]>
git.saurik.com Git - wxWidgets.git/blob - tests/misc/module.cpp
3566010273649d12bf34ddfd5be84d53902d682c
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: tests/misc/module.cpp
3 // Purpose: Test wxModule
4 // Author: Francesco Montorsi (extracted from console sample)
7 // Copyright: (c) 2010 wxWidgets team
8 ///////////////////////////////////////////////////////////////////////////////
10 // ----------------------------------------------------------------------------
12 // ----------------------------------------------------------------------------
20 #include "wx/module.h"
21 #include "wx/wxcrt.h" // for wxStrcat()
23 // ----------------------------------------------------------------------------
24 // test classes derived from wxModule
25 // ----------------------------------------------------------------------------
27 char g_strLoadOrder
[256] = "\0";
29 class Module
: public wxModule
32 virtual bool OnInit() { wxStrcat(g_strLoadOrder
, GetClassInfo()->GetClassName()); return true; }
33 virtual void OnExit() { }
36 class ModuleA
: public Module
41 DECLARE_DYNAMIC_CLASS(ModuleA
)
44 class ModuleB
: public Module
49 DECLARE_DYNAMIC_CLASS(ModuleB
)
52 class ModuleC
: public Module
57 DECLARE_DYNAMIC_CLASS(ModuleC
)
60 class ModuleD
: public Module
65 DECLARE_DYNAMIC_CLASS(ModuleD
)
68 IMPLEMENT_DYNAMIC_CLASS(ModuleA
, wxModule
)
71 AddDependency(CLASSINFO(ModuleB
));
72 AddDependency(CLASSINFO(ModuleD
));
75 IMPLEMENT_DYNAMIC_CLASS(ModuleB
, wxModule
)
78 AddDependency(CLASSINFO(ModuleC
));
79 AddDependency(CLASSINFO(ModuleD
));
82 IMPLEMENT_DYNAMIC_CLASS(ModuleC
, wxModule
)
85 AddDependency(CLASSINFO(ModuleD
));
88 IMPLEMENT_DYNAMIC_CLASS(ModuleD
, wxModule
)
93 // ----------------------------------------------------------------------------
95 // ----------------------------------------------------------------------------
97 class ModuleTestCase
: public CppUnit::TestCase
103 CPPUNIT_TEST_SUITE( ModuleTestCase
);
104 CPPUNIT_TEST( LoadOrder
);
105 CPPUNIT_TEST_SUITE_END();
108 DECLARE_NO_COPY_CLASS(ModuleTestCase
)
111 // register in the unnamed registry so that these tests are run by default
112 CPPUNIT_TEST_SUITE_REGISTRATION( ModuleTestCase
);
114 // also include in its own registry so that these tests can be run alone
115 CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ModuleTestCase
, "ModuleTestCase" );
117 void ModuleTestCase::LoadOrder()
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
);