コード例 #1
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1200
@SYMTestCaseDesc	    Shape streaming test
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for streaming of different shapes
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testShapesL()
    {
	test.Start(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1200 Shape streaming "));

	TParsePtrC parse(KFileLocationSpec);
//
//	TheStore=CDirectFileStore::ReplaceLC(TheFs,KTestFile,EFileRead|EFileWrite);
	TheStore=CPermanentFileStore::ReplaceLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
	TheStore->SetTypeL(TheStore->Layout());
//
	RStoreWriteStream snk;
	TStreamId id=snk.CreateL(*TheStore);
	TShapeHolder hldr(ESquare,new(ELeave) CSquare(TPoint(20,30),40));
	hldr.ExternalizeSerialL(snk);
	delete hldr.Shape();
	hldr=TShapeHolder(ECircle,new(ELeave) CCircle(TPoint(70,80),40));
	hldr.ExternalizeSerialL(snk);
	delete hldr.Shape();
	snk.Close();
	RStoreReadStream src;
	src.OpenL(*TheStore,id);
	hldr.InternalizeSerialL(src);
	delete hldr.Shape();
	hldr.InternalizeSerialL(src);
	delete hldr.Shape();
	src.Close();
//
	hldr=TShapeHolder(ESquare,new(ELeave) CSquare(TPoint(20,30),40));
	id=hldr.StoreL(*TheStore);
	delete hldr.Shape();
	hldr.RestoreL(*TheStore,id);
	delete hldr.Shape();
//
	CShape* shape=new(ELeave) CCircle(TPoint(70,80),40);
	CStoreMap* map=CStoreMap::NewL(*TheStore);
	TStreamId id2 = shape->StoreL(*TheStore);

	testExtraStoreMapAPIsL();
	
	map->BindL(shape,id2);
	snk=RStoreWriteStream(*map);
	id=snk.CreateL(*TheStore);
	snk<<shape;
	snk.Close();
	delete shape;
	src.OpenL(*TheStore,id);
	src>>id;
	src.Close();
	shape=new(ELeave) CCircle;
	shape->RestoreL(*TheStore,id);
	delete map;
	TRAPD(r,shape->RestoreL(*TheStore,id));
	test(r==KErrNotFound);
	delete shape;
//
	CleanupStack::PopAndDestroy();
    }
コード例 #2
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1152
@SYMTestCaseDesc	    Tests empty streams
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for empty stream buffers.Check for end of file error,overflow error flags
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testEmptyL(CStreamStore& aStore)
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1152 Stream created using 'extend' "));
	TStreamId empty=aStore.ExtendL();
	RStoreReadStream in;
	in.OpenL(aStore,empty);
	TUint8 b;
	test(in.Source()->ReadL(&b,1)==0);
	in.Source()->SeekL(0,KStreamBeginning);
	test(in.Source()->SeekL(MStreamBuf::ERead,EStreamMark)==KStreamBeginning);
	test(in.Source()->SizeL()==0);
	TRAPD(r,in.Source()->SeekL(MStreamBuf::ERead,EStreamBeginning,1));
	test(r==KErrEof);
	TRAP(r,in.Source()->SeekL(MStreamBuf::ERead,EStreamEnd,-1));
	test(r==KErrEof);
	in.Close();
	RStoreWriteStream out;
	out.OpenL(aStore,empty);
	out.Sink()->SeekL(0,KStreamBeginning);
	test(out.Sink()->SeekL(MStreamBuf::EWrite,EStreamMark)==KStreamBeginning);
	test(out.Sink()->SizeL()==0);
	TRAP(r,out.Sink()->SeekL(MStreamBuf::EWrite,EStreamBeginning,1));
	test(r==KErrEof);
	TRAP(r,out.Sink()->SeekL(MStreamBuf::EWrite,EStreamEnd,-1));
	test(r==KErrEof);
	TRAP(r,out.WriteUint8L(0));
	test(r==KErrOverflow);
	out.Close();
//
	test.Next(_L("Replacing empty with empty"));
	out.ReplaceL(aStore,empty);
	out.CommitL();
	out.Release();
	in.OpenL(aStore,empty);
	test(in.Source()->ReadL(&b,1)==0);
	in.Source()->SeekL(0,KStreamBeginning);
	test(in.Source()->SeekL(MStreamBuf::ERead,EStreamMark)==KStreamBeginning);
	test(in.Source()->SizeL()==0);
	TRAP(r,in.Source()->SeekL(MStreamBuf::ERead,EStreamBeginning,1));
	test(r==KErrEof);
	TRAP(r,in.Source()->SeekL(MStreamBuf::ERead,EStreamEnd,-1));
	test(r==KErrEof);
	in.Close();
	out.OpenL(aStore,empty);
	out.Sink()->SeekL(0,KStreamBeginning);
	test(out.Sink()->SeekL(MStreamBuf::EWrite,EStreamMark)==KStreamBeginning);
	test(out.Sink()->SizeL()==0);
	TRAP(r,out.Sink()->SeekL(MStreamBuf::EWrite,EStreamBeginning,1));
	test(r==KErrEof);
	TRAP(r,out.Sink()->SeekL(MStreamBuf::EWrite,EStreamEnd,-1));
	test(r==KErrEof);
	TRAP(r,out.WriteUint8L(0));
	test(r==KErrOverflow);
	out.Close();
	}
コード例 #3
0
//
// Test reading from a store
//
// Reads back and checks the data written to a store by testWriteL(),
// given the store and the id returned.
//
LOCAL_C void testReadL(const CStreamStore& aStore,TStreamId anId)
	{
	test.Next(_L("Reading..."));
	RStoreReadStream in;
	in.OpenLC(aStore,anId);
	in>>TheBuf;
	TStreamId id;
	in>>id;
	in.Close();
	in.OpenL(aStore,id);
	testReadL(in);
	CleanupStack::PopAndDestroy();
	}
コード例 #4
0
//
// Test reading from a store
//
LOCAL_C void testReadL(const CPersistentStore& aStore)
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1148 Reading... "));
	RStoreReadStream in;
	in.OpenLC(aStore,aStore.Root());
	in>>TheBuf;
	TStreamId id;
	in>>id;
	in.Close();
	in.OpenL(aStore,id);
	testReadL(in);
	CleanupStack::PopAndDestroy();
	}
コード例 #5
0
ファイル: apaproc.cpp プロジェクト: cdaffara/symbiandump-mw1
/** Reads the application identifier from its stream in the specified store and 
returns it.

The location of the stream is found in the specified stream dictionary.

@param aStore The store from which the application identifier should be read. 
@param aStreamDic The stream dictionary containing the stream ID of the application 
identifier stream. The stream dictionary can be found in the root stream of 
the store.
@return The application identifier. */
EXPORT_C TApaAppIdentifier CApaProcess::ReadAppIdentifierL(const CStreamStore& aStore,const CStreamDictionary& aStreamDic)
	{
	// this is a static method
	__SHOW_TRACE(_L("Starting CApaProcess::ReadAppIdentifierL"));
	
	TStreamId infoStreamId = aStreamDic.At(KUidAppIdentifierStream);
	TApaAppIdentifier appId;
	
	// create a stream and read in the data
	RStoreReadStream stream;
	stream.OpenLC(aStore,infoStreamId);

	stream >> appId;
	stream.Close();

	CleanupStack::PopAndDestroy(); // stream
	return appId;	
	}
コード例 #6
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1151
@SYMTestCaseDesc	    Copying to a single file store test.
@SYMTestPriority 	    High
@SYMTestActions  	    Test for copying using different buffer sizes
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testCopyL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1151 Copying using small transfers "));
	TParsePtrC parse(KFileLocationSpec);
	
	CFileStore* store=CFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
	RStoreReadStream in;
	in.OpenLC(*store,store->Root());
	in>>TheBuf;
	TStreamId copyId;
	in>>copyId;
	in.Close();
	in.OpenL(*store,copyId);
	RStoreWriteStream out;
	TStreamId id=out.CreateLC(*store);
	testCopyL(out,in);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*store,id);
	testReadL(in);
	in.Close();
//
	test.Next(_L("Copying using a single big transfer"));
	in.OpenL(*store,copyId);
	id=out.CreateL(*store);
	in.ReadL(out,KTestTotal);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*store,id);
	testReadL(in);
	in.Close();
	in.OpenL(*store,copyId);
	id=out.CreateL(*store);
	out.WriteL(in,KTestTotal);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*store,id);
	testReadL(in);
//
	CleanupStack::PopAndDestroy(3);
	}
コード例 #7
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1130
@SYMTestCaseDesc	    Tests copying from one stream to another stream
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for copying using different transfer sizes
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testCopyL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1130 Opening host file "));
	
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse parse;
	parse.Set(drive.Name(), &KFileLocationSpec, NULL);
	
	CFileStore* file=CFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
//
	test.Next(_L("Opening source (root) store"));
	TStreamId root=file->Root();
	RStoreReadStream src;
	src.OpenLC(*file,root);
	RDecryptStream decrypt;
	decrypt.OpenLC(src,*thePBEKey);

	TBuf8<5> b;
	TStreamId embed;
	decrypt>>b>>embed;
	test(b==_L8(" root"));
	CleanupStack::PopAndDestroy(2); // src, decrypt
	src.OpenL(*file,embed);
	CEmbeddedStore* source=CEmbeddedStore::FromLC(src);
	CSecureStore* ssource=NULL;
	ssource=CSecureStore::NewLC(*source,*thePBEKey);

	test.Next(_L("Creating target store"));
	RStoreWriteStream trg;
	trg.CreateL(*file);
	CEmbeddedStore* target=CEmbeddedStore::NewLC(trg);
	CSecureStore* starget=NULL;
	starget=CSecureStore::NewLC(*target,*thePBEKey);

	test.Next(_L("Copying using small transfers"));
	RStoreReadStream in;
	in.OpenL(*ssource,source->Root());
	in>>TheBuf;
	TStreamId copyId;
	in>>copyId;
	in.Close();
	in.OpenL(*ssource,copyId);
	RStoreWriteStream out;
	TStreamId id=out.CreateL(*starget);
	testCopyL(out,in);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*starget,id);
	testReadL(in);
	in.Close();
//
	test.Next(_L("Copying using a single big transfer"));
	in.OpenL(*ssource,copyId);
	id=out.CreateL(*starget);
	in.ReadL(out,KTestTotal);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*starget,id);
	testReadL(in);
	in.Close();
	in.OpenL(*ssource,copyId);
	id=out.CreateL(*starget);
	out.WriteL(in,KTestTotal);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*starget,id);
	testReadL(in);
	in.Close();
//
	CleanupStack::PopAndDestroy(5);
	}
コード例 #8
0
ファイル: TALLOC.CPP プロジェクト: cdaffara/symbiandump-os1
/**
	@SYMTestCaseID
	GRAPHICS-FBSERV-0512

	@SYMTestCaseDesc
	Creates bitmaps in different ways and checks if memory allocation succeeded 

	@SYMTestActions
	Creates normal size bitmaps, large bitmaps, loads bitmaps, loads shared bitmaps,
	duplicated bitmaps, resizes bitmaps, compresses bitmaps, externalized bitmaps to write store, 
	internalizes bitmaps back again from write store. All ways of creating bitmaps are tested
	against Out Of Memory error conditions	

	@SYMTestExpectedResults
	Test should pass
*/
void CTAlloc::BitmapsL()
	{
	TInt heapMarkCheckFlag;	
	if( !iStep->GetIntFromConfig(KDefaultSectionName, KFbsHeapMarkCheckFlag, heapMarkCheckFlag) )
		{
		INFO_PRINTF1(_L("Error reading ini file"));
		User::Leave(KErrNotFound);
		}
	
	CFbsBitmap iBitmap;
	CFbsBitmap iBitmap2;

	iTestBitmapName = KTestBitmapOnZ;
	TInt ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);
	TEST2(ret, KErrNone);

	ret = iBitmap.Create(KLargeSize,EColor256); // Expand server caches
	TEST2(ret, KErrNone);
	iBitmap.Reset();

	TInt count;

// Create bitmap
	INFO_PRINTF1(_L("CFbsBitmap::Create()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}
		ret = iBitmap.Create(KSmallSize,EColor256);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMark);
				iFbs->SendCommand(EFbsMessUserMark);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMark);
				iFbs->SendCommand(EFbsMessUserMark);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret=iBitmap.Create(KSmallSize,EGray2);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// Create (large)
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Create(KLargeSize,EColor256);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Create(KLargeSize,EColor256);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// Load
	INFO_PRINTF1(_L("CFbsBitmap::Load()\r\n"));
	ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);
	TEST2(ret, KErrNone);
	iBitmap.Reset();
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Load(iTestBitmapName,ETfbs,NULL);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
	}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// Load (shared)
	INFO_PRINTF1(_L("CFbsBitmap::Load() - shared \r\n"));
	
	// Do an initial load to ensure the StreamId cache does not get updated whilst OOM testing
	ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue);
	TEST2(ret, KErrNone);
	iBitmap.Reset();
	
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue);
		
		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			continue;
			}
		else if (ret != KErrNone)
			TEST2(ret, KErrNone);
			
		ret = iBitmap2.Load(iTestBitmapName,ETfbs,ETrue);	
			
		if (ret == KErrNoMemory)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			continue;
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();	
			iBitmap2.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);		
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Load(iTestBitmapName,ETfbs,ETrue);
		
		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			continue;
			}
		else if (ret != KErrNone)
			TEST2(ret, KErrNone);
			
		ret = iBitmap2.Load(iTestBitmapName,ETfbs,ETrue);

		if (ret == KErrNoMemory)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			continue;
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			iBitmap2.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
	}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);
	
	
// Duplicate
	CFbsBitmap bmpalt;
	ret = bmpalt.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::Duplicate()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Duplicate(bmpalt.Handle());

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==1);
	ret = bmpalt.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Duplicate(bmpalt.Handle());

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	bmpalt.Reset();
	TEST(iFbs->ResourceCount()==0);

// Resize
	// force fbserv to do a resize. This makes the pile to insert an index in it's array
	// If the array is empty when the tests below are run then the insert will look like a mem leak
	ret=iBitmap.Create(KLargeSize,EColor256);
	iBitmap.Resize(KLargeSizeAlt);
	iBitmap.Reset();
	
	ret=iBitmap.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::Resize()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Resize(KSmallSizeAlt);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);
	
	
	// force fbserv to do a resize. This makes the pile to insert an index in it's array
	// If the array is empty when the tests below are run then the insert will look like a mem leak
	ret=iBitmap.Create(KLargeSize,EColor256);
	iBitmap.Resize(KLargeSizeAlt);
	iBitmap.Reset();
	
	ret=iBitmap.Create(KLargeSize,EColor256);
	TEST2(ret, KErrNone);

	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Resize(KLargeSizeAlt);

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// Compress
	ret=iBitmap.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::Compress()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Compress();

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	ret=iBitmap.Create(KLargeSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::Compress()\r\n"));
	for (count = 1; ; count++)
		{
		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		ret = iBitmap.Compress();

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

// WriteStore creation
	RFs fs;
	ret=fs.Connect();
	TEST2(ret, KErrNone);
	CDirectFileStore* writestore=NULL;

	//Construct filename using the thread id to enable concurrent test runs.
	_LIT(KSbmFileName,"c:\\tall_");
	TBuf<36> buf(KSbmFileName);
	TThreadId threadId = RThread().Id();
	TUint64 id = threadId.Id();
	TBuf<20> threadIdBuf;
	threadIdBuf.Num(id);
	buf.Append(threadIdBuf);
	buf.Append(_L(".sbm"));
	
	TRAP(ret,writestore=CDirectFileStore::ReplaceL(fs,buf,EFileStream|EFileWrite));
	TEST2(ret, KErrNone);
	TUidType uidtype(KDirectFileStoreLayoutUid,KMultiBitmapFileImageUid);
	TRAP(ret,writestore->SetTypeL(uidtype));
	TEST2(ret, KErrNone);

	RStoreWriteStream writestrm;
	TStreamId headerid(0);
	TRAP(ret,headerid=writestrm.CreateL(*writestore));
	TEST2(ret, KErrNone);
	TRAP(ret,writestore->SetRootL(headerid));
	TEST2(ret, KErrNone);

// Externalize
	ret=iBitmap.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::ExternalizeL()\r\n"));
	for (count = 1; ; count++)
		{
		__UHEAP_SETFAIL(RHeap::EDeterministic,count);
		__UHEAP_MARK;

		TRAP(ret,iBitmap.ExternalizeL(writestrm));

		if (ret == KErrNoMemory)
			{
			__UHEAP_MARKEND;
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			__UHEAP_MARKEND;
			break;
			}
		else 
			{
			__UHEAP_MARKEND;
			TEST2(ret, KErrNone);
			}
		}

	__UHEAP_RESET;
	TEST(iFbs->ResourceCount()==0);

// ExternalizeRectangle
	ret=iBitmap.Create(KSmallSize,EColor256);
	TEST2(ret, KErrNone);

	INFO_PRINTF1(_L("CFbsBitmap::ExternalizeRectangleL()\r\n"));
	for (count = 1; ; count++)
		{
		__UHEAP_SETFAIL(RHeap::EDeterministic,count);
		__UHEAP_MARK;

		TRAP(ret,iBitmap.ExternalizeRectangleL(writestrm,TRect(3,3,7,7)));

		if (ret == KErrNoMemory)
			{
			__UHEAP_MARKEND;
			}
		else if (ret == KErrNone)
			{
			__UHEAP_MARKEND;
			break;
			}
		else 
			{
			__UHEAP_MARKEND;
			TEST2(ret, KErrNone);
			}
		}

	__UHEAP_RESET;
	writestrm.Close();
	delete writestore;
	iBitmap.Reset();
	TEST(iFbs->ResourceCount()==0);

// Internalize
	INFO_PRINTF1(_L("CFbsBitmap::InternalizeL()\r\n"));
	for (count = 1; ; count++)
		{
		// ReadStore creation
		CDirectFileStore* readstore=NULL;
		TRAP(ret,readstore=CDirectFileStore::OpenL(fs,buf,EFileStream|EFileRead|EFileShareAny));
		TEST2(ret, KErrNone);
		RStoreReadStream readstrm;
		headerid=readstore->Root();
		TRAP(ret,readstrm.OpenL(*readstore,headerid));
		TEST2(ret, KErrNone);

		iFbs->SendCommand(EFbsMessDefaultAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		TRAP(ret,iBitmap.InternalizeL(readstrm));

		readstrm.Close();
		delete readstore;

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	for (count = 1; ; count++)
		{
		// ReadStore re-creation
		CDirectFileStore* readstore=NULL;
//		TRAP(ret,readstore=CDirectFileStore::OpenL(fs,_L("c:\\tall.sbm"),EFileStream|EFileRead|EFileShareAny));
		TRAP(ret,readstore=CDirectFileStore::OpenL(fs,buf,EFileStream|EFileRead|EFileShareAny));
		TEST2(ret, KErrNone);
		headerid=readstore->Root();
		RStoreReadStream readstrm;
		TRAP(ret,readstrm.OpenL(*readstore,headerid));
		TEST2(ret, KErrNone);

		iFbs->SendCommand(EFbsMessUserAllocFail,count);
		if(heapMarkCheckFlag)
			{
			iFbs->SendCommand(EFbsMessDefaultMark);
			iFbs->SendCommand(EFbsMessUserMark);
			}

		TRAP(ret,iBitmap.InternalizeL(readstrm));

		readstrm.Close();
		delete readstore;

		if (ret == KErrNoMemory)
			{
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			}
		else if (ret == KErrNone)
			{
			iBitmap.Reset();
			if(heapMarkCheckFlag)
				{
				iFbs->SendCommand(EFbsMessDefaultMarkEnd);
				iFbs->SendCommand(EFbsMessUserMarkEnd);
				}
			break;
			}
		else 
			TEST2(ret, KErrNone);
		}

	iFbs->SendCommand(EFbsMessDefaultAllocFail,0);
	iFbs->SendCommand(EFbsMessUserAllocFail,0);
	TEST(iFbs->ResourceCount()==0);

	fs.Delete(buf);
	fs.Close();
	}
コード例 #9
0
ファイル: TTYPES.CPP プロジェクト: cdaffara/symbiandump-os2
void CTTypes::ResetReadStream()
	{
	readstrm.Close();
	delete readstore;
	}
コード例 #10
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1198
@SYMTestCaseDesc	    Copying in a single file store test.
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for copying using different buffer sizes
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void testCopyL()
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1198 Opening host file "));
	TParsePtrC parse(KFileLocationSpec);
	
	CFileStore* file=CFileStore::OpenLC(TheFs,parse.NameAndExt(),EFileRead|EFileWrite);
//
	test.Next(_L("Opening source (root) store"));
	TStreamId root=file->Root();
	RStoreReadStream src;
	src.OpenLC(*file,root);
	TBuf8<5> b;
	src.ReadL(b);
	test(b==_L8(" root"));
	CleanupStack::Pop();
	CEmbeddedStore* source=CEmbeddedStore::FromLC(src);
//
	test.Next(_L("Duplicating source store"));
	RStoreWriteStream trg;
	trg.CreateLC(*file);
	MStreamBuf* host=source->Host();
	TStreamPos pos=CEmbeddedStore::Position(source->Root());
	host->SeekL(host->ERead,EStreamBeginning);
	RReadStream stream(host);
	trg.WriteL(stream,pos.Offset());
	stream>>TheBuf;
	TStreamId id;
	stream>>id;
	test(host->TellL(host->ERead).Offset()==host->SizeL());
	trg<<TheBuf;
	trg<<id;
	trg.CommitL();
	source->Detach();
	host->Release();
	source->Reattach(trg.Sink());
	CleanupStack::Pop();
	testReadL(*source);
//
	test.Next(_L("Creating target store"));
	trg.CreateLC(*file);
	trg.WriteL(_L8(" target"));
	CleanupStack::Pop();
	CEmbeddedStore* target=CEmbeddedStore::NewLC(trg);
//
	test.Next(_L("Copying using small transfers"));
	RStoreReadStream in;
	in.OpenL(*source,source->Root());
	in>>TheBuf;
	TStreamId copyId;
	in>>copyId;
	in.Close();
	in.OpenL(*source,copyId);
	RStoreWriteStream out;
	id=out.CreateL(*target);
	testCopyL(out,in);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*target,id);
	testReadL(in);
	in.Close();
//
	test.Next(_L("Copying using a single big transfer"));
	in.OpenL(*source,copyId);
	id=out.CreateL(*target);
	in.ReadL(out,KTestTotal);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*target,id);
	testReadL(in);
	in.Close();
	in.OpenL(*source,copyId);
	id=out.CreateL(*target);
	out.WriteL(in,KTestTotal);
	out.CommitL();
	out.Close();
	in.Close();
	in.OpenL(*target,id);
	testReadL(in);
	in.Close();
//
	CleanupStack::PopAndDestroy(3);
	}