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