2023-01-11 10:21:18 +00:00
|
|
|
#include "TestUiApplication.h"
|
|
|
|
#include "TestFramework.h"
|
2023-01-17 08:34:48 +00:00
|
|
|
#include "TestRenderUtils.h"
|
|
|
|
#include "TestUtils.h"
|
2023-01-11 10:21:18 +00:00
|
|
|
|
2023-01-12 11:54:08 +00:00
|
|
|
#include "RectangleNode.h"
|
2023-01-11 10:21:18 +00:00
|
|
|
#include "TextNode.h"
|
|
|
|
|
2023-01-17 08:34:48 +00:00
|
|
|
#include "Button.h"
|
|
|
|
#include "TransformNode.h"
|
|
|
|
|
2023-01-11 10:21:18 +00:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
TEST_CASE(TestD2dRendering, "graphics")
|
|
|
|
{
|
2023-01-12 11:54:08 +00:00
|
|
|
auto gui_app = TestCaseRunner::getInstance().getTestApplication();
|
|
|
|
auto scene = gui_app->getMainWindowScene();
|
|
|
|
|
|
|
|
auto rect = std::make_unique<RectangleNode>(Point(10, 10), 200.0, 200.0);
|
|
|
|
scene->addNode(rect.get());
|
|
|
|
|
|
|
|
auto text_node = std::make_unique<TextNode>("Test2", Point(100, 100));
|
|
|
|
scene->addNode(text_node.get());
|
2023-01-11 10:21:18 +00:00
|
|
|
|
2023-01-12 11:54:08 +00:00
|
|
|
scene->update();
|
2023-01-17 08:34:48 +00:00
|
|
|
gui_app->run();
|
|
|
|
};
|
|
|
|
|
|
|
|
TEST_CASE(TestD2dWidgetRendering, "graphics")
|
|
|
|
{
|
|
|
|
auto gui_app = TestCaseRunner::getInstance().getTestApplication();
|
|
|
|
auto scene = gui_app->getMainWindowScene();
|
|
|
|
|
|
|
|
Widget widget;
|
|
|
|
widget.setBackgroundColor({ 0, 200, 0 });
|
|
|
|
widget.setBounds(300, 300);
|
|
|
|
|
|
|
|
auto button = Button::Create();
|
|
|
|
button->setBackgroundColor({ 200, 0, 0 });
|
|
|
|
button->setLabel("Test Button");
|
|
|
|
button->setMaxWidth(100);
|
|
|
|
|
|
|
|
widget.addWidget(std::move(button));
|
|
|
|
widget.onPaintEvent(nullptr);
|
|
|
|
|
|
|
|
scene->addNode(widget.getRootNode());
|
|
|
|
|
|
|
|
scene->update();
|
|
|
|
|
|
|
|
TestRenderer::writeSvg(TestUtils::getTestOutputDir(__FILE__) / "TestD2dWidgetRendering.svg", scene);
|
|
|
|
|
2023-01-12 11:54:08 +00:00
|
|
|
gui_app->run();
|
2023-01-11 10:21:18 +00:00
|
|
|
};
|