]> git.saurik.com Git - wxWidgets.git/blame - tests/misc/module.cpp
Convert wxFSW_EVENT_{WARNING,ERROR} to string correctly.
[wxWidgets.git] / tests / misc / module.cpp
CommitLineData
49e323a5
FM
1///////////////////////////////////////////////////////////////////////////////
2// Name: tests/misc/module.cpp
3// Purpose: Test wxModule
4// Author: Francesco Montorsi (extracted from console sample)
5// Created: 2010-06-02
6// RCS-ID: $Id$
7// Copyright: (c) 2010 wxWidgets team
8///////////////////////////////////////////////////////////////////////////////
9
10// ----------------------------------------------------------------------------
11// headers
12// ----------------------------------------------------------------------------
13
14#include "testprec.h"
15
16#ifdef __BORLANDC__
17# pragma hdrstop
18#endif
19
20#include "wx/module.h"
8e73dcda 21#include "wx/wxcrt.h" // for wxStrcat()
49e323a5
FM
22
23// ----------------------------------------------------------------------------
24// test classes derived from wxModule
25// ----------------------------------------------------------------------------
26
27char g_strLoadOrder[256] = "\0";
28
29class Module : public wxModule
30{
31protected:
32 virtual bool OnInit() { wxStrcat(g_strLoadOrder, GetClassInfo()->GetClassName()); return true; }
33 virtual void OnExit() { }
34};
35
36class ModuleA : public Module
37{
38public:
39 ModuleA();
40private:
41 DECLARE_DYNAMIC_CLASS(ModuleA)
42};
43
44class ModuleB : public Module
45{
46public:
47 ModuleB();
48private:
49 DECLARE_DYNAMIC_CLASS(ModuleB)
50};
51
52class ModuleC : public Module
53{
54public:
55 ModuleC();
56private:
57 DECLARE_DYNAMIC_CLASS(ModuleC)
58};
59
60class ModuleD : public Module
61{
62public:
63 ModuleD();
64private:
65 DECLARE_DYNAMIC_CLASS(ModuleD)
66};
67
68IMPLEMENT_DYNAMIC_CLASS(ModuleA, wxModule)
69ModuleA::ModuleA()
70{
71 AddDependency(CLASSINFO(ModuleB));
72 AddDependency(CLASSINFO(ModuleD));
73}
74
75IMPLEMENT_DYNAMIC_CLASS(ModuleB, wxModule)
76ModuleB::ModuleB()
77{
78 AddDependency(CLASSINFO(ModuleC));
79 AddDependency(CLASSINFO(ModuleD));
80}
81
82IMPLEMENT_DYNAMIC_CLASS(ModuleC, wxModule)
83ModuleC::ModuleC()
84{
85 AddDependency(CLASSINFO(ModuleD));
86}
87
88IMPLEMENT_DYNAMIC_CLASS(ModuleD, wxModule)
89ModuleD::ModuleD()
90{
91}
92
93// ----------------------------------------------------------------------------
94// test class
95// ----------------------------------------------------------------------------
96
97class ModuleTestCase : public CppUnit::TestCase
98{
99public:
100 ModuleTestCase() { }
101
102private:
103 CPPUNIT_TEST_SUITE( ModuleTestCase );
104 CPPUNIT_TEST( LoadOrder );
105 CPPUNIT_TEST_SUITE_END();
106
107 void LoadOrder();
108 DECLARE_NO_COPY_CLASS(ModuleTestCase)
109};
110
111// register in the unnamed registry so that these tests are run by default
112CPPUNIT_TEST_SUITE_REGISTRATION( ModuleTestCase );
113
e3778b4d 114// also include in its own registry so that these tests can be run alone
49e323a5
FM
115CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ModuleTestCase, "ModuleTestCase" );
116
117void ModuleTestCase::LoadOrder()
118{
119 // module D is the only one with no dependencies and so should load as first (and so on):
120 CPPUNIT_ASSERT_EQUAL( "ModuleDModuleCModuleBModuleA", g_strLoadOrder );
121}