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: // Tests some code internal to BaflUtils sl@0: // sl@0: // sl@0: sl@0: #include "BaUtilsImp.h" sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #define UNUSED_VAR(a) a = a sl@0: sl@0: const TPtrC KValFolderName=_L("ValidFolderName"); sl@0: const TPtrC KCurrentPath=_L("C:\\System\\Data\\"); sl@0: const TPtrC KNoFolderName = _L(""); sl@0: const TPtrC KInValidFolderName=_L("C:\\System\\Data\\InValid3+FollderName"); sl@0: sl@0: namespace sl@0: { sl@0: CTrapCleanup* TrapCleanup; sl@0: RTest test(_L("T_BaflUtilsImp - Internal Bafl function tests")); sl@0: } sl@0: sl@0: class RTestDirectoryScanner : public RDirectoryScanner sl@0: { sl@0: public: sl@0: RTestDirectoryScanner(CDesCArray*& aMember) sl@0: : iOpenError(0), iFilesThatExist(aMember) sl@0: { sl@0: for (TInt i = 0; i != 26; ++i) sl@0: iDriveError[i] = 0; sl@0: } sl@0: virtual TInt Open(RFs&, const TDesC& aMatchPattern) sl@0: { sl@0: iMatch = aMatchPattern; sl@0: iIndex = 0; sl@0: return iOpenError; sl@0: } sl@0: virtual TInt Next(TEntry& aOut) sl@0: { sl@0: if (!iFilesThatExist) sl@0: return KErrEof; sl@0: while (iIndex < iFilesThatExist->Count()) sl@0: { sl@0: TInt i = iIndex++; sl@0: if (0 <= (*iFilesThatExist)[i].MatchF(iMatch)) sl@0: { sl@0: TPtrC fullName=(*iFilesThatExist)[i]; sl@0: TParsePtrC name(fullName); sl@0: aOut.iName=name.NameAndExt(); sl@0: if (1 < fullName.Length() && fullName[1] == ':') sl@0: { sl@0: TInt drive = fullName[0]; sl@0: if ('a' <= drive && drive <= 'z') sl@0: drive -= 'a'; sl@0: else sl@0: { sl@0: ASSERT('A' <= drive && drive <= 'Z'); sl@0: drive -= 'A'; sl@0: } sl@0: return iDriveError[drive]; sl@0: } sl@0: return KErrNone; sl@0: } sl@0: } sl@0: return KErrEof; sl@0: } sl@0: virtual void Close() {} sl@0: TInt iOpenError; sl@0: TInt iDriveError[26]; sl@0: private: sl@0: CDesCArray *&iFilesThatExist; sl@0: TInt iIndex; sl@0: TFileName iMatch; sl@0: }; sl@0: sl@0: class TTestNearestLanguageFileFinder : public TNearestLanguageFileFinder sl@0: { sl@0: public: sl@0: TTestNearestLanguageFileFinder(const RFs& aFs) sl@0: : TNearestLanguageFileFinder(aFs), iTestScanner(iFilesThatExist) sl@0: { sl@0: iFilesThatExist = 0; sl@0: iFilesSearchedFor = 0; sl@0: } sl@0: ~TTestNearestLanguageFileFinder() sl@0: { sl@0: delete iFilesThatExist; sl@0: delete iFilesSearchedFor; sl@0: } sl@0: virtual TInt GetCustomResourceDriveNumber() const { return iCustomRscDrive; } sl@0: virtual TBool FileExists(const TDesC& aFileName) const sl@0: { sl@0: test(aFileName[1] == ':'); sl@0: test(0 == aFileName.Left(1).CompareF(iDrivesChecked.Left(1))); sl@0: iDrivesChecked.Delete(0, 1); sl@0: test(0 <= aFileName.MatchF(iFileCheckedFor)); sl@0: if (iFilesSearchedFor) sl@0: { sl@0: test(0 == aFileName.CompareF((*iFilesSearchedFor)[0])); sl@0: iFilesSearchedFor->Delete(0); sl@0: } sl@0: if (!iFilesThatExist) sl@0: return EFalse; sl@0: TInt i; sl@0: iFilesThatExist->Find(aFileName, i); sl@0: return (0 <= i && i < iFilesThatExist->Count())? ETrue : EFalse; sl@0: } sl@0: virtual RDirectoryScanner& DirectoryScanner() { return iTestScanner; } sl@0: sl@0: TInt iCustomRscDrive; sl@0: CDesCArray* iFilesThatExist; sl@0: // File that is expected to go into FileExists. sl@0: // Can contain wildcards. sl@0: TFileName iFileCheckedFor; sl@0: // Drives expected in calls to FileExists. The first one is checked then sl@0: // discarded each time FileExists is called. sl@0: mutable TBuf<26> iDrivesChecked; sl@0: CDesCArray* iFilesSearchedFor; sl@0: RTestDirectoryScanner iTestScanner; sl@0: }; sl@0: sl@0: void 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 TestAddLanguage() sl@0: { sl@0: test.Next(_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: struct SDowngradeTest sl@0: { sl@0: TLanguage iIn[4]; sl@0: TLanguage iOut[9]; 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 TestDowngrade(SDowngradeTest& aTest) sl@0: { sl@0: test.Next(_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: 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 TestMakeLanguageDowngradePath() sl@0: { sl@0: test.Next(_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 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 TestNearestLanguageFinder() sl@0: { sl@0: test.Next(_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: @SYMTestCaseID SYSLIB-BAFL-CT-0447 sl@0: @SYMTestCaseDesc Tests for defect number DEF039977 sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for Panic in BaflUtils::DiskIsReadOnly() sl@0: when unexpected parameter supplied sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void TestforDEF039977() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0447 ")); sl@0: TFileName filename; sl@0: TBool readOnly; sl@0: TInt theRes; sl@0: RFs fileserver; sl@0: TInt err=fileserver.Connect(); sl@0: test(err==KErrNone); sl@0: sl@0: filename=_L("c"); sl@0: theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly); sl@0: test(theRes==KErrBadName); sl@0: sl@0: filename=_L(" z:"); sl@0: theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly); sl@0: test(theRes==KErrBadName); sl@0: sl@0: filename=_L("z\\"); sl@0: theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly); sl@0: test(theRes==KErrBadName); sl@0: sl@0: filename=_L("b:"); sl@0: theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly); sl@0: test(theRes==KErrNotReady); sl@0: sl@0: filename=_L("c:"); sl@0: theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly); sl@0: test(theRes==KErrNone); sl@0: test(!readOnly); sl@0: sl@0: filename=_L("z:"); sl@0: theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly); sl@0: test(theRes==KErrNone); sl@0: test(readOnly); sl@0: sl@0: filename=_L("z:\\"); sl@0: theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly); sl@0: test(theRes==KErrNone); sl@0: sl@0: filename=_L("z:\\system\\data\\"); sl@0: theRes=BaflUtils::DiskIsReadOnly(fileserver,filename,readOnly); sl@0: test(theRes==KErrNone); sl@0: sl@0: fileserver.Close(); sl@0: } sl@0: sl@0: /* sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-1284 sl@0: @SYMTestCaseDesc Tests for invalid character sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for panic when an invalid character when sl@0: supplied to BaflUtils::RootFolderPath's parameter as drive letter sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: TInt TestforInvalidCharacter(TAny* /*aData*/) sl@0: /** sl@0: This is a root thread function which runs as part of the TestforDEF040198(). sl@0: It tests a panic is produced when an invalid non alphabet character is supplied sl@0: in the aDriveLetter argument in BaflUtils::RootFolderPath(const TBuf<1> aDriveLetter) sl@0: */ sl@0: { sl@0: TBuf<1> buf1=_L("?"); sl@0: TFileName retValue; sl@0: retValue=BaflUtils::RootFolderPath(buf1); sl@0: sl@0: // Line above panics if working OK, so should never get here. sl@0: test(0); sl@0: return 0; sl@0: } sl@0: sl@0: /** sl@0: This method is a test case to demonstrate the fix for DEF040198 by supplying an invalid sl@0: input aDriveLetter argument (e.g "?") to BaflUtils::RootFolderPath(aDriveLetter). sl@0: sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0448 sl@0: @SYMTestCaseDesc Tests for defect number DEF040198 sl@0: @SYMTestPriority High sl@0: @SYMTestActions Check by giving an invalid aDriveLetter argument sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void TestforDEF040198() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0448 ")); sl@0: //Check invalid aDriveLetter argument panics with panic code EBaflPanicBadOpenArg sl@0: #if defined(_DEBUG) sl@0: TRequestStatus threadStatus; sl@0: RThread thread; sl@0: _LIT(KThreadName,"ThreadTest"); sl@0: TInt rc; sl@0: TBool jit; sl@0: jit=User::JustInTime(); sl@0: User::SetJustInTime(EFalse); sl@0: sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-1284 ")); sl@0: rc=thread.Create(KThreadName,TestforInvalidCharacter,KDefaultStackSize,KMinHeapSize,KMinHeapSize*4,NULL); sl@0: test(rc==KErrNone); sl@0: thread.Logon(threadStatus); sl@0: thread.Resume(); sl@0: User::WaitForRequest(threadStatus); sl@0: test (thread.ExitType()==EExitPanic); sl@0: test (thread.ExitReason()==EBafPanicBadOpenArg); sl@0: thread.Close(); sl@0: User::SetJustInTime(jit); sl@0: #endif sl@0: } sl@0: sl@0: /* sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-1285 sl@0: @SYMTestCaseDesc Tests for invalid path name sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for panic when an invalid character supplied to BaflUtils::RootFolderPath's parameter as drive letter sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: TInt TestforInvalidPathName(TAny* /*aData*/) sl@0: /** sl@0: This is a root thread function which runs as part of the TestforDEF040299(). sl@0: It tests a panic is produced when an invalid name is supplied sl@0: in the aFullName argument in BaflUtils::FolderNameFromFullName(const TDesC& aFullName) sl@0: */ sl@0: { sl@0: TBuf<1> buf1=_L("?"); sl@0: TFileName retValue; sl@0: retValue=BaflUtils::FolderNameFromFullName(buf1); sl@0: sl@0: // Line above panics if working OK, so should never get here. sl@0: test(0); sl@0: return 0; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0449 sl@0: @SYMTestCaseDesc Tests for defect number DEF047305 sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for correct syntax sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void TestForDEF047305() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0449 ")); sl@0: RFs aFs; sl@0: CleanupClosePushL(aFs); sl@0: User::LeaveIfError(aFs.Connect()); sl@0: sl@0: TFileName newFolderFullName = KCurrentPath; sl@0: sl@0: test(User::LeaveIfError(BaflUtils::ValidateFolderNameTypedByUserL(aFs, KValFolderName, KCurrentPath, newFolderFullName)==KErrNone)); sl@0: test(User::LeaveIfError(BaflUtils::ValidateFolderNameTypedByUserL(aFs, KNoFolderName, KCurrentPath, newFolderFullName)==KErrArgument)); sl@0: test(User::LeaveIfError(BaflUtils::ValidateFolderNameTypedByUserL(aFs, KInValidFolderName, KCurrentPath, newFolderFullName)==KErrBadName)); sl@0: sl@0: CleanupStack::PopAndDestroy(&aFs); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-0450 sl@0: @SYMTestCaseDesc Tests for defect number DEF040299 sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test by supplying an invalid input aFullName argument to BaflUtils::FolderNameFromFullName(aFullName) sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: void TestforDEF040299() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-0450 ")); sl@0: TBuf<30> buf; sl@0: TFileName fileName; sl@0: sl@0: //Path name="c:" sl@0: buf=_L("c:"); sl@0: fileName=BaflUtils::FolderNameFromFullName(buf); sl@0: test(buf==fileName); sl@0: sl@0: //Path name="c:\\" sl@0: buf=_L("c:\\"); sl@0: fileName=BaflUtils::FolderNameFromFullName(buf); sl@0: test(fileName==buf); sl@0: sl@0: //Path name="c:\\file.txt" sl@0: buf=_L("c:\\file.txt"); sl@0: fileName=BaflUtils::FolderNameFromFullName(buf); sl@0: test(fileName==_L("c:\\")); sl@0: sl@0: //Path name="c:\\system\\file.txt" sl@0: buf=_L("c:\\system\\file.txt"); sl@0: fileName=BaflUtils::FolderNameFromFullName(buf); sl@0: test(fileName==_L("system")); sl@0: sl@0: /** sl@0: This method is a test case to demonstrate the fix for DEF040299 by supplying an invalid sl@0: input aFullName argument (e.g "?") to BaflUtils::FolderNameFromFullName(aFullName). sl@0: */ sl@0: //Check invalid aFullName argument panics with panic code EBaflPanicBadOpenArg sl@0: #if defined(_DEBUG) sl@0: TRequestStatus threadStatus; sl@0: RThread thread; sl@0: //Tread name is changed due to test failing on slow machine sl@0: //Using "TreadTest" here are causing KErrAlreadyExist at tread creating stage. sl@0: //This is because the previous tread maybe still being closed when this thread is created. sl@0: _LIT(KThreadName,"ThreadTest1"); sl@0: TInt rc; sl@0: TBool jit; sl@0: jit=User::JustInTime(); sl@0: User::SetJustInTime(EFalse); sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-1285 ")); sl@0: rc=thread.Create(KThreadName,TestforInvalidPathName,KDefaultStackSize,KMinHeapSize,KMinHeapSize*4,NULL); sl@0: test(rc==KErrNone); sl@0: thread.Logon(threadStatus); sl@0: thread.Resume(); sl@0: User::WaitForRequest(threadStatus); sl@0: test (thread.ExitType()==EExitPanic); sl@0: test (thread.ExitReason()==EBafPanicBadOpenArg); sl@0: thread.Close(); sl@0: User::SetJustInTime(jit); sl@0: #endif sl@0: sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-CT-3416 sl@0: @SYMTestCaseDesc Tests for defect number DEF101927 sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test the simulated Tls functionalities Dll::Tls, Dll::SetTls and Dll::FreeTls sl@0: which is needed for BAUtils.cpp to be complied as part of an .exe. sl@0: Dll::Tls - Recalls the value currently referred to by the Tls pointer sl@0: Dll::SetTls - Sets the the values referred to by the Tls pointer sl@0: Dll::FreeTls - Sets the Tls pointer to NULL sl@0: @SYMTestExpectedResults Pass if the TLanguage values is returned as expected after calls to IdealLanguage, sl@0: SetIdealLanguage and ReleaseIdealLanguage. sl@0: @SYMDEF DEF101927 sl@0: */ sl@0: void TestForDEF101927() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-CT-3416 ")); sl@0: TLanguage test_language(ELangAmerican); sl@0: sl@0: test(BaflUtils::IdealLanguage()==ELangNone); sl@0: sl@0: BaflUtils::SetIdealLanguage(ELangAmerican); sl@0: test(test_language == ELangAmerican); sl@0: sl@0: test_language = ELangNone; sl@0: test_language = BaflUtils::IdealLanguage(); sl@0: test(test_language == ELangAmerican); sl@0: sl@0: BaflUtils::ReleaseIdealLanguage(); sl@0: test_language = BaflUtils::IdealLanguage(); sl@0: test(test_language == ELangNone); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-BAFL-UT-3667 sl@0: @SYMTestCaseDesc Tests for defect number DEF109928 sl@0: @SYMTestPriority Normal sl@0: @SYMTestActions Test for the extended NextLanguage(). Check if the MakeLanguageDowngradePath() sl@0: can now return the correct default fallback for the languages which are newly sl@0: added into the NextLanguage(). sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMDEF DEF109928 sl@0: */ sl@0: void TestForDEF109928() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-BAFL-UT-3667 ")); sl@0: TLanguage testDeviceLangs[8] = {ELangEnglish_Japan, ELangSwissFrench, ELangSwissGerman, sl@0: ELangLatinAmericanSpanish, ELangSwissItalian, ELangFinlandSwedish, sl@0: ELangMalay_Apac, ELangBrazilianPortuguese}; sl@0: TLanguagePath testOutputPath[8] = {{ELangEnglish_Japan, ELangEnglish}, {ELangSwissFrench, ELangFrench}, sl@0: {ELangSwissGerman, ELangGerman}, {ELangLatinAmericanSpanish, ELangSpanish}, sl@0: {ELangSwissItalian, ELangItalian}, {ELangFinlandSwedish, ELangSwedish}, sl@0: {ELangMalay_Apac, ELangMalay}, {ELangBrazilianPortuguese, ELangPortuguese}}; sl@0: TLocale loc; sl@0: loc.SetLanguageDowngrade(0, ELangNone); sl@0: loc.SetLanguageDowngrade(1, ELangNone); sl@0: loc.SetLanguageDowngrade(2, ELangNone); sl@0: TLanguagePath path; sl@0: TLanguage testlang; sl@0: sl@0: for(TInt i = 0; i < 8 ; i++) sl@0: { sl@0: testlang = testDeviceLangs[i]; sl@0: MakeLanguageDowngradePath(path, testlang, ELangNone, loc); sl@0: test(path[0] == testOutputPath[i][0]); sl@0: test(path[1] == testOutputPath[i][1]); sl@0: test(path[2] == ELangNone); sl@0: } sl@0: } sl@0: sl@0: /* The following 3 function is defined so that the functions IdealLanguage, sl@0: SetIdealLanguage, ReleaseIdealLanguage will compile as part as an .exe sl@0: These functions use a global TAny* to store the data that would have been sl@0: stored in the TLS under normal compilation (ie If the BaUtils was compilled sl@0: as part of a DLL). sl@0: */ sl@0: sl@0: TAny* ptr(NULL); sl@0: sl@0: TAny* Dll::Tls() sl@0: { sl@0: return ptr; sl@0: } sl@0: sl@0: TInt Dll::SetTls(TAny* aPtr) sl@0: { sl@0: ptr = aPtr; sl@0: return KErrNone; sl@0: } sl@0: sl@0: void Dll::FreeTls() sl@0: { sl@0: ptr = NULL; sl@0: } sl@0: sl@0: void RunTestsL() sl@0: { sl@0: __UHEAP_MARK; sl@0: sl@0: test.Title(); sl@0: test.Start(_L("BaflUtils Internal Tests: ")); sl@0: sl@0: TestAddLanguage(); sl@0: TestMakeLanguageDowngradePath(); sl@0: TestNearestLanguageFinder(); sl@0: TestforDEF039977(); sl@0: TestforDEF040198(); sl@0: TestforDEF040299(); sl@0: TestForDEF047305(); sl@0: TestForDEF101927(); sl@0: TestForDEF109928(); sl@0: test.End(); sl@0: test.Close(); sl@0: sl@0: __UHEAP_MARKENDC(0); sl@0: } sl@0: sl@0: TInt E32Main() sl@0: { sl@0: TrapCleanup = CTrapCleanup::New(); sl@0: TRAPD(err, RunTestsL()); sl@0: test(err == KErrNone); sl@0: delete TrapCleanup; sl@0: return 0; sl@0: }