sl@0: // Copyright (c) 1997-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 "t_langutilsimp.h" sl@0: sl@0: sl@0: #define test(cond) \ sl@0: { \ sl@0: TBool __bb = (cond); \ sl@0: TEST(__bb); \ sl@0: if (!__bb) \ sl@0: { \ sl@0: ERR_PRINTF1(_L("ERROR: Test Failed")); \ sl@0: User::Leave(1); \ sl@0: } \ sl@0: } sl@0: sl@0: sl@0: sl@0: void CT_LANGUTILSIMP::TestPath(const TLanguagePath& aPath, const TLanguage* aExpected, TInt aExpectedCount) sl@0: { sl@0: for (int i = 0; i != aExpectedCount; ++i) sl@0: test(aPath[i] == *aExpected++); sl@0: test(aPath[aExpectedCount] == ELangNone); sl@0: } sl@0: sl@0: const TLanguage ExpectedPath[] = { ELangFrench, ELangJapanese, ELangGerman, ELangGreek, sl@0: ELangArabic, ELangEnglish, ELangItalian, ELangHebrew }; sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0443 sl@0: @SYMTestCaseDesc Tests TLanguagePath class sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for adding different language paths sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CT_LANGUTILSIMP::TestAddLanguage() sl@0: { sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0443 ")); sl@0: TLanguagePath path; sl@0: path[0] = ELangNone; sl@0: AddLanguage(path, ELangNone); sl@0: TestPath(path, ExpectedPath, 0); sl@0: AddLanguage(path, ELangFrench); sl@0: TestPath(path, ExpectedPath, 1); sl@0: AddLanguage(path, ELangFrench); sl@0: TestPath(path, ExpectedPath, 1); sl@0: AddLanguage(path, ELangNone); sl@0: TestPath(path, ExpectedPath, 1); sl@0: AddLanguage(path, ELangFrench); sl@0: TestPath(path, ExpectedPath, 1); sl@0: AddLanguage(path, ELangJapanese); sl@0: TestPath(path, ExpectedPath, 2); sl@0: AddLanguage(path, ELangFrench); sl@0: TestPath(path, ExpectedPath, 2); sl@0: AddLanguage(path, ELangNone); sl@0: TestPath(path, ExpectedPath, 2); sl@0: AddLanguage(path, ELangGerman); sl@0: TestPath(path, ExpectedPath, 3); sl@0: AddLanguage(path, ELangGreek); sl@0: TestPath(path, ExpectedPath, 4); sl@0: AddLanguage(path, ELangArabic); sl@0: TestPath(path, ExpectedPath, 5); sl@0: AddLanguage(path, ELangNone); sl@0: TestPath(path, ExpectedPath, 5); sl@0: AddLanguage(path, ELangEnglish); sl@0: TestPath(path, ExpectedPath, 6); sl@0: AddLanguage(path, ELangItalian); sl@0: TestPath(path, ExpectedPath, 7); sl@0: AddLanguage(path, ELangNone); sl@0: TestPath(path, ExpectedPath, 7); sl@0: AddLanguage(path, ELangHebrew); sl@0: TestPath(path, ExpectedPath, 8); sl@0: AddLanguage(path, ELangHebrew); sl@0: TestPath(path, ExpectedPath, 8); sl@0: AddLanguage(path, ELangEnglish); sl@0: TestPath(path, ExpectedPath, 8); sl@0: AddLanguage(path, ELangItalian); sl@0: TestPath(path, ExpectedPath, 8); sl@0: AddLanguage(path, ELangNone); sl@0: TestPath(path, ExpectedPath, 8); sl@0: AddLanguage(path, ELangFrench); sl@0: TestPath(path, ExpectedPath, 8); sl@0: AddLanguage(path, ELangNone); sl@0: TestPath(path, ExpectedPath, 8); sl@0: AddLanguage(path, ELangGerman); sl@0: TestPath(path, ExpectedPath, 8); sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0444 sl@0: @SYMTestCaseDesc Tests for the functionality of TLocale class sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for language downgrades sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CT_LANGUTILSIMP::TestDowngrade(SDowngradeTest& aTest) sl@0: { sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0444 ")); sl@0: TLocale loc; sl@0: loc.SetLanguageDowngrade(0, aTest.iIn[1]); sl@0: loc.SetLanguageDowngrade(1, aTest.iIn[2]); sl@0: loc.SetLanguageDowngrade(2, aTest.iIn[3]); sl@0: TLanguagePath path; sl@0: MakeLanguageDowngradePath(path, aTest.iIn[0], ELangNone, loc); sl@0: for (int i = 0; ; ++i) sl@0: { sl@0: test(i < 9); sl@0: test(aTest.iOut[i] == path[i]); sl@0: if (path[i] == ELangNone) sl@0: return; sl@0: } sl@0: sl@0: MakeLanguageDowngradePath(path, ELangAustralian, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangNewZealand, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangSouthAfricanEnglish, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangInternationalEnglish, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangAmerican, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangEnglish_Apac, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangEnglish_Taiwan, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangEnglish_HongKong, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangEnglish_Prc, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangEnglish_Japan, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangEnglish_Thailand, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangSwissFrench, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangBelgianFrench, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangInternationalFrench, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangCanadianFrench, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangSwissGerman, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangAustrian, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangInternationalSpanish, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangLatinAmericanSpanish, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangSwissItalian, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangFinlandSwedish, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangCyprusTurkish, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangBelgianFlemish, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangHongKongChinese, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangCyprusGreek, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangMalay_Apac, ELangNone, loc); sl@0: MakeLanguageDowngradePath(path, ELangBrazilianPortuguese, ELangNone, loc); sl@0: sl@0: } sl@0: sl@0: sl@0: // Test Dialect enumeration. sl@0: // Each value represents a dialect (variant) of a TLanguage language. sl@0: // E.g. AmericanSprint is represented by ELangAmerican | EDialectSprint sl@0: sl@0: // The dialect location -- top six bits sl@0: const TUint KDialectFactor=0x0400; sl@0: enum TDialect sl@0: { sl@0: // The following are example dialects for testing only sl@0: EDialectSprint = (1*KDialectFactor), sl@0: EDialectOrange = (2*KDialectFactor), sl@0: EDialectMaximum = EDialectOrange // This must always be equal to the last TDialect enum. sl@0: // Up to 63 dialects. sl@0: }; sl@0: sl@0: const TLanguage ELangEnglishOrange = static_cast(ELangEnglish|EDialectOrange); sl@0: const TLanguage ELangAmericanSprint = static_cast(ELangAmerican|EDialectSprint); sl@0: sl@0: SDowngradeTest DowngradeData[] = sl@0: { sl@0: // 0 = test language sl@0: // 1-3 = language downgrade for locale sl@0: // 4- = calculated language downgrade path, terminated with ELangNone. sl@0: {{ELangEnglishOrange, ELangNone, ELangNone, ELangNone}, sl@0: {ELangEnglishOrange, ELangEnglish, ELangNone}}, sl@0: {{ELangAmericanSprint, ELangNone, ELangNone, ELangNone}, sl@0: {ELangAmericanSprint, ELangAmerican, ELangEnglish, ELangNone}}, sl@0: {{ELangFrench, ELangNone, ELangNone, ELangNone}, sl@0: {ELangFrench, ELangNone}}, sl@0: {{ELangSwissFrench, ELangNone, ELangNone, ELangNone}, sl@0: {ELangSwissFrench, ELangFrench, ELangNone}}, sl@0: {{ELangCanadianEnglish, ELangNone, ELangNone, ELangNone}, sl@0: {ELangCanadianEnglish, ELangAmerican, ELangEnglish, ELangNone}}, sl@0: {{ELangSwissFrench, ELangNone, ELangFrench, ELangNone}, sl@0: {ELangSwissFrench, ELangFrench, ELangNone}}, sl@0: {{ELangCanadianEnglish, ELangEnglish, ELangNone, ELangAmerican}, sl@0: {ELangCanadianEnglish, ELangEnglish, ELangAmerican, ELangNone}}, sl@0: {{ELangCanadianEnglish, ELangNone, ELangNone, ELangSwissFrench}, sl@0: {ELangCanadianEnglish, ELangSwissFrench, ELangAmerican, ELangEnglish, ELangNone}}, sl@0: {{ELangCanadianEnglish, ELangFrench, ELangAmerican, ELangSwissFrench}, sl@0: {ELangCanadianEnglish, ELangFrench, ELangAmerican, ELangSwissFrench, ELangEnglish, ELangNone}}, sl@0: {{ELangCanadianEnglish, ELangNone, ELangGerman, ELangSwissFrench}, sl@0: {ELangCanadianEnglish, ELangGerman, ELangSwissFrench, ELangAmerican, ELangEnglish, ELangNone}}, sl@0: {{ELangCanadianEnglish, ELangFinlandSwedish, ELangGerman, ELangSwissFrench}, sl@0: {ELangCanadianEnglish, ELangFinlandSwedish, ELangGerman, ELangSwissFrench, ELangAmerican, ELangEnglish, ELangNone}}, sl@0: {{ELangFinlandSwedish, ELangFinlandSwedish, ELangFinlandSwedish, ELangFinlandSwedish}, sl@0: {ELangFinlandSwedish, ELangSwedish, ELangNone}}, sl@0: }; sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0445 sl@0: @SYMTestCaseDesc Tests for language downgrades sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call up downgrade path test function sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CT_LANGUTILSIMP::TestMakeLanguageDowngradePath() sl@0: { sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0445 ")); sl@0: for (int i = 0; i != sizeof(DowngradeData)/sizeof(DowngradeData[0]); ++i) sl@0: TestDowngrade(DowngradeData[i]); sl@0: } sl@0: sl@0: void CT_LANGUTILSIMP::SetUpFinderForLanguageAndDriveSearchL( sl@0: TTestNearestLanguageFileFinder& aFinder) sl@0: { sl@0: aFinder.iDrives = _L("ZAG"); sl@0: aFinder.iFilesSearchedFor = new(ELeave) CDesCArraySeg(10); sl@0: aFinder.iFilesSearchedFor->AppendL(_L("z:\\dir\\name.e02")); sl@0: aFinder.iFilesSearchedFor->AppendL(_L("a:\\dir\\name.e02")); sl@0: aFinder.iFilesSearchedFor->AppendL(_L("g:\\dir\\name.e02")); sl@0: aFinder.iFilesSearchedFor->AppendL(_L("z:\\dir\\name.e15702")); //Extended lang sl@0: aFinder.iFilesSearchedFor->AppendL(_L("a:\\dir\\name.e15702")); sl@0: aFinder.iFilesSearchedFor->AppendL(_L("g:\\dir\\name.e15702")); sl@0: aFinder.iFilesSearchedFor->AppendL(_L("z:\\dir\\name.e01")); sl@0: aFinder.iFilesSearchedFor->AppendL(_L("a:\\dir\\name.e01")); sl@0: aFinder.iFilesSearchedFor->AppendL(_L("g:\\dir\\name.e01")); sl@0: aFinder.iFilesSearchedFor->AppendL(_L("z:\\dir\\name.ext")); sl@0: aFinder.iFilesSearchedFor->AppendL(_L("a:\\dir\\name.ext")); sl@0: aFinder.iFilesSearchedFor->AppendL(_L("g:\\dir\\name.ext")); sl@0: aFinder.iDrivesChecked = _L("zagzagzagzagzag"); sl@0: } sl@0: sl@0: _LIT(KTestFileName1, "z:\\dir\\name.ext"); sl@0: //_LIT(KTestFileName2, "z:\\dir\\náme.ext"); sl@0: _LIT(KTestFileName2, "z:\\dir\\n\u00c1me.ext"); sl@0: _LIT(KTestFileName3, "a:\\dir\\name.ext"); sl@0: _LIT(KTestFileName4, "c:\\dir\\name.ext"); sl@0: _LIT(KTestFileName5, "d:\\dir\\name.ext"); sl@0: _LIT(KTestFileName6, "y:\\dir\\name.ext"); sl@0: _LIT(KTestFileName7, "A:\\dir\\name.ext"); sl@0: _LIT(KTestFileName8, "C:\\dir\\name.ext"); sl@0: _LIT(KTestFileName9, "Y:\\dir\\name.ext"); sl@0: _LIT(KTestFileName11, "\\abc\\defg.hijkl"); sl@0: _LIT(KTestFileName256Chars, "\ sl@0: \\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz01234\ sl@0: \\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz01234\ sl@0: \\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz01234\ sl@0: \\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz0.ext"); sl@0: sl@0: _LIT(KExpectedFileName256Chars, "?:\ sl@0: \\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz01234\ sl@0: \\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz01234\ sl@0: \\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz01234\ sl@0: \\abcdefghijklmnopqrstuvwxyz01234\\abcdefghijklmnopqrstuvwxyz0.e"); sl@0: _LIT(KExpectedFileName1, "?:\\dir\\name.e"); sl@0: _LIT(KExpectedSuffix1, "xt"); sl@0: _LIT(KExpectedFileName2, "?:\\abc\\defg.hij"); sl@0: _LIT(KExpectedSuffix2, "kl"); sl@0: _LIT(KTestFileName1French, "z:\\dir\\name.e02"); sl@0: _LIT(KTestFileName1Japanese, "z:\\dir\\name.e32"); sl@0: _LIT(KTestFileName1Mongolian, "z:\\dir\\name.e54321"); sl@0: _LIT(KTestFileName1AmericanSprint, "z:\\dir\\name.e1034"); //American=0x0A, Sprint=0x0400. 0x040A=1034. sl@0: _LIT(KCheckedForFrench, "?:\\dir\\name.e02"); sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0446 sl@0: @SYMTestCaseDesc Nearest language finder test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test drive sequence construction sl@0: Test addition of language number sl@0: Test searching each drive for the specified file sl@0: Test searching language and drive down the language path sl@0: Test filename matching sl@0: Test searching for any language file within a drive sl@0: Test searching all drives for any language sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void CT_LANGUTILSIMP::TestNearestLanguageFinder() sl@0: { sl@0: INFO_PRINTF1(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0446 ")); sl@0: RFs dummy; sl@0: TTestNearestLanguageFileFinder finder(dummy); sl@0: sl@0: // Test file name setting and disecting sl@0: // SetFileName sl@0: // RepairFileName sl@0: TFileName fileName(KTestFileName1); sl@0: finder.SetFileName(fileName); sl@0: test(0 <= finder.iFileName->MatchF(KExpectedFileName1)); sl@0: test(0 == finder.iSuffix.Compare(KExpectedSuffix1)); sl@0: test('z' == finder.iInitialDriveLetter); sl@0: finder.RepairFileName(); sl@0: test(0 == finder.iFileName->Compare(KTestFileName1)); sl@0: fileName = KTestFileName11; sl@0: finder.SetFileName(fileName); sl@0: test(0 <= finder.iFileName->MatchF(KExpectedFileName2)); sl@0: test(0 == finder.iSuffix.Compare(KExpectedSuffix2)); sl@0: test(-1 == finder.iInitialDriveLetter); sl@0: finder.RepairFileName(); sl@0: test(0 == finder.iFileName->Compare(KTestFileName11)); sl@0: fileName = KTestFileName256Chars; sl@0: finder.SetFileName(fileName); sl@0: test(0 <= finder.iFileName->MatchF(KExpectedFileName256Chars)); sl@0: test(0 == finder.iSuffix.Compare(KExpectedSuffix1)); sl@0: test(-1 == finder.iInitialDriveLetter); sl@0: finder.RepairFileName(); sl@0: test(0 == finder.iFileName->Compare(KTestFileName256Chars)); sl@0: sl@0: // Test drive sequence construction sl@0: // AddCustomResourceDrive sl@0: finder.iCustomRscDrive = static_cast(EDriveC); // drive c: sl@0: fileName = KTestFileName1; sl@0: finder.SetFileName(fileName); sl@0: test(finder.AddCustomResourceDrive() == KErrNone); sl@0: test(0 == finder.iDrives.CompareF(_L("CZ"))); sl@0: fileName = KTestFileName3; sl@0: finder.SetFileName(fileName); sl@0: test(finder.AddCustomResourceDrive() == KErrNone); sl@0: test(0 == finder.iDrives.CompareF(_L("CA"))); sl@0: fileName = KTestFileName4; sl@0: finder.SetFileName(fileName); sl@0: test(finder.AddCustomResourceDrive() == KErrAlreadyExists); sl@0: test(0 == finder.iDrives.CompareF(_L("C"))); sl@0: fileName = KTestFileName5; sl@0: finder.SetFileName(fileName); sl@0: test(finder.AddCustomResourceDrive() == KErrNone); sl@0: test(0 == finder.iDrives.CompareF(_L("CD"))); sl@0: fileName = KTestFileName6; sl@0: finder.SetFileName(fileName); sl@0: test(finder.AddCustomResourceDrive() == KErrNone); sl@0: test(0 == finder.iDrives.CompareF(_L("CY"))); sl@0: fileName = KTestFileName7; sl@0: finder.SetFileName(fileName); sl@0: test(finder.AddCustomResourceDrive() == KErrNone); sl@0: test(0 == finder.iDrives.CompareF(_L("CA"))); sl@0: fileName = KTestFileName8; sl@0: finder.SetFileName(fileName); sl@0: test(finder.AddCustomResourceDrive() == KErrAlreadyExists); sl@0: test(0 == finder.iDrives.CompareF(_L("C"))); sl@0: fileName = KTestFileName9; sl@0: finder.SetFileName(fileName); sl@0: test(finder.AddCustomResourceDrive() == KErrNone); sl@0: test(0 == finder.iDrives.CompareF(_L("CY"))); sl@0: // AddAllDrives sl@0: fileName = KTestFileName1; sl@0: finder.SetFileName(fileName); sl@0: finder.AddAllDrives(); sl@0: test(0 == finder.iDrives.CompareF(_L("ZYXWVUTSRQPONMLKJIHGFEDCBA"))); sl@0: fileName = KTestFileName3; sl@0: finder.SetFileName(fileName); sl@0: finder.AddAllDrives(); sl@0: test(0 == finder.iDrives.CompareF(_L("AYXWVUTSRQPONMLKJIHGFEDCBZ"))); sl@0: fileName = KTestFileName4; sl@0: finder.SetFileName(fileName); sl@0: finder.AddAllDrives(); sl@0: test(0 == finder.iDrives.CompareF(_L("CYXWVUTSRQPONMLKJIHGFEDBAZ"))); sl@0: fileName = KTestFileName5; sl@0: finder.SetFileName(fileName); sl@0: finder.AddAllDrives(); sl@0: test(0 == finder.iDrives.CompareF(_L("DYXWVUTSRQPONMLKJIHGFECBAZ"))); sl@0: fileName = KTestFileName6; sl@0: finder.SetFileName(fileName); sl@0: finder.AddAllDrives(); sl@0: test(0 == finder.iDrives.CompareF(_L("YXWVUTSRQPONMLKJIHGFEDCBAZ"))); sl@0: fileName = KTestFileName7; sl@0: finder.SetFileName(fileName); sl@0: finder.AddAllDrives(); sl@0: test(0 == finder.iDrives.CompareF(_L("AYXWVUTSRQPONMLKJIHGFEDCBZ"))); sl@0: fileName = KTestFileName8; sl@0: finder.SetFileName(fileName); sl@0: finder.AddAllDrives(); sl@0: test(0 == finder.iDrives.CompareF(_L("CYXWVUTSRQPONMLKJIHGFEDBAZ"))); sl@0: fileName = KTestFileName9; sl@0: finder.SetFileName(fileName); sl@0: finder.AddAllDrives(); sl@0: test(0 == finder.iDrives.CompareF(_L("YXWVUTSRQPONMLKJIHGFEDCBAZ"))); sl@0: sl@0: // Test addition of language number sl@0: // AppendLanguageCode sl@0: fileName = KTestFileName1; sl@0: finder.SetFileName(fileName); sl@0: finder.AppendLanguageCode(ELangFrench); sl@0: test(0 == finder.iFileName->CompareF(KTestFileName1French)); sl@0: finder.SetFileName(fileName); sl@0: finder.AppendLanguageCode(ELangJapanese); sl@0: test(0 == finder.iFileName->CompareF(KTestFileName1Japanese)); sl@0: finder.SetFileName(fileName); sl@0: finder.AppendLanguageCode(ELangAmericanSprint); sl@0: test(0 == finder.iFileName->CompareF(KTestFileName1AmericanSprint)); sl@0: sl@0: fileName = KTestFileName1; sl@0: finder.SetFileName(fileName); sl@0: finder.AppendLanguageCode(static_cast(54321)); sl@0: test(0 == finder.iFileName->CompareF(KTestFileName1Mongolian)); sl@0: fileName = KTestFileName256Chars; sl@0: finder.SetFileName(fileName); sl@0: test(!finder.AppendLanguageCode(ELangFrench)); sl@0: sl@0: // Test searching each drive for the specified file sl@0: // FindDrive sl@0: finder.iFileCheckedFor = KCheckedForFrench; sl@0: finder.iDrivesChecked = _L("D"); sl@0: fileName = KTestFileName5; sl@0: finder.SetFileName(fileName); sl@0: finder.AppendLanguageCode(ELangFrench); sl@0: finder.FindDrive(); sl@0: test(finder.iDrivesChecked.Length() == 0); sl@0: finder.SetFileName(fileName); sl@0: finder.AddAllDrives(); sl@0: finder.iDrivesChecked = _L("dyxwvutsrqponmlkjihgfecbaz"); sl@0: finder.AppendLanguageCode(ELangFrench); sl@0: finder.FindDrive(); sl@0: test(finder.iDrivesChecked.Length() == 0); sl@0: fileName = KTestFileName5; sl@0: finder.SetFileName(fileName); sl@0: finder.AddAllDrives(); sl@0: finder.iDrivesChecked = _L("dyxwvutsrqponmlkjihgfecbaz"); sl@0: finder.AppendLanguageCode(ELangFrench); sl@0: finder.iFilesThatExist = new (ELeave) CDesCArraySeg(10); sl@0: finder.iFilesThatExist->AppendL(_L("o:\\dIR\\NAmE.E02")); sl@0: test(finder.FindDrive()); sl@0: test(0 == finder.iFileName->CompareF(_L("O:\\dir\\name.e02"))); sl@0: fileName = KTestFileName2; sl@0: finder.SetFileName(fileName); sl@0: finder.AppendLanguageCode(ELangFrench); sl@0: finder.AddAllDrives(); sl@0: finder.iDrivesChecked = _L("zyxwvutsrqponmlkjihgfedcba"); sl@0: finder.iFilesThatExist->AppendL(_L("v:\\dIR\\NA\x301mE.E02")); sl@0: //finder.iFileCheckedFor = _L("?:\\dir\\nÁme.e02"); sl@0: finder.iFileCheckedFor = _L("?:\\dir\\n\u00c1me.e02"); sl@0: test(finder.FindDrive()); sl@0: //test(0 == finder.iFileName->CompareF(_L("v:\\dir\\nÁme.e02"))); sl@0: test(0 == finder.iFileName->CompareF(_L("v:\\dir\\n\u00c1me.e02"))); sl@0: delete finder.iFilesThatExist; sl@0: finder.iFilesThatExist = 0; sl@0: sl@0: // Test searching language and drive down the language path sl@0: // FindLanguageAndDrive sl@0: finder.iPath[0] = static_cast(2); sl@0: finder.iPath[1] = static_cast(15702); sl@0: finder.iPath[2] = static_cast(1); sl@0: finder.iPath[3] = ELangNone; sl@0: fileName = KTestFileName1; sl@0: finder.SetFileName(fileName); sl@0: SetUpFinderForLanguageAndDriveSearchL(finder); sl@0: finder.iFileCheckedFor = _L("?:\\dir\\name.e*"); sl@0: test(!finder.FindLanguageAndDrive()); sl@0: // check that iFileName is undamaged sl@0: finder.RepairFileName(); sl@0: test(0 == finder.iFileName->CompareF(KTestFileName1)); sl@0: delete finder.iFilesSearchedFor; sl@0: finder.iFilesThatExist = new (ELeave) CDesCArraySeg(10); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.e15702")); sl@0: fileName = KTestFileName1; sl@0: finder.SetFileName(fileName); sl@0: SetUpFinderForLanguageAndDriveSearchL(finder); sl@0: test(finder.FindLanguageAndDrive()); sl@0: test(0 == finder.iFileName->CompareF(_L("a:\\dir\\name.e15702"))); sl@0: delete finder.iFilesSearchedFor; sl@0: finder.iFilesSearchedFor = 0; sl@0: sl@0: finder.iPath[0] = static_cast(7); sl@0: finder.iPath[1] = ELangNone; sl@0: finder.iFilesThatExist->AppendL(_L("g:\\dir\\name.ext")); sl@0: fileName = KTestFileName1; sl@0: finder.SetFileName(fileName); sl@0: finder.iDrives = _L("ZAG"); sl@0: finder.iDrivesChecked = _L("ZAGZAG"); sl@0: test(finder.FindLanguageAndDrive()); sl@0: test(0 == finder.iFileName->CompareF(_L("g:\\dir\\name.ext"))); sl@0: delete finder.iFilesThatExist; sl@0: finder.iFilesThatExist = 0; sl@0: sl@0: // Test filename matching sl@0: // LanguageNumberFromFile sl@0: test(4 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb04"), _L("AVB"))); sl@0: //test(4 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("ávb04"), _L("A\x301VB"))); sl@0: //test(4 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("a\x301vb04"), _L("ÁVB"))); sl@0: test(4 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("\u00e1vb04"), _L("A\x301VB"))); sl@0: test(4 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("a\x301vb04"), _L("\u00c1VB"))); sl@0: test(5254 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb5254"), _L("aVb"))); sl@0: test(KErrNotFound == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb04"), _L("avb04"))); sl@0: test(KErrNotFound == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb04"), _L("av"))); sl@0: test(KErrNotFound == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb04"), _L(""))); sl@0: test(0 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb0000000"), _L("AVB00000"))); sl@0: test(4 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb000000004"), _L("AVB0000000"))); sl@0: test(100004 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb000100004"), _L("AVB000"))); sl@0: test(111114 == TNearestLanguageFileFinder::LanguageNumberFromFile(_L("avb0111114"), _L("AVB0"))); sl@0: sl@0: // Test searching for any language file within a drive sl@0: // FindFirstLanguageFile sl@0: fileName = KTestFileName3; sl@0: finder.SetFileName(fileName); sl@0: finder.iFilesThatExist = new (ELeave) CDesCArraySeg(10); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.e107")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.e07")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.e02")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.ee01")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.01")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\dir\\name01")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\dir\\name01.e01")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.e15108")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\dir\\name.e03")); sl@0: finder.iTestScanner.iDriveError[0] = KErrNoMemory; sl@0: fileName = KTestFileName3; sl@0: finder.SetFileName(fileName); sl@0: test(KErrNotFound == finder.FindFirstLanguageFile(dummy)); sl@0: finder.iTestScanner.iDriveError[0] = KErrAbort; sl@0: fileName = KTestFileName3; sl@0: finder.SetFileName(fileName); sl@0: test(KErrNotFound == finder.FindFirstLanguageFile(dummy)); sl@0: finder.iTestScanner.iDriveError[0] = KErrNone; sl@0: fileName = KTestFileName3; sl@0: finder.SetFileName(fileName); sl@0: test(0 <= finder.FindFirstLanguageFile(dummy)); sl@0: test(0 == finder.iFileName->CompareF(_L("a:\\dir\\name.e02"))); sl@0: sl@0: finder.iFilesThatExist->AppendL(_L("a:\\abaffafg.100")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\abcdefg.9539")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\abcdefg.19539")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\abcdefg.1000")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\abaffafg.102")); sl@0: fileName = _L("a:\\abcdefg.xx"); sl@0: finder.SetFileName(fileName); sl@0: test(0 <= finder.FindFirstLanguageFile(dummy)); sl@0: test(0 == finder.iFileName->CompareF(_L("a:\\abcdefg.1000"))); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\abaffafg.aaa100")); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\abcdefg.0523")); // not well-formed. Will not count. sl@0: finder.iFilesThatExist->AppendL(_L("a:\\abcdefg.1001")); sl@0: fileName = _L("a:\\abcdefg.xx"); sl@0: finder.SetFileName(fileName); sl@0: test(0 <= finder.FindFirstLanguageFile(dummy)); sl@0: test(0 == finder.iFileName->CompareF(_L("a:\\abcdefg.1000"))); sl@0: fileName = _L("a:\\abaffafg.xx"); sl@0: finder.SetFileName(fileName); sl@0: test(0 <= finder.FindFirstLanguageFile(dummy)); sl@0: test(0 == finder.iFileName->CompareF(_L("a:\\abaffafg.100"))); sl@0: finder.iFilesThatExist->AppendL(_L("a:\\abaffafg.09")); sl@0: fileName = _L("a:\\abaffafg.xx"); sl@0: finder.SetFileName(fileName); sl@0: test(0 <= finder.FindFirstLanguageFile(dummy)); sl@0: test(0 == finder.iFileName->CompareF(_L("a:\\abaffafg.09"))); sl@0: sl@0: // Test searching all drives for any language sl@0: // FindFirstLanguageFileAndDrive sl@0: finder.iFilesThatExist->AppendL(_L("z:\\abcdefg.05")); sl@0: fileName = _L("c:\\abcdefg.xx"); sl@0: finder.SetFileName(fileName); sl@0: finder.iDrives = _L("az"); sl@0: test(0 <= finder.FindFirstLanguageFileAndDrive()); sl@0: test(0 == finder.iFileName->CompareF(_L("a:\\abcdefg.1000"))); sl@0: fileName = _L("c:\\abaffafg.xx"); sl@0: finder.SetFileName(fileName); sl@0: finder.iDrives = _L("az"); sl@0: test(0 <= finder.FindFirstLanguageFileAndDrive()); sl@0: test(0 == finder.iFileName->CompareF(_L("a:\\abaffafg.09"))); sl@0: fileName = _L("c:\\abcdefg.xx"); sl@0: finder.SetFileName(fileName); sl@0: finder.iDrives = _L("za"); sl@0: test(0 <= finder.FindFirstLanguageFileAndDrive()); sl@0: test(0 == finder.iFileName->CompareF(_L("z:\\abcdefg.05"))); sl@0: fileName = _L("c:\\xxx.xx"); sl@0: finder.SetFileName(fileName); sl@0: finder.iDrives = _L("za"); sl@0: test(KErrNotFound == finder.FindFirstLanguageFileAndDrive()); sl@0: finder.iTestScanner.iDriveError[25] = KErrAbort; sl@0: fileName = _L("c:\\abcdefg.xx"); sl@0: finder.SetFileName(fileName); sl@0: finder.iDrives = _L("za"); sl@0: test(0 <= finder.FindFirstLanguageFileAndDrive()); sl@0: test(0 == finder.iFileName->CompareF(_L("a:\\abcdefg.1000"))); sl@0: fileName = _L("c:\\abcdefg.xx"); sl@0: finder.SetFileName(fileName); sl@0: finder.iDrives = _L("za"); sl@0: finder.iTestScanner.iDriveError[0] = KErrNoMemory; sl@0: test(KErrNotFound == finder.FindFirstLanguageFileAndDrive()); sl@0: fileName = _L("c:\\abcdefg.xx"); sl@0: finder.SetFileName(fileName); sl@0: finder.iDrives = _L("za"); sl@0: finder.iTestScanner.iDriveError[0] = KErrAbort; sl@0: test(KErrNotFound == finder.FindFirstLanguageFileAndDrive()); sl@0: sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: void CT_LANGUTILSIMP::TestLANGUTILSIMP() sl@0: { sl@0: __UHEAP_MARK; sl@0: sl@0: INFO_PRINTF1(_L("LangUtils Internal Tests: ")); sl@0: sl@0: TestAddLanguage(); sl@0: TestMakeLanguageDowngradePath(); sl@0: TestNearestLanguageFinder(); sl@0: sl@0: sl@0: sl@0: __UHEAP_MARKENDC(0); sl@0: } sl@0: sl@0: CT_LANGUTILSIMP::CT_LANGUTILSIMP() sl@0: { sl@0: SetTestStepName(KTestStep_T_LANGUTILSIMP); sl@0: } sl@0: sl@0: TVerdict CT_LANGUTILSIMP::doTestStepL() sl@0: { sl@0: SetTestStepResult(EFail); sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TRAPD(error1, TestLANGUTILSIMP()); sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: if(error1 == KErrNone ) sl@0: { sl@0: SetTestStepResult(EPass); sl@0: } sl@0: sl@0: return TestStepResult(); sl@0: } sl@0: