mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
Extends UI element tests to include signal emission verification. This ensures that UI elements correctly emit signals upon user interaction, improving the reliability and responsiveness of the UI. Adds QSignalSpy to track signal emissions for various UI components like buttons, checkboxes, comboboxes, items, sliders, textboxes and thermos.
25 lines
793 B
C++
25 lines
793 B
C++
#include "Test.hpp"
|
|
|
|
TEST(UI_slider, to_from_json)
|
|
{
|
|
UI_slider slider("slider_text", Color(255, 255, 255), Color(0, 0, 0), 0, 100, 50, nullptr);
|
|
json j = slider.to_json(0);
|
|
UI_slider slider2;
|
|
slider2.from_json(j);
|
|
EXPECT_EQ(slider.text(), slider2.text());
|
|
EXPECT_EQ(slider.fg_color(), slider2.fg_color());
|
|
EXPECT_EQ(slider.bg_color(), slider2.bg_color());
|
|
EXPECT_EQ(slider.value(), slider2.value());
|
|
}
|
|
|
|
TEST(UI_slider, value)
|
|
{
|
|
UI_slider slider("slider_text", Color(255, 255, 255), Color(0, 0, 0), 0, 100, 50);
|
|
QSignalSpy spy_ui(&slider, &UI_slider::ui_changed);
|
|
QSignalSpy spy_value(&slider, &UI_slider::changed);
|
|
EXPECT_EQ(slider.value(), 50);
|
|
slider.set_value(10);
|
|
EXPECT_EQ(spy_ui.count(), 1);
|
|
EXPECT_EQ(spy_value.count(), 1);
|
|
}
|