persistentstorage/store/TFILE/t_storfcomp.cpp
changeset 51 7d4490026038
parent 0 08ec8eefde2f
child 55 44f437012c90
equal deleted inserted replaced
40:b8bdbc8f59c7 51:7d4490026038
     1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 1998-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".
   512 		{
   512 		{
   513 		RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
   513 		RDebug::Print(_L("Error %d connecting file session. File: %S.\n"), err, &aFullName);
   514 		}
   514 		}
   515 	}
   515 	}
   516 
   516 
       
   517 class CTestStreamStore : public CStreamStore
       
   518 	{
       
   519 public:
       
   520 	static CTestStreamStore* NewL();
       
   521 	virtual ~CTestStreamStore();
       
   522 
       
   523 private:
       
   524 	CTestStreamStore();
       
   525 	virtual MStreamBuf* DoReadL(TStreamId anId) const;
       
   526 	virtual MStreamBuf* DoCreateL(TStreamId& anId);
       
   527 	
       
   528 	};
       
   529 
       
   530 CTestStreamStore* CTestStreamStore::NewL()
       
   531 	{
       
   532 	return new (ELeave) CTestStreamStore; 
       
   533 	}
       
   534 
       
   535 CTestStreamStore::~CTestStreamStore()
       
   536 	{
       
   537 	}
       
   538 
       
   539 CTestStreamStore::CTestStreamStore()
       
   540 	{
       
   541 	}
       
   542 
       
   543 MStreamBuf* CTestStreamStore::DoReadL(TStreamId) const
       
   544 	{
       
   545 	return NULL;
       
   546 	}
       
   547 
       
   548 MStreamBuf* CTestStreamStore::DoCreateL(TStreamId&)
       
   549 	{
       
   550 	return NULL;
       
   551 	}
       
   552 
       
   553 /**
       
   554 @SYMTestCaseID          PDS-STORE-CT-4063
       
   555 @SYMTestCaseDesc        CStreamStore tests.
       
   556 @SYMTestActions         CStreamStore provides couple of virtual methods in its private section:
       
   557                         DoExtendL(), DoDeleteL(), DoReplaceL(), DoReclaimL().
       
   558                         They are no-ops and are expected to be overriden in the class derived from
       
   559                         CStreamStore. Their implementations leave with KErrNotsupported. 
       
   560                         The test uses a class derived from CStreamStore, which class does not implement
       
   561                         virtuals mentioned above. These virtuals should leave with KErrNotSupported when called.
       
   562 @SYMTestPriority        High
       
   563 @SYMTestExpectedResults Test must not fail
       
   564 */
       
   565 void TestStreamStoreVirtualsL()
       
   566 	{
       
   567 	CTestStreamStore* store = CTestStreamStore::NewL();
       
   568 	TRAPD(err, store->CommitL());
       
   569 	test(err == KErrNone);
       
   570 	TRAP(err, store->RevertL());
       
   571 	test(err == KErrNotSupported);
       
   572 	TRAP(err, store->ReclaimL());
       
   573 	test(err == KErrNotSupported);
       
   574 	TRAP(err, store->CompactL());
       
   575 	test(err == KErrNotSupported);
       
   576 	TRAP(err, store->DeleteL(TStreamId(1)));
       
   577 	test(err == KErrNotSupported);
       
   578 	delete store;
       
   579 	}
       
   580 
       
   581 //
       
   582 // Test permanent file store.
       
   583 //
   517 GLDEF_C TInt E32Main()
   584 GLDEF_C TInt E32Main()
   518 //
       
   519 // Test permanent file store.
       
   520 //
       
   521     {
   585     {
   522 	test.Title();
   586 	test.Title();
   523 	setupTestDirectory();
   587 	setupTestDirectory();
   524 	setupCleanup();
   588 	setupCleanup();
   525 	__UHEAP_MARK;
   589 	__UHEAP_MARK;
   526 //
   590 //
   527 	test.Start(_L("Test compaction"));
   591 	test.Start(_L("Test compaction"));
   528 	TRAPD(r,testCompactL());
   592 	TRAPD(r,testCompactL());
       
   593 	test(r==KErrNone);
       
   594 	test.Next(_L("@SYMTestCaseID:PDS-STORE-CT-4063: Test CStreamStore virtuals"));
       
   595 	TRAP(r, TestStreamStoreVirtualsL())
   529 	test(r==KErrNone);
   596 	test(r==KErrNone);
   530 	
   597 	
   531 	//deletion of data files must be before call to .End() - DEF047652
   598 	//deletion of data files must be before call to .End() - DEF047652
   532 	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
   599 	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
   533 	TParse parse;
   600 	TParse parse;