]>
git.saurik.com Git - wxWidgets.git/blob - tests/misc/module.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/misc/module.cpp
3 // Purpose: Test wxModule
4 // Author: Francesco Montorsi (extracted from console sample)
6 // Copyright: (c) 2010 wxWidgets team
7 ///////////////////////////////////////////////////////////////////////////////
9 // ----------------------------------------------------------------------------
11 // ----------------------------------------------------------------------------
19 #include "wx/module.h"
20 #include "wx/wxcrt.h" // for wxStrcat()
22 // ----------------------------------------------------------------------------
23 // test classes derived from wxModule
24 // ----------------------------------------------------------------------------
26 char g_strLoadOrder
[256] = "\0";
28 class Module
: public wxModule
31 virtual bool OnInit() { wxStrcat(g_strLoadOrder
, GetClassInfo()->GetClassName()); return true; }
32 virtual void OnExit() { }
35 class ModuleA
: public Module
40 DECLARE_DYNAMIC_CLASS(ModuleA
)
43 class ModuleB
: public Module
48 DECLARE_DYNAMIC_CLASS(ModuleB
)
51 class ModuleC
: public Module
56 DECLARE_DYNAMIC_CLASS(ModuleC
)
59 class ModuleD
: public Module
64 DECLARE_DYNAMIC_CLASS(ModuleD
)
67 IMPLEMENT_DYNAMIC_CLASS(ModuleA
, wxModule
)
70 AddDependency(CLASSINFO(ModuleB
));
71 AddDependency(CLASSINFO(ModuleD
));
74 IMPLEMENT_DYNAMIC_CLASS(ModuleB
, wxModule
)
77 AddDependency(CLASSINFO(ModuleC
));
78 AddDependency(CLASSINFO(ModuleD
));
81 IMPLEMENT_DYNAMIC_CLASS(ModuleC
, wxModule
)
84 AddDependency(CLASSINFO(ModuleD
));
87 IMPLEMENT_DYNAMIC_CLASS(ModuleD
, wxModule
)
92 // ----------------------------------------------------------------------------
94 // ----------------------------------------------------------------------------
96 class ModuleTestCase
: public CppUnit::TestCase
102 CPPUNIT_TEST_SUITE( ModuleTestCase
);
103 CPPUNIT_TEST( LoadOrder
);
104 CPPUNIT_TEST_SUITE_END();
107 DECLARE_NO_COPY_CLASS(ModuleTestCase
)
110 // register in the unnamed registry so that these tests are run by default
111 CPPUNIT_TEST_SUITE_REGISTRATION( ModuleTestCase
);
113 // also include in its own registry so that these tests can be run alone
114 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ModuleTestCase
, "ModuleTestCase" );
116 void ModuleTestCase::LoadOrder()
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
);