1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/misc/settings.cpp
3 // Purpose: test wxSettings
4 // Author: Francesco Montorsi
7 // Copyright: (c) 2009 Francesco Montorsi
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
20 #include "wx/settings.h"
21 #include "wx/fontenum.h"
25 // ----------------------------------------------------------------------------
27 // ----------------------------------------------------------------------------
29 class SettingsTestCase
: public CppUnit::TestCase
32 SettingsTestCase() { }
35 CPPUNIT_TEST_SUITE( SettingsTestCase
);
36 CPPUNIT_TEST( GetColour
);
37 CPPUNIT_TEST( GetFont
);
38 CPPUNIT_TEST( GlobalColours
);
39 CPPUNIT_TEST( GlobalFonts
);
40 CPPUNIT_TEST( GlobalBrushes
);
41 CPPUNIT_TEST( GlobalPens
);
42 CPPUNIT_TEST_SUITE_END();
47 // not really wxSystemSettings stuff but still nice to test:
53 DECLARE_NO_COPY_CLASS(SettingsTestCase
)
56 // register in the unnamed registry so that these tests are run by default
57 CPPUNIT_TEST_SUITE_REGISTRATION( SettingsTestCase
);
59 // also include in it's own registry so that these tests can be run alone
60 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SettingsTestCase
, "SettingsTestCase" );
63 void SettingsTestCase::GetColour()
65 for (unsigned int i
=wxSYS_COLOUR_SCROLLBAR
; i
< wxSYS_COLOUR_MAX
; i
++)
66 CPPUNIT_ASSERT( wxSystemSettings::GetColour((wxSystemColour
)i
).IsOk() );
69 void SettingsTestCase::GetFont()
71 const wxSystemFont ids
[] =
74 wxSYS_ANSI_FIXED_FONT
,
77 wxSYS_DEVICE_DEFAULT_FONT
,
78 wxSYS_SYSTEM_FIXED_FONT
,
79 wxSYS_DEFAULT_GUI_FONT
82 for (unsigned int i
=0; i
< WXSIZEOF(ids
); i
++)
84 const wxFont
& font
= wxSystemSettings::GetFont(ids
[i
]);
85 CPPUNIT_ASSERT( font
.IsOk() &&
86 wxFontEnumerator::IsValidFacename(font
.GetFaceName()) );
90 void SettingsTestCase::GlobalColours()
103 for (unsigned int i
=0; i
< WXSIZEOF(col
); i
++)
104 CPPUNIT_ASSERT( col
[i
].IsOk() );
107 void SettingsTestCase::GlobalFonts()
109 const wxFont font
[] =
117 for (unsigned int i
=0; i
< WXSIZEOF(font
); i
++)
119 CPPUNIT_ASSERT( font
[i
].IsOk() );
121 const wxString facename
= font
[i
].GetFaceName();
122 if ( !facename
.empty() )
125 ("font #%u: facename \"%s\" is invalid", i
, facename
),
126 wxFontEnumerator::IsValidFacename(facename
)
132 void SettingsTestCase::GlobalBrushes()
142 *wxMEDIUM_GREY_BRUSH
,
144 *wxTRANSPARENT_BRUSH
,
148 for (unsigned int i
=0; i
< WXSIZEOF(brush
); i
++)
149 CPPUNIT_ASSERT( brush
[i
].IsOk() );
152 void SettingsTestCase::GlobalPens()
169 for (unsigned int i
=0; i
< WXSIZEOF(pen
); i
++)
170 CPPUNIT_ASSERT( pen
[i
].IsOk() );