stuff-from-scratch/test/graphics/TestD2dRendering.cpp
2023-01-17 08:34:48 +00:00

55 lines
No EOL
1.3 KiB
C++

#include "TestUiApplication.h"
#include "TestFramework.h"
#include "TestRenderUtils.h"
#include "TestUtils.h"
#include "RectangleNode.h"
#include "TextNode.h"
#include "Button.h"
#include "TransformNode.h"
#include <memory>
#include <string>
#include <iostream>
TEST_CASE(TestD2dRendering, "graphics")
{
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());
scene->update();
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);
gui_app->run();
};