persistentstorage/centralrepository/test/t_cenrep_rfs.cpp
changeset 0 08ec8eefde2f
child 23 26645d81f48d
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2004-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 //
       
    15 
       
    16 #include "t_cenrep_helper.h"
       
    17 #include <centralrepository.h>
       
    18 #include <e32test.h>  // RTest
       
    19 #include <e32debug.h> // RDebug::Printf
       
    20 #include <f32file.h>  // RFs
       
    21 
       
    22 #include "../cenrepsrv/srvparams.h" //KServerUid3
       
    23 
       
    24 //using namespace NCentralRepositoryConstants;
       
    25 
       
    26 _LIT(KSoftReset, "--SoftReset");
       
    27 
       
    28 RTest TheTest(_L("Central Repository RFS Test"));
       
    29 
       
    30 const TUid KUidRfsRepository = { 0xffffffff };
       
    31 const TUid KUidRfsRepositoryInstallOnlyDefaultFile = { 0xfffffffe };
       
    32 const TUid KUidRfsRepositoryDefaultRfsOn = { 0xfffffffa };
       
    33 
       
    34 typedef enum
       
    35 	{
       
    36 	ERomOnly = 0x01,
       
    37 	ERomAndInstall,
       
    38 	EInstallOnly,
       
    39 	ENoRomOrInstall
       
    40 	} TRepositoryFileState;
       
    41 
       
    42 const TUint32 KInt1 = 1;
       
    43 const TInt KInt1_UpdatedValue = 73;
       
    44 const TReal KReal1_InitialValue = 2.732;
       
    45 const TUint32 KNewInt = 1000;
       
    46 const TUint32 KNewInt2 = 0x0FFF; // outside range meta (in default meta)
       
    47 const TUint32 KNewInt3 = 0x1000; // inside range meta
       
    48 const TUint32 KReal1 = 2;
       
    49 const TReal KReal1_InstallValue = 4.53;
       
    50 const TReal KReal1_UpdatedValue = 7.32;
       
    51 const TUint32 KString1 = 5;
       
    52 _LIT(KString1_InitialValue, "test\\\"string\"");
       
    53 _LIT(KString1_UpdatedValue, "another one");
       
    54 
       
    55 
       
    56 LOCAL_C void CheckL(TInt aValue, TInt aLine)
       
    57 	{
       
    58 	if(!aValue)
       
    59 		{
       
    60 		CleanupCDriveL();
       
    61 		TheTest(EFalse, aLine);
       
    62 		}
       
    63 	}
       
    64 LOCAL_C void CheckL(TInt aValue, TInt aExpected, TInt aLine)
       
    65 	{
       
    66 	if(aValue != aExpected)
       
    67 		{
       
    68 		CleanupCDriveL();
       
    69 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
       
    70 		TheTest(EFalse, aLine);
       
    71 		}
       
    72 	}
       
    73 #define TEST(arg) ::CheckL((arg), __LINE__)
       
    74 #define TEST2(aValue, aExpected) ::CheckL(aValue, aExpected, __LINE__)
       
    75 
       
    76 
       
    77 //This function restores the state of the files required for this test
       
    78 //Existing files are deleted and then the required files are copied
       
    79 //back from the Z drive to the c drive
       
    80 LOCAL_C void RestoreRFSTestFilesL(TRepositoryFileState aState)
       
    81 	{
       
    82 	//Delete all files from C:\\private\\10202BE9\\persists\\ dir
       
    83 	//and C:\\private\\10202BE9\\ dir
       
    84 	CleanupCDriveL();
       
    85 	RFs fs;
       
    86 	User::LeaveIfError(fs.Connect());
       
    87 	CleanupClosePushL(fs);
       
    88 
       
    89 	CFileMan* fm = CFileMan::NewL(fs);
       
    90 	CleanupStack::PushL(fm);
       
    91 
       
    92 	_LIT(KPersistTargetPath, "C:\\private\\10202BE9\\persists\\ffffffff.txt");
       
    93 	_LIT(KInstallTargetPath, "C:\\private\\10202BE9\\ffffffff.txt");
       
    94 	_LIT(KPersistTargetPath1,"C:\\private\\10202BE9\\persists\\fffffffe.txt");
       
    95 	_LIT(KPersistTargetPath2,"C:\\private\\10202BE9\\persists\\fffffffd.txt");
       
    96 	_LIT(KInstallTargetPath1,"C:\\private\\10202BE9\\fffffffe.txt");
       
    97 	_LIT(KRFSTestFileSourcePath, "Z:\\private\\10202BE9\\ffffffff.txc");
       
    98 
       
    99 	switch(aState)
       
   100 	{
       
   101 		case ERomOnly:
       
   102 			CopyTestFilesL(*fm,KRFSTestFileSourcePath, KPersistTargetPath);
       
   103 			break;
       
   104 
       
   105 		case ERomAndInstall:
       
   106 			CopyTestFilesL(*fm,KRFSTestFileSourcePath, KPersistTargetPath);
       
   107 			CopyTestFilesL(*fm,KRFSTestFileSourcePath, KInstallTargetPath);
       
   108 			break;
       
   109 
       
   110 		case EInstallOnly:
       
   111 			CopyTestFilesL(*fm,KRFSTestFileSourcePath, KPersistTargetPath1);
       
   112 			CopyTestFilesL(*fm,KRFSTestFileSourcePath, KInstallTargetPath1);
       
   113 			break;
       
   114 
       
   115 		case ENoRomOrInstall:
       
   116 			CopyTestFilesL(*fm,KRFSTestFileSourcePath, KPersistTargetPath2);
       
   117 			break;
       
   118 
       
   119 		default:
       
   120 			break;
       
   121 	}
       
   122 
       
   123 	CleanupStack::PopAndDestroy(2);
       
   124 
       
   125 	}
       
   126 
       
   127 //
       
   128 // Start the server process or thread
       
   129 //
       
   130 LOCAL_C TInt ReStartServerInSoftResetMode()
       
   131 	{
       
   132 	const TUidType serverUid(KNullUid, KNullUid, KServerUid3);
       
   133 
       
   134 	//
       
   135 	// EPOC and EKA2 is easy, we just create a new server process. Simultaneous
       
   136 	// launching of two such processes should be detected when the second one
       
   137 	// attempts to create the server object, failing with KErrAlreadyExists.
       
   138 	//
       
   139 	RProcess server;
       
   140 	TInt r=server.Create(KServerImg,
       
   141 						 KSoftReset,
       
   142 						 serverUid);
       
   143 
       
   144 	if (r != KErrNone)
       
   145 		{
       
   146 		return r;
       
   147 		}
       
   148 
       
   149 	TRequestStatus stat;
       
   150 	server.Rendezvous(stat);
       
   151 
       
   152 	if (stat != KRequestPending)
       
   153 		{
       
   154 		server.Kill(0);		// abort startup
       
   155 		}
       
   156 	else
       
   157 		{
       
   158 		server.Resume();	// logon OK - start the server
       
   159 		}
       
   160 
       
   161 	User::WaitForRequest(stat);		// wait for start or death
       
   162 	// we can't use the 'exit reason' if the server panicked as this
       
   163 	// is the panic 'reason' and may be '0' which cannot be distinguished
       
   164 	// from KErrNone
       
   165 	r = (server.ExitType() == EExitPanic) ? KErrGeneral : stat.Int();
       
   166 
       
   167 	server.Close();
       
   168 	return r;
       
   169 	}
       
   170 
       
   171 
       
   172 LOCAL_C void RestoreFactorySettingsTestL()
       
   173 	{
       
   174 	TheTest.Start(_L("ResetAllRepositoriesTestL"));
       
   175 	TInt r;
       
   176 	TInt i;
       
   177 	TBuf<20> str;
       
   178 
       
   179 	TheTest.Next(_L("Open repository to ensure server is running"));
       
   180 	CRepository* repository = CRepository::NewLC(KUidRfsRepository);
       
   181 
       
   182 	TheTest.Next(_L("Add a Setting"));
       
   183 	const TInt KIntValue = 1234;
       
   184 	r = repository->Create(KNewInt, KIntValue);
       
   185 	TEST2(r, KErrNone);
       
   186 
       
   187 	TheTest.Next(_L("Delete a Setting"));
       
   188 	r = repository->Delete(KReal1);
       
   189 	TEST2(r, KErrNone);
       
   190 
       
   191 	TheTest.Next(_L("Modify a Setting"));
       
   192 	r = repository->Set(KInt1, KInt1_UpdatedValue);
       
   193 	TEST2(r, KErrNone);
       
   194 
       
   195 	TheTest.Next(_L("Modify a String Setting"));
       
   196 	r = repository->Set(KString1, KString1_UpdatedValue);
       
   197 
       
   198 	TEST2(r, KErrNone);
       
   199 	// Close repository
       
   200 	CleanupStack::PopAndDestroy(repository);
       
   201 
       
   202 	TheTest.Next(_L("Kill the server process"));
       
   203 	_LIT( KCentralRepositoryServerName, "Centralrepositorysrv");
       
   204 	r = KillProcess(KCentralRepositoryServerName);
       
   205 	TEST2(r,KErrNone);
       
   206 
       
   207 	User::After(KGeneralDelay);
       
   208 
       
   209 	TheTest.Next(_L("Manually start central respository"));
       
   210 	ReStartServerInSoftResetMode();
       
   211 
       
   212 	TheTest.Next(_L("Re-create the repository to ensure server is running"));
       
   213 	repository = CRepository::NewLC(KUidRfsRepository);
       
   214 
       
   215 	TheTest.Next(_L("Get 'Added' value"));
       
   216 	r = repository->Get(KNewInt, i);
       
   217 	TEST2(r, KErrNone);
       
   218 
       
   219 	TReal real;
       
   220 	TheTest.Next(_L("Get 'Deleted' value"));
       
   221 	r = repository->Get(KReal1, real);
       
   222 	TEST2(r, KErrNone);
       
   223 	TEST(real == KReal1_InitialValue);
       
   224 
       
   225 	TheTest.Next(_L("Get 'Modified' value"));
       
   226 	r = repository->Get(KInt1, i);
       
   227 	TEST2(r, KErrNone);
       
   228 	TEST(i == KInt1_UpdatedValue);
       
   229 
       
   230 	r = repository->Get(KString1, str);
       
   231 	TEST2(r, KErrNone);
       
   232 	TEST(str==KString1_InitialValue);
       
   233 
       
   234 	// Close repository
       
   235 	CleanupStack::PopAndDestroy(repository);
       
   236 
       
   237 	TheTest.End();
       
   238 	}
       
   239 
       
   240 
       
   241 
       
   242 /**
       
   243 @SYMTestCaseID 	 SYSLIB-CENTRALREPOSITORY-CT-3341
       
   244 @SYMTestCaseDesc Restore factory Settings from Rom file.
       
   245 @SYMTestPriority High
       
   246 @SYMTestActions  Ensure that the repository file only exists on the Rom.
       
   247 				 Open the repository and modify a setting.  Force RFS
       
   248 				 and check that the repository is restored against the ROM file
       
   249 @SYMTestExpectedResults The test repository should be reset against the ROM file
       
   250 @SYMDEF 		 PDEF099108
       
   251 */
       
   252 LOCAL_C void RFSRomOnlyL()
       
   253 	{
       
   254 
       
   255 	//restore all test files - this ensures we have a repository file
       
   256 	//only on the z:
       
   257 	RestoreRFSTestFilesL(ERomOnly);
       
   258 
       
   259 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-3341 ResetAllRepositoriesTestL "));
       
   260 	TInt r, intVal;
       
   261 	TReal realVal;
       
   262 
       
   263 	TheTest.Next(_L("Open repository to ensure server is running"));
       
   264 	CRepository* repository = CRepository::NewLC(KUidRfsRepository);
       
   265 
       
   266 	TheTest.Next(_L("Modify a Setting"));
       
   267 	r = repository->Set(KInt1, KInt1_UpdatedValue);
       
   268 	TEST2(r, KErrNone);
       
   269 
       
   270 	//verify the update
       
   271 	r = repository->Get(KInt1, intVal);
       
   272 	TEST2(r, KErrNone);
       
   273 	TEST(intVal == KInt1_UpdatedValue);
       
   274 
       
   275 	TheTest.Next(_L("Modify a Setting"));
       
   276 	r = repository->Set(KReal1, KReal1_UpdatedValue);
       
   277 	TEST2(r, KErrNone);
       
   278 
       
   279 	//verify the update
       
   280 	r = repository->Get(KReal1, realVal);
       
   281 	TEST2(r, KErrNone);
       
   282 	TEST(realVal == KReal1_UpdatedValue);
       
   283 
       
   284 	// Close repository
       
   285 	CleanupStack::PopAndDestroy(repository);
       
   286 
       
   287 	//Kill the server
       
   288 	TheTest.Next(_L("Kill the server process"));
       
   289 	_LIT( KCentralRepositoryServerName, "Centralrepositorysrv");
       
   290 	r = KillProcess(KCentralRepositoryServerName);
       
   291 	TEST2(r,KErrNone);
       
   292 
       
   293 	User::After(KGeneralDelay);
       
   294 
       
   295 	//Restart the server in soft reset mode to force a
       
   296 	//repository reset
       
   297 	TheTest.Next(_L("Manually start central respository"));
       
   298 	ReStartServerInSoftResetMode();
       
   299 
       
   300 	//Open the repository
       
   301 	repository = CRepository::NewLC(KUidRfsRepository);
       
   302 
       
   303 	//Verify that the real value is reset against the value in the Rom version of
       
   304 	//the repository file
       
   305 	TheTest.Next(_L("Get 'Modified' value"));
       
   306 	r = repository->Get(KReal1, realVal);
       
   307 	TEST2(r, KErrNone);
       
   308 	TEST(realVal == KReal1_InitialValue);
       
   309 
       
   310 	// Close repository
       
   311 	CleanupStack::PopAndDestroy(repository);
       
   312 
       
   313 	TheTest.End();
       
   314 	}
       
   315 
       
   316 
       
   317 
       
   318 /**
       
   319 @SYMTestCaseID 	 SYSLIB-CENTRALREPOSITORY-CT-3342
       
   320 @SYMTestCaseDesc Restore factory Settings from merged repository.
       
   321 @SYMTestPriority High
       
   322 @SYMTestActions  Ensure that the repository file  exists in both the Rom and install
       
   323 					directories.
       
   324 				 Open the repository and modify a setting.  Force RFS
       
   325 				 and check that the repository is restored against the merged repository
       
   326 @SYMTestExpectedResults The test repository should be reset against the merged repository
       
   327 @SYMDEF 		 PDEF099108
       
   328 */
       
   329 LOCAL_C void RFSRomAndInstallL()
       
   330 	{
       
   331 
       
   332 	//restore all test files - this ensures we have a c: and z: file
       
   333 	//for the test repository which causes a repository merge
       
   334 	RestoreRFSTestFilesL(ERomAndInstall);
       
   335 
       
   336 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-3342 ResetAllRepositoriesTestL "));
       
   337 	TInt r;
       
   338 	TReal realVal;
       
   339 	TBuf<20> strVal;
       
   340 
       
   341 	TheTest.Next(_L("Open repository to ensure server is running"));
       
   342 	CRepository* repository = CRepository::NewLC(KUidRfsRepository);
       
   343 
       
   344 	TheTest.Next(_L("Modify a Setting"));
       
   345 	r = repository->Set(KReal1, KReal1_UpdatedValue);
       
   346 	TEST2(r, KErrNone);
       
   347 
       
   348 	//verify the update
       
   349 	r = repository->Get(KReal1, realVal);
       
   350 	TEST2(r, KErrNone);
       
   351 	TEST(realVal == KReal1_UpdatedValue);
       
   352 
       
   353 	// Close repository
       
   354 	CleanupStack::PopAndDestroy(repository);
       
   355 
       
   356 	//Kill the server
       
   357 	TheTest.Next(_L("Kill the server process"));
       
   358 	_LIT( KCentralRepositoryServerName, "Centralrepositorysrv");
       
   359 	r = KillProcess(KCentralRepositoryServerName);
       
   360 	TEST2(r,KErrNone);
       
   361 
       
   362 	User::After(KGeneralDelay);
       
   363 
       
   364 	//Restart the server in soft reset mode to force a
       
   365 	//repository reset
       
   366 	TheTest.Next(_L("Manually start central respository"));
       
   367 	ReStartServerInSoftResetMode();
       
   368 
       
   369 	//Open the repository
       
   370 	repository = CRepository::NewLC(KUidRfsRepository);
       
   371 
       
   372 	//Verify that the string value, which is only found in the ROM file is
       
   373 	//present in the merged repository
       
   374 	r = repository->Get(KString1, strVal);
       
   375 	TEST2(r, KErrNone);
       
   376 	TEST(strVal==KString1_InitialValue);
       
   377 
       
   378 	//verify that the Real value has been reset against the value in the install
       
   379 	//repository file
       
   380 	TheTest.Next(_L("Get 'Modified' value"));
       
   381 	r = repository->Get(KReal1, realVal);
       
   382 	TEST2(r, KErrNone);
       
   383 	TEST(realVal == KReal1_InstallValue);
       
   384 
       
   385 	// Close repository
       
   386 	CleanupStack::PopAndDestroy(repository);
       
   387 
       
   388 	TheTest.End();
       
   389 	}
       
   390 
       
   391 
       
   392 /**
       
   393 @SYMTestCaseID 	 SYSLIB-CENTRALREPOSITORY-CT-3343
       
   394 @SYMTestCaseDesc Restore factory Settings from Install file.
       
   395 @SYMTestPriority High
       
   396 @SYMTestActions  Ensure that the repository file only exists in the Install directory.
       
   397 				 Open the repository and modify a setting.  Force RFS
       
   398 				 and check that the repository is restored against the Install file
       
   399 @SYMTestExpectedResults The test repository should be reset against the Install file
       
   400 @SYMDEF 		 PDEF099108
       
   401 */
       
   402 LOCAL_C void RFSInstallOnlyL()
       
   403 	{
       
   404 
       
   405 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-3343 ResetAllRepositoriesTestL "));
       
   406 	TInt r;
       
   407 	TReal realVal;
       
   408 	TBuf<20> strVal;
       
   409 
       
   410 	//restore all test files - this ensures we have a repository file
       
   411 	//only on the c:
       
   412 	RestoreRFSTestFilesL(EInstallOnly);
       
   413 
       
   414 	TheTest.Next(_L("Open repository to ensure server is running"));
       
   415 	CRepository* repository = CRepository::NewLC(KUidRfsRepositoryInstallOnlyDefaultFile);
       
   416 
       
   417 	TheTest.Next(_L("Modify a Setting"));
       
   418 	r = repository->Set(KReal1, KReal1_UpdatedValue);
       
   419 	TEST2(r, KErrNone);
       
   420 
       
   421 	//verify the update
       
   422 	r = repository->Get(KReal1, realVal);
       
   423 	TEST2(r, KErrNone);
       
   424 	TEST(realVal == KReal1_UpdatedValue);
       
   425 
       
   426 	// Close repository
       
   427 	CleanupStack::PopAndDestroy(repository);
       
   428 
       
   429 	//Kill the server
       
   430 	TheTest.Next(_L("Kill the server process"));
       
   431 	_LIT( KCentralRepositoryServerName, "Centralrepositorysrv");
       
   432 	r = KillProcess(KCentralRepositoryServerName);
       
   433 	TEST2(r,KErrNone);
       
   434 
       
   435 	User::After(KGeneralDelay);
       
   436 
       
   437 	//Restart the server in soft reset mode to force a
       
   438 	//repository reset
       
   439 	TheTest.Next(_L("Manually start central respository"));
       
   440 	ReStartServerInSoftResetMode();
       
   441 
       
   442 	//Open the repository
       
   443 	repository = CRepository::NewLC(KUidRfsRepositoryInstallOnlyDefaultFile);
       
   444 
       
   445 	//verify that the Real value has been reset against the value in the install
       
   446 	//repository file
       
   447 	TheTest.Next(_L("Get 'Modified' value"));
       
   448 	r = repository->Get(KReal1, realVal);
       
   449 	TEST2(r, KErrNone);
       
   450 	TEST(realVal == KReal1_InstallValue);
       
   451 
       
   452 	// Close repository
       
   453 	CleanupStack::PopAndDestroy(repository);
       
   454 
       
   455 	TheTest.End();
       
   456 	}
       
   457 
       
   458 /**
       
   459 @SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-CT-3435
       
   460 @SYMTestCaseDesc		PDEF105203: Start-up Settings: New access point remains after restoring factory setting
       
   461 @SYMTestPriority		High
       
   462 @SYMTestActions			Create a new setting inside a range with range meta RFS bit set, create another setting
       
   463 						outside the range, restart server in RFS mode, check to see the setting created outside
       
   464 						the range still exists, check to see the setting created inside the range has been deleted.
       
   465 						Repeat same steps with another repository which has default meta having RFS on and range meta
       
   466 						having RFS off, check to see the setting created outside the range has been deleted, check to
       
   467 						see the setting created inside the range still exists.
       
   468 @SYMTestExpectedResults Test must not fail
       
   469 @SYMDEF					PDEF105203
       
   470 */
       
   471 LOCAL_C void PDEF105203()
       
   472 	{
       
   473 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-3435 PDEF105203: Start-up Settings: New access point remains after restoring factory setting "));
       
   474 	TInt r;
       
   475 	TInt i;
       
   476 
       
   477 	TheTest.Next(_L("Open repository to ensure server is running"));
       
   478 	CRepository* repository = CRepository::NewLC(KUidRfsRepository);
       
   479 
       
   480 	TheTest.Next(_L("Create a new setting outside RFSable range meta area"));
       
   481 	const TInt KIntValue = 999;
       
   482 	r = repository->Create(KNewInt2, KIntValue);
       
   483 	TEST2(r, KErrNone);
       
   484 
       
   485 	TheTest.Next(_L("Create a new setting in RFSable range meta area"));
       
   486 	r = repository->Create(KNewInt3, KIntValue);
       
   487 	TEST2(r, KErrNone);
       
   488 
       
   489 	// Close repository
       
   490 	CleanupStack::PopAndDestroy(repository);
       
   491 
       
   492 	TheTest.Next(_L("Kill the server process"));
       
   493 	_LIT( KCentralRepositoryServerName, "Centralrepositorysrv");
       
   494 	r = KillProcess(KCentralRepositoryServerName);
       
   495 	TEST2(r,KErrNone);
       
   496 
       
   497 	User::After(KGeneralDelay);
       
   498 
       
   499 	TheTest.Next(_L("Manually start central respository"));
       
   500 	ReStartServerInSoftResetMode();
       
   501 
       
   502 	TheTest.Next(_L("Re-create the repository to ensure server is running"));
       
   503 	repository = CRepository::NewLC(KUidRfsRepository);
       
   504 
       
   505 	TheTest.Next(_L("Get 'created' value outside range meta"));
       
   506 	r = repository->Get(KNewInt2, i);
       
   507 	TEST2(r, KErrNone); // should still exist
       
   508 	TEST(i == KIntValue);
       
   509 
       
   510 	TheTest.Next(_L("Get 'created' value inside range meta"));
       
   511 	r = repository->Get(KNewInt3, i);
       
   512 	TEST2(r, KErrNotFound); // should have been deleted
       
   513 
       
   514 	// Close repository
       
   515 	CleanupStack::PopAndDestroy(repository);
       
   516 
       
   517 	repository = CRepository::NewLC(KUidRfsRepositoryDefaultRfsOn);
       
   518 
       
   519 	TheTest.Next(_L("Create a new setting in RFSable default meta area"));
       
   520 	const TInt KIntValue2 = 990;
       
   521 	r = repository->Create(KNewInt2, KIntValue2);
       
   522 	TEST2(r, KErrNone);
       
   523 
       
   524 	TheTest.Next(_L("Create a new setting in non-RFSable range meta area"));
       
   525 	r = repository->Create(KNewInt3, KIntValue2);
       
   526 	TEST2(r, KErrNone);
       
   527 
       
   528 	// Close repository
       
   529 	CleanupStack::PopAndDestroy(repository);
       
   530 
       
   531 	TheTest.Next(_L("Kill the server process"));
       
   532 	r = KillProcess(KCentralRepositoryServerName);
       
   533 	TEST2(r,KErrNone);
       
   534 
       
   535 	User::After(KGeneralDelay);
       
   536 
       
   537 	TheTest.Next(_L("Manually start central respository"));
       
   538 	ReStartServerInSoftResetMode();
       
   539 
       
   540 	TheTest.Next(_L("Re-create the repository to ensure server is running"));
       
   541 	repository = CRepository::NewLC(KUidRfsRepositoryDefaultRfsOn);
       
   542 
       
   543 	TheTest.Next(_L("Get 'created' value outside range meta"));
       
   544 	r = repository->Get(KNewInt2, i);
       
   545 	TEST2(r, KErrNotFound); // should have been deleted
       
   546 
       
   547 	TheTest.Next(_L("Get 'created' value inside range meta"));
       
   548 	r = repository->Get(KNewInt3, i);
       
   549 	TEST2(r, KErrNone); // should still exist
       
   550 	TEST(i == KIntValue2);
       
   551 
       
   552 	// Close repository
       
   553 	CleanupStack::PopAndDestroy(repository);
       
   554 
       
   555 	TheTest.End();
       
   556 	}
       
   557 
       
   558 /**
       
   559 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4082		
       
   560 @SYMTestCaseDesc		Test for PDEF133672: Cannot remove restored access points
       
   561 @SYMTestPriority		High
       
   562 @SYMTestActions			Create a repository, delete settings with RFS meta and reset repository, 
       
   563 						then try to delete the settings again. 
       
   564 @SYMTestExpectedResults When deleting settings after reset, KErrAlreadyExists should not return.
       
   565 @SYMDEF					PDEF133672
       
   566 */	
       
   567 LOCAL_C void PDEF133672L()
       
   568 	{
       
   569 	TheTest.Start(_L("Test for PDEF133671"));
       
   570 	
       
   571 	const TUid KReposUid = {0xCCCCCC99};
       
   572 
       
   573 	const TInt KTestId1 = {0x00000001};
       
   574 	const TInt KTestId2 = {0x0000000A};
       
   575 	
       
   576 	CRepository* repos=NULL;
       
   577 		
       
   578 	repos = CRepository::NewLC(KReposUid);
       
   579 		
       
   580 	User::LeaveIfNull(repos);
       
   581 		
       
   582 	TInt r;
       
   583 	
       
   584 	r = repos->Delete(KTestId1);
       
   585 	TEST2(r, KErrNone);
       
   586 	r = repos->Delete(KTestId2);
       
   587 	TEST2(r, KErrNone);
       
   588 	
       
   589 	TheTest.Next(_L("try reset single settings"));
       
   590 	r = repos->Reset(KTestId1);
       
   591 	TEST2(r, KErrNone);
       
   592 	r = repos->Reset(KTestId2);
       
   593 	TEST2(r, KErrNone);
       
   594 		
       
   595 	r = repos->Delete(KTestId1);
       
   596 	TEST2(r, KErrNone);
       
   597 	r = repos->Delete(KTestId2);
       
   598 	TEST2(r, KErrNone);
       
   599 	
       
   600 	TheTest.Next(_L("try reset whole repository"));
       
   601 	r = repos->Reset();
       
   602 			
       
   603 	r = repos->Delete(KTestId1);
       
   604 	TEST2(r, KErrNone);
       
   605 	r = repos->Delete(KTestId2);
       
   606 	TEST2(r, KErrNone);
       
   607 		
       
   608 	CleanupStack::PopAndDestroy();
       
   609 
       
   610 	TheTest.End();
       
   611 	}
       
   612 
       
   613 /**
       
   614 @SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-CT-0497-0001
       
   615 @SYMTestCaseDesc		CentralRepository functionality test
       
   616 @SYMTestPriority		High
       
   617 @SYMTestActions			Wrapper function calling up test functions
       
   618 @SYMTestExpectedResults Test must not fail
       
   619 @SYMREQ					REQ0000
       
   620 */
       
   621 LOCAL_C void MainL()
       
   622 	{
       
   623 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-0497-0001 Restore Factory Settings tests "));
       
   624 	CleanupCDriveL();
       
   625 	RestoreFactorySettingsTestL();
       
   626 	PDEF105203();
       
   627 	RFSRomOnlyL();
       
   628 	RFSRomAndInstallL();
       
   629 	RFSInstallOnlyL();
       
   630 	PDEF133672L();
       
   631 	CleanupCDriveL();
       
   632 
       
   633 	TheTest.End();
       
   634 	TheTest.Close();
       
   635 	}
       
   636 
       
   637 TInt E32Main()
       
   638 	{
       
   639 	__UHEAP_MARK;
       
   640 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
   641 	if(!cleanup)
       
   642 		return KErrNoMemory;
       
   643 
       
   644 	TRAPD(err, MainL());
       
   645 	if (err != KErrNone)
       
   646 		User::Panic(_L("Testing failed: "), err);
       
   647 
       
   648 	delete cleanup;
       
   649 	__UHEAP_MARKEND;
       
   650 
       
   651 	return 0;
       
   652 	}