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