]> git.saurik.com Git - wxWidgets.git/blob - tests/misc/settings.cpp
Fix wxDocManager::GetLastDirectory() when there is no history.
[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 it's 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 CPPUNIT_ASSERT( wxFontEnumerator::IsValidFacename(facename) );
124 }
125 }
126
127 void SettingsTestCase::GlobalBrushes()
128 {
129 wxBrush brush[] =
130 {
131 *wxBLACK_BRUSH,
132 *wxBLUE_BRUSH,
133 *wxCYAN_BRUSH,
134 *wxGREEN_BRUSH,
135 *wxGREY_BRUSH,
136 *wxLIGHT_GREY_BRUSH,
137 *wxMEDIUM_GREY_BRUSH,
138 *wxRED_BRUSH,
139 *wxTRANSPARENT_BRUSH,
140 *wxWHITE_BRUSH
141 };
142
143 for (unsigned int i=0; i < WXSIZEOF(brush); i++)
144 CPPUNIT_ASSERT( brush[i].IsOk() );
145 }
146
147 void SettingsTestCase::GlobalPens()
148 {
149 wxPen pen[] =
150 {
151 *wxBLACK_DASHED_PEN,
152 *wxBLACK_PEN,
153 *wxBLUE_PEN,
154 *wxCYAN_PEN,
155 *wxGREEN_PEN,
156 *wxGREY_PEN,
157 *wxLIGHT_GREY_PEN,
158 *wxMEDIUM_GREY_PEN,
159 *wxRED_PEN,
160 *wxTRANSPARENT_PEN,
161 *wxWHITE_PEN
162 };
163
164 for (unsigned int i=0; i < WXSIZEOF(pen); i++)
165 CPPUNIT_ASSERT( pen[i].IsOk() );
166 }