sl@0: // Copyright (c) 2001-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_COMPRESSION"); 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: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0451 sl@0: @SYMTestCaseDesc RResourceReader class functionality test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for reading descriptors,integers sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void Test1(const TDesC& aResourceFileName, TUint aFileOffset = 0, TInt aFileSize = 0) sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0451 ")); sl@0: RResourceFile resourceFile; sl@0: CleanupClosePushL(resourceFile); sl@0: resourceFile.OpenL(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; sl@0: TResourceReader 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: sl@0: resource=resourceFile.AllocReadLC(2); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint16()==4); sl@0: test(resourceReader.ReadTPtrC()==_L("Bonjour")); sl@0: test(resourceReader.ReadTPtrC()==_L("Ni3 hao3")); sl@0: test(resourceReader.ReadTPtrC()==_L("Konnichiwa")); sl@0: test(resourceReader.ReadTPtrC()==_L("Zdravstvuit'e")); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(3); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint16()==3); sl@0: test(resourceReader.ReadTPtrC()==_L("Gamarjoba")); sl@0: test(resourceReader.ReadTPtrC()==_L("Gasou")); sl@0: test(resourceReader.ReadTPtrC()==_L("Ola")); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(4); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint16()==3); sl@0: test(resourceReader.ReadUint8()==0xbd); sl@0: test(resourceReader.ReadUint8()==0x5e); sl@0: test(resourceReader.ReadUint8()==0xf1); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(5); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint32()==4); sl@0: test(resourceReader.ReadUint32()==T_COMPRESSED_UNICODE_1_RESOURCE_5); sl@0: CleanupStack::PopAndDestroy(resource); 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: sl@0: resource=resourceFile.AllocReadLC(7); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint8()==9); sl@0: test(resourceReader.ReadTPtrC()==_L("To")); sl@0: test(resourceReader.ReadUint8()==97); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(8); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint16()==999); sl@0: test(resourceReader.ReadTPtrC()==_L("To")); sl@0: test(resourceReader.ReadUint8()==79); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(9); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint16()==53132); sl@0: test(resourceReader.ReadTPtrC()==_L("T")); sl@0: test(resourceReader.ReadUint8()==62); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(10); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadInt32()==1253869); sl@0: test(resourceReader.ReadInt32()==-986324); sl@0: test(resourceReader.ReadUint32()==0x600ddea1u); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: CleanupStack::PopAndDestroy(&resourceFile); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0452 sl@0: @SYMTestCaseDesc RResourceReader class test sl@0: Tests for RResourceReader::UidType() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for reading compressed unicode sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void Test2(const TDesC& aResourceFileName, TUid aFirstUid, TUint aFileOffset = 0, TInt aFileSize = 0) sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0452 ")); sl@0: RResourceFile resourceFile; sl@0: CleanupClosePushL(resourceFile); sl@0: resourceFile.OpenL(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; sl@0: TResourceReader resourceReader; sl@0: sl@0: resource=resourceFile.AllocReadLC(1); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint32()==4); sl@0: test(resourceReader.ReadUint32()==T_COMPRESSED_UNICODE_2_RESOURCE_1); sl@0: CleanupStack::PopAndDestroy(resource); 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: 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: sl@0: resource=resourceFile.AllocReadLC(4); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadInt32()==9174804); sl@0: test(resourceReader.ReadUint8()==6); sl@0: test(resourceReader.ReadInt32()==-6208493); sl@0: test(resourceReader.ReadUint16()==0x3176); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(5); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadInt32()==-120727); sl@0: test(resourceReader.ReadInt32()==-82385253); sl@0: test(resourceReader.ReadUint16()==0x3176); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(6); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint8()==2); sl@0: test(resourceReader.ReadTPtrC()==_L("z:\\system\\data\\uikon.mbm")); sl@0: test(resourceReader.ReadTPtrC()==_L("z:\\system\\apps\\my_program\\my_program.mbm")); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: CleanupStack::PopAndDestroy(&resourceFile); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0453 sl@0: @SYMTestCaseDesc RResourceReader class test sl@0: Tests the calypso resource file format for loading and reading sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for reading calypso resource file format sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void Test3(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: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0453 ")); sl@0: RResourceFile resourceFile; sl@0: CleanupClosePushL(resourceFile); sl@0: resourceFile.OpenL(fileServerSession, aResourceFileName, aFileOffset, aFileSize); sl@0: HBufC8* resource; sl@0: TResourceReader 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: sl@0: resource=resourceFile.AllocReadLC(2); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint16()==4); sl@0: test(resourceReader.ReadTPtrC()==_L("Bonjour")); sl@0: test(resourceReader.ReadTPtrC()==_L("Ni3 hao3")); sl@0: test(resourceReader.ReadTPtrC()==_L("Konnichiwa")); sl@0: test(resourceReader.ReadTPtrC()==_L("Zdravstvuit'e")); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(3); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint16()==3); sl@0: test(resourceReader.ReadTPtrC()==_L("Gamarjoba")); sl@0: test(resourceReader.ReadTPtrC()==_L("Gasou")); sl@0: test(resourceReader.ReadTPtrC()==_L("Ola")); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(4); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint16()==3); sl@0: test(resourceReader.ReadUint8()==0xbd); sl@0: test(resourceReader.ReadUint8()==0x5e); sl@0: test(resourceReader.ReadUint8()==0xf1); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(5); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint32()==4); sl@0: test(resourceReader.ReadUint32()==T_COMPRESSED_UNICODE_1_RESOURCE_5); sl@0: CleanupStack::PopAndDestroy(resource); 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: sl@0: resource=resourceFile.AllocReadLC(7); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint8()==9); sl@0: test(resourceReader.ReadTPtrC()==_L("To")); sl@0: test(resourceReader.ReadUint8()==97); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(8); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint16()==999); sl@0: test(resourceReader.ReadTPtrC()==_L("To")); sl@0: test(resourceReader.ReadUint8()==79); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(9); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadUint16()==53132); sl@0: test(resourceReader.ReadTPtrC()==_L("T")); sl@0: test(resourceReader.ReadUint8()==62); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: resource=resourceFile.AllocReadLC(10); sl@0: resourceReader.SetBuffer(resource); sl@0: test(resourceReader.ReadInt32()==1253869); sl@0: test(resourceReader.ReadInt32()==-986324); sl@0: test(resourceReader.ReadUint32()==0x600ddea1u); sl@0: CleanupStack::PopAndDestroy(resource); sl@0: sl@0: CleanupStack::PopAndDestroy(&resourceFile); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0454 sl@0: @SYMTestCaseDesc Tests for reading calypso resource file for signature. sl@0: Calypso resource files do not have signatures. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for RResourceFile::ConfirmSignatureL() function sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void Test4(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: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0454 ")); sl@0: RResourceFile resourceFile; sl@0: CleanupClosePushL(resourceFile); sl@0: resourceFile.OpenL(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: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0456 sl@0: @SYMTestCaseDesc Tests the behaviour of BAFL when reading a resource file for a signature. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for reading a resource file for signature. sl@0: In this case the signature is present and is NOT the first resource. sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void Test5(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: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0456 ")); sl@0: RResourceFile resourceFile; sl@0: CleanupClosePushL(resourceFile); sl@0: resourceFile.OpenL(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: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0457 sl@0: @SYMTestCaseDesc Tests the behaviour of BAFL when reading a resource file for a signature. sl@0: The signature is present and is the first resource. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for RResourceFile::ConfirmSignatureL() function sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void Test6(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: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0457 ")); sl@0: RResourceFile resourceFile; sl@0: CleanupClosePushL(resourceFile); sl@0: resourceFile.OpenL(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: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0458 sl@0: @SYMTestCaseDesc Tests the behaviour of BAFL when reading a non resource file sl@0: @SYMTestPriority High sl@0: @SYMTestActions Attempt to open a non resource file. sl@0: @SYMTestExpectedResults Tests must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void Test7(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: sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0458 ")); sl@0: RResourceFile resourceFile; sl@0: CleanupClosePushL(resourceFile); 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: sl@0: TRAP(err, resourceFile.OpenL(fileServerSession, aResourceFileName, aFileOffset, aFileSize)); sl@0: test(err != KErrNotFound && err != KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(&resourceFile); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0459 sl@0: @SYMTestCaseDesc Tests resource files containing Unicode-compressed text sl@0: @SYMTestPriority High sl@0: @SYMTestActions Calls up Test1() and Test2() functions sl@0: @SYMTestExpectedResults Test 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-0459 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: Test1(z_path); sl@0: CreateFileFromL(c_path, rsc_files[0], z_path); sl@0: Test1(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: Test2(z_path, TUid::Uid(0x101f4a6b)); sl@0: CreateFileFromL(c_path, rsc_files[1], z_path); sl@0: Test2(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-0460 sl@0: @SYMTestCaseDesc Tests for dictionary-compressed resource files sl@0: @SYMTestPriority High sl@0: @SYMTestActions Check by reading the dictionary-compressed resource files sl@0: @SYMTestExpectedResults Test 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-0460 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: Test2(z_path, TUid::Uid(0x101f5010)); sl@0: CreateFileFromL(c_path, rsc_files[2], z_path); sl@0: Test2(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-0461 sl@0: @SYMTestCaseDesc Tests for reading the Calypso ER5u format dictionary-compressed resource files sl@0: @SYMTestPriority High sl@0: @SYMTestActions Wrapper function calling up Test3() function sl@0: @SYMTestExpectedResults Test 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-0461 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: sl@0: Test3(z_path); sl@0: CreateFileFromL(c_path, rsc_files[3], z_path); sl@0: Test3(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: Test3(z_path, FileSizeL(KRomResourceFileHeader), FileSizeL(z_path) - FileSizeL(KRomResourceFileHeader)); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0462 sl@0: @SYMTestCaseDesc Tests for resource file missing signature behaviour sl@0: @SYMTestPriority High sl@0: @SYMTestActions Wrapper function calling up Test4() function sl@0: @SYMTestExpectedResults Test 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-0462 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: sl@0: Test4(z_path); sl@0: CreateFileFromL(c_path, rsc_files[3], z_path); sl@0: Test4(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path)); sl@0: DeleteDataFile(c_path); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0463 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 Test 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-0463 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: sl@0: Test5(z_path); sl@0: CreateFileFromL(c_path, rsc_files[0], z_path); sl@0: Test5(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path)); sl@0: DeleteDataFile(c_path); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0464 sl@0: @SYMTestCaseDesc Tests for resource file signature and in order behaviour sl@0: @SYMTestPriority High sl@0: @SYMTestActions Wrapper function calling up Test6() function sl@0: @SYMTestExpectedResults Test 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-0464 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: sl@0: Test6(z_path); sl@0: CreateFileFromL(c_path, rsc_files[1], z_path); sl@0: Test6(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path)); sl@0: DeleteDataFile(c_path); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0465 sl@0: @SYMTestCaseDesc Tests for invalid resource file sl@0: @SYMTestPriority High sl@0: @SYMTestActions Wrapper function calling up Test7() function sl@0: @SYMTestExpectedResults Test 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-0465 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: sl@0: Test7(z_path); sl@0: CreateFileFromL(c_path, rsc_files[4], z_path); sl@0: Test7(c_path, KRscFileHeaderData().Length(), FileSizeL(z_path)); sl@0: DeleteDataFile(c_path); 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: 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: