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