First public contribution.
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // A very boring piece of test code that tests a few filenames in various
15 // languages to make sure that support exists.
17 // Polish, Czech, Hungarian, Greek.
22 // Solve compilation problem caused by non-English locale
23 #pragma setlocale("english")
26 // Need to define this macro to use error-code macros in e32test.h
27 #define __E32TEST_EXTENSION__
32 #include "f32_test_utils.h"
34 using namespace F32_Test_Utils;
38 _LIT(KPolish1, "Jugos\x142\x61wii");
39 _LIT(KPolish1Match1, "jUGOS\x141\x41WII");
40 _LIT(KPolish1Match2, "jUGOS\x141\x41*WII");
41 _LIT(KPolish1Match3, "jUGOS\x141*i");
42 _LIT(KPolish1Match4, "Ju*wIi");
43 _LIT(KPolish1Match5, "jugos?awii");
44 _LIT(KPolish1NonMatch1, "jugoslawii");
45 _LIT(KPolish1NonMatch2, "jugosl*awii");
46 _LIT(KPolish1NonMatch3, "jugosl?awii");
47 _LIT(KPolish2, "KSI\x104Z\x307KI");
48 _LIT(KPolish2Match1, "ksia\x328z\x307ki");
49 _LIT(KPolish2Match2, "ksi?z\x307ki");
50 _LIT(KPolish2Match3, "ksia\x328?ki");
51 _LIT(KPolish2Match4, "ksi\x105\x17Cki");
52 _LIT(KPolish2NonMatch1, "ksiazki");
53 _LIT(KPolish2NonMatch2, "ksia*z\x307ki");
54 _LIT(KPolish2NonMatch3, "ksia\x328z*ki");
55 _LIT(KCzech1, "VY\x301KAZU\x30A");
56 _LIT(KCzech1Match1, "V\xDDKAZ\x16E");
57 _LIT(KCzech1Match2, "v\xFDkaz\x16F");
58 _LIT(KCzech1Match3, "*\x16F");
59 _LIT(KCzech1NonMatch1, "VY?KAZU??");
60 _LIT(KCzech2, "\x10Dtvrtlet\xED");
61 _LIT(KCzech2Match1, "c\x30Ctvrtleti\x301");
62 _LIT(KCzech2Match2, "?tvrtlet?");
63 _LIT(KHungarian1, "KO\x308ZE\x301RDEKU\x30B");
64 _LIT(KHungarian1Match1, "K\xD6Z\xC9RDEK\x170");
65 _LIT(KHungarian1Match2, "k\xF6z\xE9rdek\x171");
66 _LIT(KHungarian1Match3, "k?z?rdek?");
67 _LIT(KGreek1, "\x39B\x395\x3A6\x39A\x391\x3A3");
68 _LIT(KGreek1Match1, "\x3BB\x3B5\x3C6\x3BA\x3B1\x3C2");
69 _LIT(KGreek1Match2, "\x3BB\x3B5\x3C6\x3BA\x3B1\x3C3");
70 _LIT(KGreek1Match3, "??????");
72 CTrapCleanup* TrapCleanup;
73 RTest test(_L("T_FileMatch: testing file names in various languages."));
75 _LIT(KPath, "\\T_FileMatch\\");
81 TInt r = TheFs.MkDirAll(KPath);
82 test_Assert(r == KErrNone || r == KErrAlreadyExists, test.Printf(_L("MkDirAll returned %d\n"),r));
85 void CreateFile(const TDesC& aFileName)
90 name.Append(aFileName);
92 r = file.Create(TheFs, name, EFileShareAny);
97 void DeleteFile(const TDesC& aFileName)
102 name.Append(aFileName);
103 r = TheFs.Delete(name);
107 void CheckMatch(const TDesC& aFileName)
113 name.Append(aFileName);
114 r = dir.Open(TheFs, name, KEntryAttNormal);
117 test(dir.Read(entry) == KErrNone);
121 void CheckNonMatch(const TDesC& aFileName)
127 name.Append(aFileName);
128 r = dir.Open(TheFs, name, KEntryAttNormal);
131 test(dir.Read(entry) == KErrEof);
135 void TestFilenameMatches()
137 test.Next(_L("TestFilenameMatches()"));
140 CreateFile(KPolish1);
141 CheckMatch(KPolish1Match1);
142 CheckMatch(KPolish1Match2);
143 CheckMatch(KPolish1Match3);
144 CheckMatch(KPolish1Match4);
145 CheckMatch(KPolish1Match5);
146 CheckNonMatch(KPolish1NonMatch1);
147 CheckNonMatch(KPolish1NonMatch2);
148 CheckNonMatch(KPolish1NonMatch3);
149 DeleteFile(KPolish1);
150 CreateFile(KPolish2);
151 CheckMatch(KPolish2Match1);
152 CheckMatch(KPolish2Match2);
153 CheckMatch(KPolish2Match3);
154 CheckMatch(KPolish2Match4);
155 CheckNonMatch(KPolish2NonMatch1);
156 CheckNonMatch(KPolish2NonMatch2);
157 CheckNonMatch(KPolish2NonMatch3);
158 DeleteFile(KPolish2);
160 CheckMatch(KCzech1Match1);
161 CheckMatch(KCzech1Match2);
162 CheckMatch(KCzech1Match3);
163 CheckNonMatch(KCzech1NonMatch1);
166 CheckMatch(KCzech2Match1);
167 CheckMatch(KCzech2Match2);
169 CreateFile(KHungarian1);
170 CheckMatch(KHungarian1Match1);
171 CheckMatch(KHungarian1Match2);
172 CheckMatch(KHungarian1Match3);
173 DeleteFile(KHungarian1);
175 CheckMatch(KGreek1Match1);
176 CheckMatch(KGreek1Match2);
177 CheckMatch(KGreek1Match3);
181 void CallTestsL(void)
183 //-- set up console output
184 F32_Test_Utils::SetConsole(test.Console());
186 TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum);
187 test(nRes==KErrNone);
189 PrintDrvInfo(TheFs, gDriveNum);
191 if(Is_Win32(TheFs, gDriveNum) || Is_Fat(TheFs, gDriveNum) || Is_Lffs(TheFs, gDriveNum))
193 TestFilenameMatches();
197 test.Printf(_L("This test can't be performed on this file system. Skipping.\n"));