os/ossrv/lowlevellibsandfws/pluginfw/Framework/RegistryDataTest/RegistryDataTransitionValidation.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 implementation of the validation classes for the CRegistryData tests
18 // ______________________________________________________________________________
20 inline TRegistryData_Ctor_TransitionValidator::TRegistryData_Ctor_TransitionValidator(CUnitTestContext& aUTContext)
21 :TTransitionValidator(aUTContext)
26 inline TBool TRegistryData_Ctor_TransitionValidator::ValidatePreConditions()
32 inline TBool TRegistryData_Ctor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
34 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
39 // ______________________________________________________________________________
41 inline TRegistryData_Dtor_TransitionValidator::TRegistryData_Dtor_TransitionValidator(CUnitTestContext& aUTContext)
42 :TTransitionValidator(aUTContext)
47 inline TBool TRegistryData_Dtor_TransitionValidator::ValidatePreConditions()
49 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
54 inline TBool TRegistryData_Dtor_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
59 // ______________________________________________________________________________
61 inline TRegistryData_AddDllDataL_TransitionValidator::TRegistryData_AddDllDataL_TransitionValidator(CUnitTestContext& aUTContext)
62 :TTransitionValidator(aUTContext)
67 inline TBool TRegistryData_AddDllDataL_TransitionValidator::ValidatePreConditions()
69 CRegistryData_UnitTestContext& context = REINTERPRET_CAST(CRegistryData_UnitTestContext&,
71 TRegistryData_StateAccessor& accessor = REINTERPRET_CAST(TRegistryData_StateAccessor&,
72 iUTContext.StateAccessor());
74 // Check that the drive we are trying to add to is valid
75 if(!(accessor.IsRegisteredDrive(*context.iRegistryData, context.iDriveUnit)))
77 _LIT(KAddDllFailedPreConditions,
78 "CRegistryData_AddDllDataL_Transition failed pre-conditions");
79 iUTContext.DataLogger().LogInformation(KAddDllFailedPreConditions);
83 if(accessor.InvariantTest(context.iRegistryData))
88 inline TBool TRegistryData_AddDllDataL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
90 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
95 // ______________________________________________________________________________
97 inline TRegistryData_ListImplementations_TransitionValidator::TRegistryData_ListImplementations_TransitionValidator(CUnitTestContext& aUTContext)
98 :TTransitionValidator(aUTContext)
103 inline TBool TRegistryData_ListImplementations_TransitionValidator::ValidatePreConditions()
105 // Just do an invariant test because we should be able to call this function any time
106 // after CRegistryData has been constructed.
107 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
112 inline TBool TRegistryData_ListImplementations_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
114 // This post validation checking assumes the use of the CExample plugin implementation
115 // It has to because ListImplementationsL takes an interface uid and we give it the
116 // CExampleInterface uid.
118 CRegistryData_UnitTestContext& context = REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext);
120 const TUid KImplementationClassOne = {0x10009DC3};
121 const TUid KImplementationClassTwo = {0x10009DC4};
123 TBool foundOne = EFalse;
124 TBool foundTwo = EFalse;
125 TInt impCount = context.iUidList->Count();
126 for(TInt index = 0; index < impCount; ++index)
128 TUid uid = (*(context.iUidList))[index]->ImplementationUid();
129 if(uid == KImplementationClassOne)
131 else if(uid == KImplementationClassTwo)
134 if(foundOne == EFalse || foundTwo == EFalse)
137 if(iUTContext.StateAccessor().InvariantTest(context.iRegistryData))
142 // ______________________________________________________________________________
144 inline TRegistryData_GetImplementationInformation_TransitionValidator::TRegistryData_GetImplementationInformation_TransitionValidator(CUnitTestContext& aUTContext)
145 :TTransitionValidator(aUTContext)
150 inline TBool TRegistryData_GetImplementationInformation_TransitionValidator::ValidatePreConditions()
152 // Just do an invariant test because we should be able to call this any time after
153 // CRegistryData has been constructed.
154 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
159 inline TBool TRegistryData_GetImplementationInformation_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
161 // Check that the return from GetImplementationInformationL is what we expect
162 _LIT8(KTestDataType, "text/wml");
163 CRegistryData_UnitTestContext& context = REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext);
164 if(context.iImplementationRef == 0 ||
165 context.iImplementationRef->DataType().Find(KTestDataType) == KErrNotFound)
168 if(iUTContext.StateAccessor().InvariantTest(context.iRegistryData))
173 // ______________________________________________________________________________
175 inline TRegistryData_IsRegisteredWithDate_TransitionValidator::TRegistryData_IsRegisteredWithDate_TransitionValidator(CUnitTestContext& aUTContext)
176 :TTransitionValidator(aUTContext)
181 inline TBool TRegistryData_IsRegisteredWithDate_TransitionValidator::ValidatePreConditions()
183 // No pre condition checking required other than that the object is constructed.
184 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
189 inline TBool TRegistryData_IsRegisteredWithDate_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
191 // No post condition checking other than that this object's state is OK
192 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
197 // ______________________________________________________________________________
199 inline TRegistryData_PersistNow_TransitionValidator::TRegistryData_PersistNow_TransitionValidator(CUnitTestContext& aUTContext)
200 :TTransitionValidator(aUTContext)
205 inline TBool TRegistryData_PersistNow_TransitionValidator::ValidatePreConditions()
207 // No pre condition checking required other than that the object is correctly constructed
208 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
213 inline TBool TRegistryData_PersistNow_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
215 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
220 // ______________________________________________________________________________
222 inline TRegistryData_TemporaryUninstall_TransitionValidator::TRegistryData_TemporaryUninstall_TransitionValidator(CUnitTestContext& aUTContext)
223 :TTransitionValidator(aUTContext)
228 inline TBool TRegistryData_TemporaryUninstall_TransitionValidator::ValidatePreConditions()
230 // Only pre condition is that object is fully constructed
231 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
236 inline TBool TRegistryData_TemporaryUninstall_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
238 CRegistryData_UnitTestContext& context = REINTERPRET_CAST(CRegistryData_UnitTestContext&,
240 TRegistryData_StateAccessor& accessor = REINTERPRET_CAST(TRegistryData_StateAccessor&,
241 iUTContext.StateAccessor());
243 // Check that the drive we have uninstalled is not valid
244 if(accessor.IsRegisteredDrive(*context.iRegistryData, context.iDriveUnit))
246 _LIT(KUninstallFailedPostConditions,
247 "CRegistryData_TemporaryUninstallL_Transition failed post-conditions");
248 iUTContext.DataLogger().LogInformation(KUninstallFailedPostConditions);
252 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
257 // ______________________________________________________________________________
259 inline TRegistryData_UndoTemporaryUninstall_TransitionValidator::TRegistryData_UndoTemporaryUninstall_TransitionValidator(CUnitTestContext& aUTContext)
260 :TTransitionValidator(aUTContext)
265 inline TBool TRegistryData_UndoTemporaryUninstall_TransitionValidator::ValidatePreConditions()
267 // Only pre condition is that object is fully constructed
268 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
273 inline TBool TRegistryData_UndoTemporaryUninstall_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
275 CRegistryData_UnitTestContext& context = REINTERPRET_CAST(CRegistryData_UnitTestContext&,
277 TRegistryData_StateAccessor& accessor = REINTERPRET_CAST(TRegistryData_StateAccessor&,
278 iUTContext.StateAccessor());
280 // Check that the drive we have uninstalled is not valid
281 if(!(accessor.IsRegisteredDrive(*context.iRegistryData, context.iDriveUnit)))
283 _LIT(KUndoUninstallFailedPostConditions,
284 "CRegistryData_UndoTemporaryUninstallL_Transition failed post-conditions");
285 iUTContext.DataLogger().LogInformation(KUndoUninstallFailedPostConditions);
289 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
294 // ______________________________________________________________________________
296 inline TRegistryData_UpdateDllData_TransitionValidator::TRegistryData_UpdateDllData_TransitionValidator(CUnitTestContext& aUTContext)
297 :TTransitionValidator(aUTContext)
302 inline TBool TRegistryData_UpdateDllData_TransitionValidator::ValidatePreConditions()
304 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
309 inline TBool TRegistryData_UpdateDllData_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
311 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
316 // ______________________________________________________________________________
318 inline TRegistryData_BuildIndexes_TransitionValidator::TRegistryData_BuildIndexes_TransitionValidator(CUnitTestContext& aUTContext)
319 :TTransitionValidator(aUTContext)
324 inline TBool TRegistryData_BuildIndexes_TransitionValidator::ValidatePreConditions()
326 // Only pre condition is that object is fully constructed (BuildIndexes is actually
327 // called from ConstructL anyway)
328 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
333 inline TBool TRegistryData_BuildIndexes_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
335 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
340 // ______________________________________________________________________________
342 inline TRegistryData_IndexedFind_TransitionValidator::TRegistryData_IndexedFind_TransitionValidator(CUnitTestContext& aUTContext)
343 :TTransitionValidator(aUTContext)
348 inline TBool TRegistryData_IndexedFind_TransitionValidator::ValidatePreConditions()
350 // Only pre condition is that object is fully constructed.
351 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
356 inline TBool TRegistryData_IndexedFind_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
358 // No post condition (function is const)
359 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
364 // ______________________________________________________________________________
366 inline TRegistryData_Restore_TransitionValidator::TRegistryData_Restore_TransitionValidator(CUnitTestContext& aUTContext)
367 :TTransitionValidator(aUTContext)
372 inline TBool TRegistryData_Restore_TransitionValidator::ValidatePreConditions()
374 // Only pre condition is that object is fully constructed.
375 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
380 inline TBool TRegistryData_Restore_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
382 // The object has been restored from file so just check that it is a valid object
383 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
388 // ______________________________________________________________________________
390 inline TRegistryData_Store_TransitionValidator::TRegistryData_Store_TransitionValidator(CUnitTestContext& aUTContext)
391 :TTransitionValidator(aUTContext)
396 inline TBool TRegistryData_Store_TransitionValidator::ValidatePreConditions()
398 // Only pre condition is that object is fully constructed
399 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
404 inline TBool TRegistryData_Store_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
406 // No post condition as function is const
407 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
412 // ______________________________________________________________________________
414 inline TRegistryData_MatchOnUid_TransitionValidator::TRegistryData_MatchOnUid_TransitionValidator(CUnitTestContext& aUTContext)
415 :TTransitionValidator(aUTContext)
420 inline TBool TRegistryData_MatchOnUid_TransitionValidator::ValidatePreConditions()
422 // No pre condition checking because this function is static
426 inline TBool TRegistryData_MatchOnUid_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
428 // No post condition checking because this function is static
432 // ______________________________________________________________________________
434 inline TRegistryData_ConstructPolicyIndexL_TransitionValidator::TRegistryData_ConstructPolicyIndexL_TransitionValidator(CUnitTestContext& aUTContext)
435 :TTransitionValidator(aUTContext)
440 inline TBool TRegistryData_ConstructPolicyIndexL_TransitionValidator::ValidatePreConditions()
442 // Only pre condition is object is fully constructed
443 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
448 inline TBool TRegistryData_ConstructPolicyIndexL_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
450 // No post condition because function is const
451 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
456 // ______________________________________________________________________________
458 inline TRegistryData_SetPolicyObserver_TransitionValidator::TRegistryData_SetPolicyObserver_TransitionValidator(CUnitTestContext& aUTContext)
459 :TTransitionValidator(aUTContext)
464 inline TBool TRegistryData_SetPolicyObserver_TransitionValidator::ValidatePreConditions()
466 // Only pre condition is object is fully constructed
467 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
472 inline TBool TRegistryData_SetPolicyObserver_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
474 CRegistryData_UnitTestContext& context = REINTERPRET_CAST(CRegistryData_UnitTestContext&,
476 if(iUTContext.StateAccessor().InvariantTest(context.iRegistryData))
481 // ______________________________________________________________________________
483 inline TRegistryData_GetSecondImplInfo_TransitionValidator::TRegistryData_GetSecondImplInfo_TransitionValidator(CUnitTestContext& aUTContext)
484 :TTransitionValidator(aUTContext)
489 inline TBool TRegistryData_GetSecondImplInfo_TransitionValidator::ValidatePreConditions()
491 CRegistryData_UnitTestContext& context = REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext);
493 // Copy the result of the earlier GetImplementationInformation so we
495 context.iSecondImplementationRef = context.iImplementationRef;
497 if(iUTContext.StateAccessor().InvariantTest(context.iRegistryData))
502 inline TBool TRegistryData_GetSecondImplInfo_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
504 CRegistryData_UnitTestContext& context = REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext);
506 // if the second call to GetImplementationInformation does not return the same thing
507 // as the first then this test has failed
508 if(context.iImplementationRef != context.iSecondImplementationRef)
511 if(iUTContext.StateAccessor().InvariantTest(context.iRegistryData))
516 // ______________________________________________________________________________
518 inline TRegistryData_DiscoveriesBeginning_TransitionValidator::TRegistryData_DiscoveriesBeginning_TransitionValidator(CUnitTestContext& aUTContext)
519 :TTransitionValidator(aUTContext)
524 inline TBool TRegistryData_DiscoveriesBeginning_TransitionValidator::ValidatePreConditions()
526 if(iUTContext.StateAccessor().InvariantTest(REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext).iRegistryData))
531 inline TBool TRegistryData_DiscoveriesBeginning_TransitionValidator::ValidatePostConditions(TTestBedAsyncState /* aAsyncState */)
533 CRegistryData_UnitTestContext& context = REINTERPRET_CAST(CRegistryData_UnitTestContext&,iUTContext);
535 if(context.iRegistryData->IndexValid())
538 if(iUTContext.StateAccessor().InvariantTest(context.iRegistryData))