]>
Commit | Line | Data |
---|---|---|
e3527f7b FM |
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" | |
8057186b FM |
22 | #include "wx/brush.h" |
23 | #include "wx/pen.h" | |
e3527f7b FM |
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 | 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 | CPPUNIT_ASSERT( font[i].IsOk() && | |
119 | wxFontEnumerator::IsValidFacename(font[i].GetFaceName()) ); | |
120 | } | |
121 | ||
122 | void SettingsTestCase::GlobalBrushes() | |
123 | { | |
124 | wxBrush brush[] = | |
125 | { | |
126 | *wxBLACK_BRUSH, | |
127 | *wxBLUE_BRUSH, | |
128 | *wxCYAN_BRUSH, | |
129 | *wxGREEN_BRUSH, | |
130 | *wxGREY_BRUSH, | |
131 | *wxLIGHT_GREY_BRUSH, | |
132 | *wxMEDIUM_GREY_BRUSH, | |
133 | *wxRED_BRUSH, | |
134 | *wxTRANSPARENT_BRUSH, | |
135 | *wxWHITE_BRUSH | |
136 | }; | |
137 | ||
138 | for (unsigned int i=0; i < WXSIZEOF(brush); i++) | |
139 | CPPUNIT_ASSERT( brush[i].IsOk() ); | |
140 | } | |
141 | ||
142 | void SettingsTestCase::GlobalPens() | |
143 | { | |
144 | wxPen pen[] = | |
145 | { | |
146 | *wxBLACK_DASHED_PEN, | |
147 | *wxBLACK_PEN, | |
148 | *wxBLUE_PEN, | |
149 | *wxCYAN_PEN, | |
150 | *wxGREEN_PEN, | |
151 | *wxGREY_PEN, | |
152 | *wxLIGHT_GREY_PEN, | |
153 | *wxMEDIUM_GREY_PEN, | |
154 | *wxRED_PEN, | |
155 | *wxTRANSPARENT_PEN, | |
156 | *wxWHITE_PEN | |
157 | }; | |
158 | ||
159 | for (unsigned int i=0; i < WXSIZEOF(pen); i++) | |
160 | CPPUNIT_ASSERT( pen[i].IsOk() ); | |
161 | } |