persistentstorage/centralrepository/test/t_cenrep_perf.cpp
changeset 0 08ec8eefde2f
child 55 44f437012c90
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2008-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 <centralrepository.h>
       
    17 #include <e32test.h>
       
    18 #include <f32file.h>
       
    19 #include <bautils.h>
       
    20 #include <hal.h>
       
    21 
       
    22 RTest 				TheTest(_L("t_cenrep_perf test"));
       
    23 CRepository*		TheRepository = NULL;
       
    24 const TUid 			KTestCenRepUid = {0xCCCCCC03};
       
    25 _LIT(KFileName, "c:\\private\\10202be9\\persists\\cccccc03.cre");
       
    26 
       
    27 ///////////////////////////////////////////////////////////////////////////////////////
       
    28 
       
    29 // Shared test data 
       
    30 
       
    31 enum TValType {EIntVal, ERealVal, EBinaryVal, EStringVal, EMetaVal};
       
    32 enum TTestType {ESetTest, ECreateTest, EFindEqTest, EFindNeqTest, EResetTest};
       
    33 
       
    34 // int
       
    35 const TUint32 KIntKey = 42011136ul;
       
    36 const TUint32 KNewIntKey = 2374040320ul;
       
    37 const TUint32 KNewIntKey2 = 2374040576ul;
       
    38 const TInt KOldIntVal = 10;
       
    39 const TInt KNewIntVal = KOldIntVal + 1;
       
    40 const TUint32 KIntMeta = 0;
       
    41 
       
    42 // real
       
    43 const TUint32 KRealKey = 2374041088ul;
       
    44 const TUint32 KNewRealKey = 2374041344ul;
       
    45 const TReal KOldRealVal = 0.1;
       
    46 const TReal KNewRealVal = KOldRealVal + 1.0;
       
    47 
       
    48 // binary
       
    49 const TUint32 KBinKey = 42141952ul;
       
    50 const TUint32 KNewBinKey = 2374040832ul;
       
    51 _LIT8(KOldBinVal, "\x44\x00\x69\x00\x61\x00\x6c\x00\x4f\x00\x75\x00\x74\x00\x49\x00\x53\x00\x50\x00");
       
    52 _LIT8(KNewBinVal, "\x44\x00\x69\x00\x61\x00\x6c\x00\x4f\x00\x75\x00\x74\x00\x49\x00\x53\x00\x50\x01");
       
    53 
       
    54 // string
       
    55 const TUint32 KStrKey = 2374041600ul;
       
    56 const TUint32 KNewStrKey = 2374041856ul;
       
    57 _LIT(KOldStrVal, "hello");
       
    58 _LIT(KNewStrVal, "goodbye");
       
    59 
       
    60 
       
    61 // FindL range data
       
    62 const TUint32 KFindPartialKey = 0x08440000ul;
       
    63 const TUint32 KFindMask = 0x0FFF0000ul;
       
    64 const TInt KFindKeyCount = 15;
       
    65 
       
    66 
       
    67 ///////////////////////////////////////////////////////////////////////////////////////
       
    68 
       
    69 TInt DeleteCreFile()
       
    70 	{
       
    71 	RFs fs;
       
    72 	fs.Connect();
       
    73 	TInt err = fs.Delete(KFileName);
       
    74 	fs.Close();
       
    75 
       
    76 	// it's fine if the file or path wasn't found as there's nothing to 
       
    77 	// delete so return KErrNone
       
    78 	return (err == KErrNotFound || err == KErrPathNotFound) ? KErrNone : err;
       
    79 	}
       
    80 
       
    81 ///////////////////////////////////////////////////////////////////////////////////////
       
    82 
       
    83 void DestroyTestEnv()
       
    84 	{
       
    85 	delete TheRepository;
       
    86 
       
    87 	// delete the CRE file to clear out any changes made during the test
       
    88 	DeleteCreFile(); 
       
    89 	}
       
    90 
       
    91 ///////////////////////////////////////////////////////////////////////////////////////
       
    92 
       
    93 //Test macros and functions
       
    94 void Check(TInt aValue, TInt aLine)
       
    95 	{
       
    96 	if(!aValue)
       
    97 		{
       
    98 		DestroyTestEnv();
       
    99 		RDebug::Print(_L("*** Test failure. Boolean expression evaluates to false.\r\n"));
       
   100 		TheTest(EFalse, aLine);
       
   101 		}
       
   102 	}
       
   103 void Check2(TInt aValue, TInt aExpected, TInt aLine)
       
   104 	{
       
   105 	if(aValue != aExpected)
       
   106 		{
       
   107 		DestroyTestEnv();
       
   108 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
       
   109 		TheTest(EFalse, aLine);
       
   110 		}
       
   111 	}
       
   112 #define TEST(arg) ::Check((arg), __LINE__)
       
   113 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__)
       
   114 
       
   115 ///////////////////////////////////////////////////////////////////////////////////////
       
   116 
       
   117 // leaves if it can't successfully delete the cre file if it exists
       
   118 void CreateTestEnvL()
       
   119 	{
       
   120 	// delete the CRE file to clear out any changes leftover from previous test runs
       
   121 	User::LeaveIfError(DeleteCreFile());
       
   122 	
       
   123 	TRAPD(err, TheRepository = CRepository::NewL(KTestCenRepUid));
       
   124 	TEST2(err, KErrNone);
       
   125 	}
       
   126 
       
   127 
       
   128 //Prints aTicks parameter (converted to us)
       
   129 void PrintStats(TUint32 aStartTicks, TUint32 aEndTicks)
       
   130 	{
       
   131 	static TInt freq = 0;
       
   132 	if(freq == 0)
       
   133 		{
       
   134 		TEST2(HAL::Get(HAL::EFastCounterFrequency, freq), KErrNone);
       
   135 		}
       
   136 	TInt64 diffTicks = (TInt64)aEndTicks - (TInt64)aStartTicks;
       
   137 	if(diffTicks < 0)
       
   138 		{
       
   139 		diffTicks = KMaxTUint32 + diffTicks + 1;
       
   140 		}
       
   141 	const TInt KMicroSecIn1Sec = 1000000;
       
   142 	TInt32 us = (diffTicks * KMicroSecIn1Sec) / freq;
       
   143 	TheTest.Printf(_L("####Execution time: %d us\r\n"), us);
       
   144 	}
       
   145 
       
   146 ///////////////////////////////////////////////////////////////////////////////////////
       
   147 
       
   148 // Utility functions containing code common to multiple test cases
       
   149 
       
   150 /**
       
   151  * Common code for calling Get() with old values
       
   152  * 
       
   153  * @param aValType enum indicating which data type to test
       
   154  * 	(EIntVal, ERealVal, EBinaryVal, EStringVal or EMetaVal-- any other value will return KErrArgument).
       
   155  * @param aResult bool indicating whether the comparison was successful
       
   156  * @return err code from Get() 
       
   157  */
       
   158 TInt GetOldVal(TValType aValType, TBool& aResult)
       
   159 	{
       
   160 	TInt intVal(0);
       
   161 	TReal realVal(0.0);
       
   162 	TBuf8<100> binVal;
       
   163 	TBuf16<100> strVal;
       
   164 	TUint32 metaVal(0);
       
   165 	
       
   166 	TInt err(KErrNone);
       
   167 
       
   168 	switch (aValType)
       
   169 		{
       
   170 		case EIntVal:
       
   171 			err = TheRepository->Get(KIntKey, intVal);
       
   172 			aResult = (intVal == KOldIntVal); 
       
   173 			break;
       
   174 			
       
   175 		case ERealVal:
       
   176 			err = TheRepository->Get(KRealKey, realVal);
       
   177 			aResult = (realVal == KOldRealVal); 
       
   178 			break;
       
   179 
       
   180 		case EBinaryVal:
       
   181 			err = TheRepository->Get(KBinKey, binVal);
       
   182 			aResult = (binVal == KOldBinVal); 
       
   183 			break;
       
   184 
       
   185 		case EStringVal:
       
   186 			err = TheRepository->Get(KStrKey, strVal);
       
   187 			aResult = (strVal == KOldStrVal); 
       
   188 			break;
       
   189 
       
   190 		case EMetaVal:
       
   191 			err = TheRepository->GetMeta(KIntKey, metaVal);
       
   192 			aResult = (metaVal == KIntMeta);
       
   193 			break;
       
   194 			
       
   195 		default:
       
   196 			err = KErrArgument;
       
   197 			break;
       
   198 		}
       
   199 	return err;
       
   200 	}
       
   201 
       
   202 
       
   203 /**
       
   204  * Common code for calling Get() with new values
       
   205  * 
       
   206  * @param aValType enum indicating which data type to test
       
   207  * 	(EIntVal, ERealVal, EBinaryVal or EStringVal -- any other value will return KErrArgument).
       
   208  * @param aTestType enum defining whether Set() or Create() is being tested
       
   209  * 	(ESetTest or ECreateTest -- anything else will return KErrArgument). 
       
   210  * @param aResult bool indicating whether the comparison was successful
       
   211  * @return err code from Get() 
       
   212  */
       
   213 TInt GetNewVal(TValType aValType, TTestType aTestType, TBool& aResult)
       
   214 	{
       
   215 	// check correct test type
       
   216 	if (aTestType != ECreateTest && aTestType != ESetTest)
       
   217 		{
       
   218 		return KErrArgument;
       
   219 		}
       
   220 	
       
   221 	TInt intVal(0);
       
   222 	TReal realVal(0.0);
       
   223 	TBuf8<100> binVal;
       
   224 	TBuf16<100> strVal;
       
   225 	
       
   226 	TInt err(KErrNone);
       
   227 
       
   228 	switch (aValType)
       
   229 		{
       
   230 		case EIntVal:
       
   231 			err = TheRepository->Get(
       
   232 					(aTestType == ECreateTest ? KNewIntKey : KIntKey), intVal);
       
   233 			aResult = (intVal == KNewIntVal); 
       
   234 			break;
       
   235 			
       
   236 		case ERealVal:
       
   237 			err = TheRepository->Get(
       
   238 					(aTestType == ECreateTest ? KNewRealKey : KRealKey), realVal);
       
   239 			aResult = (realVal == KNewRealVal); 
       
   240 			break;
       
   241 
       
   242 		case EBinaryVal:
       
   243 			err = TheRepository->Get(
       
   244 					(aTestType == ECreateTest ? KNewBinKey : KBinKey), binVal);
       
   245 			aResult = (binVal == KNewBinVal); 
       
   246 			break;
       
   247 
       
   248 		case EStringVal:
       
   249 			err = TheRepository->Get(
       
   250 					(aTestType == ECreateTest ? KNewStrKey : KStrKey), strVal);
       
   251 			aResult = (strVal == KNewStrVal); 
       
   252 			break;
       
   253 
       
   254 		case EMetaVal:
       
   255 			// no meta testing on new setting so fall through
       
   256 			
       
   257 		default:
       
   258 			err = KErrNotFound;
       
   259 			break;
       
   260 		}
       
   261 	return err;
       
   262 	}
       
   263 
       
   264 
       
   265 /**
       
   266  * Common code for calling Set()
       
   267  * 
       
   268  * @param aValType enum indicating which data type to test
       
   269  * 	(EIntVal, ERealVal, EBinaryVal or EStringVal -- any other value will return KErrArgument).
       
   270  * @return err code from Set() 
       
   271  */
       
   272 TInt SetNewVal(TValType aValType)
       
   273 	{
       
   274 	TInt err(KErrNone);
       
   275 
       
   276 	switch (aValType)
       
   277 		{
       
   278 		case EIntVal:
       
   279 			err = TheRepository->Set(KIntKey, KNewIntVal);
       
   280 			break;
       
   281 			
       
   282 		case ERealVal:
       
   283 			err = TheRepository->Set(KRealKey, KNewRealVal);
       
   284 			break;
       
   285 
       
   286 		case EBinaryVal:
       
   287 			err = TheRepository->Set(KBinKey, KNewBinVal);
       
   288 			break;
       
   289 
       
   290 		case EStringVal:
       
   291 			err = TheRepository->Set(KStrKey, KNewStrVal);
       
   292 			break;
       
   293 
       
   294 		case EMetaVal:
       
   295 			// no meta testing on new setting so fall through
       
   296 			
       
   297 		default:
       
   298 			err = KErrArgument;
       
   299 			break;
       
   300 		}
       
   301 	return err;
       
   302 	}
       
   303 
       
   304 
       
   305 /**
       
   306  * Common code for calling Create()
       
   307  * 
       
   308  * @param aValType enum indicating which data type to test
       
   309  * 	(EIntVal, ERealVal, EBinaryVal or EStringVal -- any other value will return KErrArgument).
       
   310   * @return err code from Create() 
       
   311  */
       
   312 TInt CreateNewSetting(TValType aValType)
       
   313 	{
       
   314 	TInt err(KErrNone);
       
   315 
       
   316 	switch (aValType)
       
   317 		{
       
   318 		case EIntVal:
       
   319 			err = TheRepository->Create(KNewIntKey, KNewIntVal);
       
   320 			break;
       
   321 			
       
   322 		case ERealVal:
       
   323 			err = TheRepository->Create(KNewRealKey, KNewRealVal);
       
   324 			break;
       
   325 
       
   326 		case EBinaryVal:
       
   327 			err = TheRepository->Create(KNewBinKey, KNewBinVal);
       
   328 			break;
       
   329 
       
   330 		case EStringVal:
       
   331 			err = TheRepository->Create(KNewStrKey, KNewStrVal);
       
   332 			break;
       
   333 
       
   334 		case EMetaVal:
       
   335 			// no meta testing on new setting so fall through
       
   336 			
       
   337 		default:
       
   338 			err = KErrArgument;
       
   339 			break;
       
   340 		}
       
   341 	return err;
       
   342 	}
       
   343 
       
   344 
       
   345 /**
       
   346  * Common code for calling Reset()
       
   347  * 
       
   348  * @param aValType enum indicating which data type to test
       
   349  * 	(EIntVal, ERealVal, EBinaryVal or EStringVal -- any other value will return KErrArgument).
       
   350   * @return err code from Reset() 
       
   351  */
       
   352 TInt ResetSetting(TValType aValType)
       
   353 	{
       
   354 	TInt err(KErrNone);
       
   355 
       
   356 	switch (aValType)
       
   357 		{
       
   358 		case EIntVal:
       
   359 			err = TheRepository->Reset(KIntKey);
       
   360 			break;
       
   361 			
       
   362 		case ERealVal:
       
   363 			err = TheRepository->Reset(KRealKey);
       
   364 			break;
       
   365 
       
   366 		case EBinaryVal:
       
   367 			err = TheRepository->Reset(KBinKey);
       
   368 			break;
       
   369 
       
   370 		case EStringVal:
       
   371 			err = TheRepository->Reset(KStrKey);
       
   372 			break;
       
   373 
       
   374 		case EMetaVal:
       
   375 			// no meta testing on new setting so fall through
       
   376 			
       
   377 		default:
       
   378 			err = KErrArgument;
       
   379 			break;
       
   380 		}
       
   381 	return err;
       
   382 	}
       
   383 
       
   384 
       
   385 /**
       
   386  * Common code for calling FindL()
       
   387  * 
       
   388  * @param aStart Out parameter for start timer value
       
   389  * @param aEnd Out parameter for end timer value
       
   390  * @param aFound Out parameter for number of settings found
       
   391  * @return err code from FindL()
       
   392  */
       
   393 TInt FindRangeL(TInt& aStart, TInt& aEnd, TInt& aFound)
       
   394 	{
       
   395 	RArray<TUint32> keys;
       
   396 	CleanupClosePushL(keys);
       
   397 	
       
   398 	aStart = User::FastCounter();
       
   399 	TInt err = TheRepository->FindL(KFindPartialKey, KFindMask, keys);
       
   400 	aEnd = User::FastCounter();
       
   401 	
       
   402 	aFound = keys.Count();
       
   403 	
       
   404 	CleanupStack::PopAndDestroy(&keys);
       
   405 
       
   406 	return err;
       
   407 	}
       
   408 
       
   409 
       
   410 /**
       
   411  * Common code for performing all the Get() tests
       
   412  * 
       
   413  * @param aValType enum indicating which data type to test
       
   414  * 	(EIntVal, ERealVal, EBinaryVal, EStringVal or EMetaVal -- any other value will fail with KErrArgument).
       
   415  * @param aUseTransaction bool instructing whether to use a read-mode transaction or not
       
   416  */
       
   417 void DoGetTest(TValType aValType, TBool aUseTransaction = EFalse)
       
   418 	{
       
   419 	TInt err(KErrNone);
       
   420 	TInt result(EFalse);
       
   421 	TUint32 keyInfo(0);
       
   422 
       
   423 	TUint32 start = User::FastCounter();
       
   424 	
       
   425 	// start transaction, if required
       
   426 	err = aUseTransaction ? TheRepository->StartTransaction(CRepository::EReadTransaction) : err;
       
   427 	TEST2(err, KErrNone);
       
   428 
       
   429 	err = GetOldVal(aValType, result);
       
   430 	TEST2(err, KErrNone);
       
   431 
       
   432 	// end transaction, if required
       
   433 	err = aUseTransaction ? TheRepository->CommitTransaction(keyInfo) : err;
       
   434 	TEST2(err, KErrNone);
       
   435 
       
   436 	TUint32 end = User::FastCounter();
       
   437 	
       
   438 	TEST(result);
       
   439 	
       
   440 	PrintStats(start, end);
       
   441 	}
       
   442 
       
   443 
       
   444 /**
       
   445  * Common code for performing the Set() and Reset() tests for all datatypes
       
   446  * 
       
   447  * @param aValType enum indicating which data type to test
       
   448  * 	(EIntVal, ERealVal, EBinaryVal or EStringVal -- any other value will fail with KErrArgument).
       
   449  * @param aTestType enum defining whether Set() or Reset() should be timed
       
   450  */
       
   451 void DoSetResetTest(TValType aValType, TTestType aTestType)
       
   452 	{
       
   453 	TInt err(KErrNone);
       
   454 	TInt result(EFalse);
       
   455 
       
   456 	// Check we get the old expected value
       
   457 	err = GetOldVal(aValType, result);
       
   458 	TEST2(err, KErrNone);
       
   459 	TEST(result);
       
   460 
       
   461 	TUint32 start(0);
       
   462 	TUint32 end(0);
       
   463 
       
   464 	// Set the new value
       
   465 	start = aTestType == ESetTest ? User::FastCounter() : start;
       
   466 	err = SetNewVal(aValType);
       
   467 	end = aTestType == ESetTest ? User::FastCounter() : end;
       
   468 	TEST2(err, KErrNone);
       
   469 
       
   470 	// Test we get the new value to check it's worked
       
   471 	err = GetNewVal(aValType, ESetTest, result);
       
   472 	TEST2(err, KErrNone);
       
   473 	TEST(result);
       
   474 
       
   475 	// Restore the old value
       
   476 	start = aTestType == EResetTest ? User::FastCounter() : start;
       
   477 	err = ResetSetting(aValType);
       
   478 	end = aTestType == EResetTest ? User::FastCounter() : end;
       
   479 	TEST2(err, KErrNone);
       
   480 	
       
   481 	// Check reset's worked
       
   482 	err = GetOldVal(aValType, result);
       
   483 	TEST2(err, KErrNone);
       
   484 	TEST(result);
       
   485 	
       
   486 	PrintStats(start, end);
       
   487 	}
       
   488 
       
   489 
       
   490 /**
       
   491  * Common code for performing all the Create() tests
       
   492  * 
       
   493  * @param aValType enum indicating which data type to test
       
   494  * 	(EIntVal, ERealVal, EBinaryVal, EStringVal, EMetaVal -- any other value will fail with KErrArgument).
       
   495  */
       
   496 void DoCreateTest(TValType aValType)
       
   497 	{
       
   498 	TInt err(KErrNone);
       
   499 	TInt result(EFalse);
       
   500 
       
   501 	TUint32 start(0);
       
   502 	TUint32 end(0);
       
   503 
       
   504 	// Create the new setting
       
   505 	start = User::FastCounter();
       
   506 	err = CreateNewSetting(aValType);
       
   507 	end = User::FastCounter();
       
   508 	TEST2(err, KErrNone);
       
   509 
       
   510 	// Test we get the right value from the new setting to check it's worked
       
   511 	err = GetNewVal(aValType, ECreateTest, result);
       
   512 	TEST2(err, KErrNone);
       
   513 	TEST(result);
       
   514 
       
   515 	PrintStats(start, end);
       
   516 	}
       
   517 
       
   518 
       
   519 /**
       
   520  * Common code for performing all the FindEqL() and FindNeqL() tests
       
   521  * 
       
   522  * @param aValType enum indicating which data type to test
       
   523  * 	(EIntVal, ERealVal, EBinaryVal, EStringVal, EMetaVal -- any other value will fail with KErrArgument).
       
   524  * @param aTestType enum defining whether FindEqL() or FindNeqL() should be timed
       
   525  * 	(EFindEqTest or EFindNeqTest -- anything else will leave with KErrArgument). 
       
   526  */
       
   527 void DoFindEqNeqTestL(TValType aValType, TTestType aTestType)
       
   528 	{
       
   529 	const TUint32 KPartialKey(0x8D800000);
       
   530 	const TUint32 KMask(0xFFF00000);
       
   531 	const TInt KFindNum(1); 
       
   532 	const TInt KNotFindNum(15);
       
   533 	
       
   534 	const TInt KIntFindVal(9999);
       
   535 	const TReal KRealFindVal(999.9);
       
   536 	_LIT8(KBinFindVal, "\xab\xcd\x99\x99");
       
   537 	_LIT(KStrFindVal, "abcd9999");
       
   538 
       
   539 	RArray<TUint32> results;
       
   540 	CleanupClosePushL(results);
       
   541 	
       
   542 	TInt expectedCount(0);
       
   543 	switch(aTestType)
       
   544 		{
       
   545 		case EFindEqTest:
       
   546 			expectedCount = KFindNum;
       
   547 			break;
       
   548 
       
   549 		case EFindNeqTest:
       
   550 			expectedCount = KNotFindNum;
       
   551 			break;
       
   552 
       
   553 		default:
       
   554 			// wrong test type passed in
       
   555 			User::Leave(KErrArgument);
       
   556 		}
       
   557 
       
   558 	TInt err(KErrNone);
       
   559 	
       
   560 	TUint32 start = User::FastCounter();
       
   561 	switch (aValType)
       
   562 		{
       
   563 		case EIntVal:
       
   564 			err = (aTestType == EFindEqTest) ?
       
   565 					TheRepository->FindEqL(KPartialKey, KMask, KIntFindVal, results) :
       
   566 					TheRepository->FindNeqL(KPartialKey, KMask, KIntFindVal, results);
       
   567 			break;
       
   568 			
       
   569 		case ERealVal:
       
   570 			err = (aTestType == EFindEqTest) ?
       
   571 					TheRepository->FindEqL(KPartialKey, KMask, KRealFindVal, results) :
       
   572 					TheRepository->FindNeqL(KPartialKey, KMask, KRealFindVal, results);
       
   573 			break;
       
   574 
       
   575 		case EBinaryVal:
       
   576 			err = (aTestType == EFindEqTest) ?
       
   577 					TheRepository->FindEqL(KPartialKey, KMask, KBinFindVal, results) :
       
   578 					TheRepository->FindNeqL(KPartialKey, KMask, KBinFindVal, results);
       
   579 			break;
       
   580 
       
   581 		case EStringVal:
       
   582 			err = (aTestType == EFindEqTest) ?
       
   583 					TheRepository->FindEqL(KPartialKey, KMask, KStrFindVal, results) :
       
   584 					TheRepository->FindNeqL(KPartialKey, KMask, KStrFindVal, results);
       
   585 			break;
       
   586 
       
   587 		case EMetaVal:
       
   588 			// no meta testing on new setting so fall through
       
   589 			
       
   590 		default:
       
   591 			err = KErrArgument;
       
   592 			break;
       
   593 		}
       
   594 	TUint32 end = User::FastCounter();
       
   595 	
       
   596 	// Test there was no error and that we found the expected number
       
   597 	TEST2(err, KErrNone);
       
   598 	TEST(results.Count() == expectedCount);
       
   599 
       
   600 	CleanupStack::PopAndDestroy(&results);
       
   601 
       
   602 	PrintStats(start, end);
       
   603 	}
       
   604 
       
   605 ///////////////////////////////////////////////////////////////////////////////////////
       
   606 ///////////////////////////////////////////////////////////////////////////////////////
       
   607 
       
   608 // TEST CASES
       
   609 
       
   610 /**
       
   611 @SYMTestCaseID			PDS-CENTRALREPOSITORY-UT-4047
       
   612 @SYMTestCaseDesc		CRepository::Get(TUint32 aKey, TInt& aValue) - performance test
       
   613 						The test measures the time needed for retrieving of a single integer setting.
       
   614 @SYMTestPriority		High
       
   615 @SYMTestActions			CRepository::Get(TUint32 aKey, TInt& aValue) - performance test
       
   616 @SYMTestExpectedResults Test must not fail
       
   617 @SYMDEF					DEF128986
       
   618 */
       
   619 void GetIntTest()
       
   620 	{
       
   621 	DoGetTest(EIntVal);
       
   622 	}
       
   623 
       
   624 
       
   625 /**
       
   626 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4087
       
   627 @SYMTestCaseDesc		CRepository::Get(TUint32 aKey, TReal& aValue) - performance test
       
   628 						The test measures the time needed for retrieving of a single real setting,
       
   629 						witht the Get() wrapped in a read-mode transaction.
       
   630 @SYMTestPriority		High
       
   631 @SYMTestActions			CRepository::Get(TUint32 aKey, TReal& aValue)
       
   632 @SYMTestExpectedResults Test must not fail
       
   633 @SYMPREQ				PREQ2505
       
   634 @SYMREQ					REQ13142
       
   635 */
       
   636 void GetRealTest()
       
   637 	{
       
   638 	DoGetTest(ERealVal, ETrue);
       
   639 	}
       
   640 
       
   641 
       
   642 /**
       
   643 @SYMTestCaseID			PDS-CENTRALREPOSITORY-UT-4048
       
   644 @SYMTestCaseDesc		CRepository::Get(TUint32 aKey, TDes8& aValue) - performance test
       
   645 						The test measures the time needed for retrieving of a single 8-bit string setting.
       
   646 @SYMTestPriority		High
       
   647 @SYMTestActions			CRepository::Get(TUint32 aKey, TDes8& aValue) - performance test
       
   648 @SYMTestExpectedResults Test must not fail
       
   649 @SYMDEF					DEF128986
       
   650 */
       
   651 void GetBinaryTest()
       
   652 	{
       
   653 	DoGetTest(EBinaryVal);
       
   654 	}
       
   655 
       
   656 
       
   657 /**
       
   658 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4088
       
   659 @SYMTestCaseDesc		CRepository::Get(TUint32 aKey, TDes8& aValue) - performance test
       
   660 						The test measures the time needed for retrieving of a single 8-bit string setting,
       
   661 						with the Get() wrapped in a read-mode transaction.
       
   662 @SYMTestPriority		High
       
   663 @SYMTestActions			CRepository::Get(TUint32 aKey, TDes8& aValue)
       
   664 						CRepository::StartTransaction(TTransactionMode aMode)
       
   665 						CRepository::CommitTransaction(TUint32 &aKeyInfo)
       
   666 @SYMTestExpectedResults Test must not fail
       
   667 @SYMPREQ				PREQ2505
       
   668 @SYMREQ					REQ13142
       
   669 */
       
   670 void GetBinaryInTransactionTest()
       
   671 	{
       
   672 	DoGetTest(EBinaryVal, ETrue);
       
   673 	}
       
   674 
       
   675 
       
   676 /**
       
   677 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4089
       
   678 @SYMTestCaseDesc		CRepository::Get(TUint32 aKey, TDesC16& aValue) - performance test
       
   679 						The test measures the time needed for retrieving of a single 16-bit string setting.
       
   680 @SYMTestPriority		High
       
   681 @SYMTestActions			CRepository::Get(TUint32 aKey, TDesC16& aValue)
       
   682 @SYMTestExpectedResults Test must not fail
       
   683 @SYMPREQ				PREQ2505
       
   684 @SYMREQ					REQ13142
       
   685 */
       
   686 void GetStringTest()
       
   687 	{
       
   688 	DoGetTest(EStringVal, ETrue);
       
   689 	}
       
   690 
       
   691 
       
   692 /**
       
   693 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4090
       
   694 @SYMTestCaseDesc		CRepository::GetMeta(TUint32 aKey, TUint32& aMeta) - performance test
       
   695 						The test measures the time needed for retrieving metadata for a single setting.
       
   696 @SYMTestPriority		High
       
   697 @SYMTestActions			CRepository::GetMeta(TUint32 aKey, TUint32& aMeta)
       
   698 @SYMTestExpectedResults Test must not fail
       
   699 @SYMPREQ				PREQ2505
       
   700 @SYMREQ					REQ13142
       
   701 */
       
   702 void GetMetaTest()
       
   703 	{
       
   704 	DoGetTest(EMetaVal, ETrue);
       
   705 	}
       
   706 
       
   707 
       
   708 /**
       
   709 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4091
       
   710 @SYMTestCaseDesc		CRepository::Set(TUint32 aKey, TInt aValue) - performance test
       
   711 						The test measures the time needed for setting a single integer setting.
       
   712 @SYMTestPriority		High
       
   713 @SYMTestActions			CRepository::Set(TUint32 aKey, TInt aValue)
       
   714 @SYMTestExpectedResults Test must not fail
       
   715 @SYMPREQ				PREQ2505
       
   716 @SYMREQ					REQ13142
       
   717 */
       
   718 void SetIntTest()
       
   719 	{
       
   720 	DoSetResetTest(EIntVal, ESetTest);
       
   721 	}
       
   722 
       
   723 
       
   724 /**
       
   725 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4092
       
   726 @SYMTestCaseDesc		CRepository::Set(TUint32 aKey, TReal aValue) - performance test
       
   727 						The test measures the time needed for setting a single real setting.
       
   728 @SYMTestPriority		High
       
   729 @SYMTestActions			CRepository::Set(TUint32 aKey, TReal aValue)
       
   730 @SYMTestExpectedResults Test must not fail
       
   731 @SYMPREQ				PREQ2505
       
   732 @SYMREQ					REQ13142
       
   733 */
       
   734 void SetRealTest()
       
   735 	{
       
   736 	DoSetResetTest(ERealVal, ESetTest);
       
   737 	}
       
   738 
       
   739 	
       
   740 /**
       
   741 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4093
       
   742 @SYMTestCaseDesc		CRepository::Set(TUint32 aKey, TDes8& aValue) - performance test
       
   743 						The test measures the time needed for setting a single 8-bit string setting.
       
   744 @SYMTestPriority		High
       
   745 @SYMTestActions			CRepository::Set(TUint32 aKey, TDes8& aValue)
       
   746 @SYMTestExpectedResults Test must not fail
       
   747 @SYMPREQ				PREQ2505
       
   748 @SYMREQ					REQ13142
       
   749 */
       
   750 void SetBinaryTest()
       
   751 	{
       
   752 	DoSetResetTest(EBinaryVal, ESetTest);
       
   753 	}
       
   754 
       
   755 
       
   756 /**
       
   757 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4094
       
   758 @SYMTestCaseDesc		CRepository::Set(TUint32 aKey, TDesC16& aValue) - performance test
       
   759 						The test measures the time needed for setting a single 16-bit string setting.
       
   760 @SYMTestPriority		High
       
   761 @SYMTestActions			CRepository::Set(TUint32 aKey, TDesC16& aValue)
       
   762 @SYMTestExpectedResults Test must not fail
       
   763 @SYMPREQ				PREQ2505
       
   764 @SYMREQ					REQ13142
       
   765 */
       
   766 void SetStringTest()
       
   767 	{
       
   768 	DoSetResetTest(EStringVal, ESetTest);
       
   769 	}
       
   770 
       
   771 
       
   772 /**
       
   773 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4095
       
   774 @SYMTestCaseDesc		CRepository::Create(TUint32 aKey, TInt aValue) - performance test
       
   775 						The test measures the time needed for creating a new single integer setting.
       
   776 @SYMTestPriority		High
       
   777 @SYMTestActions			CRepository::Create(TUint32 aKey, TInt aValue)
       
   778 @SYMTestExpectedResults Test must not fail
       
   779 @SYMPREQ				PREQ2505
       
   780 @SYMREQ					REQ13142
       
   781 */
       
   782 void CreateIntTest()
       
   783 	{
       
   784 	DoCreateTest(EIntVal);
       
   785 	}
       
   786 
       
   787 
       
   788 /**
       
   789 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4096
       
   790 @SYMTestCaseDesc		CRepository::Create(TUint32 aKey, TReal aValue) - performance test
       
   791 						The test measures the time needed for creating a new single real setting.
       
   792 @SYMTestPriority		High
       
   793 @SYMTestActions			CRepository::Create(TUint32 aKey, TReal aValue)
       
   794 @SYMTestExpectedResults Test must not fail
       
   795 @SYMPREQ				PREQ2505
       
   796 @SYMREQ					REQ13142
       
   797 */
       
   798 void CreateRealTest()
       
   799 	{
       
   800 	DoCreateTest(ERealVal);
       
   801 	}
       
   802 
       
   803 
       
   804 /**
       
   805 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4097
       
   806 @SYMTestCaseDesc		CRepository::Create(TUint32 aKey, TDesC8& aValue) - performance test
       
   807 						The test measures the time needed for creating a new single 8-bit string setting.
       
   808 @SYMTestPriority		High
       
   809 @SYMTestActions			CRepository::Create(TUint32 aKey, TDesC8& aValue)
       
   810 @SYMTestExpectedResults Test must not fail
       
   811 @SYMPREQ				PREQ2505
       
   812 @SYMREQ					REQ13142
       
   813 */
       
   814 void CreateBinaryTest()
       
   815 	{
       
   816 	DoCreateTest(EBinaryVal);
       
   817 	}
       
   818 
       
   819 
       
   820 /**
       
   821 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4098
       
   822 @SYMTestCaseDesc		CRepository::Create(TUint32 aKey, TDesC16& aValue) - performance test
       
   823 						The test measures the time needed for creating a new single 16-bit string setting.
       
   824 @SYMTestPriority		High
       
   825 @SYMTestActions			CRepository::Create(TUint32 aKey, TDesC16& aValue)
       
   826 @SYMTestExpectedResults Test must not fail
       
   827 @SYMPREQ				PREQ2505
       
   828 @SYMREQ					REQ13142
       
   829 */
       
   830 void CreateStringTest()
       
   831 	{
       
   832 	DoCreateTest(EStringVal);
       
   833 	}
       
   834 
       
   835 
       
   836 /**
       
   837 @SYMTestCaseID			PDS-CENTRALREPOSITORY-UT-4049
       
   838 @SYMTestCaseDesc		CRepository::FindL(TUint32 aPartialKey, TUint32 aMask, RArray<TUint32>& aFoundKeys) - performance test
       
   839 						The test measures the time needed for retrieving of an array of keys matching the function arguments.
       
   840 @SYMTestPriority		High
       
   841 @SYMTestActions			CRepository::FindL(TUint32 aPartialKey, TUint32 aMask, RArray<TUint32>& aFoundKeys)
       
   842 @SYMTestExpectedResults Test must not fail
       
   843 @SYMDEF					DEF128986
       
   844 */
       
   845 void FindTestL()
       
   846 	{
       
   847 	TInt start(0);
       
   848 	TInt end(0);
       
   849 	TInt found(0);
       
   850 	
       
   851 	TInt err = FindRangeL(start, end, found);
       
   852 		
       
   853 	TEST2(err, KErrNone);
       
   854 	TEST2(found, KFindKeyCount);
       
   855 
       
   856 	PrintStats(start, end);
       
   857 	}
       
   858 
       
   859 
       
   860 /**
       
   861 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4099
       
   862 @SYMTestCaseDesc		CRepository::FindEqL(TUint32 aPartialKey, TUint32 aMask, TInt aValue, RArray< TUint32 > &aFoundKeys) - performance test
       
   863 						The test measures the time to find an int setting in an "equals" search on a range.
       
   864 @SYMTestPriority		High
       
   865 @SYMTestActions			CRepository::FindEqL(TUint32 aPartialKey, TUint32 aMask, TInt aValue, RArray< TUint32 > &aFoundKeys)
       
   866 @SYMTestExpectedResults Test must not fail
       
   867 @SYMPREQ				PREQ2505
       
   868 @SYMREQ					REQ13142
       
   869 */
       
   870 void FindEqIntTestL()
       
   871 	{
       
   872 	DoFindEqNeqTestL(EIntVal, EFindEqTest);
       
   873 	}
       
   874 
       
   875 
       
   876 /**
       
   877 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4100
       
   878 @SYMTestCaseDesc		CRepository::FindEqL(TUint32 aPartialKey, TUint32 aMask, TReal aValue, RArray< TUint32 > &aFoundKeys) - performance test
       
   879 						The test measures the time to find a real setting in an "equals" search on a range.
       
   880 @SYMTestPriority		High
       
   881 @SYMTestActions			CRepository::FindEqL(TUint32 aPartialKey, TUint32 aMask, TReal aValue, RArray< TUint32 > &aFoundKeys)
       
   882 @SYMTestExpectedResults Test must not fail
       
   883 @SYMPREQ				PREQ2505
       
   884 @SYMREQ					REQ13142
       
   885 */
       
   886 void FindEqRealTestL()
       
   887 	{
       
   888 	DoFindEqNeqTestL(ERealVal, EFindEqTest);
       
   889 	}
       
   890 
       
   891 
       
   892 /**
       
   893 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4101
       
   894 @SYMTestCaseDesc		CRepository::FindEqL(TUint32 aPartialKey, TUint32 aMask, TDesC8& aValue, RArray< TUint32 > &aFoundKeys) - performance test
       
   895 						The test measures the time to find an 8-bit string setting in an "equals" search on a range.
       
   896 @SYMTestPriority		High
       
   897 @SYMTestActions			CRepository::FindEqL(TUint32 aPartialKey, TUint32 aMask, TDesC8& aValue, RArray< TUint32 > &aFoundKeys)
       
   898 @SYMTestExpectedResults Test must not fail
       
   899 @SYMPREQ				PREQ2505
       
   900 @SYMREQ					REQ13142
       
   901 */
       
   902 void FindEqBinaryTestL()
       
   903 	{
       
   904 	DoFindEqNeqTestL(EBinaryVal, EFindEqTest);
       
   905 	}
       
   906 
       
   907 
       
   908 /**
       
   909 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4102
       
   910 @SYMTestCaseDesc		CRepository::FindEqL(TUint32 aPartialKey, TUint32 aMask, TDesC16& aValue, RArray< TUint32 > &aFoundKeys) - performance test
       
   911 						The test measures the time to find an 16-bit string setting in an "equals" search on a range.
       
   912 @SYMTestPriority		High
       
   913 @SYMTestActions			CRepository::FindEqL(TUint32 aPartialKey, TUint32 aMask, TDesC16& aValue, RArray< TUint32 > &aFoundKeys)
       
   914 @SYMTestExpectedResults Test must not fail
       
   915 @SYMPREQ				PREQ2505
       
   916 @SYMREQ					REQ13142
       
   917 */
       
   918 void FindEqStringTestL()
       
   919 	{
       
   920 	DoFindEqNeqTestL(EStringVal, EFindEqTest);
       
   921 	}
       
   922 
       
   923 
       
   924 /**
       
   925 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4103
       
   926 @SYMTestCaseDesc		CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask, TInt aValue, RArray< TUint32 > &aFoundKeys) - performance test
       
   927 						The test measures the time to find an int setting in an "not equals" search on a range.
       
   928 @SYMTestPriority		High
       
   929 @SYMTestActions			CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask, TInt aValue, RArray< TUint32 > &aFoundKeys)
       
   930 @SYMTestExpectedResults Test must not fail
       
   931 @SYMPREQ				PREQ2505
       
   932 @SYMREQ					REQ13142
       
   933 */
       
   934 void FindNeqIntTestL()
       
   935 	{
       
   936 	DoFindEqNeqTestL(EIntVal, EFindNeqTest);
       
   937 	}
       
   938 
       
   939 
       
   940 /**
       
   941 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4104
       
   942 @SYMTestCaseDesc		CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask, TReal aValue, RArray< TUint32 > &aFoundKeys) - performance test
       
   943 						The test measures the time to find a real setting in an "not equals" search on a range.
       
   944 @SYMTestPriority		High
       
   945 @SYMTestActions			CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask, TReal aValue, RArray< TUint32 > &aFoundKeys)
       
   946 @SYMTestExpectedResults Test must not fail
       
   947 @SYMPREQ				PREQ2505
       
   948 @SYMREQ					REQ13142
       
   949 */
       
   950 void FindNeqRealTestL()
       
   951 	{
       
   952 	DoFindEqNeqTestL(ERealVal, EFindNeqTest);
       
   953 	}
       
   954 
       
   955 
       
   956 /**
       
   957 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4105
       
   958 @SYMTestCaseDesc		CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask, TDesC8& aValue, RArray< TUint32 > &aFoundKeys) - performance test
       
   959 						The test measures the time to find an 8-bit string setting in an "not equals" search on a range.
       
   960 @SYMTestPriority		High
       
   961 @SYMTestActions			CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask, TDesC8& aValue, RArray< TUint32 > &aFoundKeys)
       
   962 @SYMTestExpectedResults Test must not fail
       
   963 @SYMPREQ				PREQ2505
       
   964 @SYMREQ					REQ13142
       
   965 */
       
   966 void FindNeqBinaryTestL()
       
   967 	{
       
   968 	DoFindEqNeqTestL(EBinaryVal, EFindNeqTest);
       
   969 	}
       
   970 
       
   971 
       
   972 /**
       
   973 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4106
       
   974 @SYMTestCaseDesc		CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask, TDesC16& aValue, RArray< TUint32 > &aFoundKeys) - performance test
       
   975 						The test measures the time to find an 16-bit string setting in an "not equals" search on a range.
       
   976 @SYMTestPriority		High
       
   977 @SYMTestActions			CRepository::FindNeqL(TUint32 aPartialKey, TUint32 aMask, TDesC16& aValue, RArray< TUint32 > &aFoundKeys)
       
   978 @SYMTestExpectedResults Test must not fail
       
   979 @SYMPREQ				PREQ2505
       
   980 @SYMREQ					REQ13142
       
   981 */
       
   982 void FindNeqStringTestL()
       
   983 	{
       
   984 	DoFindEqNeqTestL(EStringVal, EFindNeqTest);
       
   985 	}
       
   986 
       
   987 
       
   988 /**
       
   989 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4107
       
   990 @SYMTestCaseDesc		Performance test that measures the time taken to retrieve data to rebuild a table of ints with 22 rows 
       
   991 						and 8 columns, using successive calls of Find() with subsequent calls to Get for each key retrieved.
       
   992 @SYMTestPriority		High
       
   993 @SYMTestActions			CRepository::FindL(TUint32 aPartialKey, TUint32 aMask, RArray<TUint32>& aFoundKeys)
       
   994 						CRepository::Get(TUint32 aPartialKey, TUint32 aMask, RArray<TUint32>& aFoundKeys)
       
   995 @SYMTestExpectedResults Test must not fail
       
   996 @SYMPREQ				PREQ2505
       
   997 @SYMREQ					REQ13142
       
   998 */
       
   999 void RetrieveTableTestL()
       
  1000 	{
       
  1001 	TUint32 partialKeyData[] = {
       
  1002 		0x03950000, 0x03980000, 0x039A0000, 0x039E0000, 0x03A80000, 0x03A90000,
       
  1003 		0x03AA0000, 0x03AB0000, 0x03B50000, 0x03B60000, 0x03B70000, 0x03B80000,
       
  1004 		0x03B90000, 0x03BA0000, 0x03BB0000, 0x03BC0000, 0x03BD0000, 0x03BE0000,
       
  1005 		0x03BF0000, 0x03C00000, 0x03C10000, 0x03C20000
       
  1006 		};
       
  1007 	const TInt KNumRows(22); // same as number of partialKeys in array above
       
  1008 	const TInt KNumCols(8); // expected number of columns per row
       
  1009 	const TUint32 KMask(0xFFFF0000); // match top 2 bytes
       
  1010 
       
  1011 	RArray<TUint32> rowKeys(KNumCols); // set granularity to num cols
       
  1012 	CleanupClosePushL(rowKeys);
       
  1013 	
       
  1014 	TUint32 start = User::FastCounter();
       
  1015 
       
  1016 	for (TInt i(0); i < KNumRows; ++i)
       
  1017 		{
       
  1018 		// fetch all keys representing columns/cells in the row 
       
  1019 		// matching the key range defined by the partial key
       
  1020 		TInt findErr = TheRepository->FindL(partialKeyData[i], KMask, rowKeys);
       
  1021 		TEST2(findErr, KErrNone);
       
  1022 		
       
  1023 		const TInt KColCount = rowKeys.Count();
       
  1024 		TEST(KColCount == KNumCols);
       
  1025 		
       
  1026 		// retrieve data for each column/cell represented 
       
  1027 		// by a key from the row key range 
       
  1028 		TInt value(KErrNotFound);
       
  1029 		for (TInt j(0); j < KColCount; ++j)
       
  1030 			{
       
  1031 			TInt getErr = TheRepository->Get(rowKeys[j], value);
       
  1032 			TEST2(getErr, KErrNone);
       
  1033 			
       
  1034 			// data for these cells are 0 or 1
       
  1035 			TEST(value == 0 || value == 1);
       
  1036 			}
       
  1037 
       
  1038 		// clear our keys array for next row
       
  1039 		rowKeys.Reset();
       
  1040 		}
       
  1041 
       
  1042 	TUint32 end = User::FastCounter();
       
  1043 	PrintStats(start, end);
       
  1044 
       
  1045 	CleanupStack::PopAndDestroy(&rowKeys);
       
  1046 	}
       
  1047 
       
  1048 
       
  1049 /**
       
  1050 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4108
       
  1051 @SYMTestCaseDesc		CRepository::Move(TUint32 aSourcePartialKey, TUint32 aTargetPartialKey, TUint32 aMask, TUint32 &aErrorKey) - performance test
       
  1052 						The test measures the time needed for moving a single integer setting.
       
  1053 @SYMTestPriority		High
       
  1054 @SYMTestActions			CRepository::Move(TUint32 aSourcePartialKey, TUint32 aTargetPartialKey, TUint32 aMask, TUint32 &aErrorKey)
       
  1055 @SYMTestExpectedResults Test must not fail
       
  1056 @SYMPREQ				PREQ2505
       
  1057 @SYMREQ					REQ13142
       
  1058 */
       
  1059 void MoveTest()
       
  1060 	{
       
  1061 	TUint32 errorKey(0);
       
  1062 	
       
  1063 	// Move a setting to a new key
       
  1064 	TUint32 start = User::FastCounter();
       
  1065 	TInt err = TheRepository->Move(KNewIntKey, KNewIntKey2, 0xFFFFFFFF, errorKey);
       
  1066 	TUint32 end = User::FastCounter();
       
  1067 	TEST2(err, KErrNone);
       
  1068 
       
  1069 	// Test we get the right value from the new location
       
  1070 	TInt val(0);
       
  1071 	err = TheRepository->Get(KNewIntKey2, val);
       
  1072 	TEST2(err, KErrNone);
       
  1073 	TEST2(val, KNewIntVal);
       
  1074 
       
  1075 	// Test we get the KErrNotFound from the old location
       
  1076 	err = TheRepository->Get(KNewIntKey, val);
       
  1077 	TEST2(err, KErrNotFound);
       
  1078 	
       
  1079 	PrintStats(start, end);
       
  1080 	}
       
  1081 
       
  1082 
       
  1083 /**
       
  1084 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4109
       
  1085 @SYMTestCaseDesc		CRepository::Delete(TUint32 aKey) - performance test
       
  1086 						The test measures the time needed for deleting a single setting.
       
  1087 @SYMTestPriority		High
       
  1088 @SYMTestActions			CRepository::Delete(TUint32 aKey)
       
  1089 @SYMTestExpectedResults Test must not fail
       
  1090 @SYMPREQ				PREQ2505
       
  1091 @SYMREQ					REQ13142
       
  1092 */
       
  1093 void DeleteTest()
       
  1094 	{
       
  1095 	// Test the setting is there and we get the right value 
       
  1096 	TInt val(0);
       
  1097 	TInt err = TheRepository->Get(KNewIntKey2, val);
       
  1098 	TEST2(err, KErrNone);
       
  1099 	TEST2(val, KNewIntVal);
       
  1100 
       
  1101 	// Delete the setting
       
  1102 	TUint32 start = User::FastCounter();
       
  1103 	err = TheRepository->Delete(KNewIntKey2);
       
  1104 	TUint32 end = User::FastCounter();
       
  1105 	TEST2(err, KErrNone);
       
  1106 
       
  1107 	// Test we get the KErrNotFound from the key now
       
  1108 	err = TheRepository->Get(KNewIntKey2, val);
       
  1109 	TEST2(err, KErrNotFound);
       
  1110 	
       
  1111 	PrintStats(start, end);
       
  1112 	}
       
  1113 
       
  1114 /**
       
  1115 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4110
       
  1116 @SYMTestCaseDesc		CRepository::Delete(TUint32 aKey) - performance test
       
  1117 						The test measures the time needed for deleting a single setting.
       
  1118 @SYMTestPriority		High
       
  1119 @SYMTestActions			CRepository::Delete(TUint32 aKey)
       
  1120 @SYMTestExpectedResults Test must not fail
       
  1121 @SYMPREQ				PREQ2505
       
  1122 @SYMREQ					REQ13142
       
  1123 */
       
  1124 void DeleteRangeTestL()
       
  1125 	{
       
  1126 	TInt start(0);
       
  1127 	TInt end(0);
       
  1128 	TInt found(0);
       
  1129 	
       
  1130 	// Check we can find the settings in the range
       
  1131 	// (ignore timing data here as we're not timing find)
       
  1132 	TInt err = FindRangeL(start, end, found);
       
  1133 	TEST2(err, KErrNone);
       
  1134 	TEST2(found, KFindKeyCount);
       
  1135 
       
  1136 	// Delete the setting
       
  1137 	TUint32 errorKey(0);
       
  1138 	start = User::FastCounter();
       
  1139 	err = TheRepository->Delete(KFindPartialKey, KFindMask, errorKey);
       
  1140 	end = User::FastCounter();
       
  1141 	TEST2(err, KErrNone);
       
  1142 
       
  1143 	// Check we *can't* find the settings in the range now they've been deleted
       
  1144 	err = FindRangeL(start, end, found);
       
  1145 	TEST2(err, KErrNotFound);
       
  1146 	
       
  1147 	PrintStats(start, end);
       
  1148 	}
       
  1149 
       
  1150 
       
  1151 /**
       
  1152 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4111
       
  1153 @SYMTestCaseDesc		CRepository::Reset(TUint32 aKey) - performance test
       
  1154 						The test measures the time needed for resetting a single integer setting.
       
  1155 @SYMTestPriority		High
       
  1156 @SYMTestActions			CRepository::Reset(TUint32 aKey)
       
  1157 @SYMTestExpectedResults Test must not fail
       
  1158 @SYMPREQ				PREQ2505
       
  1159 @SYMREQ					REQ13142
       
  1160 */
       
  1161 void ResetTest()
       
  1162 	{
       
  1163 	DoSetResetTest(EIntVal, EResetTest);
       
  1164 	}
       
  1165 
       
  1166 
       
  1167 /**
       
  1168 @SYMTestCaseID			PDS-CENTRALREPOSITORY-CT-4112
       
  1169 @SYMTestCaseDesc		CRepository::Reset() - performance test
       
  1170 						The test measures the time needed for resetting the whole keyspace.
       
  1171 @SYMTestPriority		High
       
  1172 @SYMTestActions			CRepository::Reset()
       
  1173 @SYMTestExpectedResults Test must not fail
       
  1174 @SYMPREQ				PREQ2505
       
  1175 @SYMREQ					REQ13142
       
  1176 */
       
  1177 void ResetAllTest()
       
  1178 	{
       
  1179 	// Check we can get the value of the newly created binary setting
       
  1180 	TBool result;
       
  1181 	TInt err = GetNewVal(EBinaryVal, ECreateTest, result);
       
  1182 	TEST2(err, KErrNone);
       
  1183 	TEST(result);
       
  1184 	
       
  1185 	// Reset the whole keyspace
       
  1186 	TInt start = User::FastCounter();
       
  1187 	TheRepository->Reset();
       
  1188 	TInt end = User::FastCounter();
       
  1189 	TEST2(err, KErrNone);
       
  1190 
       
  1191 	// Check we *can't* get the value of the newly created binary setting
       
  1192 	// since it shouldn't exist anymore after the Reset()
       
  1193 	err = GetNewVal(EBinaryVal, ECreateTest, result);
       
  1194 	TEST2(err, KErrNotFound);
       
  1195 	PrintStats(start, end);
       
  1196 	}
       
  1197 
       
  1198 ///////////////////////////////////////////////////////////////////////////////////////
       
  1199 
       
  1200 // MAIN
       
  1201 
       
  1202 void DoTestsL()
       
  1203 	{
       
  1204 	TheTest.Start(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-UT-4047 Get Int test"));
       
  1205 	GetIntTest();
       
  1206 
       
  1207 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4087 Get Real test"));
       
  1208 	GetRealTest();
       
  1209 
       
  1210 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-UT-4048 Get Binary test"));
       
  1211 	GetBinaryTest();
       
  1212 
       
  1213 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4088 Get Binary in Transaction test"));
       
  1214 	GetBinaryInTransactionTest();
       
  1215 
       
  1216 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4089 Get String test"));
       
  1217 	GetStringTest();
       
  1218 
       
  1219 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4090 GetMeta test"));
       
  1220 	GetMetaTest();
       
  1221 
       
  1222 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4091 Set Int test"));
       
  1223 	SetIntTest();
       
  1224 
       
  1225 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4092 Set Real test"));
       
  1226 	SetRealTest();
       
  1227 
       
  1228 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4093 Set Binary test"));
       
  1229 	SetBinaryTest();
       
  1230 
       
  1231 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4094 Set String test"));
       
  1232 	SetStringTest();
       
  1233 
       
  1234 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4095 Create Int setting test"));
       
  1235 	CreateIntTest();
       
  1236 
       
  1237 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4096 Create Real setting test"));
       
  1238 	CreateRealTest();
       
  1239 
       
  1240 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4097 Create Binary setting test"));
       
  1241 	CreateBinaryTest();
       
  1242 
       
  1243 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4098 Create String setting test"));
       
  1244 	CreateStringTest();
       
  1245 
       
  1246 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-UT-4049 Find test"));
       
  1247 	FindTestL();
       
  1248 
       
  1249 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4099 FindEq Int test"));
       
  1250 	FindEqIntTestL();
       
  1251 
       
  1252 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4100 FindEq Real test"));
       
  1253 	FindEqRealTestL();
       
  1254 
       
  1255 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4101 FindEq Binary test"));
       
  1256 	FindEqBinaryTestL();
       
  1257 
       
  1258 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4102 FindEq String test"));
       
  1259 	FindEqStringTestL();
       
  1260 
       
  1261 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4103 FindNeq Int test"));
       
  1262 	FindNeqIntTestL();
       
  1263 
       
  1264 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4104 FindNeq Real test"));
       
  1265 	FindNeqRealTestL();
       
  1266 
       
  1267 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4105 FindNeq Binary test"));
       
  1268 	FindNeqBinaryTestL();
       
  1269 
       
  1270 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4106 FindNeq String test"));
       
  1271 	FindNeqStringTestL();
       
  1272 
       
  1273 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4107 Retrieve structured data table test"));
       
  1274 	RetrieveTableTestL();
       
  1275 
       
  1276 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4108 Move test"));
       
  1277 	MoveTest();
       
  1278 
       
  1279 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4109 Delete test"));
       
  1280 	DeleteTest();
       
  1281 
       
  1282 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4110 Delete test"));
       
  1283 	DeleteRangeTestL();
       
  1284 
       
  1285 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4111 Reset Single test"));
       
  1286 	ResetTest();
       
  1287 
       
  1288 	TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4112 Reset All test"));
       
  1289 	ResetAllTest();
       
  1290 	}
       
  1291 
       
  1292 
       
  1293 TInt E32Main()
       
  1294 	{
       
  1295 	TheTest.Title();
       
  1296 	
       
  1297 	CTrapCleanup* tc = CTrapCleanup::New();
       
  1298 	TheTest(tc != NULL);
       
  1299 	
       
  1300 	__UHEAP_MARK;
       
  1301 	
       
  1302 	TRAPD(err, CreateTestEnvL());
       
  1303 	TEST2(err, KErrNone);
       
  1304 
       
  1305 	TRAP(err, DoTestsL());
       
  1306 	DestroyTestEnv();
       
  1307 	TEST2(err, KErrNone);
       
  1308 	
       
  1309 	__UHEAP_MARKEND;
       
  1310 	
       
  1311 	TheTest.End();
       
  1312 	TheTest.Close();
       
  1313 	
       
  1314 	delete tc;
       
  1315 	
       
  1316 	User::Heap().Check();
       
  1317 	return KErrNone;
       
  1318 	}