os/ossrv/lowlevellibsandfws/pluginfw/Framework/RegistryDataTest/RegistryDataUnitTests.inl
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // The implementaition of the unit tests for the CRegistryData class.
    15 // 
    16 //
    17 
    18 const TUid KCExampleInterfaceUid = {0x10009DC0};
    19 const TUid KCExampleInterfaceImp = {0x10009DC3};
    20 
    21 // ______________________________________________________________________________
    22 //
    23 _LIT(KRegistryDataCreateAndDestroyUnitTest,"CRegistryData_CreateAndDestroy_UnitTest");
    24 
    25 CRegistryData_CreateAndDestroy_UnitTest* CRegistryData_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger,
    26 											MUnitTestObserver& aObserver)
    27 	{
    28 	CRegistryData_CreateAndDestroy_UnitTest* self = 
    29 					new(ELeave) CRegistryData_CreateAndDestroy_UnitTest(aDataLogger,
    30 																aObserver);
    31 	CleanupStack::PushL(self);
    32 	self->ConstructL();
    33 	CleanupStack::Pop();
    34 	return self; 
    35 	}
    36 
    37 inline TInt CRegistryData_CreateAndDestroy_UnitTest::RunError(TInt aError)
    38 	{
    39 	// The RunL left so chain to the base first and then cleanup
    40 	TInt error = CUnitTest::RunError(aError);	// Chain to base
    41 	delete iUTContext;
    42 	delete iStateAccessor;
    43 	delete iCtorValidator;
    44 	delete iDtorValidator;
    45 	return error;
    46 	}
    47 
    48 inline CRegistryData_CreateAndDestroy_UnitTest::~CRegistryData_CreateAndDestroy_UnitTest()
    49 	{
    50 	// Simply delete our test class instance
    51 	delete iUTContext;
    52 	delete iStateAccessor;
    53 	delete iCtorValidator;
    54 	delete iDtorValidator;
    55 	}
    56 
    57 inline CRegistryData_CreateAndDestroy_UnitTest::CRegistryData_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger,
    58 																	MUnitTestObserver& aObserver)
    59 : CUnitTest(KRegistryDataCreateAndDestroyUnitTest, aDataLogger, aObserver)
    60 	{
    61 	//Do nothing
    62 	}
    63 
    64 // Now the Individual transitions need to be added.
    65 inline void CRegistryData_CreateAndDestroy_UnitTest::ConstructL()
    66 	{
    67 	// Perform the base class initialization
    68 	UnitTestConstructL();
    69 
    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));
    82 	}
    83 
    84 void CRegistryData_CreateAndDestroy_UnitTest::PrepareUnitTestL()
    85 	{
    86 	}
    87 
    88 // ______________________________________________________________________________
    89 //
    90 _LIT(KRegistryDataAddDataUnitTest,"CRegistryData_AddData_UnitTest");
    91 
    92 CRegistryData_AddData_UnitTest* CRegistryData_AddData_UnitTest::NewL(CDataLogger& aDataLogger,
    93 											MUnitTestObserver& aObserver)
    94 	{
    95 	CRegistryData_AddData_UnitTest* self = 
    96 					new(ELeave) CRegistryData_AddData_UnitTest(aDataLogger,
    97 																aObserver);
    98 	CleanupStack::PushL(self);
    99 	self->ConstructL();
   100 	CleanupStack::Pop();
   101 	return self; 
   102 	}
   103 
   104 inline TInt CRegistryData_AddData_UnitTest::RunError(TInt aError)
   105 	{
   106 	// The RunL left so chain to the base first and then cleanup
   107 	TInt error = CUnitTest::RunError(aError);	// Chain to base
   108 	delete iUTContext;
   109 	delete iStateAccessor;
   110 
   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;
   120 
   121 	return error;
   122 	}
   123 
   124 inline CRegistryData_AddData_UnitTest::~CRegistryData_AddData_UnitTest()
   125 	{
   126 	// Simply delete our test class instance
   127 	delete iUTContext;
   128 	delete iStateAccessor;
   129 	
   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;
   139 
   140 	delete iDtorValidator;
   141 	}
   142 
   143 inline CRegistryData_AddData_UnitTest::CRegistryData_AddData_UnitTest(CDataLogger& aDataLogger,
   144 																	MUnitTestObserver& aObserver)
   145 : CUnitTest(KRegistryDataAddDataUnitTest, aDataLogger, aObserver)
   146 	{
   147 	//Do nothing
   148 	}
   149 
   150 // Now the Individual transitions need to be added.
   151 inline void CRegistryData_AddData_UnitTest::ConstructL()
   152 	{
   153 	// Perform the base class initialization
   154 	UnitTestConstructL();
   155 
   156 	// Create the Unit test state accessor
   157 	iStateAccessor = new(ELeave) TRegistryData_StateAccessor;
   158 
   159 	// Construct the Unit test context.
   160 	iUTContext = new(ELeave) CRegistryData_UnitTestContext(iDataLogger, 
   161 														   *iStateAccessor, 
   162 														   *this, 
   163 														   iFs);
   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);
   173 
   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);
   185 
   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));
   194 	}
   195 
   196 // ______________________________________________________________________________
   197 //
   198 _LIT(KRegistryDataRetrieveInfoUnitTest,"CRegistryData_RetrieveInfo_UnitTest");
   199 
   200 CRegistryData_RetrieveInfo_UnitTest* CRegistryData_RetrieveInfo_UnitTest::NewL(CDataLogger& aDataLogger,
   201 											MUnitTestObserver& aObserver)
   202 	{
   203 	CRegistryData_RetrieveInfo_UnitTest* self = 
   204 					new(ELeave) CRegistryData_RetrieveInfo_UnitTest(aDataLogger,
   205 																aObserver);
   206 	CleanupStack::PushL(self);
   207 	self->ConstructL();
   208 	CleanupStack::Pop();
   209 	return self; 
   210 	}
   211 
   212 inline TInt CRegistryData_RetrieveInfo_UnitTest::RunError(TInt aError)
   213 	{
   214 	// The RunL left so chain to the base first and then cleanup
   215 	TInt error = CUnitTest::RunError(aError);	// Chain to base
   216 	delete iUTContext;
   217 	delete iStateAccessor;
   218 	/* delete any validators used */
   219 	delete iCtorValidator;
   220 	delete iListImplementationsValidator;
   221 	delete iGetImplementationInformationValidator;
   222 	delete iDtorValidator;
   223 	return error;
   224 	}
   225 
   226 inline CRegistryData_RetrieveInfo_UnitTest::~CRegistryData_RetrieveInfo_UnitTest()
   227 	{
   228 	// Simply delete our test class instance
   229 	delete iUTContext;
   230 	delete iStateAccessor;
   231 
   232 	delete iCtorValidator;
   233 	delete iListImplementationsValidator;
   234 	delete iGetImplementationInformationValidator;
   235 	delete iDtorValidator;
   236 	}
   237 
   238 inline CRegistryData_RetrieveInfo_UnitTest::CRegistryData_RetrieveInfo_UnitTest(CDataLogger& aDataLogger,
   239 																	MUnitTestObserver& aObserver)
   240 : CUnitTest(KRegistryDataRetrieveInfoUnitTest, aDataLogger, aObserver)
   241 	{
   242 	//Do nothing
   243 	}
   244 
   245 // Now the Individual transitions need to be added.
   246 inline void CRegistryData_RetrieveInfo_UnitTest::ConstructL()
   247 	{
   248 	// Perform the base class initialization
   249 	UnitTestConstructL();
   250 
   251 	// Create the Unit test state accessor
   252 	iStateAccessor = new(ELeave) TRegistryData_StateAccessor;
   253 
   254 	// Construct the Unit test context.
   255 	iUTContext = new(ELeave) CRegistryData_UnitTestContext(iDataLogger, 
   256 														   *iStateAccessor, 
   257 														   *this, 
   258 														   iFs);
   259 	iUTContext->iInterfaceUid.iUid		= KCExampleInterfaceUid.iUid;
   260 	iUTContext->iImplementationUid.iUid	= KCExampleInterfaceImp.iUid;
   261 
   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);
   267 
   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));
   274 
   275 	// Add the permissible error codes for failures
   276 	AddLeaveErrorCodeL(KEComErrNoInterfaceIdentified);
   277 	}
   278 
   279 // ______________________________________________________________________________
   280 //
   281 _LIT(KRegistryDataInfoWhileDiscoveringUnitTest,"CRegistryData_GetImplInfoWhileDiscovering_UnitTest");
   282 
   283 CRegistryData_GetImplInfoWhileDiscovering_UnitTest* 
   284 	CRegistryData_GetImplInfoWhileDiscovering_UnitTest::NewL(CDataLogger& aDataLogger,
   285 											MUnitTestObserver& aObserver)
   286 	{
   287 	CRegistryData_GetImplInfoWhileDiscovering_UnitTest* self = 
   288 			new(ELeave) CRegistryData_GetImplInfoWhileDiscovering_UnitTest(aDataLogger,
   289 																aObserver);
   290 	CleanupStack::PushL(self);
   291 	self->ConstructL();
   292 	CleanupStack::Pop(self);
   293 	return self; 
   294 	}
   295 
   296 inline TInt CRegistryData_GetImplInfoWhileDiscovering_UnitTest::RunError(TInt aError)
   297 	{
   298 	// The RunL left so chain to the base first and then cleanup
   299 	TInt error = CUnitTest::RunError(aError);	// Chain to base
   300 	delete iUTContext;
   301 	delete iStateAccessor;
   302 	// delete any validators used
   303 	delete iCtorValidator;
   304 	delete iGetImplInfoValidator;
   305 	delete iDiscoveriesBeginningValidator;
   306 	delete iGetSecondImplInfoValidator;
   307 	delete iDtorValidator;
   308 
   309 	return error;
   310 	}
   311 
   312 inline CRegistryData_GetImplInfoWhileDiscovering_UnitTest::~CRegistryData_GetImplInfoWhileDiscovering_UnitTest()
   313 	{
   314 	// Simply delete our test class instance
   315 	delete iUTContext;
   316 	delete iStateAccessor;
   317 
   318 	// delete any validators used
   319 	delete iCtorValidator;
   320 	delete iGetImplInfoValidator;
   321 	delete iDiscoveriesBeginningValidator;
   322 	delete iGetSecondImplInfoValidator;
   323 	delete iDtorValidator;
   324 	}
   325 
   326 inline CRegistryData_GetImplInfoWhileDiscovering_UnitTest::
   327 	CRegistryData_GetImplInfoWhileDiscovering_UnitTest(CDataLogger& aDataLogger,
   328 													   MUnitTestObserver& aObserver)
   329 : CUnitTest(KRegistryDataInfoWhileDiscoveringUnitTest, aDataLogger, aObserver)
   330 	{
   331 	//Do nothing
   332 	}
   333 
   334 // Now the Individual transitions need to be added.
   335 inline void CRegistryData_GetImplInfoWhileDiscovering_UnitTest::ConstructL()
   336 	{
   337 	// Perform the base class initialization
   338 	UnitTestConstructL();
   339 
   340 	// Create the Unit test state accessor
   341 	iStateAccessor = new(ELeave) TRegistryData_StateAccessor;
   342 
   343 	// Construct the Unit test context.
   344 	iUTContext = new(ELeave) CRegistryData_UnitTestContext(iDataLogger, 
   345 														   *iStateAccessor, 
   346 														   *this, 
   347 														   iFs);
   348 
   349 	iUTContext->iInterfaceUid.iUid		= KCExampleInterfaceUid.iUid;
   350 	iUTContext->iImplementationUid.iUid	= KCExampleInterfaceImp.iUid;
   351 
   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);
   359 
   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));
   365 	}
   366