sl@0: // Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: RTest test(_L("T_RESOURCE_COMPRESSION2")); sl@0: RFs fileServerSession; sl@0: _LIT8(KRscFileHeaderData, "0123456789ABCDEF"); sl@0: _LIT(KRomResourceFileHeader, "z:\\system\\data\\RscHeader.bin"); sl@0: sl@0: LOCAL_D const TPtrC rsc_files[] = sl@0: { sl@0: _L("T_COMPRESSED_UNICODE_1.RSC") sl@0: , _L("T_COMPRESSED_UNICODE_2.RSC") sl@0: , _L("T_DICTIONARY_COMPRESSED_VERSIO_OF_2.RSC") sl@0: , _L("T_CALYPSO_TEST_RESOURCE_FILE_1.RSC") sl@0: , _L("T_NotRscFile.RSC") sl@0: , _L("TRscROMCalypsoComprNewFmt.rsc") sl@0: }; sl@0: _LIT(KZDir, "z:\\system\\data\\"); sl@0: _LIT(KCDir, "c:\\"); sl@0: sl@0: LOCAL_C void DeleteDataFile(const TDesC& aFullName) sl@0: { sl@0: // make sure the file is read/write sl@0: TInt err = fileServerSession.SetAtt(aFullName,0, KEntryAttReadOnly); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Print(_L("error changing attributes file = %d"),err); sl@0: } sl@0: // delete the file sl@0: err = BaflUtils::DeleteFile(fileServerSession, aFullName); sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Print(_L("error deleting file = %d"),err); sl@0: } sl@0: } sl@0: sl@0: LOCAL_C TInt FileSizeL(const TDesC& aFileName) sl@0: { sl@0: RFile file; sl@0: User::LeaveIfError(file.Open(fileServerSession, aFileName, EFileRead)); sl@0: CleanupClosePushL(file); sl@0: TInt size = 0; sl@0: User::LeaveIfError(file.Size(size)); sl@0: CleanupStack::PopAndDestroy(&file); sl@0: return size; sl@0: } sl@0: sl@0: LOCAL_C void CreateFileFromL(const TDesC& aDestFileName, const TDesC& aSrcFileName) sl@0: { sl@0: RFile destFile; sl@0: RFile srcFile; sl@0: sl@0: CleanupClosePushL(destFile); sl@0: CleanupClosePushL(srcFile); sl@0: sl@0: BaflUtils::DeleteFile(fileServerSession, aDestFileName); sl@0: User::LeaveIfError(destFile.Create(fileServerSession, aDestFileName, EFileRead | EFileWrite)); sl@0: sl@0: User::LeaveIfError(srcFile.Open(fileServerSession, aSrcFileName, EFileRead)); sl@0: TInt size = 0; sl@0: User::LeaveIfError(srcFile.Size(size)); sl@0: HBufC8* buf = HBufC8::NewMaxLC(size); sl@0: TPtr8 ptr = buf->Des(); sl@0: srcFile.Read(ptr); sl@0: sl@0: destFile.Write(KRscFileHeaderData); sl@0: destFile.Write(ptr); sl@0: sl@0: CleanupStack::PopAndDestroy(buf); sl@0: CleanupStack::PopAndDestroy(&srcFile); sl@0: CleanupStack::PopAndDestroy(&destFile); sl@0: } sl@0: sl@0: LOCAL_C void CreateFileFromL(TDes& aDestFilePath, const TDesC& aDestFileName, const TDesC& aSrcFilePath) sl@0: { sl@0: aDestFilePath.Copy(KCDir); sl@0: aDestFilePath += _L("N_"); sl@0: aDestFilePath += aDestFileName; sl@0: CreateFileFromL(aDestFilePath, aSrcFilePath); sl@0: } sl@0: sl@0: LOCAL_C void Test1L(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0) sl@0: { sl@0: CResourceFile* resourceFile = CResourceFile::NewLC(fileServerSession, aResourceFileName, aFileOffset, aFileSize); sl@0: test(resourceFile->UidType()==TUidType(TUid::Uid(0x101f4a6b), TUid::Uid(0x000eb205), TUid::Uid(TUint(T_COMPRESSED_UNICODE_1_RESOURCE_1)>>12))); sl@0: HBufC8* resource = NULL; sl@0: RResourceReader resourceReader; sl@0: sl@0: resource=resourceFile->AllocReadLC(1); sl@0: test(resource->Length()%sizeof(TText)==0); sl@0: test(TPtrC((TText*)resource->Ptr(), resource->Length()/sizeof(TText))==_L("Gruezi miteinander")); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 2); sl@0: test(resourceReader.ReadUint16L()==4); sl@0: test(resourceReader.ReadTPtrCL()==_L("Bonjour")); sl@0: test(resourceReader.ReadTPtrCL()==_L("Ni3 hao3")); sl@0: test(resourceReader.ReadTPtrCL()==_L("Konnichiwa")); sl@0: test(resourceReader.ReadTPtrCL()==_L("Zdravstvuit'e")); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 3); sl@0: test(resourceReader.ReadUint16L()==3); sl@0: test(resourceReader.ReadTPtrCL()==_L("Gamarjoba")); sl@0: test(resourceReader.ReadTPtrCL()==_L("Gasou")); sl@0: test(resourceReader.ReadTPtrCL()==_L("Ola")); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 4); sl@0: test(resourceReader.ReadUint16L()==3); sl@0: test(resourceReader.ReadUint8L()==0xbd); sl@0: test(resourceReader.ReadUint8L()==0x5e); sl@0: test(resourceReader.ReadUint8L()==0xf1); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 5); sl@0: test(resourceReader.ReadUint32L()==4); sl@0: test(resourceReader.ReadUint32L()==T_COMPRESSED_UNICODE_1_RESOURCE_5); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resource=resourceFile->AllocReadLC(6); sl@0: test(resource->Length()%sizeof(TText)==0); sl@0: test(TPtrC((TText*)resource->Ptr(), resource->Length()/sizeof(TText))==_L("_")); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 7); sl@0: test(resourceReader.ReadUint8L()==9); sl@0: test(resourceReader.ReadTPtrCL()==_L("To")); sl@0: test(resourceReader.ReadUint8L()==97); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 8); sl@0: test(resourceReader.ReadUint16L()==999); sl@0: test(resourceReader.ReadTPtrCL()==_L("To")); sl@0: test(resourceReader.ReadUint8L()==79); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 9); sl@0: test(resourceReader.ReadUint16L()==53132); sl@0: test(resourceReader.ReadTPtrCL()==_L("T")); sl@0: test(resourceReader.ReadUint8L()==62); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 10); sl@0: test(resourceReader.ReadInt32L()==1253869); sl@0: test(resourceReader.ReadInt32L()==-986324); sl@0: test(resourceReader.ReadUint32L()==0x600ddea1u); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: CleanupStack::PopAndDestroy(resourceFile); sl@0: } sl@0: sl@0: LOCAL_C void Test2L(const TDesC& aResourceFileName, TUid aFirstUid, TUint aFileOffset = 0, TInt aFileSize = 0) sl@0: { sl@0: CResourceFile* resourceFile = CResourceFile::NewLC(fileServerSession, aResourceFileName, aFileOffset, aFileSize); sl@0: test(resourceFile->UidType()==TUidType(aFirstUid, TUid::Null(), TUid::Uid(TUint(T_COMPRESSED_UNICODE_2_RESOURCE_1)>>12))); sl@0: HBufC8* resource = NULL; sl@0: RResourceReader resourceReader; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 1); sl@0: test(resourceReader.ReadUint32L()==4); sl@0: test(resourceReader.ReadUint32L()==T_COMPRESSED_UNICODE_2_RESOURCE_1); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resource=resourceFile->AllocReadLC(2); sl@0: test(resource->Length()%sizeof(TText)==0); sl@0: test(TPtrC((TText*)resource->Ptr(), resource->Length()/sizeof(TText))==_L("My program is cool")); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: resource = NULL; sl@0: sl@0: resource=resourceFile->AllocReadLC(3); sl@0: test(resource->Length()%sizeof(TText)==0); sl@0: test(TPtrC((TText*)resource->Ptr(), resource->Length()/sizeof(TText))==_L("z:\\system\\data\\eikon.mbm")); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 4); sl@0: test(resourceReader.ReadInt32L()==9174804); sl@0: test(resourceReader.ReadUint8L()==6); sl@0: test(resourceReader.ReadInt32L()==-6208493); sl@0: test(resourceReader.ReadUint16L()==0x3176); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 5); sl@0: test(resourceReader.ReadInt32L()==-120727); sl@0: test(resourceReader.ReadInt32L()==-82385253); sl@0: test(resourceReader.ReadUint16L()==0x3176); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 6); sl@0: test(resourceReader.ReadUint8L()==2); sl@0: test(resourceReader.ReadTPtrCL()==_L("z:\\system\\data\\uikon.mbm")); sl@0: test(resourceReader.ReadTPtrCL()==_L("z:\\system\\apps\\my_program\\my_program.mbm")); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: CleanupStack::PopAndDestroy(resourceFile); sl@0: } sl@0: sl@0: LOCAL_C void Test3L(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0) sl@0: { sl@0: /* This function tests the calypso resoruce file format loading/reading sl@0: * and was derived from the Test1 function above. Therefore the resource sl@0: * file it reads is also derived from the file used in test 1. sl@0: */ sl@0: sl@0: CResourceFile* resourceFile = CResourceFile::NewLC(fileServerSession, aResourceFileName, aFileOffset, aFileSize); sl@0: HBufC8* resource = NULL; sl@0: RResourceReader resourceReader; sl@0: sl@0: resource=resourceFile->AllocReadLC(1); sl@0: test(resource->Length()%sizeof(TText)==0); sl@0: test(TPtrC((TText*)resource->Ptr(), resource->Length()/sizeof(TText))==_L("Gruezi miteinander")); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 2); sl@0: test(resourceReader.ReadUint16L()==4); sl@0: test(resourceReader.ReadTPtrCL()==_L("Bonjour")); sl@0: test(resourceReader.ReadTPtrCL()==_L("Ni3 hao3")); sl@0: test(resourceReader.ReadTPtrCL()==_L("Konnichiwa")); sl@0: test(resourceReader.ReadTPtrCL()==_L("Zdravstvuit'e")); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 3); sl@0: test(resourceReader.ReadUint16L()==3); sl@0: test(resourceReader.ReadTPtrCL()==_L("Gamarjoba")); sl@0: test(resourceReader.ReadTPtrCL()==_L("Gasou")); sl@0: test(resourceReader.ReadTPtrCL()==_L("Ola")); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 4); sl@0: test(resourceReader.ReadUint16L()==3); sl@0: test(resourceReader.ReadUint8L()==0xbd); sl@0: test(resourceReader.ReadUint8L()==0x5e); sl@0: test(resourceReader.ReadUint8L()==0xf1); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 5); sl@0: test(resourceReader.ReadUint32L()==4); sl@0: test(resourceReader.ReadUint32L()==T_COMPRESSED_UNICODE_1_RESOURCE_5); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resource=resourceFile->AllocReadLC(6); sl@0: test(resource->Length()%sizeof(TText)==0); sl@0: test(TPtrC((TText*)resource->Ptr(), resource->Length()/sizeof(TText))==_L("_")); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 7); sl@0: test(resourceReader.ReadUint8L()==9); sl@0: test(resourceReader.ReadTPtrCL()==_L("To")); sl@0: test(resourceReader.ReadUint8L()==97); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 8); sl@0: test(resourceReader.ReadUint16L()==999); sl@0: test(resourceReader.ReadTPtrCL()==_L("To")); sl@0: test(resourceReader.ReadUint8L()==79); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 9); sl@0: test(resourceReader.ReadUint16L()==53132); sl@0: test(resourceReader.ReadTPtrCL()==_L("T")); sl@0: test(resourceReader.ReadUint8L()==62); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: resourceReader.OpenLC(resourceFile, 10); sl@0: test(resourceReader.ReadInt32L()==1253869); sl@0: test(resourceReader.ReadInt32L()==-986324); sl@0: test(resourceReader.ReadUint32L()==0x600ddea1u); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: // reading resource 11 takes some time, as it is long sl@0: // and gets compressed. sl@0: // This is useful for the timing measurements in TestDef044572L() sl@0: resourceReader.OpenLC(resourceFile, 11); sl@0: CleanupStack::PopAndDestroy(1, &resourceReader); sl@0: resource = NULL; sl@0: sl@0: CleanupStack::PopAndDestroy(resourceFile); sl@0: } sl@0: sl@0: LOCAL_C void Test4L(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0) sl@0: { sl@0: /* This function tests the behaviour of bafl when reading a calypso resource file sl@0: * for a signature. Calypso resource files do not have signatures. sl@0: */ sl@0: sl@0: CResourceFile* resourceFile = CResourceFile::NewLC(fileServerSession, aResourceFileName, aFileOffset, aFileSize); sl@0: sl@0: // Need to pass the TInt as required, but doesn't sl@0: // use it. Legacy for BC sake. sl@0: TInt err = KErrNone; sl@0: TRAP(err, resourceFile->ConfirmSignatureL(1)); sl@0: test(err == KErrCorrupt); sl@0: sl@0: // New function that has further test to confirm absence of signature sl@0: // Hopefully we can get clients to move over to this in future. sl@0: TRAP(err, resourceFile->ConfirmSignatureL()); sl@0: test(err == KErrCorrupt); sl@0: sl@0: CleanupStack::PopAndDestroy(resourceFile); sl@0: } sl@0: sl@0: LOCAL_C void Test5L(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0) sl@0: { sl@0: /* This function tests the behaviour of bafl when reading a resource file sl@0: * for a signature. sl@0: * In this case the signature is present and is NOT the first resource. sl@0: */ sl@0: sl@0: CResourceFile* resourceFile = CResourceFile::NewLC(fileServerSession, aResourceFileName, aFileOffset, aFileSize); sl@0: sl@0: // Need to pass the TInt as required, but doesn't sl@0: // use it. Legacy for BC sake. sl@0: TInt err = KErrNone; sl@0: TRAP(err, resourceFile->ConfirmSignatureL(1)); sl@0: test(err == KErrCorrupt); sl@0: sl@0: // New function that has further test to confirm absence of signature sl@0: // Hopefully we can get clients to move over to this in future. sl@0: TRAP(err, resourceFile->ConfirmSignatureL()); sl@0: test(err == KErrCorrupt); sl@0: sl@0: CleanupStack::PopAndDestroy(resourceFile); sl@0: } sl@0: sl@0: LOCAL_C void Test6L(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0) sl@0: { sl@0: /* This function tests the behaviour of bafl when reading a resource file sl@0: * for a signature. sl@0: * In this case the signature is present and is the first resource. sl@0: */ sl@0: sl@0: CResourceFile* resourceFile = CResourceFile::NewLC(fileServerSession, aResourceFileName, aFileOffset, aFileSize); sl@0: sl@0: // Need to pass the TInt as required, but doesn't sl@0: // use it. Legacy for BC sake. sl@0: TInt err = KErrNone; sl@0: TRAP(err, resourceFile->ConfirmSignatureL(1)); sl@0: test(err == KErrNone); sl@0: sl@0: // New function that has further test to confirm absence of signature sl@0: // Hopefully we can get clients to move over to this in future. sl@0: TRAP(err, resourceFile->ConfirmSignatureL()); sl@0: test(err == KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(resourceFile); sl@0: } sl@0: sl@0: LOCAL_C void Test7L(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0) sl@0: { sl@0: /* This function tests the behaviour of bafl when reading a non resource file. sl@0: */ sl@0: TRAPD(err, (void)CResourceFile::NewL(fileServerSession, aResourceFileName, aFileOffset, aFileSize)); sl@0: test(err != KErrNotFound && err != KErrNone); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0480 sl@0: @SYMTestCaseDesc Testing resource files containing Unicode-compressed text sl@0: @SYMTestPriority High sl@0: @SYMTestActions Wrapper function calling up Test1L() and Test2L() functions sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void SubTest1L() sl@0: { sl@0: test.Start(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0480 Testing resource files containing Unicode-compressed text ")); sl@0: TBuf<128> z_path; sl@0: TBuf<128> c_path; sl@0: sl@0: z_path.Copy(KZDir); sl@0: z_path += rsc_files[0]; sl@0: Test1L(z_path); sl@0: CreateFileFromL(c_path, rsc_files[0], z_path); sl@0: Test1L(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path)); sl@0: DeleteDataFile(c_path); sl@0: sl@0: z_path.Copy(KZDir); sl@0: z_path.Append(rsc_files[1]); sl@0: Test2L(z_path, TUid::Uid(0x101f4a6b)); sl@0: CreateFileFromL(c_path, rsc_files[1], z_path); sl@0: Test2L(c_path, TUid::Uid(0x101f4a6b), KRscFileHeaderData().Length(), FileSizeL(z_path)); sl@0: DeleteDataFile(c_path); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0481 sl@0: @SYMTestCaseDesc Testing dictionary-compressed resource files sl@0: @SYMTestPriority High sl@0: @SYMTestActions Wrapper function calling up Test2L() function sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void SubTest2L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0481 Testing dictionary-compressed resource files ")); sl@0: TBuf<128> z_path; sl@0: TBuf<128> c_path; sl@0: sl@0: z_path.Copy(KZDir); sl@0: z_path.Append(rsc_files[2]); sl@0: Test2L(z_path, TUid::Uid(0x101f5010)); sl@0: CreateFileFromL(c_path, rsc_files[2], z_path); sl@0: Test2L(c_path, TUid::Uid(0x101f5010), KRscFileHeaderData().Length(), FileSizeL(z_path)); sl@0: DeleteDataFile(c_path); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0482-0001 sl@0: @SYMTestCaseDesc Testing Calypso ER5u format dictionary-compressed resource files sl@0: @SYMTestPriority High sl@0: @SYMTestActions Wrapper function calling up Test3L() function sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void SubTest3L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0482-0001 Testing Calypso ER5u format dictionary-compressed resource files ")); sl@0: TBuf<128> z_path; sl@0: TBuf<128> c_path; sl@0: sl@0: z_path.Copy(KZDir); sl@0: z_path.Append(rsc_files[3]); sl@0: Test3L(z_path); sl@0: CreateFileFromL(c_path, rsc_files[3], z_path); sl@0: Test3L(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path)); sl@0: DeleteDataFile(c_path); sl@0: sl@0: z_path.Copy(KZDir); sl@0: z_path.Append(rsc_files[5]); sl@0: Test3L(z_path, FileSizeL(KRomResourceFileHeader), FileSizeL(z_path) - FileSizeL(KRomResourceFileHeader)); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0483-0001 sl@0: @SYMTestCaseDesc Testing resource file missing signature behaviour sl@0: @SYMTestPriority High sl@0: @SYMTestActions Wrapper function calling up Test4L() function sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void SubTest4L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0483-0001 Testing resource file missing signature behaviour ")); sl@0: TBuf<128> z_path; sl@0: TBuf<128> c_path; sl@0: sl@0: z_path.Copy(KZDir); sl@0: z_path.Append(rsc_files[3]); sl@0: Test4L(z_path); sl@0: CreateFileFromL(c_path, rsc_files[3], z_path); sl@0: Test4L(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path)); sl@0: DeleteDataFile(c_path); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0484-0001 sl@0: @SYMTestCaseDesc Testing resource file signature present and not in order behaviour sl@0: @SYMTestPriority High sl@0: @SYMTestActions Wrapper function calling up Test5() function sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void SubTest5L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0484-0001 Testing resource file signature present and not in order behaviour ")); sl@0: TBuf<128> z_path; sl@0: TBuf<128> c_path; sl@0: sl@0: z_path.Copy(KZDir); sl@0: z_path.Append(rsc_files[0]); sl@0: Test5L(z_path); sl@0: CreateFileFromL(c_path, rsc_files[0], z_path); sl@0: Test5L(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path)); sl@0: DeleteDataFile(c_path); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0485-0001 sl@0: @SYMTestCaseDesc Testing resource file signature present and in order behaviour sl@0: @SYMTestPriority High sl@0: @SYMTestActions Wrapper function calling up Test6L() function sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void SubTest6L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0485-0001 Testing resource file signature present and in order behaviour ")); sl@0: TBuf<128> z_path; sl@0: TBuf<128> c_path; sl@0: sl@0: z_path.Copy(KZDir); sl@0: z_path.Append(rsc_files[1]); sl@0: Test6L(z_path); sl@0: CreateFileFromL(c_path, rsc_files[1], z_path); sl@0: Test6L(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path)); sl@0: DeleteDataFile(c_path); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0486-0001 sl@0: @SYMTestCaseDesc Testing invalid resource file sl@0: @SYMTestPriority High sl@0: @SYMTestActions Wrapper function calling up Test7L() function sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void SubTest7L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0486-0001 Testing invalid resource file ")); sl@0: TBuf<128> z_path; sl@0: TBuf<128> c_path; sl@0: sl@0: z_path.Copy(KZDir); sl@0: z_path.Append(rsc_files[4]); sl@0: Test7L(z_path); sl@0: CreateFileFromL(c_path, rsc_files[4], z_path); sl@0: Test7L(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path)); sl@0: DeleteDataFile(c_path); sl@0: } sl@0: sl@0: /** sl@0: This test is for measuring the performance improvements from sl@0: compressed resource file dictionary cache (added DEF044572) sl@0: sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0487-0001 sl@0: @SYMTestCaseDesc Tests for defect number Def044572L sl@0: @SYMTestPriority High sl@0: @SYMTestActions Attempt for measuring the performance improvements from compressed resource file dictionary cache sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDef044572L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0487-0001 ")); sl@0: // measure the time taken to run this test 10 times. sl@0: TTime startTime, stopTime; sl@0: startTime.UniversalTime(); sl@0: sl@0: // run the test 20 times to make the time easier to measure sl@0: for (TInt repeat=0;repeat<20;repeat++) sl@0: { sl@0: // SubTest3 which uses "Calypso ER5u format dictionary-compressed resource files" sl@0: SubTest3L(); sl@0: } sl@0: sl@0: // display the time taken sl@0: // for WINSCW this increase from 3.4 to 1.3 seconds when the sl@0: // compressed resource file dictionary cache was added DEF044572 sl@0: stopTime.UniversalTime(); sl@0: TTimeIntervalMicroSeconds timeTaken = stopTime.MicroSecondsFrom(startTime); sl@0: test.Printf(_L("Time taken for Subtest3:%d microseconds\n"), timeTaken.Int64() ); sl@0: } sl@0: sl@0: /** sl@0: This test checks reading resource files for memory leaks, sl@0: when running Out Of Memory.(added as part of DEF044572) sl@0: sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0488-0001 sl@0: @SYMTestCaseDesc Out of memory tests sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for memory leaks while reading resource files. sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void MemoryLeakTestL() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0488-0001 ")); sl@0: TInt ret = KErrNoMemory; sl@0: TInt pass = 1; sl@0: sl@0: __UHEAP_MARK; sl@0: // increasing the value of pass until the test completes with KErrNone sl@0: while (ret != KErrNone ) sl@0: { sl@0: // check that the test is failing with KErrNoMemory sl@0: test(ret==KErrNoMemory); sl@0: sl@0: __UHEAP_FAILNEXT(pass); sl@0: TRAP(ret, SubTest3L()); sl@0: __UHEAP_CHECK(0); sl@0: sl@0: pass++; sl@0: } sl@0: sl@0: // disable the heap fail sl@0: __UHEAP_RESET; sl@0: __UHEAP_MARKEND; sl@0: sl@0: } sl@0: sl@0: sl@0: LOCAL_C void DoE32MainL() sl@0: { sl@0: CleanupClosePushL(fileServerSession); sl@0: User::LeaveIfError(fileServerSession.Connect()); sl@0: sl@0: SubTest1L(); sl@0: SubTest2L(); sl@0: SubTest3L(); sl@0: SubTest4L(); sl@0: SubTest5L(); sl@0: SubTest6L(); sl@0: SubTest7L(); sl@0: TestDef044572L(); sl@0: MemoryLeakTestL(); sl@0: sl@0: CleanupStack::PopAndDestroy(1, &fileServerSession); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: CTrapCleanup* trapCleanup=CTrapCleanup::New(); sl@0: TRAPD(error, DoE32MainL()); sl@0: test(error == KErrNone); sl@0: test.Next(_L("/n")); sl@0: test.End(); sl@0: test.Close(); sl@0: delete trapCleanup; sl@0: __UHEAP_MARKEND; sl@0: return error; sl@0: } sl@0: