]> git.saurik.com Git - wxWidgets.git/blame - tests/misc/settings.cpp
return a wxAnyStrPtr covnertible to either narrow or wide char pointer from wxDateTim...
[wxWidgets.git] / tests / misc / settings.cpp
CommitLineData
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"
22
23// ----------------------------------------------------------------------------
24// test class
25// ----------------------------------------------------------------------------
26
27class SettingsTestCase : public CppUnit::TestCase
28{
29public:
30 SettingsTestCase() { }
31
32private:
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();
41
42 void GetColour();
43 void GetFont();
44
45 // not really wxSystemSettings stuff but still nice to test:
46 void GlobalColours();
47 void GlobalFonts();
48 void GlobalBrushes();
49 void GlobalPens();
50
51 DECLARE_NO_COPY_CLASS(SettingsTestCase)
52};
53
54// register in the unnamed registry so that these tests are run by default
55CPPUNIT_TEST_SUITE_REGISTRATION( SettingsTestCase );
56
57// also include in it's own registry so that these tests can be run alone
58CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( SettingsTestCase, "SettingsTestCase" );
59
60
61void SettingsTestCase::GetColour()
62{
63 for (unsigned int i=wxSYS_COLOUR_SCROLLBAR; i < wxSYS_COLOUR_MAX; i++)
64 CPPUNIT_ASSERT( wxSystemSettings::GetColour((wxSystemColour)i).IsOk() );
65}
66
67void SettingsTestCase::GetFont()
68{
69 const wxSystemFont ids[] =
70 {
71 wxSYS_OEM_FIXED_FONT,
72 wxSYS_ANSI_FIXED_FONT,
73 wxSYS_ANSI_VAR_FONT,
74 wxSYS_SYSTEM_FONT,
75 wxSYS_DEVICE_DEFAULT_FONT,
76 wxSYS_SYSTEM_FIXED_FONT,
77 wxSYS_DEFAULT_GUI_FONT
78 };
79
80 for (unsigned int i=0; i < WXSIZEOF(ids); i++)
81 {
82 const wxFont& font = wxSystemSettings::GetFont(ids[i]);
83 CPPUNIT_ASSERT( font.IsOk() &&
84 wxFontEnumerator::IsValidFacename(font.GetFaceName()) );
85 }
86}
87
88void SettingsTestCase::GlobalColours()
89{
90 wxColour col[] =
91 {
92 *wxBLACK,
93 *wxBLUE,
94 *wxCYAN,
95 *wxGREEN,
96 *wxLIGHT_GREY,
97 *wxRED,
98 *wxWHITE
99 };
100
101 for (unsigned int i=0; i < WXSIZEOF(col); i++)
102 CPPUNIT_ASSERT( col[i].IsOk() );
103}
104
105void SettingsTestCase::GlobalFonts()
106{
107 wxFont font[] =
108 {
109 *wxNORMAL_FONT,
110 *wxSMALL_FONT,
111 *wxITALIC_FONT,
112 *wxSWISS_FONT
113 };
114
115 for (unsigned int i=0; i < WXSIZEOF(font); i++)
116 CPPUNIT_ASSERT( font[i].IsOk() &&
117 wxFontEnumerator::IsValidFacename(font[i].GetFaceName()) );
118}
119
120void SettingsTestCase::GlobalBrushes()
121{
122 wxBrush brush[] =
123 {
124 *wxBLACK_BRUSH,
125 *wxBLUE_BRUSH,
126 *wxCYAN_BRUSH,
127 *wxGREEN_BRUSH,
128 *wxGREY_BRUSH,
129 *wxLIGHT_GREY_BRUSH,
130 *wxMEDIUM_GREY_BRUSH,
131 *wxRED_BRUSH,
132 *wxTRANSPARENT_BRUSH,
133 *wxWHITE_BRUSH
134 };
135
136 for (unsigned int i=0; i < WXSIZEOF(brush); i++)
137 CPPUNIT_ASSERT( brush[i].IsOk() );
138}
139
140void SettingsTestCase::GlobalPens()
141{
142 wxPen pen[] =
143 {
144 *wxBLACK_DASHED_PEN,
145 *wxBLACK_PEN,
146 *wxBLUE_PEN,
147 *wxCYAN_PEN,
148 *wxGREEN_PEN,
149 *wxGREY_PEN,
150 *wxLIGHT_GREY_PEN,
151 *wxMEDIUM_GREY_PEN,
152 *wxRED_PEN,
153 *wxTRANSPARENT_PEN,
154 *wxWHITE_PEN
155 };
156
157 for (unsigned int i=0; i < WXSIZEOF(pen); i++)
158 CPPUNIT_ASSERT( pen[i].IsOk() );
159}