Files
remote-ui/tests/UI_combobox.cpp
T
sani7 89ca146e97 Adds signal testing to UI elements
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.
2026-02-14 14:32:17 +01:00

22 lines
686 B
C++

#include "Test.hpp"
TEST(UI_combobox, to_from_json)
{
UI_combobox combobox(Color(255, 255, 255), Color(0, 0, 0), {"option1", "option2"});
json j = combobox.to_json(0);
UI_combobox combobox2;
combobox2.from_json(j);
EXPECT_EQ(combobox.text(), combobox2.text());
EXPECT_EQ(combobox.fg_color(), combobox2.fg_color());
EXPECT_EQ(combobox.bg_color(), combobox2.bg_color());
EXPECT_EQ(combobox.selected(), combobox2.selected());
}
TEST(UI_combobox, signal)
{
UI_combobox combobox(Color::Default, Color::Default, {"option1", "option2"});
QSignalSpy spy(&combobox, &UI_combobox::changed);
combobox.set_selected(1);
EXPECT_EQ(spy.count(), 1);
}