0
|
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".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// A very boring piece of test code that tests a few filenames in various
|
|
15 |
// languages to make sure that support exists.
|
|
16 |
// Current languages:
|
|
17 |
// Polish, Czech, Hungarian, Greek.
|
|
18 |
//
|
|
19 |
//
|
|
20 |
|
|
21 |
#ifdef __VC32__
|
|
22 |
// Solve compilation problem caused by non-English locale
|
|
23 |
#pragma setlocale("english")
|
|
24 |
#endif
|
|
25 |
|
|
26 |
// Need to define this macro to use error-code macros in e32test.h
|
|
27 |
#define __E32TEST_EXTENSION__
|
|
28 |
|
|
29 |
#include <e32test.h>
|
|
30 |
#include <f32file.h>
|
|
31 |
|
|
32 |
#include "f32_test_utils.h"
|
|
33 |
|
|
34 |
using namespace F32_Test_Utils;
|
|
35 |
|
|
36 |
#include "t_server.h"
|
|
37 |
|
|
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, "??????");
|
|
71 |
|
|
72 |
CTrapCleanup* TrapCleanup;
|
|
73 |
RTest test(_L("T_FileMatch: testing file names in various languages."));
|
|
74 |
|
|
75 |
_LIT(KPath, "\\T_FileMatch\\");
|
|
76 |
|
|
77 |
TInt gDriveNum = -1;
|
|
78 |
|
|
79 |
void Begin()
|
|
80 |
{
|
|
81 |
TInt r = TheFs.MkDirAll(KPath);
|
|
82 |
test_Assert(r == KErrNone || r == KErrAlreadyExists, test.Printf(_L("MkDirAll returned %d\n"),r));
|
|
83 |
}
|
|
84 |
|
|
85 |
void CreateFile(const TDesC& aFileName)
|
|
86 |
{
|
|
87 |
TInt r;
|
|
88 |
TFileName name;
|
|
89 |
name = KPath;
|
|
90 |
name.Append(aFileName);
|
|
91 |
RFile file;
|
|
92 |
r = file.Create(TheFs, name, EFileShareAny);
|
|
93 |
test_KErrNone(r);
|
|
94 |
file.Close();
|
|
95 |
}
|
|
96 |
|
|
97 |
void DeleteFile(const TDesC& aFileName)
|
|
98 |
{
|
|
99 |
TInt r;
|
|
100 |
TFileName name;
|
|
101 |
name = KPath;
|
|
102 |
name.Append(aFileName);
|
|
103 |
r = TheFs.Delete(name);
|
|
104 |
test_KErrNone(r);
|
|
105 |
}
|
|
106 |
|
|
107 |
void CheckMatch(const TDesC& aFileName)
|
|
108 |
{
|
|
109 |
TInt r;
|
|
110 |
RDir dir;
|
|
111 |
TFileName name;
|
|
112 |
name = KPath;
|
|
113 |
name.Append(aFileName);
|
|
114 |
r = dir.Open(TheFs, name, KEntryAttNormal);
|
|
115 |
test_KErrNone(r);
|
|
116 |
TEntry entry;
|
|
117 |
test(dir.Read(entry) == KErrNone);
|
|
118 |
dir.Close();
|
|
119 |
}
|
|
120 |
|
|
121 |
void CheckNonMatch(const TDesC& aFileName)
|
|
122 |
{
|
|
123 |
TInt r;
|
|
124 |
RDir dir;
|
|
125 |
TFileName name;
|
|
126 |
name = KPath;
|
|
127 |
name.Append(aFileName);
|
|
128 |
r = dir.Open(TheFs, name, KEntryAttNormal);
|
|
129 |
test_KErrNone(r);
|
|
130 |
TEntry entry;
|
|
131 |
test(dir.Read(entry) == KErrEof);
|
|
132 |
dir.Close();
|
|
133 |
}
|
|
134 |
|
|
135 |
void TestFilenameMatches()
|
|
136 |
{
|
|
137 |
test.Next(_L("TestFilenameMatches()"));
|
|
138 |
|
|
139 |
Begin();
|
|
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);
|
|
159 |
CreateFile(KCzech1);
|
|
160 |
CheckMatch(KCzech1Match1);
|
|
161 |
CheckMatch(KCzech1Match2);
|
|
162 |
CheckMatch(KCzech1Match3);
|
|
163 |
CheckNonMatch(KCzech1NonMatch1);
|
|
164 |
DeleteFile(KCzech1);
|
|
165 |
CreateFile(KCzech2);
|
|
166 |
CheckMatch(KCzech2Match1);
|
|
167 |
CheckMatch(KCzech2Match2);
|
|
168 |
DeleteFile(KCzech2);
|
|
169 |
CreateFile(KHungarian1);
|
|
170 |
CheckMatch(KHungarian1Match1);
|
|
171 |
CheckMatch(KHungarian1Match2);
|
|
172 |
CheckMatch(KHungarian1Match3);
|
|
173 |
DeleteFile(KHungarian1);
|
|
174 |
CreateFile(KGreek1);
|
|
175 |
CheckMatch(KGreek1Match1);
|
|
176 |
CheckMatch(KGreek1Match2);
|
|
177 |
CheckMatch(KGreek1Match3);
|
|
178 |
DeleteFile(KGreek1);
|
|
179 |
}
|
|
180 |
|
|
181 |
void CallTestsL(void)
|
|
182 |
{
|
|
183 |
//-- set up console output
|
|
184 |
F32_Test_Utils::SetConsole(test.Console());
|
|
185 |
|
|
186 |
TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum);
|
|
187 |
test(nRes==KErrNone);
|
|
188 |
|
|
189 |
PrintDrvInfo(TheFs, gDriveNum);
|
|
190 |
|
|
191 |
if(Is_Win32(TheFs, gDriveNum) || Is_Fat(TheFs, gDriveNum) || Is_Lffs(TheFs, gDriveNum))
|
|
192 |
{
|
|
193 |
TestFilenameMatches();
|
|
194 |
}
|
|
195 |
else
|
|
196 |
{
|
|
197 |
test.Printf(_L("This test can't be performed on this file system. Skipping.\n"));
|
|
198 |
}
|
|
199 |
|
|
200 |
}
|
|
201 |
|