2023-01-18 13:29:31 +00:00
|
|
|
#include "TestFramework.h"
|
|
|
|
#include "TestUtils.h"
|
|
|
|
#include "TestRenderUtils.h"
|
|
|
|
|
|
|
|
#include "ThemeManager.h"
|
|
|
|
#include "PaintEvent.h"
|
2023-01-18 20:25:13 +00:00
|
|
|
#include "MouseEvent.h"
|
2023-01-18 13:29:31 +00:00
|
|
|
|
2023-01-18 17:31:16 +00:00
|
|
|
#include "VerticalSpacer.h"
|
2023-01-19 14:25:58 +00:00
|
|
|
#include "MediaResources.h"
|
2023-01-18 17:31:16 +00:00
|
|
|
|
2023-01-18 13:29:31 +00:00
|
|
|
#include "Button.h"
|
|
|
|
|
|
|
|
TEST_CASE(TestButton_Elevated, "ui_controls")
|
|
|
|
{
|
|
|
|
auto theme_manager = std::make_unique<ThemeManager>();
|
|
|
|
|
2023-01-18 17:31:16 +00:00
|
|
|
VerticalSpacer spacer;
|
|
|
|
spacer.setWidth(300);
|
|
|
|
spacer.setHeight(200);
|
|
|
|
|
|
|
|
auto enabled_button = Button::Create(ButtonData::Component::Elevated);
|
|
|
|
enabled_button->setLabel("Enabled");
|
2023-01-19 14:25:58 +00:00
|
|
|
enabled_button->setSvgIcon(Resource::Icon::Svg::HOME_MEDIUM);
|
2023-01-18 13:29:31 +00:00
|
|
|
|
2023-01-19 15:42:34 +00:00
|
|
|
|
2023-01-18 17:31:16 +00:00
|
|
|
auto disabled_button = Button::Create(ButtonData::Component::Elevated);
|
|
|
|
disabled_button->setEnabled(false);
|
|
|
|
disabled_button->setLabel("Disabled");
|
2023-01-19 15:42:34 +00:00
|
|
|
disabled_button->setSvgIcon(Resource::Icon::Svg::HOME_MEDIUM);
|
2023-01-18 13:29:31 +00:00
|
|
|
|
2023-01-19 15:42:34 +00:00
|
|
|
/*
|
2023-01-18 20:25:13 +00:00
|
|
|
auto pressed_button = Button::Create(ButtonData::Component::Elevated);
|
|
|
|
pressed_button->setLabel("Pressed");
|
|
|
|
|
2023-01-19 14:25:58 +00:00
|
|
|
*/
|
|
|
|
|
2023-01-18 17:31:16 +00:00
|
|
|
spacer.addWidget(std::move(enabled_button));
|
2023-01-19 15:42:34 +00:00
|
|
|
spacer.addWidget(std::move(disabled_button));
|
2023-01-19 14:25:58 +00:00
|
|
|
//spacer.addWidget(std::move(pressed_button));
|
2023-01-18 13:29:31 +00:00
|
|
|
|
2023-01-18 17:31:16 +00:00
|
|
|
auto node = spacer.getRootNode();
|
2023-01-18 13:29:31 +00:00
|
|
|
|
|
|
|
TestRenderer renderer;
|
|
|
|
renderer.getScene()->addNode(node);
|
|
|
|
|
2023-01-18 20:25:13 +00:00
|
|
|
auto mouse_event = MouseEvent::Create();
|
|
|
|
mouse_event->setAction(MouseEvent::Action::Pressed);
|
|
|
|
mouse_event->setClientLocation({ 250, 20 });
|
2023-01-19 14:25:58 +00:00
|
|
|
//spacer.onMouseEvent(mouse_event.get());
|
2023-01-18 20:25:13 +00:00
|
|
|
|
2023-01-18 17:31:16 +00:00
|
|
|
auto paint_event = PaintEvent::Create(theme_manager.get(), nullptr);
|
|
|
|
spacer.onPaintEvent(paint_event.get());
|
|
|
|
|
|
|
|
renderer.writeSvg(TestUtils::getTestOutputDir(__FILE__) / "Elevated.svg");
|
|
|
|
renderer.write(TestUtils::getTestOutputDir(__FILE__) / "Elevated.png");
|
2023-01-18 13:29:31 +00:00
|
|
|
|
|
|
|
};
|