os/ossrv/lowlevellibsandfws/pluginfw/Framework/RegistryDataTest/RegistryDataUnitTests.inl
Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // The implementaition of the unit tests for the CRegistryData class.
18 const TUid KCExampleInterfaceUid = {0x10009DC0};
19 const TUid KCExampleInterfaceImp = {0x10009DC3};
21 // ______________________________________________________________________________
23 _LIT(KRegistryDataCreateAndDestroyUnitTest,"CRegistryData_CreateAndDestroy_UnitTest");
25 CRegistryData_CreateAndDestroy_UnitTest* CRegistryData_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger,
26 MUnitTestObserver& aObserver)
28 CRegistryData_CreateAndDestroy_UnitTest* self =
29 new(ELeave) CRegistryData_CreateAndDestroy_UnitTest(aDataLogger,
31 CleanupStack::PushL(self);
37 inline TInt CRegistryData_CreateAndDestroy_UnitTest::RunError(TInt aError)
39 // The RunL left so chain to the base first and then cleanup
40 TInt error = CUnitTest::RunError(aError); // Chain to base
42 delete iStateAccessor;
43 delete iCtorValidator;
44 delete iDtorValidator;
48 inline CRegistryData_CreateAndDestroy_UnitTest::~CRegistryData_CreateAndDestroy_UnitTest()
50 // Simply delete our test class instance
52 delete iStateAccessor;
53 delete iCtorValidator;
54 delete iDtorValidator;
57 inline CRegistryData_CreateAndDestroy_UnitTest::CRegistryData_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger,
58 MUnitTestObserver& aObserver)
59 : CUnitTest(KRegistryDataCreateAndDestroyUnitTest, aDataLogger, aObserver)
64 // Now the Individual transitions need to be added.
65 inline void CRegistryData_CreateAndDestroy_UnitTest::ConstructL()
67 // Perform the base class initialization
70 // Create the Unit test state accessor
71 iStateAccessor = new(ELeave) TRegistryData_StateAccessor;
72 // Construct the Unit test context.
73 iUTContext = new(ELeave) CRegistryData_UnitTestContext(iDataLogger, *iStateAccessor, *this, iFs);
74 // and a default validator
75 iCtorValidator = new(ELeave) TRegistryData_Ctor_TransitionValidator(*iUTContext);
76 iDtorValidator = new(ELeave) TRegistryData_Dtor_TransitionValidator(*iUTContext);
77 // Add the Transitions in the order they are to run
78 // C'tor first, D'tor last...
79 // Examples of C'tor and D'tor transitions on CRegistryData class.
80 AddTransitionL(new(ELeave)CRegistryData_NewL_Transition(*iUTContext,*iCtorValidator));
81 AddTransitionL(new(ELeave)CRegistryData_Dtor_Transition(*iUTContext,*iDtorValidator));
84 void CRegistryData_CreateAndDestroy_UnitTest::PrepareUnitTestL()
88 // ______________________________________________________________________________
90 _LIT(KRegistryDataAddDataUnitTest,"CRegistryData_AddData_UnitTest");
92 CRegistryData_AddData_UnitTest* CRegistryData_AddData_UnitTest::NewL(CDataLogger& aDataLogger,
93 MUnitTestObserver& aObserver)
95 CRegistryData_AddData_UnitTest* self =
96 new(ELeave) CRegistryData_AddData_UnitTest(aDataLogger,
98 CleanupStack::PushL(self);
104 inline TInt CRegistryData_AddData_UnitTest::RunError(TInt aError)
106 // The RunL left so chain to the base first and then cleanup
107 TInt error = CUnitTest::RunError(aError); // Chain to base
109 delete iStateAccessor;
111 delete iCtorValidator;
112 delete iSetObserverValidator;
113 delete iUndoTemporaryUninstallValidator;
114 delete iAddDllDataValidator;
115 delete iIsRegisteredValidator;
116 delete iUpdateDllDataValidator;
117 delete iTemporaryUninstallValidator;
118 delete iPersistNowValidator;
119 delete iDtorValidator;
124 inline CRegistryData_AddData_UnitTest::~CRegistryData_AddData_UnitTest()
126 // Simply delete our test class instance
128 delete iStateAccessor;
130 // delete any validators used
131 delete iCtorValidator;
132 delete iSetObserverValidator;
133 delete iUndoTemporaryUninstallValidator;
134 delete iAddDllDataValidator;
135 delete iIsRegisteredValidator;
136 delete iUpdateDllDataValidator;
137 delete iTemporaryUninstallValidator;
138 delete iPersistNowValidator;
140 delete iDtorValidator;
143 inline CRegistryData_AddData_UnitTest::CRegistryData_AddData_UnitTest(CDataLogger& aDataLogger,
144 MUnitTestObserver& aObserver)
145 : CUnitTest(KRegistryDataAddDataUnitTest, aDataLogger, aObserver)
150 // Now the Individual transitions need to be added.
151 inline void CRegistryData_AddData_UnitTest::ConstructL()
153 // Perform the base class initialization
154 UnitTestConstructL();
156 // Create the Unit test state accessor
157 iStateAccessor = new(ELeave) TRegistryData_StateAccessor;
159 // Construct the Unit test context.
160 iUTContext = new(ELeave) CRegistryData_UnitTestContext(iDataLogger,
164 _LIT(KDDriveLetter, "D");
165 iUTContext->iDriveUnit = KDDriveLetter;
166 iUTContext->iFoundDriveIndex = -1;
167 TUid thirdUid = {0x10009DB1};
168 iUTContext->iDllEntry.iType = TUidType(KNullUid, KNullUid, thirdUid);
169 iUTContext->iDllData = CRegistryData::CDllData::NewLC(iUTContext->iDllEntry);
170 CleanupStack::Pop(iUTContext->iDllData);
171 iUTContext->iNewDllData = CRegistryData::CDllData::NewLC(iUTContext->iDllEntry);
172 CleanupStack::Pop(iUTContext->iNewDllData);
174 // Add the Transitions in the order they are to run
175 // C'tor first, D'tor last...
176 iCtorValidator = new(ELeave) TRegistryData_Ctor_TransitionValidator(*iUTContext);
177 iSetObserverValidator = new(ELeave) TRegistryData_SetPolicyObserver_TransitionValidator(*iUTContext);
178 iUndoTemporaryUninstallValidator = new(ELeave) TRegistryData_UndoTemporaryUninstall_TransitionValidator(*iUTContext);
179 iAddDllDataValidator = new(ELeave) TRegistryData_AddDllDataL_TransitionValidator(*iUTContext);
180 iIsRegisteredValidator = new(ELeave) TRegistryData_IsRegisteredWithDate_TransitionValidator(*iUTContext);
181 iUpdateDllDataValidator = new(ELeave) TRegistryData_UpdateDllData_TransitionValidator(*iUTContext);
182 iTemporaryUninstallValidator = new(ELeave) TRegistryData_TemporaryUninstall_TransitionValidator(*iUTContext);
183 iPersistNowValidator = new(ELeave) TRegistryData_PersistNow_TransitionValidator(*iUTContext);
184 iDtorValidator = new(ELeave) TRegistryData_Dtor_TransitionValidator(*iUTContext);
186 AddTransitionL(new(ELeave)CRegistryData_NewL_Transition(*iUTContext,*iCtorValidator));
187 AddTransitionL(new(ELeave)CRegistryData_UndoTemporaryUninstallL_Transition(*iUTContext,*iUndoTemporaryUninstallValidator));
188 AddTransitionL(new(ELeave)CRegistryData_AddDllDataL_Transition(*iUTContext,*iAddDllDataValidator));
189 AddTransitionL(new(ELeave)CRegistryData_IsRegisteredWithDateL_Transition(*iUTContext,*iIsRegisteredValidator));
190 AddTransitionL(new(ELeave)CRegistryData_UpdateDllDataL_Transition(*iUTContext,*iUpdateDllDataValidator));
191 AddTransitionL(new(ELeave)CRegistryData_TemporaryUninstallL_Transition(*iUTContext,*iTemporaryUninstallValidator));
192 AddTransitionL(new(ELeave)CRegistryData_PersistNowL_Transition(*iUTContext,*iPersistNowValidator));
193 AddTransitionL(new(ELeave)CRegistryData_Dtor_Transition(*iUTContext,*iDtorValidator));
196 // ______________________________________________________________________________
198 _LIT(KRegistryDataRetrieveInfoUnitTest,"CRegistryData_RetrieveInfo_UnitTest");
200 CRegistryData_RetrieveInfo_UnitTest* CRegistryData_RetrieveInfo_UnitTest::NewL(CDataLogger& aDataLogger,
201 MUnitTestObserver& aObserver)
203 CRegistryData_RetrieveInfo_UnitTest* self =
204 new(ELeave) CRegistryData_RetrieveInfo_UnitTest(aDataLogger,
206 CleanupStack::PushL(self);
212 inline TInt CRegistryData_RetrieveInfo_UnitTest::RunError(TInt aError)
214 // The RunL left so chain to the base first and then cleanup
215 TInt error = CUnitTest::RunError(aError); // Chain to base
217 delete iStateAccessor;
218 /* delete any validators used */
219 delete iCtorValidator;
220 delete iListImplementationsValidator;
221 delete iGetImplementationInformationValidator;
222 delete iDtorValidator;
226 inline CRegistryData_RetrieveInfo_UnitTest::~CRegistryData_RetrieveInfo_UnitTest()
228 // Simply delete our test class instance
230 delete iStateAccessor;
232 delete iCtorValidator;
233 delete iListImplementationsValidator;
234 delete iGetImplementationInformationValidator;
235 delete iDtorValidator;
238 inline CRegistryData_RetrieveInfo_UnitTest::CRegistryData_RetrieveInfo_UnitTest(CDataLogger& aDataLogger,
239 MUnitTestObserver& aObserver)
240 : CUnitTest(KRegistryDataRetrieveInfoUnitTest, aDataLogger, aObserver)
245 // Now the Individual transitions need to be added.
246 inline void CRegistryData_RetrieveInfo_UnitTest::ConstructL()
248 // Perform the base class initialization
249 UnitTestConstructL();
251 // Create the Unit test state accessor
252 iStateAccessor = new(ELeave) TRegistryData_StateAccessor;
254 // Construct the Unit test context.
255 iUTContext = new(ELeave) CRegistryData_UnitTestContext(iDataLogger,
259 iUTContext->iInterfaceUid.iUid = KCExampleInterfaceUid.iUid;
260 iUTContext->iImplementationUid.iUid = KCExampleInterfaceImp.iUid;
262 // Add the Transitions in the order they are to run
263 iCtorValidator = new(ELeave) TRegistryData_Ctor_TransitionValidator(*iUTContext);
264 iListImplementationsValidator = new(ELeave) TRegistryData_ListImplementations_TransitionValidator(*iUTContext);
265 iGetImplementationInformationValidator = new(ELeave) TRegistryData_GetImplementationInformation_TransitionValidator(*iUTContext);
266 iDtorValidator = new(ELeave) TRegistryData_Dtor_TransitionValidator(*iUTContext);
268 AddTransitionL(new(ELeave)CRegistryData_NewL_Transition(*iUTContext,*iCtorValidator));
269 AddTransitionL(new(ELeave)CRegistryData_ListImplementationsL_Transition(*iUTContext,
270 *iListImplementationsValidator));
271 AddTransitionL(new(ELeave)CRegistryData_GetImplementationInformationL_Transition(*iUTContext,
272 *iGetImplementationInformationValidator));
273 AddTransitionL(new(ELeave)CRegistryData_Dtor_Transition(*iUTContext,*iDtorValidator));
275 // Add the permissible error codes for failures
276 AddLeaveErrorCodeL(KEComErrNoInterfaceIdentified);
279 // ______________________________________________________________________________
281 _LIT(KRegistryDataInfoWhileDiscoveringUnitTest,"CRegistryData_GetImplInfoWhileDiscovering_UnitTest");
283 CRegistryData_GetImplInfoWhileDiscovering_UnitTest*
284 CRegistryData_GetImplInfoWhileDiscovering_UnitTest::NewL(CDataLogger& aDataLogger,
285 MUnitTestObserver& aObserver)
287 CRegistryData_GetImplInfoWhileDiscovering_UnitTest* self =
288 new(ELeave) CRegistryData_GetImplInfoWhileDiscovering_UnitTest(aDataLogger,
290 CleanupStack::PushL(self);
292 CleanupStack::Pop(self);
296 inline TInt CRegistryData_GetImplInfoWhileDiscovering_UnitTest::RunError(TInt aError)
298 // The RunL left so chain to the base first and then cleanup
299 TInt error = CUnitTest::RunError(aError); // Chain to base
301 delete iStateAccessor;
302 // delete any validators used
303 delete iCtorValidator;
304 delete iGetImplInfoValidator;
305 delete iDiscoveriesBeginningValidator;
306 delete iGetSecondImplInfoValidator;
307 delete iDtorValidator;
312 inline CRegistryData_GetImplInfoWhileDiscovering_UnitTest::~CRegistryData_GetImplInfoWhileDiscovering_UnitTest()
314 // Simply delete our test class instance
316 delete iStateAccessor;
318 // delete any validators used
319 delete iCtorValidator;
320 delete iGetImplInfoValidator;
321 delete iDiscoveriesBeginningValidator;
322 delete iGetSecondImplInfoValidator;
323 delete iDtorValidator;
326 inline CRegistryData_GetImplInfoWhileDiscovering_UnitTest::
327 CRegistryData_GetImplInfoWhileDiscovering_UnitTest(CDataLogger& aDataLogger,
328 MUnitTestObserver& aObserver)
329 : CUnitTest(KRegistryDataInfoWhileDiscoveringUnitTest, aDataLogger, aObserver)
334 // Now the Individual transitions need to be added.
335 inline void CRegistryData_GetImplInfoWhileDiscovering_UnitTest::ConstructL()
337 // Perform the base class initialization
338 UnitTestConstructL();
340 // Create the Unit test state accessor
341 iStateAccessor = new(ELeave) TRegistryData_StateAccessor;
343 // Construct the Unit test context.
344 iUTContext = new(ELeave) CRegistryData_UnitTestContext(iDataLogger,
349 iUTContext->iInterfaceUid.iUid = KCExampleInterfaceUid.iUid;
350 iUTContext->iImplementationUid.iUid = KCExampleInterfaceImp.iUid;
352 // Add the Transitions in the order they are to run
353 // C'tor first, D'tor last...
354 iCtorValidator = new(ELeave) TRegistryData_Ctor_TransitionValidator(*iUTContext);
355 iGetImplInfoValidator = new(ELeave) TRegistryData_GetImplementationInformation_TransitionValidator(*iUTContext);
356 iDiscoveriesBeginningValidator = new(ELeave) TRegistryData_DiscoveriesBeginning_TransitionValidator(*iUTContext);
357 iGetSecondImplInfoValidator = new(ELeave) TRegistryData_GetSecondImplInfo_TransitionValidator(*iUTContext);
358 iDtorValidator = new(ELeave) TRegistryData_Dtor_TransitionValidator(*iUTContext);
360 AddTransitionL(new(ELeave)CRegistryData_NewL_Transition(*iUTContext,*iCtorValidator));
361 AddTransitionL(new(ELeave)CRegistryData_GetImplementationInformationL_Transition(*iUTContext,*iGetImplInfoValidator));
362 AddTransitionL(new(ELeave)CRegistryData_DiscoveriesBeginning_Transition(*iUTContext,*iDiscoveriesBeginningValidator));
363 AddTransitionL(new(ELeave)CRegistryData_GetImplementationInformationL_Transition(*iUTContext,*iGetSecondImplInfoValidator));
364 AddTransitionL(new(ELeave)CRegistryData_Dtor_Transition(*iUTContext,*iDtorValidator));