os/persistentdata/persistentstorage/centralrepository/test/t_cenrep_fotaUT.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/centralrepository/test/t_cenrep_fotaUT.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1018 @@
     1.4 +// Copyright (c) 2008-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 +//
    1.18 +
    1.19 +#include <e32test.h>
    1.20 +#include <f32file.h>
    1.21 +#include <badesca.h>
    1.22 +
    1.23 +#include "srvrepos_noc.h"
    1.24 +#include "srvres.h"
    1.25 +#include "cachemgr.h"
    1.26 +#include "sessnotf.h"
    1.27 +#include "t_cenrep_helper.h"
    1.28 +
    1.29 +#include "testexecute/SWI/src/tui.h"
    1.30 +#include <swi/launcher.h>
    1.31 +#include "swi/sisregistrysession.h"
    1.32 +#include "swi/sisregistrypackage.h"
    1.33 +#include "swi/sisregistryentry.h"
    1.34 +
    1.35 +
    1.36 +RTest TheTest(_L("Central Repository FOTx Unit Tests"));
    1.37 +
    1.38 +_LIT(KCachedVersionFile,"C:\\private\\10202be9\\romversion\\romversion_info.txt");
    1.39 +_LIT(KModified2RepositoryCre,"z:\\private\\10202be9\\10033333_modified2.cre");
    1.40 +_LIT(KPersistsRepositoryCre,"C:\\private\\10202be9\\persists\\10033333.cre");
    1.41 +_LIT(KStoredSWIRepository,"z:\\private\\10202be9\\10033333_modified3.cre");
    1.42 +_LIT(KSWIInstallRepository,"C:\\private\\10202be9\\10033333.cre");
    1.43 +_LIT(KModifiedSwVersion, "z:\\private\\10202be9\\sw_modified.txt");
    1.44 +_LIT(KStoredRepository,"z:\\private\\10202be9\\10033340_reserved.cre");
    1.45 +_LIT(KStoredRepository2,"z:\\private\\10202be9\\10033341_orig.cre");
    1.46 +_LIT(KPersistsBasedRepository,"C:\\private\\10202be9\\persists\\10033340.cre");
    1.47 +_LIT(KPersistsBasedRepository2,"C:\\private\\10202be9\\persists\\10033341.cre");
    1.48 +
    1.49 +_LIT(KRomRepositoryCre1,"z:\\private\\10202be9\\10043336_persists.cre");
    1.50 +_LIT(KRomRepositoryCre2,"z:\\private\\10202be9\\10043337_persists.cre");
    1.51 +_LIT(KRomRepositoryCre3,"z:\\private\\10202be9\\10043338_persists.cre");
    1.52 +_LIT(KPersistsRepositoryCre1,"C:\\private\\10202be9\\persists\\10043336.cre");
    1.53 +_LIT(KPersistsRepositoryCre2,"C:\\private\\10202be9\\persists\\10043337.cre");
    1.54 +_LIT(KPersistsRepositoryCre3,"C:\\private\\10202be9\\persists\\10043338.cre");
    1.55 +
    1.56 +
    1.57 +_LIT(KSisFile,"z:\\private\\10202be9\\RF1.sis");
    1.58 +_LIT(KSisFile2,"z:\\private\\10202be9\\RF4.sis");
    1.59 +
    1.60 +const TUid KUidRomRepositoryList[]   = {0x10033333,0x10033340,0x10033341,0x10043336,0x10043337,0x10043338};
    1.61 +const TUint32 KNewSettingList[]      = {1000,1001,0x2300,0x02010000};
    1.62 +const TUint32 KModifiedSettingList[] = {0x04010200,0x04010400,0x03010100};
    1.63 +const TUint32 KDeletedSettingList[]  = {0x03010500,0x04010100,0x02010300};
    1.64 +const TUint32 KSWIBasedSettingList[] = {0x08010100};
    1.65 +const TInt KSettingValueList[]       = {1234,1111,12345,10,200,400};
    1.66 +
    1.67 +///////////////////////////////////////////////////////////////////////////////////////
    1.68 +///////////////////////////////////////////////////////////////////////////////////////
    1.69 +//Test macroses and functions
    1.70 +
    1.71 +LOCAL_C void DeleteFilesL()
    1.72 +	{
    1.73 +	_LIT( KOldInstallFiles, "c:\\private\\10202BE9\\*.cre" );
    1.74 +	_LIT( KOldPersistsFiles, "c:\\private\\10202BE9\\persists\\100*.cre" );
    1.75 +	_LIT( KOldRomVersionFiles, "c:\\private\\10202BE9\\romversion\\romversion_info.t*" );
    1.76 +	CFileMan* fm = CFileMan::NewL( TServerResources::iFs );
    1.77 +	CleanupStack::PushL( fm );
    1.78 +
    1.79 +	TInt r = fm->Delete( KOldInstallFiles );
    1.80 +	if ( r != KErrNone && r != KErrNotFound && r != KErrPathNotFound )
    1.81 +		User::Leave(r);
    1.82 +	r = fm->Delete( KOldPersistsFiles);
    1.83 +	if ( r != KErrNone && r != KErrNotFound && r != KErrPathNotFound )
    1.84 +		User::Leave(r);
    1.85 +	r = fm->Delete( KOldRomVersionFiles,CFileMan::ERecurse);
    1.86 +	if ( r != KErrNone && r != KErrNotFound && r != KErrPathNotFound )
    1.87 +		User::Leave(r);
    1.88 +
    1.89 +	CleanupStack::PopAndDestroy( fm );
    1.90 +	}
    1.91 +
    1.92 +LOCAL_C void Check( TInt aValue, TInt aLine )
    1.93 +	{
    1.94 +	if ( !aValue )
    1.95 +		{
    1.96 +		TheTest( EFalse, aLine );
    1.97 +		}
    1.98 +	}
    1.99 +
   1.100 +LOCAL_C void Check( TInt aValue, TInt aExpected, TInt aLine )
   1.101 +	{
   1.102 +	if ( aValue != aExpected )
   1.103 +		{
   1.104 +		RDebug::Print( _L( "*** Expected error: %d, got: %d\r\n"), aExpected, aValue );
   1.105 +		TheTest( EFalse, aLine );
   1.106 +		}
   1.107 +	}
   1.108 +
   1.109 +#define TEST(arg) ::Check((arg), __LINE__)
   1.110 +#define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
   1.111 +
   1.112 +///////////////////////////////////////////////////////////////////////////////////////
   1.113 +///////////////////////////////////////////////////////////////////////////////////////
   1.114 +
   1.115 +LOCAL_C void CleanUp()
   1.116 +	{
   1.117 +	// If cache manager is initialized and used before, we flush it
   1.118 +	if (TServerResources::iCacheManager)
   1.119 +		{
   1.120 +		TServerResources::iCacheManager->FlushCache();
   1.121 +		}
   1.122 +	// To get rid of the iOpenRepositories array leaking problem during OOM testing.
   1.123 +	TServerResources::iObserver->CloseiOpenRepositories();
   1.124 +	TServerResources::iObserver->Reset();
   1.125 +	// To get rid of the array leaking problems during OOM testing.
   1.126 +	TServerResources::iOwnerIdLookUpTable.Reset();
   1.127 +	User::After(KGeneralDelay);
   1.128 +	}
   1.129 +
   1.130 +LOCAL_C void PerformSWIinstallL(const TDesC& aSisFileName)
   1.131 +{
   1.132 +//********************************************************
   1.133 +//Requires stub file to be set up before it will work
   1.134 +//requires techview
   1.135 +//********************************************************
   1.136 +   	using namespace Swi;
   1.137 +   	TUI* Ui = new(ELeave) TUI();
   1.138 +   	CInstallPrefs* prefs = CInstallPrefs::NewLC();
   1.139 +   	TInt err = Launcher::Install(*Ui, aSisFileName, *prefs);
   1.140 +   	delete Ui;
   1.141 + 	TEST2(err, KErrNone);
   1.142 +   	CleanupStack::PopAndDestroy();//prefs
   1.143 +
   1.144 +    User::After(KGeneralDelay);
   1.145 +
   1.146 +	// If cache manager is initialized and used before, we flush it
   1.147 +	CleanUp();
   1.148 +}
   1.149 +
   1.150 +LOCAL_C void UserModifyRepositoryL()
   1.151 +{
   1.152 +	CSessionNotifier* notifier = new(ELeave)CSessionNotifier;
   1.153 +	CleanupStack::PushL(notifier);
   1.154 +
   1.155 +    CServerRepository* repository = new(ELeave) CServerRepository();
   1.156 +    CleanupStack::PushL(repository);
   1.157 +
   1.158 +    repository->OpenL(KUidRomRepositoryList[0],*notifier);
   1.159 +
   1.160 +    User::LeaveIfError(repository->StartTransaction(EReadWriteTransaction));
   1.161 +
   1.162 +	TInt err = repository->TransactionDeleteL(KDeletedSettingList[0]);
   1.163 +	TEST2(err,KErrNone);
   1.164 +
   1.165 +	err = repository->TransactionCreateL(KNewSettingList[1],KSettingValueList[0],NULL);
   1.166 +	TEST2(err,KErrNone);
   1.167 +	err = repository->TransactionCreateL(KNewSettingList[2],KSettingValueList[0],NULL);
   1.168 +	TEST2(err,KErrNone);
   1.169 +	err = repository->TransactionDeleteL(KDeletedSettingList[2]);
   1.170 + 	TEST2(err,KErrNone);
   1.171 + 	err = repository->TransactionDeleteL(KNewSettingList[1]);//remove a setting added by the user
   1.172 + 	TEST2(err,KErrNone);
   1.173 +	err = repository->TransactionSetL(KModifiedSettingList[2],KSettingValueList[2]);
   1.174 +	TEST2(err,KErrNone);
   1.175 +
   1.176 +	TUint32 tempKeyInfo;
   1.177 +	User::LeaveIfError(repository->CommitTransaction(tempKeyInfo));
   1.178 +
   1.179 +	repository->Close();
   1.180 +	CleanupStack::PopAndDestroy(2);//repository, notifier
   1.181 +}
   1.182 +
   1.183 +LOCAL_C void UserModifyRepository2L()
   1.184 +{
   1.185 +	//Have the user add,delete and modify some entries
   1.186 +	CSessionNotifier* notifier = new(ELeave)CSessionNotifier;
   1.187 +	CleanupStack::PushL(notifier);
   1.188 +
   1.189 +    CServerRepository* repository = new(ELeave) CServerRepository();
   1.190 +    CleanupStack::PushL(repository);
   1.191 +    repository->OpenL(KUidRomRepositoryList[0],*notifier);
   1.192 +
   1.193 +    User::LeaveIfError(repository->StartTransaction(EReadWriteTransaction));
   1.194 +   	//0x03010500 has been deleted by user in modified persisted repository.
   1.195 +    //but this rom based deleted setting, should have been reinstated by the SWI, which also contains it.
   1.196 +	TInt settingValue = 0;
   1.197 +	TInt r = repository->Get(KDeletedSettingList[2], settingValue);
   1.198 +	TEST(r == KErrNone);
   1.199 +
   1.200 +	//delete the SWI and rom based setting, it should be reinstated after the rom update.
   1.201 +	r = repository->TransactionDeleteL(KDeletedSettingList[2]);
   1.202 + 	TEST2(r,KErrNone);
   1.203 +	//
   1.204 +	//Modify setting
   1.205 +	r = repository->TransactionSetL(KModifiedSettingList[2],KSettingValueList[2]);
   1.206 +	TEST2(r,KErrNone);
   1.207 +	//Add and delete a user setting
   1.208 +	r = repository->TransactionCreateL(KNewSettingList[1],KSettingValueList[0],NULL);
   1.209 +	TEST2(r,KErrNone);
   1.210 +	 r = repository->TransactionDeleteL(KNewSettingList[1]);//remove a setting added by the user
   1.211 + 	TEST2(r,KErrNone);
   1.212 + 	//Add a user setting
   1.213 +	r = repository->TransactionCreateL(KNewSettingList[2],KSettingValueList[0],NULL);
   1.214 +	TEST2(r,KErrNone);
   1.215 +
   1.216 +	TUint32 tempKeyInfo;
   1.217 +	User::LeaveIfError(repository->CommitTransaction(tempKeyInfo));
   1.218 +	repository->Close();
   1.219 +	CleanupStack::PopAndDestroy(2);//repository, notifier
   1.220 +}
   1.221 +
   1.222 +LOCAL_C void VerifyCorrectMergingL(TInt aVerifySwi = EFalse)
   1.223 +{
   1.224 +	//Check the merge content for correctness.
   1.225 +	CSessionNotifier* notifier = new(ELeave)CSessionNotifier;
   1.226 +	CleanupStack::PushL(notifier);
   1.227 +
   1.228 +    CServerRepository* repository = new(ELeave) CServerRepository();
   1.229 +    CleanupStack::PushL(repository);
   1.230 +
   1.231 +    repository->OpenL(KUidRomRepositoryList[0],*notifier);
   1.232 +
   1.233 +	//Get the rom based user deleted setting, it should have been reinstated.
   1.234 +	TInt settingValue = 0;
   1.235 +	TInt r = repository->Get(KDeletedSettingList[2], settingValue);
   1.236 +	TEST(r == KErrNone);
   1.237 +	//Get the user based deleted setting, it should still be missing.
   1.238 +	r = repository->Get(KNewSettingList[1], settingValue);
   1.239 +	TEST(r == KErrNotFound);
   1.240 +	//Get the user added setting.
   1.241 +	r = repository->Get(KNewSettingList[2], settingValue);
   1.242 +	TEST(r == KErrNone);
   1.243 +	//Get user modified settings. It should contain the user modification
   1.244 +	r = repository->Get(KModifiedSettingList[2], settingValue);
   1.245 +	TEST(r == KErrNone);
   1.246 +	TEST(settingValue == KSettingValueList[2]);
   1.247 +
   1.248 +	if(aVerifySwi)
   1.249 +	{
   1.250 +	//Get SWI modified settings for a clean rom value. It should contain the SWI modification
   1.251 +	settingValue = 0;
   1.252 +	r = repository->Get(KModifiedSettingList[0], settingValue);
   1.253 +	TEST(r == KErrNone);
   1.254 +	TEST(settingValue == KSettingValueList[2]);
   1.255 +	//Get SWI added setting
   1.256 +	r = repository->Get(KNewSettingList[0], settingValue);
   1.257 +	TEST(r == KErrNone);
   1.258 +	}
   1.259 +	repository->Close();
   1.260 +	CleanupStack::PopAndDestroy(2);//repository, notifier
   1.261 +}
   1.262 +
   1.263 +/**
   1.264 +@SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-UT-4025
   1.265 +@SYMTestCaseDesc		This test verifies that a locally persisted copy of the rom version file
   1.266 +						is created after a call to CheckROMReflashL
   1.267 +@SYMTestPriority		High
   1.268 +@SYMTestActions			Remove locally persisted rom version file.
   1.269 +						Call CheckROMReflashL to simulate a reboot of cenrep.
   1.270 +						Check that locally persisted copy of rom version file is created.
   1.271 +@SYMTestExpectedResults Persisted copy of rom version file has been created.
   1.272 +@SYMCR					CR1198
   1.273 +*/
   1.274 +LOCAL_C void SYSLIB_CENTRALREPOSITORY_UT_4025L()
   1.275 +{
   1.276 +	TheTest.Next( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-UT-4025 " ) );
   1.277 +	CFileMan* fm = CFileMan::NewL(TServerResources::iFs);
   1.278 +
   1.279 +	// Remove locally stored rom version file if it exists
   1.280 +	TInt err = fm->Delete(KCachedVersionFile);
   1.281 +	if((err != KErrNotFound) && (err != KErrNone))
   1.282 +	  {
   1.283 +	  RDebug::Print( _L( "*** UnExpected error: %d\r\n"), err );
   1.284 +	  TheTest( EFalse, __LINE__ );
   1.285 +	  }
   1.286 +
   1.287 +	delete fm;//fm
   1.288 +	CServerRepository::CheckROMReflashL();
   1.289 +	User::After(KGeneralDelay);//Allow the filesystem to write the files.
   1.290 +
   1.291 +	TEntry entry;
   1.292 +	TEST(TServerResources::iFs.Entry(KCachedVersionFile,entry) == KErrNone);
   1.293 +
   1.294 +}
   1.295 +
   1.296 +/**
   1.297 +@SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-UT-4026
   1.298 +@SYMTestCaseDesc		This test verifies that when the locally persisted copy of the rom version file
   1.299 +						is equal to the rom version file then no merging takes place.
   1.300 +@SYMTestPriority		High
   1.301 +@SYMTestActions			Remove a rom based setting.
   1.302 +						Call CheckROMReflashL to simulate a reboot of cenrep.
   1.303 +						Check that the deleted value hasnt been reinstated.
   1.304 +@SYMTestExpectedResults Deleted value hasnt been reinstated, demonstrating that no merge took place.
   1.305 +@SYMCR					CR1198
   1.306 +*/
   1.307 +LOCAL_C void SYSLIB_CENTRALREPOSITORY_UT_4026L()
   1.308 +{
   1.309 +	TheTest.Next( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-UT-4026 " ) );
   1.310 +	CFileMan* fm = CFileMan::NewL(TServerResources::iFs);
   1.311 +
   1.312 +	//Initial cleanup
   1.313 +	fm->Delete(KPersistsRepositoryCre);
   1.314 +	delete fm;//fm
   1.315 +
   1.316 +	CSessionNotifier* notifier = new(ELeave)CSessionNotifier;
   1.317 +	CleanupStack::PushL(notifier);
   1.318 +
   1.319 +    CServerRepository* repository = new(ELeave) CServerRepository();
   1.320 +    CleanupStack::PushL(repository);
   1.321 +
   1.322 +    repository->OpenL(KUidRomRepositoryList[0],*notifier);
   1.323 +
   1.324 +	//Attempt to retrieve a setting before deleting it.
   1.325 +    User::LeaveIfError(repository->StartTransaction(EReadWriteTransaction));
   1.326 +	TInt settingValue = 0;
   1.327 +	TInt r = repository->Get(KDeletedSettingList[0], settingValue);
   1.328 +	TEST(r == KErrNone);
   1.329 +
   1.330 +	repository->TransactionDeleteL(KDeletedSettingList[0]);
   1.331 +	TUint32 tempKeyInfo;
   1.332 +	User::LeaveIfError(repository->CommitTransaction(tempKeyInfo));
   1.333 +
   1.334 +	repository->Close();
   1.335 +	CleanupStack::PopAndDestroy(2);//repository, notifier
   1.336 +
   1.337 +	//Dont Copy modified stored rom version info so that no rom update should take place
   1.338 +
   1.339 +	// flush cache
   1.340 +	CleanUp();
   1.341 +
   1.342 +	CServerRepository::CheckROMReflashL();
   1.343 +
   1.344 +	notifier = new(ELeave)CSessionNotifier;
   1.345 +	CleanupStack::PushL(notifier);
   1.346 +
   1.347 +    repository = new(ELeave) CServerRepository();
   1.348 +    CleanupStack::PushL(repository);
   1.349 +
   1.350 +    repository->OpenL(KUidRomRepositoryList[0],*notifier);
   1.351 +
   1.352 +	r = repository->Get(KDeletedSettingList[0], settingValue);
   1.353 +	TEST(r == KErrNotFound);//It hasnt been reinstated.
   1.354 +
   1.355 +	repository->Close();
   1.356 +
   1.357 +	CleanupStack::PopAndDestroy(2);//repository, notifier
   1.358 +
   1.359 +	// If cache manager is initialized and used before, we flush it
   1.360 +	CleanUp();
   1.361 +}
   1.362 +
   1.363 +/**
   1.364 +@SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-UT-4027
   1.365 +@SYMTestCaseDesc		This test verifies that after a rom flash, rom and user modified values are merged correctly.
   1.366 +@SYMTestPriority		High
   1.367 +@SYMTestActions			Open a repository and create two settings.
   1.368 +						Delete a rom based setting.
   1.369 +						Delete on of the new settings.
   1.370 +						Remove a rom based setting.
   1.371 +						Modify a rom based setting.
   1.372 +						Call CheckROMReflashL to simulate a reboot of cenrep.
   1.373 +						Check that the deleted rom base value has been reinstated.
   1.374 +						Check that the deleted user setting hasnt been reinstated.
   1.375 +
   1.376 +@SYMTestExpectedResults Deleted user value hasnt been reinstated.
   1.377 +						Deleted rom based value has been reinstated.
   1.378 +						Other User added setting is present.
   1.379 +						User modified setting contains user value.
   1.380 +@SYMCR					CR1198
   1.381 +*/
   1.382 +LOCAL_C void SYSLIB_CENTRALREPOSITORY_UT_4027L()
   1.383 +{
   1.384 +	TheTest.Next( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-UT-4027 " ) );//Force a rom update for this repository.
   1.385 +
   1.386 +	CFileMan* fm = CFileMan::NewL(TServerResources::iFs);
   1.387 +	CleanupStack::PushL(fm);
   1.388 +
   1.389 +	//Initial cleanup
   1.390 +	fm->Delete(KPersistsRepositoryCre);
   1.391 +
   1.392 +	//Copy of modified stored rom version info
   1.393 +	User::LeaveIfError(fm->Copy(KModifiedSwVersion,KCachedVersionFile,CFileMan::EOverWrite));
   1.394 +	User::LeaveIfError(fm->Attribs(KCachedVersionFile,0,KEntryAttReadOnly,TTime(0)));
   1.395 +	User::After(KGeneralDelay);
   1.396 +
   1.397 +	UserModifyRepositoryL();
   1.398 +
   1.399 +	// flush the cache manager contents.
   1.400 +	CleanUp();
   1.401 +
   1.402 +	CServerRepository::CheckROMReflashL();
   1.403 +
   1.404 +	VerifyCorrectMergingL(EFalse);
   1.405 +
   1.406 +	//Final Cleanup
   1.407 +	fm->Delete(KPersistsRepositoryCre);
   1.408 +
   1.409 +	CleanupStack::PopAndDestroy();//fm
   1.410 +
   1.411 +	// If cache manager is initialized and used before, we flush it
   1.412 +	CleanUp();
   1.413 +}
   1.414 +
   1.415 +/**
   1.416 +@SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-UT-4028
   1.417 +@SYMTestCaseDesc		This test verifies that repositories that exist in persists directory but have
   1.418 +						no basis in install or rom are removed after a rom update.
   1.419 +@SYMTestPriority		High
   1.420 +@SYMTestActions			Copy a repository into the persists directory that has no rom or SWI equivalent.
   1.421 +						Call CheckROMReflashL to simulate a reboot of cenrep.
   1.422 +						Verify that the persisted repository is removed.
   1.423 +
   1.424 +@SYMTestExpectedResults Persisted repository is removed during rom update.
   1.425 +@SYMCR					CR1198
   1.426 +*/
   1.427 +LOCAL_C void SYSLIB_CENTRALREPOSITORY_UT_4028L()
   1.428 +{
   1.429 +	TheTest.Next( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-UT-4028 " ) );
   1.430 +	CFileMan* fm = CFileMan::NewL(TServerResources::iFs);
   1.431 +	CleanupStack::PushL(fm);
   1.432 +
   1.433 +	//Initial cleanup
   1.434 +	fm->Delete(KPersistsBasedRepository);
   1.435 +
   1.436 +	//Place a repository in persists that has no basis in SWI or rom and it should be removed.
   1.437 +	//by the rom update as it will look like a rom based repository that has been removed by
   1.438 +	//the update.
   1.439 +
   1.440 +	//Copy the repository that isnt in SWI or ROM to persists
   1.441 +	//Copy 100333340_reserved to 100333340.cre persists
   1.442 +	User::LeaveIfError(fm->Copy(KStoredRepository,KPersistsBasedRepository,CFileMan::EOverWrite));
   1.443 +	User::LeaveIfError(fm->Attribs(KPersistsBasedRepository,0,KEntryAttReadOnly,TTime(0)));
   1.444 +	User::After(KGeneralDelay);
   1.445 +	//Copy of modified stored rom version info
   1.446 +
   1.447 +	User::LeaveIfError(fm->Copy(KModifiedSwVersion,KCachedVersionFile,CFileMan::EOverWrite));
   1.448 +	User::LeaveIfError(fm->Attribs(KCachedVersionFile,0,KEntryAttReadOnly,TTime(0)));
   1.449 +	User::After(KGeneralDelay);
   1.450 +	CleanupStack::PopAndDestroy();//fm
   1.451 +
   1.452 +	CServerRepository::CheckROMReflashL();
   1.453 +	TEntry entry;
   1.454 +
   1.455 +	TEST(TServerResources::iFs.Entry(KPersistsBasedRepository,entry) == KErrNotFound);
   1.456 +
   1.457 +}
   1.458 +
   1.459 +/**
   1.460 +@SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-UT-4029
   1.461 +@SYMTestCaseDesc		This test verifies that a repository is merged correctly with SWI and user changes after a rom update.
   1.462 +@SYMTestPriority		High
   1.463 +@SYMTestActions			Copy a prepared repository into the persists directory that contains clean
   1.464 +						settings that do not exist in its rom equivalent,missing settings that exist in
   1.465 +						its rom equivalent and user modified settings that differ from its rom equivalent.
   1.466 +						Perform an SWI install to modify and add some settings.
   1.467 +						The user adds,deletes and modifies some settings.
   1.468 +						Copy a modified rom version file over the locally persisted rom version file.
   1.469 +						Call CheckROMReflashL to simulate a reboot of cenrep.
   1.470 +@SYMTestExpectedResults Verify that the persisted repository clean settings that do not exist in rom equivalent are removed.
   1.471 +						Verify that settings in the rom repository that are not in the persisted repository are added.
   1.472 +						Verify that user modified settings retain user values.
   1.473 +						Verify that the rom based user deleted setting are reinstated.
   1.474 +						Verify that the user based deleted setting is not present.
   1.475 +						Verify the user added setting exists.
   1.476 +@SYMCR					CR1198
   1.477 +*/
   1.478 +LOCAL_C void SYSLIB_CENTRALREPOSITORY_UT_4029L()
   1.479 +{
   1.480 +	TheTest.Next( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-UT-4029 " ) );
   1.481 +	CFileMan* fm = CFileMan::NewL(TServerResources::iFs);
   1.482 +	CleanupStack::PushL(fm);
   1.483 +
   1.484 +	//Initial cleanup
   1.485 +	fm->Delete(KPersistsRepositoryCre);
   1.486 +
   1.487 +	//Merge User, Rom and SWI settings.
   1.488 +	//Need to copy a repository into the persists, that has a variance from the rom based
   1.489 +	//repository to give the impression that some of the rom based entries have been modified,
   1.490 +	// removed and added by the rom update.
   1.491 +	//Copy a modified repository
   1.492 +
   1.493 +	User::LeaveIfError(fm->Copy(KModified2RepositoryCre,KPersistsRepositoryCre,CFileMan::EOverWrite));
   1.494 +	User::LeaveIfError(fm->Attribs(KPersistsRepositoryCre,0,KEntryAttReadOnly,TTime(0)));
   1.495 +	User::After(KGeneralDelay);
   1.496 +	//Have SWI add and modify some entries.
   1.497 +    TFileName SisFileName;
   1.498 +    SisFileName.Copy(KSisFile);
   1.499 +
   1.500 +    PerformSWIinstallL(SisFileName);
   1.501 +	User::After(KGeneralDelay*5);
   1.502 +
   1.503 +	UserModifyRepository2L();
   1.504 +
   1.505 +	//flush cachemanager contents
   1.506 +	CleanUp();
   1.507 +
   1.508 +	User::LeaveIfError(fm->Copy(KModifiedSwVersion,KCachedVersionFile,CFileMan::EOverWrite));
   1.509 +	User::LeaveIfError(fm->Attribs(KCachedVersionFile,0,KEntryAttReadOnly,TTime(0)));
   1.510 +	User::After(KGeneralDelay);
   1.511 +
   1.512 +	CleanupStack::PopAndDestroy();//fm
   1.513 +
   1.514 +	CServerRepository::CheckROMReflashL();
   1.515 +
   1.516 +	VerifyCorrectMergingL(ETrue);
   1.517 +
   1.518 +	// If cache manager is initialized and used before, we flush it
   1.519 +	CleanUp();
   1.520 +}
   1.521 +
   1.522 +/**
   1.523 +@SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-UT-4030
   1.524 +@SYMTestCaseDesc		A repository is removed from the ROM but has an SWI, it remains on the C:\
   1.525 +						but all clean settings that do not exist in the SWI install file are removed.
   1.526 +@SYMTestPriority		High
   1.527 +@SYMTestActions			Copy a prepared repository into the persists directory that has no basis
   1.528 +						in ROM.
   1.529 +						Perform an SWI, that adds new keys to the persisted repository.
   1.530 +						Have the user create a new entry.
   1.531 +						Have the user modify a rom based entry.
   1.532 +						Update the locally persisted rom version file.
   1.533 +						Call CheckROMReflashL to simulate a centrep reboot.
   1.534 +@SYMTestExpectedResults Verify the user modified rom based setting exists.
   1.535 +						Verify that a clean rom based setting is removed.
   1.536 +						Verify that a sample of the SWI based setting exists.
   1.537 +@SYMCR					CR1198
   1.538 +*/
   1.539 +LOCAL_C void SYSLIB_CENTRALREPOSITORY_UT_4030L()
   1.540 +{
   1.541 +	TheTest.Next( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-UT-4030 " ) );
   1.542 +	CFileMan* fm = CFileMan::NewL(TServerResources::iFs);
   1.543 +	CleanupStack::PushL(fm);
   1.544 +
   1.545 +	//Initial cleanup
   1.546 +	DeleteFilesL();
   1.547 +
   1.548 +	//Remove ROM and Merge User and SWI settings.
   1.549 +	//Need to copy a prepared repository into the persists,that has more entries than the SWI based
   1.550 +	//repository to simulate that some of the rom based entries have been removed,
   1.551 +	//by the rom update. All the clean entries should be removed, leaving only user modified ones and common SWI ones.
   1.552 +	User::LeaveIfError(fm->Copy(KStoredRepository2,KPersistsBasedRepository2,CFileMan::EOverWrite));
   1.553 +	User::LeaveIfError(fm->Attribs(KPersistsBasedRepository2,0,KEntryAttReadOnly,TTime(0)));
   1.554 +	User::After(KGeneralDelay);
   1.555 +	//Have SWI add some entries 0x08010100-500.
   1.556 +    TFileName SisFileName;
   1.557 +    SisFileName.Copy(KSisFile2);
   1.558 +
   1.559 +    PerformSWIinstallL(SisFileName);
   1.560 +	User::After(KGeneralDelay*2);
   1.561 +
   1.562 +	//Have the user add and modify some rom based entries
   1.563 +	CSessionNotifier* notifier = new(ELeave)CSessionNotifier;
   1.564 +	CleanupStack::PushL(notifier);
   1.565 +
   1.566 +    CServerRepository* repository = new(ELeave) CServerRepository();
   1.567 +    CleanupStack::PushL(repository);
   1.568 +    repository->OpenL(KUidRomRepositoryList[2],*notifier);
   1.569 +
   1.570 +    User::LeaveIfError(repository->StartTransaction(EReadWriteTransaction));
   1.571 +   	//
   1.572 +	//Modify setting
   1.573 +	TInt r = repository->TransactionSetL(KModifiedSettingList[2],KSettingValueList[2]);
   1.574 +	TEST2(r,KErrNone);
   1.575 +
   1.576 + 	//Add a setting
   1.577 +	r = repository->TransactionCreateL(KNewSettingList[2],KSettingValueList[0],NULL);
   1.578 +	TEST2(r,KErrNone);
   1.579 +
   1.580 + 	//Get some clean rom based settings to show they are present
   1.581 + 	TInt settingValue = 0;
   1.582 +	r = repository->Get(KModifiedSettingList[0], settingValue);
   1.583 +	TEST(r == KErrNone);
   1.584 +
   1.585 + 	//Get some clean rom based settings to show they are present
   1.586 + 	settingValue = 0;
   1.587 +	r = repository->Get(KModifiedSettingList[1], settingValue);
   1.588 +	TEST(r == KErrNone);
   1.589 +
   1.590 +	TUint32 tempKeyInfo;
   1.591 +	User::LeaveIfError(repository->CommitTransaction(tempKeyInfo));
   1.592 +	repository->Close();
   1.593 +	CleanupStack::PopAndDestroy(2);//repository, notifier
   1.594 +
   1.595 +	// If cache manager is initialized and used before, we flush it
   1.596 +	CleanUp();
   1.597 +
   1.598 +	//Copy of modified stored rom version info
   1.599 +	User::LeaveIfError(fm->Copy(KModifiedSwVersion,KCachedVersionFile,CFileMan::EOverWrite));
   1.600 +	User::LeaveIfError(fm->Attribs(KCachedVersionFile,0,KEntryAttReadOnly,TTime(0)));
   1.601 +	User::After(KGeneralDelay);
   1.602 +	CleanupStack::PopAndDestroy();//fm
   1.603 +
   1.604 +	CServerRepository::CheckROMReflashL();
   1.605 +
   1.606 +	//Check the merge content for correctness.
   1.607 +	notifier = new(ELeave)CSessionNotifier;
   1.608 +	CleanupStack::PushL(notifier);
   1.609 +
   1.610 +    repository = new(ELeave) CServerRepository();
   1.611 +    CleanupStack::PushL(repository);
   1.612 +    repository->OpenL(KUidRomRepositoryList[2],*notifier);
   1.613 +
   1.614 +	//Get the rom based user modified setting it should still be there
   1.615 +	settingValue = 0;
   1.616 +	r = repository->Get(KModifiedSettingList[2], settingValue);
   1.617 +	TEST(r == KErrNone);
   1.618 +
   1.619 +	//Get the rom only based clean setting, it should still be missing.
   1.620 +	r = repository->Get(KModifiedSettingList[0], settingValue);
   1.621 +	TEST(r == KErrNotFound);
   1.622 +
   1.623 +	//Get the rom only based clean setting, it should still be missing.
   1.624 +	r = repository->Get(KModifiedSettingList[1], settingValue);
   1.625 +	TEST(r == KErrNotFound);
   1.626 +
   1.627 +	//Get SWI based setting. It should be there
   1.628 +	r = repository->Get(KSWIBasedSettingList[0], settingValue);
   1.629 +	TEST(r == KErrNone);
   1.630 +
   1.631 +	//Get user based setting. It should be there
   1.632 +	r = repository->Get(KNewSettingList[2], settingValue);
   1.633 +	TEST(r == KErrNone);
   1.634 +	repository->Close();
   1.635 +	CleanupStack::PopAndDestroy(2);//repository, notifier
   1.636 +
   1.637 +	// If cache manager is initialized and used before, we flush it
   1.638 +	CleanUp();
   1.639 +}
   1.640 +
   1.641 +/**
   1.642 +@SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-UT-4031
   1.643 +@SYMTestCaseDesc		Test that repository settings that are altered by SWI value are not overwritten by a rom flash.
   1.644 +						SWI values dominate ROM values.
   1.645 +@SYMTestPriority		High
   1.646 +@SYMTestActions			Copy a prepared repository into the persists directory and into the install directory.
   1.647 +						There exists and equivalent rom based version of this repository with different values.
   1.648 +						Update the locally persisted rom version file.
   1.649 +						Call CheckROMReflashL to simulate a centrep reboot.
   1.650 +@SYMTestExpectedResults Verify the user modified rom based setting exists.
   1.651 +						Verify that some settings that exists within ROM and SWI has SWI values.
   1.652 +@SYMCR					CR1198
   1.653 +*/
   1.654 +LOCAL_C void SYSLIB_CENTRALREPOSITORY_UT_4031L()
   1.655 +{
   1.656 +	TheTest.Next( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-UT-4031 " ) );
   1.657 +	CFileMan* fm = CFileMan::NewL(TServerResources::iFs);
   1.658 +	CleanupStack::PushL(fm);
   1.659 +
   1.660 +	//Initial cleanup
   1.661 +	fm->Delete(KPersistsRepositoryCre);
   1.662 +	fm->Delete(KSWIInstallRepository);
   1.663 +
   1.664 +	//Simulate an SWI install by having the modified repository in the install and persists directory.
   1.665 +	User::LeaveIfError(fm->Copy(KStoredSWIRepository,KPersistsRepositoryCre,CFileMan::EOverWrite));
   1.666 +	User::LeaveIfError(fm->Attribs(KPersistsRepositoryCre,0,KEntryAttReadOnly,TTime(0)));
   1.667 +	User::After(KGeneralDelay);
   1.668 +	User::LeaveIfError(fm->Copy(KStoredSWIRepository,KSWIInstallRepository,CFileMan::EOverWrite));
   1.669 +	User::LeaveIfError(fm->Attribs(KSWIInstallRepository,0,KEntryAttReadOnly,TTime(0)));
   1.670 +	User::After(KGeneralDelay);
   1.671 +
   1.672 +	//Copy of modified stored rom version info
   1.673 +	User::LeaveIfError(fm->Copy(KModifiedSwVersion,KCachedVersionFile,CFileMan::EOverWrite));
   1.674 +	User::LeaveIfError(fm->Attribs(KCachedVersionFile,0,KEntryAttReadOnly,TTime(0)));
   1.675 +	User::After(KGeneralDelay);
   1.676 +	CleanupStack::PopAndDestroy();//fm
   1.677 +
   1.678 +	CServerRepository::CheckROMReflashL();
   1.679 +
   1.680 +	CSessionNotifier* notifier = new(ELeave)CSessionNotifier;
   1.681 +	CleanupStack::PushL(notifier);
   1.682 +
   1.683 +    CServerRepository* repository = new(ELeave) CServerRepository();
   1.684 +    CleanupStack::PushL(repository);
   1.685 +    repository->OpenL(KUidRomRepositoryList[0],*notifier);
   1.686 +
   1.687 +   	//Get the rom based user modified setting it should still be there
   1.688 +	TInt settingValue = 0;
   1.689 +	TInt r = repository->Get(KModifiedSettingList[0], settingValue);
   1.690 +	TEST(r == KErrNone);
   1.691 +	TEST(settingValue == KSettingValueList[4]);
   1.692 +
   1.693 +	//Get the rom and SWI setting it should have SWI value
   1.694 +	r = repository->Get(KModifiedSettingList[1], settingValue);
   1.695 +	TEST(r == KErrNone);
   1.696 +	TEST(settingValue == KSettingValueList[5]);
   1.697 +
   1.698 +	//Get the rom and SWI setting it should have SWI value
   1.699 +	r = repository->Get(KModifiedSettingList[2], settingValue);
   1.700 +	TEST(r == KErrNone);
   1.701 +	TEST(settingValue == KSettingValueList[2]);
   1.702 +
   1.703 +	repository->Close();
   1.704 +	CleanupStack::PopAndDestroy(2);//repository, notifier
   1.705 +
   1.706 +	// If cache manager is initialized and used before, we flush it
   1.707 +	CleanUp();
   1.708 +}
   1.709 +
   1.710 +/**
   1.711 +@SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-UT-4032
   1.712 +@SYMTestCaseDesc		This test checks that after a rom flash that contains a corrupt repository.
   1.713 +						The corrupt repository is skipped and the non corrupt repositories are processed as normal.
   1.714 +@SYMTestPriority		High
   1.715 +@SYMTestActions			Copy 3 prepared repositories into persists dir.
   1.716 +						Two user new settings are added[1000,1001].
   1.717 +						One user setting is deleted [1001].
   1.718 +						One rom setting is deleted [0x04010100].
   1.719 +						One rom setting is modified [0x04010200].
   1.720 +						Copy modified rom version file over local persisted version
   1.721 +						Call CheckRomFlash
   1.722 +@SYMTestExpectedResults Verfiy that the corrupt repository 10043337 is skipped and the other repositories are processed.
   1.723 +@SYMCR					CR1198
   1.724 +*/
   1.725 +LOCAL_C void SYSLIB_CENTRALREPOSITORY_UT_4032L()
   1.726 +{
   1.727 +	TheTest.Next( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-UT-4032 " ) );
   1.728 +	CFileMan* fm = CFileMan::NewL(TServerResources::iFs);
   1.729 +	CleanupStack::PushL(fm);
   1.730 +
   1.731 +	//Initial cleanup
   1.732 +	fm->Delete(KPersistsRepositoryCre1);
   1.733 +	fm->Delete(KPersistsRepositoryCre2);
   1.734 +	fm->Delete(KPersistsRepositoryCre3);
   1.735 +	//Copy of modified stored rom version info
   1.736 +
   1.737 +	//Copy 10043336,10043337 and 10043338 prepared repositories into persists directory.
   1.738 +	//These repositories have a two user added,1 user deleted,1 rom deleted and 1 rom modified settings.
   1.739 +	User::LeaveIfError(fm->Copy(KRomRepositoryCre1,KPersistsRepositoryCre1,CFileMan::EOverWrite));
   1.740 +	User::LeaveIfError(fm->Attribs(KPersistsRepositoryCre1,0,KEntryAttReadOnly,TTime(0)));
   1.741 +	User::LeaveIfError(fm->Copy(KRomRepositoryCre2,KPersistsRepositoryCre2,CFileMan::EOverWrite));
   1.742 +	User::LeaveIfError(fm->Attribs(KPersistsRepositoryCre2,0,KEntryAttReadOnly,TTime(0)));
   1.743 +	User::LeaveIfError(fm->Copy(KRomRepositoryCre3,KPersistsRepositoryCre3,CFileMan::EOverWrite));
   1.744 +	User::LeaveIfError(fm->Attribs(KPersistsRepositoryCre3,0,KEntryAttReadOnly,TTime(0)));
   1.745 +	User::After(KGeneralDelay);
   1.746 +
   1.747 +	//Copy of modified stored rom version info
   1.748 +	User::LeaveIfError(fm->Copy(KModifiedSwVersion,KCachedVersionFile,CFileMan::EOverWrite));
   1.749 +	User::LeaveIfError(fm->Attribs(KCachedVersionFile,0,KEntryAttReadOnly,TTime(0)));
   1.750 +	User::After(KGeneralDelay);
   1.751 +	CleanupStack::PopAndDestroy();//fm
   1.752 +
   1.753 +	CServerRepository::CheckROMReflashL();
   1.754 +
   1.755 +	CSessionNotifier* notifier = new(ELeave)CSessionNotifier;
   1.756 +	CleanupStack::PushL(notifier);
   1.757 +
   1.758 +    CServerRepository* repository = new(ELeave) CServerRepository();
   1.759 +    CleanupStack::PushL(repository);
   1.760 +
   1.761 +    TInt ii = 3;
   1.762 +	while(ii < 6)
   1.763 +		{
   1.764 +    	repository->OpenL(KUidRomRepositoryList[ii],*notifier);
   1.765 +		 //Get the user added setting it should still be there
   1.766 +		TInt settingValue = 0;
   1.767 +		TInt r = repository->Get(KNewSettingList[0], settingValue);
   1.768 +		TEST(r == KErrNone);
   1.769 +
   1.770 +		//Get the rom added value
   1.771 +		r = repository->Get(KNewSettingList[3], settingValue);
   1.772 +		if(ii == 4)//Corrupted rom repository is skipped, so it wont have been added
   1.773 +			{
   1.774 +			TEST2(r, KErrNotFound);
   1.775 +			}
   1.776 +		else
   1.777 +			{
   1.778 +			TEST2(r, KErrNone);
   1.779 +			}
   1.780 +
   1.781 +		//Get the rom deleted value, it will have been reinstated
   1.782 +		r = repository->Get(KDeletedSettingList[1], settingValue);
   1.783 +		if(ii == 4)//Corrupted rom repository is skipped, so it wont have been added
   1.784 +			{
   1.785 +			TEST2(r, KErrNotFound);
   1.786 +			}
   1.787 +		else
   1.788 +			{
   1.789 +			TEST2(r, KErrNone);
   1.790 +			}
   1.791 +
   1.792 +		//Get the user added and deleted value, it shouldnt be there.
   1.793 +		r = repository->Get(KNewSettingList[1], settingValue);
   1.794 +		TEST2(r, KErrNotFound);
   1.795 +
   1.796 +		// Close repository
   1.797 +		repository->Close();
   1.798 +		ii++;
   1.799 +		}
   1.800 +
   1.801 +	CleanupStack::PopAndDestroy(2);//repository, notifier
   1.802 +
   1.803 +	// If cache manager is initialized and used before, we flush it
   1.804 +	CleanUp();
   1.805 +}
   1.806 +
   1.807 +/**
   1.808 +@SYMTestCaseID			PDS-CENTRALREPOSITORY-UT-4083
   1.809 +@SYMTestCaseDesc		This test verifies that after a rom flash, rom and user modified values are merged correctly
   1.810 +						and all policies/meta are set correctly
   1.811 +@SYMTestPriority		High
   1.812 +@SYMTestActions			The test is used to simulate the rom flashing.It starts with 2 ROM keyspaces, the 2nd rom keyspace
   1.813 +						CADACADA been the "updated" ROM keyspace. The test starts with loading old rom keyspace, modify
   1.814 +						keyspace and then persisted under the "updated" ROM keyspace UID. So next time when we open
   1.815 +						the "updated" ROM keyspace, a remerging will happen. The properites of the keyspace and the
   1.816 +						individual settings are verified wrt the policies and metadata
   1.817 +@SYMTestExpectedResults The merging is correct with policies and meta specified in new ROM correctly applied to the 
   1.818 +						persisted file
   1.819 +@SYMDEF					INC134085
   1.820 +*/
   1.821 +
   1.822 +//class to allow direct access to TSecurityPolicy class
   1.823 +class TCompiledSecurityPolicy
   1.824 +{
   1.825 +public:
   1.826 +	TCompiledSecurityPolicy(TSecurityPolicy aPolicy):iPolicy(aPolicy){}
   1.827 +	TBool IsTypeFail()
   1.828 +		{
   1.829 +		return iPolicy.iType==TSecurityPolicy::ETypeFail;
   1.830 +		}
   1.831 +	TBool IsTypePass()
   1.832 +		{
   1.833 +		return iPolicy.iType==TSecurityPolicy::ETypePass;		
   1.834 +		}
   1.835 +public:		
   1.836 +TSecurityPolicy iPolicy;	
   1.837 +};
   1.838 +
   1.839 +LOCAL_C void INC134085L()
   1.840 +	{
   1.841 +	TheTest.Next( _L( " @SYMTestCaseID:PDS-CENTRALREPOSITORY-UT-4083 " ) );
   1.842 +	CFileMan* fm = CFileMan::NewL(TServerResources::iFs);
   1.843 +	CleanupStack::PushL(fm);
   1.844 +
   1.845 +	//orig_rom Test Uid
   1.846 +	const TUid KTestUid={0xCABACABA};
   1.847 +	//updated_rom Test Uid
   1.848 +	const TUid KUpdatedRomUid={0xCADACADA};
   1.849 +
   1.850 +	//Initial cleanup
   1.851 +	_LIT(KPersistsRepositoryCre,"C:\\private\\10202be9\\persists\\cadacada.cre");	
   1.852 +	fm->Delete(KPersistsRepositoryCre);
   1.853 +
   1.854 +	//Copy of modified stored rom version info
   1.855 +	User::LeaveIfError(fm->Copy(KModifiedSwVersion,KCachedVersionFile,CFileMan::EOverWrite));
   1.856 +	User::LeaveIfError(fm->Attribs(KCachedVersionFile,0,KEntryAttReadOnly,TTime(0)));
   1.857 +	User::After(KGeneralDelay);
   1.858 +
   1.859 +
   1.860 +	//-------------------------Modify one of the settings--------------------------------
   1.861 +	CSessionNotifier* notifier = new(ELeave)CSessionNotifier;
   1.862 +	CleanupStack::PushL(notifier);
   1.863 +    CServerRepository* repository = new(ELeave) CServerRepository();
   1.864 +    CleanupStack::PushL(repository);
   1.865 +
   1.866 +	//Need to reset the Uid to the new ROM value to ensure when persisting it is persisted
   1.867 +	//under the new ROM Uid value in order to simulate the ROM Reflash later
   1.868 +    repository->OpenL(KTestUid,*notifier);
   1.869 +    repository->iUid=KUpdatedRomUid;
   1.870 +    repository->iRepository->SetUid(KUpdatedRomUid);
   1.871 +	TServerResources::iObserver->RemoveObserver(KTestUid,repository,0);
   1.872 +	TServerResources::iObserver->RemoveSharedRepositoryInfo(KTestUid);
   1.873 +		
   1.874 +   	TServerResources::iObserver->AddObserverL(KUpdatedRomUid, repository);
   1.875 +	TServerResources::iObserver->AddSharedRepositoryInfoL(KUpdatedRomUid); 
   1.876 +
   1.877 +    //set a string key
   1.878 +    TBuf8<100> KTestString;
   1.879 +    KTestString.Copy(_L("voicemailboxnumber"));
   1.880 +  	User::LeaveIfError(repository->StartTransaction(EReadWriteTransaction));
   1.881 +	TInt err = repository->TransactionSetL(1,KTestString);
   1.882 +	TEST2(err,KErrNone);
   1.883 +	//a old ROM setting that has been modified by the user remains there even
   1.884 +	//when the new ROM does not contain that setting
   1.885 +	err = repository->TransactionSetL(0x300,5);
   1.886 +	TEST2(err,KErrNone);	
   1.887 +	TUint32 tempKeyInfo;
   1.888 +	User::LeaveIfError(repository->CommitTransaction(tempKeyInfo));
   1.889 +
   1.890 +	repository->Close();
   1.891 +	CleanupStack::PopAndDestroy(2);//repository, notifier
   1.892 +	
   1.893 +	//--------------------------Simulate the ROM Reflash---------------------------------
   1.894 +	// flush the cache manager contents.
   1.895 +	CleanUp();
   1.896 +	CServerRepository::CheckROMReflashL();
   1.897 +
   1.898 +	
   1.899 +	//--------------------------Validate the merging--------------------------------------
   1.900 +	notifier-new (ELeave)CSessionNotifier;
   1.901 +	CleanupStack::PushL(notifier);
   1.902 +    repository = new(ELeave) CServerRepository();
   1.903 +    CleanupStack::PushL(repository);
   1.904 +    repository->OpenL(KUpdatedRomUid,*notifier);
   1.905 +    
   1.906 +    //validate the keyspace global properties
   1.907 +    RSettingsArray& settings=repository->iRepository->iSimRep->SettingsArray();
   1.908 +    TEST2(settings.Count(),22);
   1.909 +    RArray<TUint32>& deletedArray=repository->iRepository->iSimRep->DeletedSettingsArray();
   1.910 +    TEST2(deletedArray.Count(),0)    ;
   1.911 +    RRangePolicyArray& rangePolicy=repository->iRepository->iSimRep->RangePolicyArray();
   1.912 +    TEST2(rangePolicy.Count(),1);
   1.913 +    RPointerArray<TSettingsAccessPolicy>& individualPolicy=repository->iRepository->iSimRep->SinglePolicyArray();
   1.914 +    TEST2(individualPolicy.Count(),20);    
   1.915 +
   1.916 +    RDefaultMetaArray& rangeMeta=repository->iRepository->iSimRep->RangeMetaArray();
   1.917 +    TEST2(rangeMeta.Count(),1);    
   1.918 +    for (TInt i=0;i<settings.Count();i++)
   1.919 +    	{
   1.920 +    	TUint32 key=settings[i].Key();
   1.921 +
   1.922 +    	//-------------validate the meta------------    	
   1.923 +    	//validate the meta only the modfiied setting will be not clean
   1.924 +    	if (key!=1 && key!=0x300)
   1.925 +       		TEST(settings[i].IsClean());
   1.926 +    	else
   1.927 +       		TEST(!settings[i].IsClean());
   1.928 +    	TUint32 meta=settings[i].Meta();
   1.929 +    	if (key==0 || key==0x11)
   1.930 +    		TEST(settings[i].Meta()==0x81000000);
   1.931 +    	//settings that have been modified
   1.932 +    	else if (key==1)
   1.933 +    		TEST(settings[i].Meta()==0x01000000);
   1.934 +    	//settings that used the range defined meta
   1.935 +    	else if (key==0x300)
   1.936 +    		TEST(settings[i].Meta()==300);
   1.937 +    	else
   1.938 +    		TEST(settings[i].Meta()==0x80000000);
   1.939 +    	
   1.940 +    	//------------validate the security policies-----
   1.941 +    	TCompiledSecurityPolicy r_tsp(*(settings[i].GetReadAccessPolicy()));
   1.942 +    	TEST(r_tsp.IsTypePass());
   1.943 +    	TCompiledSecurityPolicy w_tsp(*(settings[i].GetWriteAccessPolicy()));
   1.944 +    	if (key==5 || key==9 || key==16 || key==22)
   1.945 +    		TEST(w_tsp.IsTypeFail());    	
   1.946 +    	
   1.947 +    	}
   1.948 +      
   1.949 +    repository->Close();
   1.950 +	CleanupStack::PopAndDestroy(2);//repository, notifier
   1.951 +	CleanupStack::PopAndDestroy();//fm
   1.952 +
   1.953 +	// If cache manager is initialized and used before, we flush it
   1.954 +	CleanUp();	
   1.955 +	}
   1.956 +
   1.957 +LOCAL_C void FuncTestsL()
   1.958 +	{
   1.959 +	SYSLIB_CENTRALREPOSITORY_UT_4025L();
   1.960 +	SYSLIB_CENTRALREPOSITORY_UT_4026L();
   1.961 +	SYSLIB_CENTRALREPOSITORY_UT_4027L();
   1.962 +	SYSLIB_CENTRALREPOSITORY_UT_4028L();
   1.963 +	SYSLIB_CENTRALREPOSITORY_UT_4029L();
   1.964 +	SYSLIB_CENTRALREPOSITORY_UT_4030L();
   1.965 +	SYSLIB_CENTRALREPOSITORY_UT_4031L();
   1.966 +	SYSLIB_CENTRALREPOSITORY_UT_4032L();
   1.967 +	INC134085L();
   1.968 +	}
   1.969 +
   1.970 +LOCAL_C void DoTestsL()
   1.971 +	{
   1.972 +
   1.973 +	TheTest.Start( _L( "FOTA functionality" ) );
   1.974 +	FuncTestsL();
   1.975 +	TheTest.End();
   1.976 +
   1.977 +	}
   1.978 +
   1.979 +LOCAL_C void MainL()
   1.980 +	{
   1.981 +	__UHEAP_MARK;
   1.982 +	TheTest.Start( _L( "Fota Tests" ) );
   1.983 +
   1.984 +	// create and install the active scheduler we need
   1.985 +	CActiveScheduler* s = new(ELeave) CActiveScheduler;
   1.986 +	CleanupStack::PushL( s );
   1.987 +	CActiveScheduler::Install( s );
   1.988 +
   1.989 +	TServerResources::InitialiseL();
   1.990 +
   1.991 +	DeleteFilesL();
   1.992 +
   1.993 +	DoTestsL();
   1.994 +
   1.995 +	DeleteFilesL();
   1.996 +	TServerResources::Close();
   1.997 +
   1.998 +	// Cleanup the scheduler
   1.999 +	CleanupStack::PopAndDestroy( s );
  1.1000 +
  1.1001 +	TheTest.End();
  1.1002 +	TheTest.Close();
  1.1003 +	__UHEAP_MARKEND;
  1.1004 +	}
  1.1005 +
  1.1006 +TInt E32Main()
  1.1007 +	{
  1.1008 +	__UHEAP_MARK;
  1.1009 +	CTrapCleanup* cleanup = CTrapCleanup::New();
  1.1010 +	if ( !cleanup )
  1.1011 +		return KErrNoMemory;
  1.1012 +
  1.1013 +	TRAPD( err, MainL()  );
  1.1014 +	TEST2(err, KErrNone);
  1.1015 +
  1.1016 +	delete cleanup;
  1.1017 +	__UHEAP_MARKEND;
  1.1018 +
  1.1019 +	return 0;
  1.1020 +	}
  1.1021 +