Skip to content

Commit

Permalink
Update datafiletests.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
nlogozzo committed Sep 2, 2024
1 parent c573e4e commit dfa26fc
Showing 1 changed file with 27 additions and 3 deletions.
30 changes: 27 additions & 3 deletions tests/datafiletests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,16 @@ class AppConfig : public DataFileBase
m_json["WindowGeometry"]["Height"] = static_cast<Json::Int64>(geometry.getHeight());
m_json["WindowGeometry"]["IsMaximized"] = geometry.isMaximized();
}

bool getAutomaticallyCheckForUpdates() const
{
return m_json.get("AutomaticallyCheckForUpdates", true).asBool();
}

void setAutomaticallyCheckForUpdates(bool value)
{
m_json["AutomaticallyCheckForUpdates"] = value;
}
};

class DataFileTest : public testing::Test
Expand All @@ -74,13 +84,14 @@ TEST_F(DataFileTest, EnsureDefaultAppConfig)
ASSERT_EQ(geometry.getWidth(), 800);
ASSERT_EQ(geometry.getHeight(), 600);
ASSERT_EQ(geometry.isMaximized(), false);
ASSERT_EQ(config.getAutomaticallyCheckForUpdates(), true);
}

TEST_F(DataFileTest, ChangeAppConfig)
TEST_F(DataFileTest, ChangeAppConfig1)
{
AppConfig& config{m_manager->get<AppConfig>("config") };
config.setTheme(Theme::Light);
config.setWindowGeometry(WindowGeometry{ 1920, 1080, true });
ASSERT_NO_THROW(config.setTheme(Theme::Light));
ASSERT_NO_THROW(config.setWindowGeometry(WindowGeometry{ 1920, 1080, true }));
ASSERT_TRUE(config.save());
}

Expand All @@ -92,4 +103,17 @@ TEST_F(DataFileTest, EnsureChangeInAppConfig)
ASSERT_EQ(geometry.getWidth(), 1920);
ASSERT_EQ(geometry.getHeight(), 1080);
ASSERT_EQ(geometry.isMaximized(), true);
}

TEST_F(DataFileTest, ChangeAppConfig2)
{
AppConfig& config{ m_manager->get<AppConfig>("config") };
ASSERT_NO_THROW(config.setAutomaticallyCheckForUpdates(false));
ASSERT_TRUE(config.save());
}

TEST_F(DataFileTest, EnsureChangeInAppConfig2)
{
AppConfig& config{ m_manager->get<AppConfig>("config") };
ASSERT_EQ(config.getAutomaticallyCheckForUpdates(), false);
}

0 comments on commit dfa26fc

Please sign in to comment.