stuff-from-scratch/test/graphics/TestD2dRendering.cpp
2023-01-20 08:07:09 +00:00

53 lines
No EOL
1.2 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>(Transform(Point(10, 10)), 200.0, 200.0);
scene->addNode(rect.get());
auto text_node = std::make_unique<TextNode>("Test2", Transform(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.setBounds(300, 300);
auto button = Button::Create();
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();
};