author | Mike Kinghan <mikek@symbian.org> |
Thu, 25 Nov 2010 14:35:45 +0000 | |
branch | GCC_SURGE |
changeset 305 | 1ba12ef4ef89 |
parent 109 | b3a1d9898418 |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1999-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 |
// f32test\server\t_appins.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
18 |
#define __E32TEST_EXTENSION__ |
0 | 19 |
#include <f32file.h> |
20 |
#include <e32test.h> |
|
21 |
#include <hal.h> |
|
22 |
#include "t_server.h" |
|
23 |
#include "t_chlffs.h" |
|
24 |
||
25 |
#if defined(__WINS__) |
|
26 |
#define WIN32_LEAN_AND_MEAN |
|
27 |
#pragma warning (disable:4201) // warning C4201: nonstandard extension used : nameless struct/union |
|
28 |
#pragma warning (default:4201) // warning C4201: nonstandard extension used : nameless struct/union |
|
29 |
#endif |
|
30 |
||
31 |
#if defined(_UNICODE) |
|
32 |
#if !defined(UNICODE) |
|
33 |
#define UNICODE |
|
34 |
#endif |
|
35 |
#endif |
|
36 |
||
37 |
GLDEF_D RTest test(_L("T_APPINS")); |
|
38 |
LOCAL_D RFs TheNotifyFs; // Fileserver session to receive/request change notification |
|
39 |
TInt RemovableDrive; |
|
40 |
/* |
|
41 |
||
42 |
What this test is for: |
|
43 |
Tests bug fix for the bug which doesn't notify drive D: when files are installed onto it |
|
44 |
||
45 |
*/ |
|
46 |
||
47 |
LOCAL_C void Test1() |
|
48 |
// |
|
49 |
// Test notification when session path of notification session is set to be explicitly different |
|
50 |
// from the drive and directory into which files and directories are created |
|
51 |
// |
|
52 |
{ |
|
53 |
TFileName path; |
|
54 |
path=_L("?:\\F32-TST\\T_APPINS\\"); |
|
55 |
||
56 |
TInt r=TheNotifyFs.SessionPath(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
57 |
test_KErrNone(r); |
0 | 58 |
|
59 |
TChar driveChar; |
|
60 |
r=RFs::DriveToChar(RemovableDrive,driveChar); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
61 |
test_KErrNone(r); |
0 | 62 |
|
63 |
if (gSessionPath[0]=='C') |
|
64 |
(gSessionPath[0] == (TText)gDriveToTest)? (path[0] = (TText)driveChar):(path[0] = (TText)gDriveToTest); |
|
65 |
else if (gSessionPath[0]=='Y') |
|
66 |
path[0]='X'; |
|
67 |
else if (gSessionPath[0]=='X') |
|
68 |
path[0]='Y'; |
|
69 |
else |
|
70 |
path[0]='C'; //invalid drive numbers shouldn't reach here, must be filtered out from t_main |
|
71 |
//return; |
|
72 |
||
73 |
TRequestStatus statEntry(KRequestPending); |
|
74 |
TRequestStatus statFile(KRequestPending); |
|
75 |
TRequestStatus statDir(KRequestPending); |
|
76 |
TRequestStatus statWild(KRequestPending); |
|
77 |
TRequestStatus statWilder(KRequestPending); |
|
78 |
||
79 |
r=TheFs.RmDir(path); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
80 |
test_Value(r, (r == KErrNone)||(r==KErrNotFound)||(r==KErrPathNotFound)); |
0 | 81 |
|
82 |
test.Printf(_L("Notify Session Path %S\n"),&gSessionPath); |
|
83 |
||
84 |
// Submit notify change requests (requesting ahead) |
|
85 |
test.Printf(_L("Create a directory %S\n"),&path); |
|
86 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); |
|
87 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
88 |
TheNotifyFs.NotifyChange(ENotifyDir,statDir,path); |
|
89 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\")); |
|
90 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\")); |
|
91 |
||
92 |
r=TheFs.MkDir(path); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
93 |
test_Value(r, (r == KErrNone)||(r==KErrAlreadyExists)); |
0 | 94 |
User::WaitForAnyRequest(); |
95 |
test(statEntry==KErrNone); |
|
96 |
test(statFile==KErrNone); |
|
97 |
test(statDir==KErrNone); |
|
98 |
test(statWild==KErrNone); |
|
99 |
test(statWilder==KErrNone); |
|
100 |
||
101 |
// Resubmit notify change requests (requesting ahead) |
|
102 |
test.Next(_L("Create a file in the directory")); |
|
103 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); |
|
104 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
105 |
TheNotifyFs.NotifyChange(ENotifyDir,statDir,path); |
|
106 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\")); |
|
107 |
TheNotifyFs.NotifyChange(ENotifyFile,statWilder,_L("*:\\")); |
|
108 |
||
109 |
TFileName filePath; |
|
110 |
filePath=path; |
|
111 |
filePath+=_L("TestFile.app"); |
|
112 |
RFile file; |
|
113 |
r=file.Replace(TheFs,filePath,EFileRead|EFileWrite); |
|
114 |
file.Close(); |
|
115 |
User::WaitForAnyRequest(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
test_KErrNone(r); |
0 | 117 |
test (statEntry==KErrNone); |
118 |
test(statFile==KErrNone); |
|
119 |
test(statDir==KRequestPending); |
|
120 |
test(statWild==KErrNone); |
|
121 |
test(statWilder==KErrNone); |
|
122 |
||
123 |
// Resubmit notify change requests |
|
124 |
test.Next(_L("Remove the file from the directory")); |
|
125 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); |
|
126 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
127 |
TheNotifyFs.NotifyChange(ENotifyDir,statWild,_L("?:\\F32-TST\\T_APPINS\\")); |
|
128 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\")); |
|
129 |
||
130 |
r=TheFs.Delete(filePath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
131 |
test_KErrNone(r); |
0 | 132 |
User::WaitForAnyRequest(); |
133 |
test (statEntry==KErrNone); |
|
134 |
test(statFile==KErrNone); |
|
135 |
test(statDir==KRequestPending); |
|
136 |
test(statWild==KRequestPending); |
|
137 |
test(statWilder==KErrNone); |
|
138 |
||
139 |
// Resubmit notify change requests |
|
140 |
test.Next(_L("Remove the directory")); |
|
141 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); |
|
142 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
143 |
// TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\")); |
|
144 |
TheNotifyFs.NotifyChange(ENotifyFile,statWilder,_L("*:\\")); |
|
145 |
||
146 |
r=TheFs.RmDir(path); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
test_KErrNone(r); |
0 | 148 |
User::WaitForAnyRequest(); |
149 |
test (statEntry==KErrNone); |
|
150 |
test(statFile==KRequestPending); |
|
151 |
test(statDir==KErrNone); |
|
152 |
test(statWild==KErrNone); |
|
153 |
test(statWilder==KRequestPending); |
|
154 |
||
155 |
// In case any outstanding notification requests exist |
|
156 |
TheNotifyFs.NotifyChangeCancel(); |
|
157 |
} |
|
158 |
||
159 |
LOCAL_C void Test2() |
|
160 |
// |
|
161 |
// Test notification when session path of the notification session is implicitly different |
|
162 |
// to the drive and directory into which files and directories are created |
|
163 |
// |
|
164 |
{ |
|
165 |
TFileName sessionPath; |
|
166 |
sessionPath=_L("?:\\F32-TST\\"); |
|
167 |
||
168 |
TChar driveChar; |
|
169 |
TInt err=RFs::DriveToChar(RemovableDrive,driveChar); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
170 |
test_KErrNone(err); |
0 | 171 |
|
172 |
if (gSessionPath[0]=='C') |
|
173 |
(gSessionPath[0] == (TText)gDriveToTest)? (sessionPath[0] = (TText)driveChar):(sessionPath[0] = (TText)gDriveToTest); |
|
174 |
else if (gSessionPath[0]=='Y') |
|
175 |
sessionPath[0]='X'; |
|
176 |
else if (gSessionPath[0]=='X') |
|
177 |
sessionPath[0]='Y'; |
|
178 |
else |
|
179 |
sessionPath[0]='C'; //invalid drive numbers shouldn't reach here, must be filtered out from t_main |
|
180 |
//return; |
|
181 |
||
182 |
TInt r=TheFs.SetSessionPath(sessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
183 |
test_KErrNone(r); |
0 | 184 |
|
185 |
TFileName path; |
|
186 |
path=_L("\\F32-TST\\T_APPINS\\"); // Takes drive implicitly from associated session path |
|
187 |
||
188 |
r=TheFs.RmDir(path); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
189 |
test_Value(r, (r == KErrNone)||(r==KErrNotFound)||(r==KErrPathNotFound)); |
0 | 190 |
|
191 |
TRequestStatus statEntry(KRequestPending); |
|
192 |
TRequestStatus statFile(KRequestPending); |
|
193 |
TRequestStatus statDir(KRequestPending); |
|
194 |
TRequestStatus statWild(KRequestPending); |
|
195 |
TRequestStatus statWilder(KRequestPending); |
|
196 |
||
197 |
test.Printf(_L("Notify Session Path %S\n"),&gSessionPath); |
|
198 |
test.Printf(_L("File Creation Session Path %S\n"),&sessionPath); |
|
199 |
||
200 |
// Submit notify change requests (requesting ahead) |
|
201 |
test.Printf(_L("Create a directory %S\n"),&path); |
|
202 |
||
203 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); // Watches drive associated with |
|
204 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
205 |
TheNotifyFs.NotifyChange(ENotifyDir,statDir,path); |
|
206 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\")); |
|
207 |
TheNotifyFs.NotifyChange(ENotifyAll,statWilder,_L("*:\\")); |
|
208 |
||
209 |
r=TheFs.MkDir(path); // Creates the directory on the drive |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
210 |
test_Value(r, (r == KErrNone)||(r==KErrAlreadyExists)); // associated with TheFs session path |
0 | 211 |
test (statEntry==KRequestPending); |
212 |
test(statFile==KRequestPending); |
|
213 |
test(statDir==KRequestPending); // No notification because it's watching a different drive! |
|
214 |
test(statWild==KErrNone); // BUG FIX TEST |
|
215 |
test(statWilder==KErrNone); |
|
216 |
||
217 |
// Don't need to resubmit notify change requests |
|
218 |
test.Next(_L("Create a file in the directory")); |
|
219 |
TheNotifyFs.NotifyChange(ENotifyFile,statWild,_L("?:\\F32-TST\\T_APPINS\\")); |
|
220 |
TheNotifyFs.NotifyChange(ENotifyFile,statWilder,_L("*:\\")); |
|
221 |
||
222 |
TFileName filePath; |
|
223 |
filePath=path; |
|
224 |
filePath+=_L("TestFile.app"); |
|
225 |
RFile file; |
|
226 |
r=file.Replace(TheFs,filePath,EFileRead|EFileWrite); |
|
227 |
file.Close(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
228 |
test_KErrNone(r); |
0 | 229 |
|
230 |
test (statEntry==KRequestPending); // No notification! |
|
231 |
test(statFile==KRequestPending); |
|
232 |
test(statDir==KRequestPending); |
|
233 |
test(statWild==KErrNone); |
|
234 |
test(statWilder==KErrNone); |
|
235 |
||
236 |
// No need to resubmit notify change requests |
|
237 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\T_APPINS\\")); |
|
238 |
TheNotifyFs.NotifyChange(ENotifyDir,statWilder,_L("*:\\")); |
|
239 |
||
240 |
r=TheFs.Delete(filePath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
241 |
test_KErrNone(r); |
0 | 242 |
// Still no notification |
243 |
test (statEntry==KRequestPending); |
|
244 |
test(statFile==KRequestPending); |
|
245 |
test(statDir==KRequestPending); |
|
246 |
test(statWild==KErrNone); |
|
247 |
test(statWilder==KRequestPending); |
|
248 |
||
249 |
// No need to resubmit notify change requests |
|
250 |
test.Next(_L("Remove the directory")); |
|
251 |
TheNotifyFs.NotifyChange(ENotifyDir,statWild,_L("?:\\F32-TST\\T_APPINS\\")); |
|
252 |
// TheNotifyFs.NotifyChange(ENotifyDir,statWilder,_L("*:\\")); |
|
253 |
r=TheFs.RmDir(path); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
254 |
test_KErrNone(r); |
0 | 255 |
// Still no notification |
256 |
test (statEntry==KRequestPending); |
|
257 |
test(statFile==KRequestPending); |
|
258 |
test(statDir==KRequestPending); |
|
259 |
test(statWild==KErrNone); |
|
260 |
test(statWilder==KErrNone); |
|
261 |
||
262 |
// Cancel the outstanding requests |
|
263 |
TheNotifyFs.NotifyChangeCancel(); |
|
264 |
} |
|
265 |
||
266 |
LOCAL_C void Test3() |
|
267 |
// |
|
268 |
// Test notification when session path of the notification session is set to be the |
|
269 |
// same as the drive and directory into which files and directories are created |
|
270 |
// |
|
271 |
{ |
|
272 |
TFileName path; |
|
273 |
path=_L("\\F32-TST\\T_APPINS\\"); |
|
274 |
TInt r=TheFs.RmDir(path); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
275 |
test_Value(r, (r == KErrNone)||(r==KErrNotFound)||(r==KErrPathNotFound)); |
0 | 276 |
|
277 |
TRequestStatus statEntry(KRequestPending); |
|
278 |
TRequestStatus statFile(KRequestPending); |
|
279 |
TRequestStatus statDir(KRequestPending); |
|
280 |
TRequestStatus statWild(KRequestPending); |
|
281 |
TRequestStatus statWilder(KRequestPending); |
|
282 |
||
283 |
test.Printf(_L("Session Path %S\n"),&gSessionPath); |
|
284 |
// Set the session path of the session which creates the file/directory to be |
|
285 |
// the same as the notification session's session path |
|
286 |
r=TheFs.SetSessionPath(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
287 |
test_KErrNone(r); |
0 | 288 |
|
289 |
// Submit notify change requests (requesting ahead) |
|
290 |
test.Printf(_L("Create a directory %S\n"),&path); |
|
291 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); |
|
292 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
293 |
TheNotifyFs.NotifyChange(ENotifyDir,statDir,path); |
|
294 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\")); |
|
295 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\")); |
|
296 |
||
297 |
r=TheFs.MkDir(path); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
298 |
test_Value(r, (r == KErrNone)||(r==KErrAlreadyExists)); |
0 | 299 |
User::WaitForAnyRequest(); |
300 |
test (statEntry==KErrNone); |
|
301 |
test(statFile==KErrNone); |
|
302 |
test(statDir==KErrNone); |
|
303 |
test(statWild==KErrNone); |
|
304 |
test(statWilder==KErrNone); |
|
305 |
||
306 |
// Resubmit notify change requests (requesting ahead) |
|
307 |
test.Next(_L("Create a file in the directory")); |
|
308 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); |
|
309 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
310 |
TheNotifyFs.NotifyChange(ENotifyDir,statDir,path); |
|
311 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\")); |
|
312 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\")); |
|
313 |
||
314 |
||
315 |
TFileName filePath; |
|
316 |
filePath=path; |
|
317 |
filePath+=_L("TestFile.app"); |
|
318 |
RFile file; |
|
319 |
r=file.Replace(TheFs,filePath,EFileRead|EFileWrite); |
|
320 |
file.Close(); |
|
321 |
User::WaitForAnyRequest(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
322 |
test_KErrNone(r); |
0 | 323 |
test (statEntry==KErrNone); |
324 |
test(statFile==KErrNone); |
|
325 |
test(statDir==KRequestPending); |
|
326 |
test(statWild==KErrNone); |
|
327 |
test(statWilder==KErrNone); |
|
328 |
||
329 |
// Resubmit notify change requests |
|
330 |
test.Next(_L("Remove the file from the directory")); |
|
331 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); |
|
332 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
333 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\")); |
|
334 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\")); |
|
335 |
||
336 |
r=TheFs.Delete(filePath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
337 |
test_KErrNone(r); |
0 | 338 |
User::WaitForAnyRequest(); |
339 |
test (statEntry==KErrNone); |
|
340 |
test(statFile==KErrNone); |
|
341 |
test(statDir==KRequestPending); |
|
342 |
test(statWild==KErrNone); |
|
343 |
test(statWilder==KErrNone); |
|
344 |
||
345 |
// Resubmit notify change requests |
|
346 |
test.Next(_L("Remove the directory")); |
|
347 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); |
|
348 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
349 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWild,_L("?:\\F32-TST\\")); |
|
350 |
TheNotifyFs.NotifyChange(ENotifyEntry,statWilder,_L("*:\\")); |
|
351 |
||
352 |
r=TheFs.RmDir(path); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
353 |
test_KErrNone(r); |
0 | 354 |
User::WaitForAnyRequest(); |
355 |
test (statEntry==KErrNone); |
|
356 |
test(statFile==KRequestPending); |
|
357 |
test(statDir==KErrNone); |
|
358 |
test(statWild==KErrNone); |
|
359 |
test(statWilder==KErrNone); |
|
360 |
||
361 |
// Cancel any outstanding notification change requests |
|
362 |
TheNotifyFs.NotifyChangeCancel(); |
|
363 |
} |
|
364 |
||
365 |
#if !defined(__WINS__) |
|
366 |
||
367 |
LOCAL_C void Test4() |
|
368 |
// |
|
369 |
// Test notification when session path is set to be different from the drive and directory |
|
370 |
// into which files and directories are created |
|
371 |
// |
|
372 |
{ |
|
373 |
TFileName path; |
|
374 |
TBuf<23> pathBuf=_L("?:\\F32-TST\\T_APPINS\\"); |
|
375 |
||
376 |
TChar driveChar; |
|
377 |
TInt r=RFs::DriveToChar(RemovableDrive,driveChar); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
378 |
test_KErrNone(r); |
0 | 379 |
|
380 |
if (gDriveToTest =='C') |
|
381 |
pathBuf[0]=driveChar; |
|
382 |
else |
|
383 |
pathBuf[0] =gDriveToTest; |
|
384 |
||
385 |
path = pathBuf; |
|
386 |
r=TheFs.RmDir(path); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
387 |
test_Value(r, (r == KErrNone)||(r==KErrNotFound)||(r==KErrPathNotFound)); |
0 | 388 |
|
389 |
TInt result; |
|
390 |
result=TheFs.MkDir(_L("C:\\SILLY\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
391 |
test_Value(result, (result == KErrNone)||(result==KErrAlreadyExists)); |
0 | 392 |
result=TheFs.MkDir(_L("C:\\SILLY\\SILLIER\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
393 |
test_Value(result, (result == KErrNone)||(result==KErrAlreadyExists)); |
0 | 394 |
result=TheFs.MkDir(_L("C:\\SILLY\\SILLIER\\SILLIEST\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
395 |
test_Value(result, (result == KErrNone)||(result==KErrAlreadyExists)); |
0 | 396 |
|
397 |
result=TheNotifyFs.SetSessionPath(_L("C:\\SILLY\\SILLIER\\SILLIEST\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
398 |
test_KErrNone(result); |
0 | 399 |
|
400 |
result=TheNotifyFs.SessionPath(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
401 |
test_KErrNone(result); |
0 | 402 |
test.Printf(_L("Session Path %S\n"),&gSessionPath); |
403 |
||
404 |
TRequestStatus statEntry(KRequestPending); |
|
405 |
TRequestStatus statFile(KRequestPending); |
|
406 |
TRequestStatus statDir(KRequestPending); |
|
407 |
||
408 |
// Submit notify change requests (requesting ahead) |
|
409 |
test.Printf(_L("Create a directory %S\n"),&path); |
|
410 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); |
|
411 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
412 |
TheNotifyFs.NotifyChange(ENotifyDir,statDir,path); |
|
413 |
||
414 |
r=TheFs.MkDir(path); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
415 |
test_Value(r, (r == KErrNone)||(r==KErrAlreadyExists)); |
0 | 416 |
User::WaitForAnyRequest(); |
417 |
test (statEntry==KErrNone); |
|
418 |
test(statFile==KErrNone); |
|
419 |
test(statDir==KErrNone); |
|
420 |
||
421 |
// Resubmit notify change requests (requesting ahead) |
|
422 |
test.Next(_L("Create a file in the directory")); |
|
423 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); |
|
424 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
425 |
TheNotifyFs.NotifyChange(ENotifyDir,statDir,path); |
|
426 |
||
427 |
TFileName filePath; |
|
428 |
filePath=path; |
|
429 |
filePath+=_L("TestFile.app"); |
|
430 |
RFile file; |
|
431 |
r=file.Replace(TheFs,filePath,EFileRead|EFileWrite); |
|
432 |
file.Close(); |
|
433 |
User::WaitForAnyRequest(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
434 |
test_KErrNone(r); |
0 | 435 |
test (statEntry==KErrNone); |
436 |
test(statFile==KErrNone); |
|
437 |
test(statDir==KRequestPending); |
|
438 |
||
439 |
// Resubmit notify change requests |
|
440 |
test.Next(_L("Remove the file from the directory")); |
|
441 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); |
|
442 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
443 |
||
444 |
r=TheFs.Delete(filePath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
445 |
test_KErrNone(r); |
0 | 446 |
User::WaitForAnyRequest(); |
447 |
test (statEntry==KErrNone); |
|
448 |
test(statFile==KErrNone); |
|
449 |
test(statDir==KRequestPending); |
|
450 |
||
451 |
// Resubmit notify change requests |
|
452 |
test.Next(_L("Remove the directory")); |
|
453 |
TheNotifyFs.NotifyChange(ENotifyEntry,statEntry,path); |
|
454 |
TheNotifyFs.NotifyChange(ENotifyFile,statFile,path); |
|
455 |
r=TheFs.RmDir(path); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
456 |
test_KErrNone(r); |
0 | 457 |
User::WaitForAnyRequest(); |
458 |
test (statEntry==KErrNone); |
|
459 |
test(statFile==KRequestPending); |
|
460 |
test(statDir==KErrNone); |
|
461 |
||
462 |
result=TheFs.RmDir(_L("C:\\SILLY\\SILLIER\\SILLIEST\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
463 |
test_Value(result, (result == KErrNone)||(result==KErrAlreadyExists)); |
0 | 464 |
result=TheFs.RmDir(_L("C:\\SILLY\\SILLIER\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
465 |
test_Value(result, (result == KErrNone)||(result==KErrAlreadyExists)); |
0 | 466 |
result=TheFs.RmDir(_L("C:\\SILLY\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
467 |
test_Value(result, (result == KErrNone)||(result==KErrAlreadyExists)); |
0 | 468 |
} |
469 |
||
470 |
#endif |
|
471 |
LOCAL_C void DoTests() |
|
472 |
// |
|
473 |
// Do all tests |
|
474 |
// |
|
475 |
{ |
|
476 |
Test1(); |
|
477 |
Test2(); |
|
478 |
Test3(); |
|
479 |
} |
|
480 |
||
481 |
GLDEF_D void CallTestsL(void) |
|
482 |
// |
|
483 |
// |
|
484 |
// |
|
485 |
{ |
|
486 |
test.Title(); |
|
487 |
||
488 |
TChar driveLetter; |
|
489 |
TChar driveChar; |
|
490 |
TDriveList drvList; |
|
491 |
TBuf<13> dirBuf=_L("?:\\F32-TST\\"); |
|
492 |
||
493 |
||
494 |
if (IsSessionDriveLFFS(TheFs,driveLetter)) |
|
495 |
{ |
|
496 |
test.Printf(_L("DoTestsL(): Skipped: test does not run on LFFS.\n")); |
|
497 |
return; |
|
498 |
} |
|
499 |
||
500 |
test.Start(_L("Testing filesystem")); |
|
501 |
TInt r=TheNotifyFs.Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
502 |
test_KErrNone(r); |
0 | 503 |
TFileName sessionPath; |
504 |
TInt uid; |
|
505 |
test(HAL::Get(HAL::EMachineUid,uid)==KErrNone); |
|
506 |
if(uid==HAL::EMachineUid_Cogent || uid==HAL::EMachineUid_IQ80310 || uid==HAL::EMachineUid_X86PC) |
|
507 |
{ |
|
508 |
test.Printf(_L("WARNING: d: not tested on cogent or IQ80310 \n")); |
|
509 |
goto End; |
|
510 |
} |
|
511 |
||
512 |
#if !defined(__WINS__) |
|
513 |
// MARM TESTS |
|
514 |
r=TheFs.MkDir(_L("C:\\F32-TST\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
515 |
test_Value(r, (r == KErrNone)||(r==KErrAlreadyExists)); |
0 | 516 |
|
517 |
if(KErrNone == TheFs.DriveList(drvList)) |
|
518 |
{ |
|
519 |
TInt i; |
|
520 |
//should be successful, otherwise it means a system w/o any drive!!! |
|
521 |
for(i=0;i<KMaxDrives;i++) |
|
522 |
{ |
|
523 |
TDriveInfo driveInfo; |
|
524 |
if((drvList[i] != 0) |
|
525 |
&& (KErrNone == TheFs.Drive(driveInfo, i)) |
|
526 |
&& (driveInfo.iType == EMediaHardDisk) |
|
527 |
&& (driveInfo.iDriveAtt & KDriveAttRemovable)) |
|
528 |
{ |
|
529 |
RemovableDrive = i; |
|
530 |
test.Printf(_L("RemovableDrive = %d\n"),RemovableDrive); |
|
531 |
break; |
|
532 |
} |
|
533 |
} |
|
534 |
if(i == KMaxDrives) |
|
535 |
{ |
|
536 |
test.Printf(_L("No Removable media found! Testing discontinued.\n")); |
|
537 |
User::Exit(KErrNone); |
|
538 |
} |
|
539 |
} |
|
540 |
else |
|
541 |
{ |
|
542 |
test.Printf(_L("No Drive found! Testing discontinued.\n")); |
|
543 |
User::Exit(KErrNone); |
|
544 |
} |
|
545 |
||
546 |
r=RFs::DriveToChar(RemovableDrive,driveChar); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
547 |
test_KErrNone(r); |
0 | 548 |
|
549 |
if(gDriveToTest == 'C') |
|
550 |
dirBuf[0] = (TText)driveChar; |
|
551 |
else |
|
552 |
dirBuf[0] = (TText)gDriveToTest; |
|
553 |
||
554 |
r=TheFs.MkDir(dirBuf); |
|
555 |
if ((r!=KErrNone)||(r!=KErrAlreadyExists)) |
|
556 |
{ |
|
557 |
test.Printf(_L("TEST REQUIRES A CF CARD - ")); |
|
558 |
//test.Printf(_L("PUT A VALID CARD IN AND PRESS A KEY...")); |
|
559 |
//test.Getch(); |
|
560 |
r=TheFs.MkDir(dirBuf); |
|
561 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
562 |
test_Value(r, (r == KErrNone)||(r==KErrAlreadyExists)); |
0 | 563 |
|
564 |
// Set the notification session path to the test directory on C drive |
|
565 |
sessionPath=_L("C:\\F32-TST\\"); |
|
566 |
r=TheNotifyFs.SetSessionPath(sessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
567 |
test_KErrNone(r); |
0 | 568 |
// Run tests |
569 |
TRAP(r,DoTests()); |
|
570 |
if (r!=KErrNone) |
|
571 |
test.Printf(_L("Error: %d\n"),r); |
|
572 |
Test4(); |
|
573 |
CheckDisk(); |
|
574 |
||
575 |
// Set the notification session path to the test directory on gDriveToTest |
|
576 |
if(gDriveToTest == 'C') |
|
577 |
sessionPath[0] = (TText)driveChar; |
|
578 |
else |
|
579 |
sessionPath[0] = (TText)gDriveToTest; |
|
580 |
||
581 |
||
582 |
r=TheNotifyFs.SetSessionPath(sessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
583 |
test_KErrNone(r); |
0 | 584 |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
585 |
test_KErrNone(r); |
0 | 586 |
TRAP(r,DoTests()); |
587 |
if (r!=KErrNone) |
|
588 |
test.Printf(_L("Error: %d\n"),r); |
|
589 |
Test4(); |
|
590 |
CheckDisk(); |
|
591 |
#elif defined (__WINS__) |
|
592 |
r=TheFs.MkDir(_L("X:\\F32-TST\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
593 |
test_Value(r, (r == KErrNone)||(r==KErrAlreadyExists)); |
0 | 594 |
r=TheFs.MkDir(_L("Y:\\F32-TST\\")); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
595 |
test_Value(r, (r == KErrNone)||(r==KErrAlreadyExists)); |
0 | 596 |
// Set session path to test directory on Y drive |
597 |
r=TheNotifyFs.SetSessionPath(_L("Y:\\F32-TST\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
598 |
test_KErrNone(r); |
0 | 599 |
TRAP(r,DoTests()); |
600 |
if (r!=KErrNone) |
|
601 |
test.Printf(_L("Error: %d\n"),r); |
|
602 |
||
603 |
CheckDisk(); |
|
604 |
||
605 |
//we have no X drive on eka2 yet |
|
606 |
// Set session path to test directory on X drive |
|
607 |
// r=TheNotifyFs.SetSessionPath(_L("X:\\F32-TST\\")); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
608 |
// test_KErrNone(r); |
0 | 609 |
// TRAP(r,DoTests()); |
610 |
||
611 |
if (r!=KErrNone) |
|
612 |
test.Printf(_L("Error: %d\n"),r); |
|
613 |
||
614 |
CheckDisk(); |
|
615 |
#endif |
|
616 |
||
617 |
End: |
|
618 |
TheNotifyFs.Close(); |
|
619 |
test.End(); |
|
620 |
test.Close(); |
|
621 |
} |
|
622 |