sl@0
|
1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// A very boring piece of test code that tests a few filenames in various
|
sl@0
|
15 |
// languages to make sure that support exists.
|
sl@0
|
16 |
// Current languages:
|
sl@0
|
17 |
// Polish, Czech, Hungarian, Greek.
|
sl@0
|
18 |
//
|
sl@0
|
19 |
//
|
sl@0
|
20 |
|
sl@0
|
21 |
#ifdef __VC32__
|
sl@0
|
22 |
// Solve compilation problem caused by non-English locale
|
sl@0
|
23 |
#pragma setlocale("english")
|
sl@0
|
24 |
#endif
|
sl@0
|
25 |
|
sl@0
|
26 |
// Need to define this macro to use error-code macros in e32test.h
|
sl@0
|
27 |
#define __E32TEST_EXTENSION__
|
sl@0
|
28 |
|
sl@0
|
29 |
#include <e32test.h>
|
sl@0
|
30 |
#include <f32file.h>
|
sl@0
|
31 |
|
sl@0
|
32 |
#include "f32_test_utils.h"
|
sl@0
|
33 |
|
sl@0
|
34 |
using namespace F32_Test_Utils;
|
sl@0
|
35 |
|
sl@0
|
36 |
#include "t_server.h"
|
sl@0
|
37 |
|
sl@0
|
38 |
_LIT(KPolish1, "Jugos\x142\x61wii");
|
sl@0
|
39 |
_LIT(KPolish1Match1, "jUGOS\x141\x41WII");
|
sl@0
|
40 |
_LIT(KPolish1Match2, "jUGOS\x141\x41*WII");
|
sl@0
|
41 |
_LIT(KPolish1Match3, "jUGOS\x141*i");
|
sl@0
|
42 |
_LIT(KPolish1Match4, "Ju*wIi");
|
sl@0
|
43 |
_LIT(KPolish1Match5, "jugos?awii");
|
sl@0
|
44 |
_LIT(KPolish1NonMatch1, "jugoslawii");
|
sl@0
|
45 |
_LIT(KPolish1NonMatch2, "jugosl*awii");
|
sl@0
|
46 |
_LIT(KPolish1NonMatch3, "jugosl?awii");
|
sl@0
|
47 |
_LIT(KPolish2, "KSI\x104Z\x307KI");
|
sl@0
|
48 |
_LIT(KPolish2Match1, "ksia\x328z\x307ki");
|
sl@0
|
49 |
_LIT(KPolish2Match2, "ksi?z\x307ki");
|
sl@0
|
50 |
_LIT(KPolish2Match3, "ksia\x328?ki");
|
sl@0
|
51 |
_LIT(KPolish2Match4, "ksi\x105\x17Cki");
|
sl@0
|
52 |
_LIT(KPolish2NonMatch1, "ksiazki");
|
sl@0
|
53 |
_LIT(KPolish2NonMatch2, "ksia*z\x307ki");
|
sl@0
|
54 |
_LIT(KPolish2NonMatch3, "ksia\x328z*ki");
|
sl@0
|
55 |
_LIT(KCzech1, "VY\x301KAZU\x30A");
|
sl@0
|
56 |
_LIT(KCzech1Match1, "V\xDDKAZ\x16E");
|
sl@0
|
57 |
_LIT(KCzech1Match2, "v\xFDkaz\x16F");
|
sl@0
|
58 |
_LIT(KCzech1Match3, "*\x16F");
|
sl@0
|
59 |
_LIT(KCzech1NonMatch1, "VY?KAZU??");
|
sl@0
|
60 |
_LIT(KCzech2, "\x10Dtvrtlet\xED");
|
sl@0
|
61 |
_LIT(KCzech2Match1, "c\x30Ctvrtleti\x301");
|
sl@0
|
62 |
_LIT(KCzech2Match2, "?tvrtlet?");
|
sl@0
|
63 |
_LIT(KHungarian1, "KO\x308ZE\x301RDEKU\x30B");
|
sl@0
|
64 |
_LIT(KHungarian1Match1, "K\xD6Z\xC9RDEK\x170");
|
sl@0
|
65 |
_LIT(KHungarian1Match2, "k\xF6z\xE9rdek\x171");
|
sl@0
|
66 |
_LIT(KHungarian1Match3, "k?z?rdek?");
|
sl@0
|
67 |
_LIT(KGreek1, "\x39B\x395\x3A6\x39A\x391\x3A3");
|
sl@0
|
68 |
_LIT(KGreek1Match1, "\x3BB\x3B5\x3C6\x3BA\x3B1\x3C2");
|
sl@0
|
69 |
_LIT(KGreek1Match2, "\x3BB\x3B5\x3C6\x3BA\x3B1\x3C3");
|
sl@0
|
70 |
_LIT(KGreek1Match3, "??????");
|
sl@0
|
71 |
|
sl@0
|
72 |
CTrapCleanup* TrapCleanup;
|
sl@0
|
73 |
RTest test(_L("T_FileMatch: testing file names in various languages."));
|
sl@0
|
74 |
|
sl@0
|
75 |
_LIT(KPath, "\\T_FileMatch\\");
|
sl@0
|
76 |
|
sl@0
|
77 |
TInt gDriveNum = -1;
|
sl@0
|
78 |
|
sl@0
|
79 |
void Begin()
|
sl@0
|
80 |
{
|
sl@0
|
81 |
TInt r = TheFs.MkDirAll(KPath);
|
sl@0
|
82 |
test_Assert(r == KErrNone || r == KErrAlreadyExists, test.Printf(_L("MkDirAll returned %d\n"),r));
|
sl@0
|
83 |
}
|
sl@0
|
84 |
|
sl@0
|
85 |
void CreateFile(const TDesC& aFileName)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
TInt r;
|
sl@0
|
88 |
TFileName name;
|
sl@0
|
89 |
name = KPath;
|
sl@0
|
90 |
name.Append(aFileName);
|
sl@0
|
91 |
RFile file;
|
sl@0
|
92 |
r = file.Create(TheFs, name, EFileShareAny);
|
sl@0
|
93 |
test_KErrNone(r);
|
sl@0
|
94 |
file.Close();
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
void DeleteFile(const TDesC& aFileName)
|
sl@0
|
98 |
{
|
sl@0
|
99 |
TInt r;
|
sl@0
|
100 |
TFileName name;
|
sl@0
|
101 |
name = KPath;
|
sl@0
|
102 |
name.Append(aFileName);
|
sl@0
|
103 |
r = TheFs.Delete(name);
|
sl@0
|
104 |
test_KErrNone(r);
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
void CheckMatch(const TDesC& aFileName)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
TInt r;
|
sl@0
|
110 |
RDir dir;
|
sl@0
|
111 |
TFileName name;
|
sl@0
|
112 |
name = KPath;
|
sl@0
|
113 |
name.Append(aFileName);
|
sl@0
|
114 |
r = dir.Open(TheFs, name, KEntryAttNormal);
|
sl@0
|
115 |
test_KErrNone(r);
|
sl@0
|
116 |
TEntry entry;
|
sl@0
|
117 |
test(dir.Read(entry) == KErrNone);
|
sl@0
|
118 |
dir.Close();
|
sl@0
|
119 |
}
|
sl@0
|
120 |
|
sl@0
|
121 |
void CheckNonMatch(const TDesC& aFileName)
|
sl@0
|
122 |
{
|
sl@0
|
123 |
TInt r;
|
sl@0
|
124 |
RDir dir;
|
sl@0
|
125 |
TFileName name;
|
sl@0
|
126 |
name = KPath;
|
sl@0
|
127 |
name.Append(aFileName);
|
sl@0
|
128 |
r = dir.Open(TheFs, name, KEntryAttNormal);
|
sl@0
|
129 |
test_KErrNone(r);
|
sl@0
|
130 |
TEntry entry;
|
sl@0
|
131 |
test(dir.Read(entry) == KErrEof);
|
sl@0
|
132 |
dir.Close();
|
sl@0
|
133 |
}
|
sl@0
|
134 |
|
sl@0
|
135 |
void TestFilenameMatches()
|
sl@0
|
136 |
{
|
sl@0
|
137 |
test.Next(_L("TestFilenameMatches()"));
|
sl@0
|
138 |
|
sl@0
|
139 |
Begin();
|
sl@0
|
140 |
CreateFile(KPolish1);
|
sl@0
|
141 |
CheckMatch(KPolish1Match1);
|
sl@0
|
142 |
CheckMatch(KPolish1Match2);
|
sl@0
|
143 |
CheckMatch(KPolish1Match3);
|
sl@0
|
144 |
CheckMatch(KPolish1Match4);
|
sl@0
|
145 |
CheckMatch(KPolish1Match5);
|
sl@0
|
146 |
CheckNonMatch(KPolish1NonMatch1);
|
sl@0
|
147 |
CheckNonMatch(KPolish1NonMatch2);
|
sl@0
|
148 |
CheckNonMatch(KPolish1NonMatch3);
|
sl@0
|
149 |
DeleteFile(KPolish1);
|
sl@0
|
150 |
CreateFile(KPolish2);
|
sl@0
|
151 |
CheckMatch(KPolish2Match1);
|
sl@0
|
152 |
CheckMatch(KPolish2Match2);
|
sl@0
|
153 |
CheckMatch(KPolish2Match3);
|
sl@0
|
154 |
CheckMatch(KPolish2Match4);
|
sl@0
|
155 |
CheckNonMatch(KPolish2NonMatch1);
|
sl@0
|
156 |
CheckNonMatch(KPolish2NonMatch2);
|
sl@0
|
157 |
CheckNonMatch(KPolish2NonMatch3);
|
sl@0
|
158 |
DeleteFile(KPolish2);
|
sl@0
|
159 |
CreateFile(KCzech1);
|
sl@0
|
160 |
CheckMatch(KCzech1Match1);
|
sl@0
|
161 |
CheckMatch(KCzech1Match2);
|
sl@0
|
162 |
CheckMatch(KCzech1Match3);
|
sl@0
|
163 |
CheckNonMatch(KCzech1NonMatch1);
|
sl@0
|
164 |
DeleteFile(KCzech1);
|
sl@0
|
165 |
CreateFile(KCzech2);
|
sl@0
|
166 |
CheckMatch(KCzech2Match1);
|
sl@0
|
167 |
CheckMatch(KCzech2Match2);
|
sl@0
|
168 |
DeleteFile(KCzech2);
|
sl@0
|
169 |
CreateFile(KHungarian1);
|
sl@0
|
170 |
CheckMatch(KHungarian1Match1);
|
sl@0
|
171 |
CheckMatch(KHungarian1Match2);
|
sl@0
|
172 |
CheckMatch(KHungarian1Match3);
|
sl@0
|
173 |
DeleteFile(KHungarian1);
|
sl@0
|
174 |
CreateFile(KGreek1);
|
sl@0
|
175 |
CheckMatch(KGreek1Match1);
|
sl@0
|
176 |
CheckMatch(KGreek1Match2);
|
sl@0
|
177 |
CheckMatch(KGreek1Match3);
|
sl@0
|
178 |
DeleteFile(KGreek1);
|
sl@0
|
179 |
}
|
sl@0
|
180 |
|
sl@0
|
181 |
void CallTestsL(void)
|
sl@0
|
182 |
{
|
sl@0
|
183 |
//-- set up console output
|
sl@0
|
184 |
F32_Test_Utils::SetConsole(test.Console());
|
sl@0
|
185 |
|
sl@0
|
186 |
TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum);
|
sl@0
|
187 |
test(nRes==KErrNone);
|
sl@0
|
188 |
|
sl@0
|
189 |
PrintDrvInfo(TheFs, gDriveNum);
|
sl@0
|
190 |
|
sl@0
|
191 |
if(Is_Win32(TheFs, gDriveNum) || Is_Fat(TheFs, gDriveNum) || Is_Lffs(TheFs, gDriveNum))
|
sl@0
|
192 |
{
|
sl@0
|
193 |
TestFilenameMatches();
|
sl@0
|
194 |
}
|
sl@0
|
195 |
else
|
sl@0
|
196 |
{
|
sl@0
|
197 |
test.Printf(_L("This test can't be performed on this file system. Skipping.\n"));
|
sl@0
|
198 |
}
|
sl@0
|
199 |
|
sl@0
|
200 |
}
|
sl@0
|
201 |
|