sl@0: // Copyright (c) 1998-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 the License "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: // A very boring piece of test code that tests a few filenames in various sl@0: // languages to make sure that support exists. sl@0: // Current languages: sl@0: // Polish, Czech, Hungarian, Greek. sl@0: // sl@0: // sl@0: sl@0: #ifdef __VC32__ sl@0: // Solve compilation problem caused by non-English locale sl@0: #pragma setlocale("english") sl@0: #endif sl@0: sl@0: // Need to define this macro to use error-code macros in e32test.h sl@0: #define __E32TEST_EXTENSION__ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include "f32_test_utils.h" sl@0: sl@0: using namespace F32_Test_Utils; sl@0: sl@0: #include "t_server.h" sl@0: sl@0: _LIT(KPolish1, "Jugos\x142\x61wii"); sl@0: _LIT(KPolish1Match1, "jUGOS\x141\x41WII"); sl@0: _LIT(KPolish1Match2, "jUGOS\x141\x41*WII"); sl@0: _LIT(KPolish1Match3, "jUGOS\x141*i"); sl@0: _LIT(KPolish1Match4, "Ju*wIi"); sl@0: _LIT(KPolish1Match5, "jugos?awii"); sl@0: _LIT(KPolish1NonMatch1, "jugoslawii"); sl@0: _LIT(KPolish1NonMatch2, "jugosl*awii"); sl@0: _LIT(KPolish1NonMatch3, "jugosl?awii"); sl@0: _LIT(KPolish2, "KSI\x104Z\x307KI"); sl@0: _LIT(KPolish2Match1, "ksia\x328z\x307ki"); sl@0: _LIT(KPolish2Match2, "ksi?z\x307ki"); sl@0: _LIT(KPolish2Match3, "ksia\x328?ki"); sl@0: _LIT(KPolish2Match4, "ksi\x105\x17Cki"); sl@0: _LIT(KPolish2NonMatch1, "ksiazki"); sl@0: _LIT(KPolish2NonMatch2, "ksia*z\x307ki"); sl@0: _LIT(KPolish2NonMatch3, "ksia\x328z*ki"); sl@0: _LIT(KCzech1, "VY\x301KAZU\x30A"); sl@0: _LIT(KCzech1Match1, "V\xDDKAZ\x16E"); sl@0: _LIT(KCzech1Match2, "v\xFDkaz\x16F"); sl@0: _LIT(KCzech1Match3, "*\x16F"); sl@0: _LIT(KCzech1NonMatch1, "VY?KAZU??"); sl@0: _LIT(KCzech2, "\x10Dtvrtlet\xED"); sl@0: _LIT(KCzech2Match1, "c\x30Ctvrtleti\x301"); sl@0: _LIT(KCzech2Match2, "?tvrtlet?"); sl@0: _LIT(KHungarian1, "KO\x308ZE\x301RDEKU\x30B"); sl@0: _LIT(KHungarian1Match1, "K\xD6Z\xC9RDEK\x170"); sl@0: _LIT(KHungarian1Match2, "k\xF6z\xE9rdek\x171"); sl@0: _LIT(KHungarian1Match3, "k?z?rdek?"); sl@0: _LIT(KGreek1, "\x39B\x395\x3A6\x39A\x391\x3A3"); sl@0: _LIT(KGreek1Match1, "\x3BB\x3B5\x3C6\x3BA\x3B1\x3C2"); sl@0: _LIT(KGreek1Match2, "\x3BB\x3B5\x3C6\x3BA\x3B1\x3C3"); sl@0: _LIT(KGreek1Match3, "??????"); sl@0: sl@0: CTrapCleanup* TrapCleanup; sl@0: RTest test(_L("T_FileMatch: testing file names in various languages.")); sl@0: sl@0: _LIT(KPath, "\\T_FileMatch\\"); sl@0: sl@0: TInt gDriveNum = -1; sl@0: sl@0: void Begin() sl@0: { sl@0: TInt r = TheFs.MkDirAll(KPath); sl@0: test_Assert(r == KErrNone || r == KErrAlreadyExists, test.Printf(_L("MkDirAll returned %d\n"),r)); sl@0: } sl@0: sl@0: void CreateFile(const TDesC& aFileName) sl@0: { sl@0: TInt r; sl@0: TFileName name; sl@0: name = KPath; sl@0: name.Append(aFileName); sl@0: RFile file; sl@0: r = file.Create(TheFs, name, EFileShareAny); sl@0: test_KErrNone(r); sl@0: file.Close(); sl@0: } sl@0: sl@0: void DeleteFile(const TDesC& aFileName) sl@0: { sl@0: TInt r; sl@0: TFileName name; sl@0: name = KPath; sl@0: name.Append(aFileName); sl@0: r = TheFs.Delete(name); sl@0: test_KErrNone(r); sl@0: } sl@0: sl@0: void CheckMatch(const TDesC& aFileName) sl@0: { sl@0: TInt r; sl@0: RDir dir; sl@0: TFileName name; sl@0: name = KPath; sl@0: name.Append(aFileName); sl@0: r = dir.Open(TheFs, name, KEntryAttNormal); sl@0: test_KErrNone(r); sl@0: TEntry entry; sl@0: test(dir.Read(entry) == KErrNone); sl@0: dir.Close(); sl@0: } sl@0: sl@0: void CheckNonMatch(const TDesC& aFileName) sl@0: { sl@0: TInt r; sl@0: RDir dir; sl@0: TFileName name; sl@0: name = KPath; sl@0: name.Append(aFileName); sl@0: r = dir.Open(TheFs, name, KEntryAttNormal); sl@0: test_KErrNone(r); sl@0: TEntry entry; sl@0: test(dir.Read(entry) == KErrEof); sl@0: dir.Close(); sl@0: } sl@0: sl@0: void TestFilenameMatches() sl@0: { sl@0: test.Next(_L("TestFilenameMatches()")); sl@0: sl@0: Begin(); sl@0: CreateFile(KPolish1); sl@0: CheckMatch(KPolish1Match1); sl@0: CheckMatch(KPolish1Match2); sl@0: CheckMatch(KPolish1Match3); sl@0: CheckMatch(KPolish1Match4); sl@0: CheckMatch(KPolish1Match5); sl@0: CheckNonMatch(KPolish1NonMatch1); sl@0: CheckNonMatch(KPolish1NonMatch2); sl@0: CheckNonMatch(KPolish1NonMatch3); sl@0: DeleteFile(KPolish1); sl@0: CreateFile(KPolish2); sl@0: CheckMatch(KPolish2Match1); sl@0: CheckMatch(KPolish2Match2); sl@0: CheckMatch(KPolish2Match3); sl@0: CheckMatch(KPolish2Match4); sl@0: CheckNonMatch(KPolish2NonMatch1); sl@0: CheckNonMatch(KPolish2NonMatch2); sl@0: CheckNonMatch(KPolish2NonMatch3); sl@0: DeleteFile(KPolish2); sl@0: CreateFile(KCzech1); sl@0: CheckMatch(KCzech1Match1); sl@0: CheckMatch(KCzech1Match2); sl@0: CheckMatch(KCzech1Match3); sl@0: CheckNonMatch(KCzech1NonMatch1); sl@0: DeleteFile(KCzech1); sl@0: CreateFile(KCzech2); sl@0: CheckMatch(KCzech2Match1); sl@0: CheckMatch(KCzech2Match2); sl@0: DeleteFile(KCzech2); sl@0: CreateFile(KHungarian1); sl@0: CheckMatch(KHungarian1Match1); sl@0: CheckMatch(KHungarian1Match2); sl@0: CheckMatch(KHungarian1Match3); sl@0: DeleteFile(KHungarian1); sl@0: CreateFile(KGreek1); sl@0: CheckMatch(KGreek1Match1); sl@0: CheckMatch(KGreek1Match2); sl@0: CheckMatch(KGreek1Match3); sl@0: DeleteFile(KGreek1); sl@0: } sl@0: sl@0: void CallTestsL(void) sl@0: { sl@0: //-- set up console output sl@0: F32_Test_Utils::SetConsole(test.Console()); sl@0: sl@0: TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum); sl@0: test(nRes==KErrNone); sl@0: sl@0: PrintDrvInfo(TheFs, gDriveNum); sl@0: sl@0: if(Is_Win32(TheFs, gDriveNum) || Is_Fat(TheFs, gDriveNum) || Is_Lffs(TheFs, gDriveNum)) sl@0: { sl@0: TestFilenameMatches(); sl@0: } sl@0: else sl@0: { sl@0: test.Printf(_L("This test can't be performed on this file system. Skipping.\n")); sl@0: } sl@0: sl@0: } sl@0: