persistentstorage/centralrepository/test/t_cenrep.cpp
branchRCL_3
changeset 11 667e88a979d7
parent 0 08ec8eefde2f
child 55 44f437012c90
equal deleted inserted replaced
10:fa9941cf3867 11:667e88a979d7
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    35 const TUid KUidResetTestRepository = { 0x00000004 };
    35 const TUid KUidResetTestRepository = { 0x00000004 };
    36 
    36 
    37 const TUid KUidDriveCRepository = { 0x00000010 };
    37 const TUid KUidDriveCRepository = { 0x00000010 };
    38 
    38 
    39 const TUid KUidDriveCOnlyRepository = { 0x00000013 };
    39 const TUid KUidDriveCOnlyRepository = { 0x00000013 };
       
    40 
       
    41 const TUid KUidTestRepository3 = { 0x00000103 };
    40 
    42 
    41 //
    43 //
    42 // Test repository 1
    44 // Test repository 1
    43 //
    45 //
    44 
    46 
  2237 	TEST2(r, KErrNone);
  2239 	TEST2(r, KErrNone);
  2238 	TEST(i==1);
  2240 	TEST(i==1);
  2239 
  2241 
  2240 	CleanupStack::PopAndDestroy();
  2242 	CleanupStack::PopAndDestroy();
  2241 	}
  2243 	}
       
  2244 
       
  2245 /**
       
  2246 @SYMTestCaseID          PDS-CENTRALREPOSITORY-CT-4113
       
  2247 @SYMTestCaseDesc        Validates meta data is not lost before a transaction is committed
       
  2248                         when deleting a range of settings.
       
  2249 @SYMTestPriority        High
       
  2250 @SYMTestActions         1) Start a transaction.
       
  2251                         2) Delete a setting using the delete range function.
       
  2252                         3) Create a new setting (using the deleted key)
       
  2253                         4) Commit the transaction.
       
  2254                         5) Check the metadata of the setting.                     
       
  2255 @SYMTestExpectedResults When deleting a range of settings in a keyspace, and then 
       
  2256                         creating a new setting (with a key of a previously deleted setting)
       
  2257                         the meta data should not be reset to 0, it should take on the default
       
  2258                         metadata, if it exists.
       
  2259 @SYMDEF                 DEF144530
       
  2260 */
       
  2261 LOCAL_C void RangeDeleteMetaL()
       
  2262     {
       
  2263     TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4113 "));
       
  2264 
       
  2265     TUint32 partialKey   = 0x0000004;
       
  2266     TUint32 mask         = 0xFFFFFFF;
       
  2267     TUint32 meta = 0;
       
  2268     TUint32 expectedMeta = 0x10; // 16 
       
  2269     TUint32 keyCount = 0;
       
  2270     TUint32 expectedKeyCount = 1;
       
  2271     TUint32 error;
       
  2272 
       
  2273     CRepository* repository;
       
  2274     User::LeaveIfNull(repository = CRepository::NewL(KUidTestRepository3)); // 00000103.txt
       
  2275     
       
  2276     repository->StartTransaction(CRepository::EReadWriteTransaction);
       
  2277 
       
  2278     // Only want to delete 1 specific key, using the range delete function.
       
  2279     TInt ret = repository->Delete(partialKey, mask, error);
       
  2280     // We don't care about 'error' if 'ret==KErrNone'.
       
  2281     TEST2(ret, KErrNone);  
       
  2282     
       
  2283     // Create a new setting that is the same key and type as the deleted one.
       
  2284     ret = repository->Create(partialKey, 200); 
       
  2285     TEST2(ret, KErrNone);
       
  2286     
       
  2287     ret = repository->CommitTransaction(keyCount);
       
  2288     TEST2(ret, KErrNone);
       
  2289     // Confirm only 1 setting was updated.
       
  2290     TEST2(keyCount, expectedKeyCount);
       
  2291     
       
  2292     // Check the meta data of the newly created setting. It should be the 
       
  2293     // the same as the defaultmeta value in the keyspace.
       
  2294     ret = repository->GetMeta(partialKey, meta);
       
  2295     TEST2(ret, KErrNone);
       
  2296     TEST2(meta, expectedMeta);
       
  2297     
       
  2298     delete repository;
       
  2299     }
       
  2300 
       
  2301 
  2242 /**
  2302 /**
  2243 @SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-CT-0494
  2303 @SYMTestCaseID			SYSLIB-CENTRALREPOSITORY-CT-0494
  2244 @SYMTestCaseDesc		Tests the various functions on CentralRepository
  2304 @SYMTestCaseDesc		Tests the various functions on CentralRepository
  2245 @SYMTestPriority		High
  2305 @SYMTestPriority		High
  2246 @SYMTestActions			Tests the get/set,find,notify,create/delete,
  2306 @SYMTestActions			Tests the get/set,find,notify,create/delete,
  2290 	TheTest.Next(_L("Negative testing for the notification cancelling"));
  2350 	TheTest.Next(_L("Negative testing for the notification cancelling"));
  2291 	CancelNotificationsL();
  2351 	CancelNotificationsL();
  2292 
  2352 
  2293 	TheTest.Next(_L("Notify-only client optimizations"));
  2353 	TheTest.Next(_L("Notify-only client optimizations"));
  2294 	NotifyOnlyL();
  2354 	NotifyOnlyL();
  2295 
  2355 	
       
  2356 	TheTest.Next(_L("Meta data after a Range Delete in transaction"));
       
  2357     RangeDeleteMetaL();
       
  2358     
  2296 	TheTest.End();
  2359 	TheTest.End();
  2297 	}
  2360 	}
  2298 
  2361 
  2299 /**
  2362 /**
  2300 OomTest
  2363 OomTest