mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-26 21:51:13 +01:00
b server tests
This commit is contained in:
+1
-1
@@ -24,7 +24,7 @@ bool UI_item::is_type(json j)
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return magic_enum::enum_cast<UI_enum>(j.at("type")).value_or(UI_enum::end) == m_type;
|
return magic_enum::enum_cast<UI_enum>((std::string)j.at("type")).value_or(UI_enum::end) == m_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UI_item::set_text(std::string text)
|
void UI_item::set_text(std::string text)
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ if (GTest_FOUND)
|
|||||||
target_link_libraries(tests
|
target_link_libraries(tests
|
||||||
PRIVATE
|
PRIVATE
|
||||||
UI
|
UI
|
||||||
|
UI_enum
|
||||||
gtest
|
gtest
|
||||||
magic_enum::magic_enum
|
magic_enum::magic_enum
|
||||||
GTest::gtest_main
|
GTest::gtest_main
|
||||||
|
|||||||
+11
-10
@@ -1,24 +1,25 @@
|
|||||||
#include "ui_item.hpp"
|
#include "ui_item.hpp"
|
||||||
|
#include "ui_enum.hpp"
|
||||||
#include <QSignalSpy>
|
#include <QSignalSpy>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
TEST(UI_item, is_type)
|
TEST(UI_item, is_type)
|
||||||
{
|
{
|
||||||
UI_item item(std::string("item"));
|
UI_item item(UI_enum::end);
|
||||||
json j = {{"type", "item"}};
|
json j = {{"type", "end"}};
|
||||||
EXPECT_TRUE(item.is_type(j));
|
EXPECT_TRUE(item.is_type(j));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(UI_item, set_text)
|
TEST(UI_item, set_text)
|
||||||
{
|
{
|
||||||
UI_item item(std::string("item"));
|
UI_item item(UI_enum::end);
|
||||||
item.set_text("text");
|
item.set_text("text");
|
||||||
EXPECT_EQ(item.text(), "text");
|
EXPECT_EQ(item.text(), "text");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(UI_item, set_fg_color)
|
TEST(UI_item, set_fg_color)
|
||||||
{
|
{
|
||||||
UI_item item(std::string("item"));
|
UI_item item(UI_enum::end);
|
||||||
item.set_fg_color(Color(0, 0, 0));
|
item.set_fg_color(Color(0, 0, 0));
|
||||||
EXPECT_EQ(item.fg_color(), Color(0, 0, 0));
|
EXPECT_EQ(item.fg_color(), Color(0, 0, 0));
|
||||||
|
|
||||||
@@ -28,7 +29,7 @@ TEST(UI_item, set_fg_color)
|
|||||||
|
|
||||||
TEST(UI_item, set_bg_color)
|
TEST(UI_item, set_bg_color)
|
||||||
{
|
{
|
||||||
UI_item item(std::string("item"));
|
UI_item item(UI_enum::end);
|
||||||
item.set_bg_color(Color(0, 0, 0));
|
item.set_bg_color(Color(0, 0, 0));
|
||||||
EXPECT_EQ(item.bg_color(), Color(0, 0, 0));
|
EXPECT_EQ(item.bg_color(), Color(0, 0, 0));
|
||||||
|
|
||||||
@@ -38,10 +39,10 @@ TEST(UI_item, set_bg_color)
|
|||||||
|
|
||||||
TEST(UI_item, from_json)
|
TEST(UI_item, from_json)
|
||||||
{
|
{
|
||||||
UI_item item(std::string("item"));
|
UI_item item(UI_enum::end);
|
||||||
json j;
|
json j;
|
||||||
j["id"] = 0;
|
j["id"] = 0;
|
||||||
j["type"] = "item";
|
j["type"] = "end";
|
||||||
j["text"] = "item_text";
|
j["text"] = "item_text";
|
||||||
j["text_size"] = 12;
|
j["text_size"] = 12;
|
||||||
j["fg_color"] = "0xFFFFFFFF";
|
j["fg_color"] = "0xFFFFFFFF";
|
||||||
@@ -57,9 +58,9 @@ TEST(UI_item, from_json)
|
|||||||
|
|
||||||
TEST(UI_item, to_json)
|
TEST(UI_item, to_json)
|
||||||
{
|
{
|
||||||
UI_item item("item", "item_text", Color(255, 255, 255), Color(0, 0, 0));
|
UI_item item(UI_enum::end, "item_text", Color(255, 255, 255), Color(0, 0, 0));
|
||||||
json j = item.to_json(0);
|
json j = item.to_json(0);
|
||||||
EXPECT_EQ(j.at("type"), "item");
|
EXPECT_EQ(j.at("type"), "end");
|
||||||
EXPECT_EQ(j.at("id"), 0);
|
EXPECT_EQ(j.at("id"), 0);
|
||||||
EXPECT_EQ(j.at("text"), "item_text");
|
EXPECT_EQ(j.at("text"), "item_text");
|
||||||
EXPECT_EQ(j.at("fg_color"), Color(255, 255, 255).to_hex());
|
EXPECT_EQ(j.at("fg_color"), Color(255, 255, 255).to_hex());
|
||||||
@@ -68,7 +69,7 @@ TEST(UI_item, to_json)
|
|||||||
|
|
||||||
TEST(UI_item, signal)
|
TEST(UI_item, signal)
|
||||||
{
|
{
|
||||||
UI_item item("item", "item_text", Color(255, 255, 255), Color(0, 0, 0));
|
UI_item item(UI_enum::end, "item_text", Color(255, 255, 255), Color(0, 0, 0));
|
||||||
QSignalSpy spy(&item, &UI_item::ui_changed);
|
QSignalSpy spy(&item, &UI_item::ui_changed);
|
||||||
item.set_text("text");
|
item.set_text("text");
|
||||||
item.append_text(" ");
|
item.append_text(" ");
|
||||||
|
|||||||
Reference in New Issue
Block a user