예제 #1
0
//
// Test writing to a store
//
LOCAL_C void testWriteL(CPersistentStore& aStore)
	{
	test.Next(_L("Writing..."));
	RStoreWriteStream out;
	TStreamId id=out.CreateLC(aStore);
	TStreamPos end=KStreamBeginning; //*
	for (TInt i=0;i<=KTestLength;++i)
		{
		test(out.Sink()->SeekL(MStreamBuf::EWrite,EStreamMark)==end); //*
		out.WriteL(KTestDes,i);
		test(out.Sink()->SeekL(0,EStreamEnd,-i)==end); //*
		out.WriteL(&KTestData[i],KTestLength-i);
		end+=KTestLength; //*
		}
//*	test(out.Sink()->SizeL()==end.Offset());
//*	out.WriteL(KTestDes,12);
//*	end+=12;
	test(out.Sink()->SizeL()==end.Offset()); //*
	out.CommitL();
	test(out.Sink()->SizeL()==end.Offset()); //*
	out.Close();
	aStore.SetRootL(out.CreateL(aStore));
	out<<KTestDes;
	out<<id;
	out.CommitL();
	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
/**
@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);
	}