persistentstorage/centralrepository/test/t_cenrep.cpp
changeset 55 44f437012c90
parent 15 3eacc0623088
equal deleted inserted replaced
51:7d4490026038 55:44f437012c90
    21 #include "../common/inc/srvdefs.h"
    21 #include "../common/inc/srvdefs.h"
    22 #include "../cenrepsrv/srvparams.h"
    22 #include "../cenrepsrv/srvparams.h"
    23 
    23 
    24 using namespace NCentralRepositoryConstants;
    24 using namespace NCentralRepositoryConstants;
    25 
    25 
    26 RTest TheTest(_L("Central Repository Tests"));
    26 RTest TheTest(_L("t_cenrep.exe"));
       
    27 
       
    28 _LIT( KCentralRepositoryServerName, "Centralrepositorysrv");
    27 
    29 
    28 TBool OomTesting;
    30 TBool OomTesting;
    29 
    31 
    30 const TUid KUidTestRepository1 = { 0x00000001 };
    32 const TUid KUidTestRepository1 = { 0x00000001 };
    31 const TUid KUidCreTestRepository1 = { 0x22222221 };
    33 const TUid KUidCreTestRepository1 = { 0x22222221 };
    32 const TUid KUidTestRepository2 = { 0x00000002 };
    34 const TUid KUidTestRepository2 = { 0x00000002 };
    33 
    35 
       
    36 #if defined(SYMBIAN_INCLUDE_APP_CENTRIC)
       
    37 const TUid KUidTxtPMATestRepos1   = { 0xf1000111 }; //ROM PMA txt repos
       
    38 const TUid KUidCrePMATestRepos1   = { 0xf1000112 }; //ROM PMA cre repos
       
    39 const TUid KUidCrePMAinPMADriveTestRepos1   = { 0xf1000113 }; //PMA drive cre repos
       
    40 const TUid KUidCorruptRepos1      = { 0xf1000114 }; //Non-PMA Repos in PMA drive
       
    41 const TUid KUidCorruptRepos2      = { 0xf1000115 }; //PMA Repos in persist folder
       
    42 const TUid KUidTxtInPMADriveRepos1 = { 0xf1000116 }; //TXT Repos in PMA drive
       
    43 const TUid KUidPmaTxtInInstallDir1 = { 0xf1000117 }; //TXT Repos in PMA drive
       
    44 const TUid KUidPmaCreInInstallDir1 = { 0xf1000118 }; //TXT Repos in PMA drive
       
    45 #endif
       
    46 
       
    47 
    34 const TUid KUidCorruptRepository = { 0x00000003 };
    48 const TUid KUidCorruptRepository = { 0x00000003 };
    35 const TUid KUidResetTestRepository = { 0x00000004 };
    49 const TUid KUidResetTestRepository = { 0x00000004 };
    36 
    50 
    37 const TUid KUidDriveCRepository = { 0x00000010 };
    51 const TUid KUidDriveZRepository = { 0x00000010 };
    38 
    52 
    39 const TUid KUidDriveCOnlyRepository = { 0x00000013 };
    53 const TUid KUidDriveCOnlyRepository = { 0x00000013 };
    40 
    54 
    41 const TUid KUidTestRepository3 = { 0x00000103 };
    55 const TUid KUidTestRepository3 = { 0x00000103 };
    42 
    56 
   100 
   114 
   101 
   115 
   102 
   116 
   103 ///////////////////////////////////////////////////////////////////////////////////////
   117 ///////////////////////////////////////////////////////////////////////////////////////
   104 ///////////////////////////////////////////////////////////////////////////////////////
   118 ///////////////////////////////////////////////////////////////////////////////////////
   105 //Test macroses and functions
   119 //Test macros and functions
   106 
   120 
   107 LOCAL_C void CheckL(TInt aValue, TInt aLine)
   121 LOCAL_C void CheckL(TInt aValue, TInt aLine)
   108 	{
   122 	{
   109 	if(!aValue)
   123 	if(!aValue)
   110 		{
   124 		{
   111 		CleanupCDriveL();
   125 		CleanupCDriveL();
       
   126 		User::LeaveIfError(KillProcess(KCentralRepositoryServerName));
   112 		TheTest(EFalse, aLine);
   127 		TheTest(EFalse, aLine);
   113 		}
   128 		}
   114 	}
   129 	}
       
   130 
   115 LOCAL_C void CheckL(TInt aValue, TInt aExpected, TInt aLine)
   131 LOCAL_C void CheckL(TInt aValue, TInt aExpected, TInt aLine)
   116 	{
   132 	{
   117 	if(aValue != aExpected)
   133 	if(aValue != aExpected)
   118 		{
   134 		{
   119 		CleanupCDriveL();
   135 		CleanupCDriveL();
       
   136 		User::LeaveIfError(KillProcess(KCentralRepositoryServerName));
   120 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
   137 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
   121 		TheTest(EFalse, aLine);
   138 		TheTest(EFalse, aLine);
   122 		}
   139 		}
   123 	}
   140 	}
   124 #define TEST(arg) ::CheckL((arg), __LINE__)
   141 #define TEST(arg) ::CheckL((arg), __LINE__)
   155 //This function resets the KUidTestRepository1 repository
   172 //This function resets the KUidTestRepository1 repository
   156 //to its intial state to remove any changes made to the repository during
   173 //to its intial state to remove any changes made to the repository during
   157 //previous tests
   174 //previous tests
   158 LOCAL_C void ResetTestRepositoryL()
   175 LOCAL_C void ResetTestRepositoryL()
   159 	{
   176 	{
   160 	CRepository* repository;
   177     CRepository* repository(NULL);
   161 
   178 
   162 	User::LeaveIfNull(repository = CRepository::NewLC(KUidTestRepository1));
   179 	User::LeaveIfNull(repository = CRepository::NewLC(KUidTestRepository1));
   163 	TInt r = repository->Reset();
   180 	TInt r = repository->Reset();
   164 	TEST2(r, KErrNone);
   181 	TEST2(r, KErrNone);
   165 	CleanupStack::PopAndDestroy(repository);
   182 	CleanupStack::PopAndDestroy(repository);
   168 //This function restores the state of the files required for this test
   185 //This function restores the state of the files required for this test
   169 //Existing files are deleted and then the required files are copied
   186 //Existing files are deleted and then the required files are copied
   170 //back from the Z drive to the c drive
   187 //back from the Z drive to the c drive
   171 LOCAL_C void RestoreTestFilesL()
   188 LOCAL_C void RestoreTestFilesL()
   172 	{
   189 	{
   173 	//Delete all files from C:\\private\\10202BE9\\persists\\ dir
       
   174 	//and C:\\private\\10202BE9\\ dir
       
   175 	CleanupCDriveL();
   190 	CleanupCDriveL();
   176 
   191 
   177 	RFs fs;
   192 	RFs fs;
   178 	User::LeaveIfError(fs.Connect());
   193 	User::LeaveIfError(fs.Connect());
   179 	CleanupClosePushL(fs);
   194 	CleanupClosePushL(fs);
   180 
   195 
   181 	CFileMan* fm = CFileMan::NewL(fs);
   196 	CFileMan* fm = CFileMan::NewL(fs);
   182 	CleanupStack::PushL(fm);
   197 	CleanupStack::PushL(fm);
   183 
   198 
   184 //	_LIT(KPersistTargetPath, "c:\\private\\10202BE9\\persists\\*.txt");
   199 	// The target path's drive will be patched with the correct
   185 	_LIT(KPersistTargetPath, "z:\\private\\10202BE9\\*.txt");
   200 	// system drive in CopyTestFilesL
       
   201 	_LIT(KPersistTargetPath, "C:\\private\\10202BE9\\*.txt");
   186 	_LIT(KPersistSourcePath, "Z:\\private\\10202BE9\\*.txc");
   202 	_LIT(KPersistSourcePath, "Z:\\private\\10202BE9\\*.txc");
   187 	_LIT(KInstallTargetPath, "C:\\private\\10202BE9\\*.txt");
   203 	_LIT(KInstallTargetPath, "C:\\private\\10202BE9\\*.txt");
   188 	_LIT(KInstallSourcePath, "Z:\\private\\10202BE9\\*.txi");
   204 	_LIT(KInstallSourcePath, "Z:\\private\\10202BE9\\*.txi");
   189 
   205 
   190 	//copy test files from Z: to C:
   206 	//copy test files from Z: to C:
   191 	CopyTestFilesL(*fm,KPersistSourcePath, KPersistTargetPath);
   207 	CopyTestFilesL(*fm,KPersistSourcePath, KPersistTargetPath);
   192 	CopyTestFilesL(*fm,KInstallSourcePath, KInstallTargetPath);
   208 	CopyTestFilesL(*fm,KInstallSourcePath, KInstallTargetPath);
       
   209 	
       
   210 #if defined(SYMBIAN_INCLUDE_APP_CENTRIC)
       
   211 	//Copy cre files to PMA protected folder for testing
       
   212 	_LIT(KPMASourcePath, "Z:\\private\\10202BE9\\*.pma");
       
   213 	_LIT(KPMATargetPath, "C:\\private\\10202BE9\\persists\\protected\\*.cre");
       
   214     CopyTestFilesL(*fm,KPMASourcePath, KPMATargetPath);
       
   215     
       
   216     //Copy PMA protected cre file to persist folder for testing
       
   217     _LIT(KPMACreSourcePath, "Z:\\private\\10202BE9\\f1000115.crp");
       
   218     _LIT(KPMACreTargetPath, "C:\\private\\10202BE9\\persists\\*.cre");
       
   219     CopyTestFilesL(*fm,KPMACreSourcePath, KPMACreTargetPath);
       
   220     
       
   221     //Copy PMA protected txt file to persist folder for testing
       
   222     _LIT(KPMATxtSourcePath, "Z:\\private\\10202BE9\\f1000116.txp");
       
   223     _LIT(KPMATxtTargetPath, "C:\\private\\10202BE9\\persists\\protected\\*.txt");
       
   224     CopyTestFilesL(*fm,KPMATxtSourcePath, KPMATxtTargetPath);
       
   225 #endif
   193 
   226 
   194 	CleanupStack::PopAndDestroy(2);
   227 	CleanupStack::PopAndDestroy(2);
   195 
   228 
   196 	}
   229 	}
   197 
   230 
   204 @SYMTestExpectedResults Test must not fail
   237 @SYMTestExpectedResults Test must not fail
   205 @SYMREQ					REQ0000
   238 @SYMREQ					REQ0000
   206 */
   239 */
   207 LOCAL_C void OpenRepositoryL()
   240 LOCAL_C void OpenRepositoryL()
   208 	{
   241 	{
   209 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1297 "));
       
   210 	CRepository* repositoryA;
   242 	CRepository* repositoryA;
   211 	CRepository* repositoryB;
   243 	CRepository* repositoryB;
   212 
   244 
   213 	TInt r;
   245 	TInt r;
   214 
   246 
   261 @SYMTestPriority		High
   293 @SYMTestPriority		High
   262 @SYMTestActions			Tests for CRepository::Get(),CRepository::Set() functions
   294 @SYMTestActions			Tests for CRepository::Get(),CRepository::Set() functions
   263 @SYMTestExpectedResults Test must not fail
   295 @SYMTestExpectedResults Test must not fail
   264 @SYMREQ					REQ0000
   296 @SYMREQ					REQ0000
   265 */
   297 */
       
   298 /**
       
   299 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4114
       
   300 @SYMTestCaseDesc		Tests for CRepository's Integer,Real,String's Get and Set functions on PMA keyspace
       
   301 @SYMTestPriority		High
       
   302 @SYMTestActions			Tests for CRepository::Get(),CRepository::Set() functions
       
   303 @SYMTestExpectedResults Test should get the correct value of a setting and set operation must not fail.
       
   304 @SYMREQ					REQ42876
       
   305 */
   266 LOCAL_C void GetSetL(const TUid& aUid)
   306 LOCAL_C void GetSetL(const TUid& aUid)
   267 	{
   307 	{
   268 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1298 "));
   308     CRepository* repository(NULL);
   269 	CRepository* repository;
       
   270 	User::LeaveIfNull(repository = CRepository::NewLC(aUid));
   309 	User::LeaveIfNull(repository = CRepository::NewLC(aUid));
   271 
   310 
   272 	_LIT8(KString12_InitialValue, "string");
   311 	_LIT8(KString12_InitialValue, "string");
   273 	TPtrC8 p8(KString12_InitialValue);
   312 	TPtrC8 p8(KString12_InitialValue);
   274 
   313 
   590 @SYMTestExpectedResults Test must not fail
   629 @SYMTestExpectedResults Test must not fail
   591 @SYMREQ					REQ0000
   630 @SYMREQ					REQ0000
   592 */
   631 */
   593 LOCAL_C void FindL()
   632 LOCAL_C void FindL()
   594 	{
   633 	{
   595 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1299 "));
   634 	CRepository* repository(NULL);
   596 	CRepository* repository;
       
   597 	User::LeaveIfNull(repository = CRepository::NewLC(KUidTestRepository1));
   635 	User::LeaveIfNull(repository = CRepository::NewLC(KUidTestRepository1));
   598 
   636 
   599 	RArray<TUint32> foundIds;
   637 	RArray<TUint32> foundIds;
   600 
   638 
   601 	TInt r = KErrNone;
   639 	TInt r = KErrNone;
   909 @SYMTestPriority		High
   947 @SYMTestPriority		High
   910 @SYMTestActions			Test for CRepository::NotifyRequest() functions
   948 @SYMTestActions			Test for CRepository::NotifyRequest() functions
   911 @SYMTestExpectedResults Test must not fail
   949 @SYMTestExpectedResults Test must not fail
   912 @SYMREQ					REQ0000
   950 @SYMREQ					REQ0000
   913 */
   951 */
   914 LOCAL_C void NotifyL()
   952 /**
       
   953 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4115
       
   954 @SYMTestCaseDesc		Tests for CRepository's notification functionality test on PMA keyspaces
       
   955 @SYMTestPriority		High
       
   956 @SYMTestActions			Tests for CRepository::NotifyRequest() functions
       
   957 @SYMTestExpectedResults Notification request of a setting should behave as expected. 
       
   958                         i.e. non-existent setting should return KErrNotFound
       
   959                              Duplicate notification should not be created
       
   960                              Other request should return KErrNone.
       
   961 @SYMREQ					REQ42876
       
   962 */
       
   963 LOCAL_C void NotifyL(TUid aReposUid)
   915 	{
   964 	{
   916 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1300 "));
   965 	CRepository* repository(NULL);
   917 	CRepository* repository;
   966 	User::LeaveIfNull(repository = CRepository::NewLC(aReposUid));
   918 	User::LeaveIfNull(repository = CRepository::NewLC(KUidTestRepository1));
       
   919 
   967 
   920 	TInt r = KErrNone;
   968 	TInt r = KErrNone;
   921 	TInt intval;
   969 	TInt intval;
   922 	TRequestStatus intStatus;
   970 	TRequestStatus intStatus;
   923 	TRequestStatus realStatus;
   971 	TRequestStatus realStatus;
   949 	r = repository->Set(KInt1, intval);
   997 	r = repository->Set(KInt1, intval);
   950 	TEST2(r, KErrNone);
   998 	TEST2(r, KErrNone);
   951 	TEST(intStatus==KRequestPending);
   999 	TEST(intStatus==KRequestPending);
   952 	TEST(realStatus==KRequestPending);
  1000 	TEST(realStatus==KRequestPending);
   953 	TEST(stringStatus==KRequestPending);
  1001 	TEST(stringStatus==KRequestPending);
   954 	TEST(thisThread.RequestCount()==0);
  1002 	TEST2(thisThread.RequestCount(),0);
   955 
  1003 
   956 	// First change to setting should cause notification
  1004 	// First change to setting should cause notification
   957 	r = repository->Set(KInt1, 0);
  1005 	r = repository->Set(KInt1, 0);
   958 	TEST2(r, KErrNone);
  1006 	TEST2(r, KErrNone);
   959 	User::WaitForAnyRequest();
  1007 	User::WaitForAnyRequest();
   966 	r = repository->Set(KInt1, 0);
  1014 	r = repository->Set(KInt1, 0);
   967 	TEST2(r, KErrNone);
  1015 	TEST2(r, KErrNone);
   968 	TEST(intStatus==7777);
  1016 	TEST(intStatus==7777);
   969 	TEST(realStatus==KRequestPending);
  1017 	TEST(realStatus==KRequestPending);
   970 	TEST(stringStatus==KRequestPending);
  1018 	TEST(stringStatus==KRequestPending);
   971 	TEST(thisThread.RequestCount()==0);
  1019 	TEST2(thisThread.RequestCount(),0);
   972 
  1020 
   973 
  1021 
   974 	// Setting to the same value should not cause a notification
  1022 	// Setting to the same value should not cause a notification
   975 	TReal realval;
  1023 	TReal realval;
   976 	r = repository->Get(KReal1, realval);
  1024 	r = repository->Get(KReal1, realval);
   978 	r = repository->Set(KReal1, realval);
  1026 	r = repository->Set(KReal1, realval);
   979 	TEST2(r, KErrNone);
  1027 	TEST2(r, KErrNone);
   980 	TEST(intStatus==7777);
  1028 	TEST(intStatus==7777);
   981 	TEST(realStatus==KRequestPending);
  1029 	TEST(realStatus==KRequestPending);
   982 	TEST(stringStatus==KRequestPending);
  1030 	TEST(stringStatus==KRequestPending);
   983 	TEST(thisThread.RequestCount()==0);
  1031 	TEST2(thisThread.RequestCount(),0);
   984 
  1032 
   985 	r = repository->Set(KReal1, 0.0);
  1033 	r = repository->Set(KReal1, 0.0);
   986 	TEST2(r, KErrNone);
  1034 	TEST2(r, KErrNone);
   987 	User::WaitForAnyRequest();
  1035 	User::WaitForAnyRequest();
   988 	TEST(intStatus==7777);
  1036 	TEST(intStatus==7777);
  1138 						(for more nformation on this requirement see DEF061504)
  1186 						(for more nformation on this requirement see DEF061504)
  1139 @SYMDEF               	INC102413
  1187 @SYMDEF               	INC102413
  1140 */
  1188 */
  1141 LOCAL_C void CancelNotificationsL()
  1189 LOCAL_C void CancelNotificationsL()
  1142 	{
  1190 	{
  1143 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-3400 "));
  1191 	CRepository* repository(NULL);
  1144 	CRepository* repository;
       
  1145 	User::LeaveIfNull(repository = CRepository::NewLC(KUidTestRepository1));
  1192 	User::LeaveIfNull(repository = CRepository::NewLC(KUidTestRepository1));
  1146 
  1193 
  1147 	TInt r = KErrNone;
  1194 	TInt r = KErrNone;
  1148 	TRequestStatus intStatus;
  1195 	TRequestStatus intStatus;
  1149 	TRequestStatus realStatus1;
  1196 	TRequestStatus realStatus1;
  1273 @SYMTestPriority		High
  1320 @SYMTestPriority		High
  1274 @SYMTestActions			Test for CRepository::Create(),CRepository::Delete() functions
  1321 @SYMTestActions			Test for CRepository::Create(),CRepository::Delete() functions
  1275 @SYMTestExpectedResults Test must not fail
  1322 @SYMTestExpectedResults Test must not fail
  1276 @SYMREQ					REQ0000
  1323 @SYMREQ					REQ0000
  1277 */
  1324 */
       
  1325 /**
       
  1326 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4116
       
  1327 @SYMTestCaseDesc		Tests for CRepository's Create and Delete functionality test on PMA keyspaces
       
  1328 @SYMTestPriority		High
       
  1329 @SYMTestActions			Test for CRepository::Create(),CRepository::Delete() functions
       
  1330 @SYMTestExpectedResults Create and Delete of settings should behave as expected. 
       
  1331                         i.e. Create should not fail unless setting already exists
       
  1332                              Non-existent setting should return KErrNotFound.
       
  1333                              Mask deletion should delete only expected settings.
       
  1334 @SYMREQ					REQ42876
       
  1335 */
  1278 LOCAL_C void CreateDeleteL(const TUid& aUid)
  1336 LOCAL_C void CreateDeleteL(const TUid& aUid)
  1279 	{
  1337 	{
  1280 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1301 "));
  1338 	CRepository* repository(NULL);
  1281 	CRepository* repository;
       
  1282 	User::LeaveIfNull(repository = CRepository::NewLC(aUid));
  1339 	User::LeaveIfNull(repository = CRepository::NewLC(aUid));
  1283 
  1340 
  1284 	TInt x;
  1341 	TInt x;
  1285 	TReal y;
  1342 	TReal y;
  1286 	TBuf8<20> z8;
  1343 	TBuf8<20> z8;
  1634 @SYMTestExpectedResults Test must not fail
  1691 @SYMTestExpectedResults Test must not fail
  1635 @SYMREQ					REQ0000
  1692 @SYMREQ					REQ0000
  1636 */
  1693 */
  1637 LOCAL_C void MultiClientL()
  1694 LOCAL_C void MultiClientL()
  1638 	{
  1695 	{
  1639 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1302 "));
       
  1640 	CRepository* repository1;
  1696 	CRepository* repository1;
  1641 	User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1));
  1697 	User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1));
  1642 	CRepository* repository2;
  1698 	CRepository* repository2;
  1643 	User::LeaveIfNull(repository2 = CRepository::NewLC(KUidTestRepository1));
  1699 	User::LeaveIfNull(repository2 = CRepository::NewLC(KUidTestRepository1));
  1644 
  1700 
  1685 @SYMTestExpectedResults Test must not fail
  1741 @SYMTestExpectedResults Test must not fail
  1686 @SYMREQ					REQ0000
  1742 @SYMREQ					REQ0000
  1687 */
  1743 */
  1688 LOCAL_C void ResetL()
  1744 LOCAL_C void ResetL()
  1689 	{
  1745 	{
  1690 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1303 "));
       
  1691 	CRepository* repositoryA;
  1746 	CRepository* repositoryA;
  1692 	User::LeaveIfNull(repositoryA = CRepository::NewLC(KUidTestRepository1));
  1747 	User::LeaveIfNull(repositoryA = CRepository::NewLC(KUidTestRepository1));
  1693 
  1748 
  1694 	//
  1749 	//
  1695 	// Test reset on a single setting that exists in the
  1750 	// Test reset on a single setting that exists in the
  1998 	r = repositoryA->Reset();
  2053 	r = repositoryA->Reset();
  1999 	TEST2(r, KErrNone);
  2054 	TEST2(r, KErrNone);
  2000 
  2055 
  2001 	CleanupStack::PopAndDestroy(repositoryA);
  2056 	CleanupStack::PopAndDestroy(repositoryA);
  2002 	}
  2057 	}
       
  2058 
       
  2059 #if defined(SYMBIAN_INCLUDE_APP_CENTRIC)
       
  2060 /**
       
  2061 @SYMTestCaseID          PDS-CENTRALREPOSITORY-CT-4117
       
  2062 @SYMTestCaseDesc        Tests for resetting the new changes on CRepository (PMA repository)
       
  2063 @SYMTestPriority        High
       
  2064 @SYMTestActions         Tests for CRepository::Reset() function on a PMA repository
       
  2065                         Tests for reset on a single setting that exists in the original ROM-based settings.
       
  2066                         Tests for reset for a single setting that does not exist in the original ROM-based settings.
       
  2067                         Tests for repository-wide reset for a repository that exists on ROM.
       
  2068 @SYMTestExpectedResults Test must not fail
       
  2069 @SYMREQ                 REQ42876
       
  2070 */
       
  2071 LOCAL_C void ResetPMAL(TUid aReposUid)
       
  2072     {
       
  2073     CRepository* repository(NULL);
       
  2074     User::LeaveIfNull(repository = CRepository::NewLC(aReposUid));
       
  2075 
       
  2076     //
       
  2077     // Test reset on a single setting that exists in the
       
  2078     // original ROM-based settings (we'll use KInt1)
       
  2079     //
       
  2080 
       
  2081     // Ensure KInt1 is set to a different value to its initial value
       
  2082     TInt r = repository->Set(KInt1, KInt1_InitialValue+10);
       
  2083     TEST2(r, KErrNone);
       
  2084 
       
  2085     r = repository->Reset(KInt1);
       
  2086     TEST2(r, KErrNotSupported);
       
  2087 
       
  2088     // Check KInt1 now still has the new value
       
  2089     TInt x;
       
  2090     r = repository->Get(KInt1, x);
       
  2091     TEST2(r, KErrNone);
       
  2092     TEST(x==KInt1_InitialValue+10);
       
  2093 
       
  2094     //
       
  2095     // Test reset for a single setting that does not exist
       
  2096     // in the original ROM-based settings.
       
  2097     // Test repository-wide reset for a repository
       
  2098     // that exists on ROM.
       
  2099     //
       
  2100     const TInt KIntValue = 1234;
       
  2101     r = repository->Create(KNewInt, KIntValue);
       
  2102     TEST2(r, KErrNone);
       
  2103 
       
  2104     //Reset a setting should fail as it is supported on PMA repositories
       
  2105     r = repository->Reset(KNewInt);
       
  2106     TEST2(r, KErrNotSupported);
       
  2107     
       
  2108     //Reset whole repository should fail as it is supported on PMA repositories
       
  2109     r = repository->Reset();
       
  2110     TEST2(r, KErrNotSupported);
       
  2111 
       
  2112     //Check that KNewInt is still there
       
  2113     r = repository->Get(KNewInt, x);
       
  2114     TEST2(r, KErrNone);
       
  2115     TEST(x==KIntValue);
       
  2116 
       
  2117     CleanupStack::PopAndDestroy(repository);
       
  2118     }
       
  2119 
       
  2120 /**
       
  2121 @SYMTestCaseID          PDS-CENTRALREPOSITORY-CT-4118
       
  2122 @SYMTestCaseDesc        Tests for CentRep's repository type check during opening. 
       
  2123 @SYMTestPriority        High
       
  2124 @SYMTestActions         Tests for opening a PMA repository that is stored in persist folder
       
  2125                         Tests for opening a non-PMA repository that is stored in PMA drive
       
  2126 @SYMTestExpectedResults Must return with KErrNotSupported in both cases
       
  2127 @SYMREQ                 REQ42876
       
  2128 */
       
  2129 LOCAL_C void CorruptPMAL(TUid aReposUid, TInt aExpectedResult)
       
  2130     {
       
  2131     CRepository* repository(NULL);
       
  2132     TRAPD(err, repository = CRepository::NewL(aReposUid));
       
  2133     TEST2(err, aExpectedResult);
       
  2134     TEST(repository == NULL);
       
  2135     
       
  2136     // We should only test for KErrNotFound if aExpectedResult is not the same. 
       
  2137     // No point to test again for KErrNotFound.
       
  2138     if (aExpectedResult != KErrNotFound) 
       
  2139         {
       
  2140         //The corrupted repository should be deleted, so it should get KErrNotFound
       
  2141         TRAP(err, repository = CRepository::NewL(aReposUid));
       
  2142         TEST2(err, KErrNotFound);
       
  2143         TEST(repository == NULL);
       
  2144         }
       
  2145 
       
  2146     }
       
  2147 
       
  2148 /**
       
  2149 @SYMTestCaseID          PDS-CENTRALREPOSITORY-CT-4119
       
  2150 @SYMTestCaseDesc        Tests for opening PMA txt repos in PMA drive. 
       
  2151 @SYMTestPriority        High
       
  2152 @SYMTestActions         Tests for opening PMA txt repos that is stored in PMA drive
       
  2153 @SYMTestExpectedResults Must return with KErrNotFound
       
  2154 @SYMREQ                 REQ42876
       
  2155 */
       
  2156 LOCAL_C void OpenTxtInPMAL(TUid aReposUid)
       
  2157     {
       
  2158     CRepository* repository(NULL);
       
  2159     TRAPD(err, repository = CRepository::NewL(aReposUid));
       
  2160     
       
  2161     TEST2(err, KErrNotFound);
       
  2162     TEST(repository == NULL);
       
  2163     }
       
  2164 
       
  2165 /**
       
  2166 @SYMTestCaseID          PDS-CENTRALREPOSITORY-CT-4175
       
  2167 @SYMTestCaseDesc        Tests for opening PMA txt and cre repos in install directory. 
       
  2168 @SYMTestPriority        High
       
  2169 @SYMTestActions         Open PMA txt and cre repos in install directory
       
  2170 @SYMTestExpectedResults Both cases must return with KErrNotSupported and 
       
  2171                         the PMA files must be deleted from the install directory
       
  2172 @SYMREQ                 REQ42876
       
  2173 */
       
  2174 LOCAL_C void OpenPmaRepInInstallDirL()
       
  2175     {
       
  2176     RFs fs;
       
  2177     TEntry entry;
       
  2178     CRepository* repository(NULL);
       
  2179    
       
  2180     TInt err = fs.Connect();
       
  2181     TEST2(err, KErrNone);
       
  2182     
       
  2183     CFileMan* fm = CFileMan::NewL(fs);
       
  2184     CleanupStack::PushL(fm);
       
  2185     
       
  2186     // Copying the test repository files here to the install directory, because 
       
  2187     //  if they are copied before the Central Repository server has started, when
       
  2188     //  the server starts they will be deleted, as PMA repositories are not
       
  2189     //  allowed in the install directory.
       
  2190     _LIT(KPMATxtInstallSourcePath, "Z:\\private\\10202BE9\\f1000117.txi");
       
  2191     _LIT(KPMATxtInstallTargetPath, "C:\\private\\10202BE9\\f1000117.txt");
       
  2192     CopyTestFilesL(*fm,KPMATxtInstallSourcePath, KPMATxtInstallTargetPath);
       
  2193     
       
  2194     _LIT(KPMACreInstallSourcePath, "Z:\\private\\10202BE9\\f1000118.cri");
       
  2195     _LIT(KPMACreInstallTargetPath, "C:\\private\\10202BE9\\f1000118.cre");
       
  2196     CopyTestFilesL(*fm,KPMACreInstallSourcePath, KPMACreInstallTargetPath);
       
  2197 
       
  2198     CleanupStack::PopAndDestroy(fm);
       
  2199     
       
  2200 
       
  2201     
       
  2202     TRAP(err, repository = CRepository::NewL(KUidPmaTxtInInstallDir1));
       
  2203     TEST2(err, KErrNotSupported);
       
  2204     TEST(repository == NULL);
       
  2205     
       
  2206     //The PMA txt file in the install directory should be deleted after the open attempt
       
  2207     err = fs.Entry(KPMATxtInstallTargetPath,entry);
       
  2208     TEST2(err, KErrNotFound);
       
  2209         
       
  2210     TRAP(err, repository = CRepository::NewL(KUidPmaCreInInstallDir1));
       
  2211     TEST2(err, KErrNotSupported);
       
  2212     TEST(repository == NULL);
       
  2213     
       
  2214     //The PMA cre file in the install directory should be deleted after the open attempt
       
  2215     err = fs.Entry(KPMACreInstallTargetPath,entry);
       
  2216     TEST2(err, KErrNotFound);
       
  2217     }
       
  2218 #endif
  2003 
  2219 
  2004 /**
  2220 /**
  2005 @SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-CT-1304
  2221 @SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-CT-1304
  2006 @SYMTestCaseDesc		Tests for initialising file searching
  2222 @SYMTestCaseDesc		Tests for initialising file searching
  2007 @SYMTestPriority		High
  2223 @SYMTestPriority		High
  2009 @SYMTestExpectedResults Test must not fail
  2225 @SYMTestExpectedResults Test must not fail
  2010 @SYMREQ					REQ0000
  2226 @SYMREQ					REQ0000
  2011 */
  2227 */
  2012 LOCAL_C void IniFileSearching()
  2228 LOCAL_C void IniFileSearching()
  2013 	{
  2229 	{
  2014 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1304 "));
  2230     RFs fs;
       
  2231     User::LeaveIfError(fs.Connect());
       
  2232     
       
  2233     //The purpose of this test case is to prove that ROM version of the 
       
  2234     // keyspace will be used before the install version.
       
  2235     // So we want to delete the persisted version here, otherwise it will 
       
  2236     // be picked up before the ROM version.
       
  2237     _LIT(KReposFileName,"c:\\private\\10202be9\\persists\\00000010.cre");
       
  2238     TInt r = fs.Delete(KReposFileName);
       
  2239     if (r != KErrNone && r != KErrNotFound && r != KErrPathNotFound)
       
  2240         {
       
  2241         User::Leave(r);
       
  2242         }
       
  2243     
  2015 	const TInt KSettingKey = 1;
  2244 	const TInt KSettingKey = 1;
  2016 
  2245 
  2017 	_LIT(KDriveZ, "drive z");
  2246 	_LIT(KDriveZ, "drive z");
  2018 
  2247 
  2019 	const TInt KBufLen = 7; // = Max of 3 above string lengths
  2248 	const TInt KBufLen = 7; // = Max of 3 above string lengths
  2020 
  2249 	
  2021 	//
  2250 	CRepository* repository = CRepository::NewL(KUidDriveZRepository);
  2022 	// File on drive C should take precedence
       
  2023 	//
       
  2024 	CRepository* repository = CRepository::NewL(KUidDriveCRepository);
       
  2025 
  2251 
  2026 	TBuf<KBufLen> str;
  2252 	TBuf<KBufLen> str;
  2027 	TInt r = repository->Get(KSettingKey, str);
  2253 	r = repository->Get(KSettingKey, str);
  2028 	TEST2(r, KErrNone);
  2254 	TEST2(r, KErrNone);
  2029 	TEST(str==KDriveZ); 
  2255 	TEST(str==KDriveZ); 
  2030 
  2256 
  2031 	delete repository;
  2257 	delete repository;
  2032 	}
  2258 	}
  2039 @SYMTestExpectedResults Test must not fail
  2265 @SYMTestExpectedResults Test must not fail
  2040 @SYMREQ					REQ0000
  2266 @SYMREQ					REQ0000
  2041 */
  2267 */
  2042 LOCAL_C void RepositoryOnDriveC()
  2268 LOCAL_C void RepositoryOnDriveC()
  2043 	{
  2269 	{
  2044 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1305 "));
       
  2045 	const TInt KSettingKey = KNonExisitentSetting;
  2270 	const TInt KSettingKey = KNonExisitentSetting;
  2046 	const TInt KInitialValue = 10;
  2271 	const TInt KInitialValue = 10;
  2047 
  2272 
  2048 	CRepository* repository = CRepository::NewL(KUidDriveCOnlyRepository);
  2273 	CRepository* repository = CRepository::NewL(KUidDriveCOnlyRepository);
  2049 	CleanupStack::PushL(repository);
  2274 	CleanupStack::PushL(repository);
  2096 @SYMTestExpectedResults Test must not fail
  2321 @SYMTestExpectedResults Test must not fail
  2097 @SYMPREQ				PREQ1228
  2322 @SYMPREQ				PREQ1228
  2098 */
  2323 */
  2099 LOCAL_C void NotifyOnlyL()
  2324 LOCAL_C void NotifyOnlyL()
  2100 	{
  2325 	{
  2101 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1656 "));
       
  2102 	CRepository* repository1;
  2326 	CRepository* repository1;
  2103 	User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1));
  2327 	User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1));
  2104 
  2328 
  2105 	// check that functions work
  2329 	// check that functions work
  2106 	TInt i;
  2330 	TInt i;
  2213 
  2437 
  2214 	r = repository2->Set(KInt1, 0);
  2438 	r = repository2->Set(KInt1, 0);
  2215 	TEST2(r, KErrNone);
  2439 	TEST2(r, KErrNone);
  2216 	User::WaitForAnyRequest();
  2440 	User::WaitForAnyRequest();
  2217 	TEST(status1==KInt1);
  2441 	TEST(status1==KInt1);
       
  2442 	User::WaitForAnyRequest();
  2218 	TEST(status3==KInt1);
  2443 	TEST(status3==KInt1);
  2219 	
  2444 	
  2220 	r = repository1->NotifyRequest(KInt1, status1);
  2445 	r = repository1->NotifyRequest(KInt1, status1);
  2221 	TEST2(r, KErrNone);
  2446 	TEST2(r, KErrNone);
  2222 	r = repository3->NotifyRequest(KInt1, status3);
  2447 	r = repository3->NotifyRequest(KInt1, status3);
  2226 
  2451 
  2227 	r = repository2->Set(KInt1, 1);
  2452 	r = repository2->Set(KInt1, 1);
  2228 	TEST2(r, KErrNone);
  2453 	TEST2(r, KErrNone);
  2229 	User::WaitForAnyRequest();
  2454 	User::WaitForAnyRequest();
  2230 	TEST(status1==KInt1);
  2455 	TEST(status1==KInt1);
       
  2456 	User::WaitForAnyRequest();
  2231 	TEST(status3==KInt1);
  2457 	TEST(status3==KInt1);
  2232 
  2458 
  2233 	CleanupStack::PopAndDestroy(3);
  2459 	CleanupStack::PopAndDestroy(3);
  2234 	// Kill the server to force clearing the cache
  2460 	// Kill the server to force clearing the cache
  2235 	KillCentRepServerL();
  2461 	KillCentRepServerL();
  2258                         metadata, if it exists.
  2484                         metadata, if it exists.
  2259 @SYMDEF                 DEF144530
  2485 @SYMDEF                 DEF144530
  2260 */
  2486 */
  2261 LOCAL_C void RangeDeleteMetaL()
  2487 LOCAL_C void RangeDeleteMetaL()
  2262     {
  2488     {
  2263     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4113 "));
       
  2264 
       
  2265     TUint32 partialKey   = 0x0000004;
  2489     TUint32 partialKey   = 0x0000004;
  2266     TUint32 mask         = 0xFFFFFFF;
  2490     TUint32 mask         = 0xFFFFFFF;
  2267     TUint32 meta = 0;
  2491     TUint32 meta = 0;
  2268     TUint32 expectedMeta = 0x10; // 16 
  2492     TUint32 expectedMeta = 0x10; // 16 
  2269     TUint32 keyCount = 0;
  2493     TUint32 keyCount = 0;
  2270     TUint32 expectedKeyCount = 1;
  2494     TUint32 expectedKeyCount = 1;
  2271     TUint32 error;
  2495     TUint32 error;
  2272 
  2496 
  2273     CRepository* repository;
  2497     CRepository* repository(NULL);
  2274     User::LeaveIfNull(repository = CRepository::NewL(KUidTestRepository3)); // 00000103.txt
  2498     User::LeaveIfNull(repository = CRepository::NewL(KUidTestRepository3)); // 00000103.txt
  2275     
  2499     
  2276     repository->StartTransaction(CRepository::EReadWriteTransaction);
  2500     repository->StartTransaction(CRepository::EReadWriteTransaction);
  2277 
  2501 
  2278     // Only want to delete 1 specific key, using the range delete function.
  2502     // Only want to delete 1 specific key, using the range delete function.
  2295     TEST2(ret, KErrNone);
  2519     TEST2(ret, KErrNone);
  2296     TEST2(meta, expectedMeta);
  2520     TEST2(meta, expectedMeta);
  2297     
  2521     
  2298     delete repository;
  2522     delete repository;
  2299     }
  2523     }
  2300 
       
  2301 
  2524 
  2302 /**
  2525 /**
  2303 @SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-CT-0494
  2526 @SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-CT-0494
  2304 @SYMTestCaseDesc		Tests the various functions on CentralRepository
  2527 @SYMTestCaseDesc		Tests the various functions on CentralRepository
  2305 @SYMTestPriority		High
  2528 @SYMTestPriority		High
  2312 LOCAL_C void FuncTestsL()
  2535 LOCAL_C void FuncTestsL()
  2313 	{
  2536 	{
  2314 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-0494 Open/Close repository "));
  2537 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-0494 Open/Close repository "));
  2315 	OpenRepositoryL();
  2538 	OpenRepositoryL();
  2316 
  2539 
  2317 	TheTest.Next(_L("Get/Set .ini"));
  2540 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1298 Get/Set .ini"));
  2318 	GetSetL(KUidTestRepository1);
  2541 	GetSetL(KUidTestRepository1);
  2319 
  2542 
  2320 	TheTest.Next(_L("Get/Set .cre"));
  2543 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1298 Get/Set .cre"));
  2321 	GetSetL(KUidCreTestRepository1);
  2544 	GetSetL(KUidCreTestRepository1);
  2322 
  2545 	
  2323 	TheTest.Next(_L("Find"));
  2546 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1299 Find"));
  2324 	FindL();
  2547 	FindL();
  2325 
  2548 	
  2326 	TheTest.Next(_L("Notify"));
  2549 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1300 Notify"));
  2327 	NotifyL();
  2550 	NotifyL(KUidTestRepository1);
  2328 
  2551 	
  2329 	TheTest.Next(_L("Create/Delete .ini"));
  2552 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1301 Create/Delete .ini"));
  2330 	CreateDeleteL(KUidTestRepository1);
  2553 	CreateDeleteL(KUidTestRepository1);
  2331 
  2554 
  2332 	TheTest.Next(_L("Create/Delete .cre"));
  2555 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1301 Create/Delete .cre"));
  2333 	CreateDeleteL(KUidCreTestRepository1);
  2556 	CreateDeleteL(KUidCreTestRepository1);
  2334 
  2557 	
  2335 	TheTest.Next(_L("Initialisation file searching"));
  2558 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1304 Initialisation file searching"));
  2336 	IniFileSearching();
  2559 	IniFileSearching();
  2337 
  2560 	
  2338 	TheTest.Next(_L("Repository on Drive C only"));
  2561 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1305 Repository on Drive C only"));
  2339 	RepositoryOnDriveC();
  2562 	RepositoryOnDriveC();
  2340 
  2563 
  2341 	TheTest.Next(_L("Multiple clients"));
  2564 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1302 Multiple clients"));
  2342 	MultiClientL();
  2565 	MultiClientL();
  2343 
  2566 
  2344 	TheTest.Next(_L("Restore factory settings"));
  2567 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1303 Restore factory settings"));
  2345 	ResetL();
  2568 	ResetL();
  2346 
  2569 	
  2347 	TheTest.Next(_L("Restore factory settings from binary based rep"));
  2570 	TheTest.Next(_L("Restore factory settings from binary based rep"));
  2348 	ResetCreL();
  2571 	ResetCreL();
  2349 
  2572 	
  2350 	TheTest.Next(_L("Negative testing for the notification cancelling"));
  2573 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-3400 Negative testing for the notification cancelling"));
  2351 	CancelNotificationsL();
  2574 	CancelNotificationsL();
  2352 
  2575 
  2353 	TheTest.Next(_L("Notify-only client optimizations"));
  2576 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1656 Notify-only client optimizations"));
  2354 	NotifyOnlyL();
  2577 	NotifyOnlyL();
  2355 	
  2578 	
  2356 	TheTest.Next(_L("Meta data after a Range Delete in transaction"));
  2579 	TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4113 Meta data after a Range Delete in transaction"));
  2357     RangeDeleteMetaL();
  2580     RangeDeleteMetaL();
  2358     
  2581     
  2359 	TheTest.End();
  2582 #if defined(SYMBIAN_INCLUDE_APP_CENTRIC)
       
  2583     // The following tests are done on PMA based repositories
       
  2584     
       
  2585     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4114 Get/Set PMA .txt in ROM"));
       
  2586     GetSetL(KUidTxtPMATestRepos1);
       
  2587     
       
  2588     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4114 Get/Set PMA .cre in ROM"));
       
  2589     GetSetL(KUidCrePMATestRepos1);
       
  2590     
       
  2591     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4114 Get/Set PMA .cre in PMA drive"));
       
  2592     GetSetL(KUidCrePMAinPMADriveTestRepos1);
       
  2593     
       
  2594     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4115 Notify PMA"));
       
  2595     NotifyL(KUidTxtPMATestRepos1);
       
  2596         
       
  2597     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4116 Create/Delete PMA .txt in ROM"));
       
  2598     CreateDeleteL(KUidTxtPMATestRepos1);
       
  2599                 
       
  2600     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4116 Create/Delete PMA .cre in ROM"));
       
  2601     CreateDeleteL(KUidCrePMATestRepos1);
       
  2602     
       
  2603     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4116 Create/Delete PMA .cre in PMA drive"));
       
  2604     CreateDeleteL(KUidCrePMAinPMADriveTestRepos1);
       
  2605     
       
  2606     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4117 Restore factory settings on PMA repository"));
       
  2607     ResetPMAL(KUidTxtPMATestRepos1);
       
  2608                 
       
  2609     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4117 Restore factory settings on binary based PMA repository"));
       
  2610     ResetPMAL(KUidCrePMATestRepos1);
       
  2611     
       
  2612     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4118 Opening a non-PMA repos that is in PMA drive"));
       
  2613     CorruptPMAL(KUidCorruptRepos1, KErrNotSupported);
       
  2614     
       
  2615     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4118 Opening a PMA repos that is in persist folder"));
       
  2616     CorruptPMAL(KUidCorruptRepos2, KErrNotFound);
       
  2617     
       
  2618     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4119 Opening a txt repos that is in PMA drive"));
       
  2619     OpenTxtInPMAL(KUidTxtInPMADriveRepos1);
       
  2620     
       
  2621     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4175 Opening PMA repositories that only exists in the install directory"));
       
  2622     OpenPmaRepInInstallDirL();
       
  2623 
       
  2624 #endif // SYMBIAN_INCLUDE_APP_CENTRIC
       
  2625 
       
  2626     TheTest.End();
  2360 	}
  2627 	}
  2361 
  2628 
  2362 /**
  2629 /**
  2363 OomTest
  2630 OomTest
  2364 Function to convert a test into an OOM test
  2631 Function to convert a test into an OOM test
  2405 	User::__DbgSetAllocFail(RHeap::EUser, RHeap::ENone, 1);
  2672 	User::__DbgSetAllocFail(RHeap::EUser, RHeap::ENone, 1);
  2406 	}
  2673 	}
  2407 
  2674 
  2408 LOCAL_C void OomTestsL()
  2675 LOCAL_C void OomTestsL()
  2409 	{
  2676 	{
  2410 	TheTest.Start(_L("Open/Close repository"));
  2677 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1297 Open/Close repository"));
  2411 	OomTest(OpenRepositoryL);
  2678 	OomTest(OpenRepositoryL);
  2412 
  2679 
  2413 	TheTest.Next(_L("GetSet for KUidTestRepository1"));
  2680 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1298 GetSet for KUidTestRepository1"));
  2414 	GetSetL(KUidTestRepository1);
  2681 	GetSetL(KUidTestRepository1);
  2415 	TheTest.Next(_L("GetSet for KUidCreTestRepository1"));
  2682 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1298 GetSet for KUidCreTestRepository1"));
  2416 	GetSetL(KUidCreTestRepository1);
  2683 	GetSetL(KUidCreTestRepository1);
  2417 
  2684 
  2418 	TheTest.Next(_L("Find"));
  2685 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1299 Find"));
  2419 	OomTest(FindL);
  2686 	OomTest(FindL);
  2420 
  2687 
  2421 	TheTest.End();
  2688 	TheTest.End();
  2422 	}
  2689 	}
  2423 
  2690 
  2424 //This function tests the replacement of RFile with RFileBuf in CIniFileOut class (inifile.h)
  2691 //This function tests the replacement of RFile with RFileBuf in CIniFileOut class (inifile.h)
  2425 //It shows that there is approx. 20% (LUBBOCK) performance boost when using simple "Set"
  2692 //It shows that there is approx. 20% (LUBBOCK) performance boost when using simple "Set"
  2426 //operations. It may be even better when using "Commit" functionality.
  2693 //operations. It may be even better when using "Commit" functionality.
  2427 static void PerformanceTestL()
  2694 static void PerformanceTestL()
  2428 	{
  2695     {
  2429 	CRepository* repository = CRepository::NewL(KUidDriveCOnlyRepository);
  2696     CRepository* repository = CRepository::NewL(KUidDriveCOnlyRepository);
  2430 	CleanupStack::PushL(repository);
  2697     CleanupStack::PushL(repository);
  2431 	//Test settings IDs
  2698     //Test settings IDs
  2432 	const TUint KIntId = 101;
  2699     const TUint KIntId = 101;
  2433 	const TUint KRealId = 102;
  2700     const TUint KRealId = 102;
  2434 	const TUint KDes16Id = 103;
  2701     const TUint KDes16Id = 103;
  2435 	const TUint KDes8Id = 104;
  2702     const TUint KDes8Id = 104;
  2436 	//Create test settings
  2703     //Create test settings
  2437 	TInt err = repository->Create(KIntId, 1);
  2704     TInt err = repository->Create(KIntId, 1);
  2438 	TEST2(err, KErrNone);
  2705     TEST2(err, KErrNone);
  2439 	err = repository->Create(KRealId, 1.1);
  2706     err = repository->Create(KRealId, 1.1);
  2440 	TEST2(err, KErrNone);
  2707     TEST2(err, KErrNone);
  2441 	err = repository->Create(KDes16Id, _L16("DES16"));
  2708     err = repository->Create(KDes16Id, _L16("DES16"));
  2442 	TEST2(err, KErrNone);
  2709     TEST2(err, KErrNone);
  2443 	err = repository->Create(KDes8Id, _L8("DES8"));
  2710     err = repository->Create(KDes8Id, _L8("DES8"));
  2444 	TEST2(err, KErrNone);
  2711     TEST2(err, KErrNone);
  2445 	//Performance test
  2712     //Performance test
  2446 	TBuf16<32> buf16;
  2713     TBuf16<32> buf16;
  2447 	TBuf8<32> buf8;
  2714     TBuf8<32> buf8;
  2448 	TUint timeStart = User::TickCount();
  2715     TUint timeStart = User::TickCount();
  2449 	for(TInt i=0;i<500;++i)
  2716     for(TInt i=0;i<500;++i)
  2450 		{
  2717         {
  2451 		buf16.Zero();
  2718         buf16.Zero();
  2452 		buf16.AppendNum(i);
  2719         buf16.AppendNum(i);
  2453 		buf8.Zero();
  2720         buf8.Zero();
  2454 		buf8.AppendNum(i);
  2721         buf8.AppendNum(i);
  2455 
  2722 
  2456 		TInt err = repository->Set(KIntId, i);
  2723         TInt err = repository->Set(KIntId, i);
  2457 		TEST2(err, KErrNone);
  2724         TEST2(err, KErrNone);
  2458 		err = repository->Set(KRealId, (TReal)i);
  2725         err = repository->Set(KRealId, (TReal)i);
  2459 		TEST2(err, KErrNone);
  2726         TEST2(err, KErrNone);
  2460 		err = repository->Set(KDes16Id, buf16);
  2727         err = repository->Set(KDes16Id, buf16);
  2461 		TEST2(err, KErrNone);
  2728         TEST2(err, KErrNone);
  2462 		err = repository->Set(KDes8Id, buf8);
  2729         err = repository->Set(KDes8Id, buf8);
  2463 		TEST2(err, KErrNone);
  2730         TEST2(err, KErrNone);
  2464 		}
  2731         }
  2465 	TUint timeEnd = User::TickCount();
  2732     TUint timeEnd = User::TickCount();
  2466 	CleanupStack::PopAndDestroy(repository);
  2733     CleanupStack::PopAndDestroy(repository);
  2467 	TheTest.Printf(_L("\nPerformanceTestL - %d ticks\n"), timeEnd-timeStart);
  2734     TheTest.Printf(_L("\nPerformanceTestL - %d ticks\n"), timeEnd-timeStart);
  2468 	}
  2735     }
  2469 
  2736 
  2470 /**
  2737 /**
  2471 @SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-CT-0497
  2738 @SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-CT-0497
  2472 @SYMTestCaseDesc		CentralRepository functionality test
  2739 @SYMTestCaseDesc		CentralRepository functionality test
  2473 @SYMTestPriority		High
  2740 @SYMTestPriority		High
  2475 @SYMTestExpectedResults Test must not fail
  2742 @SYMTestExpectedResults Test must not fail
  2476 @SYMREQ					REQ0000
  2743 @SYMREQ					REQ0000
  2477 */
  2744 */
  2478 LOCAL_C void MainL()
  2745 LOCAL_C void MainL()
  2479 	{
  2746 	{
  2480 	TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-0497 Functional tests "));
  2747 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-0497 Functional tests "));
       
  2748     
  2481 	OomTesting = EFalse;
  2749 	OomTesting = EFalse;
  2482 	// Existance of caching functionality invalidates some tests and
  2750 	// Existence of caching functionality invalidates some tests and
  2483 	// makes them fail. So cleanup cace.
  2751 	// makes them fail. So cleanup cache.
  2484 	RestoreTestFilesL();
  2752 	RestoreTestFilesL();
  2485 	FuncTestsL();
  2753 	FuncTestsL();
  2486 
  2754 
  2487 	TheTest.Next(_L("Out-of-memory tests"));
  2755 	TheTest.Next(_L("Out-of-memory tests"));
  2488 	OomTesting = ETrue;
  2756 	OomTesting = ETrue;
  2495 	PerformanceTestL();
  2763 	PerformanceTestL();
  2496 
  2764 
  2497 	TheTest.Next(_L("Clean out C: files"));
  2765 	TheTest.Next(_L("Clean out C: files"));
  2498 	CleanupCDriveL();
  2766 	CleanupCDriveL();
  2499 
  2767 
  2500 	TheTest.End();
       
  2501 	TheTest.Close();
       
  2502 	}
  2768 	}
  2503 
  2769 
  2504 TInt E32Main()
  2770 TInt E32Main()
  2505 	{
  2771 	{
  2506 	__UHEAP_MARK;
  2772     TheTest.Title ();
  2507 	CTrapCleanup* cleanup = CTrapCleanup::New();
  2773     TheTest.Start(_L("PMA Central Repository API Test"));
  2508 	if(!cleanup)
  2774     
  2509 		return KErrNoMemory;
  2775     CTrapCleanup* cleanup = CTrapCleanup::New();
  2510 
  2776     TheTest(cleanup != NULL);
  2511 	TRAPD(err, MainL());
  2777     
  2512 	if (err != KErrNone)
  2778     __UHEAP_MARK;
  2513 		User::Panic(_L("Testing failed: "), err);
  2779     
  2514 
  2780     KillProcess(KCentralRepositoryServerName);
  2515 	delete cleanup;
  2781     TRAPD(err, MainL());
  2516 	__UHEAP_MARKEND;
  2782     KillProcess(KCentralRepositoryServerName);
  2517 
  2783     
  2518 	return 0;
  2784     TEST2(err, KErrNone);
       
  2785     
       
  2786     __UHEAP_MARKEND;
       
  2787     
       
  2788     TheTest.End ();
       
  2789     TheTest.Close ();
       
  2790     
       
  2791     delete cleanup;
       
  2792         
       
  2793     User::Heap().Check();
       
  2794     return KErrNone;
  2519 	}
  2795 	}