]> git.saurik.com Git - wxWidgets.git/blob - tests/misc/settings.cpp
Add CombineURIs implementation for wxWebFileProtocolHandler. Update the IE backend...
[wxWidgets.git] / tests / misc / settings.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/misc/settings.cpp
3 // Purpose: test wxSettings
4 // Author: Francesco Montorsi
5 // Created: 2009-03-24
6 // RCS-ID: $Id$
7 // Copyright: (c) 2009 Francesco Montorsi
8 ///////////////////////////////////////////////////////////////////////////////
9
10 // ----------------------------------------------------------------------------
11 // headers
12 // ----------------------------------------------------------------------------
13
14 #include "testprec.h"
15
16 #ifdef __BORLANDC__
17 #pragma hdrstop
18 #endif
19
20 #include "wx/settings.h"
21 #include "wx/fontenum.h"
22 #include "wx/brush.h"
23 #include "wx/pen.h"
24
25 // ----------------------------------------------------------------------------
26 // test class
27 // ----------------------------------------------------------------------------
28
29 class SettingsTestCase : public CppUnit::TestCase
30 {
31 public:
32 SettingsTestCase() { }
33
34 private:
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();
43
44 void GetColour();
45 void GetFont();
46
47 // not really wxSystemSettings stuff but still nice to test:
48 void GlobalColours();
49 void GlobalFonts();
50 void GlobalBrushes();
51 void GlobalPens();
52
53 DECLARE_NO_COPY_CLASS(SettingsTestCase)
54 };
55
56 // register in the unnamed registry so that these tests are run by default
57 CPPUNIT_TEST_SUITE_REGISTRATION( SettingsTestCase );
58
59 // also include in its own registry so that these tests can be run alone
60 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SettingsTestCase, "SettingsTestCase" );
61
62
63 void SettingsTestCase::GetColour()
64 {
65 for (unsigned int i=wxSYS_COLOUR_SCROLLBAR; i < wxSYS_COLOUR_MAX; i++)
66 CPPUNIT_ASSERT( wxSystemSettings::GetColour((wxSystemColour)i).IsOk() );
67 }
68
69 void SettingsTestCase::GetFont()
70 {
71 const wxSystemFont ids[] =
72 {
73 wxSYS_OEM_FIXED_FONT,
74 wxSYS_ANSI_FIXED_FONT,
75 wxSYS_ANSI_VAR_FONT,
76 wxSYS_SYSTEM_FONT,
77 wxSYS_DEVICE_DEFAULT_FONT,
78 wxSYS_SYSTEM_FIXED_FONT,
79 wxSYS_DEFAULT_GUI_FONT
80 };
81
82 for (unsigned int i=0; i < WXSIZEOF(ids); i++)
83 {
84 const wxFont& font = wxSystemSettings::GetFont(ids[i]);
85 CPPUNIT_ASSERT( font.IsOk() &&
86 wxFontEnumerator::IsValidFacename(font.GetFaceName()) );
87 }
88 }
89
90 void SettingsTestCase::GlobalColours()
91 {
92 wxColour col[] =
93 {
94 *wxBLACK,
95 *wxBLUE,
96 *wxCYAN,
97 *wxGREEN,
98 *wxLIGHT_GREY,
99 *wxRED,
100 *wxWHITE
101 };
102
103 for (unsigned int i=0; i < WXSIZEOF(col); i++)
104 CPPUNIT_ASSERT( col[i].IsOk() );
105 }
106
107 void SettingsTestCase::GlobalFonts()
108 {
109 const wxFont font[] =
110 {
111 *wxNORMAL_FONT,
112 *wxSMALL_FONT,
113 *wxITALIC_FONT,
114 *wxSWISS_FONT
115 };
116
117 for (unsigned int i=0; i < WXSIZEOF(font); i++)
118 {
119 CPPUNIT_ASSERT( font[i].IsOk() );
120
121 const wxString facename = font[i].GetFaceName();
122 if ( !facename.empty() )
123 {
124 WX_ASSERT_MESSAGE(
125 ("font #%u: facename \"%s\" is invalid", i, facename),
126 wxFontEnumerator::IsValidFacename(facename)
127 );
128 }
129 }
130 }
131
132 void SettingsTestCase::GlobalBrushes()
133 {
134 wxBrush brush[] =
135 {
136 *wxBLACK_BRUSH,
137 *wxBLUE_BRUSH,
138 *wxCYAN_BRUSH,
139 *wxGREEN_BRUSH,
140 *wxGREY_BRUSH,
141 *wxLIGHT_GREY_BRUSH,
142 *wxMEDIUM_GREY_BRUSH,
143 *wxRED_BRUSH,
144 *wxTRANSPARENT_BRUSH,
145 *wxWHITE_BRUSH
146 };
147
148 for (unsigned int i=0; i < WXSIZEOF(brush); i++)
149 CPPUNIT_ASSERT( brush[i].IsOk() );
150 }
151
152 void SettingsTestCase::GlobalPens()
153 {
154 wxPen pen[] =
155 {
156 *wxBLACK_DASHED_PEN,
157 *wxBLACK_PEN,
158 *wxBLUE_PEN,
159 *wxCYAN_PEN,
160 *wxGREEN_PEN,
161 *wxGREY_PEN,
162 *wxLIGHT_GREY_PEN,
163 *wxMEDIUM_GREY_PEN,
164 *wxRED_PEN,
165 *wxTRANSPARENT_PEN,
166 *wxWHITE_PEN
167 };
168
169 for (unsigned int i=0; i < WXSIZEOF(pen); i++)
170 CPPUNIT_ASSERT( pen[i].IsOk() );
171 }