11#include < gtest/gtest.h>
22#include " app/aura.h"
3+ #include " app/windowgeometry.h"
34#include " filesystem/userdirectories.h"
45#include " notifications/shellnotification.h"
56
@@ -25,12 +26,29 @@ class AppConfig : public ConfigurationBase
2526
2627 Theme getTheme () const
2728 {
28- return ( Theme) m_json.get (" Theme" , (int )Theme::System).asInt ();
29+ return static_cast < Theme>( m_json.get (" Theme" , (int )Theme::System).asInt () );
2930 }
3031
3132 void setTheme (Theme theme)
3233 {
33- m_json[" Theme" ] = (int )theme;
34+ m_json[" Theme" ] = static_cast <int >(theme);
35+ }
36+
37+ WindowGeometry getWindowGeometry ()
38+ {
39+ WindowGeometry geometry;
40+ const Json::Value json{ m_json[" WindowGeometry" ] };
41+ geometry.setWidth (json.get (" Width" , 800 ).asInt64 ());
42+ geometry.setHeight (json.get (" Height" , 600 ).asInt64 ());
43+ geometry.setIsMaximized (json.get (" IsMaximized" , false ).asBool ());
44+ return geometry;
45+ }
46+
47+ void setWindowGeometry (const WindowGeometry& geometry)
48+ {
49+ m_json[" WindowGeometry" ][" Width" ] = static_cast <Json::Int64>(geometry.getWidth ());
50+ m_json[" WindowGeometry" ][" Height" ] = static_cast <Json::Int64>(geometry.getHeight ());
51+ m_json[" WindowGeometry" ][" IsMaximized" ] = geometry.isMaximized ();
3452 }
3553};
3654
@@ -57,21 +75,29 @@ TEST_F(AuraTest, SetAppInfo)
5775TEST_F (AuraTest, EnsureDefaultAppConfig)
5876{
5977 AppConfig& config{ Aura::getActive ().getConfig <AppConfig>(" config" ) };
78+ WindowGeometry geometry{ config.getWindowGeometry () };
6079 ASSERT_EQ (config.getTheme (), Theme::System);
80+ ASSERT_EQ (geometry.getWidth (), 800 );
81+ ASSERT_EQ (geometry.getHeight (), 600 );
82+ ASSERT_EQ (geometry.isMaximized (), false );
6183}
6284
6385TEST_F (AuraTest, ChangeAppConfig)
6486{
6587 AppConfig& config{ Aura::getActive ().getConfig <AppConfig>(" config" ) };
6688 config.setTheme (Theme::Light);
89+ config.setWindowGeometry (WindowGeometry{ 1920 , 1080 , true });
6790 ASSERT_TRUE (config.save ());
68- ASSERT_EQ (config.getTheme (), Theme::Light);
6991}
7092
7193TEST_F (AuraTest, EnsureChangeInAppConfig)
7294{
7395 AppConfig& config{ Aura::getActive ().getConfig <AppConfig>(" config" ) };
7496 ASSERT_EQ (config.getTheme (), Theme::Light);
97+ WindowGeometry geometry{ config.getWindowGeometry () };
98+ ASSERT_EQ (geometry.getWidth (), 1920 );
99+ ASSERT_EQ (geometry.getHeight (), 1080 );
100+ ASSERT_EQ (geometry.isMaximized (), true );
75101}
76102
77103TEST_F (AuraTest, ResetAppConfig)
0 commit comments