|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Demonstrates a simple set of derived class implementations to |
|
15 // test the CRegistrar class using the test bed. |
|
16 // It may be used as a basis to develop a full test bed dll. |
|
17 // For support and comment please contact the authors. |
|
18 // |
|
19 // |
|
20 |
|
21 #include "StateAccessor.h" |
|
22 #include <test_bed/testbeddefinitions.h> |
|
23 #include <test_bed/unittest.h> |
|
24 #include <test_bed/transition.h> |
|
25 #include <test_bed/datalogger.h> |
|
26 #include "ComponentTester.h" |
|
27 |
|
28 #include "Registrar.h" |
|
29 |
|
30 #include "RegistrarTransitions.h" |
|
31 #include "RegistrarUnitTests.h" |
|
32 |
|
33 RTest test(_L("RegistrarTest.cpp")); |
|
34 |
|
35 // ______________________________________________________________________________ |
|
36 // |
|
37 /** |
|
38 @internalComponent |
|
39 Comments : Test the CRegistrar class. |
|
40 */ |
|
41 class CRegistrar_ComponentTest : public CComponentTester |
|
42 { |
|
43 public: |
|
44 /** |
|
45 @fn NewLC(CDataLogger& aDataLogger, |
|
46 MComponentTestObserver& aObserver) |
|
47 Intended Usage : Standard two-phase construction which leaves nothing on the |
|
48 cleanup stack. |
|
49 Error Condition : Leaves with the error code. |
|
50 @leave KErrNoMemory |
|
51 @since 7.0 |
|
52 @param aDataLogger The output logging object. |
|
53 @param aObserver The observer of this component test. |
|
54 @return CRegistrar_ComponentTest* The constructed object. |
|
55 @pre None. |
|
56 @post CRegistrar_ComponentTest is fully constructed. |
|
57 */ |
|
58 static CRegistrar_ComponentTest* NewLC(CDataLogger& aDataLogger, |
|
59 MComponentTestObserver& aObserver); |
|
60 |
|
61 private: |
|
62 /** |
|
63 @fn CRegistrar_ComponentTest(CDataLogger& aDataLogger, |
|
64 MComponentTestObserver& aObserver) |
|
65 Intended Usage : Standard c'tor method. |
|
66 Error Condition : None. |
|
67 @since 7.0 |
|
68 @param aDataLogger The logging object. |
|
69 @param aObserver The observer of this component test. |
|
70 @pre None. |
|
71 @post CRegistrar_ComponentTest is fully constructed. |
|
72 */ |
|
73 inline CRegistrar_ComponentTest(CDataLogger& aDataLogger, |
|
74 MComponentTestObserver& aObserver); |
|
75 /** |
|
76 @fn void ConstructL() |
|
77 Intended Usage : Second phase of safe two phase construction, |
|
78 to complete the object initialisation. |
|
79 Error Condition : Leaves with an error code. |
|
80 @leave KErrNoMemory. |
|
81 @since 7.0 |
|
82 @return None |
|
83 @pre CRegistrar_ComponentTest is fully constructed. |
|
84 @post CRegistrar_ComponentTest is fully initialised. |
|
85 */ |
|
86 inline void ConstructL(); |
|
87 |
|
88 }; // CRegistrar_ComponentTest |
|
89 |
|
90 // ______________________________________________________________________________ |
|
91 // |
|
92 inline CRegistrar_UnitTestContext::CRegistrar_UnitTestContext(CDataLogger& aDataLogger, |
|
93 MStateAccessor& aStateAccessor, |
|
94 MTransitionObserver& aObserver, |
|
95 CRegistryData& aRegistryData, |
|
96 MRegistrarObserver& aRegistrarObserver, |
|
97 RFs& aFs) |
|
98 : CUnitTestContext(aDataLogger, aStateAccessor, aObserver), |
|
99 iRegistryData(aRegistryData), |
|
100 iRegistrarObserver(aRegistrarObserver), |
|
101 iFs(aFs) |
|
102 { |
|
103 //Do nothing |
|
104 } |
|
105 |
|
106 inline CRegistrar_UnitTestContext::~CRegistrar_UnitTestContext() |
|
107 { |
|
108 delete iRegistrar; |
|
109 delete iDllData; |
|
110 } |
|
111 |
|
112 // ______________________________________________________________________________ |
|
113 // |
|
114 inline CRegistrar_ComponentTest* CRegistrar_ComponentTest::NewLC(CDataLogger& aDataLogger, MComponentTestObserver& aObserver) |
|
115 { |
|
116 CRegistrar_ComponentTest* self = new (ELeave) CRegistrar_ComponentTest(aDataLogger, aObserver); |
|
117 CleanupStack::PushL(self); |
|
118 self->ConstructL(); |
|
119 return self; |
|
120 } |
|
121 |
|
122 inline CRegistrar_ComponentTest::CRegistrar_ComponentTest(CDataLogger& aDataLogger, |
|
123 MComponentTestObserver& aObserver) |
|
124 : CComponentTester(aDataLogger, aObserver) |
|
125 { |
|
126 // Do nothing here. |
|
127 } |
|
128 |
|
129 inline void CRegistrar_ComponentTest::ConstructL() |
|
130 { |
|
131 // Perform base class initialization |
|
132 ComponentTesterConstructL(); |
|
133 |
|
134 AddUnitTestL(CRegistrar_CreateAndDestroy_UnitTest::NewL(iDataLogger, *this)); |
|
135 AddUnitTestL(CRegistrar_BeginComplete_UnitTest::NewL(iDataLogger, *this)); |
|
136 AddUnitTestL(CRegistrar_RegisterDiscovery_UnitTest::NewL(iDataLogger, *this)); |
|
137 AddUnitTestL(CRegistrar_RegisterTwice_UnitTest::NewL(iDataLogger, *this)); |
|
138 AddUnitTestL(CRegistrar_UseWhileDiscovering_UnitTest::NewL(iDataLogger, *this)); |
|
139 } |
|
140 |
|
141 // ______________________________________________________________________________ |
|
142 // |
|
143 EXPORT_C CComponentTester* NewComponentTestLC(CDataLogger& aDataLogger, |
|
144 MComponentTestObserver& aComponentTestObserver) |
|
145 { |
|
146 return CRegistrar_ComponentTest::NewLC(aDataLogger, aComponentTestObserver); |
|
147 } |
|
148 |
|
149 // ___________________________________________________________________________ |
|
150 // |
|
151 // This section of the module simply includes the exported test harness template which |
|
152 // makes this a "whole" CPP file with a E32Main entry point below. The test MMP |
|
153 // project file can then produce a EXE for the test project instead of a DLL. |
|
154 |
|
155 #include <ecom/test_bed/testharnesstemplate.h> |
|
156 |
|
157 GLDEF_C TInt E32Main() |
|
158 { |
|
159 test.Title(); |
|
160 test.Start(_L(" @SYMTestCaseID:SYSLIB-ECOM-LEGACY-REGISTRARTEST-0001 ")); |
|
161 |
|
162 test.End(); |
|
163 test.Close(); |
|
164 |
|
165 return E32Main_TestHarness(NewComponentTestLC); |
|
166 } |
|
167 |