1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/misc/settings.cpp
3 // Purpose: test wxSettings
4 // Author: Francesco Montorsi
6 // Copyright: (c) 2009 Francesco Montorsi
7 ///////////////////////////////////////////////////////////////////////////////
9 // ----------------------------------------------------------------------------
11 // ----------------------------------------------------------------------------
19 #include "wx/settings.h"
20 #include "wx/fontenum.h"
24 // ----------------------------------------------------------------------------
26 // ----------------------------------------------------------------------------
28 class SettingsTestCase
: public CppUnit::TestCase
31 SettingsTestCase() { }
34 CPPUNIT_TEST_SUITE( SettingsTestCase
);
35 CPPUNIT_TEST( GetColour
);
36 CPPUNIT_TEST( GetFont
);
37 CPPUNIT_TEST( GlobalColours
);
38 CPPUNIT_TEST( GlobalFonts
);
39 CPPUNIT_TEST( GlobalBrushes
);
40 CPPUNIT_TEST( GlobalPens
);
41 CPPUNIT_TEST_SUITE_END();
46 // not really wxSystemSettings stuff but still nice to test:
52 DECLARE_NO_COPY_CLASS(SettingsTestCase
)
55 // register in the unnamed registry so that these tests are run by default
56 CPPUNIT_TEST_SUITE_REGISTRATION( SettingsTestCase
);
58 // also include in its own registry so that these tests can be run alone
59 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SettingsTestCase
, "SettingsTestCase" );
62 void SettingsTestCase::GetColour()
64 for (unsigned int i
=wxSYS_COLOUR_SCROLLBAR
; i
< wxSYS_COLOUR_MAX
; i
++)
65 CPPUNIT_ASSERT( wxSystemSettings::GetColour((wxSystemColour
)i
).IsOk() );
68 void SettingsTestCase::GetFont()
70 const wxSystemFont ids
[] =
73 wxSYS_ANSI_FIXED_FONT
,
76 wxSYS_DEVICE_DEFAULT_FONT
,
77 wxSYS_SYSTEM_FIXED_FONT
,
78 wxSYS_DEFAULT_GUI_FONT
81 for (unsigned int i
=0; i
< WXSIZEOF(ids
); i
++)
83 const wxFont
& font
= wxSystemSettings::GetFont(ids
[i
]);
84 CPPUNIT_ASSERT( font
.IsOk() &&
85 wxFontEnumerator::IsValidFacename(font
.GetFaceName()) );
89 void SettingsTestCase::GlobalColours()
102 for (unsigned int i
=0; i
< WXSIZEOF(col
); i
++)
103 CPPUNIT_ASSERT( col
[i
].IsOk() );
106 void SettingsTestCase::GlobalFonts()
108 const wxFont font
[] =
116 for (unsigned int i
=0; i
< WXSIZEOF(font
); i
++)
118 CPPUNIT_ASSERT( font
[i
].IsOk() );
120 const wxString facename
= font
[i
].GetFaceName();
121 if ( !facename
.empty() )
124 ("font #%u: facename \"%s\" is invalid", i
, facename
),
125 wxFontEnumerator::IsValidFacename(facename
)
131 void SettingsTestCase::GlobalBrushes()
141 *wxMEDIUM_GREY_BRUSH
,
143 *wxTRANSPARENT_BRUSH
,
147 for (unsigned int i
=0; i
< WXSIZEOF(brush
); i
++)
148 CPPUNIT_ASSERT( brush
[i
].IsOk() );
151 void SettingsTestCase::GlobalPens()
168 for (unsigned int i
=0; i
< WXSIZEOF(pen
); i
++)
169 CPPUNIT_ASSERT( pen
[i
].IsOk() );