os/ossrv/lowlevellibsandfws/pluginfw/Framework/RegistryDataTest/RegistryDataUnitTests.inl
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/RegistryDataTest/RegistryDataUnitTests.inl	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,366 @@
     1.4 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// The implementaition of the unit tests for the CRegistryData class.
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +const TUid KCExampleInterfaceUid = {0x10009DC0};
    1.22 +const TUid KCExampleInterfaceImp = {0x10009DC3};
    1.23 +
    1.24 +// ______________________________________________________________________________
    1.25 +//
    1.26 +_LIT(KRegistryDataCreateAndDestroyUnitTest,"CRegistryData_CreateAndDestroy_UnitTest");
    1.27 +
    1.28 +CRegistryData_CreateAndDestroy_UnitTest* CRegistryData_CreateAndDestroy_UnitTest::NewL(CDataLogger& aDataLogger,
    1.29 +											MUnitTestObserver& aObserver)
    1.30 +	{
    1.31 +	CRegistryData_CreateAndDestroy_UnitTest* self = 
    1.32 +					new(ELeave) CRegistryData_CreateAndDestroy_UnitTest(aDataLogger,
    1.33 +																aObserver);
    1.34 +	CleanupStack::PushL(self);
    1.35 +	self->ConstructL();
    1.36 +	CleanupStack::Pop();
    1.37 +	return self; 
    1.38 +	}
    1.39 +
    1.40 +inline TInt CRegistryData_CreateAndDestroy_UnitTest::RunError(TInt aError)
    1.41 +	{
    1.42 +	// The RunL left so chain to the base first and then cleanup
    1.43 +	TInt error = CUnitTest::RunError(aError);	// Chain to base
    1.44 +	delete iUTContext;
    1.45 +	delete iStateAccessor;
    1.46 +	delete iCtorValidator;
    1.47 +	delete iDtorValidator;
    1.48 +	return error;
    1.49 +	}
    1.50 +
    1.51 +inline CRegistryData_CreateAndDestroy_UnitTest::~CRegistryData_CreateAndDestroy_UnitTest()
    1.52 +	{
    1.53 +	// Simply delete our test class instance
    1.54 +	delete iUTContext;
    1.55 +	delete iStateAccessor;
    1.56 +	delete iCtorValidator;
    1.57 +	delete iDtorValidator;
    1.58 +	}
    1.59 +
    1.60 +inline CRegistryData_CreateAndDestroy_UnitTest::CRegistryData_CreateAndDestroy_UnitTest(CDataLogger& aDataLogger,
    1.61 +																	MUnitTestObserver& aObserver)
    1.62 +: CUnitTest(KRegistryDataCreateAndDestroyUnitTest, aDataLogger, aObserver)
    1.63 +	{
    1.64 +	//Do nothing
    1.65 +	}
    1.66 +
    1.67 +// Now the Individual transitions need to be added.
    1.68 +inline void CRegistryData_CreateAndDestroy_UnitTest::ConstructL()
    1.69 +	{
    1.70 +	// Perform the base class initialization
    1.71 +	UnitTestConstructL();
    1.72 +
    1.73 +	// Create the Unit test state accessor
    1.74 +	iStateAccessor = new(ELeave) TRegistryData_StateAccessor;
    1.75 +	// Construct the Unit test context.
    1.76 +	iUTContext = new(ELeave) CRegistryData_UnitTestContext(iDataLogger, *iStateAccessor, *this, iFs);
    1.77 +	// and a default validator
    1.78 +	iCtorValidator = new(ELeave) TRegistryData_Ctor_TransitionValidator(*iUTContext);
    1.79 +	iDtorValidator = new(ELeave) TRegistryData_Dtor_TransitionValidator(*iUTContext);
    1.80 +	// Add the Transitions in the order they are to run
    1.81 +	// C'tor first, D'tor last...
    1.82 +	//	Examples of C'tor and D'tor transitions on CRegistryData class.
    1.83 +	AddTransitionL(new(ELeave)CRegistryData_NewL_Transition(*iUTContext,*iCtorValidator));
    1.84 +	AddTransitionL(new(ELeave)CRegistryData_Dtor_Transition(*iUTContext,*iDtorValidator));
    1.85 +	}
    1.86 +
    1.87 +void CRegistryData_CreateAndDestroy_UnitTest::PrepareUnitTestL()
    1.88 +	{
    1.89 +	}
    1.90 +
    1.91 +// ______________________________________________________________________________
    1.92 +//
    1.93 +_LIT(KRegistryDataAddDataUnitTest,"CRegistryData_AddData_UnitTest");
    1.94 +
    1.95 +CRegistryData_AddData_UnitTest* CRegistryData_AddData_UnitTest::NewL(CDataLogger& aDataLogger,
    1.96 +											MUnitTestObserver& aObserver)
    1.97 +	{
    1.98 +	CRegistryData_AddData_UnitTest* self = 
    1.99 +					new(ELeave) CRegistryData_AddData_UnitTest(aDataLogger,
   1.100 +																aObserver);
   1.101 +	CleanupStack::PushL(self);
   1.102 +	self->ConstructL();
   1.103 +	CleanupStack::Pop();
   1.104 +	return self; 
   1.105 +	}
   1.106 +
   1.107 +inline TInt CRegistryData_AddData_UnitTest::RunError(TInt aError)
   1.108 +	{
   1.109 +	// The RunL left so chain to the base first and then cleanup
   1.110 +	TInt error = CUnitTest::RunError(aError);	// Chain to base
   1.111 +	delete iUTContext;
   1.112 +	delete iStateAccessor;
   1.113 +
   1.114 +	delete iCtorValidator;
   1.115 +	delete iSetObserverValidator;
   1.116 +	delete iUndoTemporaryUninstallValidator;
   1.117 +	delete iAddDllDataValidator;
   1.118 +	delete iIsRegisteredValidator;
   1.119 +	delete iUpdateDllDataValidator;
   1.120 +	delete iTemporaryUninstallValidator;
   1.121 +	delete iPersistNowValidator;
   1.122 +	delete iDtorValidator;
   1.123 +
   1.124 +	return error;
   1.125 +	}
   1.126 +
   1.127 +inline CRegistryData_AddData_UnitTest::~CRegistryData_AddData_UnitTest()
   1.128 +	{
   1.129 +	// Simply delete our test class instance
   1.130 +	delete iUTContext;
   1.131 +	delete iStateAccessor;
   1.132 +	
   1.133 +	// delete any validators used
   1.134 +	delete iCtorValidator;
   1.135 +	delete iSetObserverValidator;
   1.136 +	delete iUndoTemporaryUninstallValidator;
   1.137 +	delete iAddDllDataValidator;
   1.138 +	delete iIsRegisteredValidator;
   1.139 +	delete iUpdateDllDataValidator;
   1.140 +	delete iTemporaryUninstallValidator;
   1.141 +	delete iPersistNowValidator;
   1.142 +
   1.143 +	delete iDtorValidator;
   1.144 +	}
   1.145 +
   1.146 +inline CRegistryData_AddData_UnitTest::CRegistryData_AddData_UnitTest(CDataLogger& aDataLogger,
   1.147 +																	MUnitTestObserver& aObserver)
   1.148 +: CUnitTest(KRegistryDataAddDataUnitTest, aDataLogger, aObserver)
   1.149 +	{
   1.150 +	//Do nothing
   1.151 +	}
   1.152 +
   1.153 +// Now the Individual transitions need to be added.
   1.154 +inline void CRegistryData_AddData_UnitTest::ConstructL()
   1.155 +	{
   1.156 +	// Perform the base class initialization
   1.157 +	UnitTestConstructL();
   1.158 +
   1.159 +	// Create the Unit test state accessor
   1.160 +	iStateAccessor = new(ELeave) TRegistryData_StateAccessor;
   1.161 +
   1.162 +	// Construct the Unit test context.
   1.163 +	iUTContext = new(ELeave) CRegistryData_UnitTestContext(iDataLogger, 
   1.164 +														   *iStateAccessor, 
   1.165 +														   *this, 
   1.166 +														   iFs);
   1.167 +	_LIT(KDDriveLetter, "D");
   1.168 +	iUTContext->iDriveUnit = KDDriveLetter;
   1.169 +	iUTContext->iFoundDriveIndex = -1;
   1.170 +	TUid thirdUid = {0x10009DB1};
   1.171 +	iUTContext->iDllEntry.iType = TUidType(KNullUid, KNullUid, thirdUid);
   1.172 +	iUTContext->iDllData = CRegistryData::CDllData::NewLC(iUTContext->iDllEntry);
   1.173 +	CleanupStack::Pop(iUTContext->iDllData);
   1.174 +	iUTContext->iNewDllData = CRegistryData::CDllData::NewLC(iUTContext->iDllEntry);
   1.175 +	CleanupStack::Pop(iUTContext->iNewDllData);
   1.176 +
   1.177 +	// Add the Transitions in the order they are to run
   1.178 +	// C'tor first, D'tor last...
   1.179 +	iCtorValidator	  = new(ELeave) TRegistryData_Ctor_TransitionValidator(*iUTContext);
   1.180 +	iSetObserverValidator = new(ELeave) TRegistryData_SetPolicyObserver_TransitionValidator(*iUTContext);
   1.181 +	iUndoTemporaryUninstallValidator = new(ELeave) TRegistryData_UndoTemporaryUninstall_TransitionValidator(*iUTContext);
   1.182 +	iAddDllDataValidator = new(ELeave) TRegistryData_AddDllDataL_TransitionValidator(*iUTContext);
   1.183 +	iIsRegisteredValidator = new(ELeave) TRegistryData_IsRegisteredWithDate_TransitionValidator(*iUTContext);
   1.184 +	iUpdateDllDataValidator = new(ELeave) TRegistryData_UpdateDllData_TransitionValidator(*iUTContext);
   1.185 +	iTemporaryUninstallValidator = new(ELeave) TRegistryData_TemporaryUninstall_TransitionValidator(*iUTContext);
   1.186 +	iPersistNowValidator = new(ELeave) TRegistryData_PersistNow_TransitionValidator(*iUTContext);
   1.187 +	iDtorValidator	  = new(ELeave) TRegistryData_Dtor_TransitionValidator(*iUTContext);
   1.188 +
   1.189 +	AddTransitionL(new(ELeave)CRegistryData_NewL_Transition(*iUTContext,*iCtorValidator));
   1.190 +	AddTransitionL(new(ELeave)CRegistryData_UndoTemporaryUninstallL_Transition(*iUTContext,*iUndoTemporaryUninstallValidator));
   1.191 +	AddTransitionL(new(ELeave)CRegistryData_AddDllDataL_Transition(*iUTContext,*iAddDllDataValidator));
   1.192 +	AddTransitionL(new(ELeave)CRegistryData_IsRegisteredWithDateL_Transition(*iUTContext,*iIsRegisteredValidator));
   1.193 +	AddTransitionL(new(ELeave)CRegistryData_UpdateDllDataL_Transition(*iUTContext,*iUpdateDllDataValidator));
   1.194 +	AddTransitionL(new(ELeave)CRegistryData_TemporaryUninstallL_Transition(*iUTContext,*iTemporaryUninstallValidator));
   1.195 +	AddTransitionL(new(ELeave)CRegistryData_PersistNowL_Transition(*iUTContext,*iPersistNowValidator));
   1.196 +	AddTransitionL(new(ELeave)CRegistryData_Dtor_Transition(*iUTContext,*iDtorValidator));
   1.197 +	}
   1.198 +
   1.199 +// ______________________________________________________________________________
   1.200 +//
   1.201 +_LIT(KRegistryDataRetrieveInfoUnitTest,"CRegistryData_RetrieveInfo_UnitTest");
   1.202 +
   1.203 +CRegistryData_RetrieveInfo_UnitTest* CRegistryData_RetrieveInfo_UnitTest::NewL(CDataLogger& aDataLogger,
   1.204 +											MUnitTestObserver& aObserver)
   1.205 +	{
   1.206 +	CRegistryData_RetrieveInfo_UnitTest* self = 
   1.207 +					new(ELeave) CRegistryData_RetrieveInfo_UnitTest(aDataLogger,
   1.208 +																aObserver);
   1.209 +	CleanupStack::PushL(self);
   1.210 +	self->ConstructL();
   1.211 +	CleanupStack::Pop();
   1.212 +	return self; 
   1.213 +	}
   1.214 +
   1.215 +inline TInt CRegistryData_RetrieveInfo_UnitTest::RunError(TInt aError)
   1.216 +	{
   1.217 +	// The RunL left so chain to the base first and then cleanup
   1.218 +	TInt error = CUnitTest::RunError(aError);	// Chain to base
   1.219 +	delete iUTContext;
   1.220 +	delete iStateAccessor;
   1.221 +	/* delete any validators used */
   1.222 +	delete iCtorValidator;
   1.223 +	delete iListImplementationsValidator;
   1.224 +	delete iGetImplementationInformationValidator;
   1.225 +	delete iDtorValidator;
   1.226 +	return error;
   1.227 +	}
   1.228 +
   1.229 +inline CRegistryData_RetrieveInfo_UnitTest::~CRegistryData_RetrieveInfo_UnitTest()
   1.230 +	{
   1.231 +	// Simply delete our test class instance
   1.232 +	delete iUTContext;
   1.233 +	delete iStateAccessor;
   1.234 +
   1.235 +	delete iCtorValidator;
   1.236 +	delete iListImplementationsValidator;
   1.237 +	delete iGetImplementationInformationValidator;
   1.238 +	delete iDtorValidator;
   1.239 +	}
   1.240 +
   1.241 +inline CRegistryData_RetrieveInfo_UnitTest::CRegistryData_RetrieveInfo_UnitTest(CDataLogger& aDataLogger,
   1.242 +																	MUnitTestObserver& aObserver)
   1.243 +: CUnitTest(KRegistryDataRetrieveInfoUnitTest, aDataLogger, aObserver)
   1.244 +	{
   1.245 +	//Do nothing
   1.246 +	}
   1.247 +
   1.248 +// Now the Individual transitions need to be added.
   1.249 +inline void CRegistryData_RetrieveInfo_UnitTest::ConstructL()
   1.250 +	{
   1.251 +	// Perform the base class initialization
   1.252 +	UnitTestConstructL();
   1.253 +
   1.254 +	// Create the Unit test state accessor
   1.255 +	iStateAccessor = new(ELeave) TRegistryData_StateAccessor;
   1.256 +
   1.257 +	// Construct the Unit test context.
   1.258 +	iUTContext = new(ELeave) CRegistryData_UnitTestContext(iDataLogger, 
   1.259 +														   *iStateAccessor, 
   1.260 +														   *this, 
   1.261 +														   iFs);
   1.262 +	iUTContext->iInterfaceUid.iUid		= KCExampleInterfaceUid.iUid;
   1.263 +	iUTContext->iImplementationUid.iUid	= KCExampleInterfaceImp.iUid;
   1.264 +
   1.265 +	// Add the Transitions in the order they are to run
   1.266 +	iCtorValidator = new(ELeave) TRegistryData_Ctor_TransitionValidator(*iUTContext);
   1.267 +	iListImplementationsValidator = new(ELeave) TRegistryData_ListImplementations_TransitionValidator(*iUTContext);
   1.268 +	iGetImplementationInformationValidator = new(ELeave) TRegistryData_GetImplementationInformation_TransitionValidator(*iUTContext);
   1.269 +	iDtorValidator = new(ELeave) TRegistryData_Dtor_TransitionValidator(*iUTContext);
   1.270 +
   1.271 +	AddTransitionL(new(ELeave)CRegistryData_NewL_Transition(*iUTContext,*iCtorValidator));
   1.272 +	AddTransitionL(new(ELeave)CRegistryData_ListImplementationsL_Transition(*iUTContext,
   1.273 +																			*iListImplementationsValidator));
   1.274 +	AddTransitionL(new(ELeave)CRegistryData_GetImplementationInformationL_Transition(*iUTContext,
   1.275 +																			  *iGetImplementationInformationValidator));
   1.276 +	AddTransitionL(new(ELeave)CRegistryData_Dtor_Transition(*iUTContext,*iDtorValidator));
   1.277 +
   1.278 +	// Add the permissible error codes for failures
   1.279 +	AddLeaveErrorCodeL(KEComErrNoInterfaceIdentified);
   1.280 +	}
   1.281 +
   1.282 +// ______________________________________________________________________________
   1.283 +//
   1.284 +_LIT(KRegistryDataInfoWhileDiscoveringUnitTest,"CRegistryData_GetImplInfoWhileDiscovering_UnitTest");
   1.285 +
   1.286 +CRegistryData_GetImplInfoWhileDiscovering_UnitTest* 
   1.287 +	CRegistryData_GetImplInfoWhileDiscovering_UnitTest::NewL(CDataLogger& aDataLogger,
   1.288 +											MUnitTestObserver& aObserver)
   1.289 +	{
   1.290 +	CRegistryData_GetImplInfoWhileDiscovering_UnitTest* self = 
   1.291 +			new(ELeave) CRegistryData_GetImplInfoWhileDiscovering_UnitTest(aDataLogger,
   1.292 +																aObserver);
   1.293 +	CleanupStack::PushL(self);
   1.294 +	self->ConstructL();
   1.295 +	CleanupStack::Pop(self);
   1.296 +	return self; 
   1.297 +	}
   1.298 +
   1.299 +inline TInt CRegistryData_GetImplInfoWhileDiscovering_UnitTest::RunError(TInt aError)
   1.300 +	{
   1.301 +	// The RunL left so chain to the base first and then cleanup
   1.302 +	TInt error = CUnitTest::RunError(aError);	// Chain to base
   1.303 +	delete iUTContext;
   1.304 +	delete iStateAccessor;
   1.305 +	// delete any validators used
   1.306 +	delete iCtorValidator;
   1.307 +	delete iGetImplInfoValidator;
   1.308 +	delete iDiscoveriesBeginningValidator;
   1.309 +	delete iGetSecondImplInfoValidator;
   1.310 +	delete iDtorValidator;
   1.311 +
   1.312 +	return error;
   1.313 +	}
   1.314 +
   1.315 +inline CRegistryData_GetImplInfoWhileDiscovering_UnitTest::~CRegistryData_GetImplInfoWhileDiscovering_UnitTest()
   1.316 +	{
   1.317 +	// Simply delete our test class instance
   1.318 +	delete iUTContext;
   1.319 +	delete iStateAccessor;
   1.320 +
   1.321 +	// delete any validators used
   1.322 +	delete iCtorValidator;
   1.323 +	delete iGetImplInfoValidator;
   1.324 +	delete iDiscoveriesBeginningValidator;
   1.325 +	delete iGetSecondImplInfoValidator;
   1.326 +	delete iDtorValidator;
   1.327 +	}
   1.328 +
   1.329 +inline CRegistryData_GetImplInfoWhileDiscovering_UnitTest::
   1.330 +	CRegistryData_GetImplInfoWhileDiscovering_UnitTest(CDataLogger& aDataLogger,
   1.331 +													   MUnitTestObserver& aObserver)
   1.332 +: CUnitTest(KRegistryDataInfoWhileDiscoveringUnitTest, aDataLogger, aObserver)
   1.333 +	{
   1.334 +	//Do nothing
   1.335 +	}
   1.336 +
   1.337 +// Now the Individual transitions need to be added.
   1.338 +inline void CRegistryData_GetImplInfoWhileDiscovering_UnitTest::ConstructL()
   1.339 +	{
   1.340 +	// Perform the base class initialization
   1.341 +	UnitTestConstructL();
   1.342 +
   1.343 +	// Create the Unit test state accessor
   1.344 +	iStateAccessor = new(ELeave) TRegistryData_StateAccessor;
   1.345 +
   1.346 +	// Construct the Unit test context.
   1.347 +	iUTContext = new(ELeave) CRegistryData_UnitTestContext(iDataLogger, 
   1.348 +														   *iStateAccessor, 
   1.349 +														   *this, 
   1.350 +														   iFs);
   1.351 +
   1.352 +	iUTContext->iInterfaceUid.iUid		= KCExampleInterfaceUid.iUid;
   1.353 +	iUTContext->iImplementationUid.iUid	= KCExampleInterfaceImp.iUid;
   1.354 +
   1.355 +	// Add the Transitions in the order they are to run
   1.356 +	// C'tor first, D'tor last...
   1.357 +	iCtorValidator = new(ELeave) TRegistryData_Ctor_TransitionValidator(*iUTContext);
   1.358 +	iGetImplInfoValidator = new(ELeave) TRegistryData_GetImplementationInformation_TransitionValidator(*iUTContext);
   1.359 +	iDiscoveriesBeginningValidator = new(ELeave) TRegistryData_DiscoveriesBeginning_TransitionValidator(*iUTContext);
   1.360 +	iGetSecondImplInfoValidator = new(ELeave) TRegistryData_GetSecondImplInfo_TransitionValidator(*iUTContext);
   1.361 +	iDtorValidator = new(ELeave) TRegistryData_Dtor_TransitionValidator(*iUTContext);
   1.362 +
   1.363 +	AddTransitionL(new(ELeave)CRegistryData_NewL_Transition(*iUTContext,*iCtorValidator));
   1.364 +	AddTransitionL(new(ELeave)CRegistryData_GetImplementationInformationL_Transition(*iUTContext,*iGetImplInfoValidator));
   1.365 +	AddTransitionL(new(ELeave)CRegistryData_DiscoveriesBeginning_Transition(*iUTContext,*iDiscoveriesBeginningValidator));
   1.366 +	AddTransitionL(new(ELeave)CRegistryData_GetImplementationInformationL_Transition(*iUTContext,*iGetSecondImplInfoValidator));
   1.367 +	AddTransitionL(new(ELeave)CRegistryData_Dtor_Transition(*iUTContext,*iDtorValidator));
   1.368 +	}
   1.369 +