|
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 // The unit test class implementations for the CComponentInfo class. |
|
15 // |
|
16 // |
|
17 |
|
18 #include "ComponentInfoUnitTest.h" |
|
19 |
|
20 // ______________________________________________________________________________ |
|
21 // |
|
22 _LIT(KComponentInfoCreateAndDestroyUnitTest,"CComponentInfo_CreateAndDestroy_UnitTest"); |
|
23 |
|
24 CComponentInfo_CreateAndDestroy_UnitTest* CComponentInfo_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger, |
|
25 MUnitTestObserver& aObserver) |
|
26 { |
|
27 CComponentInfo_CreateAndDestroy_UnitTest* self = |
|
28 new(ELeave) CComponentInfo_CreateAndDestroy_UnitTest(aDataLogger, |
|
29 aObserver); |
|
30 CleanupStack::PushL(self); |
|
31 self->ConstructL(); |
|
32 CleanupStack::Pop(); |
|
33 return self; |
|
34 } |
|
35 |
|
36 inline TInt CComponentInfo_CreateAndDestroy_UnitTest::RunError(TInt aError) |
|
37 { |
|
38 // The RunL left so chain to the base first and then cleanup |
|
39 TInt error = CUnitTest::RunError(aError); // Chain to base |
|
40 delete iUTContext; |
|
41 iUTContext = NULL; |
|
42 delete iStateAccessor; |
|
43 iStateAccessor = NULL; |
|
44 /* delete any validators used */ |
|
45 delete iCtorValidator; |
|
46 iCtorValidator = NULL; |
|
47 delete iDtorValidator; |
|
48 iDtorValidator = NULL; |
|
49 return error; |
|
50 } |
|
51 |
|
52 inline CComponentInfo_CreateAndDestroy_UnitTest::~CComponentInfo_CreateAndDestroy_UnitTest() |
|
53 { |
|
54 // Simply delete our test class instance |
|
55 delete iUTContext; |
|
56 delete iStateAccessor; |
|
57 /* delete any validators used */ |
|
58 delete iCtorValidator; |
|
59 delete iDtorValidator; |
|
60 } |
|
61 |
|
62 inline CComponentInfo_CreateAndDestroy_UnitTest::CComponentInfo_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger, |
|
63 MUnitTestObserver& aObserver) |
|
64 : CUnitTest(KComponentInfoCreateAndDestroyUnitTest, aDataLogger, aObserver) |
|
65 { |
|
66 //Do nothing |
|
67 } |
|
68 |
|
69 // Now the Individual transitions need to be added. |
|
70 inline void CComponentInfo_CreateAndDestroy_UnitTest::ConstructL() |
|
71 { |
|
72 // Perform the base class initialization |
|
73 UnitTestConstructL(); |
|
74 |
|
75 // Create the Unit test state accessor |
|
76 iStateAccessor = new(ELeave) TComponentInfo_StateAccessor; |
|
77 // Construct the Unit test context. |
|
78 iUTContext = new(ELeave) CComponentInfo_UnitTestContext(iDataLogger, *iStateAccessor, *this); |
|
79 iUTContext->iOwnParams = ETrue; |
|
80 //Leave function pointer at 0, assume CBase does this |
|
81 //iUTContext->iEntryFunc = iUTContext->iEntryFuncPostCheck = 0; |
|
82 iUTContext->iTestInfoArray = new(ELeave) RPointerArray<CUnitTestInfo>; |
|
83 |
|
84 // Add the Transitions in the order they are to run |
|
85 // C'tor first, D'tor last... |
|
86 iCtorValidator = new(ELeave) TComponentInfo_Ctor_TransitionValidator(*iUTContext); |
|
87 iDtorValidator = new(ELeave) TComponentInfo_Dtor_TransitionValidator(*iUTContext); |
|
88 |
|
89 AddTransitionL(new(ELeave)CComponentInfo_NewL_Transition(*iUTContext,*iCtorValidator)); |
|
90 AddTransitionL(new(ELeave)CComponentInfo_Dtor_Transition(*iUTContext,*iDtorValidator)); |
|
91 } |
|
92 |
|
93 // ______________________________________________________________________________ |
|
94 // |
|
95 _LIT(KComponentInfoRetrieveTestNamesUnitTest,"CComponentInfo_RetrieveTestNames_UnitTest"); |
|
96 |
|
97 CComponentInfo_RetrieveTestNames_UnitTest* CComponentInfo_RetrieveTestNames_UnitTest::NewL(CDataLogger& aDataLogger, |
|
98 MUnitTestObserver& aObserver) |
|
99 { |
|
100 CComponentInfo_RetrieveTestNames_UnitTest* self = |
|
101 new(ELeave) CComponentInfo_RetrieveTestNames_UnitTest(aDataLogger, |
|
102 aObserver); |
|
103 CleanupStack::PushL(self); |
|
104 self->ConstructL(); |
|
105 CleanupStack::Pop(); |
|
106 return self; |
|
107 } |
|
108 |
|
109 inline TInt CComponentInfo_RetrieveTestNames_UnitTest::RunError(TInt aError) |
|
110 { |
|
111 // The RunL left so chain to the base first and then cleanup |
|
112 TInt error = CUnitTest::RunError(aError); // Chain to base |
|
113 delete iUTContext; |
|
114 iUTContext = NULL; |
|
115 delete iStateAccessor; |
|
116 iStateAccessor = NULL; |
|
117 /* delete any validators used */ |
|
118 delete iCtorValidator; |
|
119 iCtorValidator = NULL; |
|
120 delete iEntryValidator; |
|
121 iEntryValidator = NULL; |
|
122 delete iUnitTestsInfoValidator; |
|
123 iUnitTestsInfoValidator = NULL; |
|
124 delete iDtorValidator; |
|
125 iDtorValidator = NULL; |
|
126 return error; |
|
127 } |
|
128 |
|
129 inline CComponentInfo_RetrieveTestNames_UnitTest::~CComponentInfo_RetrieveTestNames_UnitTest() |
|
130 { |
|
131 // Simply delete our test class instance |
|
132 delete iUTContext; |
|
133 delete iStateAccessor; |
|
134 /* delete any validators used */ |
|
135 delete iCtorValidator; |
|
136 delete iEntryValidator; |
|
137 delete iUnitTestsInfoValidator; |
|
138 delete iDtorValidator; |
|
139 } |
|
140 |
|
141 inline CComponentInfo_RetrieveTestNames_UnitTest::CComponentInfo_RetrieveTestNames_UnitTest(CDataLogger& aDataLogger, |
|
142 MUnitTestObserver& aObserver) |
|
143 : CUnitTest(KComponentInfoRetrieveTestNamesUnitTest, aDataLogger, aObserver) |
|
144 { |
|
145 //Do nothing |
|
146 } |
|
147 |
|
148 // Now the Individual transitions need to be added. |
|
149 inline void CComponentInfo_RetrieveTestNames_UnitTest::ConstructL() |
|
150 { |
|
151 // Perform the base class initialization |
|
152 UnitTestConstructL(); |
|
153 |
|
154 // Create the Unit test state accessor |
|
155 iStateAccessor = new(ELeave) TComponentInfo_StateAccessor; |
|
156 // Construct the Unit test context. |
|
157 iUTContext = new(ELeave) CComponentInfo_UnitTestContext(iDataLogger, *iStateAccessor, *this); |
|
158 |
|
159 // Add the Transitions in the order they are to run |
|
160 // C'tor first, D'tor last... |
|
161 iCtorValidator = new(ELeave) TComponentInfo_Ctor_TransitionValidator(*iUTContext); |
|
162 iEntryValidator = new(ELeave) TComponentInfo_Entry_TransitionValidator(*iUTContext); |
|
163 iUnitTestsInfoValidator = new(ELeave) TComponentInfo_UnitTestsInfo_TransitionValidator(*iUTContext); |
|
164 iDtorValidator = new(ELeave) TComponentInfo_Dtor_TransitionValidator(*iUTContext); |
|
165 |
|
166 AddTransitionL(new(ELeave)CComponentInfo_NewL_Transition(*iUTContext,*iCtorValidator)); |
|
167 AddTransitionL(new(ELeave)CComponentInfo_Entry_Transition(*iUTContext,*iEntryValidator)); |
|
168 AddTransitionL(new(ELeave)CComponentInfo_UnitTestsInfo_Transition(*iUTContext,*iUnitTestsInfoValidator)); |
|
169 AddTransitionL(new(ELeave)CComponentInfo_Dtor_Transition(*iUTContext,*iDtorValidator)); |
|
170 } |
|
171 |