Files
remote-ui/tests/UI_dial.cpp
T
sani7 149d27d980 Updates test includes for UI components
Updates test files to include necessary headers and removes the now unused `Test.hpp` file.
2026-02-14 14:32:21 +01:00

32 lines
889 B
C++

#include <gtest/gtest.h>
#include <QSignalSpy>
#include "ui_dial.hpp"
TEST(UI_dial, to_from_json)
{
UI_dial dial("slider_text", Color(255, 255, 255), Color(0, 0, 0), 0, 100, 50);
json j = dial.to_json(0);
UI_dial dial2;
dial2.from_json(j);
EXPECT_EQ(dial.text(), dial2.text());
EXPECT_EQ(dial.fg_color(), dial2.fg_color());
EXPECT_EQ(dial.bg_color(), dial2.bg_color());
EXPECT_EQ(dial.value(), dial2.value());
EXPECT_EQ(dial.unit(), dial2.unit());
}
TEST(UI_dial, set_value)
{
UI_dial dial("slider_text", Color(255, 255, 255), Color(0, 0, 0), 0, 100, 50);
QSignalSpy spy(&dial, &UI_dial::ui_changed);
dial.set_value(75);
EXPECT_EQ(dial.value(), 75);
EXPECT_EQ(spy.count(), 1);
}
TEST(UI_dial, unit)
{
UI_dial dial("slider_text", "unit", Color(255, 255, 255), Color(0, 0, 0), 0, 100, 50);
EXPECT_EQ(dial.unit(), "unit");
}