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"
23 // ----------------------------------------------------------------------------
25 // ----------------------------------------------------------------------------
27 class SettingsTestCase
: public CppUnit::TestCase
30 SettingsTestCase() { }
33 CPPUNIT_TEST_SUITE( SettingsTestCase
);
34 CPPUNIT_TEST( GetColour
);
35 CPPUNIT_TEST( GetFont
);
36 CPPUNIT_TEST( GlobalColours
);
37 CPPUNIT_TEST( GlobalFonts
);
38 CPPUNIT_TEST( GlobalBrushes
);
39 CPPUNIT_TEST( GlobalPens
);
40 CPPUNIT_TEST_SUITE_END();
45 // not really wxSystemSettings stuff but still nice to test:
51 DECLARE_NO_COPY_CLASS(SettingsTestCase
)
54 // register in the unnamed registry so that these tests are run by default
55 CPPUNIT_TEST_SUITE_REGISTRATION( SettingsTestCase
);
57 // also include in it's own registry so that these tests can be run alone
58 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SettingsTestCase
, "SettingsTestCase" );
61 void SettingsTestCase::GetColour()
63 for (unsigned int i
=wxSYS_COLOUR_SCROLLBAR
; i
< wxSYS_COLOUR_MAX
; i
++)
64 CPPUNIT_ASSERT( wxSystemSettings::GetColour((wxSystemColour
)i
).IsOk() );
67 void SettingsTestCase::GetFont()
69 const wxSystemFont ids
[] =
72 wxSYS_ANSI_FIXED_FONT
,
75 wxSYS_DEVICE_DEFAULT_FONT
,
76 wxSYS_SYSTEM_FIXED_FONT
,
77 wxSYS_DEFAULT_GUI_FONT
80 for (unsigned int i
=0; i
< WXSIZEOF(ids
); i
++)
82 const wxFont
& font
= wxSystemSettings::GetFont(ids
[i
]);
83 CPPUNIT_ASSERT( font
.IsOk() &&
84 wxFontEnumerator::IsValidFacename(font
.GetFaceName()) );
88 void SettingsTestCase::GlobalColours()
101 for (unsigned int i
=0; i
< WXSIZEOF(col
); i
++)
102 CPPUNIT_ASSERT( col
[i
].IsOk() );
105 void SettingsTestCase::GlobalFonts()
115 for (unsigned int i
=0; i
< WXSIZEOF(font
); i
++)
116 CPPUNIT_ASSERT( font
[i
].IsOk() &&
117 wxFontEnumerator::IsValidFacename(font
[i
].GetFaceName()) );
120 void SettingsTestCase::GlobalBrushes()
130 *wxMEDIUM_GREY_BRUSH
,
132 *wxTRANSPARENT_BRUSH
,
136 for (unsigned int i
=0; i
< WXSIZEOF(brush
); i
++)
137 CPPUNIT_ASSERT( brush
[i
].IsOk() );
140 void SettingsTestCase::GlobalPens()
157 for (unsigned int i
=0; i
< WXSIZEOF(pen
); i
++)
158 CPPUNIT_ASSERT( pen
[i
].IsOk() );