author | hgs |
Tue, 02 Nov 2010 15:42:21 +0000 | |
changeset 301 | 172f33f13d7d |
parent 300 | 1d28c8722707 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2008-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_notifier.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
189 | 18 |
#define __E32TEST_EXTENSION__ |
0 | 19 |
#include <f32file.h> |
20 |
#include <e32test.h> |
|
21 |
#include <e32svr.h> |
|
22 |
#include <hal.h> |
|
23 |
#include "t_server.h" |
|
24 |
#include "t_chlffs.h" |
|
25 |
#include "t_notify_plugin.h" |
|
300 | 26 |
#include "f32_test_utils.h" |
0 | 27 |
|
28 |
const TInt KNotificationHeaderSize = (sizeof(TUint16)*2)+(sizeof(TUint)); |
|
29 |
const TInt KMinNotificationBufferSize = 2*KNotificationHeaderSize + 2*KMaxFileName; |
|
30 |
||
31 |
||
32 |
RTest test(_L("T_NOTIFIER")); |
|
33 |
const TInt KMaxHeapSize = 0x800000; |
|
34 |
TInt globalDriveNum; |
|
300 | 35 |
TBuf<50> filesystem; //storing original file system name |
36 |
_LIT(KTestNotifyFileSystemExeName,"t_tfsys_notify.fsy"); |
|
37 |
_LIT(KNotifyTestFileSystem,"CNotifyTestFileSystem"); |
|
0 | 38 |
|
39 |
void DismountPlugin() |
|
40 |
{ |
|
41 |
TheFs.DismountPlugin(KNotifyPluginName); |
|
42 |
TheFs.RemovePlugin(KNotifyPluginFileName); |
|
43 |
} |
|
44 |
||
300 | 45 |
void RemountOriginalFileSystem() |
46 |
{ |
|
47 |
//Replace old FS. |
|
48 |
TheFs.DismountFileSystem(KNotifyTestFileSystem,globalDriveNum); |
|
49 |
TheFs.MountFileSystem(filesystem,globalDriveNum); |
|
50 |
TheFs.RemoveFileSystem(KNotifyTestFileSystem); |
|
51 |
} |
|
52 |
||
53 |
inline void safe_external_test(RTest& aTest, TInt aError, TInt aLine, TText* aName) |
|
54 |
{ |
|
55 |
if(aError!=KErrNone) |
|
56 |
{ |
|
57 |
test.Printf(_L(": ERROR : %d received on line %d\n"),aError,aLine); |
|
58 |
RemountOriginalFileSystem(); |
|
59 |
aTest.operator()(aError==KErrNone,aLine,(TText*)aName); |
|
60 |
} |
|
61 |
} |
|
62 |
||
0 | 63 |
inline void safe_test(RTest& aTest, TInt aError, TInt aLine, TText* aName) |
64 |
{ |
|
65 |
if(aError!=KErrNone) |
|
66 |
{ |
|
67 |
test.Printf(_L(": ERROR : %d received on line %d\n"),aError,aLine); |
|
68 |
DismountPlugin(); |
|
69 |
aTest.operator()(aError==KErrNone,aLine,(TText*)aName); |
|
70 |
} |
|
71 |
} |
|
72 |
||
73 |
// Used by TestMultipleNotificationsL() to show which line the function is called from |
|
74 |
inline void safe_test(RTest& aTest, TInt aError, TInt aLine, TInt aLineCall) |
|
75 |
{ |
|
76 |
if(aError != KErrNone) |
|
77 |
{ |
|
78 |
aTest.Printf(_L(": ERROR : %d received on line %d\n"), aError, aLine); |
|
79 |
aTest.Printf(_L(": ERROR : Function called from line number: %d\n"), aLineCall); |
|
80 |
aTest.operator()(aError == KErrNone, aLine); |
|
81 |
} |
|
82 |
} |
|
83 |
||
84 |
// Prints out the filename |
|
85 |
#define ExpandMe(X) L ## X |
|
86 |
#define Expand(X) ExpandMe(X) |
|
87 |
||
88 |
namespace t_notification |
|
89 |
{ |
|
90 |
enum EOperation |
|
91 |
{ |
|
92 |
//TFsNotification::ECreate |
|
93 |
EFileReplace, |
|
94 |
EFileCreate, |
|
95 |
EFileCreate_subs, //Create files in subdir, watch subdirs |
|
96 |
EFileCreate_subs_nowatch, //Create files in subdir, do not monitor subdirs |
|
97 |
EFileCreate_txt_nowatch, //Create .txt files in subdir, do not monitor subdirs |
|
98 |
EFileCreate_txt, //Create .txt files |
|
99 |
EFsMkDir, //Create directory |
|
100 |
//TFsNotification::EAttribute |
|
101 |
EFileSetAtt, |
|
102 |
EFileSetAtt_subs, //Set attributes in subdir |
|
103 |
EFileSet, |
|
104 |
EFsSetEntry, |
|
105 |
//TFsNotification::ERename |
|
106 |
EFsReplace, //Replace file |
|
107 |
EFsRename, //Rename file |
|
108 |
EFsRename_dir, //Rename directory |
|
109 |
EFileRename, |
|
110 |
EFileRename_wild, //Rename file using wildcard name |
|
111 |
//TFsNotification::EDelete |
|
112 |
EFsDelete, //Delete file |
|
113 |
EFsRmDir, //Remove directory |
|
114 |
EFsRmDir_nonEmpty, //Remove non-empty directory, which will return KErrInUse |
|
115 |
EFsRmDir_wild, //Remove subdirectory using wildcard name |
|
116 |
//TFsNotification::EFileChange |
|
117 |
EFileWrite, |
|
118 |
EFileWrite_samesize, //Write to file without changing its size |
|
119 |
EFileWrite_async, //Asynchronous write |
|
120 |
EFileSetSize, |
|
121 |
//TFsNotification::EVolumeName |
|
122 |
ESetVolumeLabel, |
|
123 |
//TFsNotification::EDriveName |
|
124 |
ESetDriveName, |
|
125 |
//TFsNotification::EMediaChange |
|
126 |
EMount, |
|
127 |
EDismount, |
|
128 |
EMountScan, |
|
129 |
EMountDismount, |
|
130 |
EFormat, |
|
131 |
EMediaCardRemoval, |
|
132 |
EMediaCardInsertion, |
|
133 |
ERawDiskWrite, |
|
134 |
//Multiple Filters |
|
135 |
EAllOps1, //Create/Replace and Delete |
|
136 |
EAllOps2, //Create/Replace, FileChange(Write) and Delete |
|
137 |
EAllOps3, //Create/Replace, FileChange(SetSize) and Delete |
|
138 |
EAllOps4, //Create/Replace, Attribute(SetAtt) and Delete |
|
139 |
EAllOps5, //Create/Replace and Rename |
|
140 |
EAllOps6, //VolumeName and DriveName |
|
141 |
ECFileManMove //Create filex in monitored directory, write 4, move to unmonitored, setsize 8, move back, delete |
|
142 |
}; |
|
143 |
} |
|
144 |
||
145 |
// Package filename and semaphore for thread |
|
146 |
struct SThreadPackage |
|
147 |
{ |
|
148 |
TFileName iFileName; |
|
149 |
RSemaphore iBarrier; |
|
150 |
}; |
|
151 |
||
152 |
struct SThreadPackageDualSemaphore |
|
153 |
{ |
|
154 |
TFileName iFileName; |
|
155 |
RSemaphore iBarrier; |
|
156 |
RSemaphore iBarrier2; |
|
157 |
}; |
|
158 |
||
159 |
struct SThreadPackage2 |
|
160 |
{ |
|
161 |
TInt iTestCase; |
|
162 |
RSemaphore iBarrier; |
|
163 |
}; |
|
164 |
||
165 |
// Used by TestMultipleNotificationsL |
|
166 |
struct SThreadPackageMultiple |
|
167 |
{ |
|
168 |
TFileName iString; //Commonly stores the filename |
|
169 |
TFileName iFileName; //Commonly stores the path (not inc filename) |
|
170 |
RSemaphore iBarrier; |
|
171 |
t_notification::EOperation iOperation; |
|
172 |
TFsNotification::TFsNotificationType iNotifyType; |
|
173 |
TInt iIterations; //# of times to 'do' something |
|
174 |
TInt iMaxNotifications; //# of notifications expected |
|
175 |
TInt iBufferSize; |
|
176 |
TInt iLineCall; //Line where the function is called from |
|
177 |
}; |
|
178 |
||
179 |
void PrintLine() |
|
180 |
{ |
|
181 |
test.Printf(_L("======================================================================\n")); |
|
182 |
} |
|
183 |
||
184 |
||
185 |
// We should receive an EMediaChange notification even though we did not register for it |
|
186 |
void TestMediaCardNotificationWhenNotRegisteredForIt() |
|
187 |
{ |
|
188 |
RFs fs; |
|
189 |
TInt r = fs.Connect(); |
|
189 | 190 |
test_KErrNone(r); |
0 | 191 |
|
192 |
CFsNotify* notify = NULL; |
|
193 |
TRAP(r,notify= CFsNotify::NewL(fs,KMinNotificationBufferSize)); |
|
194 |
||
195 |
TBuf<40> path; |
|
196 |
path.Append((TChar)gDriveToTest); |
|
197 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
198 |
||
199 |
TBuf<20> filename; |
|
200 |
filename.Append(_L("media.change1")); |
|
201 |
||
202 |
r = notify->AddNotification((TUint)TFsNotification::ECreate,path,filename); |
|
189 | 203 |
test_KErrNone(r); |
0 | 204 |
|
205 |
TRequestStatus status; |
|
206 |
r = notify->RequestNotifications(status); |
|
189 | 207 |
test_KErrNone(r); |
0 | 208 |
|
209 |
test.Printf(_L("*****************************************************************\n")); |
|
210 |
test.Printf(_L("Waiting 10 seconds.\n")); |
|
211 |
test.Printf(_L("This is a MANUAL test, it requires the removal of the media card.\n")); |
|
212 |
test.Printf(_L("PLEASE REMOVE THE MEDIA CARD. (DriveNumber %d)\n"),globalDriveNum); |
|
213 |
test.Printf(_L("Or press Ctrl + F5 on the emulator.\n")); |
|
214 |
test.Printf(_L("*****************************************************************\n")); |
|
215 |
RTimer timer1; |
|
216 |
r = timer1.CreateLocal(); |
|
189 | 217 |
test_KErrNone(r); |
0 | 218 |
TRequestStatus timeout; |
219 |
TTimeIntervalMicroSeconds32 time = 10000000; |
|
220 |
timer1.After(timeout,time); |
|
221 |
User::WaitForRequest(timeout,status); |
|
222 |
test(status.Int() != KRequestPending); |
|
223 |
timer1.Cancel(); |
|
224 |
timer1.Close(); |
|
225 |
||
226 |
const TFsNotification* notification = notify->NextNotification(); |
|
227 |
test(notification != NULL); |
|
228 |
TFsNotification::TFsNotificationType type = notification->NotificationType(); |
|
229 |
test(type == TFsNotification::EMediaChange); |
|
230 |
TBuf<2> drive; |
|
231 |
drive.Append((TChar)gDriveToTest); |
|
232 |
drive.Append(_L(":")); |
|
233 |
TPtrC drivePtr; |
|
234 |
r = notification->Path(drivePtr); |
|
189 | 235 |
test_KErrNone(r); |
0 | 236 |
r = drivePtr.Compare(drive); |
189 | 237 |
test_Value(r, r == 0); |
0 | 238 |
|
239 |
test.Printf(_L("*****************************************************************\n")); |
|
240 |
test.Printf(_L("Waiting 10 seconds.\n")); |
|
241 |
test.Printf(_L("This is a MANUAL test, it requires the insertion of the media card.\n")); |
|
242 |
test.Printf(_L("PLEASE INSERT THE MEDIA CARD. (DriveNumber %d)\n"),globalDriveNum); |
|
243 |
test.Printf(_L("Or press Ctrl + F5 on the emulator.\n")); |
|
244 |
test.Printf(_L("*****************************************************************\n")); |
|
245 |
||
246 |
notification = notify->NextNotification(); |
|
247 |
if(notification == NULL) |
|
248 |
{ |
|
249 |
notify->RequestNotifications(status); |
|
250 |
RTimer timer2; |
|
251 |
r = timer2.CreateLocal(); |
|
189 | 252 |
test_KErrNone(r); |
0 | 253 |
TRequestStatus timeout2; |
254 |
timer2.After(timeout2,time); |
|
255 |
User::WaitForRequest(timeout2,status); |
|
256 |
test(status.Int() != KRequestPending); |
|
257 |
notification = notify->NextNotification(); |
|
258 |
timer2.Cancel(); |
|
259 |
timer2.Close(); |
|
260 |
} |
|
261 |
test(notification != NULL); |
|
262 |
type = notification->NotificationType(); |
|
263 |
test(type == TFsNotification::EMediaChange); |
|
264 |
||
265 |
delete notify; |
|
266 |
fs.Close(); |
|
267 |
} |
|
268 |
||
269 |
// Creates two sessions, removes the first one |
|
270 |
// and then checks if the second one still works |
|
271 |
TInt TestClientRemovalL() |
|
272 |
{ |
|
273 |
RFs fs; |
|
274 |
TInt r = fs.Connect(); |
|
189 | 275 |
test_KErrNone(r); |
0 | 276 |
|
277 |
CFsNotify* notify1 = NULL; |
|
278 |
CFsNotify* notify2 = NULL; |
|
279 |
TRAP(r,notify1= CFsNotify::NewL(fs,KMinNotificationBufferSize); |
|
280 |
notify2= CFsNotify::NewL(fs,KMinNotificationBufferSize); |
|
281 |
); |
|
282 |
if(r!=KErrNone) |
|
283 |
{ |
|
284 |
delete notify1; |
|
285 |
delete notify2; |
|
189 | 286 |
test_KErrNone(r); |
0 | 287 |
} |
288 |
||
289 |
TBuf<40> path; |
|
290 |
path.Append((TChar)gDriveToTest); |
|
291 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
292 |
||
293 |
TBuf<15> filename; |
|
294 |
filename.Append(_L("create.file")); |
|
295 |
||
296 |
TBuf<40> fullname; |
|
297 |
fullname.Append(path); |
|
298 |
fullname.Append(filename); |
|
299 |
||
300 |
r = notify1->AddNotification((TUint)TFsNotification::ECreate,path,filename); |
|
189 | 301 |
test_KErrNone(r); |
0 | 302 |
r = notify2->AddNotification((TUint)TFsNotification::ECreate,path,filename); |
189 | 303 |
test_KErrNone(r); |
0 | 304 |
|
305 |
delete notify1; //Delete notify1 and ensure we still get notification on notify2 |
|
306 |
||
307 |
TRequestStatus status; |
|
308 |
r = notify2->RequestNotifications(status); |
|
189 | 309 |
test_KErrNone(r); |
0 | 310 |
|
311 |
RFile file; |
|
312 |
file.Replace(fs,fullname,EFileWrite); //Replace produces Create notification |
|
313 |
file.Close(); |
|
314 |
||
315 |
RTimer tim; |
|
316 |
r = tim.CreateLocal(); |
|
189 | 317 |
test_KErrNone(r); |
0 | 318 |
|
319 |
TRequestStatus timStatus; |
|
320 |
TTimeIntervalMicroSeconds32 time = 10000000; //10 seconds |
|
321 |
tim.After(timStatus,time); |
|
322 |
||
323 |
User::WaitForRequest(status,timStatus); |
|
324 |
test(status!=KRequestPending); |
|
325 |
||
326 |
r = fs.Delete(fullname); |
|
189 | 327 |
test_KErrNone(r); |
0 | 328 |
|
329 |
delete notify2; |
|
330 |
tim.Close(); |
|
331 |
fs.Close(); |
|
332 |
return KErrNone; |
|
333 |
} |
|
334 |
||
335 |
/* |
|
336 |
* This tests that u can set and receive notifications in the root |
|
337 |
* of a drive. |
|
338 |
* |
|
339 |
* (something which was apparently not possible on RFs::NotifyChange) |
|
340 |
*/ |
|
341 |
TInt TestRootDriveNotifications() |
|
342 |
{ |
|
343 |
test.Next(_L("TestRootDriveNotifications")); |
|
344 |
RFs fs; |
|
345 |
fs.Connect(); |
|
346 |
||
347 |
CFsNotify* notify = NULL; |
|
348 |
||
349 |
TRAPD(r,notify = CFsNotify::NewL(fs,KMinNotificationBufferSize);); |
|
189 | 350 |
test_KErrNone(r); |
0 | 351 |
test(notify!=NULL); |
352 |
||
353 |
TBuf<40> path; |
|
354 |
path.Append((TChar)gDriveToTest); |
|
355 |
path.Append(_L(":\\")); |
|
356 |
||
357 |
TBuf<15> filename; |
|
358 |
filename.Append(_L("*")); |
|
359 |
||
360 |
r = notify->AddNotification((TUint)TFsNotification::ECreate,path,filename); |
|
189 | 361 |
test_KErrNone(r); |
0 | 362 |
|
363 |
TRequestStatus status; |
|
364 |
r = notify->RequestNotifications(status); |
|
189 | 365 |
test_KErrNone(r); |
0 | 366 |
|
367 |
RFile file; |
|
368 |
TBuf<40> filePath; |
|
369 |
filePath.Append((TChar)gDriveToTest); |
|
370 |
filePath.Append(_L(":\\file.root")); |
|
371 |
r = file.Replace(fs,filePath,EFileRead); |
|
189 | 372 |
test_KErrNone(r); |
0 | 373 |
file.Close(); |
374 |
||
375 |
TRequestStatus s2; |
|
376 |
RTimer tim; |
|
377 |
test(tim.CreateLocal()==KErrNone); |
|
378 |
TTimeIntervalMicroSeconds32 time = 10000000; //10 seconds |
|
379 |
tim.After(s2,time); |
|
380 |
User::WaitForRequest(status,s2); |
|
381 |
test(status!=KRequestPending); |
|
382 |
||
383 |
delete notify; |
|
384 |
notify = NULL; |
|
385 |
tim.Close(); |
|
386 |
fs.Close(); |
|
387 |
return KErrNone; |
|
388 |
} |
|
389 |
||
390 |
/* |
|
391 |
* Creates and deletes loads of CFsNotify objects and makes sure they're all |
|
392 |
* cleaned up afterwards. |
|
393 |
*/ |
|
394 |
TInt TestNewDeleteCFsNotify(TInt aIterations) |
|
395 |
{ |
|
396 |
RPointerArray<CFsNotify> array; |
|
397 |
TInt inArray = 0; |
|
398 |
TInt r = KErrNone; |
|
399 |
for(TInt i = 0; i < aIterations; i++) |
|
400 |
{ |
|
401 |
CFsNotify* notify = NULL; |
|
402 |
TRAP(r,notify = CFsNotify::NewL(TheFs,500)); |
|
403 |
if(r==KErrNone) |
|
404 |
{ |
|
405 |
test(notify!=NULL); |
|
406 |
r = array.Append(notify); |
|
407 |
if(r==KErrNone) |
|
408 |
{ |
|
409 |
inArray++; |
|
410 |
} |
|
411 |
else |
|
412 |
{ |
|
413 |
delete notify; |
|
414 |
break; |
|
415 |
} |
|
416 |
} |
|
417 |
else |
|
418 |
{ |
|
419 |
break; |
|
420 |
} |
|
421 |
} |
|
422 |
||
423 |
for(TInt j = inArray-1; j >= 0; j--) |
|
424 |
{ |
|
425 |
CFsNotify* notify = (CFsNotify*)array[j]; |
|
426 |
array.Remove(j); |
|
427 |
delete notify; |
|
428 |
} |
|
429 |
||
430 |
array.Reset(); |
|
431 |
array.Close(); |
|
432 |
return KErrNone; |
|
433 |
} |
|
434 |
||
435 |
||
436 |
/* |
|
437 |
* Creates a file |
|
438 |
* Used in SimpleTest1L(), TestTwoDoersL() TestTwoWatchersL(), TestCancelNotificationL() |
|
439 |
*/ |
|
440 |
TInt SimpleSingleNotificationTFDoer(TAny* aAny) |
|
441 |
{ |
|
442 |
SThreadPackageDualSemaphore pkgDoer = *(SThreadPackageDualSemaphore*)aAny; |
|
443 |
RTest simpleTestDoer(_L("SimpleSingleNotificationTFDoer")); |
|
444 |
simpleTestDoer.Start(_L("SimpleSingleNotificationTFDoer")); |
|
445 |
TBuf<40> path; |
|
446 |
path.Append(gDriveToTest); |
|
447 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
448 |
path.Append(pkgDoer.iFileName); |
|
449 |
||
450 |
//Delete file so we definitely get a create notification |
|
451 |
RFs fs; |
|
452 |
TInt r = fs.Connect(); |
|
453 |
safe_test(simpleTestDoer,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
454 |
r = fs.Delete(path); |
|
455 |
if(r==KErrNone || r==KErrPathNotFound || r==KErrNotFound) |
|
456 |
r = KErrNone; |
|
457 |
safe_test(simpleTestDoer,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
458 |
r = fs.MkDirAll(path); |
|
459 |
if(r==KErrNone || r==KErrAlreadyExists) |
|
460 |
r = KErrNone; |
|
461 |
safe_test(simpleTestDoer,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
462 |
||
463 |
simpleTestDoer.Printf(_L("SimpleSingleNotificationTFDoer - Create File %S\n"),&path); |
|
464 |
//Create file |
|
465 |
RFile file; |
|
466 |
r = file.Create(fs,path,EFileWrite); |
|
467 |
safe_test(simpleTestDoer,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
468 |
file.Close(); |
|
469 |
||
470 |
fs.Close(); |
|
471 |
simpleTestDoer.End(); |
|
472 |
simpleTestDoer.Close(); |
|
473 |
return KErrNone; |
|
474 |
} |
|
475 |
||
476 |
/* |
|
477 |
* Watches 1 file creation |
|
478 |
* Used in SimpleTest1L() |
|
479 |
*/ |
|
480 |
TInt SimpleSingleNotificationTFWatcher(TAny* aAny) |
|
481 |
{ |
|
482 |
CTrapCleanup* cleanup; |
|
483 |
cleanup = CTrapCleanup::New(); |
|
484 |
RThread thread; |
|
485 |
TUint64 threadId = thread.Id().Id(); |
|
486 |
||
487 |
SThreadPackage pkgDoer = *(SThreadPackage*)aAny; |
|
488 |
RSemaphore& simpleBarrierTest = pkgDoer.iBarrier; |
|
489 |
||
490 |
RTest simpleTestWatcher(_L("SimpleSingleNotificationTFWatcher")); |
|
491 |
simpleTestWatcher.Start(_L("SimpleSingleNotificationTFWatcher")); |
|
492 |
||
493 |
RFs fs; |
|
494 |
fs.Connect(); |
|
495 |
||
496 |
simpleTestWatcher.Printf(_L("SimpleSingleNotificationTFWatcher(%d) - Create CFsNotify\n"),threadId); |
|
497 |
CFsNotify* notify = NULL; |
|
498 |
TRAPD(r,notify = CFsNotify::NewL(fs,100); ); |
|
499 |
safe_test(simpleTestWatcher,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
500 |
TBuf<40> path; |
|
501 |
path.Append(gDriveToTest); |
|
502 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); //len=22 |
|
503 |
||
504 |
TBuf<20> filename; |
|
505 |
filename.Append(pkgDoer.iFileName); |
|
506 |
||
507 |
TBuf<40> fullname; |
|
508 |
fullname.Append(path); |
|
509 |
fullname.Append(filename); |
|
510 |
||
511 |
simpleTestWatcher.Printf(_L("SimpleSingleNotificationTFWatcher - Add Notification for %S\n"),&path); |
|
512 |
r = notify->AddNotification((TUint)TFsNotification::ECreate,path,filename); |
|
513 |
safe_test(simpleTestWatcher,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
514 |
TRequestStatus status; |
|
515 |
simpleTestWatcher.Printf(_L("SimpleSingleNotificationTFWatcher(%d) - Request Notifications\n"),threadId); |
|
516 |
r = notify->RequestNotifications(status); |
|
517 |
safe_test(simpleTestWatcher,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
518 |
||
519 |
simpleBarrierTest.Signal(); |
|
520 |
||
521 |
simpleTestWatcher.Printf(_L("SimpleSingleNotificationTFWatcher(%d) - Wait for status to return\n"),threadId); |
|
522 |
User::WaitForRequest(status); |
|
523 |
||
524 |
simpleTestWatcher.Printf(_L("(%d) NextNotification\n"),threadId); |
|
525 |
const TFsNotification* notification = notify->NextNotification(); |
|
526 |
//Test notification is not null. |
|
527 |
//We should be getting 1 notification. |
|
528 |
if(notification == NULL) |
|
529 |
safe_test(simpleTestWatcher,KErrNotFound,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
530 |
||
531 |
simpleTestWatcher.Printf(_L("(%d) - Notification Type\n"),threadId); |
|
532 |
TFsNotification::TFsNotificationType notificationType = ((TFsNotification*)notification)->NotificationType(); |
|
533 |
if(notificationType != TFsNotification::ECreate) |
|
534 |
safe_test(simpleTestWatcher,KErrGeneral,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
535 |
simpleTestWatcher.Printf(_L("(%d) - Notification Path\n"),threadId); |
|
536 |
TPtrC _pathC; |
|
537 |
((TFsNotification*)notification)->Path(_pathC); |
|
538 |
simpleTestWatcher.Printf(_L("Notification Path = %S\n"),&_pathC); |
|
539 |
TBuf<40> _path; |
|
540 |
_path.Copy(_pathC); |
|
541 |
if(_path.Match(fullname)!=KErrNone) |
|
542 |
safe_test(simpleTestWatcher,KErrBadName,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
543 |
||
300 | 544 |
|
0 | 545 |
TInt driveNumber = 0; |
546 |
TInt gDriveNum = -1; |
|
547 |
notification->DriveNumber(driveNumber); |
|
548 |
RFs::CharToDrive(_pathC[0],gDriveNum); |
|
549 |
if(driveNumber != gDriveNum) |
|
550 |
safe_test(simpleTestWatcher,KErrBadHandle,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
551 |
||
552 |
TUid uid; |
|
300 | 553 |
TInt32 realUID = 0x76543210; |
0 | 554 |
r = notification->UID(uid); |
555 |
safe_test(simpleTestWatcher,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
300 | 556 |
safe_test(simpleTestWatcher,((realUID == uid.iUid)?KErrNone:KErrNotFound),__LINE__,(TText*)Expand("t_notifier.cpp")); |
557 |
||
0 | 558 |
delete notify; |
559 |
fs.Close(); |
|
560 |
simpleTestWatcher.End(); |
|
561 |
simpleTestWatcher.Close(); |
|
562 |
delete cleanup; |
|
563 |
return KErrNone; |
|
564 |
} |
|
565 |
||
566 |
/* |
|
567 |
* SimpleTest1L - Runs a simple Create test, gets 1 notification, calls type, path etc and exits |
|
568 |
* Two threads: 1 watcher, 1 doer |
|
569 |
*/ |
|
570 |
TInt SimpleCreateTestL() |
|
571 |
{ |
|
572 |
test.Next(_L("SimpleTest")); |
|
573 |
RFs fs; |
|
574 |
fs.Connect(); |
|
575 |
_LIT(KFileName,"simple.create"); |
|
576 |
SThreadPackage pkgDoer; |
|
577 |
pkgDoer.iFileName = KFileName; |
|
578 |
||
579 |
SThreadPackage watcherPkg; |
|
580 |
watcherPkg.iFileName = KFileName; |
|
581 |
User::LeaveIfError(pkgDoer.iBarrier.CreateLocal(0)); |
|
582 |
User::LeaveIfError(watcherPkg.iBarrier.CreateLocal(0)); |
|
583 |
RThread watcher; |
|
584 |
RThread doer; |
|
585 |
watcher.Create(_L("Simple1WatcherThread"),SimpleSingleNotificationTFWatcher,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&watcherPkg); |
|
586 |
doer.Create(_L("Simple1DoerThread"),SimpleSingleNotificationTFDoer,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&pkgDoer); |
|
587 |
watcher.Resume(); |
|
588 |
watcherPkg.iBarrier.Wait(); //Wait till Watcher has requested notification |
|
589 |
doer.Resume(); |
|
590 |
||
591 |
TRequestStatus status; |
|
592 |
doer.Logon(status); |
|
593 |
User::WaitForRequest(status); |
|
594 |
test.Printf(_L("SimpleCreateTest - Doer Exit Reason = %d\n"),doer.ExitReason()); |
|
595 |
safe_test(test,doer.ExitReason(),__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
596 |
||
597 |
RDebug::Print(_L("Line %d"),__LINE__); |
|
598 |
||
599 |
||
600 |
watcher.Logon(status); |
|
601 |
RTimer timer1; |
|
602 |
TInt r = timer1.CreateLocal(); |
|
603 |
safe_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
604 |
TRequestStatus timeout; |
|
605 |
TTimeIntervalMicroSeconds32 time = 10000000; //10 seconds |
|
606 |
timer1.After(timeout,time); |
|
607 |
User::WaitForRequest(timeout,status); |
|
608 |
test(status.Int() != KRequestPending); |
|
609 |
timer1.Cancel(); |
|
610 |
timer1.Close(); |
|
611 |
||
612 |
||
613 |
// User::WaitForRequest(status); |
|
614 |
test.Printf(_L("SimpleCreateTest - Watcher Exit Reason = %d\n"),watcher.ExitReason()); |
|
615 |
safe_test(test,watcher.ExitReason(),__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
616 |
||
617 |
CLOSE_AND_WAIT(doer); |
|
618 |
CLOSE_AND_WAIT(watcher); |
|
619 |
||
620 |
pkgDoer.iBarrier.Close(); |
|
621 |
watcherPkg.iBarrier.Close(); |
|
622 |
fs.Close(); |
|
623 |
return KErrNone; |
|
624 |
} |
|
625 |
||
626 |
// Doer thread for TestMultipleNotificationsL |
|
627 |
TInt MultipleNotificationTFDoer(TAny* aAny) |
|
628 |
{ |
|
629 |
RDebug::Print(_L("MultipleNotificationTFDoer - Start, Line %d"), __LINE__); |
|
630 |
SThreadPackageMultiple pkgDoer = *(SThreadPackageMultiple*)aAny; |
|
631 |
RTest multipleTestDoer(_L("MultipleNotificationTFDoer")); |
|
632 |
multipleTestDoer.Start(_L("Multi-Doer")); |
|
633 |
multipleTestDoer.Printf(_L("MultipleNotificationTFDoer - Line %d"),__LINE__); |
|
634 |
TBuf<40> basepath; |
|
635 |
basepath.Append(gDriveToTest); |
|
636 |
basepath.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
637 |
||
638 |
RThread thread; |
|
639 |
RDebug::Print(_L("MultipleNotificationTFDoer - Line %d"), __LINE__); |
|
640 |
TUint64 threadID = thread.Id().Id(); |
|
641 |
RDebug::Print(_L("MultipleNotificationTFDoer - Line %d"), __LINE__); |
|
642 |
||
643 |
//Delete file so we definitely get a create notification |
|
644 |
RFs fs; |
|
645 |
TInt r = fs.Connect(); |
|
646 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
647 |
||
648 |
TEntry entry; |
|
649 |
TBool wildcard = EFalse; |
|
650 |
TBuf<40> _path; |
|
651 |
_path.Append(basepath); |
|
652 |
_path.Append(pkgDoer.iFileName); |
|
653 |
_path.Append(pkgDoer.iString); |
|
654 |
r = fs.Entry(_path, entry); |
|
655 |
if (pkgDoer.iNotifyType != TFsNotification::EMediaChange && |
|
656 |
pkgDoer.iNotifyType != TFsNotification::EDriveName && |
|
657 |
pkgDoer.iNotifyType != TFsNotification::EVolumeName && |
|
658 |
pkgDoer.iOperation != t_notification::EAllOps6) |
|
659 |
{ |
|
660 |
if (r == KErrBadName) |
|
661 |
{ |
|
662 |
wildcard = ETrue; |
|
663 |
} |
|
664 |
if(r != KErrNone && r != KErrPathNotFound && r != KErrNotFound && r != KErrBadName) |
|
665 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
666 |
if (r == KErrNone && !entry.IsDir() && pkgDoer.iOperation != t_notification::EFsDelete && !wildcard && |
|
667 |
pkgDoer.iOperation != t_notification::EFsRmDir && pkgDoer.iOperation != t_notification::EFsRmDir_nonEmpty) |
|
668 |
{ |
|
669 |
r = fs.Delete(_path); |
|
670 |
if(r != KErrNone && r != KErrPathNotFound && r != KErrNotFound) |
|
671 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
672 |
} |
|
673 |
r = fs.MkDirAll(basepath); |
|
674 |
if(r != KErrNone && r != KErrAlreadyExists) |
|
675 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
676 |
} |
|
677 |
||
678 |
multipleTestDoer.Printf(_L("MultipleNotificationTFDoer (%d) - Line %d"),threadID,__LINE__); |
|
679 |
||
680 |
switch(pkgDoer.iOperation) |
|
681 |
{ |
|
682 |
case t_notification::EFileReplace: |
|
683 |
{ |
|
684 |
RFile file; |
|
685 |
//Generate Notification |
|
686 |
multipleTestDoer.Printf(_L("File Replace - (%d)\n"),threadID); |
|
687 |
r = file.Replace(fs,_path,EFileWrite); //RFile::Replace -> TFsNotification::ECreate |
|
688 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
689 |
file.Close(); |
|
690 |
||
691 |
r = fs.Delete(_path); |
|
692 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
693 |
break; |
|
694 |
} |
|
695 |
case t_notification::EFileCreate: |
|
696 |
case t_notification::EFileCreate_txt_nowatch: |
|
697 |
case t_notification::EFileCreate_txt: |
|
698 |
case t_notification::EAllOps1: |
|
699 |
{ |
|
700 |
multipleTestDoer.Printf(_L("MultipleNotificationTFDoer (%d) - Line %d"),threadID,__LINE__); |
|
701 |
if(wildcard) |
|
702 |
{ |
|
703 |
for (TInt i = 0; i < pkgDoer.iIterations; i++) |
|
704 |
{ |
|
705 |
multipleTestDoer.Printf(_L("MultipleNotificationTFDoer (%d) - Line %d"),threadID,__LINE__); |
|
706 |
RFile file; |
|
707 |
TBuf<40> path; |
|
708 |
path.Append(basepath); |
|
709 |
path.AppendNum(i); |
|
710 |
if(pkgDoer.iOperation == t_notification::EFileCreate_txt) |
|
711 |
{ |
|
712 |
//Create file with different extension (no notification) |
|
713 |
path.Append(_L(".wrg")); |
|
714 |
fs.Delete(path); |
|
715 |
multipleTestDoer.Printf(_L("File Create (wrong extension) - %S (%d)\n"),&path,threadID); |
|
716 |
r = file.Create(fs, path, EFileWrite); |
|
717 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
718 |
//Change path to contain file with correct extension (notification occurs) |
|
719 |
path.Replace(path.Length()-3,3,_L("txt")); |
|
720 |
} |
|
721 |
else if(pkgDoer.iOperation == t_notification::EFileCreate_txt_nowatch) |
|
722 |
{ |
|
723 |
path.Append(_L(".txt")); |
|
724 |
} |
|
725 |
fs.Delete(path); |
|
726 |
||
727 |
multipleTestDoer.Printf(_L("File Create - %S (%d)\n"),&path,threadID); |
|
728 |
r = file.Create(fs, path, EFileWrite); |
|
729 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
730 |
file.Close(); |
|
731 |
r = fs.Delete(path); |
|
732 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
733 |
} |
|
734 |
} |
|
735 |
else |
|
736 |
{ |
|
737 |
multipleTestDoer.Printf(_L("MultipleNotificationTFDoer (%d) - Line %d"),threadID,__LINE__); |
|
738 |
for(TInt i = 0; i < pkgDoer.iIterations; i++) |
|
739 |
{ |
|
740 |
multipleTestDoer.Printf(_L("MultipleNotificationTFDoer (%d) - Line %d"),threadID,__LINE__); |
|
741 |
RFile file; |
|
742 |
multipleTestDoer.Printf(_L("File Create - %S (%d)\n"),&_path,threadID); |
|
743 |
r = file.Create(fs,_path,EFileWrite); |
|
744 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
745 |
file.Close(); |
|
746 |
r = fs.Delete(_path); |
|
747 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
748 |
} |
|
749 |
} |
|
750 |
break; |
|
751 |
} |
|
752 |
case t_notification::EFileCreate_subs: |
|
753 |
case t_notification::EFileCreate_subs_nowatch: |
|
754 |
{ |
|
755 |
if (wildcard) |
|
756 |
{ |
|
757 |
for (TInt i = 0; i < pkgDoer.iIterations; i++) |
|
758 |
{ |
|
759 |
RFile file; |
|
760 |
TBuf<40> path; |
|
761 |
path.Append(basepath); |
|
762 |
path.Append(_L("SubDir\\")); |
|
763 |
r = fs.MkDirAll(path); |
|
764 |
if(r != KErrNone && r != KErrAlreadyExists) |
|
765 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
766 |
path.AppendNum(i); |
|
767 |
fs.Delete(path); |
|
768 |
multipleTestDoer.Printf(_L("File Create - %S (%d)\n"),&path,threadID); |
|
769 |
r = file.Create(fs, path, EFileWrite); |
|
770 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
771 |
file.Close(); |
|
772 |
r = fs.Delete(path); |
|
773 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
774 |
} |
|
775 |
} |
|
776 |
break; |
|
777 |
} |
|
778 |
case t_notification::EFileWrite: |
|
779 |
case t_notification::EAllOps2: |
|
780 |
{ |
|
781 |
//Works on single file |
|
782 |
RFile file; |
|
783 |
TBuf<40> path; |
|
784 |
path.Append(basepath); |
|
785 |
path.Append(pkgDoer.iFileName); |
|
786 |
path.Append(pkgDoer.iString); |
|
787 |
r = file.Replace(fs,path,EFileWrite); |
|
788 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
789 |
for(TInt i = 0; i < pkgDoer.iIterations; i++) |
|
790 |
{ |
|
791 |
multipleTestDoer.Printf(_L("File Write - %S (%d)\n"),&path,threadID); |
|
792 |
r = file.Write(4*i,_L8("abcd")); |
|
793 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
794 |
//If cache is enabled, a notification is received only when the cache is flushed |
|
795 |
//We flush the file to make this a general test |
|
796 |
multipleTestDoer.Printf(_L("File Flush - (%d)\n"),threadID); |
|
797 |
r = file.Flush(); |
|
798 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
799 |
} |
|
800 |
file.Close(); |
|
801 |
r = fs.Delete(path); |
|
802 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
803 |
break; |
|
804 |
} |
|
805 |
case t_notification::EFileWrite_samesize: |
|
806 |
{ |
|
807 |
RFile file; |
|
808 |
TBuf<40> path; |
|
809 |
path.Append(basepath); |
|
810 |
path.Append(pkgDoer.iFileName); |
|
811 |
path.Append(pkgDoer.iString); |
|
812 |
r = file.Replace(fs,path,EFileWrite); |
|
813 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
814 |
multipleTestDoer.Printf(_L("File Write - %S (%d)\n"),&path,threadID); |
|
815 |
r = file.Write(0,_L8("abcd")); |
|
816 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
817 |
||
818 |
//If cache is enabled, a notification is received only when the cache is flushed |
|
819 |
//We flush the file to make this a general test |
|
820 |
multipleTestDoer.Printf(_L("File Flush - (%d)\n"),threadID); |
|
821 |
r = file.Flush(); |
|
822 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
823 |
||
824 |
for(TInt i = 0; i < pkgDoer.iIterations; i++) |
|
825 |
{ |
|
826 |
TBuf<2> toWrite; |
|
827 |
toWrite.AppendNum(i); |
|
828 |
multipleTestDoer.Printf(_L("File Write - %S (%d)\n"),&path,threadID); |
|
829 |
r = file.Write(0,(TDesC8&)toWrite); |
|
830 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
831 |
multipleTestDoer.Printf(_L("File Flush - (%d)\n"),threadID); |
|
832 |
r = file.Flush(); |
|
833 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
834 |
} |
|
835 |
file.Close(); |
|
836 |
r = fs.Delete(path); |
|
837 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
838 |
break; |
|
839 |
} |
|
840 |
case t_notification::EFileWrite_async: |
|
841 |
{ |
|
842 |
RFile file; |
|
843 |
TBuf<40> path; |
|
844 |
path.Append(basepath); |
|
845 |
path.Append(pkgDoer.iFileName); |
|
846 |
path.Append(pkgDoer.iString); |
|
847 |
r = file.Replace(fs,path,EFileWrite); |
|
848 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
849 |
for(TInt i = 0; i < pkgDoer.iIterations; i++) |
|
850 |
{ |
|
851 |
TRequestStatus status; |
|
852 |
file.Write(52*i, _L8("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"), status); |
|
853 |
User::WaitForRequest(status); |
|
854 |
multipleTestDoer.Printf(_L("File Write Async - %S (%d)\n"),&path,threadID); |
|
855 |
TInt fileSize; |
|
856 |
file.Size(fileSize); |
|
857 |
multipleTestDoer.Printf(_L("File Write Async - FileSize: %d\n"),fileSize); |
|
858 |
multipleTestDoer.Printf(_L("File Flush - (%d)\n"),threadID); |
|
859 |
r = file.Flush(); |
|
860 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
861 |
} |
|
862 |
file.Close(); |
|
863 |
r = fs.Delete(path); |
|
864 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
865 |
break; |
|
866 |
} |
|
867 |
case t_notification::EFileSetSize: |
|
868 |
case t_notification::EAllOps3: |
|
869 |
{ |
|
870 |
//Works on single file |
|
871 |
RFile file; |
|
872 |
TBuf<40> path; |
|
873 |
path.Append(basepath); |
|
874 |
path.Append(pkgDoer.iFileName); |
|
875 |
path.Append(pkgDoer.iString); |
|
876 |
r = file.Replace(fs,path,EFileWrite); |
|
877 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
878 |
||
879 |
//Increase file size |
|
880 |
for(TInt i = 0; i < pkgDoer.iIterations; i++) |
|
881 |
{ |
|
882 |
r = file.SetSize(4*(i+1)); |
|
883 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
884 |
multipleTestDoer.Printf(_L("File Set Size - %d (%d)\n"),4*(i+1),threadID); |
|
885 |
} |
|
886 |
||
887 |
//Decrease file size |
|
888 |
for(TInt j = pkgDoer.iIterations - 2; j >= 0; j--) |
|
889 |
{ |
|
890 |
r = file.SetSize(4*(j+1)); |
|
891 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
892 |
multipleTestDoer.Printf(_L("File Set Size - %d (%d)\n"),4*(j+1),threadID); |
|
893 |
} |
|
894 |
||
895 |
file.Close(); |
|
896 |
r = fs.Delete(path); |
|
897 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
898 |
break; |
|
899 |
} |
|
900 |
case t_notification::EFsReplace: |
|
901 |
{ |
|
902 |
TBuf<45> path; |
|
903 |
path.Append(basepath); |
|
904 |
path.Append(pkgDoer.iFileName); |
|
905 |
path.Append(pkgDoer.iString); |
|
906 |
path.AppendNum(0); |
|
907 |
||
908 |
RFile tempFile; |
|
909 |
multipleTestDoer.Printf(_L("RFs Replace (Create temp file) - (%d)\n"),threadID); |
|
910 |
r = tempFile.Replace(fs,_path,EFileWrite); |
|
911 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
912 |
tempFile.Close(); |
|
913 |
||
914 |
multipleTestDoer.Printf(_L("RFs Replace - (%d)\n"),threadID); |
|
915 |
r = fs.Replace(_path,path); //RFs::Replace -> TFsNotification::ERename |
|
916 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
917 |
||
918 |
r = fs.Delete(path); |
|
919 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
920 |
break; |
|
921 |
} |
|
922 |
case t_notification::EFsRename: |
|
923 |
{ |
|
924 |
TBuf<45> path; |
|
925 |
path.Append(basepath); |
|
926 |
path.Append(pkgDoer.iFileName); |
|
927 |
path.Append(pkgDoer.iString); |
|
928 |
path.AppendNum(0); |
|
929 |
||
930 |
RFile file; |
|
931 |
r = file.Replace(fs,_path,EFileWrite); |
|
932 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
933 |
file.Close(); |
|
934 |
||
935 |
multipleTestDoer.Printf(_L("RFs Rename - (%d)\n"),threadID); |
|
936 |
r = fs.Rename(_path,path); |
|
937 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
938 |
||
939 |
r = fs.Delete(path); |
|
940 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
941 |
break; |
|
942 |
} |
|
943 |
case t_notification::EFileRename: |
|
944 |
case t_notification::EFileRename_wild: |
|
945 |
case t_notification::EAllOps5: |
|
946 |
{ |
|
947 |
TBuf<45> path; |
|
948 |
path.Append(basepath); |
|
949 |
if (!wildcard) |
|
950 |
{ |
|
951 |
path.Append(pkgDoer.iFileName); |
|
952 |
path.Append(pkgDoer.iString); |
|
953 |
} |
|
954 |
path.AppendNum(0); |
|
955 |
||
956 |
//Delete new path to ensure it does not exist |
|
957 |
r = fs.Delete(path); |
|
958 |
if(r != KErrNone && r != KErrNotFound && r != KErrPathNotFound) |
|
959 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
960 |
||
961 |
if (wildcard) |
|
962 |
{ |
|
963 |
_path.Delete(_path.Length()-1,1); |
|
964 |
_path.AppendNum(9); |
|
965 |
} |
|
966 |
||
967 |
RFile file; |
|
968 |
r = file.Replace(fs, _path, EFileWrite); |
|
969 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
970 |
||
971 |
if (wildcard) |
|
972 |
{ |
|
973 |
for(TInt i = 1; i <= pkgDoer.iIterations; i++) |
|
974 |
{ |
|
975 |
path.Delete(path.Length()-1,1); |
|
976 |
path.AppendNum(i); |
|
977 |
multipleTestDoer.Printf(_L("File Rename - %S (%d)\n"),&path,threadID); |
|
978 |
r = file.Rename(path); |
|
979 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
980 |
} |
|
981 |
} |
|
982 |
else |
|
983 |
{ |
|
984 |
multipleTestDoer.Printf(_L("File Rename - (%d)\n"),threadID); |
|
985 |
r = file.Rename(path); |
|
986 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
987 |
} |
|
988 |
||
989 |
file.Close(); |
|
990 |
r = fs.Delete(path); |
|
991 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
992 |
break; |
|
993 |
} |
|
994 |
case t_notification::EFsRename_dir: |
|
995 |
{ |
|
996 |
r = fs.MkDirAll(_path); |
|
997 |
if(r != KErrNone && r != KErrAlreadyExists) |
|
998 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
999 |
||
1000 |
TBuf<45> newPath; |
|
1001 |
newPath.Copy(_path); |
|
1002 |
newPath.Delete(newPath.Length()-1,1); |
|
1003 |
newPath.AppendNum(0); |
|
1004 |
newPath.Append(KPathDelimiter); |
|
1005 |
||
1006 |
//Delete new path to ensure it does not exist |
|
1007 |
r = fs.RmDir(newPath); |
|
1008 |
if(r != KErrNone && r != KErrNotFound && r != KErrPathNotFound) |
|
1009 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1010 |
||
1011 |
multipleTestDoer.Printf(_L("RFs Rename Dir - (%d)\n"),threadID); |
|
1012 |
r = fs.Rename(_path,newPath); |
|
1013 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1014 |
break; |
|
1015 |
} |
|
1016 |
case t_notification::EFsDelete: |
|
1017 |
{ |
|
1018 |
if (wildcard) |
|
1019 |
{ |
|
1020 |
for(TInt i = 0; i < pkgDoer.iIterations; i++) |
|
1021 |
{ |
|
1022 |
//Create/replace file |
|
1023 |
RFile file; |
|
1024 |
TBuf<40> path; |
|
1025 |
path.Append(basepath); |
|
1026 |
r = fs.MkDirAll(path); |
|
1027 |
if(r != KErrNone && r != KErrAlreadyExists) |
|
1028 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1029 |
path.AppendNum(i); |
|
1030 |
path.Append(_L(".txt")); |
|
1031 |
r = file.Replace(fs,path,EFileWrite); |
|
1032 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1033 |
file.Close(); |
|
1034 |
||
1035 |
//Delete file |
|
1036 |
multipleTestDoer.Printf(_L("RFs Delete - %S (%d)\n"),&path,threadID); |
|
1037 |
r = fs.Delete(path); |
|
1038 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1039 |
||
1040 |
//Create file with a different extension which should not produce notifications |
|
1041 |
path.AppendNum(i); |
|
1042 |
r = file.Replace(fs,path,EFileWrite); |
|
1043 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1044 |
file.Close(); |
|
1045 |
||
1046 |
//Delete that file |
|
1047 |
multipleTestDoer.Printf(_L("RFs Delete - %S (%d)\n"),&path,threadID); |
|
1048 |
r = fs.Delete(path); |
|
1049 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1050 |
} |
|
1051 |
} |
|
1052 |
else |
|
1053 |
{ |
|
1054 |
RFile file; |
|
1055 |
r = file.Replace(fs,_path,EFileWrite); //Make sure file exists |
|
1056 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1057 |
file.Close(); |
|
1058 |
||
1059 |
multipleTestDoer.Printf(_L("RFs Delete - (%d)\n"),threadID); |
|
1060 |
r = fs.Delete(_path); |
|
1061 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1062 |
} |
|
1063 |
break; |
|
1064 |
} |
|
1065 |
case t_notification::EFileSet: |
|
1066 |
{ |
|
1067 |
RFile file; |
|
1068 |
r = file.Replace(fs,_path,EFileWrite); |
|
1069 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1070 |
||
1071 |
multipleTestDoer.Printf(_L("File Set - (%d)\n"),threadID); |
|
1072 |
r = file.Set(TTime(0),KEntryAttHidden,KEntryAttReadOnly); |
|
1073 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1074 |
||
1075 |
file.Close(); |
|
1076 |
break; |
|
1077 |
} |
|
1078 |
case t_notification::EFileSetAtt: |
|
1079 |
case t_notification::EAllOps4: |
|
1080 |
{ |
|
1081 |
RFile file; |
|
1082 |
r = file.Replace(fs,_path,EFileWrite); |
|
1083 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1084 |
||
1085 |
multipleTestDoer.Printf(_L("File SetAtt - (%d)\n"),threadID); |
|
1086 |
r = file.SetAtt(KEntryAttHidden,KEntryAttReadOnly); |
|
1087 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1088 |
||
1089 |
file.Close(); |
|
1090 |
r = fs.Delete(_path); |
|
1091 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1092 |
break; |
|
1093 |
} |
|
1094 |
case t_notification::EFileSetAtt_subs: |
|
1095 |
{ |
|
1096 |
if (wildcard) |
|
1097 |
{ |
|
1098 |
TBuf<40> path; |
|
1099 |
path.Append(basepath); |
|
1100 |
path.Append(_L("SubDir\\")); |
|
1101 |
r = fs.MkDirAll(path); |
|
1102 |
if(r != KErrNone && r != KErrAlreadyExists) |
|
1103 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1104 |
||
1105 |
//Create/replace files and set their attributes |
|
1106 |
for(TInt i = 0; i < pkgDoer.iIterations; i++) |
|
1107 |
{ |
|
1108 |
RFile file; |
|
1109 |
TBuf<40> dirPath; |
|
1110 |
dirPath.Append(path); |
|
1111 |
dirPath.AppendNum(i); |
|
1112 |
dirPath.Append(_L(".ext")); |
|
1113 |
r = file.Replace(fs, dirPath, EFileWrite); |
|
1114 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1115 |
||
1116 |
multipleTestDoer.Printf(_L("File SetAtt Subs - %d.ext - (%d)\n"),i,threadID); |
|
1117 |
r = file.SetAtt(KEntryAttHidden,KEntryAttReadOnly); |
|
1118 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1119 |
||
1120 |
file.Close(); |
|
1121 |
r = fs.Delete(dirPath); |
|
1122 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1123 |
} |
|
1124 |
} |
|
1125 |
break; |
|
1126 |
} |
|
1127 |
case t_notification::EFsSetEntry: |
|
1128 |
{ |
|
1129 |
RFile file; |
|
1130 |
r = file.Replace(fs,_path,EFileWrite); |
|
1131 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1132 |
file.Close(); |
|
1133 |
||
1134 |
multipleTestDoer.Printf(_L("RFs SetEntry - (%d)\n"),threadID); |
|
1135 |
r = fs.SetEntry(_path,TTime(0),KEntryAttHidden,KEntryAttReadOnly); |
|
1136 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1137 |
break; |
|
1138 |
} |
|
1139 |
case t_notification::EDismount: |
|
1140 |
{ |
|
1141 |
multipleTestDoer.Printf(_L("DismountFileSystem - (%d)\n"),threadID); |
|
1142 |
r = fs.DismountFileSystem(pkgDoer.iFileName,globalDriveNum); |
|
1143 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1144 |
break; |
|
1145 |
} |
|
1146 |
case t_notification::EMount: |
|
1147 |
{ |
|
1148 |
multipleTestDoer.Printf(_L("MountFileSystem - (%d)\n"),threadID); |
|
1149 |
r = fs.MountFileSystem(pkgDoer.iFileName,globalDriveNum); |
|
1150 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1151 |
break; |
|
1152 |
} |
|
1153 |
case t_notification::EMountScan: |
|
1154 |
{ |
|
1155 |
multipleTestDoer.Printf(_L("DismountFileSystem - (%d)\n"),threadID); |
|
1156 |
r = fs.DismountFileSystem(pkgDoer.iFileName,globalDriveNum); |
|
1157 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1158 |
TBool isMount; |
|
1159 |
multipleTestDoer.Printf(_L("MountFileSystemAndScan - (%d)\n"),threadID); |
|
1160 |
r = fs.MountFileSystemAndScan(pkgDoer.iFileName,globalDriveNum,isMount); |
|
1161 |
if(!isMount) |
|
1162 |
safe_test(multipleTestDoer,KErrGeneral,__LINE__,pkgDoer.iLineCall); |
|
1163 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1164 |
break; |
|
1165 |
} |
|
1166 |
case t_notification::EMountDismount: |
|
1167 |
{ |
|
1168 |
for(TInt i = 0; i < pkgDoer.iIterations; i++) |
|
1169 |
{ |
|
1170 |
multipleTestDoer.Printf(_L("DismountFileSystem - (%d)\n"),threadID); |
|
1171 |
r = fs.DismountFileSystem(pkgDoer.iFileName,globalDriveNum); |
|
1172 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1173 |
||
1174 |
multipleTestDoer.Printf(_L("MountFileSystem - (%d)\n"),threadID); |
|
1175 |
r = fs.MountFileSystem(pkgDoer.iFileName,globalDriveNum); |
|
1176 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1177 |
} |
|
1178 |
break; |
|
1179 |
} |
|
1180 |
case t_notification::EFormat: |
|
1181 |
{ |
|
1182 |
RFormat format; |
|
1183 |
TInt count = -1; |
|
1184 |
TBuf<2> driveDes; |
|
1185 |
driveDes.Append(pkgDoer.iFileName); |
|
1186 |
driveDes.Append((TChar)':'); |
|
1187 |
format.Open(fs,driveDes,EQuickFormat,count); |
|
1188 |
multipleTestDoer.Printf(_L("Format - (%d)\n"),threadID); |
|
1189 |
while(count != 0) |
|
1190 |
{ |
|
1191 |
format.Next(count); |
|
1192 |
} |
|
1193 |
format.Close(); |
|
1194 |
||
1195 |
break; |
|
1196 |
} |
|
1197 |
case t_notification::EMediaCardRemoval: |
|
1198 |
case t_notification::EMediaCardInsertion: |
|
1199 |
{ |
|
1200 |
//These are MANUAL tests, they require the removal/insertion of the media card |
|
1201 |
//Instructions are given out in the watcher thread |
|
1202 |
break; |
|
1203 |
} |
|
1204 |
case t_notification::ESetDriveName: |
|
1205 |
{ |
|
1206 |
for(TInt i = 0; i < pkgDoer.iIterations; i++) |
|
1207 |
{ |
|
1208 |
multipleTestDoer.Printf(_L("SetDriveName - MyDrive\n")); |
|
1209 |
_LIT(KDriveName,"MyDrive"); |
|
1210 |
r = fs.SetDriveName(globalDriveNum,KDriveName); |
|
1211 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1212 |
||
1213 |
multipleTestDoer.Printf(_L("SetDriveName - MyDrive2\n")); |
|
1214 |
_LIT(KDriveName2,"MyDrive2"); |
|
1215 |
r = fs.SetDriveName(globalDriveNum,KDriveName2); |
|
1216 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1217 |
} |
|
1218 |
break; |
|
1219 |
} |
|
1220 |
case t_notification::ERawDiskWrite: |
|
1221 |
{ |
|
1222 |
RRawDisk rawdisk; |
|
1223 |
TInt drive = 0; |
|
1224 |
TBuf<1> driveDes; |
|
1225 |
driveDes.Append(pkgDoer.iFileName); |
|
1226 |
RFs::CharToDrive(pkgDoer.iFileName[0],drive); |
|
1227 |
r = rawdisk.Open(fs,drive); |
|
1228 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1229 |
||
1230 |
//Read some data |
|
1231 |
TBuf8<10> readData; |
|
1232 |
r = rawdisk.Read(0,readData); |
|
1233 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1234 |
||
1235 |
//Write it back |
|
1236 |
TPtrC8 dataPtr(readData); |
|
1237 |
r = rawdisk.Write((TInt64)0,dataPtr); |
|
1238 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1239 |
rawdisk.Close(); |
|
1240 |
break; |
|
1241 |
} |
|
1242 |
case t_notification::ESetVolumeLabel: |
|
1243 |
{ |
|
1244 |
for(TInt i = 0; i < pkgDoer.iIterations; i++) |
|
1245 |
{ |
|
1246 |
multipleTestDoer.Printf(_L("SetVolumeLabel - MyVolume\n")); |
|
1247 |
_LIT(KVolumeLabel,"MyVolume"); |
|
1248 |
r = fs.SetVolumeLabel(KVolumeLabel,globalDriveNum); |
|
1249 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1250 |
||
1251 |
multipleTestDoer.Printf(_L("SetVolumeLabel - MyVolume2\n")); |
|
1252 |
_LIT(KVolumeLabel2,"MyVolume2"); |
|
1253 |
r = fs.SetVolumeLabel(KVolumeLabel2,globalDriveNum); |
|
1254 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1255 |
} |
|
1256 |
break; |
|
1257 |
} |
|
1258 |
case t_notification::EFsRmDir: |
|
1259 |
{ |
|
1260 |
r = fs.MkDirAll(_path); //Make sure directory exists |
|
1261 |
if(r != KErrNone && r != KErrAlreadyExists) |
|
1262 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1263 |
multipleTestDoer.Printf(_L("RFs RmDir - Remove directory\n")); |
|
1264 |
r = fs.RmDir(_path); |
|
1265 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1266 |
break; |
|
1267 |
} |
|
1268 |
case t_notification::EFsRmDir_wild: |
|
1269 |
{ |
|
1270 |
if (wildcard) |
|
1271 |
{ |
|
1272 |
TBuf<40> path; |
|
1273 |
path.Append(basepath); |
|
1274 |
path.Append(_L("SubDir\\")); |
|
1275 |
r = fs.MkDirAll(path); |
|
1276 |
if(r != KErrNone && r != KErrAlreadyExists) |
|
1277 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1278 |
||
1279 |
multipleTestDoer.Printf(_L("RFs RmDir - Remove directory\n")); |
|
1280 |
r = fs.RmDir(path); |
|
1281 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1282 |
break; |
|
1283 |
} |
|
1284 |
} |
|
1285 |
case t_notification::EFsRmDir_nonEmpty: |
|
1286 |
case t_notification::EFsMkDir: |
|
1287 |
{ |
|
1288 |
TBuf<50> path; |
|
1289 |
path.Append(_path); |
|
1290 |
path.Append(pkgDoer.iFileName); //Append another sub-directory |
|
1291 |
multipleTestDoer.Printf(_L("RFs RmDir \n")); |
|
1292 |
r=fs.RmDir(path); |
|
1293 |
if(r != KErrNone && r != KErrPathNotFound && r != KErrNotFound) |
|
1294 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1295 |
r=fs.RmDir(_path); |
|
1296 |
if(r != KErrNone && r != KErrPathNotFound && r != KErrNotFound) |
|
1297 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1298 |
||
1299 |
multipleTestDoer.Printf(_L("RFs MkDir \n")); |
|
1300 |
r=fs.MkDir(path); |
|
1301 |
multipleTestDoer (r==KErrPathNotFound); |
|
1302 |
r=fs.MkDir(_path); |
|
1303 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1304 |
r=fs.MkDir(path); |
|
1305 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1306 |
||
1307 |
multipleTestDoer.Printf(_L("RFs RmDir nonEmpty - Full path: %S"),&_path); |
|
1308 |
r = fs.RmDir(_path); |
|
1309 |
if(r != KErrInUse) |
|
1310 |
safe_test(multipleTestDoer,KErrGeneral,__LINE__,pkgDoer.iLineCall); |
|
1311 |
||
1312 |
r = fs.RmDir(path); |
|
1313 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1314 |
||
1315 |
multipleTestDoer.Printf(_L("RFs EFsRmDir_nonEmpty - Full path: %S"),&_path); |
|
1316 |
r = fs.RmDir(_path); |
|
1317 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1318 |
||
1319 |
break; |
|
1320 |
} |
|
1321 |
case t_notification::EAllOps6: |
|
1322 |
{ |
|
1323 |
//Set drive name to TestDrive |
|
1324 |
multipleTestDoer.Printf(_L("SetDriveName - TestDrive\n")); |
|
1325 |
_LIT(KDriveName,"TestDrive"); |
|
1326 |
r = fs.SetDriveName(globalDriveNum,KDriveName); |
|
1327 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1328 |
//Set volume label to TestVolume |
|
1329 |
multipleTestDoer.Printf(_L("SetVolumeLabel - TestVolume\n")); |
|
1330 |
_LIT(KVolumeLabel,"TestVolume"); |
|
1331 |
r = fs.SetVolumeLabel(KVolumeLabel,globalDriveNum); |
|
1332 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1333 |
break; |
|
1334 |
} |
|
1335 |
case t_notification::ECFileManMove: |
|
1336 |
{ |
|
1337 |
CTrapCleanup* cleanup; |
|
1338 |
cleanup = CTrapCleanup::New(); |
|
1339 |
||
1340 |
multipleTestDoer.Printf(_L("Doer - ECFileManMove_part1\n")); |
|
1341 |
||
1342 |
//Stage 1 - Create File & write some data |
|
1343 |
RFile file; |
|
1344 |
r = file.Replace(fs,_path,EFileWrite); |
|
1345 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1346 |
r = file.SetSize(4); |
|
1347 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1348 |
file.Close(); |
|
1349 |
||
1350 |
CFileMan* cfman = NULL; |
|
1351 |
TRAP(r, cfman = CFileMan::NewL(fs);) |
|
189 | 1352 |
test_KErrNone(r); |
0 | 1353 |
test(cfman != NULL); |
1354 |
TBuf<40> unmonitored_path; |
|
1355 |
unmonitored_path.Append(gDriveToTest); |
|
1356 |
unmonitored_path.Append(_L(":\\F32-TST\\")); |
|
1357 |
unmonitored_path.Append(pkgDoer.iString); |
|
1358 |
||
1359 |
//Stage 2 - Move to unmonitored Dir |
|
1360 |
//Rename 1 |
|
1361 |
r = cfman->Move(_path,unmonitored_path); |
|
1362 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1363 |
||
1364 |
//SetSize (size := 8) |
|
1365 |
RFile file2; |
|
1366 |
r = file2.Open(fs,unmonitored_path,EFileWrite); |
|
1367 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1368 |
r = file2.SetSize(8); |
|
1369 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1370 |
file2.Flush(); |
|
1371 |
file2.Close(); |
|
1372 |
||
1373 |
//Stage 3 - Move back to monitored Dir |
|
1374 |
//Rename 2 |
|
1375 |
r = cfman->Move(unmonitored_path,_path); |
|
1376 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1377 |
||
1378 |
//Stage 4 - Delete |
|
1379 |
//Delete |
|
1380 |
r = cfman->Delete(_path); |
|
1381 |
safe_test(multipleTestDoer,r,__LINE__,pkgDoer.iLineCall); |
|
1382 |
||
1383 |
delete cleanup; |
|
1384 |
delete cfman; |
|
1385 |
break; |
|
1386 |
} |
|
1387 |
default: |
|
1388 |
{ |
|
1389 |
break; |
|
1390 |
} |
|
1391 |
} |
|
1392 |
||
1393 |
fs.Close(); |
|
1394 |
multipleTestDoer.End(); |
|
1395 |
multipleTestDoer.Close(); |
|
1396 |
return KErrNone; |
|
1397 |
} |
|
1398 |
||
1399 |
/* |
|
1400 |
* Test process Capabilites tries to set up filters on the |
|
1401 |
* the private folder for uid 01234567. |
|
1402 |
* This function returns the results to trying to add filters on the specified path. |
|
1403 |
* |
|
1404 |
* There are three MMP files: |
|
1405 |
* t_notifier_nocaps.mmp, t_notifier_allfiles.mmp, t_notifier_belongs.mmp |
|
1406 |
* |
|
1407 |
* t_notifier_nocaps.mmp - |
|
1408 |
* This process does not have any capabilites, so should not be allowed to set the filter. |
|
1409 |
* t_notifier_allfiles.mmp - |
|
1410 |
* This process has ALLFILES capability, so should |
|
1411 |
* t_notifier_belongs.mmp - |
|
1412 |
* This process is process with UID 01234567 so this should work too. |
|
1413 |
* |
|
1414 |
* See: f32test\server\t_notifier_caps.cpp |
|
1415 |
*/ |
|
1416 |
TInt TestProcessCapabilities(const TDesC& aProcessName) |
|
1417 |
{ |
|
1418 |
RProcess process; |
|
1419 |
TUidType uid; |
|
1420 |
TPtrC command((TText*)&gDriveToTest,1); |
|
1421 |
TInt r = process.Create(aProcessName,command,uid); |
|
189 | 1422 |
test_KErrNone(r); |
0 | 1423 |
process.Resume(); |
1424 |
TRequestStatus s1; |
|
1425 |
TRequestStatus s2; |
|
1426 |
RTimer tim; |
|
1427 |
r = tim.CreateLocal(); |
|
189 | 1428 |
test_KErrNone(r); |
0 | 1429 |
TTimeIntervalMicroSeconds32 delay = 5000000; //5 seconds |
1430 |
tim.After(s1,delay); |
|
1431 |
process.Logon(s2); |
|
1432 |
User::WaitForRequest(s1,s2); |
|
1433 |
test(s2.Int()!=KRequestPending); |
|
1434 |
r = process.ExitReason(); |
|
1435 |
process.Close(); |
|
1436 |
return r; |
|
1437 |
} |
|
1438 |
||
1439 |
/* |
|
1440 |
* Creates a file and writes to it twice. |
|
1441 |
* Used in TestTwoNotificationsL(). |
|
1442 |
*/ |
|
1443 |
TInt TwoNotificationsTFDoer(TAny* aAny) |
|
1444 |
{ |
|
1445 |
RTest testDoer(_L("TestTwoNotificationsThreadFunctionDoer")); |
|
1446 |
testDoer.Start(_L("TestTwoNotificationsThreadFunctionDoer")); |
|
1447 |
||
1448 |
SThreadPackageMultiple package = *(SThreadPackageMultiple*)aAny; |
|
1449 |
TBuf<40> path; |
|
1450 |
path.Append(gDriveToTest); |
|
1451 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); //len=22 |
|
1452 |
path.Append(package.iFileName); |
|
1453 |
||
1454 |
//Delete file so we definitely get a create notification |
|
1455 |
RFs fs; |
|
1456 |
TInt r = fs.Connect(); |
|
1457 |
testDoer(r==KErrNone); |
|
1458 |
r = fs.Delete(path); |
|
1459 |
testDoer(r==KErrNone || r==KErrPathNotFound || r==KErrNotFound); |
|
1460 |
r = fs.MkDirAll(path); |
|
1461 |
testDoer(r==KErrNone || r==KErrAlreadyExists); |
|
1462 |
||
1463 |
testDoer.Printf(_L("TestTwoNotificationsThreadFunctionDoer - Create File %S\n"),&path); |
|
1464 |
//Create file |
|
1465 |
RFile file; |
|
1466 |
r = file.Create(fs,path,EFileWrite); |
|
1467 |
testDoer(r == KErrNone); |
|
1468 |
||
1469 |
testDoer.Printf(_L("TestTwoNotificationsThreadFunctionDoer - Size File 1 %S\n"),&path); |
|
1470 |
TInt fileSize = 0; |
|
1471 |
r = file.Size(fileSize); |
|
1472 |
testDoer(r == KErrNone); |
|
1473 |
testDoer(fileSize==0); |
|
1474 |
||
1475 |
testDoer.Printf(_L("TestTwoNotificationsThreadFunctionDoer - Write File 1 %S\n"),&path); |
|
1476 |
r = file.Write(_L8("1234")); |
|
1477 |
testDoer(r == KErrNone); |
|
1478 |
testDoer.Printf(_L("TestTwoNotificationsThreadFunctionDoer - Size File 2 %S\n"),&path); |
|
1479 |
r = file.Size(fileSize); |
|
1480 |
testDoer(r == KErrNone); |
|
1481 |
test(fileSize==4); |
|
1482 |
||
1483 |
testDoer.Printf(_L("TestTwoNotificationsThreadFunctionDoer - Write File 2 %S\n"),&path); |
|
1484 |
r = file.Write(_L8("5678")); |
|
1485 |
testDoer(r == KErrNone); |
|
1486 |
testDoer.Printf(_L("TestTwoNotificationsThreadFunctionDoer - Size File 3 %S\n"),&path); |
|
1487 |
r = file.Size(fileSize); |
|
1488 |
testDoer(r == KErrNone); |
|
1489 |
test(fileSize==8); |
|
1490 |
||
1491 |
file.Close(); |
|
1492 |
||
1493 |
fs.Close(); |
|
1494 |
testDoer.End(); |
|
1495 |
testDoer.Close(); |
|
1496 |
return KErrNone; |
|
1497 |
} |
|
1498 |
||
1499 |
/* |
|
1500 |
* The following enum are for the CFileMan test |
|
1501 |
*/ |
|
1502 |
enum TCFsManEnum |
|
1503 |
{ |
|
1504 |
ECFManCreate1 = 0x01, |
|
1505 |
ECFManWrite1 = 0x02, |
|
1506 |
ECFManDelete1 = 0x04, |
|
1507 |
ECFManCreate2 = 0x08, |
|
1508 |
ECFManSetSize1 = 0x10, |
|
1509 |
ECFManWrite2 = 0x20, |
|
1510 |
ECFManAtt1 = 0x40, |
|
1511 |
ECFManDelete2 = 0x80, |
|
1512 |
//Either a create, copy, delete (above - not supported in test) |
|
1513 |
//or rename operation (below) |
|
1514 |
ECFManRename1 = 0x100, |
|
1515 |
ECFManRename2 = 0x200 |
|
1516 |
}; |
|
1517 |
||
1518 |
/* |
|
1519 |
* Used by MultipleNotificationsTFWatcher() to test the notifications. |
|
1520 |
*/ |
|
1521 |
void HandleMultipleNotifications(RTest& aTest, SThreadPackageMultiple& aPackage, CFsNotify* notify, TDesC& aFullname) |
|
1522 |
{ |
|
1523 |
RThread thread; |
|
1524 |
TUint64 threadID = thread.Id().Id(); |
|
1525 |
TInt numNotifications = 0; |
|
1526 |
TInt64 fileSize = 0; |
|
1527 |
TBool overflow = EFalse; |
|
1528 |
||
1529 |
TInt scratch = 0; |
|
1530 |
||
1531 |
for(TInt i = 0; i < aPackage.iMaxNotifications; ) //Outer-loop to control when we should exit |
|
1532 |
{ |
|
1533 |
aTest.Printf(_L("(%d) - NextNotification\n"),threadID); |
|
1534 |
const TFsNotification* notification = notify->NextNotification(); |
|
1535 |
while(notification != NULL) |
|
1536 |
{ |
|
1537 |
numNotifications++; |
|
1538 |
aTest.Printf(_L("NumNotifications = %d\n"),numNotifications); |
|
1539 |
//Test notification is not null. |
|
1540 |
//We should be getting 1 notification. |
|
1541 |
aTest(notification != NULL); |
|
1542 |
||
1543 |
aTest.Printf(_L("(%d) - Notification Type\n"),threadID); |
|
1544 |
TFsNotification::TFsNotificationType notificationType = notification->NotificationType(); |
|
1545 |
aTest(notificationType & aPackage.iNotifyType || |
|
1546 |
notificationType & TFsNotification::EOverflow); |
|
1547 |
||
1548 |
aTest.Printf(_L("Notification Type = %u - (%d)\n"),notificationType,threadID); |
|
1549 |
||
1550 |
if(notificationType != TFsNotification::EOverflow) |
|
1551 |
{ |
|
1552 |
aTest.Printf(_L("(%d) - Notification Path\n"),threadID); |
|
1553 |
TPtrC _pathC; |
|
1554 |
((TFsNotification*) notification)->Path(_pathC); |
|
1555 |
aTest.Printf(_L("%S - (%d)\n"),&_pathC,threadID); |
|
1556 |
||
1557 |
if(aPackage.iOperation == t_notification::ECFileManMove |
|
1558 |
&& (scratch == (ECFManWrite1 | ECFManCreate1))) |
|
1559 |
{ |
|
1560 |
TChar drive = gDriveToTest; |
|
1561 |
TBuf<40> unmodified_path; |
|
1562 |
unmodified_path.Append(drive); |
|
1563 |
unmodified_path.Append(_L(":\\F32-TST\\")); |
|
1564 |
unmodified_path.Append(_L("cf1le.man")); |
|
1565 |
((TFsNotification*) notification)->NewName(_pathC); |
|
1566 |
TInt matches = _pathC.Match(unmodified_path); |
|
1567 |
safe_test(aTest,matches,__LINE__,aPackage.iLineCall); |
|
1568 |
} |
|
1569 |
else if((scratch == (ECFManWrite1 | ECFManCreate1 | ECFManRename1))) |
|
1570 |
{ |
|
1571 |
((TFsNotification*) notification)->NewName(_pathC); |
|
1572 |
safe_test(aTest,_pathC.Match(aFullname),__LINE__,aPackage.iLineCall); |
|
1573 |
} |
|
1574 |
else |
|
1575 |
{ |
|
1576 |
safe_test(aTest,_pathC.Match(aFullname),__LINE__,aPackage.iLineCall); |
|
1577 |
} |
|
1578 |
} |
|
1579 |
else |
|
1580 |
{ |
|
1581 |
aTest.Printf(_L("(%d) - OVERFLOW\n"),threadID); |
|
1582 |
//Overflow |
|
1583 |
overflow = ETrue; |
|
1584 |
return; |
|
1585 |
} |
|
1586 |
||
1587 |
//notificationType will only be of 1 type |
|
1588 |
if(notificationType == TFsNotification::EFileChange) |
|
1589 |
{ |
|
1590 |
if(!(((aPackage.iNotifyType & TFsNotification::EFileChange) == TFsNotification::EFileChange) && |
|
1591 |
(aPackage.iOperation == t_notification::EFileWrite || |
|
1592 |
aPackage.iOperation == t_notification::EFileWrite_async || |
|
1593 |
aPackage.iOperation == t_notification::EFileWrite_samesize || |
|
1594 |
aPackage.iOperation == t_notification::EFileSetSize || |
|
1595 |
aPackage.iOperation == t_notification::ECFileManMove || |
|
1596 |
aPackage.iOperation == t_notification::EAllOps2 || |
|
1597 |
aPackage.iOperation == t_notification::EAllOps3))) |
|
1598 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1599 |
||
1600 |
if (aPackage.iOperation == t_notification::ECFileManMove) |
|
1601 |
{ |
|
1602 |
((TFsNotification*) notification)->FileSize(fileSize); |
|
1603 |
//File just been created and written to. |
|
1604 |
if(fileSize == 4) |
|
1605 |
{ |
|
1606 |
scratch |= ECFManWrite1; |
|
1607 |
} |
|
1608 |
else if(fileSize == 8) |
|
1609 |
{ |
|
1610 |
scratch |= ECFManWrite2; |
|
1611 |
} |
|
1612 |
} |
|
1613 |
else if (aPackage.iNotifyType == TFsNotification::EFileChange) |
|
1614 |
{ |
|
1615 |
((TFsNotification*) notification)->FileSize(fileSize); |
|
1616 |
aTest.Printf(_L("Filesize - %d (%d)\n"),fileSize,threadID); |
|
1617 |
//A notification is received every time the size is changed |
|
1618 |
//due to the flushing |
|
1619 |
if (aPackage.iOperation == t_notification::EFileWrite_async) |
|
1620 |
{ |
|
1621 |
//We write 52 letters |
|
1622 |
if(fileSize != 52*(i+1)) |
|
1623 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1624 |
} |
|
1625 |
else if (aPackage.iOperation == t_notification::EFileWrite_samesize) |
|
1626 |
{ |
|
1627 |
//Only 4 letters in file |
|
1628 |
if(fileSize != 4) |
|
1629 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1630 |
} |
|
1631 |
else if (i < aPackage.iIterations) |
|
1632 |
{ |
|
1633 |
//We write/increase size by 4 letters/bytes |
|
1634 |
if(fileSize != 4*(i+1)) |
|
1635 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1636 |
} |
|
1637 |
else |
|
1638 |
{ |
|
1639 |
//We decrease size by 4 bytes |
|
1640 |
if(fileSize != 4*(aPackage.iMaxNotifications-i)) |
|
1641 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1642 |
} |
|
1643 |
} |
|
1644 |
} |
|
1645 |
else if(notificationType == TFsNotification::ECreate) |
|
1646 |
{ |
|
1647 |
if(!(((aPackage.iNotifyType & TFsNotification::ECreate) == TFsNotification::ECreate) && |
|
1648 |
(aPackage.iOperation == t_notification::EFileCreate || |
|
1649 |
aPackage.iOperation == t_notification::EFileReplace || |
|
1650 |
aPackage.iOperation == t_notification::EFileCreate_subs || |
|
1651 |
aPackage.iOperation == t_notification::EFileCreate_subs_nowatch || |
|
1652 |
aPackage.iOperation == t_notification::EFileCreate_txt_nowatch || |
|
1653 |
aPackage.iOperation == t_notification::EFileCreate_txt || |
|
1654 |
aPackage.iOperation == t_notification::EFsMkDir || |
|
1655 |
aPackage.iOperation == t_notification::ECFileManMove || |
|
1656 |
aPackage.iOperation == t_notification::EAllOps1 || |
|
1657 |
aPackage.iOperation == t_notification::EAllOps2 || |
|
1658 |
aPackage.iOperation == t_notification::EAllOps3 || |
|
1659 |
aPackage.iOperation == t_notification::EAllOps4 || |
|
1660 |
aPackage.iOperation == t_notification::EAllOps5))) |
|
1661 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1662 |
if (aPackage.iOperation == t_notification::EFileCreate_txt) |
|
1663 |
{ |
|
1664 |
//Check filename is of correct extension |
|
1665 |
TPtrC _path; |
|
1666 |
((TFsNotification*) notification)->Path(_path); |
|
1667 |
TBuf<5> _ext; |
|
1668 |
_ext.Append(_L(".txt")); |
|
1669 |
TBuf<5> ext; |
|
1670 |
ext.Append(_path.Right(4)); |
|
1671 |
safe_test(aTest,ext.Match(_ext),__LINE__,aPackage.iLineCall); |
|
1672 |
} |
|
1673 |
else if (aPackage.iOperation == t_notification::ECFileManMove) |
|
1674 |
{ |
|
1675 |
if(scratch & ECFManCreate1) |
|
1676 |
{ |
|
1677 |
scratch |= ECFManCreate2; //File created second time |
|
1678 |
} |
|
1679 |
else |
|
1680 |
{ |
|
1681 |
scratch |= ECFManCreate1; //File created first time |
|
1682 |
} |
|
1683 |
} |
|
1684 |
} |
|
1685 |
else if(notificationType == TFsNotification::EDelete) |
|
1686 |
{ |
|
1687 |
if(!(((aPackage.iNotifyType & TFsNotification::EDelete) == TFsNotification::EDelete) && |
|
1688 |
(aPackage.iOperation == t_notification::EFsDelete || |
|
1689 |
aPackage.iOperation == t_notification::EFsRmDir || |
|
1690 |
aPackage.iOperation == t_notification::EFsRmDir_nonEmpty || |
|
1691 |
aPackage.iOperation == t_notification::EFsRmDir_wild || |
|
1692 |
aPackage.iOperation == t_notification::ECFileManMove || |
|
1693 |
aPackage.iOperation == t_notification::EAllOps1 || |
|
1694 |
aPackage.iOperation == t_notification::EAllOps2 || |
|
1695 |
aPackage.iOperation == t_notification::EAllOps3 || |
|
1696 |
aPackage.iOperation == t_notification::EAllOps4))) |
|
1697 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1698 |
||
1699 |
if(aPackage.iOperation == t_notification::ECFileManMove) |
|
1700 |
{ |
|
1701 |
if(scratch & ECFManDelete1) |
|
1702 |
{ |
|
1703 |
scratch |= ECFManDelete2; |
|
1704 |
} |
|
1705 |
else |
|
1706 |
{ |
|
1707 |
scratch |= ECFManDelete1; |
|
1708 |
} |
|
1709 |
} |
|
1710 |
} |
|
1711 |
else if(notificationType == TFsNotification::ERename) |
|
1712 |
{ |
|
1713 |
if(!(((aPackage.iNotifyType & TFsNotification::ERename) == TFsNotification::ERename) && |
|
1714 |
(aPackage.iOperation == t_notification::EFileRename || |
|
1715 |
aPackage.iOperation == t_notification::EFileRename_wild || |
|
1716 |
aPackage.iOperation == t_notification::EFsReplace || |
|
1717 |
aPackage.iOperation == t_notification::ECFileManMove || |
|
1718 |
aPackage.iOperation == t_notification::EFsRename || |
|
1719 |
aPackage.iOperation == t_notification::EFsRename_dir || |
|
1720 |
aPackage.iOperation == t_notification::EAllOps5))) |
|
1721 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1722 |
TPtrC newnameC; |
|
1723 |
((TFsNotification*)notification)->NewName(newnameC); |
|
1724 |
aTest.Printf(_L("%S - (%d)\n"),&newnameC,threadID); |
|
1725 |
||
1726 |
TPtrC _pathC; |
|
1727 |
((TFsNotification*) notification)->Path(_pathC); |
|
1728 |
||
1729 |
TBuf<40> _path; |
|
1730 |
_path.Copy(_pathC); |
|
1731 |
||
1732 |
if (aPackage.iOperation == t_notification::EFsRename_dir) |
|
1733 |
{ |
|
1734 |
_path.Delete(_path.Length()-1,1); |
|
1735 |
_path.AppendNum(0); |
|
1736 |
_path.Append(KPathDelimiter); |
|
1737 |
} |
|
1738 |
else if (aPackage.iOperation == t_notification::EFileRename_wild) |
|
1739 |
{ |
|
1740 |
_path.Delete(_path.Length()-1,1); |
|
1741 |
_path.AppendNum(numNotifications); |
|
1742 |
} |
|
1743 |
else |
|
1744 |
{ |
|
1745 |
_path.AppendNum(0); |
|
1746 |
} |
|
1747 |
||
1748 |
if(aPackage.iOperation != t_notification::ECFileManMove) |
|
1749 |
{ |
|
1750 |
safe_test(aTest,newnameC.Match(_path),__LINE__,aPackage.iLineCall); |
|
1751 |
} |
|
1752 |
else if(scratch & ECFManRename1) |
|
1753 |
{ |
|
1754 |
scratch |= ECFManRename2; |
|
1755 |
} |
|
1756 |
else |
|
1757 |
{ |
|
1758 |
scratch |= ECFManRename1; |
|
1759 |
} |
|
1760 |
||
1761 |
} |
|
1762 |
else if(notificationType == TFsNotification::EAttribute) |
|
1763 |
{ |
|
1764 |
if(!(((aPackage.iNotifyType & TFsNotification::EAttribute) == TFsNotification::EAttribute) && |
|
1765 |
(aPackage.iOperation == t_notification::EFsSetEntry || |
|
1766 |
aPackage.iOperation == t_notification::EFileSet || |
|
1767 |
aPackage.iOperation == t_notification::EFileSetAtt || |
|
1768 |
aPackage.iOperation == t_notification::EFileSetAtt_subs || |
|
1769 |
aPackage.iOperation == t_notification::ECFileManMove || |
|
1770 |
aPackage.iOperation == t_notification::EAllOps4))) |
|
1771 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1772 |
TUint setAtt = 0; |
|
1773 |
TUint clearAtt = 0; |
|
1774 |
((TFsNotification*) notification)->Attributes(setAtt, clearAtt); |
|
1775 |
||
1776 |
if(aPackage.iOperation == t_notification::ECFileManMove) |
|
1777 |
{ |
|
1778 |
scratch |= ECFManAtt1; |
|
1779 |
} |
|
1780 |
else |
|
1781 |
{ |
|
1782 |
if(setAtt != KEntryAttHidden) |
|
1783 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1784 |
if(clearAtt != KEntryAttReadOnly) |
|
1785 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1786 |
} |
|
1787 |
} |
|
1788 |
else if(notificationType == TFsNotification::EMediaChange) |
|
1789 |
{ |
|
1790 |
if(!(((aPackage.iNotifyType & TFsNotification::EMediaChange) == TFsNotification::EMediaChange) && |
|
1791 |
(aPackage.iOperation == t_notification::EMount || |
|
1792 |
aPackage.iOperation == t_notification::EMountScan || |
|
1793 |
aPackage.iOperation == t_notification::EDismount || |
|
1794 |
aPackage.iOperation == t_notification::EMountDismount || |
|
1795 |
aPackage.iOperation == t_notification::EMediaCardInsertion || |
|
1796 |
aPackage.iOperation == t_notification::EMediaCardRemoval || |
|
1797 |
aPackage.iOperation == t_notification::EFormat || |
|
1798 |
aPackage.iOperation == t_notification::ECFileManMove || |
|
1799 |
aPackage.iOperation == t_notification::ERawDiskWrite))) |
|
1800 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1801 |
} |
|
1802 |
else if(notificationType == TFsNotification::EDriveName) |
|
1803 |
{ |
|
1804 |
if(!(((aPackage.iNotifyType & TFsNotification::EDriveName) == TFsNotification::EDriveName) && |
|
1805 |
(aPackage.iOperation == t_notification::ESetDriveName || |
|
1806 |
aPackage.iOperation == t_notification::EAllOps6))) |
|
1807 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1808 |
} |
|
1809 |
else if(notificationType == TFsNotification::EVolumeName) |
|
1810 |
{ |
|
1811 |
if(!(((aPackage.iNotifyType & TFsNotification::EVolumeName) == TFsNotification::EVolumeName) && |
|
1812 |
(aPackage.iOperation == t_notification::ESetVolumeLabel || |
|
1813 |
aPackage.iOperation == t_notification::EAllOps6))) |
|
1814 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1815 |
||
1816 |
TPtrC newnameC; |
|
1817 |
((TFsNotification*)notification)->NewName(newnameC); |
|
1818 |
aTest.Printf(_L("New volume name: %S - (%d)\n"),&newnameC,threadID); |
|
1819 |
} |
|
1820 |
||
1821 |
i++; |
|
1822 |
notification = notify->NextNotification(); |
|
1823 |
if (notification == NULL) |
|
1824 |
aTest.Printf(_L("Notification is NULL - (%d)\n"),threadID); |
|
1825 |
} |
|
1826 |
||
1827 |
if(i==1) //First iteration will only ever get 1 notification |
|
1828 |
{ |
|
1829 |
if(numNotifications != 1) |
|
1830 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1831 |
} |
|
1832 |
||
1833 |
if(numNotifications < aPackage.iMaxNotifications && !overflow) //Ensure we get all of the notifications we expected |
|
1834 |
{ |
|
1835 |
TRequestStatus status; |
|
1836 |
notify->RequestNotifications(status); |
|
1837 |
User::WaitForRequest(status); |
|
1838 |
} |
|
1839 |
} |
|
1840 |
||
1841 |
//0x307 = create1 | write1 | delete1 | rename1 | rename2 |
|
1842 |
if(aPackage.iOperation == t_notification::ECFileManMove && (scratch != 0x307)) |
|
1843 |
{ |
|
1844 |
aTest.Printf(_L("CFileManMove test failure - scratch = 0x%x"),scratch); |
|
1845 |
safe_test(aTest,KErrGeneral,__LINE__,aPackage.iLineCall); |
|
1846 |
} |
|
1847 |
||
1848 |
} |
|
1849 |
||
1850 |
/* |
|
1851 |
* Watches for changes in files/directories. |
|
1852 |
* Used in TestMultipleNotificationsL(). |
|
1853 |
*/ |
|
1854 |
TInt MultipleNotificationsTFWatcher(TAny* aAny) |
|
1855 |
{ |
|
1856 |
CTrapCleanup* cleanup; |
|
1857 |
cleanup = CTrapCleanup::New(); |
|
1858 |
||
1859 |
RThread thread; |
|
1860 |
TUint64 threadID = thread.Id().Id(); |
|
1861 |
||
1862 |
SThreadPackageMultiple package = *(SThreadPackageMultiple*) aAny; |
|
1863 |
RTest multipleWatcherTest(_L("MultipleNotificationsTFWatcher")); |
|
1864 |
multipleWatcherTest.Start(_L("MultipleNotificationsTFWatcher")); |
|
1865 |
||
1866 |
RFs fs; |
|
1867 |
fs.Connect(); |
|
1868 |
||
1869 |
multipleWatcherTest.Printf(_L("MultipleNotificationsTFWatcher (%d) - Create CFsNotify\n"),threadID); |
|
1870 |
CFsNotify* notify = NULL; |
|
1871 |
TRAPD(r,notify = CFsNotify::NewL(fs,package.iBufferSize)); |
|
1872 |
safe_test(multipleWatcherTest,r,__LINE__,package.iLineCall); |
|
1873 |
TBuf<40> path; |
|
1874 |
TBuf<20> filename; |
|
1875 |
if(package.iNotifyType != TFsNotification::EMediaChange && |
|
1876 |
package.iNotifyType != TFsNotification::EDriveName && |
|
1877 |
package.iNotifyType != TFsNotification::EVolumeName && |
|
1878 |
package.iOperation != t_notification::EAllOps6) |
|
1879 |
{ |
|
1880 |
path.Append(gDriveToTest); |
|
1881 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); //len=22 |
|
1882 |
path.Append(package.iFileName); |
|
1883 |
filename.Append(package.iString); |
|
1884 |
} |
|
1885 |
else |
|
1886 |
{ |
|
1887 |
path.Append((TChar)globalDriveNum+(TChar)'A'); |
|
1888 |
path.Append(_L(":")); |
|
1889 |
} |
|
1890 |
TBuf<40> fullname; |
|
1891 |
fullname.Append(path); |
|
1892 |
fullname.Append(filename); |
|
1893 |
||
1894 |
if (package.iNotifyType == TFsNotification::EVolumeName || |
|
1895 |
package.iOperation == t_notification::EAllOps6) |
|
1896 |
{ |
|
1897 |
//Ensure volume has no label |
|
1898 |
multipleWatcherTest.Printf(_L("Set volume label to nothing\n")); |
|
1899 |
r = fs.SetVolumeLabel(_L(""),globalDriveNum); |
|
1900 |
safe_test(multipleWatcherTest,r,__LINE__,package.iLineCall); |
|
1901 |
} |
|
1902 |
||
1903 |
if (package.iNotifyType == TFsNotification::EDriveName || |
|
1904 |
package.iOperation == t_notification::EAllOps6) |
|
1905 |
{ |
|
1906 |
//Ensure drive has no name |
|
1907 |
multipleWatcherTest.Printf(_L("Set drive name to nothing\n")); |
|
1908 |
r = fs.SetDriveName(globalDriveNum,_L("")); |
|
1909 |
safe_test(multipleWatcherTest,r,__LINE__,package.iLineCall); |
|
1910 |
} |
|
1911 |
||
1912 |
multipleWatcherTest.Printf(_L("MultipleNotificationsTFWatcher - Add Notification for path %S\n"),&path); |
|
1913 |
multipleWatcherTest.Printf(_L("Add Notification for type %u - (%d)\n"),(TUint)package.iNotifyType,threadID); |
|
1914 |
r = notify->AddNotification((TUint)package.iNotifyType,path,filename); |
|
1915 |
safe_test(multipleWatcherTest,r,__LINE__,package.iLineCall); |
|
1916 |
||
1917 |
TRequestStatus status; |
|
1918 |
multipleWatcherTest.Printf(_L("(%d) - Request Notifications\n"),threadID); |
|
1919 |
r = notify->RequestNotifications(status); |
|
1920 |
safe_test(multipleWatcherTest,r,__LINE__,package.iLineCall); |
|
1921 |
||
1922 |
if (package.iOperation == t_notification::EMediaCardRemoval) |
|
1923 |
{ |
|
1924 |
multipleWatcherTest.Printf(_L("*****************************************************************\n")); |
|
1925 |
multipleWatcherTest.Printf(_L("Waiting 10 seconds.\n")); |
|
1926 |
multipleWatcherTest.Printf(_L("This is a MANUAL test, it requires the removal of the media card.\n")); |
|
1927 |
multipleWatcherTest.Printf(_L("PLEASE REMOVE THE MEDIA CARD. (DriveNumber %d)\n"),globalDriveNum); |
|
1928 |
multipleWatcherTest.Printf(_L("Or press Ctrl + F5 on the emulator.\n")); |
|
1929 |
multipleWatcherTest.Printf(_L("*****************************************************************\n")); |
|
1930 |
} |
|
1931 |
if (package.iOperation == t_notification::EMediaCardInsertion) |
|
1932 |
{ |
|
1933 |
multipleWatcherTest.Printf(_L("*******************************************************************\n")); |
|
1934 |
multipleWatcherTest.Printf(_L("Waiting 10 seconds.\n")); |
|
1935 |
multipleWatcherTest.Printf(_L("This is a MANUAL test, it requires the insertion of the media card.\n")); |
|
1936 |
multipleWatcherTest.Printf(_L("PLEASE INSERT THE MEDIA CARD. (DriveNumber %d)\n"),globalDriveNum); |
|
1937 |
multipleWatcherTest.Printf(_L("*******************************************************************\n")); |
|
1938 |
} |
|
1939 |
||
1940 |
multipleWatcherTest.Printf(_L("(%d) - Signal Test thread to start Doer thread\n"),threadID); |
|
1941 |
package.iBarrier.Signal(); |
|
1942 |
User::WaitForRequest(status); |
|
1943 |
||
1944 |
multipleWatcherTest.Printf(_L("(%d) - MultipleNotificationsTFWatcher Line %d\n"),threadID,__LINE__); |
|
1945 |
||
1946 |
//Handles the notifications |
|
1947 |
HandleMultipleNotifications(multipleWatcherTest, package, notify, (TDesC&)fullname); |
|
1948 |
||
1949 |
multipleWatcherTest.Printf(_L("(%d) - MultipleNotificationsTFWatcher Line %d\n"),threadID,__LINE__); |
|
1950 |
||
1951 |
delete notify; |
|
1952 |
fs.Close(); |
|
1953 |
multipleWatcherTest.End(); |
|
1954 |
multipleWatcherTest.Close(); |
|
1955 |
delete cleanup; |
|
1956 |
return KErrNone; |
|
1957 |
} |
|
1958 |
||
1959 |
/* |
|
1960 |
* TestTwoNotificationsL - Tests File Write, 1 Doer writes to a file twice. |
|
1961 |
* 1 Watcher watches for file write changes. Just so happens that the second one overflows. |
|
1962 |
*/ |
|
1963 |
TInt TestTwoNotificationsL() |
|
1964 |
{ |
|
1965 |
test.Next(_L("TestTwoNotifications")); |
|
1966 |
||
1967 |
RFs fs; |
|
1968 |
fs.Connect(); |
|
1969 |
RSemaphore twoNotificationsDoerBar; |
|
1970 |
SThreadPackageMultiple package; |
|
1971 |
_LIT(KFileName,"file0.write"); |
|
1972 |
package.iIterations = 10; |
|
1973 |
package.iOperation = t_notification::EFileWrite; |
|
1974 |
package.iNotifyType = TFsNotification::EFileChange; |
|
1975 |
package.iFileName = KFileName; |
|
1976 |
package.iBufferSize = 100; //Should get changed to KMin... in CFsNotify::NewL |
|
1977 |
||
1978 |
User::LeaveIfError(twoNotificationsDoerBar.CreateLocal(0)); |
|
1979 |
User::LeaveIfError(package.iBarrier.CreateLocal(0)); |
|
1980 |
RThread watcher; |
|
1981 |
RThread doer; |
|
1982 |
||
1983 |
TInt r = watcher.Create(_L("TestTwoNotificationsWatcherThread"),MultipleNotificationsTFWatcher,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&package); |
|
189 | 1984 |
test_KErrNone(r); |
0 | 1985 |
r = doer.Create(_L("TestTwoNotificationsDoerThread"),TwoNotificationsTFDoer,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&package); |
189 | 1986 |
test_KErrNone(r); |
0 | 1987 |
test.Next(_L("TestTwoNotifications - Resume Watcher")); |
1988 |
watcher.Resume(); |
|
1989 |
test.Next(_L("TestTwoNotifications - Wait for Watcher to be ready")); |
|
1990 |
package.iBarrier.Wait(); //Wait till Watcher has requested notification |
|
1991 |
test.Next(_L("TestTwoNotifications - Resume Doer")); |
|
1992 |
doer.Resume(); |
|
1993 |
||
1994 |
test.Next(_L("TestTwoNotifications - Wait for doer thread death")); |
|
1995 |
TRequestStatus status; |
|
1996 |
doer.Logon(status); |
|
1997 |
User::WaitForRequest(status); |
|
1998 |
test(doer.ExitReason()==KErrNone); |
|
1999 |
||
2000 |
test.Next(_L("TestTwoNotifications - Wait for watcher thread death")); |
|
2001 |
watcher.Logon(status); |
|
2002 |
User::WaitForRequest(status); |
|
2003 |
test(watcher.ExitReason()==KErrNone); |
|
2004 |
||
2005 |
CLOSE_AND_WAIT(doer); |
|
2006 |
CLOSE_AND_WAIT(watcher); |
|
2007 |
||
2008 |
twoNotificationsDoerBar.Close(); |
|
2009 |
package.iBarrier.Close(); |
|
2010 |
fs.Close(); |
|
2011 |
||
2012 |
return KErrNone; |
|
2013 |
} |
|
2014 |
||
2015 |
||
2016 |
/* |
|
2017 |
* Watch two threads to receive two notifications. |
|
2018 |
* Used in TestTwoDoersL(). |
|
2019 |
*/ |
|
2020 |
TInt TestTwoDoersWatcher(TAny* aAny) |
|
2021 |
{ |
|
2022 |
CTrapCleanup* cleanup; |
|
2023 |
cleanup = CTrapCleanup::New(); |
|
2024 |
||
2025 |
RSemaphore& twoThreadsBarrier = *(RSemaphore*)aAny; |
|
2026 |
RTest twoThreadsWatcherTest(_L("TwoThreadsWatcher")); |
|
2027 |
twoThreadsWatcherTest.Start(_L("TwoThreadsWatcher")); |
|
2028 |
||
2029 |
RFs fs; |
|
2030 |
fs.Connect(); |
|
2031 |
||
2032 |
twoThreadsWatcherTest.Next(_L("Create CFsNotify")); |
|
2033 |
CFsNotify* notify = NULL; |
|
2034 |
TRAPD(r,notify = CFsNotify::NewL(fs,200)); |
|
2035 |
twoThreadsWatcherTest(r == KErrNone); |
|
2036 |
||
2037 |
TBuf<40> path1; |
|
2038 |
TBuf<20> filename1; |
|
2039 |
TBuf<40> path2; |
|
2040 |
TBuf<20> filename2; |
|
2041 |
path1.Append(gDriveToTest); |
|
2042 |
path2.Append(gDriveToTest); |
|
2043 |
path1.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
2044 |
filename1.Append(_L("file1.create")); |
|
2045 |
path2.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
2046 |
filename2.Append(_L("file2.create")); |
|
2047 |
TBuf<40> fullname1; |
|
2048 |
fullname1.Append(path1); |
|
2049 |
fullname1.Append(filename1); |
|
2050 |
TBuf<40> fullname2; |
|
2051 |
fullname2.Append(path2); |
|
2052 |
fullname2.Append(filename2); |
|
2053 |
||
2054 |
twoThreadsWatcherTest.Printf(_L("TwoThreadsWatcher - Add Notification for %S\n"),&path1); |
|
2055 |
r = notify->AddNotification((TUint)TFsNotification::ECreate,path1,filename1); |
|
2056 |
twoThreadsWatcherTest(r == KErrNone); |
|
2057 |
||
2058 |
twoThreadsWatcherTest.Printf(_L("TwoThreadsWatcher - Add Notification for %S\n"),&path2); |
|
2059 |
r = notify->AddNotification((TUint)TFsNotification::ECreate,path2,filename2); |
|
2060 |
twoThreadsWatcherTest(r == KErrNone); |
|
2061 |
||
2062 |
TRequestStatus status; |
|
2063 |
twoThreadsWatcherTest.Next(_L("TwoThreadsWatcher - Request Notifications")); |
|
2064 |
r = notify->RequestNotifications(status); |
|
2065 |
twoThreadsWatcherTest(r == KErrNone); |
|
2066 |
||
2067 |
twoThreadsBarrier.Signal(); //Signal Doer threads to start |
|
2068 |
User::WaitForRequest(status); |
|
2069 |
||
2070 |
// We should be getting 2 notifications |
|
2071 |
// Test notifications are not null and check notification types and paths |
|
2072 |
// 1st notification: |
|
2073 |
twoThreadsWatcherTest.Next(_L("TwoThreadsWatcher - First Notification")); |
|
2074 |
const TFsNotification* notification = notify->NextNotification(); |
|
2075 |
twoThreadsWatcherTest(notification != NULL); |
|
2076 |
twoThreadsWatcherTest.Next(_L("TwoThreadsWatcher - First Notification Type")); |
|
2077 |
TFsNotification::TFsNotificationType notificationType = ((TFsNotification*)notification)->NotificationType(); |
|
2078 |
twoThreadsWatcherTest(notificationType == TFsNotification::ECreate); |
|
2079 |
twoThreadsWatcherTest.Next(_L("TwoThreadsWatcher - First Notification Path")); |
|
2080 |
TPtrC _pathC; |
|
2081 |
((TFsNotification*)notification)->Path(_pathC); |
|
2082 |
twoThreadsWatcherTest.Printf(_L("TwoThreadsWatcher - First Notification Path returned %S\n"),&_pathC); |
|
2083 |
TBuf<40> _path; |
|
2084 |
_path.Copy(_pathC); |
|
2085 |
//We can't guarantee which thread ran first so check that it was either path1 or path2 |
|
2086 |
twoThreadsWatcherTest(_path.Match(fullname1) == KErrNone || _path.Match(fullname2) == KErrNone); |
|
2087 |
||
2088 |
// 2nd notification: |
|
2089 |
twoThreadsWatcherTest.Next(_L("TwoThreadsWatcher - Second Notification")); |
|
2090 |
notification = notify->NextNotification(); |
|
2091 |
// Check if next notification exists |
|
2092 |
if (!notification) |
|
2093 |
{ |
|
2094 |
notify->RequestNotifications(status); |
|
2095 |
User::WaitForRequest(status); |
|
2096 |
notification = notify->NextNotification(); |
|
2097 |
} |
|
2098 |
twoThreadsWatcherTest(notification != NULL); |
|
2099 |
twoThreadsWatcherTest.Next(_L("TwoThreadsWatcher - Second Notification Type")); |
|
2100 |
notificationType = ((TFsNotification*)notification)->NotificationType(); |
|
2101 |
twoThreadsWatcherTest(notificationType == TFsNotification::ECreate); |
|
2102 |
twoThreadsWatcherTest.Next(_L("TwoThreadsWatcher - Second Notification Path")); |
|
2103 |
((TFsNotification*)notification)->Path(_pathC); |
|
2104 |
twoThreadsWatcherTest.Printf(_L("TwoThreadsWatcher - Second Notification Path returned %S\n"),&_pathC); |
|
2105 |
_path.Copy(_pathC); |
|
2106 |
twoThreadsWatcherTest(_path.Match(fullname1) == KErrNone || _path.Match(fullname2) == KErrNone); |
|
2107 |
||
2108 |
delete notify; |
|
2109 |
fs.Close(); |
|
2110 |
twoThreadsWatcherTest.End(); |
|
2111 |
twoThreadsWatcherTest.Close(); |
|
2112 |
delete cleanup; |
|
2113 |
return KErrNone; |
|
2114 |
} |
|
2115 |
||
2116 |
/* |
|
2117 |
* TestTwoDoersL - Two Doer threads create a file each and there's one Watcher |
|
2118 |
* which expects two notifications (one from each Doer). |
|
2119 |
*/ |
|
2120 |
TInt TestTwoDoersL() |
|
2121 |
{ |
|
2122 |
test.Next(_L("TestTwoDoers")); |
|
2123 |
||
2124 |
RFs fs; |
|
2125 |
fs.Connect(); |
|
2126 |
||
2127 |
_LIT(KFileName1,"file1.create"); |
|
2128 |
_LIT(KFileName2,"file2.create"); |
|
2129 |
RSemaphore simpleBarrierTest; |
|
2130 |
SThreadPackage pkgDoer1; |
|
2131 |
SThreadPackage pkgDoer2; |
|
2132 |
pkgDoer1.iFileName = KFileName1; |
|
2133 |
pkgDoer2.iFileName = KFileName2; |
|
2134 |
||
2135 |
User::LeaveIfError(pkgDoer1.iBarrier.CreateLocal(0)); |
|
2136 |
User::LeaveIfError(pkgDoer2.iBarrier.CreateLocal(0)); |
|
2137 |
User::LeaveIfError(simpleBarrierTest.CreateLocal(0)); |
|
2138 |
RThread watcher; |
|
2139 |
RThread doer1; |
|
2140 |
RThread doer2; |
|
2141 |
||
2142 |
watcher.Create(_L("TestTwoDoers-WatcherThread"),TestTwoDoersWatcher,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&simpleBarrierTest); |
|
2143 |
doer1.Create(_L("TestTwoDoers-DoerThread1"),SimpleSingleNotificationTFDoer,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&pkgDoer1); |
|
2144 |
doer2.Create(_L("TestTwoDoers-DoerThread2"),SimpleSingleNotificationTFDoer,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&pkgDoer2); |
|
2145 |
watcher.Resume(); |
|
2146 |
simpleBarrierTest.Wait(); //Wait until Watcher has created CFsNotify |
|
2147 |
||
2148 |
doer1.Resume(); |
|
2149 |
doer2.Resume(); |
|
2150 |
||
2151 |
test.Next(_L("TestTwoDoers - Wait for doer1 thread death")); |
|
2152 |
TRequestStatus status; |
|
2153 |
doer1.Logon(status); |
|
2154 |
User::WaitForRequest(status); |
|
2155 |
test(doer1.ExitReason()==KErrNone); |
|
2156 |
||
2157 |
test.Next(_L("TestTwoDoers - Wait for doer2 thread death")); |
|
2158 |
doer2.Logon(status); |
|
2159 |
User::WaitForRequest(status); |
|
2160 |
test(doer2.ExitReason()==KErrNone); |
|
2161 |
||
2162 |
test.Next(_L("TestTwoDoers - Wait for watcher thread death")); |
|
2163 |
watcher.Logon(status); |
|
2164 |
RTimer timer1; |
|
2165 |
TInt r = timer1.CreateLocal(); |
|
2166 |
safe_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
2167 |
TRequestStatus timeout; |
|
2168 |
TTimeIntervalMicroSeconds32 time = 10000000; //10 seconds |
|
2169 |
timer1.After(timeout,time); |
|
2170 |
User::WaitForRequest(timeout,status); |
|
2171 |
test(status.Int() != KRequestPending); |
|
2172 |
timer1.Cancel(); |
|
2173 |
timer1.Close(); |
|
2174 |
//User::WaitForRequest(status); |
|
2175 |
test(watcher.ExitReason()==KErrNone); |
|
2176 |
||
2177 |
CLOSE_AND_WAIT(doer1); |
|
2178 |
CLOSE_AND_WAIT(doer2); |
|
2179 |
CLOSE_AND_WAIT(watcher); |
|
2180 |
||
2181 |
pkgDoer1.iBarrier.Close(); |
|
2182 |
pkgDoer2.iBarrier.Close(); |
|
2183 |
simpleBarrierTest.Close(); |
|
2184 |
fs.Close(); |
|
2185 |
return KErrNone; |
|
2186 |
} |
|
2187 |
||
2188 |
/* |
|
2189 |
* TestTwoWatchersL - Uses two watcher threads and one doer thread to test that running |
|
2190 |
* two distinct sub sessions at the same time (both watch the same file). |
|
2191 |
*/ |
|
2192 |
TInt TestTwoWatchersL() |
|
2193 |
{ |
|
2194 |
test.Next(_L("TestTwoWatchers")); |
|
2195 |
RFs fs; |
|
2196 |
fs.Connect(); |
|
2197 |
_LIT(KFileName,"file.creat3"); |
|
2198 |
SThreadPackage pkgDoer; |
|
2199 |
pkgDoer.iFileName = KFileName; |
|
2200 |
||
2201 |
SThreadPackage watcherPkg; |
|
2202 |
watcherPkg.iFileName = KFileName; |
|
2203 |
||
2204 |
User::LeaveIfError(pkgDoer.iBarrier.CreateLocal(0)); |
|
2205 |
User::LeaveIfError(watcherPkg.iBarrier.CreateLocal(0)); |
|
2206 |
RThread watcher; |
|
2207 |
RThread watcher2; |
|
2208 |
RThread doer; |
|
2209 |
watcher.Create(_L("TestTwoWatchersWatcherThread"),SimpleSingleNotificationTFWatcher,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&watcherPkg); |
|
2210 |
watcher2.Create(_L("TestTwoWatchersWatcher2Thread"),SimpleSingleNotificationTFWatcher,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&watcherPkg); |
|
2211 |
doer.Create(_L("TestTwoWatchersDoerThread"),SimpleSingleNotificationTFDoer,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&pkgDoer); |
|
2212 |
watcher.Resume(); |
|
2213 |
watcher2.Resume(); |
|
2214 |
watcherPkg.iBarrier.Wait(); //Wait till both watchers have requested notification |
|
2215 |
watcherPkg.iBarrier.Wait(); |
|
2216 |
doer.Resume(); |
|
2217 |
||
2218 |
test.Printf(_L("Wait for DOER to terminate , Line %d"),__LINE__); |
|
2219 |
TRequestStatus status; |
|
2220 |
doer.Logon(status); |
|
2221 |
User::WaitForRequest(status); |
|
2222 |
test(doer.ExitReason()==KErrNone); |
|
2223 |
||
2224 |
test.Printf(_L("Wait for WATCHER to terminate , Line %d"),__LINE__); |
|
2225 |
watcher.Logon(status); |
|
2226 |
RTimer timer1; |
|
2227 |
TInt r = timer1.CreateLocal(); |
|
2228 |
safe_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
2229 |
TRequestStatus timeout; |
|
2230 |
TTimeIntervalMicroSeconds32 time = 10000000; //10 seconds |
|
2231 |
timer1.After(timeout,time); |
|
2232 |
User::WaitForRequest(timeout,status); |
|
2233 |
test(status.Int() != KRequestPending); |
|
2234 |
timer1.Cancel(); |
|
2235 |
timer1.Close(); |
|
2236 |
// User::WaitForRequest(status); |
|
2237 |
test(watcher.ExitReason()==KErrNone); |
|
2238 |
||
2239 |
test.Printf(_L("Wait for WATCHER2 to terminate , Line %d"),__LINE__); |
|
2240 |
watcher2.Logon(status); |
|
2241 |
RTimer timer2; |
|
2242 |
r = timer2.CreateLocal(); |
|
2243 |
safe_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
2244 |
TRequestStatus timeout2; |
|
2245 |
timer2.After(timeout2,time); |
|
2246 |
User::WaitForRequest(timeout2,status); |
|
2247 |
test(status.Int() != KRequestPending); |
|
2248 |
timer2.Cancel(); |
|
2249 |
timer2.Close(); |
|
2250 |
//User::WaitForRequest(status); |
|
2251 |
test(watcher2.ExitReason()==KErrNone); |
|
2252 |
||
2253 |
CLOSE_AND_WAIT(doer); |
|
2254 |
CLOSE_AND_WAIT(watcher); |
|
2255 |
CLOSE_AND_WAIT(watcher2); |
|
2256 |
||
2257 |
pkgDoer.iBarrier.Close(); |
|
2258 |
watcherPkg.iBarrier.Close(); |
|
2259 |
fs.Close(); |
|
2260 |
return KErrNone; |
|
2261 |
} |
|
2262 |
||
2263 |
||
2264 |
/* |
|
2265 |
* TestTwoWatchersTwoDoersL - Two watcher threads watches two different doer threads. |
|
2266 |
*/ |
|
2267 |
TInt TestTwoWatchersTwoDoersL() |
|
2268 |
{ |
|
2269 |
test.Next(_L("TestTwoWatchersTwoDoers")); |
|
2270 |
RFs fs; |
|
2271 |
fs.Connect(); |
|
2272 |
_LIT(KFileName1,"f1le.create"); |
|
2273 |
_LIT(KFileName2,"f2le.create"); |
|
2274 |
SThreadPackage package1; |
|
2275 |
package1.iFileName = KFileName1; |
|
2276 |
||
2277 |
SThreadPackage package2; |
|
2278 |
package2.iFileName = KFileName2; |
|
2279 |
||
2280 |
User::LeaveIfError(package1.iBarrier.CreateLocal(0)); |
|
2281 |
User::LeaveIfError(package2.iBarrier.CreateLocal(0)); |
|
2282 |
RThread watcher; |
|
2283 |
RThread watcher2; |
|
2284 |
RThread doer; |
|
2285 |
RThread doer2; |
|
2286 |
watcher.Create(_L("TestTwoWatchersTwoDoersWatcherThread"),SimpleSingleNotificationTFWatcher,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&package1); |
|
2287 |
doer.Create(_L("TestTwoWatchersTwoDoersDoerThread"),SimpleSingleNotificationTFDoer,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&package1); |
|
2288 |
||
2289 |
watcher2.Create(_L("TestTwoWatchersTwoDoersWatcher2Thread"),SimpleSingleNotificationTFWatcher,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&package2); |
|
2290 |
doer2.Create(_L("TestTwoWatchersTwoDoersDoer2Thread"),SimpleSingleNotificationTFDoer,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&package2); |
|
2291 |
watcher.Resume(); |
|
2292 |
watcher2.Resume(); |
|
2293 |
package1.iBarrier.Wait(); //Wait till both watchers have requested notification |
|
2294 |
package2.iBarrier.Wait(); |
|
2295 |
doer.Resume(); |
|
2296 |
doer2.Resume(); |
|
2297 |
||
2298 |
test.Printf(_L("Wait for DOER to terminate , Line %d"),__LINE__); |
|
2299 |
TRequestStatus status; |
|
2300 |
doer.Logon(status); |
|
2301 |
User::WaitForRequest(status); |
|
2302 |
test(doer.ExitReason()==KErrNone); |
|
2303 |
||
2304 |
test.Printf(_L("Wait for DOER2 to terminate , Line %d"),__LINE__); |
|
2305 |
doer2.Logon(status); |
|
2306 |
User::WaitForRequest(status); |
|
2307 |
test(doer2.ExitReason()==KErrNone); |
|
2308 |
||
2309 |
test.Printf(_L("Wait for WATCHER to terminate , Line %d"),__LINE__); |
|
2310 |
watcher.Logon(status); |
|
2311 |
RTimer timer1; |
|
2312 |
TInt r = timer1.CreateLocal(); |
|
2313 |
safe_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
2314 |
TRequestStatus timeout; |
|
2315 |
TTimeIntervalMicroSeconds32 time = 10000000; //10 seconds |
|
2316 |
timer1.After(timeout,time); |
|
2317 |
User::WaitForRequest(timeout,status); |
|
2318 |
test(status.Int() != KRequestPending); |
|
2319 |
timer1.Cancel(); |
|
2320 |
timer1.Close(); |
|
2321 |
test(watcher.ExitReason()==KErrNone); |
|
2322 |
||
2323 |
test.Printf(_L("Wait for WATCHER2 to terminate , Line %d"),__LINE__); |
|
2324 |
watcher2.Logon(status); |
|
2325 |
RTimer timer2; |
|
2326 |
r = timer2.CreateLocal(); |
|
2327 |
safe_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
2328 |
TRequestStatus timeout2; |
|
2329 |
timer2.After(timeout2,time); |
|
2330 |
User::WaitForRequest(timeout2,status); |
|
2331 |
test(status.Int() != KRequestPending); |
|
2332 |
timer2.Cancel(); |
|
2333 |
timer2.Close(); |
|
2334 |
test(watcher2.ExitReason()==KErrNone); |
|
2335 |
||
2336 |
CLOSE_AND_WAIT(doer); |
|
2337 |
CLOSE_AND_WAIT(doer2); |
|
2338 |
CLOSE_AND_WAIT(watcher); |
|
2339 |
CLOSE_AND_WAIT(watcher2); |
|
2340 |
||
2341 |
package1.iBarrier.Close(); |
|
2342 |
package2.iBarrier.Close(); |
|
2343 |
fs.Close(); |
|
2344 |
return KErrNone; |
|
2345 |
} |
|
2346 |
||
2347 |
||
2348 |
/* |
|
2349 |
* Multi-purpose test |
|
2350 |
* |
|
2351 |
* If aFailureExpected is ETrue, it is expected that the watcher thread is not terminated normally, |
|
2352 |
* due to the notification(s) not being sent. |
|
2353 |
* Since this function is called many times, aLineCall is used to show the line where it is called from. |
|
2354 |
* See SThreadPackageMultiple. |
|
2355 |
*/ |
|
2356 |
TInt TestMultipleNotificationsL(const TDesC& aFilename, const TDesC& aString, TInt aIterations, |
|
2357 |
TInt aMaxNotifications, t_notification::EOperation aOperation, |
|
2358 |
TUint aNotifyType, TInt aBufferSize, TBool aFailureExpected, TInt aLineCall) |
|
2359 |
{ |
|
2360 |
test.Next(_L("TestMultipleNotifications")); |
|
2361 |
||
2362 |
RFs fs; |
|
2363 |
fs.Connect(); |
|
2364 |
SThreadPackageMultiple package; |
|
2365 |
package.iIterations = aIterations; |
|
2366 |
package.iMaxNotifications = aMaxNotifications; |
|
2367 |
package.iOperation = aOperation; |
|
2368 |
package.iNotifyType = (TFsNotification::TFsNotificationType)aNotifyType; |
|
2369 |
package.iString = aString; |
|
2370 |
package.iFileName = aFilename; |
|
2371 |
package.iBufferSize = aBufferSize; |
|
2372 |
package.iLineCall = aLineCall; |
|
2373 |
||
2374 |
User::LeaveIfError(package.iBarrier.CreateLocal(0)); |
|
2375 |
RThread watcher; |
|
2376 |
RThread doer; |
|
2377 |
RTimer tim; |
|
2378 |
User::LeaveIfError(tim.CreateLocal()); |
|
2379 |
||
2380 |
TInt r = watcher.Create(_L("TestMultipleNotificationsWatcherThread"),MultipleNotificationsTFWatcher,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&package); |
|
2381 |
safe_test(test,r,__LINE__,package.iLineCall); |
|
2382 |
r = doer.Create(_L("TestMultipleNotificationsDoerThread"),MultipleNotificationTFDoer,KDefaultStackSize*2,KMinHeapSize,KMaxHeapSize,&package); |
|
2383 |
safe_test(test,r,__LINE__,package.iLineCall); |
|
2384 |
test.Next(_L("TestMultipleNotifications - Resume Watcher")); |
|
2385 |
watcher.Resume(); |
|
2386 |
test.Next(_L("TestMultipleNotifications - Wait for Watcher to be ready")); |
|
2387 |
package.iBarrier.Wait(); //Wait till Watcher has requested notification |
|
2388 |
test.Next(_L("TestMultipleNotifications - Resume Doer")); |
|
2389 |
doer.Resume(); |
|
2390 |
||
2391 |
test.Next(_L("TestMultipleNotifications - Wait for doer thread death")); |
|
2392 |
TRequestStatus status; |
|
2393 |
doer.Logon(status); |
|
2394 |
User::WaitForRequest(status); |
|
2395 |
test.Printf(_L("TestMultipleNotifications - Doer Exit Reason %d\n"),doer.ExitReason()); |
|
2396 |
safe_test(test,doer.ExitReason(),__LINE__,package.iLineCall); |
|
2397 |
||
2398 |
TRequestStatus timStatus; |
|
2399 |
TTimeIntervalMicroSeconds32 timeout; |
|
2400 |
if (aFailureExpected && !(package.iOperation == t_notification::EMediaCardInsertion || |
|
2401 |
package.iOperation == t_notification::EMediaCardRemoval)) |
|
2402 |
{ |
|
2403 |
timeout = 1500000; //1.5 seconds, we don't want to wait too long if we expect it to fail |
|
2404 |
} |
|
2405 |
else |
|
2406 |
{ |
|
2407 |
timeout = 10000000; //10 seconds |
|
2408 |
} |
|
2409 |
tim.After(timStatus,timeout); |
|
2410 |
||
2411 |
test.Next(_L("TestMultipleNotifications - Wait for watcher thread death or timeout")); |
|
2412 |
watcher.Logon(status); |
|
2413 |
User::WaitForRequest(status,timStatus); |
|
2414 |
if(!(status != KRequestPending || aFailureExpected)) |
|
2415 |
safe_test(test,KErrGeneral,__LINE__,package.iLineCall); |
|
2416 |
||
2417 |
test.Printf(_L("TestMultipleNotifications - Watcher Exit Reason %d\n"),watcher.ExitReason()); |
|
2418 |
safe_test(test,watcher.ExitReason(),__LINE__,package.iLineCall); |
|
2419 |
||
2420 |
CLOSE_AND_WAIT(doer); |
|
2421 |
||
2422 |
if(status == KRequestPending) |
|
2423 |
{ |
|
2424 |
watcher.Kill(KErrTimedOut); |
|
2425 |
test.Printf(_L("TestMultipleNotifications - Watcher timed out\n")); |
|
2426 |
} |
|
2427 |
CLOSE_AND_WAIT(watcher); |
|
2428 |
||
2429 |
package.iBarrier.Close(); |
|
2430 |
fs.Close(); |
|
2431 |
tim.Close(); |
|
2432 |
test.Printf(_L("----------------------------------------------------------------------\n")); |
|
2433 |
return KErrNone; |
|
2434 |
} |
|
2435 |
||
2436 |
TInt TestMultipleNotificationsL(const TDesC& aFilename, const TDesC& aString, TInt aIterations, |
|
2437 |
TInt aMaxNotifications, t_notification::EOperation aOperation, |
|
2438 |
TFsNotification::TFsNotificationType aNotifyType, TInt aBufferSize, |
|
2439 |
TBool aFailureExpected, TInt aLineCall) |
|
2440 |
{ |
|
2441 |
return TestMultipleNotificationsL(aFilename, aString, aIterations, aMaxNotifications, aOperation, |
|
2442 |
(TUint)aNotifyType, aBufferSize, aFailureExpected, aLineCall); |
|
2443 |
} |
|
2444 |
||
2445 |
TInt TestMultipleNotificationsL(const TDesC& aFilename, TInt aIterations, TInt aMaxNotifications, |
|
2446 |
t_notification::EOperation aOperation, TUint aNotifyType, TInt aBufferSize, |
|
2447 |
TBool aFailureExpected, TInt aLineCall) |
|
2448 |
{ |
|
2449 |
return TestMultipleNotificationsL(aFilename,_L(""), aIterations, aMaxNotifications, aOperation, aNotifyType, |
|
2450 |
aBufferSize, aFailureExpected, aLineCall); |
|
2451 |
} |
|
2452 |
||
2453 |
||
2454 |
// Watcher for TestAddRemoveNotificationL() |
|
2455 |
TInt TestAddRemoveNotificationWatcher(TAny* aAny) |
|
2456 |
{ |
|
2457 |
CTrapCleanup* cleanup; |
|
2458 |
cleanup = CTrapCleanup::New(); |
|
2459 |
RThread thread; |
|
2460 |
TUint64 threadId = thread.Id().Id(); |
|
2461 |
||
2462 |
SThreadPackage pkgDoer = *(SThreadPackage*)aAny; |
|
2463 |
RSemaphore& addRemoveBarrier = pkgDoer.iBarrier; |
|
2464 |
||
2465 |
RTest addRemoveWatcherTest(_L("TestAddRemoveNotificationWatcher")); |
|
2466 |
addRemoveWatcherTest.Start(_L("TestAddRemoveNotificationWatcher")); |
|
2467 |
||
2468 |
RFs fs; |
|
2469 |
fs.Connect(); |
|
2470 |
||
2471 |
addRemoveWatcherTest.Printf(_L("TestAddRemoveNotificationWatcher(%d) - Create CFsNotify\n"),threadId); |
|
2472 |
CFsNotify* notify = NULL; |
|
2473 |
TRAPD(r,notify = CFsNotify::NewL(fs,100); ); |
|
2474 |
addRemoveWatcherTest( r == KErrNone); |
|
2475 |
TBuf<40> path; |
|
2476 |
TBuf<20> filename; |
|
2477 |
path.Append(gDriveToTest); |
|
2478 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); //len=22 |
|
2479 |
filename.Append(pkgDoer.iFileName); |
|
2480 |
||
2481 |
addRemoveWatcherTest.Printf(_L("TestAddRemoveNotificationWatcher - Add Notification for %S\n"),&path); |
|
2482 |
r = notify->AddNotification((TUint)TFsNotification::ECreate,path,filename); |
|
2483 |
addRemoveWatcherTest(r==KErrNone); |
|
2484 |
addRemoveWatcherTest.Printf(_L("TestAddRemoveNotificationWatcher(%d) - Remove Notifications\n"),threadId); |
|
2485 |
r = notify->RemoveNotifications(); |
|
2486 |
addRemoveWatcherTest(r==KErrNone); |
|
2487 |
addRemoveWatcherTest.Printf(_L("TestAddRemoveNotificationWatcher(%d) - Request Notifications\n"),threadId); |
|
2488 |
TRequestStatus status; |
|
2489 |
r = notify->RequestNotifications(status); |
|
2490 |
addRemoveWatcherTest(r==KErrNone); |
|
2491 |
addRemoveWatcherTest.Printf(_L("TestAddRemoveNotificationWatcher status = %d"),status.Int()); |
|
2492 |
addRemoveBarrier.Signal(); |
|
2493 |
||
2494 |
addRemoveWatcherTest.Printf(_L("TestAddRemoveNotificationWatcher(%d) - NextNotification\n"),threadId); |
|
2495 |
//We should not be getting any notifications as the notification request has been removed |
|
2496 |
const TFsNotification* notification = notify->NextNotification(); |
|
2497 |
addRemoveWatcherTest(notification == NULL); |
|
2498 |
||
2499 |
delete notify; |
|
2500 |
fs.Close(); |
|
2501 |
addRemoveWatcherTest.End(); |
|
2502 |
addRemoveWatcherTest.Close(); |
|
2503 |
delete cleanup; |
|
2504 |
return KErrNone; |
|
2505 |
} |
|
2506 |
||
2507 |
||
2508 |
/* |
|
2509 |
* TestAddRemoveNotificationL - Watcher adds and removes notification request. |
|
2510 |
* Any changes by doer thread should not be detected. |
|
2511 |
*/ |
|
2512 |
TInt TestAddRemoveNotificationL() |
|
2513 |
{ |
|
2514 |
test.Next(_L("TestAddRemoveNotification")); |
|
2515 |
RFs fs; |
|
2516 |
fs.Connect(); |
|
2517 |
||
2518 |
SThreadPackage package; |
|
2519 |
_LIT(KFileName,"noFile.create"); |
|
2520 |
package.iFileName = KFileName; |
|
2521 |
||
2522 |
User::LeaveIfError(package.iBarrier.CreateLocal(0)); |
|
2523 |
RThread watcher; |
|
2524 |
RThread doer; |
|
2525 |
||
2526 |
watcher.Create(_L("TestAddRemoveNotification-WatcherThread"),TestAddRemoveNotificationWatcher,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&package); |
|
2527 |
doer.Create(_L("TestAddRemoveNotification-DoerThread"),SimpleSingleNotificationTFDoer,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&package); |
|
2528 |
watcher.Resume(); |
|
2529 |
||
2530 |
test.Printf(_L("TestAddRemoveNotification - Wait until Watcher has created CFsNotify\n")); |
|
2531 |
package.iBarrier.Wait(); //Wait until Watcher has created CFsNotify |
|
2532 |
doer.Resume(); |
|
2533 |
||
2534 |
test.Next(_L("TestAddRemoveNotification - Wait for doer thread death")); |
|
2535 |
TRequestStatus status; |
|
2536 |
doer.Logon(status); |
|
2537 |
User::WaitForRequest(status); |
|
2538 |
test(doer.ExitReason()==KErrNone); |
|
2539 |
||
2540 |
test.Next(_L("TestAddRemoveNotification - Wait for watcher thread death")); |
|
2541 |
watcher.Logon(status); |
|
2542 |
RTimer timer1; |
|
2543 |
TInt r = timer1.CreateLocal(); |
|
2544 |
safe_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
2545 |
TRequestStatus timeout; |
|
2546 |
TTimeIntervalMicroSeconds32 time = 10000000; //10 seconds |
|
2547 |
timer1.After(timeout,time); |
|
2548 |
User::WaitForRequest(timeout,status); |
|
2549 |
test(status.Int() != KRequestPending); |
|
2550 |
timer1.Cancel(); |
|
2551 |
timer1.Close(); |
|
2552 |
test.Printf(_L("Test - Watcher Exit Reason %d\n"),watcher.ExitReason()); |
|
2553 |
test(watcher.ExitReason()==KErrNone); |
|
2554 |
||
2555 |
CLOSE_AND_WAIT(doer); |
|
2556 |
CLOSE_AND_WAIT(watcher); |
|
2557 |
||
2558 |
package.iBarrier.Close(); |
|
2559 |
fs.Close(); |
|
2560 |
return KErrNone; |
|
2561 |
} |
|
2562 |
||
2563 |
||
2564 |
/* |
|
2565 |
* Adds and cancels notification request. |
|
2566 |
* Used in TestCancelNotificationL(). |
|
2567 |
*/ |
|
2568 |
TInt TestCancelNotificationWatcher(TAny* aAny) |
|
2569 |
{ |
|
2570 |
CTrapCleanup* cleanup; |
|
2571 |
cleanup = CTrapCleanup::New(); |
|
2572 |
||
2573 |
RTest cancelNotificationsWatcherTest(_L("TestCancelNotificationWatcher")); |
|
2574 |
cancelNotificationsWatcherTest.Start(_L("TestCancelNotificationWatcher")); |
|
2575 |
||
2576 |
RThread thread; |
|
2577 |
TUint64 threadId = thread.Id().Id(); |
|
2578 |
||
2579 |
SThreadPackageDualSemaphore pkgDoer = *(SThreadPackageDualSemaphore*)aAny; |
|
2580 |
RSemaphore& addRemoveBarrier = pkgDoer.iBarrier; |
|
2581 |
RSemaphore& addRemoveBarrier2 = pkgDoer.iBarrier2; |
|
2582 |
||
2583 |
RFs fs; |
|
2584 |
fs.Connect(); |
|
2585 |
||
2586 |
cancelNotificationsWatcherTest.Printf(_L("TestCancelNotificationWatcher(%d) - Create CFsNotify\n"),threadId); |
|
2587 |
CFsNotify* notify = NULL; |
|
2588 |
TRAPD(r,notify = CFsNotify::NewL(fs,100); ); |
|
2589 |
cancelNotificationsWatcherTest(r == KErrNone); |
|
2590 |
TBuf<40> path; |
|
2591 |
TBuf<20> filename; |
|
2592 |
path.Append(gDriveToTest); |
|
2593 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); //len=22 |
|
2594 |
filename.Append(pkgDoer.iFileName); |
|
2595 |
||
2596 |
cancelNotificationsWatcherTest.Printf(_L("TestCancelNotificationWatcher - Add Notification for %S\n"),&path); |
|
2597 |
r = notify->AddNotification((TUint)TFsNotification::ECreate,path,filename); |
|
2598 |
cancelNotificationsWatcherTest(r==KErrNone); |
|
2599 |
cancelNotificationsWatcherTest.Printf(_L("TestCancelNotificationWatcher(%d) - Request Notifications\n"),threadId); |
|
2600 |
TRequestStatus status; |
|
2601 |
r = notify->RequestNotifications(status); |
|
2602 |
cancelNotificationsWatcherTest(r==KErrNone); |
|
2603 |
||
2604 |
cancelNotificationsWatcherTest.Printf(_L("TestCancelNotificationWatcher(%d) - Cancel Notifications\n"),threadId); |
|
2605 |
r = notify->CancelNotifications(status); |
|
2606 |
cancelNotificationsWatcherTest(r==KErrNone); |
|
2607 |
||
2608 |
cancelNotificationsWatcherTest.Printf(_L("TestCancelNotificationWatcher(%d) - Signal W1 - Start doer\n"),threadId); |
|
2609 |
addRemoveBarrier.Signal(); //W1 - Start doer |
|
2610 |
||
2611 |
cancelNotificationsWatcherTest.Printf(_L("TestCancelNotificationWatcher(%d) - Wait S1 - doer complete\n"),threadId); |
|
2612 |
addRemoveBarrier2.Wait(); //S1 - Wait for doer to have created file |
|
2613 |
||
2614 |
cancelNotificationsWatcherTest.Printf(_L("TestCancelNotificationWatcher(%d) - NextNotification\n"),threadId); |
|
2615 |
//We should not be getting any notifications as the notification request has been removed |
|
2616 |
const TFsNotification* notification = notify->NextNotification(); |
|
2617 |
cancelNotificationsWatcherTest(notification == NULL); |
|
2618 |
||
2619 |
delete notify; |
|
2620 |
fs.Close(); |
|
2621 |
cancelNotificationsWatcherTest.Printf(_L("TestCancelNotificationWatcher(%d) - Complete\n"),threadId); |
|
2622 |
cancelNotificationsWatcherTest.End(); |
|
2623 |
cancelNotificationsWatcherTest.Close(); |
|
2624 |
delete cleanup; |
|
2625 |
return KErrNone; |
|
2626 |
} |
|
2627 |
||
2628 |
||
2629 |
/* |
|
2630 |
* TestCancelNotificationL - Watcher adds and cancels notification request. |
|
2631 |
*/ |
|
2632 |
TInt TestCancelNotificationL() |
|
2633 |
{ |
|
2634 |
test.Next(_L("TestCancelNotification")); |
|
2635 |
RFs fs; |
|
2636 |
fs.Connect(); |
|
2637 |
||
2638 |
SThreadPackageDualSemaphore package; |
|
2639 |
_LIT(KFileName,"cancel.create"); |
|
2640 |
package.iFileName = KFileName; |
|
2641 |
||
2642 |
User::LeaveIfError(package.iBarrier.CreateLocal(0)); |
|
2643 |
User::LeaveIfError(package.iBarrier2.CreateLocal(0)); |
|
2644 |
RThread watcher; |
|
2645 |
RThread doer; |
|
2646 |
||
2647 |
TInt r = watcher.Create(_L("TestCancelNotification-WatcherThread"),TestCancelNotificationWatcher,KDefaultStackSize*2,KMinHeapSize,KMaxHeapSize,&package); |
|
189 | 2648 |
test_KErrNone(r); |
0 | 2649 |
r = doer.Create(_L("TestCancelNotification-DoerThread"),SimpleSingleNotificationTFDoer,KDefaultStackSize*2,KMinHeapSize,KMaxHeapSize,&package); |
189 | 2650 |
test_KErrNone(r); |
0 | 2651 |
test.Printf(_L("TestCancelNotificationL - Watcher.Resume()")); |
2652 |
watcher.Resume(); |
|
2653 |
test.Printf(_L("TestCancelNotificationL - Waiting on package.iBarrier.Wait()")); |
|
2654 |
package.iBarrier.Wait(); //W1 - Wait until Watcher has created CFsNotify |
|
2655 |
test.Printf(_L("TestCancelNotificationL -Doer Resume")); |
|
2656 |
TRequestStatus status; |
|
2657 |
doer.Logon(status); |
|
2658 |
doer.Resume(); |
|
2659 |
||
2660 |
test.Next(_L("TestCancelNotification - Wait for doer thread death")); |
|
2661 |
User::WaitForRequest(status); |
|
2662 |
test(doer.ExitReason()==KErrNone); |
|
2663 |
||
2664 |
package.iBarrier2.Signal(); //S1 |
|
2665 |
||
2666 |
test.Next(_L("TestCancelNotification - Wait for watcher thread death")); |
|
2667 |
watcher.Logon(status); |
|
2668 |
||
2669 |
RTimer tim; |
|
2670 |
r = tim.CreateLocal(); |
|
189 | 2671 |
test_KErrNone(r); |
0 | 2672 |
|
2673 |
TRequestStatus timStatus; |
|
2674 |
TTimeIntervalMicroSeconds32 time = 10000000; //10 seconds |
|
2675 |
tim.After(timStatus,time); |
|
2676 |
||
2677 |
User::WaitForRequest(status,timStatus); |
|
2678 |
test(status!=KRequestPending); |
|
2679 |
test(watcher.ExitReason()==KErrNone); |
|
2680 |
||
2681 |
CLOSE_AND_WAIT(doer); |
|
2682 |
CLOSE_AND_WAIT(watcher); |
|
2683 |
||
2684 |
package.iBarrier.Close(); |
|
2685 |
package.iBarrier2.Close(); |
|
2686 |
fs.Close(); |
|
2687 |
tim.Close(); |
|
2688 |
return KErrNone; |
|
2689 |
} |
|
2690 |
||
2691 |
/* |
|
2692 |
* Test that if we close the session |
|
2693 |
* before closing the subsession (deleting CFsNotify) |
|
2694 |
* that everything is A-Ok. |
|
2695 |
*/ |
|
2696 |
TInt TestSessionCloseTF(TAny* aTestCase) |
|
2697 |
{ |
|
2698 |
CTrapCleanup* cleanup; |
|
2699 |
cleanup = CTrapCleanup::New(); |
|
2700 |
||
2701 |
TRAPD(r, |
|
2702 |
RFs fs; |
|
2703 |
fs.Connect(); |
|
2704 |
RDebug::Printf("TestSessionClose\n"); |
|
2705 |
||
2706 |
SThreadPackage2 package = *(SThreadPackage2*)aTestCase; |
|
2707 |
package.iBarrier.Signal(); |
|
2708 |
||
2709 |
switch(package.iTestCase) |
|
2710 |
{ |
|
2711 |
case 1: |
|
2712 |
{ |
|
2713 |
RDebug::Printf("TestSessionCloseTF - Case 1 - NewL\n"); |
|
2714 |
CFsNotify* notify = CFsNotify::NewL(fs,KMinNotificationBufferSize); |
|
2715 |
User::LeaveIfNull(notify); |
|
2716 |
||
2717 |
RDebug::Printf("TestSessionCloseTF - Case 1 - Fs.Close\n"); |
|
2718 |
fs.Close(); |
|
2719 |
||
2720 |
TBuf<45> path; |
|
2721 |
path.Append((TChar)gDriveToTest); |
|
2722 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
2723 |
||
2724 |
TBuf<20> filename; |
|
2725 |
filename.Append(_L("session.close")); |
|
2726 |
||
2727 |
CleanupStack::PushL(notify); |
|
2728 |
||
2729 |
RDebug::Printf("TestSessionCloseTF - Case 1 - Add Notification - Panic Expected\n"); |
|
2730 |
r = notify->AddNotification((TUint)TFsNotification::ECreate,path,filename); |
|
2731 |
User::LeaveIfError(r); |
|
2732 |
||
2733 |
RDebug::Printf("TestSessionCloseTF - Case 1 - After Session Close\n"); |
|
2734 |
fs.Close(); |
|
2735 |
CleanupStack::Pop(notify); |
|
2736 |
||
2737 |
RDebug::Printf("TestSessionCloseTF - Case 1 - After Delete Notify\n"); |
|
2738 |
delete notify; |
|
2739 |
break; |
|
2740 |
} |
|
2741 |
case 2: |
|
2742 |
{ |
|
2743 |
RDebug::Printf("TestSessionCloseTF - Case 2 - NewL\n"); |
|
2744 |
CFsNotify* notify = CFsNotify::NewL(fs,KMinNotificationBufferSize); |
|
2745 |
User::LeaveIfNull(notify); |
|
2746 |
||
2747 |
TBuf<45> path; |
|
2748 |
path.Append((TChar)gDriveToTest); |
|
2749 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
2750 |
TBuf<20> filename; |
|
2751 |
filename.Append(_L("session.close")); |
|
2752 |
||
2753 |
RDebug::Printf("TestSessionCloseTF - Case 2 - Add Notification\n"); |
|
2754 |
r = notify->AddNotification((TUint)TFsNotification::ECreate,path,filename); |
|
189 | 2755 |
test_KErrNone(r); |
0 | 2756 |
|
2757 |
RDebug::Printf("TestSessionCloseTF - Case 2 - Fs.Close\n"); |
|
2758 |
fs.Close(); |
|
2759 |
||
2760 |
CleanupStack::PushL(notify); |
|
2761 |
TRequestStatus status; |
|
2762 |
RDebug::Printf("TestSessionCloseTF - Case 2 - Request Notification - Panic Expected\n"); |
|
2763 |
r = notify->RequestNotifications(status); |
|
2764 |
CleanupStack::Pop(notify); |
|
2765 |
||
2766 |
RDebug::Printf("TestSessionCloseTF - Case 2 - After Delete Notify\n"); |
|
2767 |
delete notify; |
|
2768 |
break; |
|
2769 |
} |
|
2770 |
default: |
|
2771 |
{ |
|
2772 |
break; |
|
2773 |
} |
|
2774 |
} |
|
2775 |
); |
|
2776 |
delete cleanup; |
|
2777 |
return r; |
|
2778 |
} |
|
2779 |
||
2780 |
/* |
|
2781 |
* Test that if we close the session |
|
2782 |
* before closing the subsession (deleting CFsNotify) |
|
2783 |
* that everything is A-Ok. |
|
2784 |
*/ |
|
2785 |
void TestSessionClose(TInt aTestCase) |
|
2786 |
{ |
|
2787 |
RSemaphore sem; |
|
2788 |
User::LeaveIfError(sem.CreateLocal(0)); |
|
2789 |
||
2790 |
SThreadPackage2 package; |
|
2791 |
package.iTestCase = aTestCase; |
|
2792 |
package.iBarrier = sem; |
|
2793 |
||
2794 |
RThread thread; |
|
2795 |
thread.Create(_L("TestSessionClose"),TestSessionCloseTF,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&package); |
|
2796 |
||
2797 |
thread.Resume(); |
|
2798 |
sem.Wait(); |
|
2799 |
||
2800 |
TRequestStatus status; |
|
2801 |
thread.Logon(status); |
|
2802 |
User::WaitForRequest(status); |
|
2803 |
test.Printf(_L("Kern-Exec 0 is EXPECTED\n")); |
|
2804 |
TInt err = thread.ExitReason(); |
|
189 | 2805 |
test_KErrNone(err); |
0 | 2806 |
TExitType et = thread.ExitType(); |
2807 |
test(et == EExitPanic); |
|
2808 |
CLOSE_AND_WAIT(thread); |
|
2809 |
sem.Close(); |
|
2810 |
} |
|
2811 |
||
2812 |
const TInt KNotificationOverflowIterationLimit = 7; |
|
2813 |
||
2814 |
/* |
|
2815 |
* Does stuff for TestOverflowL |
|
2816 |
* Synchronises such that watchers have seen 1 change. |
|
2817 |
* Then fills their buffers up to KNotificationOverflowIterationLimit. |
|
2818 |
* |
|
2819 |
*/ |
|
2820 |
TInt TestOverflowDoerTF(TAny* aAny) |
|
2821 |
{ |
|
2822 |
RFs fs; |
|
2823 |
fs.Connect(); |
|
2824 |
||
2825 |
SThreadPackage& package = *(SThreadPackage*) aAny; |
|
2826 |
||
2827 |
TBuf<45> path; |
|
2828 |
path.Append((TChar)gDriveToTest); |
|
2829 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
2830 |
path.Append(package.iFileName); |
|
2831 |
||
2832 |
fs.MkDirAll(path); |
|
2833 |
||
2834 |
RFile file; |
|
2835 |
TInt r = file.Replace(fs,path,EFileWrite); |
|
2836 |
User::LeaveIfError(r); |
|
2837 |
||
2838 |
//Perform first set size. |
|
2839 |
r = file.SetSize(1); |
|
2840 |
User::LeaveIfError(r); |
|
2841 |
||
2842 |
//Wait until both watchers have received this change. |
|
2843 |
package.iBarrier.Wait(); |
|
2844 |
||
2845 |
for(TInt i = 0; i< KNotificationOverflowIterationLimit; i++) |
|
2846 |
{ |
|
2847 |
file.SetSize(i); |
|
2848 |
} |
|
2849 |
||
2850 |
file.Close(); |
|
2851 |
fs.Close(); |
|
2852 |
return KErrNone; |
|
2853 |
} |
|
2854 |
||
2855 |
/* |
|
2856 |
* Thread function used as part of TestOverflowL |
|
2857 |
* Counts the number of notifications and ensures it the correct number before overflow is received# |
|
2858 |
*/ |
|
2859 |
TInt TestOverflowWatcher1TF(TAny* aAny) |
|
2860 |
{ |
|
2861 |
CTrapCleanup* cleanup; |
|
2862 |
cleanup = CTrapCleanup::New(); |
|
2863 |
||
2864 |
RTest overflowTest(_L("TestOverflowWatcher1TF")); |
|
2865 |
overflowTest.Start(_L("TestOverflowWatcher1TF")); |
|
2866 |
||
2867 |
SThreadPackage& package = *(SThreadPackage*) aAny; |
|
2868 |
RFs fs; |
|
2869 |
fs.Connect(); |
|
2870 |
TBuf<45> path; |
|
2871 |
TBuf<20> filename; |
|
2872 |
path.Append((TChar)gDriveToTest); |
|
2873 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
2874 |
filename.Append(package.iFileName); |
|
2875 |
||
2876 |
TRequestStatus status; |
|
2877 |
CFsNotify* notify = NULL; |
|
2878 |
||
2879 |
//This notification's size is 80. |
|
2880 |
//80*7 = 560. |
|
2881 |
// -4 means we should get 6 notifications |
|
2882 |
//Except the first one will still be in the buffer |
|
2883 |
// (as we've not called RequestNotification yet) so we'll only actually get 5. |
|
2884 |
TRAPD(r, notify = CFsNotify::NewL(fs,(80*7)-4)); |
|
189 | 2885 |
test_KErrNone(r); |
0 | 2886 |
User::LeaveIfNull(notify); |
2887 |
notify->AddNotification(TFsNotification::EFileChange,path,filename); |
|
2888 |
notify->RequestNotifications(status); |
|
2889 |
||
2890 |
//Signal that we are ready for doer to start (W1) |
|
2891 |
package.iBarrier.Signal(); |
|
2892 |
||
2893 |
//We wait for the 1 notification (doer only does 1 at first) |
|
2894 |
User::WaitForRequest(status); |
|
2895 |
||
2896 |
overflowTest.Next(_L("Overflow- Get First Notification (Start framework)")); |
|
2897 |
const TFsNotification *notification = notify->NextNotification(); |
|
2898 |
||
2899 |
TFsNotification::TFsNotificationType type = notification->NotificationType(); |
|
2900 |
overflowTest.Printf(_L("Overflow - First Notification Type = %d\n"),type); |
|
2901 |
||
2902 |
//Signal the test thread (W2) |
|
2903 |
package.iBarrier.Signal(); |
|
2904 |
//Wait for Signal to continue (W3); |
|
2905 |
package.iBarrier.Wait(); |
|
2906 |
||
2907 |
notify->RequestNotifications(status); |
|
2908 |
User::WaitForRequest(status); |
|
2909 |
||
2910 |
TInt count = 0; |
|
2911 |
overflowTest.Next(_L("Overflow- Get the rest of the notifications")); |
|
2912 |
notification = notify->NextNotification(); |
|
2913 |
while(notification != NULL) |
|
2914 |
{ |
|
2915 |
||
2916 |
type = notification->NotificationType(); |
|
2917 |
overflowTest.Printf(_L("Overflow - NotificationType = %d\n"),type); |
|
2918 |
if(type & TFsNotification::EOverflow) |
|
2919 |
{ |
|
2920 |
delete notify; |
|
2921 |
fs.Close(); |
|
2922 |
overflowTest.Printf(_L("Overflow +- Count = %d\n"),count); |
|
2923 |
overflowTest.End(); |
|
2924 |
overflowTest.Close(); |
|
2925 |
return count; |
|
2926 |
} |
|
2927 |
||
2928 |
notification = notify->NextNotification(); |
|
2929 |
count++; |
|
2930 |
} |
|
2931 |
overflowTest.Printf(_L("Overflow -- Count = %d\n"),count); |
|
2932 |
||
2933 |
overflowTest.End(); |
|
2934 |
overflowTest.Close(); |
|
2935 |
delete notify; |
|
2936 |
delete cleanup; |
|
2937 |
fs.Close(); |
|
2938 |
return -1; |
|
2939 |
} |
|
2940 |
||
2941 |
||
2942 |
/* |
|
2943 |
* Overflow test |
|
2944 |
* As some of the tests above assume sucess if they receive an overflow |
|
2945 |
* we need to ensure that overflow works properly! |
|
2946 |
*/ |
|
2947 |
TInt TestOverflowL() |
|
2948 |
{ |
|
2949 |
/* |
|
2950 |
* The scheme used is as follows: |
|
2951 |
* 1 Doer thread which is setting the size of a file, over and over. |
|
2952 |
* 1 watcher thread. |
|
2953 |
* |
|
2954 |
* The doer thread does 1 operation then waits on a signal. |
|
2955 |
* The watcher thread requests notification and receives 1 notification. |
|
2956 |
* It then signals the Doer thread. |
|
2957 |
* |
|
2958 |
* The doer thread continues doing setsize until the number of notifications |
|
2959 |
* should have overflowed. |
|
2960 |
* |
|
2961 |
* The watcher Waits for a signal from doer (that all of the notifications have been sent). |
|
2962 |
* The watcher's last notification should be an overflow |
|
2963 |
*/ |
|
2964 |
test.Next(_L("TestOverflow")); |
|
2965 |
RFs fs; |
|
2966 |
TInt r = fs.Connect(); |
|
189 | 2967 |
test_KErrNone(r); |
0 | 2968 |
_LIT(KFileName,"over.flow"); |
2969 |
SThreadPackage doerPkg; |
|
2970 |
doerPkg.iFileName = KFileName; |
|
2971 |
||
2972 |
SThreadPackage watcher1Pkg; |
|
2973 |
watcher1Pkg.iFileName = KFileName; |
|
2974 |
||
2975 |
User::LeaveIfError(doerPkg.iBarrier.CreateLocal(0)); |
|
2976 |
User::LeaveIfError(watcher1Pkg.iBarrier.CreateLocal(0)); |
|
2977 |
RThread watcher1; |
|
2978 |
RThread doer; |
|
2979 |
watcher1.Create(_L("TestOverflowWatcher1Thread"),TestOverflowWatcher1TF,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&watcher1Pkg); |
|
2980 |
doer.Create(_L("TestOverflowDoerThread"),TestOverflowDoerTF,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&doerPkg); |
|
2981 |
watcher1.Resume(); |
|
2982 |
||
2983 |
//Wait until Request has been requested. (W1) |
|
2984 |
watcher1Pkg.iBarrier.Wait(); |
|
2985 |
||
2986 |
doer.Resume(); |
|
2987 |
||
2988 |
//Wait till watcher has received first notification (W2) |
|
2989 |
watcher1Pkg.iBarrier.Wait(); |
|
2990 |
||
2991 |
//Signal the doer that it is free to continue |
|
2992 |
//doing the rest of the operations |
|
2993 |
doerPkg.iBarrier.Signal(); |
|
2994 |
||
2995 |
test.Next(_L("TestOverflow - Wait for doer thread death")); |
|
2996 |
TRequestStatus status; |
|
2997 |
doer.Logon(status); |
|
2998 |
User::WaitForRequest(status); |
|
2999 |
test(doer.ExitReason()==KErrNone); |
|
3000 |
CLOSE_AND_WAIT(doer); |
|
3001 |
||
3002 |
//Wait until doer has finished doing notifications |
|
3003 |
//thus the watcher should receive an overflow |
|
3004 |
// (W3) |
|
3005 |
watcher1Pkg.iBarrier.Signal(); |
|
3006 |
||
3007 |
RTimer tim; |
|
3008 |
r = tim.CreateLocal(); |
|
189 | 3009 |
test_KErrNone(r); |
0 | 3010 |
TRequestStatus timStatus; |
3011 |
||
3012 |
test.Next(_L("TestOverflow - Wait for watcher1 thread death")); |
|
3013 |
TTimeIntervalMicroSeconds32 interval = 10000000; //10 seconds |
|
3014 |
tim.After(timStatus,interval); |
|
3015 |
watcher1.Logon(status); |
|
3016 |
User::WaitForRequest(status,timStatus); |
|
3017 |
test(status != KRequestPending); |
|
3018 |
/* |
|
3019 |
* The number of notifications returned here should be 5. |
|
3020 |
* This is because : |
|
3021 |
* |
|
3022 |
* The first notification means that the buffer has lost 80 (the size of this |
|
3023 |
* particular notification). Even though the client has read it becase they've not called |
|
3024 |
* RequestNotification the server doesn't know that yet so that's why it's 5 not 6. |
|
3025 |
* |
|
3026 |
* That leaves 556 - 80. Which means only 5 notifications will fit. |
|
3027 |
*/ |
|
3028 |
TInt count = watcher1.ExitReason(); |
|
3029 |
test(count==5); |
|
3030 |
||
3031 |
CLOSE_AND_WAIT(watcher1); |
|
3032 |
watcher1Pkg.iBarrier.Close(); |
|
3033 |
doerPkg.iBarrier.Close(); |
|
3034 |
fs.Close(); |
|
3035 |
tim.Close(); |
|
3036 |
return KErrNone; |
|
3037 |
} |
|
3038 |
||
3039 |
/* |
|
3040 |
* Does stuff for TestPostOverflowL |
|
3041 |
* Synchronises such that watchers have seen 1 change. |
|
3042 |
* Then fills their buffers up to KNotificationOverflowIterationLimit. |
|
3043 |
* Then continues to request changes and akes sure that it gets 3 non-overflow notifications |
|
3044 |
* For DEF140387. |
|
3045 |
*/ |
|
3046 |
TInt TestPostOverflowDoerTF(TAny* aAny) |
|
3047 |
{ |
|
3048 |
RFs fs; |
|
3049 |
fs.Connect(); |
|
3050 |
||
3051 |
SThreadPackage& package = *(SThreadPackage*) aAny; |
|
3052 |
||
3053 |
TBuf<45> path; |
|
3054 |
path.Append((TChar)gDriveToTest); |
|
3055 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
3056 |
path.Append(package.iFileName); |
|
3057 |
||
3058 |
fs.MkDirAll(path); |
|
3059 |
||
3060 |
RFile file; |
|
3061 |
TInt r = file.Replace(fs,path,EFileWrite); |
|
3062 |
User::LeaveIfError(r); |
|
3063 |
||
3064 |
//Perform first set size. |
|
3065 |
r = file.SetSize(1); |
|
3066 |
User::LeaveIfError(r); |
|
3067 |
||
3068 |
//Wait until both watchers have received this change. |
|
3069 |
//D-W-1 |
|
3070 |
package.iBarrier.Wait(); |
|
3071 |
||
3072 |
for(TInt i = 0; i< KNotificationOverflowIterationLimit; i++) |
|
3073 |
{ |
|
3074 |
file.SetSize(i); |
|
3075 |
} |
|
3076 |
||
3077 |
file.Close(); |
|
3078 |
fs.Close(); |
|
3079 |
return KErrNone; |
|
3080 |
} |
|
3081 |
||
3082 |
TInt HandlePostOverflow(SThreadPackage& aPackage, CFsNotify* aNotify) |
|
3083 |
{ |
|
3084 |
TRequestStatus status; |
|
3085 |
TInt r = aNotify->RequestNotifications(status); |
|
189 | 3086 |
test_KErrNone(r); |
0 | 3087 |
//Signal that overflow has been found (W4) |
3088 |
aPackage.iBarrier.Signal(); |
|
3089 |
||
3090 |
User::WaitForRequest(status); |
|
3091 |
||
3092 |
const TFsNotification* notification = NULL; |
|
3093 |
TInt count = 1; |
|
3094 |
||
3095 |
notification = aNotify->NextNotification(); |
|
3096 |
test(notification != NULL); |
|
3097 |
||
3098 |
//3 set sizes will be done (Sx) |
|
3099 |
aPackage.iBarrier.Wait(); |
|
3100 |
||
3101 |
while(count < 3) |
|
3102 |
{ |
|
3103 |
TUint type = notification->NotificationType(); |
|
3104 |
if(type & TFsNotification::EOverflow) |
|
3105 |
{ |
|
3106 |
return KErrOverflow; |
|
3107 |
} |
|
3108 |
notification = aNotify->NextNotification(); |
|
3109 |
if(notification == NULL) |
|
3110 |
{ |
|
3111 |
r = aNotify->RequestNotifications(status); |
|
189 | 3112 |
test_KErrNone(r); |
0 | 3113 |
User::WaitForRequest(status); |
3114 |
notification = aNotify->NextNotification(); |
|
3115 |
} |
|
3116 |
test(notification != NULL); |
|
3117 |
count++; |
|
3118 |
} |
|
3119 |
return count; |
|
3120 |
} |
|
3121 |
||
3122 |
||
3123 |
/* |
|
3124 |
* Thread function used as part of TestOverflowL |
|
3125 |
* Counts the number of notifications and ensures it the correct number before overflow is received# |
|
3126 |
*/ |
|
3127 |
TInt TestPostOverflowWatcher1TF(TAny* aAny) |
|
3128 |
{ |
|
3129 |
CTrapCleanup* cleanup; |
|
3130 |
cleanup = CTrapCleanup::New(); |
|
3131 |
||
3132 |
RTest overflowTest(_L("TestOverflowWatcher1TF")); |
|
3133 |
overflowTest.Start(_L("TestOverflowWatcher1TF")); |
|
3134 |
||
3135 |
SThreadPackage& package = *(SThreadPackage*) aAny; |
|
3136 |
RFs fs; |
|
3137 |
fs.Connect(); |
|
3138 |
TBuf<45> path; |
|
3139 |
TBuf<20> filename; |
|
3140 |
path.Append((TChar)gDriveToTest); |
|
3141 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
3142 |
filename.Append(package.iFileName); |
|
3143 |
||
3144 |
TRequestStatus status; |
|
3145 |
CFsNotify* notify = NULL; |
|
3146 |
||
3147 |
//This notification's size is 80. |
|
3148 |
//80*7 = 560. |
|
3149 |
// -4 means we should get 6 notifications |
|
3150 |
//Except the first one will still be in the buffer |
|
3151 |
// (as we've not called RequestNotification yet) so we'll only actually get 5. |
|
3152 |
TRAPD(r, notify = CFsNotify::NewL(fs,(80*7)-4)); |
|
189 | 3153 |
test_KErrNone(r); |
0 | 3154 |
User::LeaveIfNull(notify); |
3155 |
notify->AddNotification(TFsNotification::EFileChange,path,filename); |
|
3156 |
notify->RequestNotifications(status); |
|
3157 |
||
3158 |
//Signal that we are ready for doer to start (W1) |
|
3159 |
package.iBarrier.Signal(); |
|
3160 |
||
3161 |
//We wait for the 1 notification (doer only does 1 at first) |
|
3162 |
User::WaitForRequest(status); |
|
3163 |
||
3164 |
overflowTest.Next(_L("Overflow- Get First Notification (Start framework)")); |
|
3165 |
const TFsNotification *notification = notify->NextNotification(); |
|
3166 |
||
3167 |
TFsNotification::TFsNotificationType type = notification->NotificationType(); |
|
3168 |
overflowTest.Printf(_L("Overflow - First Notification Type = %d\n"),type); |
|
3169 |
||
3170 |
//Signal the test thread (W2) |
|
3171 |
package.iBarrier.Signal(); |
|
3172 |
//Wait for Signal to continue (W3); |
|
3173 |
package.iBarrier.Wait(); |
|
3174 |
||
3175 |
notify->RequestNotifications(status); |
|
3176 |
User::WaitForRequest(status); |
|
3177 |
||
3178 |
TInt handlePostOverflow = 0; |
|
3179 |
TInt count = 0; |
|
3180 |
overflowTest.Next(_L("Overflow- Get the rest of the notifications")); |
|
3181 |
notification = notify->NextNotification(); |
|
3182 |
while(notification != NULL) |
|
3183 |
{ |
|
3184 |
||
3185 |
type = notification->NotificationType(); |
|
3186 |
overflowTest.Printf(_L("Overflow - NotificationType = %d\n"),type); |
|
3187 |
if(type & TFsNotification::EOverflow) |
|
3188 |
{ |
|
3189 |
overflowTest.Printf(_L("Overflow +- Count = %d\n"),count); |
|
3190 |
if(handlePostOverflow) |
|
3191 |
{ |
|
3192 |
count = HandlePostOverflow(package,notify); |
|
3193 |
} |
|
3194 |
delete notify; |
|
3195 |
fs.Close(); |
|
3196 |
overflowTest.End(); |
|
3197 |
overflowTest.Close(); |
|
3198 |
return count; |
|
3199 |
} |
|
3200 |
notification = notify->NextNotification(); |
|
3201 |
count++; |
|
3202 |
||
3203 |
if(count==5) |
|
3204 |
handlePostOverflow = 1; |
|
3205 |
} |
|
3206 |
overflowTest.Printf(_L("Overflow -- Count = %d\n"),count); |
|
3207 |
||
3208 |
overflowTest.End(); |
|
3209 |
overflowTest.Close(); |
|
3210 |
delete notify; |
|
3211 |
delete cleanup; |
|
3212 |
fs.Close(); |
|
3213 |
return -1; |
|
3214 |
} |
|
3215 |
||
3216 |
||
3217 |
TInt TestPostOverflowNotifications() |
|
3218 |
{ |
|
3219 |
test.Next(_L("TestPostOverflowNotifications")); |
|
3220 |
RFs fs; |
|
3221 |
TInt r = fs.Connect(); |
|
189 | 3222 |
test_KErrNone(r); |
0 | 3223 |
_LIT(KFileName,"post.over"); |
3224 |
SThreadPackage doerPkg; |
|
3225 |
doerPkg.iFileName = KFileName; |
|
3226 |
||
3227 |
SThreadPackage watcher1Pkg; |
|
3228 |
watcher1Pkg.iFileName = KFileName; |
|
3229 |
||
3230 |
User::LeaveIfError(doerPkg.iBarrier.CreateLocal(0)); |
|
3231 |
User::LeaveIfError(watcher1Pkg.iBarrier.CreateLocal(0)); |
|
3232 |
RThread watcher1; |
|
3233 |
RThread doer; |
|
3234 |
watcher1.Create(_L("TestPostOverflowWatcher1Thread"),TestPostOverflowWatcher1TF,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&watcher1Pkg); |
|
3235 |
doer.Create(_L("TestPostOverflowDoerThread"),TestPostOverflowDoerTF,KDefaultStackSize,KMinHeapSize,KMaxHeapSize,&doerPkg); |
|
3236 |
watcher1.Resume(); |
|
3237 |
||
3238 |
//Wait until Request has been requested. (W1) |
|
3239 |
watcher1Pkg.iBarrier.Wait(); |
|
3240 |
||
3241 |
doer.Resume(); |
|
3242 |
||
3243 |
//Wait till watcher has received first notification (W2) |
|
3244 |
watcher1Pkg.iBarrier.Wait(); |
|
3245 |
||
3246 |
//Signal the doer that it is free to continue |
|
3247 |
//doing the rest of the operations (D-W-1) |
|
3248 |
doerPkg.iBarrier.Signal(); |
|
3249 |
||
3250 |
test.Next(_L("TestOverflow - Wait for doer thread death")); |
|
3251 |
TRequestStatus status; |
|
3252 |
doer.Logon(status); |
|
3253 |
User::WaitForRequest(status); |
|
3254 |
test(doer.ExitReason()==KErrNone); |
|
3255 |
CLOSE_AND_WAIT(doer); |
|
3256 |
||
3257 |
//Wait until doer has finished doing notifications |
|
3258 |
//thus the watcher should receive an overflow |
|
3259 |
// (W3) |
|
3260 |
watcher1Pkg.iBarrier.Signal(); |
|
3261 |
||
3262 |
||
3263 |
//wait for the watcher to have processed the first overflow |
|
3264 |
//and to have requested notification. |
|
3265 |
//Then we will perform some actions here |
|
3266 |
// The watcher will wait on the semaphore until we are doing |
|
3267 |
// doing all the operations we want to do |
|
3268 |
// then it should process next notification |
|
3269 |
watcher1Pkg.iBarrier.Wait(); //W4 |
|
3270 |
||
3271 |
TBuf<45> path; |
|
3272 |
path.Append((TChar)gDriveToTest); |
|
3273 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
3274 |
path.Append(watcher1Pkg.iFileName); |
|
3275 |
RFile file; |
|
3276 |
r = file.Open(fs,path,EFileWrite); |
|
189 | 3277 |
test_KErrNone(r); |
0 | 3278 |
|
3279 |
r = file.SetSize(1); |
|
189 | 3280 |
test_KErrNone(r); |
0 | 3281 |
r = file.SetSize(2); |
189 | 3282 |
test_KErrNone(r); |
0 | 3283 |
r = file.SetSize(3); |
189 | 3284 |
test_KErrNone(r); |
0 | 3285 |
file.Close(); |
3286 |
||
3287 |
watcher1Pkg.iBarrier.Signal(); // Signal post operations complete (Sx) |
|
3288 |
||
3289 |
RTimer tim; |
|
3290 |
r = tim.CreateLocal(); |
|
189 | 3291 |
test_KErrNone(r); |
0 | 3292 |
TRequestStatus timStatus; |
3293 |
||
3294 |
test.Next(_L("TestOverflow - Wait for watcher1 thread death")); |
|
3295 |
TTimeIntervalMicroSeconds32 interval = 10000000; //10 seconds |
|
3296 |
tim.After(timStatus,interval); |
|
3297 |
watcher1.Logon(status); |
|
3298 |
User::WaitForRequest(status,timStatus); |
|
3299 |
test(status != KRequestPending); |
|
3300 |
/* |
|
3301 |
* The number of notifications returned here should be 3. |
|
3302 |
* This is because : |
|
3303 |
* |
|
3304 |
* The first notification means that the buffer has lost 80 (the size of this |
|
3305 |
* particular notification). Even though the client has read it becase they've not called |
|
3306 |
* RequestNotification the server doesn't know that yet so that's why it's 5 not 6. |
|
3307 |
* |
|
3308 |
* That leaves 556 - 80. Which means only 5 notifications will fit. |
|
3309 |
* |
|
3310 |
* Then overflow occurs. |
|
3311 |
* |
|
3312 |
* Then count is reset and 3 more operations are performed. |
|
3313 |
*/ |
|
3314 |
TInt count = watcher1.ExitReason(); |
|
3315 |
test(count==3); |
|
3316 |
||
3317 |
CLOSE_AND_WAIT(watcher1); |
|
3318 |
watcher1Pkg.iBarrier.Close(); |
|
3319 |
doerPkg.iBarrier.Close(); |
|
3320 |
fs.Close(); |
|
3321 |
tim.Close(); |
|
3322 |
return KErrNone; |
|
3323 |
} |
|
3324 |
||
3325 |
/* |
|
3326 |
* Call AddNotification with a file without a path nor drive |
|
3327 |
*/ |
|
3328 |
void TestNonDriveFilters() |
|
3329 |
{ |
|
3330 |
test.Next(_L("TestNonDriveFilters")); |
|
3331 |
RFs fs; |
|
3332 |
TInt r = fs.Connect(); |
|
189 | 3333 |
test_KErrNone(r); |
0 | 3334 |
|
3335 |
TDriveList drives; |
|
3336 |
r = fs.DriveList(drives); |
|
189 | 3337 |
test_KErrNone(r); |
0 | 3338 |
|
3339 |
CFsNotify* notify = NULL; |
|
3340 |
TRAP(r,notify= CFsNotify::NewL(fs,KMinNotificationBufferSize)); |
|
3341 |
||
3342 |
TBuf<20> testfile; |
|
3343 |
testfile.Append(_L("test.file")); |
|
3344 |
||
3345 |
r = notify->AddNotification((TUint)TFsNotification::ECreate,_L(""),testfile); |
|
189 | 3346 |
test_KErrNone(r); |
0 | 3347 |
|
3348 |
TRequestStatus status; |
|
3349 |
r = notify->RequestNotifications(status); |
|
189 | 3350 |
test_KErrNone(r); |
0 | 3351 |
|
3352 |
TBuf<40> path; |
|
3353 |
path.Append((TChar)gDriveToTest); |
|
3354 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
3355 |
||
3356 |
TBuf<40> fullname; |
|
3357 |
fullname.Append(path); |
|
3358 |
fullname.Append(testfile); |
|
3359 |
||
3360 |
RFile file; |
|
3361 |
r = fs.MkDirAll(path); |
|
189 | 3362 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 3363 |
r = file.Replace(fs,fullname,EFileWrite); |
189 | 3364 |
test_KErrNone(r); |
0 | 3365 |
file.Close(); |
3366 |
||
3367 |
fs.Delete(fullname); |
|
3368 |
||
3369 |
TChar testDrive = (TChar)gDriveToTest; |
|
3370 |
testDrive.UpperCase(); |
|
3371 |
||
3372 |
//Also create the file on another drive; |
|
3373 |
for(TInt i = 0; i < KMaxDrives; i++) |
|
3374 |
{ |
|
3375 |
TChar drive = drives[i]; |
|
3376 |
if(drive == testDrive) |
|
3377 |
continue; |
|
3378 |
||
3379 |
if(drive) |
|
3380 |
{ |
|
3381 |
TText16 drive16 = (TText16)(i+(TChar)'A'); |
|
3382 |
fullname.operator [](0) = drive16; |
|
3383 |
break; |
|
3384 |
} |
|
3385 |
} |
|
3386 |
||
3387 |
r = fs.MkDirAll(fullname); |
|
189 | 3388 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 3389 |
r = file.Replace(fs,fullname,EFileWrite); |
189 | 3390 |
test_KErrNone(r); |
0 | 3391 |
file.Close(); |
3392 |
||
3393 |
RTimer timer1; |
|
3394 |
r = timer1.CreateLocal(); |
|
189 | 3395 |
test_KErrNone(r); |
0 | 3396 |
TRequestStatus timeout; |
3397 |
TTimeIntervalMicroSeconds32 time = 10000000; //10 seconds |
|
3398 |
timer1.After(timeout,time); |
|
3399 |
User::WaitForRequest(timeout,status); |
|
3400 |
test(status.Int() != KRequestPending); |
|
3401 |
timer1.Cancel(); |
|
3402 |
timer1.Close(); |
|
3403 |
||
3404 |
const TFsNotification* notification = notify->NextNotification(); |
|
3405 |
test(notification != NULL); |
|
3406 |
TPtrC _path; |
|
3407 |
r = notification->Path(_path); |
|
189 | 3408 |
test_KErrNone(r); |
0 | 3409 |
TChar driveletter = _path[0]; |
3410 |
driveletter.UpperCase(); |
|
3411 |
test(driveletter == (TChar)gDriveToTest); |
|
3412 |
||
3413 |
if(notification = notify->NextNotification(), notification==NULL) |
|
3414 |
{ |
|
3415 |
TRequestStatus status2; |
|
3416 |
r = notify->RequestNotifications(status2); |
|
189 | 3417 |
test_KErrNone(r); |
0 | 3418 |
|
3419 |
RTimer timer2; |
|
3420 |
r = timer2.CreateLocal(); |
|
189 | 3421 |
test_KErrNone(r); |
0 | 3422 |
TRequestStatus timeout2; |
3423 |
TTimeIntervalMicroSeconds32 time2 = 10000000; //10 seconds |
|
3424 |
timer2.After(timeout2,time2); |
|
3425 |
User::WaitForRequest(timeout2,status2); |
|
3426 |
test(status2.Int() != KRequestPending); |
|
3427 |
timer2.Cancel(); |
|
3428 |
timer2.Close(); |
|
3429 |
||
3430 |
notification = notify->NextNotification(); |
|
3431 |
} |
|
3432 |
test(notification != NULL); |
|
3433 |
r = notification->Path(_path); |
|
189 | 3434 |
test_KErrNone(r); |
0 | 3435 |
driveletter = _path[0]; |
3436 |
driveletter.UpperCase(); |
|
3437 |
test(driveletter == (TChar)'C'); |
|
3438 |
||
3439 |
delete notify; |
|
3440 |
fs.Close(); |
|
3441 |
} |
|
3442 |
||
3443 |
// Negative testing for directory without * |
|
3444 |
// We receive no notifications for files changed under the directory |
|
3445 |
void NegativeTestDirStar() |
|
3446 |
{ |
|
3447 |
RFs fs; |
|
3448 |
TInt r = fs.Connect(); |
|
189 | 3449 |
test_KErrNone(r); |
0 | 3450 |
|
3451 |
CFsNotify* notify = NULL; |
|
3452 |
TRAP(r,notify= CFsNotify::NewL(fs,KMinNotificationBufferSize)); |
|
3453 |
||
3454 |
TBuf<40> path; |
|
3455 |
path.Append((TChar)gDriveToTest); |
|
3456 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
3457 |
r = fs.MkDirAll(path); |
|
189 | 3458 |
test_Value(r, r == KErrNone || r == KErrAlreadyExists); |
0 | 3459 |
|
3460 |
r = notify->AddNotification((TUint)TFsNotification::ECreate,path,_L("")); |
|
189 | 3461 |
test_KErrNone(r); |
0 | 3462 |
|
3463 |
TRequestStatus status; |
|
3464 |
r = notify->RequestNotifications(status); |
|
189 | 3465 |
test_KErrNone(r); |
0 | 3466 |
|
3467 |
TBuf<40> filename; |
|
3468 |
filename.Append((TChar)gDriveToTest); |
|
3469 |
filename.Append(_L(":\\F32-TST\\T_NOTIFIER\\dir.star")); |
|
3470 |
||
3471 |
RFile file; |
|
3472 |
r = file.Replace(fs,filename,EFileWrite); |
|
189 | 3473 |
test_KErrNone(r); |
0 | 3474 |
file.Close(); |
3475 |
||
3476 |
RTimer timer1; |
|
3477 |
r = timer1.CreateLocal(); |
|
189 | 3478 |
test_KErrNone(r); |
0 | 3479 |
TRequestStatus timeout; |
3480 |
TTimeIntervalMicroSeconds32 time = 2000000; //2 seconds |
|
3481 |
timer1.After(timeout,time); |
|
3482 |
User::WaitForRequest(timeout,status); |
|
3483 |
test(status.Int() == KRequestPending); |
|
3484 |
timer1.Cancel(); |
|
3485 |
timer1.Close(); |
|
3486 |
||
3487 |
const TFsNotification* notification = notify->NextNotification(); |
|
3488 |
test(notification == NULL); |
|
3489 |
||
3490 |
delete notify; |
|
3491 |
fs.Close(); |
|
3492 |
} |
|
3493 |
||
3494 |
/* |
|
3495 |
* Negative Testing |
|
3496 |
*/ |
|
3497 |
void NegativeTests() |
|
3498 |
{ |
|
3499 |
test.Next(_L("Negative Tests")); |
|
3500 |
//1 |
|
3501 |
test.Printf(_L("NegativeTests() A\n")); |
|
3502 |
RFs fs; |
|
3503 |
CFsNotify* notify = NULL; |
|
3504 |
TInt r = fs.Connect(); |
|
189 | 3505 |
test_KErrNone(r); |
0 | 3506 |
TRAP(r,notify = CFsNotify::NewL(fs,0)); |
3507 |
test(notify != NULL); |
|
3508 |
delete notify; |
|
3509 |
notify = NULL; |
|
3510 |
||
3511 |
//2 |
|
3512 |
test.Printf(_L("NegativeTests() B\n")); |
|
3513 |
TRAP(r,notify = CFsNotify::NewL(fs,-1)); |
|
3514 |
test(notify != NULL); |
|
3515 |
delete notify; |
|
3516 |
notify = NULL; |
|
3517 |
||
3518 |
test.Printf(_L("NegativeTests() C\n")); |
|
3519 |
TRAP(r,notify = CFsNotify::NewL(fs,KMaxTInt)); |
|
189 | 3520 |
test_Value(r, r == KErrArgument); |
0 | 3521 |
test(notify==NULL); |
3522 |
||
3523 |
//3 |
|
3524 |
test.Printf(_L("NegativeTests() D\n")); |
|
3525 |
TBuf<40> path; |
|
3526 |
path.Append((TChar)gDriveToTest); |
|
3527 |
path.Append(_L(":\\F32-TST\\T_NOTIFIER\\")); |
|
3528 |
TBuf<20> filename; |
|
3529 |
filename.Append(_L("file.txt")); |
|
3530 |
TRAP(r,notify = CFsNotify::NewL(fs,KMinNotificationBufferSize)); |
|
189 | 3531 |
test_KErrNone(r); |
0 | 3532 |
test(notify!=NULL); |
3533 |
r = notify->AddNotification(0,path,filename); |
|
189 | 3534 |
test_Value(r, r == KErrArgument); |
0 | 3535 |
|
3536 |
test.Printf(_L("NegativeTests() E\n")); |
|
3537 |
r = notify->AddNotification((TUint)0x8000,path,filename); //invalid value |
|
189 | 3538 |
test_Value(r, r == KErrArgument); |
0 | 3539 |
|
3540 |
test.Printf(_L("NegativeTests() F\n")); |
|
3541 |
TBuf<40> invalidPath; |
|
3542 |
invalidPath.Append(_L("1:\\*")); |
|
3543 |
r = notify->AddNotification((TUint)TFsNotification::ECreate,invalidPath,filename); |
|
189 | 3544 |
test_Value(r, r == KErrNotFound || r == KErrPathNotFound); |
0 | 3545 |
|
3546 |
//4 |
|
3547 |
test.Printf(_L("NegativeTests() G\n")); |
|
3548 |
TRequestStatus wrongStatus; |
|
3549 |
wrongStatus = KRequestPending; |
|
3550 |
r = notify->RequestNotifications(wrongStatus); |
|
189 | 3551 |
test_Value(r, r == KErrInUse); |
0 | 3552 |
|
3553 |
test.Printf(_L("NegativeTests() H\n")); |
|
3554 |
TRequestStatus status; |
|
3555 |
r = notify->RequestNotifications(status); |
|
189 | 3556 |
test_KErrNone(r); |
0 | 3557 |
r = notify->CancelNotifications(wrongStatus); |
189 | 3558 |
test_Value(r, r == KErrInUse); |
0 | 3559 |
|
3560 |
delete notify; |
|
3561 |
notify = NULL; |
|
3562 |
fs.Close(); |
|
3563 |
} |
|
3564 |
||
3565 |
||
3566 |
/* |
|
3567 |
* RPlugin devired. |
|
3568 |
* Doesn't actually do anything special. |
|
3569 |
* Can probably be deleted. |
|
3570 |
*/ |
|
3571 |
class MyRPlugin : public RPlugin |
|
3572 |
{ |
|
3573 |
public: |
|
3574 |
void DoRequest(TInt aReqNo,TRequestStatus& aStatus) const; |
|
3575 |
void DoRequest(TInt aReqNo,TRequestStatus& aStatus,TDes8& a1) const; |
|
3576 |
void DoRequest(TInt aReqNo,TRequestStatus& aStatus,TDes8& a1,TDes8& a2) const; |
|
3577 |
TInt DoControl(TInt aFunction) const; |
|
3578 |
TInt DoControl(TInt aFunction,TDes8& a1) const; |
|
3579 |
TInt DoControl(TInt aFunction,TDes8& a1,TDes8& a2) const; |
|
3580 |
void DoCancel(TUint aReqMask) const; |
|
3581 |
}; |
|
3582 |
||
3583 |
void MyRPlugin::DoRequest(TInt aReqNo,TRequestStatus& aStatus) const |
|
3584 |
{ |
|
3585 |
RPlugin::DoRequest(aReqNo,aStatus); |
|
3586 |
} |
|
3587 |
void MyRPlugin::DoRequest(TInt aReqNo,TRequestStatus& aStatus,TDes8& a1) const |
|
3588 |
{ |
|
3589 |
RPlugin::DoRequest(aReqNo,aStatus,a1); |
|
3590 |
} |
|
3591 |
void MyRPlugin::DoRequest(TInt aReqNo,TRequestStatus& aStatus,TDes8& a1,TDes8& a2) const |
|
3592 |
{ |
|
3593 |
RPlugin::DoRequest(aReqNo,aStatus,a1,a2); |
|
3594 |
} |
|
3595 |
TInt MyRPlugin::DoControl(TInt aFunction) const |
|
3596 |
{ |
|
3597 |
return RPlugin::DoControl(aFunction); |
|
3598 |
} |
|
3599 |
TInt MyRPlugin::DoControl(TInt aFunction,TDes8& a1) const |
|
3600 |
{ |
|
3601 |
return RPlugin::DoControl(aFunction,a1); |
|
3602 |
} |
|
3603 |
TInt MyRPlugin::DoControl(TInt aFunction,TDes8& a1,TDes8& a2) const |
|
3604 |
{ |
|
3605 |
return RPlugin::DoControl(aFunction,a1,a2); |
|
3606 |
} |
|
3607 |
void MyRPlugin::DoCancel(TUint aReqMask) const |
|
3608 |
{ |
|
3609 |
RPlugin::DoCancel(aReqMask); |
|
3610 |
} |
|
3611 |
||
3612 |
/* |
|
3613 |
* This tests that when file server plugins perform operations that |
|
3614 |
* the framework doesn't notify about them |
|
3615 |
*/ |
|
3616 |
TInt TestNotificationsWithFServPlugins() |
|
3617 |
{ |
|
3618 |
TInt r = TheFs.AddPlugin(KNotifyPluginFileName); |
|
189 | 3619 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 3620 |
r = TheFs.MountPlugin(KNotifyPluginName,(TUint)gDriveToTest.GetUpperCase() - 65); |
3621 |
if (r == KErrNotSupported) |
|
3622 |
{ |
|
3623 |
test.Printf(_L("Plugins are not supported on pagable drives.\nSkipping test.\n")); |
|
3624 |
safe_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3625 |
} |
|
3626 |
||
3627 |
MyRPlugin rplugin; |
|
3628 |
TPckgBuf<TChar> drivePckg(gDriveToTest); |
|
3629 |
||
3630 |
test.Next(_L("Open RPlugin connection for NotifyPlugin")); |
|
3631 |
r = rplugin.Open(TheFs,KNotifyPos); |
|
3632 |
safe_test(test,r,__LINE__,(TText*)Expand("t_notify_plugin.cpp")); |
|
3633 |
||
3634 |
test.Next(_L("Send drive letter to test down to plugin")); |
|
3635 |
r = rplugin.DoControl(KPluginSetDrive,drivePckg); |
|
3636 |
safe_test(test,r,__LINE__,(TText*)Expand("t_notify_plugin.cpp")); |
|
3637 |
rplugin.Close(); |
|
3638 |
||
3639 |
r = SimpleCreateTestL(); |
|
3640 |
safe_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3641 |
||
3642 |
DismountPlugin(); |
|
3643 |
return KErrNone; |
|
3644 |
} |
|
3645 |
||
300 | 3646 |
_LIT(KPhantomExtendedReplace,"?:\\PhantomExtended_Replaced.txt"); |
3647 |
_LIT(KPhantomExtendedRenamed,"?:\\PhantomExtended_Renamed.txt"); |
|
3648 |
_LIT(KPhantomExtendedRenameMe,"?:\\PhantomExtended_RenameMe.txt"); |
|
3649 |
||
3650 |
TInt DoTestExternalNotificationL() |
|
3651 |
{ |
|
3652 |
TRequestStatus statusN, statusT; |
|
3653 |
RTimer timer1; |
|
3654 |
TTimeIntervalMicroSeconds32 time = 10000000; |
|
3655 |
||
3656 |
test.Printf(_L("DoTestExternalNotification")); |
|
3657 |
CFsNotify* notify = CFsNotify::NewL(TheFs,1024); |
|
3658 |
TInt r = notify->AddNotification(TFsNotification::ECreate, _L("?:\\"),_L("PhantomExtended_Replaced.txt")); |
|
3659 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3660 |
r = notify->RequestNotifications(statusN); |
|
3661 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3662 |
||
3663 |
RFile file; |
|
3664 |
r = file.Replace(TheFs,_L("\\Extended_Replaced.txt"),EFileWrite); |
|
3665 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3666 |
file.Close(); |
|
3667 |
||
3668 |
r = timer1.CreateLocal(); |
|
3669 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3670 |
timer1.After(statusT,time); |
|
3671 |
User::WaitForRequest(statusN,statusT); |
|
3672 |
test_Compare(statusN.Int(),!=,KRequestPending) |
|
3673 |
timer1.Cancel(); |
|
3674 |
timer1.Close(); |
|
3675 |
User::WaitForRequest(statusT); |
|
3676 |
||
3677 |
const TFsNotification* notification = notify->NextNotification(); |
|
3678 |
if(!notification) |
|
3679 |
safe_external_test(test,KErrUnderflow,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3680 |
||
3681 |
//Check Path |
|
3682 |
TPtrC path; |
|
3683 |
r = notification->Path(path); |
|
3684 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3685 |
||
3686 |
if(path.Match(KPhantomExtendedReplace)==KErrNotFound) |
|
3687 |
{ |
|
3688 |
safe_external_test(test,KErrNotFound,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3689 |
} |
|
3690 |
||
3691 |
//Check NewName |
|
3692 |
TPtrC newName; |
|
3693 |
r = notification->NewName(newName); |
|
3694 |
safe_external_test(test,(r==KErrNotSupported) ? KErrNone : r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3695 |
||
3696 |
notify->CancelNotifications(statusN); |
|
3697 |
delete notify; |
|
3698 |
||
3699 |
//************************************************************* |
|
3700 |
// Rename: |
|
3701 |
//************************************************************* |
|
3702 |
||
3703 |
notify = CFsNotify::NewL(TheFs,1024); |
|
3704 |
r = notify->AddNotification(TFsNotification::ERename, _L("?:\\"),_L("PhantomExtended_Renamed.txt")); |
|
3705 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3706 |
r = notify->RequestNotifications(statusN); |
|
3707 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3708 |
||
3709 |
r = file.Replace(TheFs,_L("\\Extended_RenameMe.txt"),EFileWrite); |
|
3710 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3711 |
file.Close(); |
|
3712 |
||
3713 |
r = timer1.CreateLocal(); |
|
3714 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3715 |
timer1.After(statusT,time); |
|
3716 |
User::WaitForRequest(statusN,statusT); |
|
3717 |
test_Compare(statusN.Int(),!=,KRequestPending) |
|
3718 |
timer1.Cancel(); |
|
3719 |
timer1.Close(); |
|
3720 |
User::WaitForRequest(statusT); |
|
3721 |
||
3722 |
notification = notify->NextNotification(); |
|
3723 |
if(!notification) |
|
3724 |
safe_external_test(test,KErrUnderflow,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3725 |
||
3726 |
r = notification->Path(path); |
|
3727 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3728 |
||
3729 |
if(path.Match(KPhantomExtendedRenameMe)==KErrNotFound) |
|
3730 |
{ |
|
3731 |
safe_external_test(test,KErrNotFound,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3732 |
} |
|
3733 |
||
3734 |
//Check NewName |
|
3735 |
r = notification->NewName(newName); |
|
3736 |
if(newName.Match(KPhantomExtendedRenamed)==KErrNotFound) |
|
3737 |
{ |
|
3738 |
safe_external_test(test,KErrNotFound,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3739 |
} |
|
3740 |
||
3741 |
notify->CancelNotifications(statusN); |
|
3742 |
delete notify; |
|
3743 |
||
3744 |
return KErrNone; |
|
3745 |
} |
|
3746 |
||
3747 |
void TestExternalNotifications() |
|
3748 |
{ |
|
3749 |
test.Printf(_L("Test External Notifications (Load test file system)")); |
|
3750 |
||
3751 |
if(F32_Test_Utils::Is_SimulatedSystemDrive(TheFs,globalDriveNum)) |
|
3752 |
{ |
|
3753 |
test.Printf(_L("Not testing External Notifications on SimulatedSystemDrive")); |
|
3754 |
return; |
|
3755 |
} |
|
3756 |
||
3757 |
TInt r = TheFs.FileSystemName(filesystem,globalDriveNum); |
|
3758 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3759 |
r = TheFs.DismountFileSystem(filesystem,globalDriveNum); |
|
3760 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3761 |
r = TheFs.AddFileSystem(KTestNotifyFileSystemExeName); |
|
3762 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3763 |
r = TheFs.MountFileSystem(KNotifyTestFileSystem,globalDriveNum); |
|
3764 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3765 |
||
3766 |
TRAP(r,DoTestExternalNotificationL()); |
|
3767 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3768 |
||
3769 |
//Replace old FS. |
|
3770 |
r = TheFs.DismountFileSystem(KNotifyTestFileSystem,globalDriveNum); |
|
3771 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3772 |
r = TheFs.MountFileSystem(filesystem,globalDriveNum); |
|
3773 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3774 |
r = TheFs.RemoveFileSystem(KNotifyTestFileSystem); |
|
3775 |
safe_external_test(test,r,__LINE__,(TText*)Expand("t_notifier.cpp")); |
|
3776 |
} |
|
3777 |
||
0 | 3778 |
/* |
3779 |
* This test is testing the use cases |
|
3780 |
* and for negative testing of SYMBIAN_F32_ENHANCED_CHANGE_NOTIFICATION |
|
3781 |
* |
|
3782 |
* Performance tests can be found in test t_notify_perf |
|
3783 |
*/ |
|
3784 |
void CallTestsL() |
|
3785 |
{ |
|
3786 |
CTrapCleanup* cleanup; |
|
3787 |
cleanup = CTrapCleanup::New(); |
|
3788 |
||
3789 |
globalDriveNum = gDriveToTest - (TChar)'A'; |
|
3790 |
||
3791 |
PrintLine(); |
|
3792 |
test.Start(_L("T_NOTIFIER Test Start")); |
|
3793 |
TInt r = KErrNone; |
|
3794 |
||
3795 |
//========================================================================================= |
|
3796 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2443 |
|
3797 |
//! @SYMTestType CIT |
|
3798 |
//! @SYMREQ PREQ1847 |
|
3799 |
//! @SYMTestCaseDesc Simple Tests/User Heap Tests |
|
3800 |
//! @SYMTestStatus Implemented |
|
3801 |
//========================================================================================= |
|
3802 |
// |
|
3803 |
// 1. Create and delete many CFsNotify objects |
|
3804 |
// |
|
3805 |
PrintLine(); |
|
3806 |
test.Next(_L("CFsNotify Creation and Delete Tests")); |
|
3807 |
//Creates and Deletes 1 CFsNotify |
|
3808 |
__UHEAP_MARK; |
|
3809 |
r = TestNewDeleteCFsNotify(1); |
|
3810 |
__UHEAP_MARKEND; |
|
189 | 3811 |
test_KErrNone(r); |
0 | 3812 |
//Creates and Deletes 50 CFsNotifys |
3813 |
__UHEAP_MARK; |
|
3814 |
r = TestNewDeleteCFsNotify(50); |
|
3815 |
__UHEAP_MARKEND; |
|
189 | 3816 |
test_KErrNone(r); |
0 | 3817 |
test.Printf(_L("------- End of User Heap Tests ---------------------------------------\n")); |
3818 |
// |
|
3819 |
// 2. Add notification for creating a file |
|
3820 |
// Create that file |
|
3821 |
// |
|
3822 |
PrintLine(); |
|
3823 |
__UHEAP_MARK; |
|
3824 |
r = SimpleCreateTestL(); |
|
3825 |
__UHEAP_MARKEND; |
|
189 | 3826 |
test_KErrNone(r); |
0 | 3827 |
test.Printf(_L("------- End of CFsNotify Creation and Delete Tests -------------------\n")); |
3828 |
// |
|
3829 |
// 3. Add notification at the root of a drive |
|
3830 |
// Create a file in that drive |
|
3831 |
// |
|
3832 |
PrintLine(); |
|
3833 |
TestRootDriveNotifications(); |
|
3834 |
test.Printf(_L("------- End of RootDriveNotifications Test ---------------------------\n")); |
|
3835 |
// |
|
3836 |
// 4. Add notification for a filename without a drive |
|
3837 |
// Create that file in the current drive |
|
3838 |
// Create that file in another drive |
|
3839 |
// |
|
3840 |
PrintLine(); |
|
3841 |
TestNonDriveFilters(); |
|
3842 |
test.Printf(_L("------- End of TestNonDriveFilters Test ------------------------------\n")); |
|
3843 |
// |
|
3844 |
// 5. Add notifications for 2 file creations |
|
3845 |
// Create 2 clients |
|
3846 |
// The clients create a file each |
|
3847 |
// |
|
3848 |
PrintLine(); |
|
3849 |
__UHEAP_MARK; |
|
3850 |
r = TestTwoDoersL(); |
|
3851 |
__UHEAP_MARKEND; |
|
189 | 3852 |
test_KErrNone(r); |
0 | 3853 |
test.Printf(_L("------- End of TwoDoers Test -----------------------------------------\n")); |
3854 |
// |
|
3855 |
// 6. Create 2 file server sessions |
|
3856 |
// Add a notification on each session for the same specific file creation |
|
3857 |
// Create that file |
|
3858 |
// |
|
3859 |
PrintLine(); |
|
3860 |
__UHEAP_MARK; |
|
3861 |
r = TestTwoWatchersL(); |
|
3862 |
__UHEAP_MARKEND; |
|
189 | 3863 |
test_KErrNone(r); |
0 | 3864 |
test.Printf(_L("------- End of TwoWatchers Test --------------------------------------\n")); |
3865 |
// |
|
3866 |
// 7. Create 2 file server sessions and 2 clients |
|
3867 |
// Add a notification on each session for different file creations |
|
3868 |
// Clients create a file each |
|
3869 |
// |
|
3870 |
PrintLine(); |
|
3871 |
__UHEAP_MARK; |
|
3872 |
r = TestTwoWatchersTwoDoersL(); |
|
3873 |
__UHEAP_MARKEND; |
|
189 | 3874 |
test_KErrNone(r); |
0 | 3875 |
test.Printf(_L("------- End of TwoWatchersTwoDoers Test ------------------------------\n")); |
3876 |
// |
|
3877 |
// 8. Add notification for a specific file creation |
|
3878 |
// Cancel the notification request |
|
3879 |
// Create that file |
|
3880 |
// |
|
3881 |
PrintLine(); |
|
3882 |
__UHEAP_MARK; |
|
3883 |
r = TestCancelNotificationL(); |
|
3884 |
__UHEAP_MARKEND; |
|
189 | 3885 |
test_KErrNone(r); |
0 | 3886 |
test.Printf(_L("------- End of CancelNotification Test -------------------------------\n")); |
3887 |
// |
|
3888 |
// 9. Create 2 file server sessions |
|
3889 |
// Add a notification on each session for the same specific file creation |
|
3890 |
// Delete the first notification |
|
3891 |
// Create that file |
|
3892 |
// |
|
3893 |
PrintLine(); |
|
3894 |
test.Next(_L("TestClientRemoval")); |
|
3895 |
__UHEAP_MARK; |
|
3896 |
r = TestClientRemovalL(); |
|
3897 |
__UHEAP_MARKEND; |
|
189 | 3898 |
test_KErrNone(r); |
0 | 3899 |
test.Printf(_L("------- End of TestClientRemoval Test --------------------------------\n")); |
3900 |
// |
|
3901 |
// 10. Create a CFsNotify object |
|
3902 |
// Close the session before closing the subsession |
|
3903 |
// Add notification and request notifications |
|
3904 |
// |
|
3905 |
PrintLine(); |
|
3906 |
__UHEAP_MARK; |
|
3907 |
// Close session after creating the object |
|
3908 |
TestSessionClose(1); |
|
3909 |
__UHEAP_MARKEND; |
|
3910 |
__UHEAP_MARK; |
|
3911 |
// Close session after adding the notification |
|
3912 |
TestSessionClose(2); |
|
3913 |
__UHEAP_MARKEND; |
|
3914 |
test.Printf(_L("------- End of TestSessionClose Test ---------------------------------\n")); |
|
3915 |
||
3916 |
||
3917 |
//========================================================================================= |
|
3918 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2444 |
|
3919 |
//! @SYMTestType UT |
|
3920 |
//! @SYMREQ PREQ1847 |
|
3921 |
//! @SYMTestCaseDesc File/Directory Create and Replace – Single File Server Session |
|
3922 |
//! @SYMTestStatus Implemented |
|
3923 |
//! |
|
3924 |
//! TFsNotificationType ECreate |
|
3925 |
//========================================================================================= |
|
3926 |
// |
|
3927 |
// RFile::Create |
|
3928 |
// 1. Add notification for a specific file creation |
|
3929 |
// Create that file |
|
3930 |
// |
|
3931 |
PrintLine(); |
|
3932 |
test.Next(_L("EFileCreate Tests")); |
|
3933 |
_LIT(KFilename3,"file.create"); |
|
3934 |
r = TestMultipleNotificationsL(_L(""),KFilename3,5,5,t_notification::EFileCreate,TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 3935 |
test_KErrNone(r); |
0 | 3936 |
test.Printf(_L("------- End of EFileCreate Tests -------------------------------------\n")); |
3937 |
// |
|
3938 |
// RFs::MkDir |
|
3939 |
// 2. Add notification for a specific directory creation |
|
3940 |
// Create that directory |
|
3941 |
// |
|
3942 |
PrintLine(); |
|
3943 |
test.Next(_L("EFsMkDir Test")); |
|
3944 |
_LIT(KDirName1,"dirCreate\\"); |
|
3945 |
r = TestMultipleNotificationsL(KDirName1,_L(""),1,1,t_notification::EFsMkDir,TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 3946 |
test_KErrNone(r); |
0 | 3947 |
test.Printf(_L("------- End of EFsMkDir Test -----------------------------------------\n")); |
3948 |
// |
|
3949 |
// RFile::Replace |
|
3950 |
// 3. Add notification for a specific file creation |
|
3951 |
// Replace that file |
|
3952 |
// |
|
3953 |
PrintLine(); |
|
3954 |
test.Next(_L("EFileReplace Test")); |
|
3955 |
r = TestMultipleNotificationsL(_L(""),KFilename3,1,1,t_notification::EFileReplace,TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 3956 |
test_KErrNone(r); |
0 | 3957 |
test.Printf(_L("------- End of EFileReplace Test -------------------------------------\n")); |
3958 |
// |
|
3959 |
// 4. Add notification for a specific file creation |
|
3960 |
// Remove that notification |
|
3961 |
// Create that file |
|
3962 |
// |
|
3963 |
PrintLine(); |
|
3964 |
__UHEAP_MARK; |
|
3965 |
r = TestAddRemoveNotificationL(); |
|
3966 |
__UHEAP_MARKEND; |
|
189 | 3967 |
test_KErrNone(r); |
0 | 3968 |
test.Printf(_L("------- End of Add and Remove Notification Test ----------------------\n")); |
3969 |
// |
|
3970 |
// Wildcard Create Tests |
|
3971 |
// 5. Add notification for file creation using wildcard name |
|
3972 |
// Add notification for file/directory wildcard including subdirectories |
|
3973 |
// Create number of files and directories that match each notification |
|
3974 |
// |
|
3975 |
PrintLine(); |
|
3976 |
test.Next(_L("Wildcard Create Tests")); |
|
3977 |
// |
|
3978 |
// Wildcard Name |
|
3979 |
_LIT(KWildcardName1,"*"); |
|
3980 |
r = TestMultipleNotificationsL(_L(""),KWildcardName1,1,1,t_notification::EFileCreate,TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 3981 |
test_KErrNone(r); |
0 | 3982 |
r = TestMultipleNotificationsL(KWildcardName1,KWildcardName1,1,1,t_notification::EFileCreate_subs,TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
189 | 3983 |
test_KErrNone(r); |
0 | 3984 |
r = TestMultipleNotificationsL(KWildcardName1,KWildcardName1,1,1,t_notification::EFileCreate_subs_nowatch,TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)ETrue,__LINE__); |
189 | 3985 |
test_KErrNone(r); |
0 | 3986 |
// |
3987 |
// Wildcard including Subdirectories |
|
3988 |
_LIT(KWildcardName2,"*\\"); |
|
3989 |
r = TestMultipleNotificationsL(KWildcardName2,KWildcardName1,1,1,t_notification::EFileCreate,TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)ETrue,__LINE__); |
|
189 | 3990 |
test_KErrNone(r); |
0 | 3991 |
r = TestMultipleNotificationsL(KWildcardName2,KWildcardName1,1,1,t_notification::EFileCreate_subs_nowatch,TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
189 | 3992 |
test_KErrNone(r); |
0 | 3993 |
_LIT(KDirName2,"SubDir\\"); |
3994 |
_LIT(KWildcardName3,"?"); |
|
3995 |
r = TestMultipleNotificationsL(KDirName2,KWildcardName3,1,1,t_notification::EFileCreate_subs_nowatch,TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 3996 |
test_KErrNone(r); |
0 | 3997 |
// |
3998 |
// Wildcard Type |
|
3999 |
_LIT(KWildcardName4,"*.*"); |
|
4000 |
r = TestMultipleNotificationsL(_L(""),KWildcardName4,1,1,t_notification::EFileCreate_txt_nowatch,TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4001 |
test_KErrNone(r); |
0 | 4002 |
r = TestMultipleNotificationsL(_L(""),KWildcardName4,1,1,t_notification::EFileCreate_subs_nowatch,TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)ETrue,__LINE__); |
189 | 4003 |
test_KErrNone(r); |
0 | 4004 |
// |
4005 |
// 6. Add notification for file creation for a specific type |
|
4006 |
// Create file with that type |
|
4007 |
// Create file with different type |
|
4008 |
// |
|
4009 |
_LIT(KWildcardName5,"*.txt"); |
|
4010 |
r = TestMultipleNotificationsL(_L(""),KWildcardName5,1,1,t_notification::EFileCreate_txt,TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4011 |
test_KErrNone(r); |
0 | 4012 |
test.Printf(_L("------- End of Wildcard Create Tests ---------------------------------\n")); |
4013 |
||
4014 |
||
4015 |
//============================================================================= |
|
4016 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2445 |
|
4017 |
//! @SYMTestType UT |
|
4018 |
//! @SYMREQ PREQ1847 |
|
4019 |
//! @SYMTestCaseDesc File Attribute Change – Single File Server Session |
|
4020 |
//! @SYMTestStatus Implemented |
|
4021 |
// |
|
4022 |
// TFsNotificationType EAttribute |
|
4023 |
//============================================================================= |
|
4024 |
// |
|
4025 |
// RFile::SetAtt, RFile::Set and RFs::SetEntry |
|
4026 |
// 1. Add notification for a specific file attribute change |
|
4027 |
// Change the attribute for that file |
|
4028 |
// |
|
4029 |
PrintLine(); |
|
4030 |
test.Next(_L("Attribute Tests")); |
|
4031 |
_LIT(KFilename4,"file.setatts"); |
|
4032 |
r = TestMultipleNotificationsL(_L(""),KFilename4,1,1,t_notification::EFileSetAtt,TFsNotification::EAttribute,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4033 |
test_KErrNone(r); |
0 | 4034 |
r = TestMultipleNotificationsL(_L(""),KFilename4,1,1,t_notification::EFileSet,TFsNotification::EAttribute,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
189 | 4035 |
test_KErrNone(r); |
0 | 4036 |
r = TestMultipleNotificationsL(_L(""),KFilename4,1,1,t_notification::EFsSetEntry,TFsNotification::EAttribute,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
189 | 4037 |
test_KErrNone(r); |
0 | 4038 |
// |
4039 |
// Wildcard Attribute Test including subdirectories |
|
4040 |
// 2. Add notification for file attribute change using wildcard name |
|
4041 |
// Create number of files that match the notification |
|
4042 |
// Change attributes of some files |
|
4043 |
// |
|
4044 |
r = TestMultipleNotificationsL(KWildcardName2,_L("*"),3,3,t_notification::EFileSetAtt_subs,TFsNotification::EAttribute,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4045 |
test_KErrNone(r); |
0 | 4046 |
test.Printf(_L("------- End of Attribute Tests ---------------------------------------\n")); |
4047 |
||
4048 |
||
4049 |
//============================================================================= |
|
4050 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2446 |
|
4051 |
//! @SYMTestType UT |
|
4052 |
//! @SYMREQ PREQ1847 |
|
4053 |
//! @SYMTestCaseDesc File/Directory Rename – Single File Server Session |
|
4054 |
//! @SYMTestStatus Implemented |
|
4055 |
// |
|
4056 |
// TFsNotificationType ERename |
|
4057 |
//============================================================================= |
|
4058 |
// |
|
4059 |
// RFs::Replace, RFs::Rename and RFile::Rename |
|
4060 |
// 1. Add notification for a specific file rename change |
|
4061 |
// Rename that file |
|
4062 |
// |
|
4063 |
PrintLine(); |
|
4064 |
test.Next(_L("Rename Tests")); |
|
4065 |
_LIT(KFilename5,"file.rename"); |
|
4066 |
r = TestMultipleNotificationsL(_L(""),KFilename5,1,1,t_notification::EFsReplace,TFsNotification::ERename,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4067 |
test_KErrNone(r); |
0 | 4068 |
r = TestMultipleNotificationsL(_L(""),KFilename5,1,1,t_notification::EFsRename,TFsNotification::ERename,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
189 | 4069 |
test_KErrNone(r); |
0 | 4070 |
r = TestMultipleNotificationsL(_L(""),KFilename5,1,1,t_notification::EFileRename,TFsNotification::ERename,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
189 | 4071 |
test_KErrNone(r); |
0 | 4072 |
// |
4073 |
// 2. Add notification for a specific directory rename |
|
4074 |
// Rename that directory |
|
4075 |
// |
|
4076 |
_LIT(KDirName3,"dirRename\\"); |
|
4077 |
r = TestMultipleNotificationsL(KDirName3,_L(""),1,1,t_notification::EFsRename_dir,TFsNotification::ERename,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4078 |
test_KErrNone(r); |
0 | 4079 |
// |
4080 |
// 3. Add notification for file rename using wildcard name |
|
4081 |
// Create file that match the notification |
|
4082 |
// Repeatedly rename the file |
|
4083 |
// |
|
4084 |
r = TestMultipleNotificationsL(_L(""),KWildcardName1,3,3,t_notification::EFileRename_wild,TFsNotification::ERename,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4085 |
test_KErrNone(r); |
0 | 4086 |
test.Printf(_L("------- End of Rename Tests ------------------------------------------\n")); |
4087 |
||
4088 |
||
4089 |
//============================================================================= |
|
4090 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2447 |
|
4091 |
//! @SYMTestType UT |
|
4092 |
//! @SYMREQ PREQ1847 |
|
4093 |
//! @SYMTestCaseDesc File/Directory Delete – Single File Server Session |
|
4094 |
//! @SYMTestStatus Implemented |
|
4095 |
// |
|
4096 |
// TFsNotificationType EDelete |
|
4097 |
//============================================================================= |
|
4098 |
// |
|
4099 |
// RFs::Delete |
|
4100 |
// 1. Add notification for a specific file delete |
|
4101 |
// Delete that file |
|
4102 |
// |
|
4103 |
PrintLine(); |
|
4104 |
test.Next(_L("EFsDelete Test")); |
|
4105 |
_LIT(KFilename6,"file.delete"); |
|
4106 |
r = TestMultipleNotificationsL(_L(""),KFilename6,1,1,t_notification::EFsDelete,TFsNotification::EDelete,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4107 |
test_KErrNone(r); |
0 | 4108 |
// |
4109 |
// RFs::RmDir |
|
4110 |
// 2. Add notification for a specific directory delete |
|
4111 |
// Delete that directory |
|
4112 |
// |
|
4113 |
PrintLine(); |
|
4114 |
test.Next(_L("EFsRmDir Tests")); |
|
4115 |
_LIT(KDirName4,"dirRemove\\"); |
|
4116 |
r = TestMultipleNotificationsL(KDirName4,_L(""),1,1,t_notification::EFsRmDir,TFsNotification::EDelete,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4117 |
test_KErrNone(r); |
0 | 4118 |
// |
4119 |
// This test should not receive any notifications because a non-empty directory cannot be removed |
|
4120 |
// 3. Add notification for specific directory delete |
|
4121 |
// Create files inside that directory |
|
4122 |
// Delete the directory |
|
4123 |
// |
|
4124 |
_LIT(KDirName5,"dirRmNonEmp\\"); |
|
4125 |
r = TestMultipleNotificationsL(KDirName5,_L(""),1,1,t_notification::EFsRmDir_nonEmpty,TFsNotification::EDelete,KMinNotificationBufferSize,(TBool)ETrue,__LINE__); |
|
189 | 4126 |
test_KErrNone(r); |
0 | 4127 |
// |
4128 |
// Wildcard Name ("*") |
|
4129 |
// 4. Add notification for directory delete using wildcard name |
|
4130 |
// Create directory that match the notification |
|
4131 |
// Delete that directory |
|
4132 |
// |
|
4133 |
r = TestMultipleNotificationsL(KWildcardName1,_L(""),1,1,t_notification::EFsRmDir_wild,TFsNotification::EDelete,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4134 |
test_KErrNone(r); |
0 | 4135 |
// |
4136 |
// Wildcard Type ("*.txt") |
|
4137 |
// Creates files with different types and should only receive notifications from "*.txt" file deletions |
|
4138 |
// 5. Add notification for file deletes using wildcard type |
|
4139 |
// Create number of files that match the notification |
|
4140 |
// Delete those files |
|
4141 |
// |
|
4142 |
r = TestMultipleNotificationsL(_L(""),KWildcardName4,3,3,t_notification::EFsDelete,TFsNotification::EDelete,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4143 |
test_KErrNone(r); |
0 | 4144 |
test.Printf(_L("------- End of Delete Tests ------------------------------------------\n")); |
4145 |
||
4146 |
||
4147 |
//====================================================================== |
|
4148 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2448 |
|
4149 |
//! @SYMTestType UT |
|
4150 |
//! @SYMREQ PREQ1847 |
|
4151 |
//! @SYMTestCaseDesc File Change – Single File Server Session |
|
4152 |
//! @SYMTestStatus Implemented |
|
4153 |
// |
|
4154 |
// TFsNotificationType EFileChange |
|
4155 |
//====================================================================== |
|
4156 |
// |
|
4157 |
// File Write |
|
4158 |
// If caching is enabled, notifications are received only when the file cache is flushed |
|
4159 |
// We flush everytime we do a write to ensure the tests work regardless of cache |
|
4160 |
// |
|
4161 |
// 1. Add notification for a specific file change |
|
4162 |
// Create the file |
|
4163 |
// Write to that file |
|
4164 |
// |
|
4165 |
PrintLine(); |
|
4166 |
test.Next(_L("EFileWrite Tests")); |
|
4167 |
_LIT(KFilename7,"file.write"); |
|
4168 |
__UHEAP_MARK; |
|
4169 |
r = TestMultipleNotificationsL(_L(""),KFilename7,7,7,t_notification::EFileWrite,TFsNotification::EFileChange,3*KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
4170 |
__UHEAP_MARKEND; |
|
189 | 4171 |
test_KErrNone(r); |
0 | 4172 |
// |
4173 |
// 2. Add notification for a specific file change |
|
4174 |
// Write to the specified file a number of times without changing its size |
|
4175 |
// |
|
4176 |
// Four letters are written to a file, then the first letter in the file is replaced aIterations times |
|
4177 |
// aMaxNotifications = 1 + aIterations |
|
4178 |
// |
|
4179 |
r = TestMultipleNotificationsL(_L(""),KFilename7,3,4,t_notification::EFileWrite_samesize,TFsNotification::EFileChange,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4180 |
test_KErrNone(r); |
0 | 4181 |
test.Printf(_L("------- End of EFileWrite Tests --------------------------------------\n")); |
4182 |
// |
|
4183 |
// 3. Add notification for a specific file change |
|
4184 |
// Write to that file asynchronously |
|
4185 |
// |
|
4186 |
PrintLine(); |
|
4187 |
test.Next(_L("EFileWrite_async Tests")); |
|
4188 |
_LIT(KFilename8,"async.write"); |
|
4189 |
__UHEAP_MARK; |
|
4190 |
r = TestMultipleNotificationsL(_L(""),KFilename8,4,4,t_notification::EFileWrite_async,TFsNotification::EFileChange,2*KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
4191 |
__UHEAP_MARKEND; |
|
189 | 4192 |
test_KErrNone(r); |
0 | 4193 |
test.Printf(_L("------- End of EFileWrite_async Tests --------------------------------\n")); |
4194 |
// |
|
4195 |
// File Set Size |
|
4196 |
// 4. Add notification for a specific file change |
|
4197 |
// Both increase and decrease the file sizes a number of times |
|
4198 |
// |
|
4199 |
// The file size is increased aIterations times, and decreased (aIterations - 1) times |
|
4200 |
// aMaxNotifications = 2*aIterations - 1 |
|
4201 |
// |
|
4202 |
PrintLine(); |
|
4203 |
test.Next(_L("EFileSetSize Tests")); |
|
4204 |
_LIT(KFilename9,"file.setsize"); |
|
4205 |
r = TestMultipleNotificationsL(_L(""),KFilename9,5,9,t_notification::EFileSetSize,TFsNotification::EFileChange,3*KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4206 |
test_KErrNone(r); |
0 | 4207 |
test.Printf(_L("------- End of EFileSetSize Tests ------------------------------------\n")); |
4208 |
||
4209 |
||
4210 |
// |
|
4211 |
PrintLine(); |
|
4212 |
test.Next(_L("CFileMan Tests")); |
|
4213 |
_LIT(KFilenameCFMan,"cf1le.man"); |
|
4214 |
TUint notificationTypes = (TUint)TFsNotification::ECreate|TFsNotification::EFileChange|TFsNotification::EAttribute|TFsNotification::EDelete|TFsNotification::ERename; |
|
4215 |
r = TestMultipleNotificationsL(_L(""),KFilenameCFMan,1,5,t_notification::ECFileManMove,notificationTypes,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4216 |
test_KErrNone(r); |
0 | 4217 |
test.Printf(_L("------- End of CFileMan Tests -------------------------------------\n")); |
4218 |
||
4219 |
||
4220 |
//======================================================================================== |
|
4221 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2449 |
|
4222 |
//! @SYMTestType UT |
|
4223 |
//! @SYMREQ PREQ1847 |
|
4224 |
//! @SYMTestCaseDesc File System Mounted/Dismounted, Media Card Removal/Insertion, |
|
4225 |
// RawDisk Write – Single File Server Session |
|
4226 |
//! @SYMTestStatus Implemented |
|
4227 |
// |
|
4228 |
// TFsNotificationType EMediaChange |
|
4229 |
//======================================================================================== |
|
4230 |
// |
|
4231 |
// RFs::DismountFileSystem |
|
4232 |
// 1. Add notification for media change |
|
4233 |
// Dismount the file system |
|
4234 |
// |
|
4235 |
PrintLine(); |
|
4236 |
test.Next(_L("Mount Tests")); |
|
4237 |
TFullName filesystemName; |
|
4238 |
r = TheFs.FileSystemName(filesystemName,globalDriveNum); |
|
189 | 4239 |
test_KErrNone(r); |
0 | 4240 |
r = TestMultipleNotificationsL(filesystemName,1,1,t_notification::EDismount,TFsNotification::EMediaChange,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
189 | 4241 |
test_KErrNone(r); |
0 | 4242 |
// |
4243 |
// RFs::MountFileSystem |
|
4244 |
// 2. Add notification for media change |
|
4245 |
// Mount the file system |
|
4246 |
// |
|
4247 |
r = TestMultipleNotificationsL(filesystemName,1,1,t_notification::EMount,TFsNotification::EMediaChange,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4248 |
test_KErrNone(r); |
0 | 4249 |
// |
4250 |
// Repeatedly mount and dismount the file system |
|
4251 |
// 3. Add notification for media change |
|
4252 |
// Repeatedly dismount and mount the file system |
|
4253 |
// |
|
4254 |
// The file system is dismounted and mounted aIterations times |
|
4255 |
// aMaxNotifications = 2*aIterations |
|
4256 |
// |
|
4257 |
r = TestMultipleNotificationsL(filesystemName,5,10,t_notification::EMountDismount,TFsNotification::EMediaChange,3*KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4258 |
test_KErrNone(r); |
0 | 4259 |
// |
4260 |
// RFs::MountFileSystemAndScan |
|
4261 |
// 4. Add notification for media change |
|
4262 |
// Mount and scan the file system |
|
4263 |
// |
|
4264 |
// The file system is dismounted and mounted aIterations times |
|
4265 |
// aMaxNotifications = 2*aIterations |
|
4266 |
// |
|
4267 |
//#ifndef __WINS__ |
|
4268 |
// r = TestMultipleNotificationsL(filesystemName,1,2,t_notification::EMountScan,TFsNotification::EMediaChange,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4269 |
// test_KErrNone(r); |
0 | 4270 |
//#endif |
4271 |
test.Printf(_L("------- End of Mount Tests -------------------------------------------\n")); |
|
4272 |
TDriveInfo drvInfo; |
|
4273 |
TInt driveNum; |
|
4274 |
TheFs.CharToDrive(gDriveToTest,driveNum); |
|
4275 |
r = TheFs.Drive(drvInfo,driveNum); |
|
189 | 4276 |
test_KErrNone(r); |
0 | 4277 |
TPtrC driveDes((TText*)&gDriveToTest,1); |
4278 |
// |
|
4279 |
// Manual Tests - Will only run on removable drives |
|
4280 |
// |
|
4281 |
/* if(drvInfo.iDriveAtt & KDriveAttRemovable) |
|
4282 |
{ |
|
4283 |
// |
|
4284 |
// 5. Add notification for media change |
|
4285 |
// Remove media card manually |
|
4286 |
// |
|
4287 |
PrintLine(); |
|
4288 |
test.Next(_L("Media Card Removal/Insertion Tests")); |
|
4289 |
r = TestMultipleNotificationsL(driveDes,1,1,t_notification::EMediaCardRemoval,TFsNotification::EMediaChange,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4290 |
test_KErrNone(r); |
0 | 4291 |
// |
4292 |
// 6. Add notification for media change |
|
4293 |
// Insert media card manually |
|
4294 |
// |
|
4295 |
r = TestMultipleNotificationsL(driveDes,1,1,t_notification::EMediaCardInsertion,TFsNotification::EMediaChange,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4296 |
test_KErrNone(r); |
0 | 4297 |
test.Printf(_L("------- End of Media Card Removal/Insertion Tests --------------------\n")); |
4298 |
// |
|
4299 |
// We should receive an EMediaChange notification even though we did not register for it |
|
4300 |
// 7. Do not add notification for media change |
|
4301 |
// Remove and insert media card manually |
|
4302 |
// |
|
4303 |
PrintLine(); |
|
4304 |
TestMediaCardNotificationWhenNotRegisteredForIt(); |
|
4305 |
test.Printf(_L("------- End of TestMediaCardNotificationWhenNotRegisteredForIt -------\n")); |
|
4306 |
} |
|
4307 |
*/ // |
|
4308 |
// RRawDisk::Write |
|
4309 |
// 8. Add notification for media change |
|
4310 |
// Write directly to the media |
|
4311 |
// |
|
4312 |
#ifdef __WINS__ |
|
4313 |
if(gDriveToTest-(TChar)'A' != 2) |
|
4314 |
#endif |
|
4315 |
{ |
|
4316 |
PrintLine(); |
|
4317 |
test.Next(_L("RRawDisk::Write Tests")); |
|
4318 |
r = TestMultipleNotificationsL(driveDes,1,1,t_notification::ERawDiskWrite,TFsNotification::EMediaChange,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4319 |
test_KErrNone(r); |
0 | 4320 |
test.Printf(_L("------- End of RRawDisk::Write Test ------------------------------ \n")); |
4321 |
} |
|
4322 |
||
4323 |
||
4324 |
//=============================================================================== |
|
4325 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2450 |
|
4326 |
//! @SYMTestType UT |
|
4327 |
//! @SYMREQ PREQ1847 |
|
4328 |
//! @SYMTestCaseDesc Drive Name Modification – Single File Server Session |
|
4329 |
//! @SYMTestStatus Implemented |
|
4330 |
// |
|
4331 |
// TFsNotificationType EDriveName |
|
4332 |
//=============================================================================== |
|
4333 |
// |
|
4334 |
// RFs::SetDriveName |
|
4335 |
// The drive name is renamed 2*aIterations times |
|
4336 |
// aMaxNotifications = 2*aIterations |
|
4337 |
// |
|
4338 |
// 1. Add notification for a specific drive name change |
|
4339 |
// Change the drive name |
|
4340 |
// |
|
4341 |
PrintLine(); |
|
4342 |
test.Next(_L("DriveName Test")); |
|
4343 |
r = TestMultipleNotificationsL(driveDes,1,2,t_notification::ESetDriveName,TFsNotification::EDriveName,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4344 |
test_KErrNone(r); |
0 | 4345 |
// |
4346 |
// 2. Add notification for a specific drive name change |
|
4347 |
// Repeatedly rename the drive |
|
4348 |
// |
|
4349 |
r = TestMultipleNotificationsL(driveDes,3,6,t_notification::ESetDriveName,TFsNotification::EDriveName,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4350 |
test_KErrNone(r); |
0 | 4351 |
test.Printf(_L("------- End of DriveName Test ----------------------------------------\n")); |
4352 |
||
4353 |
||
4354 |
//================================================================================ |
|
4355 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2451 |
|
4356 |
//! @SYMTestType UT |
|
4357 |
//! @SYMREQ PREQ1847 |
|
4358 |
//! @SYMTestCaseDesc Volume Name Modification – Single File Server Session |
|
4359 |
//! @SYMTestStatus Implemented |
|
4360 |
// |
|
4361 |
// TFsNotificationType EVolumeName |
|
4362 |
//================================================================================ |
|
4363 |
// |
|
4364 |
// RFs::SetVolumeLabel - Does not run on WINS |
|
4365 |
// The volume name is renamed 2*aIterations times |
|
4366 |
// aMaxNotifications = 2*aIterations |
|
4367 |
// |
|
4368 |
#ifndef __WINS__ |
|
4369 |
PrintLine(); |
|
4370 |
test.Next(_L("VolumeName Test")); |
|
4371 |
// |
|
4372 |
// 1. Add notification for a specific volume name change |
|
4373 |
// Change the volume name |
|
4374 |
// |
|
4375 |
r = TestMultipleNotificationsL(driveDes,1,2,t_notification::ESetVolumeLabel,TFsNotification::EVolumeName,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4376 |
test_KErrNone(r); |
0 | 4377 |
// |
4378 |
// 2. Add notification for a specific volume name change |
|
4379 |
// Repeatedly rename the volume |
|
4380 |
// |
|
4381 |
r = TestMultipleNotificationsL(driveDes,3,6,t_notification::ESetVolumeLabel,TFsNotification::EVolumeName,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4382 |
test_KErrNone(r); |
0 | 4383 |
test.Printf(_L("------- End of VolumeName Test ---------------------------------------\n")); |
4384 |
#endif |
|
4385 |
||
4386 |
||
4387 |
//============================================================================= |
|
4388 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2452 |
|
4389 |
//! @SYMTestType UT |
|
4390 |
//! @SYMREQ PREQ1847 |
|
4391 |
//! @SYMTestCaseDesc All Operations Filter – Single File Server Session |
|
4392 |
//! @SYMTestStatus Implemented |
|
4393 |
// |
|
4394 |
// TFsNotificationType EAllOps |
|
4395 |
//============================================================================= |
|
4396 |
PrintLine(); |
|
4397 |
test.Next(_L("AllOps Tests")); |
|
4398 |
// |
|
4399 |
// 1. Add notification for all operations |
|
4400 |
// Create a file |
|
4401 |
// Delete the file |
|
4402 |
// |
|
4403 |
// EAllOps1: A file is created and deleted aIterations times |
|
4404 |
// aMaxNotification = 2*aIterations |
|
4405 |
// |
|
4406 |
_LIT(KFilename10,"file.allops"); |
|
4407 |
r = TestMultipleNotificationsL(_L(""),KFilename10,4,8,t_notification::EAllOps1,(TUint)TFsNotification::EAllOps,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4408 |
test_KErrNone(r); |
0 | 4409 |
// |
4410 |
// 2. Add notification for all operations |
|
4411 |
// Create a file |
|
4412 |
// Write to the file |
|
4413 |
// Delete the file |
|
4414 |
// |
|
4415 |
// EAllOps2: A file is created, written to aIterations times and then deleted |
|
4416 |
// aMaxNotification = 2 + aIterations (See File Write Tests) |
|
4417 |
// |
|
4418 |
r = TestMultipleNotificationsL(_L(""),KFilename10,4,6,t_notification::EAllOps2,(TUint)TFsNotification::EAllOps,2*KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4419 |
test_KErrNone(r); |
0 | 4420 |
// |
4421 |
// 3. Add notification for all operations |
|
4422 |
// Create a file |
|
4423 |
// Change the file size |
|
4424 |
// Delete the file |
|
4425 |
// |
|
4426 |
// EAllOps3: A file is created, its size is increased size aIterations times, decreased (aIterations - 1) times |
|
4427 |
// and then deleted |
|
4428 |
// aMaxNotifications = 1 + 2*aIterations |
|
4429 |
// |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4430 |
r = TestMultipleNotificationsL(_L(""),KFilename10,4,9,t_notification::EAllOps3,(TUint)TFsNotification::EAllOps,KMinNotificationBufferSize*2,(TBool)EFalse,__LINE__); |
189 | 4431 |
test_KErrNone(r); |
0 | 4432 |
// |
4433 |
// 4. Add notification for all operations |
|
4434 |
// Create a file |
|
4435 |
// Change the file attribute |
|
4436 |
// Delete the file |
|
4437 |
// |
|
4438 |
// EAllOps4: A file is created, its attribute is changed and the file is deleted |
|
4439 |
// aMaxNotification = 3 |
|
4440 |
// |
|
4441 |
r = TestMultipleNotificationsL(_L(""),KFilename10,1,3,t_notification::EAllOps4,(TUint)TFsNotification::EAllOps,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4442 |
test_KErrNone(r); |
0 | 4443 |
// |
4444 |
// 5. Add notification for all operations |
|
4445 |
// Create a file |
|
4446 |
// Rename the file |
|
4447 |
// |
|
4448 |
// EAllOps5: A file is created and renamed |
|
4449 |
// aMaxNotification = 2 |
|
4450 |
// |
|
4451 |
r = TestMultipleNotificationsL(_L(""),KFilename10,1,2,t_notification::EAllOps5,(TUint)TFsNotification::EAllOps,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4452 |
test_KErrNone(r); |
0 | 4453 |
// |
4454 |
// 6. Add notification for all operations |
|
4455 |
// Change drive name |
|
4456 |
// Change volume name |
|
4457 |
// |
|
4458 |
// SetVolumeLabel does not run on WINS |
|
4459 |
// EAllOps6: The drive and volume names are changed |
|
4460 |
// aMaxNotification = 2 |
|
4461 |
// |
|
4462 |
#ifndef __WINS__ |
|
4463 |
r = TestMultipleNotificationsL(driveDes,1,2,t_notification::EAllOps6,(TUint)TFsNotification::EAllOps,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4464 |
test_KErrNone(r); |
0 | 4465 |
#endif |
4466 |
test.Printf(_L("------- End of AllOps Tests ------------------------------------------\n")); |
|
4467 |
||
4468 |
||
4469 |
//============================================================================= |
|
4470 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2453 |
|
4471 |
//! @SYMTestType UT |
|
4472 |
//! @SYMREQ PREQ1847 |
|
4473 |
//! @SYMTestCaseDesc Multiple Filters – Single File Server Session |
|
4474 |
//! @SYMTestStatus Implemented |
|
4475 |
//============================================================================= |
|
4476 |
PrintLine(); |
|
4477 |
test.Next(_L("Multiple-Filter Tests")); |
|
4478 |
// |
|
4479 |
// TFsNotification::ECreate | TFsNotification::EDelete |
|
4480 |
// 1. Add notification for create and delete for a specific file |
|
4481 |
// Create that file |
|
4482 |
// Delete the file |
|
4483 |
// |
|
4484 |
// A file is created and deleted aIterations times |
|
4485 |
// aMaxNotification = 2*aIterations |
|
4486 |
// |
|
4487 |
_LIT(KFilename11,"file.mulfil"); |
|
4488 |
r = TestMultipleNotificationsL(_L(""),KFilename11,3,6,t_notification::EAllOps1,TFsNotification::ECreate | TFsNotification::EDelete,2*KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4489 |
test_KErrNone(r); |
0 | 4490 |
// |
4491 |
// TFsNotification::EDelete | TFsNotification::ECreate | TFsNotification::EFileChange |
|
4492 |
// 2. Add notification for create, file change and delete for a specific file |
|
4493 |
// Create a file |
|
4494 |
// Change the file size |
|
4495 |
// Delete the file |
|
4496 |
// |
|
4497 |
// A file is created, its size is increased size aIterations times, decreased (aIterations - 1) times |
|
4498 |
// and then deleted |
|
4499 |
// aMaxNotifications = 1 + 2*aIterations |
|
4500 |
// |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
4501 |
r = TestMultipleNotificationsL(_L(""),KFilename11,4,9,t_notification::EAllOps3,TFsNotification::EDelete | TFsNotification::ECreate | TFsNotification::EFileChange,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
189 | 4502 |
test_KErrNone(r); |
0 | 4503 |
// |
4504 |
// TFsNotification::EAttribute | TFsNotification::EDelete | TFsNotification::ECreate |
|
4505 |
// 3. Add notification for create, attribute change and delete for a specific file |
|
4506 |
// Create a file |
|
4507 |
// Change the file attribute |
|
4508 |
// Delete the file |
|
4509 |
// |
|
4510 |
// A file is created, its attribute is changed and the file is deleted |
|
4511 |
// aMaxNotification = 3 |
|
4512 |
// |
|
4513 |
r = TestMultipleNotificationsL(_L(""),KFilename11,1,3,t_notification::EAllOps4,TFsNotification::EAttribute | TFsNotification::EDelete | TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4514 |
test_KErrNone(r); |
0 | 4515 |
// |
4516 |
// TFsNotification::ERename | TFsNotification::ECreate |
|
4517 |
// 4. Add notification for create and rename for a specific file |
|
4518 |
// Create a file |
|
4519 |
// Rename the file |
|
4520 |
// |
|
4521 |
// A file is created and renamed |
|
4522 |
// aMaxNotification = 2 |
|
4523 |
// |
|
4524 |
r = TestMultipleNotificationsL(_L(""),KFilename11,1,2,t_notification::EAllOps5,TFsNotification::ERename | TFsNotification::ECreate,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4525 |
test_KErrNone(r); |
0 | 4526 |
// |
4527 |
// TFsNotification::EVolumeName | TFsNotification::EDriveName |
|
4528 |
// 5. Add notification for drive and volume name change for a specific drive |
|
4529 |
// Change drive name |
|
4530 |
// Change volume name |
|
4531 |
// |
|
4532 |
// SetVolumeLabel does not run on WINS |
|
4533 |
// The drive and volume names are changed |
|
4534 |
// aMaxNotification = 2 |
|
4535 |
// |
|
4536 |
#ifndef __WINS__ |
|
4537 |
r = TestMultipleNotificationsL(driveDes,1,2,t_notification::EAllOps6,TFsNotification::EVolumeName | TFsNotification::EDriveName,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4538 |
test_KErrNone(r); |
0 | 4539 |
#endif |
4540 |
test.Printf(_L("------- End of Multiple-Filter Tests ---------------------------------\n")); |
|
4541 |
||
4542 |
||
4543 |
//============================================================================== |
|
4544 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2454 |
|
4545 |
//! @SYMTestType UT |
|
4546 |
//! @SYMREQ PREQ1847 |
|
4547 |
//! @SYMTestCaseDesc Overflow Notification – Single File Server Session |
|
4548 |
//! @SYMTestStatus Implemented |
|
4549 |
//============================================================================== |
|
4550 |
// |
|
4551 |
// 1. Add notification with a small buffer size, for a specific file change |
|
4552 |
// Change the file size once |
|
4553 |
// 2. Make continuous file size changes to the file |
|
4554 |
// 3. When overflow notification occurs, delete the notification |
|
4555 |
// |
|
4556 |
PrintLine(); |
|
4557 |
r = TestOverflowL(); |
|
189 | 4558 |
test_KErrNone(r); |
0 | 4559 |
|
4560 |
//For DEF140387 |
|
4561 |
PrintLine(); |
|
4562 |
r= TestPostOverflowNotifications(); |
|
189 | 4563 |
test_KErrNone(r); |
0 | 4564 |
test.Printf(_L("------- End of Overflow Test -----------------------------------------\n")); |
4565 |
||
4566 |
||
4567 |
//============================================================================ |
|
4568 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2455 |
|
4569 |
//! @SYMTestType CIT |
|
4570 |
//! @SYMREQ PREQ1847 |
|
4571 |
//! @SYMTestCaseDesc API Negative Testing – Single File Server Session |
|
4572 |
//! @SYMTestStatus Implemented |
|
4573 |
//============================================================================ |
|
4574 |
// 1. |
|
4575 |
// a-CFsNotify class creation with zero buffer size |
|
4576 |
// |
|
4577 |
// 2. |
|
4578 |
// b-CFsNotify class creation with negative buffer size |
|
4579 |
// c-CFsNotify class creation with buffer size that is too large |
|
4580 |
// |
|
4581 |
// 3. |
|
4582 |
// d-Call AddNotification with aNotiififcationType zero |
|
4583 |
// e-Call AddNotification with aNotiififcationType invalid |
|
4584 |
// f-Call AddNotification with many different invalid paths |
|
4585 |
// |
|
4586 |
// 4. |
|
4587 |
// g-Call RequestNotifications with status that is already in use |
|
4588 |
// h-Call CancelNotifications with wrong status |
|
4589 |
// |
|
4590 |
PrintLine(); |
|
4591 |
__UHEAP_MARK; |
|
4592 |
NegativeTests(); |
|
4593 |
__UHEAP_MARKEND; |
|
4594 |
// |
|
4595 |
// 5. |
|
4596 |
// i-Negative testing for directory without * |
|
4597 |
// |
|
4598 |
test.Printf(_L("NegativeTests() I\n")); |
|
4599 |
NegativeTestDirStar(); |
|
4600 |
test.Printf(_L("------- End of Negative Tests ----------------------------------------\n")); |
|
4601 |
||
4602 |
||
4603 |
//============================================================================= |
|
4604 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2461 |
|
4605 |
//! @SYMTestType CIT |
|
4606 |
//! @SYMREQ PREQ1847 |
|
4607 |
//! @SYMTestCaseDesc Plugin Tests |
|
4608 |
//! @SYMTestStatus |
|
4609 |
//============================================================================= |
|
4610 |
PrintLine(); |
|
4611 |
r = TestNotificationsWithFServPlugins(); |
|
189 | 4612 |
test_KErrNone(r); |
0 | 4613 |
test.Printf(_L("------- End of Plugin Tests ------------------------------------------\n")); |
4614 |
||
4615 |
||
4616 |
//====================================================================== |
|
4617 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2459 |
|
4618 |
//! @SYMTestType UT |
|
4619 |
//! @SYMREQ PREQ1847 |
|
4620 |
//! @SYMTestCaseDesc Drive Formatting – Single File Server Session |
|
4621 |
//! @SYMTestStatus Implemented |
|
4622 |
// |
|
4623 |
// TFsNotificationType EMediaChange |
|
4624 |
//====================================================================== |
|
4625 |
// |
|
4626 |
// RFormat |
|
4627 |
// We do these last so that we can be sure to have deleted anything we've inadvertently not deleted |
|
4628 |
// |
|
4629 |
// 1. Add notification for media change of a specific drive |
|
4630 |
// Format the drive |
|
4631 |
// |
|
4632 |
#ifdef __WINS__ |
|
4633 |
if(gDriveToTest-(TChar)'A' != 2) |
|
4634 |
#endif |
|
4635 |
{ |
|
4636 |
PrintLine(); |
|
4637 |
test.Next(_L("Format Tests")); |
|
4638 |
r = TestMultipleNotificationsL(driveDes,1,1,t_notification::EFormat,TFsNotification::EMediaChange,KMinNotificationBufferSize,(TBool)EFalse,__LINE__); |
|
189 | 4639 |
test_KErrNone(r); |
0 | 4640 |
test.Printf(_L("------- End of Format Tests ------------------------------------------\n")); |
4641 |
} |
|
4642 |
||
4643 |
||
4644 |
//====================================================================== |
|
4645 |
//! @SYMTestCaseID PBASE-T_NOTIFY-2460 |
|
4646 |
//! @SYMTestType UT |
|
4647 |
//! @SYMREQ PREQ1847 |
|
4648 |
//! @SYMTestCaseDesc Notifications for Data Caged Areas |
|
4649 |
//! @SYMTestStatus Implemented |
|
4650 |
//====================================================================== |
|
4651 |
// |
|
4652 |
// Create a private folder for a specified uid |
|
4653 |
// Add notification filter using the following processes: |
|
4654 |
// 1. A process with no capability |
|
4655 |
// 2. A process with all capabilities |
|
4656 |
// 3. A process with the specified uid |
|
4657 |
// |
|
4658 |
PrintLine(); |
|
4659 |
test.Next(_L("Test T_NOTIFIER_NOCAPS.EXE")); |
|
4660 |
r = TestProcessCapabilities(_L("T_NOTIFIER_NOCAPS.EXE")); |
|
189 | 4661 |
test_Value(r, r == KErrPermissionDenied); //Failure on emulator -> Did you forget to do a wintest? |
0 | 4662 |
|
4663 |
test.Next(_L("Test T_NOTIFIER_ALLFILES.EXE")); |
|
4664 |
r = TestProcessCapabilities(_L("T_NOTIFIER_ALLFILES.EXE")); |
|
189 | 4665 |
test_KErrNone(r); |
0 | 4666 |
|
4667 |
test.Next(_L("Test T_NOTIFIER_BELONGS.EXE")); |
|
4668 |
r = TestProcessCapabilities(_L("T_NOTIFIER_BELONGS.EXE")); |
|
189 | 4669 |
test_KErrNone(r); |
0 | 4670 |
test.Printf(_L("------- End of Data-Caging Tests -------------------------------------\n")); |
4671 |
||
300 | 4672 |
PrintLine(); |
4673 |
test.Next(_L("Test TestExternalNotifications()")); |
|
4674 |
TestExternalNotifications(); |
|
4675 |
test.Printf(_L("------- End of TestExternalNotifications Tests -------------------------------------\n")); |
|
0 | 4676 |
|
4677 |
test.End(); |
|
4678 |
test.Close(); |
|
4679 |
delete cleanup; |
|
4680 |
} //End of CallTestsL |
|
4681 |