Пример #1
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1184
@SYMTestCaseDesc	    Tests for CDictionaryFileStore::IsPresentL() function
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for the specified UID's has an associated stream within the dictionary store.
						Tests for KErrNone error flag while opening a dictionary file for read,test the value read from the file.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void Test2L(CDictionaryFileStore* aDict)
	{
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1184 "));
	test(!aDict->IsPresentL(testUid1));
	test(aDict->IsPresentL(testUid2));
	test(!aDict->IsPresentL(testUid3));
	RDictionaryReadStream readStream;
	TRAPD(ret, readStream.OpenL(*aDict,testUid2));
		test(ret==KErrNone);
	TInt val=0;
	TRAP(ret, val = readStream.ReadInt32L());
		test(ret==KErrNone);
		test(val==value2);
	readStream.Close();
	//
	//
	test.Next(_L("Close the store without commiting"));
	// add a stream, close the store (no commit)
	RDictionaryWriteStream writeStream;
	TRAP(ret, writeStream.AssignL(*aDict,testUid3));
		test(ret==KErrNone);
	TRAP(ret, writeStream.WriteInt32L(value3));
		test(ret==KErrNone);
	TRAP(ret, writeStream.CommitL());
		test(ret==KErrNone);
	writeStream.Close();
	delete aDict;
	}
Пример #2
0
void CCntServerSpeedDialManager::StoreL(CDictionaryFileStore& aStore) const
	{
	const TInt count = iSpeedDials.Count();
	if (count)
		{
		RDictionaryWriteStream stream;
		stream.AssignLC(aStore, KUidCntSpeedDialStream);
		stream.WriteInt32L(iSpeedDials.Count()); 
		for(TInt i=0; i<count; i++)
			{
			stream << *iSpeedDials[i];
			}
		stream.CommitL();
		CleanupStack::PopAndDestroy(); // stream
		}
	}
Пример #3
0
void CCntServerCurrentItemMap::StoreL(CDictionaryFileStore& aStore) const
	{
	RDictionaryWriteStream stream;
	stream.AssignLC(aStore, KUidCntCurrentItemStream);

	const TInt count = iCurrentItemMap.Count();
	stream.WriteInt32L(count);
	for(TInt i=0; i<count; i++)
		{
		const CCntCurrentItemMapEntry* entry = iCurrentItemMap[i];
		stream << *entry;
		}

	stream.CommitL();
	CleanupStack::PopAndDestroy(); // stream
	}
Пример #4
0
LOCAL_C void AddEntryL()
	{
	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse dicFilePath;
	dicFilePath.Set(drive.Name(), &KDicFilePath, NULL);
	
	CDictionaryStore* dictionary=CDictionaryFileStore::OpenLC(TheFs,dicFilePath.FullName(),dicFileUid);
	RDictionaryWriteStream s;
	s.AssignLC(*dictionary,testUid4);
	s.WriteInt32L(value1);
	s.CommitL();
	CleanupStack::PopAndDestroy();	// s
   	TInt err = dictionary->Commit(); // changed from CommitL to ensure api coverage
	User::LeaveIfError(err);
	CleanupStack::PopAndDestroy();	// dictionary
	}
Пример #5
0
// -----------------------------------------------------------------------------
// CGbaServer::WriteOptionL()
// -----------------------------------------------------------------------------
//
void CGbaServer::WriteOptionL(const TUid& aOptionID, const TDesC8& aValue) const
{
    GBA_TRACE_DEBUG(("WriteOptionL"));
    TInt pushCount = 0;
    RFs fs;
    User::LeaveIfError(fs.Connect());
    CleanupClosePushL( fs );
    pushCount++;
    TFindFile folder( fs );

    TFileName fullPath;
    MakePrivateFilenameL(fs, KGbaIniFileName, fullPath);
    EnsurePathL(fs, fullPath );

    GBA_TRACE_DEBUG(fullPath);

    TInt err = folder.FindByDir( fullPath, KNullDesC);

    if (  err == KErrNotFound || err == KErrNone )
    {
        CDictionaryFileStore* pStore = CDictionaryFileStore::OpenLC( fs, fullPath, KGbaIniUid );
        pushCount++;

        RDictionaryWriteStream wrs;
        CleanupClosePushL( wrs );
        wrs.AssignL(*pStore,aOptionID);

        wrs.WriteInt32L(aValue.Length());
        wrs.WriteL(aValue);
        wrs.CommitL();

        pStore->CommitL();
        CleanupStack::PopAndDestroy( &wrs );
        CleanupStack::PopAndDestroy( pushCount );
        GBA_TRACE_DEBUG(aValue);
    }
    else
    {
        CleanupStack::PopAndDestroy( pushCount );
        User::LeaveIfError( err );
    }
}
Пример #6
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1183
@SYMTestCaseDesc	    Tests for CDictionaryFileStore::IsPresentL(),CDictionaryFileStore::Remove() functions
@SYMTestPriority 	    High
@SYMTestActions  	    Tests for writing an entry and commit it.
                        Tests for reading the entry back.
						Tests for rewriting and reading back using LC functions.
						Tests for adding one more entry and check for the content.
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void Test1L(CDictionaryFileStore* aDict)
	{
	// write an entry and commit it
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1183 "));
	RDictionaryWriteStream writeStream;
	TRAPD(ret, writeStream.AssignL(*aDict,testUid1));
		test(ret==KErrNone);
	TRAP(ret, writeStream.WriteInt32L(value1));
		test(ret==KErrNone);
	TRAP(ret, writeStream.CommitL());
		test(ret==KErrNone);
	writeStream.Close();
	// read that entry back
	RDictionaryReadStream readStream;
	TRAP(ret, readStream.OpenL(*aDict,testUid1));
		test(ret==KErrNone);
	TInt val=0;
	TRAP(ret, val = readStream.ReadInt32L());
		test(ret==KErrNone);
		test(val==value1);
	readStream.Close();
	//
	test.Next(_L("Test the stream LC methods"));
	// read that entry back using the LC method
	readStream.OpenLC(*aDict,testUid1);
	TRAP(ret, val = readStream.ReadInt32L());
		test(ret==KErrNone);
		test(val==value1);
	//readStream.Close();
	CleanupStack::PopAndDestroy(); // readStream
	//
	// rewrite that entry using the LC method
	writeStream.AssignLC(*aDict,testUid1);
	
	//do some rading
	MStreamBuf* sbuf = writeStream.Sink();
	HBufC8* buffer = HBufC8::NewLC(400);
	TUint8* buffptr = const_cast<TUint8*>(buffer->Ptr());
	sbuf->ReadL(buffptr, 100);
	TPtr8 buffDes(buffer->Des());
	TRequestStatus rstatus;
	sbuf->ReadL(buffDes, 100, rstatus);
	User::WaitForRequest(rstatus);
	CleanupStack::PopAndDestroy(); //buffer
	
	TRAP(ret, writeStream.WriteInt32L(value1));
		test(ret==KErrNone);
	TRAP(ret, writeStream.CommitL());
		test(ret==KErrNone);
	//writeStream.Close();
	CleanupStack::PopAndDestroy(); // writestream
	//
	test.Next(_L("Test reverting the store"));
	// commit the store
	TRAP(ret, aDict->CommitL());
		test(ret==KErrNone);
	// replace the 1st entry, commit it, then revert the store
	TRAP(ret, writeStream.AssignL(*aDict,testUid1));
		test(ret==KErrNone);
	TRAP(ret, writeStream.WriteInt32L(value2));
		test(ret==KErrNone);
	TRAP(ret, writeStream.CommitL());
		test(ret==KErrNone);
	writeStream.Close();
	TRAP(ret, aDict->RevertL());
		test(ret==KErrNone);
	// check the value of the entry
	TRAP(ret, readStream.OpenL(*aDict,testUid1));
		test(ret==KErrNone);
	TRAP(ret, val = readStream.ReadInt32L());
		test(ret==KErrNone);
		test(val==value1);
	readStream.Close();
	
	test.Next(_L("Test reverting the store using alternative Revert method"));
	// replace the 1st entry, commit it, then revert the store
	TRAP(ret, writeStream.AssignL(*aDict,testUid1));
		test(ret==KErrNone);
	TRAP(ret, writeStream.WriteInt32L(value2));
		test(ret==KErrNone);
	TRAP(ret, writeStream.CommitL());
		test(ret==KErrNone);
	writeStream.Close();
	aDict->Revert();
	// check the value of the entry
	TRAP(ret, readStream.OpenL(*aDict,testUid1));
		test(ret==KErrNone);
	TRAP(ret, val = readStream.ReadInt32L());
		test(ret==KErrNone);
		test(val==value1);
	readStream.Close();
	//
	//
	test.Next(_L("Test IsPresentL() and Remove()"));
	// add another entry
	TRAP(ret, writeStream.AssignL(*aDict,testUid2));
		test(ret==KErrNone);
	TRAP(ret, writeStream.WriteInt32L(value2));
		test(ret==KErrNone);
	test(!aDict->IsPresentL(testUid2));
	TRAP(ret, writeStream.CommitL());
		test(ret==KErrNone);
	writeStream.Close();
	// test IsPresentL()
	test(aDict->IsPresentL(testUid1));
	test(aDict->IsPresentL(testUid2));
	test(!aDict->IsPresentL(testUid3));
	// test Remove()
	TRAP(ret, aDict->RemoveL(testUid1));
		test(!aDict->IsPresentL(testUid1));
	//
	//
	test.Next(_L("Close the store and re-open it"));
	// commit the store and close it
	TRAP(ret, aDict->CommitL());
		test(ret==KErrNone);
	//
	delete aDict;
	}
Пример #7
0
/**
@SYMTestCaseID          SYSLIB-STORE-CT-1189
@SYMTestCaseDesc	    Repeatedly opening a dictionary file test
@SYMTestPriority 	    High
@SYMTestActions  	    Attempt for creating a new dictionary file,write an entry an commit it.
                        Attempt for repeatedly opening the dictionary file,interogate it,and delete it without commiting
                        Attempt for repeatedly opening the dictionary file and interogate it,commit the file after each read
						Attempt for repeatedly opening the dictionary file and re-write a stream, commiting the file after each write
@SYMTestExpectedResults Test must not fail
@SYMREQ                 REQ0000
*/
LOCAL_C void repeatedUseTestsL()
	{
	// set things up...
	test.Next(_L(" @SYMTestCaseID:SYSLIB-STORE-CT-1189 "));

	TDriveUnit drive(static_cast<TUint>(RFs::GetSystemDrive()));	
	TParse dicFilePath;
	dicFilePath.Set(drive.Name(), &KDicFilePath, NULL);
	
	TInt ret = TheFs.MkDirAll(dicFilePath.DriveAndPath());
		test((ret==KErrNone)||(ret==KErrAlreadyExists));
	TheFs.Delete(dicFilePath.FullName()); // delete the file if it already exists
	//
	// create a new dictionary file
	CDictionaryFileStore* dicFile=NULL;
	TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
		test(ret==KErrNone);
	// write an entry and commit it
	RDictionaryWriteStream writeStream;
	TRAP(ret, writeStream.AssignL(*dicFile,testUid1));
		test(ret==KErrNone);
	TRAP(ret, writeStream.WriteInt32L(value1));
		test(ret==KErrNone);
	TRAP(ret, writeStream.CommitL());
		test(ret==KErrNone);
	writeStream.Close();
	// close the file
	TRAP(ret, dicFile->CommitL());
		test(ret==KErrNone);
	delete dicFile;
	dicFile = NULL;
	//
	//
	test.Next(_L("Repeatedly open a file and interogate it without commiting"));
	// repeatedly open the dic file, interogate it, and delete it without commiting
	TEntry fileEntry;
	ret = TheFs.Entry(dicFilePath.FullName(),fileEntry);
		test(ret==KErrNone);
	TInt sizeBefore=fileEntry.iSize;
	//
	TInt i;
	for (i=0 ; i<10 ; i++)
		{
		TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
			test(ret==KErrNone);
		RDictionaryReadStream readStream;
		TRAP(ret, readStream.OpenL(*dicFile,testUid1));
			test(ret==KErrNone);
		readStream.Close();
		delete dicFile;
		dicFile = NULL;
		}
	//
	ret = TheFs.Entry(dicFilePath.FullName(),fileEntry);
		test(ret==KErrNone);
	TInt sizeAfter=fileEntry.iSize;
		test(sizeAfter==sizeBefore);
	//
	//
	test.Next(_L("Repeatedly open a file, commiting after each read"));
	// repeatedly open the dic file and interogate it, commiting the file after each read
	ret = TheFs.Entry(dicFilePath.FullName(),fileEntry);
		test(ret==KErrNone);
	sizeBefore=fileEntry.iSize;
	//
	for (i=0 ; i<10 ; i++)
		{
		TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
			test(ret==KErrNone);
		RDictionaryReadStream readStream;
		TRAP(ret, readStream.OpenL(*dicFile,testUid1));
			test(ret==KErrNone);
		readStream.Close();
		TRAP(ret, dicFile->CommitL());
			test(ret==KErrNone);
		delete dicFile;
		dicFile = NULL;
		}
	//
	ret = TheFs.Entry(dicFilePath.FullName(),fileEntry);
		test(ret==KErrNone);
	sizeAfter=fileEntry.iSize;
		test(sizeAfter==sizeBefore);
	//
	//
	test.Next(_L("Repeatedly open a file and re-write a stream"));
	// repeatedly open the dic file and re-write a stream, commiting the file after each write
	ret = TheFs.Entry(dicFilePath.FullName(),fileEntry);
		test(ret==KErrNone);
	sizeBefore=fileEntry.iSize;
	//
	for (i=0 ; i<10 ; i++)
		{
		TRAP(ret, dicFile = CDictionaryFileStore::OpenL(TheFs,dicFilePath.FullName(),dicFileUid));
			test(ret==KErrNone);
		// write an entry and commit it
		RDictionaryWriteStream writeStream;
		TRAP(ret, writeStream.AssignL(*dicFile,testUid1));
			test(ret==KErrNone);
		TRAP(ret, writeStream.WriteInt32L(i));
			test(ret==KErrNone);
		TRAP(ret, writeStream.CommitL());
			test(ret==KErrNone);
		writeStream.Close();
		// close the file
		TRAP(ret, dicFile->CommitL());
			test(ret==KErrNone);
		delete dicFile;
		dicFile = NULL;
		}
	//
	ret = TheFs.Entry(dicFilePath.FullName(),fileEntry);
		test(ret==KErrNone);
	sizeAfter=fileEntry.iSize;
		test.Printf(_L("  Size before: %d\n  Size after:  %d\n"),sizeBefore,sizeAfter);
	//
	//
	// tidy up
	}