sl@0
|
1 |
// Copyright (c) 1996-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_notify.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 |
|
sl@0
|
24 |
const TInt KHeapSize=0x200;
|
sl@0
|
25 |
|
sl@0
|
26 |
// wait for a bit since NotifyChange handled asynchronously and SetDriveName synchronously
|
sl@0
|
27 |
const TInt KNotifyChangeAfter=100000;
|
sl@0
|
28 |
const TInt KMediaRemountForceMediaChange = 0x00000001;
|
sl@0
|
29 |
|
sl@0
|
30 |
RTest test(_L("T_NOTIFY"));
|
sl@0
|
31 |
RSemaphore gSleepThread;
|
sl@0
|
32 |
TInt gSocketNumber=0;
|
sl@0
|
33 |
TInt SocketToDrive[KMaxPBusSockets];
|
sl@0
|
34 |
|
sl@0
|
35 |
//#define __INCLUDE_MANUAL_TESTS__
|
sl@0
|
36 |
|
sl@0
|
37 |
void do_check_no_pending_requests(TInt aLine)
|
sl@0
|
38 |
{
|
sl@0
|
39 |
RTimer timer;
|
sl@0
|
40 |
TRequestStatus timerStat;
|
sl@0
|
41 |
timer.CreateLocal();
|
sl@0
|
42 |
timer.After(timerStat, 125000);
|
sl@0
|
43 |
User::WaitForAnyRequest();
|
sl@0
|
44 |
if(timerStat==KRequestPending)
|
sl@0
|
45 |
{
|
sl@0
|
46 |
RDebug::Printf("do_check_no_pending_requests failed at line %d",aLine);
|
sl@0
|
47 |
test(0);
|
sl@0
|
48 |
}
|
sl@0
|
49 |
timer.Close();
|
sl@0
|
50 |
}
|
sl@0
|
51 |
#define CHECK_NO_PENDING_REQUESTS do_check_no_pending_requests(__LINE__);
|
sl@0
|
52 |
|
sl@0
|
53 |
|
sl@0
|
54 |
TBool CheckDriveRead(TInt aDrive)
|
sl@0
|
55 |
//Determines if can connect to local drive number and read
|
sl@0
|
56 |
{
|
sl@0
|
57 |
TBusLocalDrive TBLD;
|
sl@0
|
58 |
TBool TBLDChangedFlag;
|
sl@0
|
59 |
|
sl@0
|
60 |
TInt r = TBLD.Connect(aDrive, TBLDChangedFlag);
|
sl@0
|
61 |
test.Printf(_L("Connect returned %d\n"), r);
|
sl@0
|
62 |
if (r == KErrNone)
|
sl@0
|
63 |
{
|
sl@0
|
64 |
const TInt KSectSize = 512;
|
sl@0
|
65 |
TBuf8<KSectSize> sect;
|
sl@0
|
66 |
r = TBLD.Read(0, KSectSize, sect);
|
sl@0
|
67 |
test.Printf(_L("Read returned %d\n"), r);
|
sl@0
|
68 |
TBLD.Disconnect();
|
sl@0
|
69 |
if(r!=KErrNone)
|
sl@0
|
70 |
return EFalse;
|
sl@0
|
71 |
else
|
sl@0
|
72 |
return ETrue;
|
sl@0
|
73 |
}
|
sl@0
|
74 |
else
|
sl@0
|
75 |
return EFalse;
|
sl@0
|
76 |
}
|
sl@0
|
77 |
|
sl@0
|
78 |
void GenerateMediaChange()
|
sl@0
|
79 |
{
|
sl@0
|
80 |
TPckgBuf<TInt> pckg;
|
sl@0
|
81 |
pckg()=0;
|
sl@0
|
82 |
|
sl@0
|
83 |
RFs fs;
|
sl@0
|
84 |
TInt r = fs.Connect();
|
sl@0
|
85 |
if (r == KErrNone)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
r = fs.RemountDrive(CurrentDrive(), &pckg, (TUint)KMediaRemountForceMediaChange);
|
sl@0
|
88 |
if(r == KErrNotReady)
|
sl@0
|
89 |
{
|
sl@0
|
90 |
r = KErrNone;
|
sl@0
|
91 |
}
|
sl@0
|
92 |
fs.Close();
|
sl@0
|
93 |
}
|
sl@0
|
94 |
|
sl@0
|
95 |
if (r!=KErrNone)
|
sl@0
|
96 |
{
|
sl@0
|
97 |
RProcess me;
|
sl@0
|
98 |
me.Panic(_L("GenMedChg"),r);
|
sl@0
|
99 |
}
|
sl@0
|
100 |
}
|
sl@0
|
101 |
|
sl@0
|
102 |
enum TTestCode {ETest1,ETest2,ETest3,ETest4,ETest5,ETest6,ETest7,ETest8,ETest9,ETest10,ETest11,ETest12};
|
sl@0
|
103 |
const TUint KGenericEntryChange=0x02;
|
sl@0
|
104 |
|
sl@0
|
105 |
static TInt ThreadEntryPoint(TAny* aTestCode)
|
sl@0
|
106 |
//
|
sl@0
|
107 |
// Thread entry point
|
sl@0
|
108 |
//
|
sl@0
|
109 |
{
|
sl@0
|
110 |
RFs fs;
|
sl@0
|
111 |
TInt r=fs.Connect();
|
sl@0
|
112 |
test(r==KErrNone);
|
sl@0
|
113 |
r=fs.SetSessionPath(gSessionPath);
|
sl@0
|
114 |
test(r==KErrNone);
|
sl@0
|
115 |
TTestCode testCode=*(TTestCode*)&aTestCode;
|
sl@0
|
116 |
RFile f;
|
sl@0
|
117 |
switch (testCode)
|
sl@0
|
118 |
{
|
sl@0
|
119 |
|
sl@0
|
120 |
case ETest1:
|
sl@0
|
121 |
r=f.Replace(fs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileStream);
|
sl@0
|
122 |
test(r==KErrNone);
|
sl@0
|
123 |
f.Close();
|
sl@0
|
124 |
break;
|
sl@0
|
125 |
|
sl@0
|
126 |
case ETest2:
|
sl@0
|
127 |
r=f.Replace(fs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileStream);
|
sl@0
|
128 |
test(r==KErrNone);
|
sl@0
|
129 |
f.Close();
|
sl@0
|
130 |
break;
|
sl@0
|
131 |
|
sl@0
|
132 |
case ETest3:
|
sl@0
|
133 |
r=fs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\SCARECROW\\"));
|
sl@0
|
134 |
test((r==KErrNone)||(r==KErrAlreadyExists));
|
sl@0
|
135 |
break;
|
sl@0
|
136 |
|
sl@0
|
137 |
case ETest4:
|
sl@0
|
138 |
{
|
sl@0
|
139 |
TRequestStatus s;
|
sl@0
|
140 |
fs.NotifyChange(ENotifyAll,s);
|
sl@0
|
141 |
test(s==KRequestPending);
|
sl@0
|
142 |
gSleepThread.Signal();
|
sl@0
|
143 |
User::After(100000000);
|
sl@0
|
144 |
}
|
sl@0
|
145 |
break;
|
sl@0
|
146 |
|
sl@0
|
147 |
case ETest5:
|
sl@0
|
148 |
{
|
sl@0
|
149 |
RFile file;
|
sl@0
|
150 |
TInt r=file.Open(fs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
|
sl@0
|
151 |
test(r==KErrNone);
|
sl@0
|
152 |
r=file.SetSize(sizeof(TCheckedUid));
|
sl@0
|
153 |
test(r==KErrNone);
|
sl@0
|
154 |
r=file.Write(sizeof(TCheckedUid),_L8("012345678912"));
|
sl@0
|
155 |
test(r==KErrNone);
|
sl@0
|
156 |
TBuf8<64> dum;
|
sl@0
|
157 |
r=file.Read(0,dum);
|
sl@0
|
158 |
test(r==KErrNone);
|
sl@0
|
159 |
file.Close();
|
sl@0
|
160 |
|
sl@0
|
161 |
r=file.Open(fs,_L("\\F32-TST\\NOTIFY\\koala.txt"),EFileRead|EFileWrite);
|
sl@0
|
162 |
test(r==KErrNone);
|
sl@0
|
163 |
r=file.SetSize(50);
|
sl@0
|
164 |
test(r==KErrNone);
|
sl@0
|
165 |
r=file.Write(sizeof(TCheckedUid),_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
|
sl@0
|
166 |
test(r==KErrNone);
|
sl@0
|
167 |
r=file.Read(0,dum);
|
sl@0
|
168 |
test(r==KErrNone);
|
sl@0
|
169 |
file.Close();
|
sl@0
|
170 |
|
sl@0
|
171 |
r=file.Open(fs,_L("\\F32-TST\\NOTIFY\\dingo.txt"),EFileRead|EFileWrite);
|
sl@0
|
172 |
test(r==KErrNone);
|
sl@0
|
173 |
r=file.SetSize(50);
|
sl@0
|
174 |
test(r==KErrNone);
|
sl@0
|
175 |
r=file.Write(sizeof(TCheckedUid),_L8("01234567890123456789"));
|
sl@0
|
176 |
test(r==KErrNone);
|
sl@0
|
177 |
r=file.Read(0,dum);
|
sl@0
|
178 |
test(r==KErrNone);
|
sl@0
|
179 |
file.Close();
|
sl@0
|
180 |
gSleepThread.Signal();
|
sl@0
|
181 |
}
|
sl@0
|
182 |
break;
|
sl@0
|
183 |
|
sl@0
|
184 |
case ETest6:
|
sl@0
|
185 |
{
|
sl@0
|
186 |
GenerateMediaChange();
|
sl@0
|
187 |
User::After(300000); // Wait for a bit
|
sl@0
|
188 |
gSleepThread.Signal();
|
sl@0
|
189 |
}
|
sl@0
|
190 |
break;
|
sl@0
|
191 |
|
sl@0
|
192 |
case ETest7:
|
sl@0
|
193 |
{
|
sl@0
|
194 |
RFile file;
|
sl@0
|
195 |
TInt r=file.Open(fs,_L("\\F32-TST\\NOTIFY\\NewFILE.TXT"),EFileRead|EFileWrite);
|
sl@0
|
196 |
test(r==KErrNone);
|
sl@0
|
197 |
r=file.Write(_L8("asdfasdfasdf"));
|
sl@0
|
198 |
test(r==KErrNone);
|
sl@0
|
199 |
file.Close();
|
sl@0
|
200 |
gSleepThread.Signal();
|
sl@0
|
201 |
}
|
sl@0
|
202 |
break;
|
sl@0
|
203 |
|
sl@0
|
204 |
case ETest8:
|
sl@0
|
205 |
{
|
sl@0
|
206 |
r=f.Open(fs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.msg"),EFileRead|EFileWrite);
|
sl@0
|
207 |
test(r==KErrNone);
|
sl@0
|
208 |
f.SetSize(500);
|
sl@0
|
209 |
f.Close();
|
sl@0
|
210 |
break;
|
sl@0
|
211 |
}
|
sl@0
|
212 |
|
sl@0
|
213 |
case ETest9:
|
sl@0
|
214 |
{
|
sl@0
|
215 |
TRequestStatus s;
|
sl@0
|
216 |
TFileName path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
217 |
fs.NotifyChange(ENotifyAll,s,path);
|
sl@0
|
218 |
test(s==KRequestPending);
|
sl@0
|
219 |
gSleepThread.Signal();
|
sl@0
|
220 |
User::After(100000000);
|
sl@0
|
221 |
}
|
sl@0
|
222 |
break;
|
sl@0
|
223 |
case ETest10:
|
sl@0
|
224 |
{
|
sl@0
|
225 |
TFileName path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\");
|
sl@0
|
226 |
r=fs.MkDir(path);
|
sl@0
|
227 |
test(r==KErrNone);
|
sl@0
|
228 |
break;
|
sl@0
|
229 |
}
|
sl@0
|
230 |
case ETest11:
|
sl@0
|
231 |
{
|
sl@0
|
232 |
TFileName path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\PayNoAttention.man");
|
sl@0
|
233 |
RFile file;
|
sl@0
|
234 |
r=file.Replace(fs,path,EFileStream);
|
sl@0
|
235 |
test(r==KErrNone);
|
sl@0
|
236 |
file.Close();
|
sl@0
|
237 |
break;
|
sl@0
|
238 |
}
|
sl@0
|
239 |
case ETest12:
|
sl@0
|
240 |
{
|
sl@0
|
241 |
RFile writer;
|
sl@0
|
242 |
TInt r=writer.Open(fs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileWrite|EFileShareAny);
|
sl@0
|
243 |
test(r==KErrNone);
|
sl@0
|
244 |
TInt i;
|
sl@0
|
245 |
for(i=0; i<10; i++)
|
sl@0
|
246 |
{
|
sl@0
|
247 |
r=writer.Write(_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
|
sl@0
|
248 |
test(r==KErrNone);
|
sl@0
|
249 |
User::After(1000000);
|
sl@0
|
250 |
}
|
sl@0
|
251 |
writer.Close();
|
sl@0
|
252 |
break;
|
sl@0
|
253 |
}
|
sl@0
|
254 |
default:
|
sl@0
|
255 |
break;
|
sl@0
|
256 |
}
|
sl@0
|
257 |
return KErrNone;
|
sl@0
|
258 |
}
|
sl@0
|
259 |
|
sl@0
|
260 |
#if defined (__EPOC32__)//we have no removable media on Emulator yet
|
sl@0
|
261 |
static void WaitForMediaChange()
|
sl@0
|
262 |
//
|
sl@0
|
263 |
// Wait for media driver to register drive is present
|
sl@0
|
264 |
//
|
sl@0
|
265 |
{
|
sl@0
|
266 |
|
sl@0
|
267 |
TEntry entry;
|
sl@0
|
268 |
FOREVER
|
sl@0
|
269 |
{
|
sl@0
|
270 |
User::After(10000);
|
sl@0
|
271 |
TInt r=TheFs.Entry(_L("xxxxxxxx"),entry);
|
sl@0
|
272 |
if (r!=KErrNotReady)
|
sl@0
|
273 |
break;
|
sl@0
|
274 |
}
|
sl@0
|
275 |
}
|
sl@0
|
276 |
#endif
|
sl@0
|
277 |
|
sl@0
|
278 |
static void Test1()
|
sl@0
|
279 |
//
|
sl@0
|
280 |
// Test notification of an entry change
|
sl@0
|
281 |
//
|
sl@0
|
282 |
{
|
sl@0
|
283 |
|
sl@0
|
284 |
test.Next(_L("Test notification of an entry change"));
|
sl@0
|
285 |
TRequestStatus reqStat(KRequestPending);
|
sl@0
|
286 |
TRequestStatus thrdStat(KRequestPending);
|
sl@0
|
287 |
TInt r;
|
sl@0
|
288 |
TheFs.NotifyChange(ENotifyEntry,reqStat);
|
sl@0
|
289 |
RThread thread;
|
sl@0
|
290 |
r=thread.Create(_L("MyThread"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
|
sl@0
|
291 |
test(r==KErrNone);
|
sl@0
|
292 |
thread.Logon(thrdStat);
|
sl@0
|
293 |
thread.Resume();
|
sl@0
|
294 |
User::WaitForRequest(thrdStat);
|
sl@0
|
295 |
test(thrdStat==KErrNone);
|
sl@0
|
296 |
thread.Close();
|
sl@0
|
297 |
User::WaitForRequest(reqStat);
|
sl@0
|
298 |
test(reqStat==KErrNone);
|
sl@0
|
299 |
|
sl@0
|
300 |
RFile file;
|
sl@0
|
301 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite|EFileShareExclusive);
|
sl@0
|
302 |
test(r==KErrNone);
|
sl@0
|
303 |
file.Write(_L8("Somewhere over the rainbow..."),reqStat);
|
sl@0
|
304 |
User::WaitForRequest(reqStat);
|
sl@0
|
305 |
test(reqStat==KErrNone);
|
sl@0
|
306 |
TBuf8<256> buf;
|
sl@0
|
307 |
file.Read(0, buf,reqStat);
|
sl@0
|
308 |
User::WaitForRequest(reqStat);
|
sl@0
|
309 |
test(reqStat==KErrNone);
|
sl@0
|
310 |
file.Close();
|
sl@0
|
311 |
|
sl@0
|
312 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareExclusive);
|
sl@0
|
313 |
test(r==KErrArgument);
|
sl@0
|
314 |
|
sl@0
|
315 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareReadersOnly);
|
sl@0
|
316 |
test(r==KErrArgument);
|
sl@0
|
317 |
|
sl@0
|
318 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
|
sl@0
|
319 |
test(r==KErrNone);
|
sl@0
|
320 |
file.Read(0, buf, 100, reqStat);
|
sl@0
|
321 |
test(reqStat==KRequestPending);
|
sl@0
|
322 |
file.Close();
|
sl@0
|
323 |
User::WaitForRequest(reqStat);
|
sl@0
|
324 |
test(reqStat==KErrCancel);
|
sl@0
|
325 |
|
sl@0
|
326 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
|
sl@0
|
327 |
test(r==KErrNone);
|
sl@0
|
328 |
file.Read(0, buf, 100, reqStat);
|
sl@0
|
329 |
test(reqStat==KRequestPending);
|
sl@0
|
330 |
file.ReadCancel(reqStat);
|
sl@0
|
331 |
User::WaitForRequest(reqStat);
|
sl@0
|
332 |
test(reqStat==KErrCancel);
|
sl@0
|
333 |
file.Close();
|
sl@0
|
334 |
|
sl@0
|
335 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileWrite|EFileShareAny);
|
sl@0
|
336 |
test(r==KErrNone);
|
sl@0
|
337 |
file.Read(0, buf, 100, reqStat);
|
sl@0
|
338 |
test(reqStat==KRequestPending);
|
sl@0
|
339 |
file.SetSize(100);
|
sl@0
|
340 |
User::WaitForRequest(reqStat);
|
sl@0
|
341 |
test(reqStat==KErrNone);
|
sl@0
|
342 |
test(buf.Length() == 100);
|
sl@0
|
343 |
file.Close();
|
sl@0
|
344 |
|
sl@0
|
345 |
test.Next(_L("Repeat Test notification of an entry change"));
|
sl@0
|
346 |
TheFs.NotifyChange(ENotifyEntry,reqStat);
|
sl@0
|
347 |
thread.Create(_L("MyThread2"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
|
sl@0
|
348 |
thread.Logon(thrdStat);
|
sl@0
|
349 |
thread.Resume();
|
sl@0
|
350 |
User::WaitForRequest(thrdStat);
|
sl@0
|
351 |
test(thrdStat==KErrNone);
|
sl@0
|
352 |
thread.Close();
|
sl@0
|
353 |
User::WaitForRequest(reqStat);
|
sl@0
|
354 |
if (reqStat!=KErrNone)
|
sl@0
|
355 |
{
|
sl@0
|
356 |
test.Printf(_L("ReqStat=%d\n"),reqStat.Int());
|
sl@0
|
357 |
//test.Getch();
|
sl@0
|
358 |
}
|
sl@0
|
359 |
test(reqStat==KErrNone);
|
sl@0
|
360 |
|
sl@0
|
361 |
test.Next(_L("Test Notify cancel"));
|
sl@0
|
362 |
TheFs.NotifyChange(ENotifyEntry,reqStat);
|
sl@0
|
363 |
TheFs.NotifyChangeCancel();
|
sl@0
|
364 |
User::WaitForRequest(reqStat);
|
sl@0
|
365 |
|
sl@0
|
366 |
test.Next(_L("Test notification still works"));
|
sl@0
|
367 |
TheFs.NotifyChange(ENotifyEntry,reqStat);
|
sl@0
|
368 |
thread.Create(_L("MyThread3"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
|
sl@0
|
369 |
thread.Logon(thrdStat);
|
sl@0
|
370 |
thread.Resume();
|
sl@0
|
371 |
User::WaitForRequest(thrdStat);
|
sl@0
|
372 |
test(thrdStat==KErrNone);
|
sl@0
|
373 |
thread.Close();
|
sl@0
|
374 |
User::WaitForRequest(reqStat);
|
sl@0
|
375 |
test(reqStat==KErrNone);
|
sl@0
|
376 |
}
|
sl@0
|
377 |
|
sl@0
|
378 |
static void Test2()
|
sl@0
|
379 |
//
|
sl@0
|
380 |
// Test notify for multiple clients
|
sl@0
|
381 |
//
|
sl@0
|
382 |
{
|
sl@0
|
383 |
|
sl@0
|
384 |
test.Next(_L("Test notification of multiple clients"));
|
sl@0
|
385 |
|
sl@0
|
386 |
TRequestStatus reqStat1(KRequestPending);
|
sl@0
|
387 |
RFs fs1;
|
sl@0
|
388 |
TInt r=fs1.Connect();
|
sl@0
|
389 |
test(r==KErrNone);
|
sl@0
|
390 |
fs1.NotifyChange(ENotifyEntry,reqStat1);
|
sl@0
|
391 |
|
sl@0
|
392 |
TRequestStatus reqStat2(KRequestPending);
|
sl@0
|
393 |
RFs fs2;
|
sl@0
|
394 |
r=fs2.Connect();
|
sl@0
|
395 |
test(r==KErrNone);
|
sl@0
|
396 |
fs2.NotifyChange(ENotifyEntry,reqStat2);
|
sl@0
|
397 |
|
sl@0
|
398 |
test(reqStat1==KRequestPending);
|
sl@0
|
399 |
test(reqStat2==KRequestPending);
|
sl@0
|
400 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\NEWFILE.TXT"));
|
sl@0
|
401 |
test(r==KErrNone);
|
sl@0
|
402 |
User::WaitForRequest(reqStat1);
|
sl@0
|
403 |
User::WaitForRequest(reqStat2);
|
sl@0
|
404 |
test(reqStat1==KErrNone);
|
sl@0
|
405 |
test(reqStat2==KErrNone);
|
sl@0
|
406 |
}
|
sl@0
|
407 |
|
sl@0
|
408 |
static void Test3()
|
sl@0
|
409 |
//
|
sl@0
|
410 |
// Test notify cancel
|
sl@0
|
411 |
//
|
sl@0
|
412 |
{
|
sl@0
|
413 |
|
sl@0
|
414 |
test.Next(_L("Cancel notification"));
|
sl@0
|
415 |
RFs fs1;
|
sl@0
|
416 |
TInt r=fs1.Connect();
|
sl@0
|
417 |
test(r==KErrNone);
|
sl@0
|
418 |
|
sl@0
|
419 |
TRequestStatus status1;
|
sl@0
|
420 |
TRequestStatus status2;
|
sl@0
|
421 |
TRequestStatus status3;
|
sl@0
|
422 |
TRequestStatus status4;
|
sl@0
|
423 |
TRequestStatus status5;
|
sl@0
|
424 |
|
sl@0
|
425 |
fs1.NotifyChange(ENotifyAll,status1);
|
sl@0
|
426 |
fs1.NotifyChange(ENotifyAll,status2);
|
sl@0
|
427 |
fs1.NotifyChange(ENotifyAll,status3);
|
sl@0
|
428 |
fs1.NotifyChange(ENotifyAll,status4);
|
sl@0
|
429 |
fs1.NotifyChange(ENotifyAll,status5);
|
sl@0
|
430 |
test(status1==KRequestPending);
|
sl@0
|
431 |
test(status2==KRequestPending);
|
sl@0
|
432 |
test(status3==KRequestPending);
|
sl@0
|
433 |
test(status4==KRequestPending);
|
sl@0
|
434 |
test(status5==KRequestPending);
|
sl@0
|
435 |
|
sl@0
|
436 |
test.Next(_L("RFs::NotifyCancel()"));
|
sl@0
|
437 |
// Test that one call to RFs::NotifyCancel() cancels all outstanding requests
|
sl@0
|
438 |
fs1.NotifyChangeCancel();
|
sl@0
|
439 |
User::WaitForRequest(status1);
|
sl@0
|
440 |
test(status1==KErrCancel);
|
sl@0
|
441 |
User::WaitForRequest(status2);
|
sl@0
|
442 |
test(status2==KErrCancel);
|
sl@0
|
443 |
User::WaitForRequest(status3);
|
sl@0
|
444 |
test(status3==KErrCancel);
|
sl@0
|
445 |
User::WaitForRequest(status4);
|
sl@0
|
446 |
test(status4==KErrCancel);
|
sl@0
|
447 |
User::WaitForRequest(status5);
|
sl@0
|
448 |
test(status5==KErrCancel);
|
sl@0
|
449 |
// Call the cancel function again to check no further action
|
sl@0
|
450 |
fs1.NotifyChangeCancel();
|
sl@0
|
451 |
|
sl@0
|
452 |
// Test overloaded function to cancel a single request
|
sl@0
|
453 |
test.Next(_L("Cancel notification request using function overload"));
|
sl@0
|
454 |
fs1.NotifyChange(ENotifyAll,status1);
|
sl@0
|
455 |
fs1.NotifyChange(ENotifyAll,status2);
|
sl@0
|
456 |
fs1.NotifyChange(ENotifyAll,status3);
|
sl@0
|
457 |
fs1.NotifyChange(ENotifyAll,status4);
|
sl@0
|
458 |
fs1.NotifyChange(ENotifyAll,status5);
|
sl@0
|
459 |
test(status1==KRequestPending);
|
sl@0
|
460 |
test(status2==KRequestPending);
|
sl@0
|
461 |
test(status3==KRequestPending);
|
sl@0
|
462 |
test(status4==KRequestPending);
|
sl@0
|
463 |
test(status5==KRequestPending);
|
sl@0
|
464 |
|
sl@0
|
465 |
// Cancel the outstanding request with status5
|
sl@0
|
466 |
test.Next(_L("RFs::NotifyCancel()"));
|
sl@0
|
467 |
fs1.NotifyChangeCancel(status5);
|
sl@0
|
468 |
User::WaitForRequest(status5);
|
sl@0
|
469 |
test(status1==KRequestPending);
|
sl@0
|
470 |
test(status2==KRequestPending);
|
sl@0
|
471 |
test(status3==KRequestPending);
|
sl@0
|
472 |
test(status4==KRequestPending);
|
sl@0
|
473 |
test(status5==KErrCancel);
|
sl@0
|
474 |
|
sl@0
|
475 |
fs1.NotifyChangeCancel(status2);
|
sl@0
|
476 |
User::WaitForRequest(status2);
|
sl@0
|
477 |
|
sl@0
|
478 |
test(status1==KRequestPending);
|
sl@0
|
479 |
test(status2==KErrCancel);
|
sl@0
|
480 |
test(status3==KRequestPending);
|
sl@0
|
481 |
test(status4==KRequestPending);
|
sl@0
|
482 |
|
sl@0
|
483 |
fs1.NotifyChangeCancel(status4);
|
sl@0
|
484 |
User::WaitForRequest(status4);
|
sl@0
|
485 |
test(status1==KRequestPending);
|
sl@0
|
486 |
test(status3==KRequestPending);
|
sl@0
|
487 |
test(status4==KErrCancel);
|
sl@0
|
488 |
|
sl@0
|
489 |
fs1.NotifyChangeCancel(status4); // Test no side effects on trying to cancel a request
|
sl@0
|
490 |
test(status4==KErrCancel); // that has already been cancelled
|
sl@0
|
491 |
|
sl@0
|
492 |
fs1.NotifyChangeCancel(status1);
|
sl@0
|
493 |
User::WaitForRequest(status1);
|
sl@0
|
494 |
test(status1==KErrCancel);
|
sl@0
|
495 |
test(status3==KRequestPending);
|
sl@0
|
496 |
fs1.NotifyChangeCancel(status1); // Test no side effects on trying to cancel a request
|
sl@0
|
497 |
test(status1==KErrCancel); // that has already been cancelled
|
sl@0
|
498 |
|
sl@0
|
499 |
fs1.NotifyChangeCancel(status3);
|
sl@0
|
500 |
User::WaitForRequest(status3);
|
sl@0
|
501 |
test(status3==KErrCancel);
|
sl@0
|
502 |
|
sl@0
|
503 |
fs1.Close();
|
sl@0
|
504 |
}
|
sl@0
|
505 |
|
sl@0
|
506 |
static void Test4()
|
sl@0
|
507 |
//
|
sl@0
|
508 |
// Test notify client death
|
sl@0
|
509 |
//
|
sl@0
|
510 |
{
|
sl@0
|
511 |
|
sl@0
|
512 |
test.Next(_L("Kill client"));
|
sl@0
|
513 |
TInt r=gSleepThread.CreateLocal(0);
|
sl@0
|
514 |
test(r==KErrNone);
|
sl@0
|
515 |
RThread clientThread;
|
sl@0
|
516 |
r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest4);
|
sl@0
|
517 |
if (r!=KErrNone)
|
sl@0
|
518 |
{
|
sl@0
|
519 |
test.Printf(_L(" ERROR: Failed to create clientthread %d\n"),r);
|
sl@0
|
520 |
test(0);
|
sl@0
|
521 |
//test.Getch();
|
sl@0
|
522 |
return;
|
sl@0
|
523 |
}
|
sl@0
|
524 |
clientThread.Resume();
|
sl@0
|
525 |
gSleepThread.Wait();
|
sl@0
|
526 |
|
sl@0
|
527 |
TBool jit = User::JustInTime();
|
sl@0
|
528 |
User::SetJustInTime(EFalse);
|
sl@0
|
529 |
clientThread.Panic(_L("Test client thread panic"),KErrGeneral);
|
sl@0
|
530 |
User::SetJustInTime(jit);
|
sl@0
|
531 |
|
sl@0
|
532 |
clientThread.Close();
|
sl@0
|
533 |
|
sl@0
|
534 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\"));
|
sl@0
|
535 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
536 |
MakeFile(_L("\\F32-TST\\NOTIFY\\NewFile.Txt"));
|
sl@0
|
537 |
User::After(1000);
|
sl@0
|
538 |
}
|
sl@0
|
539 |
|
sl@0
|
540 |
static void Test5()
|
sl@0
|
541 |
//
|
sl@0
|
542 |
// Test reads and writes do not cause notification
|
sl@0
|
543 |
//
|
sl@0
|
544 |
{
|
sl@0
|
545 |
|
sl@0
|
546 |
test.Next(_L("Test reads and writes do not cause notification"));
|
sl@0
|
547 |
|
sl@0
|
548 |
|
sl@0
|
549 |
RFile file;
|
sl@0
|
550 |
TInt r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
|
sl@0
|
551 |
test(r==KErrNone);
|
sl@0
|
552 |
file.Close();
|
sl@0
|
553 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\koala.txt"),EFileRead|EFileWrite);
|
sl@0
|
554 |
test(r==KErrNone);
|
sl@0
|
555 |
file.Close();
|
sl@0
|
556 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\dingo.txt"),EFileRead|EFileWrite);
|
sl@0
|
557 |
test(r==KErrNone);
|
sl@0
|
558 |
file.Close();
|
sl@0
|
559 |
|
sl@0
|
560 |
TRequestStatus reqStat=0;
|
sl@0
|
561 |
TheFs.NotifyChange(ENotifyEntry,reqStat);
|
sl@0
|
562 |
test(reqStat==KRequestPending);
|
sl@0
|
563 |
|
sl@0
|
564 |
r=gSleepThread.CreateLocal(0);
|
sl@0
|
565 |
test(r==KErrNone);
|
sl@0
|
566 |
RThread clientThread;
|
sl@0
|
567 |
r=clientThread.Create(_L("Test5Thread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
|
sl@0
|
568 |
test(r==KErrNone);
|
sl@0
|
569 |
clientThread.Resume();
|
sl@0
|
570 |
gSleepThread.Wait();
|
sl@0
|
571 |
test(reqStat==KRequestPending);
|
sl@0
|
572 |
|
sl@0
|
573 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
|
sl@0
|
574 |
test(r==KErrNone);
|
sl@0
|
575 |
User::WaitForRequest(reqStat);
|
sl@0
|
576 |
test(reqStat==KErrNone);
|
sl@0
|
577 |
|
sl@0
|
578 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\koala.txt"));
|
sl@0
|
579 |
test(r==KErrNone);
|
sl@0
|
580 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\dingo.txt"));
|
sl@0
|
581 |
test(r==KErrNone);
|
sl@0
|
582 |
|
sl@0
|
583 |
|
sl@0
|
584 |
|
sl@0
|
585 |
gSleepThread.Close();
|
sl@0
|
586 |
clientThread.Close();
|
sl@0
|
587 |
}
|
sl@0
|
588 |
|
sl@0
|
589 |
#if defined (__EPOC32__)//we have no removable media on Emulator yet .. ??? we do now
|
sl@0
|
590 |
static void Test6()
|
sl@0
|
591 |
//
|
sl@0
|
592 |
// Test media change notification
|
sl@0
|
593 |
//
|
sl@0
|
594 |
{
|
sl@0
|
595 |
TDriveInfo driveInfo;
|
sl@0
|
596 |
TInt r=TheFs.Drive(driveInfo,CurrentDrive());
|
sl@0
|
597 |
test(r==KErrNone);
|
sl@0
|
598 |
// only test on removable media
|
sl@0
|
599 |
if (driveInfo.iDriveAtt&KDriveAttRemovable)
|
sl@0
|
600 |
{
|
sl@0
|
601 |
TBuf<64> b;
|
sl@0
|
602 |
b.Format(_L("Test Media change notification (socket:%d)"),gSocketNumber);
|
sl@0
|
603 |
test.Next(b);
|
sl@0
|
604 |
TRequestStatus reqStat=0;
|
sl@0
|
605 |
TInt r;
|
sl@0
|
606 |
TheFs.NotifyChange(ENotifyEntry,reqStat);
|
sl@0
|
607 |
test(reqStat==KRequestPending);
|
sl@0
|
608 |
r=gSleepThread.CreateLocal(0);
|
sl@0
|
609 |
test(r==KErrNone);
|
sl@0
|
610 |
RThread clientThread;
|
sl@0
|
611 |
r=clientThread.Create(_L("Test6Thread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest6);
|
sl@0
|
612 |
test(r==KErrNone);
|
sl@0
|
613 |
clientThread.Resume();
|
sl@0
|
614 |
gSleepThread.Wait();
|
sl@0
|
615 |
TInt reqInt=reqStat.Int();
|
sl@0
|
616 |
test(reqInt==KErrNone);
|
sl@0
|
617 |
User::WaitForRequest(reqStat);
|
sl@0
|
618 |
WaitForMediaChange();
|
sl@0
|
619 |
gSleepThread.Close();
|
sl@0
|
620 |
clientThread.Close();
|
sl@0
|
621 |
}
|
sl@0
|
622 |
|
sl@0
|
623 |
//-- it seems that after generating media change the meia driver isn't ready for some time
|
sl@0
|
624 |
User::After(2000000);
|
sl@0
|
625 |
r=TheFs.Drive(driveInfo,CurrentDrive());
|
sl@0
|
626 |
test(r==KErrNone);
|
sl@0
|
627 |
|
sl@0
|
628 |
|
sl@0
|
629 |
}
|
sl@0
|
630 |
#endif
|
sl@0
|
631 |
|
sl@0
|
632 |
static void Test7()
|
sl@0
|
633 |
//
|
sl@0
|
634 |
// Test Write to uid region does not trigger notification
|
sl@0
|
635 |
//
|
sl@0
|
636 |
{
|
sl@0
|
637 |
|
sl@0
|
638 |
test.Next(_L("Test Write to uid region does not trigger notification"));
|
sl@0
|
639 |
TRequestStatus reqStat=0;
|
sl@0
|
640 |
MakeFile(_L("NewFile.TXT"));
|
sl@0
|
641 |
TInt r;
|
sl@0
|
642 |
TheFs.NotifyChange(ENotifyEntry,reqStat);
|
sl@0
|
643 |
test(reqStat==KRequestPending);
|
sl@0
|
644 |
|
sl@0
|
645 |
r=gSleepThread.CreateLocal(0);
|
sl@0
|
646 |
test(r==KErrNone);
|
sl@0
|
647 |
RThread clientThread;
|
sl@0
|
648 |
r=clientThread.Create(_L("Test7Thread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest7);
|
sl@0
|
649 |
test(r==KErrNone);
|
sl@0
|
650 |
clientThread.Resume();
|
sl@0
|
651 |
gSleepThread.Wait();
|
sl@0
|
652 |
test(reqStat==KRequestPending);
|
sl@0
|
653 |
|
sl@0
|
654 |
r=TheFs.Delete(_L("Newfile.txt"));
|
sl@0
|
655 |
test(r==KErrNone);
|
sl@0
|
656 |
|
sl@0
|
657 |
User::WaitForRequest(reqStat);
|
sl@0
|
658 |
|
sl@0
|
659 |
gSleepThread.Close();
|
sl@0
|
660 |
clientThread.Close();
|
sl@0
|
661 |
}
|
sl@0
|
662 |
|
sl@0
|
663 |
#if defined (__EPOC32__)//we have no removable media on Emulator yet
|
sl@0
|
664 |
static void MediaChangeExtendedNotification()
|
sl@0
|
665 |
//
|
sl@0
|
666 |
// Test media change notification
|
sl@0
|
667 |
// Always notified of media change - regardless of requested TNotifyType
|
sl@0
|
668 |
//
|
sl@0
|
669 |
{
|
sl@0
|
670 |
TDriveInfo driveInfo;
|
sl@0
|
671 |
TInt r=TheFs.Drive(driveInfo,CurrentDrive());
|
sl@0
|
672 |
test(r==KErrNone);
|
sl@0
|
673 |
// only test on removable media
|
sl@0
|
674 |
if (driveInfo.iDriveAtt&KDriveAttRemovable)
|
sl@0
|
675 |
{
|
sl@0
|
676 |
test.Next(_L("Test Media change extended notification"));
|
sl@0
|
677 |
TRequestStatus reqStat=0;
|
sl@0
|
678 |
TFileName path = _L("\\F32-tst\\NOTIFY\\");
|
sl@0
|
679 |
TInt r;
|
sl@0
|
680 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
681 |
test(reqStat==KRequestPending);
|
sl@0
|
682 |
r=gSleepThread.CreateLocal(0);
|
sl@0
|
683 |
test(r==KErrNone);
|
sl@0
|
684 |
RThread clientThread;
|
sl@0
|
685 |
gSocketNumber=0;
|
sl@0
|
686 |
r=clientThread.Create(_L("Test6Thread1"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest6); //only generates a media change on removable media
|
sl@0
|
687 |
test(r==KErrNone);
|
sl@0
|
688 |
clientThread.Resume();
|
sl@0
|
689 |
gSleepThread.Wait();
|
sl@0
|
690 |
User::WaitForRequest(reqStat);
|
sl@0
|
691 |
test(reqStat==KErrNone);
|
sl@0
|
692 |
WaitForMediaChange();
|
sl@0
|
693 |
gSleepThread.Close();
|
sl@0
|
694 |
clientThread.Close();
|
sl@0
|
695 |
|
sl@0
|
696 |
//-- it seems that after generating media change the meia driver isn't ready for some time
|
sl@0
|
697 |
User::After(2000000);
|
sl@0
|
698 |
r=TheFs.Drive(driveInfo,CurrentDrive());
|
sl@0
|
699 |
test(r==KErrNone);
|
sl@0
|
700 |
|
sl@0
|
701 |
|
sl@0
|
702 |
TheFs.NotifyChange(ENotifyDisk,reqStat,path);
|
sl@0
|
703 |
test(reqStat==KRequestPending);
|
sl@0
|
704 |
r=gSleepThread.CreateLocal(0);
|
sl@0
|
705 |
test(r==KErrNone);
|
sl@0
|
706 |
r=clientThread.Create(_L("Test6Thread2"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest6);
|
sl@0
|
707 |
test(r==KErrNone);
|
sl@0
|
708 |
clientThread.Resume();
|
sl@0
|
709 |
gSleepThread.Wait();
|
sl@0
|
710 |
User::WaitForRequest(reqStat);
|
sl@0
|
711 |
test(reqStat==KErrNone);
|
sl@0
|
712 |
WaitForMediaChange();
|
sl@0
|
713 |
gSleepThread.Close();
|
sl@0
|
714 |
clientThread.Close();
|
sl@0
|
715 |
|
sl@0
|
716 |
//-- it seems that after generating media change the meia driver isn't ready for some time
|
sl@0
|
717 |
User::After(2000000);
|
sl@0
|
718 |
r=TheFs.Drive(driveInfo,CurrentDrive());
|
sl@0
|
719 |
test(r==KErrNone);
|
sl@0
|
720 |
|
sl@0
|
721 |
TheFs.NotifyChange(ENotifyWrite,reqStat,path);
|
sl@0
|
722 |
test(reqStat==KRequestPending);
|
sl@0
|
723 |
r=gSleepThread.CreateLocal(0);
|
sl@0
|
724 |
test(r==KErrNone);
|
sl@0
|
725 |
r=clientThread.Create(_L("Test6Thread3"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest6);
|
sl@0
|
726 |
test(r==KErrNone);
|
sl@0
|
727 |
clientThread.Resume();
|
sl@0
|
728 |
gSleepThread.Wait();
|
sl@0
|
729 |
User::WaitForRequest(reqStat);
|
sl@0
|
730 |
test(reqStat==KErrNone);
|
sl@0
|
731 |
WaitForMediaChange();
|
sl@0
|
732 |
gSleepThread.Close();
|
sl@0
|
733 |
clientThread.Close();
|
sl@0
|
734 |
|
sl@0
|
735 |
//-- it seems that after generating media change the meia driver isn't ready for some time
|
sl@0
|
736 |
User::After(2000000);
|
sl@0
|
737 |
r=TheFs.Drive(driveInfo,CurrentDrive());
|
sl@0
|
738 |
test(r==KErrNone);
|
sl@0
|
739 |
|
sl@0
|
740 |
}
|
sl@0
|
741 |
}
|
sl@0
|
742 |
#endif
|
sl@0
|
743 |
|
sl@0
|
744 |
static void TestRequestAhead()
|
sl@0
|
745 |
//
|
sl@0
|
746 |
// Test extended notification works when path initially does not exist
|
sl@0
|
747 |
//
|
sl@0
|
748 |
{
|
sl@0
|
749 |
test.Next(_L("Test Request Ahead"));
|
sl@0
|
750 |
// First a simple example
|
sl@0
|
751 |
|
sl@0
|
752 |
TInt r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\"));
|
sl@0
|
753 |
test((r==KErrNotFound)||(r==KErrPathNotFound)||(r==KErrNone));
|
sl@0
|
754 |
|
sl@0
|
755 |
TFileName path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\");
|
sl@0
|
756 |
TRequestStatus reqStat(KRequestPending);
|
sl@0
|
757 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
758 |
test(reqStat==KRequestPending);
|
sl@0
|
759 |
|
sl@0
|
760 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\"));
|
sl@0
|
761 |
test(r==KErrNone);
|
sl@0
|
762 |
|
sl@0
|
763 |
User::WaitForRequest(reqStat);
|
sl@0
|
764 |
test(reqStat==KErrNone);
|
sl@0
|
765 |
|
sl@0
|
766 |
path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\PayNoAttention.man");
|
sl@0
|
767 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
768 |
test(reqStat==KRequestPending);
|
sl@0
|
769 |
|
sl@0
|
770 |
RFile file;
|
sl@0
|
771 |
r=file.Replace(TheFs,path,EFileStream);
|
sl@0
|
772 |
test(r==KErrNone);
|
sl@0
|
773 |
file.Close();
|
sl@0
|
774 |
|
sl@0
|
775 |
User::WaitForRequest(reqStat);
|
sl@0
|
776 |
test(reqStat==KErrNone);
|
sl@0
|
777 |
|
sl@0
|
778 |
r=TheFs.Delete(path);
|
sl@0
|
779 |
test(r==KErrNone);
|
sl@0
|
780 |
|
sl@0
|
781 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
782 |
test(reqStat==KRequestPending);
|
sl@0
|
783 |
// Now cancel the outstanding request
|
sl@0
|
784 |
TheFs.NotifyChangeCancel(reqStat);
|
sl@0
|
785 |
User::WaitForRequest(reqStat);
|
sl@0
|
786 |
test(reqStat==KErrCancel);
|
sl@0
|
787 |
|
sl@0
|
788 |
// Repeat with a ENotifyFile request
|
sl@0
|
789 |
TheFs.NotifyChange(ENotifyFile,reqStat,path);
|
sl@0
|
790 |
test(reqStat==KRequestPending);
|
sl@0
|
791 |
|
sl@0
|
792 |
r=file.Replace(TheFs,path,EFileStream);
|
sl@0
|
793 |
test(r==KErrNone);
|
sl@0
|
794 |
file.Close();
|
sl@0
|
795 |
|
sl@0
|
796 |
User::WaitForRequest(reqStat);
|
sl@0
|
797 |
test(reqStat==KErrNone);
|
sl@0
|
798 |
|
sl@0
|
799 |
r=TheFs.Delete(path);
|
sl@0
|
800 |
test(r==KErrNone);
|
sl@0
|
801 |
|
sl@0
|
802 |
TheFs.NotifyChange(ENotifyFile,reqStat,path);
|
sl@0
|
803 |
test(reqStat==KRequestPending);
|
sl@0
|
804 |
// Now cancel the outstanding request
|
sl@0
|
805 |
TheFs.NotifyChangeCancel(reqStat);
|
sl@0
|
806 |
User::WaitForRequest(reqStat);
|
sl@0
|
807 |
test(reqStat==KErrCancel);
|
sl@0
|
808 |
|
sl@0
|
809 |
// Repeat with an ENotifyAttributes request
|
sl@0
|
810 |
TheFs.NotifyChange(ENotifyAttributes,reqStat,path);
|
sl@0
|
811 |
test(reqStat==KRequestPending);
|
sl@0
|
812 |
|
sl@0
|
813 |
r=file.Replace(TheFs,path,EFileStream);
|
sl@0
|
814 |
test(r==KErrNone);
|
sl@0
|
815 |
file.Close();
|
sl@0
|
816 |
|
sl@0
|
817 |
User::WaitForRequest(reqStat);
|
sl@0
|
818 |
test(reqStat==KErrNone); // Monitoring attributes but informed anyway
|
sl@0
|
819 |
|
sl@0
|
820 |
r=TheFs.Delete(path);
|
sl@0
|
821 |
test(r==KErrNone);
|
sl@0
|
822 |
|
sl@0
|
823 |
TheFs.NotifyChange(ENotifyAttributes,reqStat,path);
|
sl@0
|
824 |
test(reqStat==KRequestPending);
|
sl@0
|
825 |
// Now cancel the outstanding request
|
sl@0
|
826 |
TheFs.NotifyChangeCancel(reqStat);
|
sl@0
|
827 |
User::WaitForRequest(reqStat);
|
sl@0
|
828 |
test(reqStat==KErrCancel);
|
sl@0
|
829 |
|
sl@0
|
830 |
// Repeat with an ENotifyWrite request
|
sl@0
|
831 |
TheFs.NotifyChange(ENotifyWrite,reqStat,path);
|
sl@0
|
832 |
test(reqStat==KRequestPending);
|
sl@0
|
833 |
|
sl@0
|
834 |
r=file.Replace(TheFs,path,EFileStream);
|
sl@0
|
835 |
test(r==KErrNone);
|
sl@0
|
836 |
file.Close();
|
sl@0
|
837 |
|
sl@0
|
838 |
User::WaitForRequest(reqStat);
|
sl@0
|
839 |
test(reqStat==KErrNone); // Monitoring file writing but informed anyway
|
sl@0
|
840 |
|
sl@0
|
841 |
r=TheFs.Delete(path);
|
sl@0
|
842 |
test(r==KErrNone);
|
sl@0
|
843 |
|
sl@0
|
844 |
TheFs.NotifyChange(ENotifyWrite,reqStat,path);
|
sl@0
|
845 |
test(reqStat==KRequestPending);
|
sl@0
|
846 |
// Now cancel the outstanding request
|
sl@0
|
847 |
TheFs.NotifyChangeCancel(reqStat);
|
sl@0
|
848 |
User::WaitForRequest(reqStat);
|
sl@0
|
849 |
test(reqStat==KErrCancel);
|
sl@0
|
850 |
|
sl@0
|
851 |
// Repeat with an ENotifyDisk request
|
sl@0
|
852 |
TheFs.NotifyChange(ENotifyDisk,reqStat,path);
|
sl@0
|
853 |
test(reqStat==KRequestPending);
|
sl@0
|
854 |
|
sl@0
|
855 |
r=file.Replace(TheFs,path,EFileStream);
|
sl@0
|
856 |
test(r==KErrNone);
|
sl@0
|
857 |
file.Close();
|
sl@0
|
858 |
|
sl@0
|
859 |
User::WaitForRequest(reqStat);
|
sl@0
|
860 |
test(reqStat==KErrNone); // Monitoring disk activity but informed anyway
|
sl@0
|
861 |
|
sl@0
|
862 |
r=TheFs.Delete(path);
|
sl@0
|
863 |
test(r==KErrNone);
|
sl@0
|
864 |
|
sl@0
|
865 |
TheFs.NotifyChange(ENotifyAttributes,reqStat,path);
|
sl@0
|
866 |
test(reqStat==KRequestPending);
|
sl@0
|
867 |
// Now cancel the outstanding request
|
sl@0
|
868 |
TheFs.NotifyChangeCancel(reqStat);
|
sl@0
|
869 |
User::WaitForRequest(reqStat);
|
sl@0
|
870 |
test(reqStat==KErrCancel);
|
sl@0
|
871 |
|
sl@0
|
872 |
// Now do much the same with directory monitoring
|
sl@0
|
873 |
path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\");
|
sl@0
|
874 |
TheFs.RmDir(path);
|
sl@0
|
875 |
|
sl@0
|
876 |
TheFs.NotifyChange(ENotifyDir,reqStat,path);
|
sl@0
|
877 |
test(reqStat==KRequestPending);
|
sl@0
|
878 |
|
sl@0
|
879 |
TheFs.MkDir(path);
|
sl@0
|
880 |
test(r==KErrNone);
|
sl@0
|
881 |
|
sl@0
|
882 |
User::WaitForRequest(reqStat);
|
sl@0
|
883 |
test(reqStat==KErrNone);
|
sl@0
|
884 |
|
sl@0
|
885 |
TheFs.RmDir(path);
|
sl@0
|
886 |
test(r==KErrNone);
|
sl@0
|
887 |
|
sl@0
|
888 |
TheFs.NotifyChange(ENotifyDir,reqStat,path);
|
sl@0
|
889 |
test(r==KErrNone);
|
sl@0
|
890 |
test(reqStat==KRequestPending);
|
sl@0
|
891 |
|
sl@0
|
892 |
// Now cancel the outstanding request
|
sl@0
|
893 |
TheFs.NotifyChangeCancel(reqStat);
|
sl@0
|
894 |
User::WaitForRequest(reqStat);
|
sl@0
|
895 |
test(reqStat==KErrCancel);
|
sl@0
|
896 |
|
sl@0
|
897 |
TheFs.NotifyChange(ENotifyDir,reqStat,path);
|
sl@0
|
898 |
test(r==KErrNone);
|
sl@0
|
899 |
test(reqStat==KRequestPending);
|
sl@0
|
900 |
|
sl@0
|
901 |
// Get a separate thread to create the directory
|
sl@0
|
902 |
RThread thread;
|
sl@0
|
903 |
thread.Create(_L("RequestAheadyThready"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest10);
|
sl@0
|
904 |
TRequestStatus thrdStat(KRequestPending);
|
sl@0
|
905 |
thread.Logon(thrdStat);
|
sl@0
|
906 |
thread.Resume();
|
sl@0
|
907 |
thread.Close();
|
sl@0
|
908 |
|
sl@0
|
909 |
User::WaitForRequest(thrdStat);
|
sl@0
|
910 |
test(thrdStat==KErrNone);
|
sl@0
|
911 |
User::WaitForRequest(reqStat);
|
sl@0
|
912 |
test(reqStat==KErrNone);
|
sl@0
|
913 |
|
sl@0
|
914 |
TheFs.RmDir(path);
|
sl@0
|
915 |
test(r==KErrNone);
|
sl@0
|
916 |
|
sl@0
|
917 |
// Check that notification is not received for a non-existent file if only the previously
|
sl@0
|
918 |
// non existent directory that contains it is created
|
sl@0
|
919 |
path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\PayNoAttention.man");
|
sl@0
|
920 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
921 |
test(r==KErrNone);
|
sl@0
|
922 |
test(reqStat==KRequestPending);
|
sl@0
|
923 |
|
sl@0
|
924 |
thread.Create(_L("RequestAheadThread"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest10);
|
sl@0
|
925 |
thread.Logon(thrdStat);
|
sl@0
|
926 |
thread.Resume();
|
sl@0
|
927 |
thread.Close();
|
sl@0
|
928 |
|
sl@0
|
929 |
User::WaitForRequest(thrdStat);
|
sl@0
|
930 |
test(thrdStat==KErrNone);
|
sl@0
|
931 |
test(reqStat==KRequestPending);
|
sl@0
|
932 |
|
sl@0
|
933 |
// Now get a thread to create the file
|
sl@0
|
934 |
thread.Create(_L("RequestAhead"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest11);
|
sl@0
|
935 |
thread.Logon(thrdStat);
|
sl@0
|
936 |
thread.Resume();
|
sl@0
|
937 |
User::WaitForRequest(thrdStat);
|
sl@0
|
938 |
test(thrdStat==KErrNone);
|
sl@0
|
939 |
thread.Close();
|
sl@0
|
940 |
|
sl@0
|
941 |
User::WaitForRequest(reqStat);
|
sl@0
|
942 |
test(reqStat==KErrNone);
|
sl@0
|
943 |
|
sl@0
|
944 |
TheFs.Delete(path);
|
sl@0
|
945 |
test(r==KErrNone);
|
sl@0
|
946 |
|
sl@0
|
947 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
948 |
test(r==KErrNone);
|
sl@0
|
949 |
test(reqStat==KRequestPending);
|
sl@0
|
950 |
|
sl@0
|
951 |
// Now cancel the outstanding request
|
sl@0
|
952 |
TheFs.NotifyChangeCancel(reqStat);
|
sl@0
|
953 |
User::WaitForRequest(reqStat);
|
sl@0
|
954 |
test(reqStat==KErrCancel);
|
sl@0
|
955 |
|
sl@0
|
956 |
path=_L("\\F32-TST\\NOTIFY\\BehindTheCurtain\\");
|
sl@0
|
957 |
TheFs.RmDir(path);
|
sl@0
|
958 |
test(r==KErrNone);
|
sl@0
|
959 |
}
|
sl@0
|
960 |
|
sl@0
|
961 |
|
sl@0
|
962 |
static void Test8()
|
sl@0
|
963 |
//
|
sl@0
|
964 |
// Test extended notification of an entry change
|
sl@0
|
965 |
//
|
sl@0
|
966 |
{
|
sl@0
|
967 |
// Test notification of an entry change in directory F32-TST
|
sl@0
|
968 |
test.Next(_L("Test notification of an entry change"));
|
sl@0
|
969 |
TRequestStatus reqStat(KRequestPending);
|
sl@0
|
970 |
TRequestStatus thrdStat(KRequestPending);
|
sl@0
|
971 |
TFileName path=(_L("\\F32-TST\\"));
|
sl@0
|
972 |
|
sl@0
|
973 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
974 |
test(reqStat==KRequestPending);
|
sl@0
|
975 |
RThread thread;
|
sl@0
|
976 |
TInt r=thread.Create(_L("MyThread"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
|
sl@0
|
977 |
test(r==KErrNone);
|
sl@0
|
978 |
thread.Logon(thrdStat);
|
sl@0
|
979 |
thread.Resume();
|
sl@0
|
980 |
User::WaitForRequest(thrdStat);
|
sl@0
|
981 |
test(thrdStat==KErrNone);
|
sl@0
|
982 |
User::WaitForRequest(reqStat);
|
sl@0
|
983 |
test(reqStat==KErrNone);
|
sl@0
|
984 |
thread.Close();
|
sl@0
|
985 |
|
sl@0
|
986 |
// Repeat the test
|
sl@0
|
987 |
test.Next(_L("Repeat Test notification of an entry change"));
|
sl@0
|
988 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
989 |
test(reqStat==KRequestPending);
|
sl@0
|
990 |
r=thread.Create(_L("MyThread2"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
|
sl@0
|
991 |
test(r==KErrNone);
|
sl@0
|
992 |
thread.Logon(thrdStat);
|
sl@0
|
993 |
thread.Resume();
|
sl@0
|
994 |
User::WaitForRequest(thrdStat);
|
sl@0
|
995 |
test(thrdStat==KErrNone);
|
sl@0
|
996 |
User::WaitForRequest(reqStat);
|
sl@0
|
997 |
test(reqStat==KErrNone);
|
sl@0
|
998 |
thread.Close();
|
sl@0
|
999 |
|
sl@0
|
1000 |
// Test it can be cancelled
|
sl@0
|
1001 |
test.Next(_L("Test Notify cancel"));
|
sl@0
|
1002 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1003 |
test(reqStat==KRequestPending);
|
sl@0
|
1004 |
TheFs.NotifyChangeCancel();
|
sl@0
|
1005 |
User::WaitForRequest(reqStat);
|
sl@0
|
1006 |
test(reqStat==KErrCancel);
|
sl@0
|
1007 |
|
sl@0
|
1008 |
// Test it can be notified again
|
sl@0
|
1009 |
test.Next(_L("Test notification still works"));
|
sl@0
|
1010 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1011 |
test(reqStat==KRequestPending);
|
sl@0
|
1012 |
r=thread.Create(_L("MyThread3"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
|
sl@0
|
1013 |
test(r==KErrNone);
|
sl@0
|
1014 |
thread.Logon(thrdStat);
|
sl@0
|
1015 |
thread.Resume();
|
sl@0
|
1016 |
User::WaitForRequest(thrdStat);
|
sl@0
|
1017 |
test(thrdStat==KErrNone);
|
sl@0
|
1018 |
User::WaitForRequest(reqStat);
|
sl@0
|
1019 |
test(reqStat==KErrNone);
|
sl@0
|
1020 |
thread.Close();
|
sl@0
|
1021 |
|
sl@0
|
1022 |
// Test notification doesn't occur when a change occurs above the directory monitored
|
sl@0
|
1023 |
// (Notification of rename events occurring above the directory which affect the path
|
sl@0
|
1024 |
// will occur - this is tested for in Test18())
|
sl@0
|
1025 |
test.Next(_L("Test changing above monitored directory"));
|
sl@0
|
1026 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\"));
|
sl@0
|
1027 |
test((r==KErrNone)||(r==KErrAlreadyExists));
|
sl@0
|
1028 |
path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\");
|
sl@0
|
1029 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1030 |
test(reqStat==KRequestPending);
|
sl@0
|
1031 |
r=thread.Create(_L("MyThread4"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
|
sl@0
|
1032 |
test(r==KErrNone);
|
sl@0
|
1033 |
thread.Logon(thrdStat);
|
sl@0
|
1034 |
thread.Resume();
|
sl@0
|
1035 |
User::WaitForRequest(thrdStat);
|
sl@0
|
1036 |
test(thrdStat==KErrNone);
|
sl@0
|
1037 |
User::After(500000);
|
sl@0
|
1038 |
thread.Close();
|
sl@0
|
1039 |
test(reqStat==KRequestPending);
|
sl@0
|
1040 |
TheFs.NotifyChangeCancel();
|
sl@0
|
1041 |
User::WaitForRequest(reqStat);
|
sl@0
|
1042 |
test(reqStat==KErrCancel);
|
sl@0
|
1043 |
|
sl@0
|
1044 |
// Test notification occurs when a change is made to the subdirectory monitored
|
sl@0
|
1045 |
test.Next(_L("Create a file in monitored subdirectory"));
|
sl@0
|
1046 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1047 |
test(reqStat==KRequestPending);
|
sl@0
|
1048 |
r=thread.Create(_L("MyThread5"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest2);
|
sl@0
|
1049 |
test(r==KErrNone);
|
sl@0
|
1050 |
thread.Logon(thrdStat);
|
sl@0
|
1051 |
thread.Resume();
|
sl@0
|
1052 |
User::WaitForRequest(thrdStat);
|
sl@0
|
1053 |
test(thrdStat==KErrNone);
|
sl@0
|
1054 |
User::WaitForRequest(reqStat);
|
sl@0
|
1055 |
test(reqStat==KErrNone);
|
sl@0
|
1056 |
thread.Close();
|
sl@0
|
1057 |
|
sl@0
|
1058 |
test.Next(_L("Create a directory in monitored subdirectory"));
|
sl@0
|
1059 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1060 |
test(reqStat==KRequestPending);
|
sl@0
|
1061 |
r=thread.Create(_L("MyThread6"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest3);
|
sl@0
|
1062 |
test(r==KErrNone);
|
sl@0
|
1063 |
thread.Logon(thrdStat);
|
sl@0
|
1064 |
thread.Resume();
|
sl@0
|
1065 |
User::WaitForRequest(thrdStat);
|
sl@0
|
1066 |
test(thrdStat==KErrNone);
|
sl@0
|
1067 |
User::WaitForRequest(reqStat);
|
sl@0
|
1068 |
test(reqStat==KErrNone);
|
sl@0
|
1069 |
thread.Close();
|
sl@0
|
1070 |
|
sl@0
|
1071 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1072 |
test(reqStat==KRequestPending);
|
sl@0
|
1073 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\SCARECROW\\TINMAN\\"));
|
sl@0
|
1074 |
test(r==KErrNone);
|
sl@0
|
1075 |
User::WaitForRequest(reqStat);
|
sl@0
|
1076 |
test(reqStat==KErrNone);
|
sl@0
|
1077 |
|
sl@0
|
1078 |
|
sl@0
|
1079 |
r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\SCARECROW\\TINMAN\\"));
|
sl@0
|
1080 |
test(r==KErrNone);
|
sl@0
|
1081 |
r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\SCARECROW\\"));
|
sl@0
|
1082 |
test(r==KErrNone);
|
sl@0
|
1083 |
|
sl@0
|
1084 |
// Test again that notification doesn't occur above the subdirectory being monitored
|
sl@0
|
1085 |
test.Next(_L("Test changing above monitored directory"));
|
sl@0
|
1086 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\"));
|
sl@0
|
1087 |
test((r==KErrNone)||(r==KErrAlreadyExists));
|
sl@0
|
1088 |
path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\");
|
sl@0
|
1089 |
|
sl@0
|
1090 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1091 |
test(reqStat==KRequestPending);
|
sl@0
|
1092 |
r=thread.Create(_L("MyThread7"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
|
sl@0
|
1093 |
test(r==KErrNone);
|
sl@0
|
1094 |
thread.Logon(thrdStat);
|
sl@0
|
1095 |
thread.Resume();
|
sl@0
|
1096 |
User::WaitForRequest(thrdStat);
|
sl@0
|
1097 |
test(thrdStat==KErrNone);
|
sl@0
|
1098 |
User::After(500000);
|
sl@0
|
1099 |
thread.Close();
|
sl@0
|
1100 |
test(reqStat==KRequestPending);
|
sl@0
|
1101 |
TheFs.NotifyChangeCancel();
|
sl@0
|
1102 |
User::WaitForRequest(reqStat);
|
sl@0
|
1103 |
test(reqStat==KErrCancel);
|
sl@0
|
1104 |
|
sl@0
|
1105 |
// Test notification occurs when a change is made to the subdirectory monitored
|
sl@0
|
1106 |
test.Next(_L("Delete a file in monitored subdirectory"));
|
sl@0
|
1107 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1108 |
test(reqStat==KRequestPending);
|
sl@0
|
1109 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"));
|
sl@0
|
1110 |
test(r==KErrNone);
|
sl@0
|
1111 |
User::WaitForRequest(reqStat);
|
sl@0
|
1112 |
test(reqStat==KErrNone);
|
sl@0
|
1113 |
|
sl@0
|
1114 |
RFile file;
|
sl@0
|
1115 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.msg"),EFileStream);
|
sl@0
|
1116 |
test(r==KErrNone);
|
sl@0
|
1117 |
file.Close();
|
sl@0
|
1118 |
|
sl@0
|
1119 |
// Test notification on a specific file
|
sl@0
|
1120 |
test.Next(_L("Monitor changes to a specific file"));
|
sl@0
|
1121 |
path+=_L("WickedWitch.msg");
|
sl@0
|
1122 |
TheFs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
1123 |
test(reqStat==KRequestPending);
|
sl@0
|
1124 |
r=thread.Create(_L("MyThread8"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest8);
|
sl@0
|
1125 |
test(r==KErrNone);
|
sl@0
|
1126 |
thread.Logon(thrdStat);
|
sl@0
|
1127 |
thread.Resume();
|
sl@0
|
1128 |
User::WaitForRequest(thrdStat);
|
sl@0
|
1129 |
test(thrdStat==KErrNone);
|
sl@0
|
1130 |
User::WaitForRequest(reqStat);
|
sl@0
|
1131 |
test(reqStat==KErrNone);
|
sl@0
|
1132 |
thread.Close();
|
sl@0
|
1133 |
|
sl@0
|
1134 |
// Test notification does not occur if a change is made above the file
|
sl@0
|
1135 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1136 |
test(reqStat==KRequestPending);
|
sl@0
|
1137 |
thread.Create(_L("MyThread9"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest2);
|
sl@0
|
1138 |
thread.Logon(thrdStat);
|
sl@0
|
1139 |
thread.Resume();
|
sl@0
|
1140 |
User::WaitForRequest(thrdStat);
|
sl@0
|
1141 |
test(thrdStat==KErrNone);
|
sl@0
|
1142 |
User::After(500000);
|
sl@0
|
1143 |
thread.Close();
|
sl@0
|
1144 |
test(reqStat==KRequestPending);
|
sl@0
|
1145 |
TheFs.NotifyChangeCancel();
|
sl@0
|
1146 |
User::WaitForRequest(reqStat);
|
sl@0
|
1147 |
test(reqStat==KErrCancel);
|
sl@0
|
1148 |
|
sl@0
|
1149 |
// Test notification occurs when a change is made to the file
|
sl@0
|
1150 |
test.Next(_L("Delete monitored file"));
|
sl@0
|
1151 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1152 |
test(reqStat==KRequestPending);
|
sl@0
|
1153 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.Msg"));
|
sl@0
|
1154 |
test(r==KErrNone);
|
sl@0
|
1155 |
User::WaitForRequest(reqStat);
|
sl@0
|
1156 |
test(reqStat==KErrNone);
|
sl@0
|
1157 |
|
sl@0
|
1158 |
// Test notification request is now submitted on the non existent path successfully
|
sl@0
|
1159 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1160 |
test(reqStat==KRequestPending);
|
sl@0
|
1161 |
TheFs.NotifyChangeCancel(reqStat);
|
sl@0
|
1162 |
User::WaitForRequest(reqStat);
|
sl@0
|
1163 |
test(reqStat==KErrCancel);
|
sl@0
|
1164 |
|
sl@0
|
1165 |
path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.Doc");
|
sl@0
|
1166 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1167 |
test(reqStat==KRequestPending);
|
sl@0
|
1168 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.Doc"));
|
sl@0
|
1169 |
test(r==KErrNone);
|
sl@0
|
1170 |
User::WaitForRequest(reqStat);
|
sl@0
|
1171 |
test(reqStat==KErrNone);
|
sl@0
|
1172 |
|
sl@0
|
1173 |
path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\");
|
sl@0
|
1174 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1175 |
test(reqStat==KRequestPending);
|
sl@0
|
1176 |
r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\"));
|
sl@0
|
1177 |
test(r==KErrNone);
|
sl@0
|
1178 |
User::WaitForRequest(reqStat);
|
sl@0
|
1179 |
test(reqStat==KErrNone);
|
sl@0
|
1180 |
|
sl@0
|
1181 |
// Submit a request for a path which does not yet exist
|
sl@0
|
1182 |
path=_L("\\F32-TST\\NOTIFY\\GOOD_WITCH\\");
|
sl@0
|
1183 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1184 |
test(reqStat==KRequestPending);
|
sl@0
|
1185 |
// Now create the directory we are waiting on
|
sl@0
|
1186 |
r=TheFs.MkDir(path);
|
sl@0
|
1187 |
test(r==KErrNone);
|
sl@0
|
1188 |
// Make sure the notification has now been received
|
sl@0
|
1189 |
User::WaitForRequest(reqStat);
|
sl@0
|
1190 |
test(reqStat==KErrNone);
|
sl@0
|
1191 |
|
sl@0
|
1192 |
// Submit a request for a file which does not yet exist
|
sl@0
|
1193 |
path=_L("\\F32-TST\\NOTIFY\\GOOD_WITCH\\Red-Shoes.red");
|
sl@0
|
1194 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1195 |
test(reqStat==KRequestPending);
|
sl@0
|
1196 |
// Now create the file we are waiting on
|
sl@0
|
1197 |
r=file.Replace(TheFs,path,EFileStream);
|
sl@0
|
1198 |
test(r==KErrNone);
|
sl@0
|
1199 |
file.Close();
|
sl@0
|
1200 |
// Make sure the notification has now been received
|
sl@0
|
1201 |
User::WaitForRequest(reqStat);
|
sl@0
|
1202 |
test(reqStat==KErrNone);
|
sl@0
|
1203 |
// Submit another notification request and delete the file
|
sl@0
|
1204 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1205 |
test(reqStat==KRequestPending);
|
sl@0
|
1206 |
r=TheFs.Delete(path);
|
sl@0
|
1207 |
test(r==KErrNone);
|
sl@0
|
1208 |
User::WaitForRequest(reqStat);
|
sl@0
|
1209 |
test(reqStat==KErrNone);
|
sl@0
|
1210 |
path=_L("\\F32-TST\\NOTIFY\\GOOD_WITCH\\");
|
sl@0
|
1211 |
TheFs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1212 |
test(reqStat==KRequestPending);
|
sl@0
|
1213 |
r=TheFs.RmDir(path);
|
sl@0
|
1214 |
test(r==KErrNone);
|
sl@0
|
1215 |
User::WaitForRequest(reqStat);
|
sl@0
|
1216 |
test(reqStat==KErrNone);
|
sl@0
|
1217 |
// test passing in an empty string
|
sl@0
|
1218 |
TheFs.NotifyChange(ENotifyEntry,reqStat,_L(""));
|
sl@0
|
1219 |
User::WaitForRequest(reqStat);
|
sl@0
|
1220 |
test(reqStat==KErrArgument);
|
sl@0
|
1221 |
}
|
sl@0
|
1222 |
|
sl@0
|
1223 |
static void Test9()
|
sl@0
|
1224 |
//
|
sl@0
|
1225 |
// Test notify for multiple clients
|
sl@0
|
1226 |
//
|
sl@0
|
1227 |
{
|
sl@0
|
1228 |
|
sl@0
|
1229 |
test.Next(_L("Test notification of multiple clients"));
|
sl@0
|
1230 |
|
sl@0
|
1231 |
// Create five sessions monitoring various levels of a directory tree
|
sl@0
|
1232 |
|
sl@0
|
1233 |
TInt r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\ANIMAL\\"));
|
sl@0
|
1234 |
test((r==KErrNone)||(r==KErrAlreadyExists));
|
sl@0
|
1235 |
RFile file;
|
sl@0
|
1236 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\ANIMAL\\cat.txt"),EFileStream);
|
sl@0
|
1237 |
test(r==KErrNone);
|
sl@0
|
1238 |
file.Close();
|
sl@0
|
1239 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\ANIMAL\\dog.txt"),EFileStream);
|
sl@0
|
1240 |
test(r==KErrNone);
|
sl@0
|
1241 |
file.Close();
|
sl@0
|
1242 |
|
sl@0
|
1243 |
TFileName path1=_L("\\F32-TST\\");
|
sl@0
|
1244 |
TFileName path2=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
1245 |
TFileName path3=_L("\\F32-TST\\NOTIFY\\ANIMAL\\");
|
sl@0
|
1246 |
TFileName path4=_L("\\F32-TST\\NOTIFY\\ANIMAL\\cat.txt");
|
sl@0
|
1247 |
TFileName path5=_L("\\F32-TST\\NOTIFY\\ANIMAL\\dog.txt");
|
sl@0
|
1248 |
TFileName path6=_L("?:\\F32-TST\\");
|
sl@0
|
1249 |
|
sl@0
|
1250 |
TRequestStatus reqStat1(KRequestPending);
|
sl@0
|
1251 |
RFs fs1;
|
sl@0
|
1252 |
r=fs1.Connect();
|
sl@0
|
1253 |
test(r==KErrNone);
|
sl@0
|
1254 |
r=fs1.SetSessionPath(gSessionPath);
|
sl@0
|
1255 |
test(r==KErrNone);
|
sl@0
|
1256 |
fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
|
sl@0
|
1257 |
|
sl@0
|
1258 |
TRequestStatus reqStat2(KRequestPending);
|
sl@0
|
1259 |
RFs fs2;
|
sl@0
|
1260 |
r=fs2.Connect();
|
sl@0
|
1261 |
test(r==KErrNone);
|
sl@0
|
1262 |
r=fs2.SetSessionPath(gSessionPath);
|
sl@0
|
1263 |
test(r==KErrNone);
|
sl@0
|
1264 |
fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
|
sl@0
|
1265 |
|
sl@0
|
1266 |
TRequestStatus reqStat3(KRequestPending);
|
sl@0
|
1267 |
RFs fs3;
|
sl@0
|
1268 |
r=fs3.Connect();
|
sl@0
|
1269 |
test(r==KErrNone);
|
sl@0
|
1270 |
r=fs3.SetSessionPath(gSessionPath);
|
sl@0
|
1271 |
test(r==KErrNone);
|
sl@0
|
1272 |
fs3.NotifyChange(ENotifyEntry,reqStat3,path3);
|
sl@0
|
1273 |
|
sl@0
|
1274 |
TRequestStatus reqStat4(KRequestPending);
|
sl@0
|
1275 |
RFs fs4;
|
sl@0
|
1276 |
r=fs4.Connect();
|
sl@0
|
1277 |
test(r==KErrNone);
|
sl@0
|
1278 |
r=fs4.SetSessionPath(gSessionPath);
|
sl@0
|
1279 |
test(r==KErrNone);
|
sl@0
|
1280 |
fs4.NotifyChange(ENotifyEntry,reqStat4,path4);
|
sl@0
|
1281 |
|
sl@0
|
1282 |
TRequestStatus reqStat5(KRequestPending);
|
sl@0
|
1283 |
RFs fs5;
|
sl@0
|
1284 |
r=fs5.Connect();
|
sl@0
|
1285 |
test(r==KErrNone);
|
sl@0
|
1286 |
r=fs5.SetSessionPath(gSessionPath);
|
sl@0
|
1287 |
test(r==KErrNone);
|
sl@0
|
1288 |
fs5.NotifyChange(ENotifyEntry,reqStat5,path5);
|
sl@0
|
1289 |
|
sl@0
|
1290 |
TRequestStatus reqStat6(KRequestPending);
|
sl@0
|
1291 |
RFs fs6;
|
sl@0
|
1292 |
r=fs6.Connect();
|
sl@0
|
1293 |
test(r==KErrNone);
|
sl@0
|
1294 |
r=fs6.SetSessionPath(gSessionPath);
|
sl@0
|
1295 |
test(r==KErrNone);
|
sl@0
|
1296 |
fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
|
sl@0
|
1297 |
|
sl@0
|
1298 |
test(reqStat1==KRequestPending);
|
sl@0
|
1299 |
test(reqStat2==KRequestPending);
|
sl@0
|
1300 |
test(reqStat3==KRequestPending);
|
sl@0
|
1301 |
test(reqStat4==KRequestPending);
|
sl@0
|
1302 |
test(reqStat5==KRequestPending);
|
sl@0
|
1303 |
test(reqStat6==KRequestPending);
|
sl@0
|
1304 |
|
sl@0
|
1305 |
// Make a change a the top level and check that only the session monitoring
|
sl@0
|
1306 |
// that level is notified
|
sl@0
|
1307 |
test.Next(_L("Test only client monitoring top level is notified"));
|
sl@0
|
1308 |
r=file.Replace(TheFs,_L("\\F32-TST\\NewFile.txt"),EFileStream);
|
sl@0
|
1309 |
test(r==KErrNone);
|
sl@0
|
1310 |
file.Close();
|
sl@0
|
1311 |
User::WaitForRequest(reqStat1);
|
sl@0
|
1312 |
test(reqStat1==KErrNone);
|
sl@0
|
1313 |
test(reqStat2==KRequestPending);
|
sl@0
|
1314 |
test(reqStat3==KRequestPending);
|
sl@0
|
1315 |
test(reqStat4==KRequestPending);
|
sl@0
|
1316 |
test(reqStat5==KRequestPending);
|
sl@0
|
1317 |
User::WaitForRequest(reqStat6);
|
sl@0
|
1318 |
test(reqStat6==KErrNone);
|
sl@0
|
1319 |
|
sl@0
|
1320 |
r=TheFs.Delete(_L("\\F32-TST\\NewFile.txt"));
|
sl@0
|
1321 |
test(r==KErrNone);
|
sl@0
|
1322 |
|
sl@0
|
1323 |
// Renew the notify request at the top level and make a change one step lower
|
sl@0
|
1324 |
fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
|
sl@0
|
1325 |
fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
|
sl@0
|
1326 |
test(reqStat1==KRequestPending);
|
sl@0
|
1327 |
test(reqStat6==KRequestPending);
|
sl@0
|
1328 |
|
sl@0
|
1329 |
test.Next(_L("Test clients monitoring levels 1 and 2 are notified"));
|
sl@0
|
1330 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileStream);
|
sl@0
|
1331 |
test(r==KErrNone);
|
sl@0
|
1332 |
file.Close();
|
sl@0
|
1333 |
|
sl@0
|
1334 |
User::WaitForRequest(reqStat1);
|
sl@0
|
1335 |
User::WaitForRequest(reqStat2);
|
sl@0
|
1336 |
test(reqStat1==KErrNone);
|
sl@0
|
1337 |
test(reqStat2==KErrNone);
|
sl@0
|
1338 |
test(reqStat3==KRequestPending);
|
sl@0
|
1339 |
test(reqStat4==KRequestPending);
|
sl@0
|
1340 |
test(reqStat5==KRequestPending);
|
sl@0
|
1341 |
User::WaitForRequest(reqStat6);
|
sl@0
|
1342 |
test(reqStat6==KErrNone);
|
sl@0
|
1343 |
|
sl@0
|
1344 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\NewFile.txt"));
|
sl@0
|
1345 |
test(r==KErrNone);
|
sl@0
|
1346 |
|
sl@0
|
1347 |
// Renew the notify request at the top and second levels and make a change
|
sl@0
|
1348 |
// one step lower still
|
sl@0
|
1349 |
fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
|
sl@0
|
1350 |
fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
|
sl@0
|
1351 |
fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
|
sl@0
|
1352 |
test(reqStat1==KRequestPending);
|
sl@0
|
1353 |
test(reqStat2==KRequestPending);
|
sl@0
|
1354 |
test(reqStat6==KRequestPending);
|
sl@0
|
1355 |
|
sl@0
|
1356 |
test.Next(_L("Test clients monitoring levels 1,2 and 3 are notified"));
|
sl@0
|
1357 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\ANIMAL\\NewFile.txt"),EFileStream);
|
sl@0
|
1358 |
test(r==KErrNone);
|
sl@0
|
1359 |
file.Close();
|
sl@0
|
1360 |
|
sl@0
|
1361 |
User::WaitForRequest(reqStat1);
|
sl@0
|
1362 |
User::WaitForRequest(reqStat2);
|
sl@0
|
1363 |
User::WaitForRequest(reqStat3);
|
sl@0
|
1364 |
test(reqStat1==KErrNone);
|
sl@0
|
1365 |
test(reqStat2==KErrNone);
|
sl@0
|
1366 |
test(reqStat3==KErrNone);
|
sl@0
|
1367 |
test(reqStat4==KRequestPending);
|
sl@0
|
1368 |
test(reqStat5==KRequestPending);
|
sl@0
|
1369 |
User::WaitForRequest(reqStat6);
|
sl@0
|
1370 |
test(reqStat6==KErrNone);
|
sl@0
|
1371 |
|
sl@0
|
1372 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\ANIMAL\\NewFile.txt"));
|
sl@0
|
1373 |
test(r==KErrNone);
|
sl@0
|
1374 |
|
sl@0
|
1375 |
// Renew the notify request at the top, second and third levels and make a change
|
sl@0
|
1376 |
// one step lower still
|
sl@0
|
1377 |
fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
|
sl@0
|
1378 |
fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
|
sl@0
|
1379 |
fs3.NotifyChange(ENotifyEntry,reqStat3,path3);
|
sl@0
|
1380 |
fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
|
sl@0
|
1381 |
test(reqStat1==KRequestPending);
|
sl@0
|
1382 |
test(reqStat2==KRequestPending);
|
sl@0
|
1383 |
test(reqStat3==KRequestPending);
|
sl@0
|
1384 |
test(reqStat6==KRequestPending);
|
sl@0
|
1385 |
|
sl@0
|
1386 |
test.Next(_L("Test clients monitoring levels 1 - 4 are notified"));
|
sl@0
|
1387 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\ANIMAL\\cat.txt"));
|
sl@0
|
1388 |
test(r==KErrNone);
|
sl@0
|
1389 |
User::WaitForRequest(reqStat1);
|
sl@0
|
1390 |
User::WaitForRequest(reqStat2);
|
sl@0
|
1391 |
User::WaitForRequest(reqStat3);
|
sl@0
|
1392 |
User::WaitForRequest(reqStat4);
|
sl@0
|
1393 |
test(reqStat1==KErrNone);
|
sl@0
|
1394 |
test(reqStat2==KErrNone);
|
sl@0
|
1395 |
test(reqStat3==KErrNone);
|
sl@0
|
1396 |
test(reqStat4==KErrNone);
|
sl@0
|
1397 |
test(reqStat5==KRequestPending);
|
sl@0
|
1398 |
User::WaitForRequest(reqStat6);
|
sl@0
|
1399 |
test(reqStat6==KErrNone);
|
sl@0
|
1400 |
|
sl@0
|
1401 |
// Renew the notify request at the top, second and third levels and on the file deleted above
|
sl@0
|
1402 |
// which will be successful, but will not complete (for obvious reasons)
|
sl@0
|
1403 |
|
sl@0
|
1404 |
// Make a change one step lower still
|
sl@0
|
1405 |
fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
|
sl@0
|
1406 |
fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
|
sl@0
|
1407 |
fs3.NotifyChange(ENotifyEntry,reqStat3,path3);
|
sl@0
|
1408 |
fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
|
sl@0
|
1409 |
fs4.NotifyChange(ENotifyEntry,reqStat4,path4);
|
sl@0
|
1410 |
test(reqStat1==KRequestPending);
|
sl@0
|
1411 |
test(reqStat2==KRequestPending);
|
sl@0
|
1412 |
test(reqStat3==KRequestPending);
|
sl@0
|
1413 |
test(reqStat4==KRequestPending);
|
sl@0
|
1414 |
test(reqStat6==KRequestPending);
|
sl@0
|
1415 |
|
sl@0
|
1416 |
test.Next(_L("Test clients monitoring levels 1 - 3 and 5 are notified"));
|
sl@0
|
1417 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\ANIMAL\\dog.txt"));
|
sl@0
|
1418 |
test(r==KErrNone);
|
sl@0
|
1419 |
User::WaitForRequest(reqStat1);
|
sl@0
|
1420 |
User::WaitForRequest(reqStat2);
|
sl@0
|
1421 |
User::WaitForRequest(reqStat3);
|
sl@0
|
1422 |
// Don't wait for reqStat4
|
sl@0
|
1423 |
User::WaitForRequest(reqStat5);
|
sl@0
|
1424 |
User::WaitForRequest(reqStat6);
|
sl@0
|
1425 |
test(reqStat1==KErrNone);
|
sl@0
|
1426 |
test(reqStat2==KErrNone);
|
sl@0
|
1427 |
test(reqStat3==KErrNone);
|
sl@0
|
1428 |
test(reqStat4==KRequestPending); // File does not exist
|
sl@0
|
1429 |
test(reqStat5==KErrNone);
|
sl@0
|
1430 |
test(reqStat6==KErrNone);
|
sl@0
|
1431 |
|
sl@0
|
1432 |
fs4.NotifyChangeCancel(reqStat4);
|
sl@0
|
1433 |
User::WaitForRequest(reqStat4);
|
sl@0
|
1434 |
test(reqStat4==KErrCancel);
|
sl@0
|
1435 |
// Renew the notify request at the top, second and third levels and attempt to renew
|
sl@0
|
1436 |
// the request on the files deleted above (which will fail).
|
sl@0
|
1437 |
|
sl@0
|
1438 |
test.Next(_L("Test clients monitoring levels 1 - 3 are notified"));
|
sl@0
|
1439 |
fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
|
sl@0
|
1440 |
fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
|
sl@0
|
1441 |
fs3.NotifyChange(ENotifyEntry,reqStat3,path3);
|
sl@0
|
1442 |
fs4.NotifyChange(ENotifyEntry,reqStat4,path4);
|
sl@0
|
1443 |
fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
|
sl@0
|
1444 |
fs5.NotifyChange(ENotifyEntry,reqStat5,path5);
|
sl@0
|
1445 |
test(reqStat1==KRequestPending);
|
sl@0
|
1446 |
test(reqStat2==KRequestPending);
|
sl@0
|
1447 |
test(reqStat3==KRequestPending);
|
sl@0
|
1448 |
test(reqStat4==KRequestPending);
|
sl@0
|
1449 |
test(reqStat5==KRequestPending);
|
sl@0
|
1450 |
test(reqStat6==KRequestPending);
|
sl@0
|
1451 |
|
sl@0
|
1452 |
r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\ANIMAL\\"));
|
sl@0
|
1453 |
test(r==KErrNone);
|
sl@0
|
1454 |
User::WaitForRequest(reqStat1);
|
sl@0
|
1455 |
User::WaitForRequest(reqStat2);
|
sl@0
|
1456 |
User::WaitForRequest(reqStat3);
|
sl@0
|
1457 |
test(reqStat1==KErrNone);
|
sl@0
|
1458 |
test(reqStat2==KErrNone);
|
sl@0
|
1459 |
test(reqStat3==KErrNone);
|
sl@0
|
1460 |
test(reqStat4==KRequestPending);
|
sl@0
|
1461 |
test(reqStat5==KRequestPending);
|
sl@0
|
1462 |
User::WaitForRequest(reqStat6);
|
sl@0
|
1463 |
test(reqStat6==KErrNone);
|
sl@0
|
1464 |
|
sl@0
|
1465 |
// Renew the notify request at the top and second levels on the third level
|
sl@0
|
1466 |
// which was removed - it'll succeed but won't complete.
|
sl@0
|
1467 |
|
sl@0
|
1468 |
test.Next(_L("Test clients monitoring levels 1 and 2 are notified"));
|
sl@0
|
1469 |
test.Next(_L("Test clients' attempts to monitor levels 3-5 fail"));
|
sl@0
|
1470 |
fs1.NotifyChange(ENotifyEntry,reqStat1,path1);
|
sl@0
|
1471 |
fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
|
sl@0
|
1472 |
fs3.NotifyChange(ENotifyEntry,reqStat3,path3);
|
sl@0
|
1473 |
fs6.NotifyChange(ENotifyEntry,reqStat6,path6);
|
sl@0
|
1474 |
|
sl@0
|
1475 |
test(reqStat1==KRequestPending);
|
sl@0
|
1476 |
test(reqStat2==KRequestPending);
|
sl@0
|
1477 |
test(reqStat3==KRequestPending);
|
sl@0
|
1478 |
test(reqStat4==KRequestPending);
|
sl@0
|
1479 |
test(reqStat5==KRequestPending);
|
sl@0
|
1480 |
test(reqStat6==KRequestPending);
|
sl@0
|
1481 |
|
sl@0
|
1482 |
fs1.NotifyChangeCancel();
|
sl@0
|
1483 |
fs2.NotifyChangeCancel();
|
sl@0
|
1484 |
|
sl@0
|
1485 |
fs1.Close();
|
sl@0
|
1486 |
fs2.Close();
|
sl@0
|
1487 |
// Close the other sessions with requests outstanding to test that there's no evilness
|
sl@0
|
1488 |
fs3.Close();
|
sl@0
|
1489 |
fs4.Close();
|
sl@0
|
1490 |
fs5.Close();
|
sl@0
|
1491 |
fs6.Close();
|
sl@0
|
1492 |
|
sl@0
|
1493 |
User::WaitForRequest(reqStat1);
|
sl@0
|
1494 |
User::WaitForRequest(reqStat2);
|
sl@0
|
1495 |
// Closing file server sessions doesn't seem to complete notifications, is this a bug?
|
sl@0
|
1496 |
// User::WaitForRequest(reqStat3);
|
sl@0
|
1497 |
// User::WaitForRequest(reqStat4);
|
sl@0
|
1498 |
// User::WaitForRequest(reqStat5);
|
sl@0
|
1499 |
// User::WaitForRequest(reqStat6);
|
sl@0
|
1500 |
}
|
sl@0
|
1501 |
|
sl@0
|
1502 |
static void Test10()
|
sl@0
|
1503 |
//
|
sl@0
|
1504 |
// Test notify cancel
|
sl@0
|
1505 |
//
|
sl@0
|
1506 |
{
|
sl@0
|
1507 |
|
sl@0
|
1508 |
test.Next(_L("Cancel notification request using simple function"));
|
sl@0
|
1509 |
TFileName path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
1510 |
RFs fs1;
|
sl@0
|
1511 |
TInt r=fs1.Connect();
|
sl@0
|
1512 |
test(r==KErrNone);
|
sl@0
|
1513 |
r=fs1.SetSessionPath(gSessionPath);
|
sl@0
|
1514 |
test(r==KErrNone);
|
sl@0
|
1515 |
|
sl@0
|
1516 |
TRequestStatus status1;
|
sl@0
|
1517 |
TRequestStatus status2;
|
sl@0
|
1518 |
TRequestStatus status3;
|
sl@0
|
1519 |
TRequestStatus status4;
|
sl@0
|
1520 |
TRequestStatus status5;
|
sl@0
|
1521 |
|
sl@0
|
1522 |
fs1.NotifyChange(ENotifyAll,status1,path);
|
sl@0
|
1523 |
fs1.NotifyChange(ENotifyAll,status2,path);
|
sl@0
|
1524 |
fs1.NotifyChange(ENotifyAll,status3,path);
|
sl@0
|
1525 |
fs1.NotifyChange(ENotifyAll,status4,path);
|
sl@0
|
1526 |
fs1.NotifyChange(ENotifyAll,status5,path);
|
sl@0
|
1527 |
test(status1==KRequestPending);
|
sl@0
|
1528 |
test(status2==KRequestPending);
|
sl@0
|
1529 |
test(status3==KRequestPending);
|
sl@0
|
1530 |
test(status4==KRequestPending);
|
sl@0
|
1531 |
test(status5==KRequestPending);
|
sl@0
|
1532 |
|
sl@0
|
1533 |
test.Next(_L("RFs::NotifyCancel()"));
|
sl@0
|
1534 |
// Test that one call to RFs::NotifyCancel() cancels all outstanding requests
|
sl@0
|
1535 |
fs1.NotifyChangeCancel();
|
sl@0
|
1536 |
User::WaitForRequest(status1);
|
sl@0
|
1537 |
test(status1==KErrCancel);
|
sl@0
|
1538 |
User::WaitForRequest(status2);
|
sl@0
|
1539 |
test(status2==KErrCancel);
|
sl@0
|
1540 |
User::WaitForRequest(status3);
|
sl@0
|
1541 |
test(status3==KErrCancel);
|
sl@0
|
1542 |
User::WaitForRequest(status4);
|
sl@0
|
1543 |
test(status4==KErrCancel);
|
sl@0
|
1544 |
User::WaitForRequest(status5);
|
sl@0
|
1545 |
test(status5==KErrCancel);
|
sl@0
|
1546 |
// Call the cancel function again to check no further action
|
sl@0
|
1547 |
fs1.NotifyChangeCancel();
|
sl@0
|
1548 |
|
sl@0
|
1549 |
// Test overloaded function to cancel a single request
|
sl@0
|
1550 |
test.Next(_L("Cancel notification request using function overload"));
|
sl@0
|
1551 |
fs1.NotifyChange(ENotifyAll,status1,path);
|
sl@0
|
1552 |
fs1.NotifyChange(ENotifyAll,status2,path);
|
sl@0
|
1553 |
fs1.NotifyChange(ENotifyAll,status3,path);
|
sl@0
|
1554 |
fs1.NotifyChange(ENotifyAll,status4,path);
|
sl@0
|
1555 |
fs1.NotifyChange(ENotifyAll,status5,path);
|
sl@0
|
1556 |
test(status1==KRequestPending);
|
sl@0
|
1557 |
test(status2==KRequestPending);
|
sl@0
|
1558 |
test(status3==KRequestPending);
|
sl@0
|
1559 |
test(status4==KRequestPending);
|
sl@0
|
1560 |
test(status5==KRequestPending);
|
sl@0
|
1561 |
|
sl@0
|
1562 |
// Cancel the outstanding request with status5
|
sl@0
|
1563 |
test.Next(_L("RFs::NotifyCancel()"));
|
sl@0
|
1564 |
fs1.NotifyChangeCancel(status5);
|
sl@0
|
1565 |
User::WaitForRequest(status5);
|
sl@0
|
1566 |
test(status1==KRequestPending);
|
sl@0
|
1567 |
test(status2==KRequestPending);
|
sl@0
|
1568 |
test(status3==KRequestPending);
|
sl@0
|
1569 |
test(status4==KRequestPending);
|
sl@0
|
1570 |
test(status5==KErrCancel);
|
sl@0
|
1571 |
|
sl@0
|
1572 |
r=TheFs.MkDir(_L("\\F32-TST\\TROPICANA\\"));
|
sl@0
|
1573 |
test(r==KErrNone);
|
sl@0
|
1574 |
test(status1==KRequestPending);
|
sl@0
|
1575 |
test(status2==KRequestPending);
|
sl@0
|
1576 |
test(status3==KRequestPending);
|
sl@0
|
1577 |
test(status4==KRequestPending);
|
sl@0
|
1578 |
|
sl@0
|
1579 |
fs1.NotifyChangeCancel(status2);
|
sl@0
|
1580 |
User::WaitForRequest(status2);
|
sl@0
|
1581 |
|
sl@0
|
1582 |
test(status1==KRequestPending);
|
sl@0
|
1583 |
test(status2==KErrCancel);
|
sl@0
|
1584 |
test(status3==KRequestPending);
|
sl@0
|
1585 |
test(status4==KRequestPending);
|
sl@0
|
1586 |
|
sl@0
|
1587 |
r=TheFs.RmDir(_L("\\F32-TST\\TROPICANA\\"));
|
sl@0
|
1588 |
test(r==KErrNone);
|
sl@0
|
1589 |
test(status1==KRequestPending);
|
sl@0
|
1590 |
test(status3==KRequestPending);
|
sl@0
|
1591 |
test(status4==KRequestPending);
|
sl@0
|
1592 |
|
sl@0
|
1593 |
fs1.NotifyChangeCancel(status4);
|
sl@0
|
1594 |
User::WaitForRequest(status4);
|
sl@0
|
1595 |
test(status1==KRequestPending);
|
sl@0
|
1596 |
test(status3==KRequestPending);
|
sl@0
|
1597 |
test(status4==KErrCancel);
|
sl@0
|
1598 |
|
sl@0
|
1599 |
fs1.NotifyChangeCancel(status4); // Test no side effects on trying to cancel a request
|
sl@0
|
1600 |
test(status4==KErrCancel); // that has already been cancelled
|
sl@0
|
1601 |
|
sl@0
|
1602 |
fs1.NotifyChangeCancel(status1);
|
sl@0
|
1603 |
User::WaitForRequest(status1);
|
sl@0
|
1604 |
test(status1==KErrCancel);
|
sl@0
|
1605 |
test(status3==KRequestPending);
|
sl@0
|
1606 |
fs1.NotifyChangeCancel(status1); // Test no side effects on trying to cancel a request
|
sl@0
|
1607 |
test(status1==KErrCancel); // that has already been cancelled
|
sl@0
|
1608 |
|
sl@0
|
1609 |
fs1.NotifyChangeCancel(status3);
|
sl@0
|
1610 |
User::WaitForRequest(status3);
|
sl@0
|
1611 |
test(status3==KErrCancel);
|
sl@0
|
1612 |
|
sl@0
|
1613 |
fs1.Close();
|
sl@0
|
1614 |
}
|
sl@0
|
1615 |
|
sl@0
|
1616 |
static void Test11()
|
sl@0
|
1617 |
//
|
sl@0
|
1618 |
// Test notify client death
|
sl@0
|
1619 |
//
|
sl@0
|
1620 |
{
|
sl@0
|
1621 |
|
sl@0
|
1622 |
test.Next(_L("Kill client while it is monitoring changes to a directory"));
|
sl@0
|
1623 |
// Call CreateLocal to create RSemaphore gSleepThread which is local to this process
|
sl@0
|
1624 |
TInt r=gSleepThread.CreateLocal(0);
|
sl@0
|
1625 |
test(r==KErrNone);
|
sl@0
|
1626 |
|
sl@0
|
1627 |
RThread clientThread;
|
sl@0
|
1628 |
r=clientThread.Create(_L("ClientThread"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest9);
|
sl@0
|
1629 |
test(r==KErrNone);
|
sl@0
|
1630 |
clientThread.Resume();
|
sl@0
|
1631 |
gSleepThread.Wait(); // Wait for gSleepThread to be signalled
|
sl@0
|
1632 |
// Client thread is waiting for notification of changes
|
sl@0
|
1633 |
// to directory \\F32-TST\\NOTIFY
|
sl@0
|
1634 |
|
sl@0
|
1635 |
TBool jit = User::JustInTime();
|
sl@0
|
1636 |
User::SetJustInTime(EFalse);
|
sl@0
|
1637 |
clientThread.Panic(_L("Test client thread panic"),KErrGeneral); // Panic client
|
sl@0
|
1638 |
User::SetJustInTime(jit);
|
sl@0
|
1639 |
|
sl@0
|
1640 |
clientThread.Close();
|
sl@0
|
1641 |
|
sl@0
|
1642 |
// Make a change and check there's no disaster
|
sl@0
|
1643 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\"));
|
sl@0
|
1644 |
test(r==KErrNone || r==KErrAlreadyExists);
|
sl@0
|
1645 |
MakeFile(_L("\\F32-TST\\NOTIFY\\NewFile.Txt"));
|
sl@0
|
1646 |
User::After(1000);
|
sl@0
|
1647 |
}
|
sl@0
|
1648 |
|
sl@0
|
1649 |
|
sl@0
|
1650 |
static void Test12()
|
sl@0
|
1651 |
//
|
sl@0
|
1652 |
// Test reads and writes do not cause notification under ENotifyEntry
|
sl@0
|
1653 |
// Test reads and writes do cause notification under ENotifyAll
|
sl@0
|
1654 |
//
|
sl@0
|
1655 |
{
|
sl@0
|
1656 |
|
sl@0
|
1657 |
test.Next(_L("Test reads and writes do not cause notification under ENotifyEntry"));
|
sl@0
|
1658 |
|
sl@0
|
1659 |
RFile file;
|
sl@0
|
1660 |
TInt r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
|
sl@0
|
1661 |
test(r==KErrNone);
|
sl@0
|
1662 |
file.Close();
|
sl@0
|
1663 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\koala.txt"),EFileRead|EFileWrite);
|
sl@0
|
1664 |
test(r==KErrNone);
|
sl@0
|
1665 |
file.Close();
|
sl@0
|
1666 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\dingo.txt"),EFileRead|EFileWrite);
|
sl@0
|
1667 |
test(r==KErrNone);
|
sl@0
|
1668 |
file.Close();
|
sl@0
|
1669 |
|
sl@0
|
1670 |
TFileName path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
1671 |
TRequestStatus reqStat1(KRequestPending);
|
sl@0
|
1672 |
RFs fs1;
|
sl@0
|
1673 |
r=fs1.Connect();
|
sl@0
|
1674 |
test(r==KErrNone);
|
sl@0
|
1675 |
r=fs1.SetSessionPath(gSessionPath);
|
sl@0
|
1676 |
test(r==KErrNone);
|
sl@0
|
1677 |
fs1.NotifyChange(ENotifyEntry,reqStat1,path);
|
sl@0
|
1678 |
|
sl@0
|
1679 |
TRequestStatus reqStat2(KRequestPending);
|
sl@0
|
1680 |
RFs fs2;
|
sl@0
|
1681 |
r=fs2.Connect();
|
sl@0
|
1682 |
test(r==KErrNone);
|
sl@0
|
1683 |
r=fs2.SetSessionPath(gSessionPath);
|
sl@0
|
1684 |
test(r==KErrNone);
|
sl@0
|
1685 |
fs2.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
1686 |
|
sl@0
|
1687 |
TRequestStatus reqStat3(KRequestPending);
|
sl@0
|
1688 |
RFs fs3;
|
sl@0
|
1689 |
r=fs3.Connect();
|
sl@0
|
1690 |
test(r==KErrNone);
|
sl@0
|
1691 |
r=fs3.SetSessionPath(gSessionPath);
|
sl@0
|
1692 |
test(r==KErrNone);
|
sl@0
|
1693 |
fs3.NotifyChange(ENotifyEntry,reqStat3,path);
|
sl@0
|
1694 |
|
sl@0
|
1695 |
test(reqStat1==KRequestPending);
|
sl@0
|
1696 |
test(reqStat2==KRequestPending);
|
sl@0
|
1697 |
test(reqStat3==KRequestPending);
|
sl@0
|
1698 |
|
sl@0
|
1699 |
r=gSleepThread.CreateLocal(0);
|
sl@0
|
1700 |
test(r==KErrNone);
|
sl@0
|
1701 |
RThread thread1;
|
sl@0
|
1702 |
r=thread1.Create(_L("TestThread1"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
|
sl@0
|
1703 |
test(r==KErrNone);
|
sl@0
|
1704 |
thread1.Resume();
|
sl@0
|
1705 |
gSleepThread.Wait();
|
sl@0
|
1706 |
|
sl@0
|
1707 |
test(reqStat1==KRequestPending);
|
sl@0
|
1708 |
test(reqStat2==KRequestPending);
|
sl@0
|
1709 |
test(reqStat3==KRequestPending);
|
sl@0
|
1710 |
|
sl@0
|
1711 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
|
sl@0
|
1712 |
test(r==KErrNone);
|
sl@0
|
1713 |
User::WaitForRequest(reqStat1);
|
sl@0
|
1714 |
User::WaitForRequest(reqStat2);
|
sl@0
|
1715 |
User::WaitForRequest(reqStat3);
|
sl@0
|
1716 |
test(reqStat1==KErrNone); // All three notifications occur because they
|
sl@0
|
1717 |
test(reqStat2==KErrNone); // are all monitoring the top level directory
|
sl@0
|
1718 |
test(reqStat3==KErrNone); // Later, we'll test monitoring individual files...
|
sl@0
|
1719 |
|
sl@0
|
1720 |
gSleepThread.Close();
|
sl@0
|
1721 |
thread1.Close();
|
sl@0
|
1722 |
|
sl@0
|
1723 |
test.Next(_L("Test reads and writes do cause notification under ENotifyAll"));
|
sl@0
|
1724 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
|
sl@0
|
1725 |
test(r==KErrNone);
|
sl@0
|
1726 |
file.Close();
|
sl@0
|
1727 |
|
sl@0
|
1728 |
fs1.NotifyChange(ENotifyAll,reqStat1,path);
|
sl@0
|
1729 |
fs2.NotifyChange(ENotifyAll,reqStat2,path);
|
sl@0
|
1730 |
fs3.NotifyChange(ENotifyAll,reqStat3,path);
|
sl@0
|
1731 |
|
sl@0
|
1732 |
test(reqStat1==KRequestPending);
|
sl@0
|
1733 |
test(reqStat2==KRequestPending);
|
sl@0
|
1734 |
test(reqStat3==KRequestPending);
|
sl@0
|
1735 |
|
sl@0
|
1736 |
r=gSleepThread.CreateLocal(0);
|
sl@0
|
1737 |
test(r==KErrNone);
|
sl@0
|
1738 |
RThread thread2;
|
sl@0
|
1739 |
r=thread2.Create(_L("TestThread2"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
|
sl@0
|
1740 |
test(r==KErrNone);
|
sl@0
|
1741 |
thread2.Resume();
|
sl@0
|
1742 |
gSleepThread.Wait();
|
sl@0
|
1743 |
|
sl@0
|
1744 |
User::WaitForRequest(reqStat1);
|
sl@0
|
1745 |
User::WaitForRequest(reqStat2);
|
sl@0
|
1746 |
User::WaitForRequest(reqStat3);
|
sl@0
|
1747 |
test(reqStat1==KErrNone);
|
sl@0
|
1748 |
test(reqStat2==KErrNone);
|
sl@0
|
1749 |
test(reqStat3==KErrNone);
|
sl@0
|
1750 |
|
sl@0
|
1751 |
gSleepThread.Close();
|
sl@0
|
1752 |
thread2.Close();
|
sl@0
|
1753 |
|
sl@0
|
1754 |
test.Next(_L("Monitor reads and writes on specific files with either TNotifyType"));
|
sl@0
|
1755 |
TFileName path1=path;
|
sl@0
|
1756 |
TFileName path2=path;
|
sl@0
|
1757 |
TFileName path3=path;
|
sl@0
|
1758 |
path1+=_L("kangaroo.txt");
|
sl@0
|
1759 |
path2+=_L("koala.txt");
|
sl@0
|
1760 |
path3+=_L("dingo.txt");
|
sl@0
|
1761 |
|
sl@0
|
1762 |
fs1.NotifyChange(ENotifyAll,reqStat1,path1);
|
sl@0
|
1763 |
fs2.NotifyChange(ENotifyEntry,reqStat2,path2);
|
sl@0
|
1764 |
fs3.NotifyChange(ENotifyAll,reqStat3,path3);
|
sl@0
|
1765 |
|
sl@0
|
1766 |
test(reqStat1==KRequestPending);
|
sl@0
|
1767 |
test(reqStat2==KRequestPending);
|
sl@0
|
1768 |
test(reqStat3==KRequestPending);
|
sl@0
|
1769 |
|
sl@0
|
1770 |
r=gSleepThread.CreateLocal(0);
|
sl@0
|
1771 |
test(r==KErrNone);
|
sl@0
|
1772 |
RThread thread3;
|
sl@0
|
1773 |
r=thread3.Create(_L("TestThread3"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
|
sl@0
|
1774 |
test(r==KErrNone);
|
sl@0
|
1775 |
thread3.Resume();
|
sl@0
|
1776 |
gSleepThread.Wait();
|
sl@0
|
1777 |
|
sl@0
|
1778 |
User::WaitForRequest(reqStat1);
|
sl@0
|
1779 |
test(reqStat1==KErrNone);
|
sl@0
|
1780 |
test(reqStat2==KRequestPending); // Monitoring with ENotifyEntry
|
sl@0
|
1781 |
User::WaitForRequest(reqStat3);
|
sl@0
|
1782 |
test(reqStat3==KErrNone);
|
sl@0
|
1783 |
|
sl@0
|
1784 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\koala.txt"));
|
sl@0
|
1785 |
test(r==KErrNone);
|
sl@0
|
1786 |
User::WaitForRequest(reqStat2);
|
sl@0
|
1787 |
test(reqStat2==KErrNone);
|
sl@0
|
1788 |
|
sl@0
|
1789 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
|
sl@0
|
1790 |
test(r==KErrNone);
|
sl@0
|
1791 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\dingo.txt"));
|
sl@0
|
1792 |
test(r==KErrNone);
|
sl@0
|
1793 |
|
sl@0
|
1794 |
gSleepThread.Close();
|
sl@0
|
1795 |
thread3.Close();
|
sl@0
|
1796 |
fs1.Close();
|
sl@0
|
1797 |
fs2.Close();
|
sl@0
|
1798 |
fs3.Close();
|
sl@0
|
1799 |
}
|
sl@0
|
1800 |
|
sl@0
|
1801 |
|
sl@0
|
1802 |
static void Test13()
|
sl@0
|
1803 |
//
|
sl@0
|
1804 |
// Test file notification
|
sl@0
|
1805 |
//
|
sl@0
|
1806 |
{
|
sl@0
|
1807 |
RFs fs; // Session to be notified of any changes
|
sl@0
|
1808 |
TInt r=fs.Connect();
|
sl@0
|
1809 |
test(r==KErrNone);
|
sl@0
|
1810 |
r=fs.SetSessionPath(gSessionPath);
|
sl@0
|
1811 |
test(r==KErrNone);
|
sl@0
|
1812 |
|
sl@0
|
1813 |
|
sl@0
|
1814 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\"));
|
sl@0
|
1815 |
test(r==KErrNone||r==KErrAlreadyExists);
|
sl@0
|
1816 |
|
sl@0
|
1817 |
RFile file;
|
sl@0
|
1818 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.msg"),EFileStream);
|
sl@0
|
1819 |
test(r==KErrNone||KErrAlreadyExists);
|
sl@0
|
1820 |
file.Close();
|
sl@0
|
1821 |
|
sl@0
|
1822 |
// Test notification on a specific file
|
sl@0
|
1823 |
test.Next(_L("Monitor changes to a specific file"));
|
sl@0
|
1824 |
TFileName path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.msg");
|
sl@0
|
1825 |
TRequestStatus reqStat(KRequestPending);
|
sl@0
|
1826 |
TRequestStatus thrdStat(KRequestPending);
|
sl@0
|
1827 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
1828 |
test(reqStat==KRequestPending);
|
sl@0
|
1829 |
RThread thread;
|
sl@0
|
1830 |
r=thread.Create(_L("MyThread7"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest8);
|
sl@0
|
1831 |
test(r==KErrNone);
|
sl@0
|
1832 |
thread.Logon(thrdStat);
|
sl@0
|
1833 |
thread.Resume();
|
sl@0
|
1834 |
User::WaitForRequest(thrdStat);
|
sl@0
|
1835 |
test(thrdStat==KErrNone);
|
sl@0
|
1836 |
User::WaitForRequest(reqStat);
|
sl@0
|
1837 |
test(reqStat==KErrNone);
|
sl@0
|
1838 |
thread.Close();
|
sl@0
|
1839 |
// Test notification does not occur if a change is made above the file
|
sl@0
|
1840 |
fs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1841 |
test(reqStat==KRequestPending);
|
sl@0
|
1842 |
r=thread.Create(_L("MyThread8"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest1);
|
sl@0
|
1843 |
test(r==KErrNone);
|
sl@0
|
1844 |
thread.Logon(thrdStat);
|
sl@0
|
1845 |
thread.Resume();
|
sl@0
|
1846 |
User::WaitForRequest(thrdStat);
|
sl@0
|
1847 |
test(thrdStat==KErrNone);
|
sl@0
|
1848 |
User::After(500000);
|
sl@0
|
1849 |
thread.Close();
|
sl@0
|
1850 |
test(reqStat==KRequestPending);
|
sl@0
|
1851 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\NEWFILE.TXT"));
|
sl@0
|
1852 |
test(r==KErrNone);
|
sl@0
|
1853 |
|
sl@0
|
1854 |
// Test notification does not occur if a change is made to another file
|
sl@0
|
1855 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Lion.log"),EFileStream);
|
sl@0
|
1856 |
test(r==KErrNone);
|
sl@0
|
1857 |
test(reqStat==KRequestPending);
|
sl@0
|
1858 |
file.Close();
|
sl@0
|
1859 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Lion.log"));
|
sl@0
|
1860 |
test(r==KErrNone);
|
sl@0
|
1861 |
test(reqStat==KRequestPending);
|
sl@0
|
1862 |
|
sl@0
|
1863 |
|
sl@0
|
1864 |
// Test notification occurs when a change is made to the file
|
sl@0
|
1865 |
test.Next(_L("Delete monitored file"));
|
sl@0
|
1866 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\WickedWitch.Msg"));
|
sl@0
|
1867 |
test(r==KErrNone);
|
sl@0
|
1868 |
User::WaitForRequest(reqStat);
|
sl@0
|
1869 |
test(reqStat==KErrNone);
|
sl@0
|
1870 |
|
sl@0
|
1871 |
fs.Close();
|
sl@0
|
1872 |
}
|
sl@0
|
1873 |
|
sl@0
|
1874 |
static void Test14()
|
sl@0
|
1875 |
|
sl@0
|
1876 |
{
|
sl@0
|
1877 |
//
|
sl@0
|
1878 |
// Test notification request succeeds with all RFile and RFs operations which result in
|
sl@0
|
1879 |
// notifications
|
sl@0
|
1880 |
//
|
sl@0
|
1881 |
RFs fs;
|
sl@0
|
1882 |
TInt r=fs.Connect(); // Session to be notified of any changes
|
sl@0
|
1883 |
test(r==KErrNone);
|
sl@0
|
1884 |
r=fs.SetSessionPath(gSessionPath);
|
sl@0
|
1885 |
test(r==KErrNone);
|
sl@0
|
1886 |
|
sl@0
|
1887 |
// RFile::Write() to a file within the monitored directory
|
sl@0
|
1888 |
test.Next(_L("RFile::Write()"));
|
sl@0
|
1889 |
TFileName path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.Doc");
|
sl@0
|
1890 |
TRequestStatus reqStat(KRequestPending);
|
sl@0
|
1891 |
|
sl@0
|
1892 |
RFile file;
|
sl@0
|
1893 |
|
sl@0
|
1894 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
1895 |
test(reqStat==KRequestPending);
|
sl@0
|
1896 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
|
sl@0
|
1897 |
test(r==KErrNone);
|
sl@0
|
1898 |
User::WaitForRequest(reqStat);
|
sl@0
|
1899 |
test(reqStat==KErrNone);
|
sl@0
|
1900 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
1901 |
test(reqStat==KRequestPending);
|
sl@0
|
1902 |
r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
|
sl@0
|
1903 |
test(r==KErrNone);
|
sl@0
|
1904 |
file.Close();
|
sl@0
|
1905 |
User::WaitForRequest(reqStat);
|
sl@0
|
1906 |
test(reqStat==KErrNone);
|
sl@0
|
1907 |
|
sl@0
|
1908 |
// RFile::Read() a file within the monitored directory - no notification for reads
|
sl@0
|
1909 |
path=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\");
|
sl@0
|
1910 |
TBuf8<100> temp;
|
sl@0
|
1911 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
1912 |
test(reqStat==KRequestPending);
|
sl@0
|
1913 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
|
sl@0
|
1914 |
test(r==KErrNone);
|
sl@0
|
1915 |
test(reqStat==KRequestPending);
|
sl@0
|
1916 |
r=file.Read(0,temp,100);
|
sl@0
|
1917 |
test(reqStat==KRequestPending);
|
sl@0
|
1918 |
|
sl@0
|
1919 |
// RFile::SetAtt() of a file within the monitored directory
|
sl@0
|
1920 |
test.Next(_L("RFile::SetAtt()"));
|
sl@0
|
1921 |
r=file.SetAtt(KEntryAttSystem,KEntryAttNormal);
|
sl@0
|
1922 |
test(r==KErrNone);
|
sl@0
|
1923 |
User::WaitForRequest(reqStat);
|
sl@0
|
1924 |
test(reqStat==KErrNone);
|
sl@0
|
1925 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
1926 |
test(reqStat==KRequestPending);
|
sl@0
|
1927 |
|
sl@0
|
1928 |
// RFile::SetSize() of a file within the monitored directory
|
sl@0
|
1929 |
test.Next(_L("RFile::SetSize()"));
|
sl@0
|
1930 |
r=file.SetSize(256);
|
sl@0
|
1931 |
test(r==KErrNone);
|
sl@0
|
1932 |
User::WaitForRequest(reqStat);
|
sl@0
|
1933 |
test(reqStat==KErrNone);
|
sl@0
|
1934 |
file.Close();
|
sl@0
|
1935 |
|
sl@0
|
1936 |
// RFile::Temp() to create a temp file within the monitored directory
|
sl@0
|
1937 |
test.Next(_L("RFile::Temp()"));
|
sl@0
|
1938 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
1939 |
test(reqStat==KRequestPending);
|
sl@0
|
1940 |
TFileName fileName;
|
sl@0
|
1941 |
r=file.Temp(TheFs,path,fileName,EFileWrite);
|
sl@0
|
1942 |
test(r==KErrNone);
|
sl@0
|
1943 |
User::WaitForRequest(reqStat);
|
sl@0
|
1944 |
test(reqStat==KErrNone);
|
sl@0
|
1945 |
file.Close();
|
sl@0
|
1946 |
|
sl@0
|
1947 |
// RFile::SetModified() to change modification time of a file within monitored dir
|
sl@0
|
1948 |
test.Next(_L("RFile::SetModified()"));
|
sl@0
|
1949 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
1950 |
test(reqStat==KRequestPending);
|
sl@0
|
1951 |
TTime now;
|
sl@0
|
1952 |
now.HomeTime();
|
sl@0
|
1953 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
|
sl@0
|
1954 |
test(r==KErrNone);
|
sl@0
|
1955 |
test(reqStat==KRequestPending);
|
sl@0
|
1956 |
file.SetModified(now);
|
sl@0
|
1957 |
file.Close();
|
sl@0
|
1958 |
User::WaitForRequest(reqStat);
|
sl@0
|
1959 |
test(reqStat==KErrNone);
|
sl@0
|
1960 |
|
sl@0
|
1961 |
// RFs::SetEntry() to change a directory entry within the monitored directory
|
sl@0
|
1962 |
test.Next(_L("RFs::SetEntry()"));
|
sl@0
|
1963 |
TEntry entry;
|
sl@0
|
1964 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
1965 |
r=TheFs.Entry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),entry);
|
sl@0
|
1966 |
test(reqStat==KRequestPending);
|
sl@0
|
1967 |
now.HomeTime();
|
sl@0
|
1968 |
r=TheFs.SetEntry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),now,KEntryAttHidden,KEntryAttNormal);
|
sl@0
|
1969 |
test(r==KErrNone);
|
sl@0
|
1970 |
User::WaitForRequest(reqStat);
|
sl@0
|
1971 |
test(reqStat==KErrNone);
|
sl@0
|
1972 |
|
sl@0
|
1973 |
// RFile::Set() to change file's modification time and attributes
|
sl@0
|
1974 |
test.Next(_L("RFile::Set()"));
|
sl@0
|
1975 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
1976 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
|
sl@0
|
1977 |
test(r==KErrNone);
|
sl@0
|
1978 |
test(reqStat==KRequestPending);
|
sl@0
|
1979 |
now.HomeTime();
|
sl@0
|
1980 |
r=file.Set(now,KEntryAttNormal,KEntryAttHidden);
|
sl@0
|
1981 |
file.Close();
|
sl@0
|
1982 |
User::WaitForRequest(reqStat);
|
sl@0
|
1983 |
test(reqStat==KErrNone);
|
sl@0
|
1984 |
|
sl@0
|
1985 |
// RFs::SetDriveName()
|
sl@0
|
1986 |
test.Next(_L("RFs::SetDriveName()"));
|
sl@0
|
1987 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
1988 |
test(reqStat==KRequestPending);
|
sl@0
|
1989 |
User::After(KNotifyChangeAfter);
|
sl@0
|
1990 |
r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVETEST"));
|
sl@0
|
1991 |
test(r==KErrNone);
|
sl@0
|
1992 |
User::WaitForRequest(reqStat);
|
sl@0
|
1993 |
test(reqStat==KErrNone);
|
sl@0
|
1994 |
fs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
1995 |
User::After(KNotifyChangeAfter);
|
sl@0
|
1996 |
r=TheFs.SetDriveName(KDefaultDrive,_L("TEST"));
|
sl@0
|
1997 |
test(r==KErrNone);
|
sl@0
|
1998 |
test(reqStat==KRequestPending);
|
sl@0
|
1999 |
fs.NotifyChangeCancel(reqStat);
|
sl@0
|
2000 |
User::WaitForRequest(reqStat);
|
sl@0
|
2001 |
test(reqStat==KErrCancel);
|
sl@0
|
2002 |
fs.NotifyChange(ENotifyDisk,reqStat,path);
|
sl@0
|
2003 |
User::After(KNotifyChangeAfter);
|
sl@0
|
2004 |
r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVE"));
|
sl@0
|
2005 |
test(r==KErrNone);
|
sl@0
|
2006 |
test(reqStat==KRequestPending);
|
sl@0
|
2007 |
fs.NotifyChangeCancel(reqStat);
|
sl@0
|
2008 |
User::WaitForRequest(reqStat);
|
sl@0
|
2009 |
test(reqStat==KErrCancel);
|
sl@0
|
2010 |
|
sl@0
|
2011 |
|
sl@0
|
2012 |
// RFs::MkDir()
|
sl@0
|
2013 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2014 |
test(reqStat==KRequestPending);
|
sl@0
|
2015 |
test.Next(_L("RFs::MkDir()"));
|
sl@0
|
2016 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
|
sl@0
|
2017 |
test(r==KErrNone);
|
sl@0
|
2018 |
User::WaitForRequest(reqStat);
|
sl@0
|
2019 |
test(reqStat==KErrNone);
|
sl@0
|
2020 |
|
sl@0
|
2021 |
// RFs::RmDir()
|
sl@0
|
2022 |
test.Next(_L("RFs::RmDir()"));
|
sl@0
|
2023 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2024 |
test(reqStat==KRequestPending);
|
sl@0
|
2025 |
r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
|
sl@0
|
2026 |
test(r==KErrNone);
|
sl@0
|
2027 |
User::WaitForRequest(reqStat);
|
sl@0
|
2028 |
test(reqStat==KErrNone);
|
sl@0
|
2029 |
|
sl@0
|
2030 |
// RFile::Create()
|
sl@0
|
2031 |
test.Next(_L("RFile::Create()"));
|
sl@0
|
2032 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2033 |
test(reqStat==KRequestPending);
|
sl@0
|
2034 |
r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"),EFileRead|EFileWrite);
|
sl@0
|
2035 |
test(r==KErrNone);
|
sl@0
|
2036 |
User::WaitForRequest(reqStat);
|
sl@0
|
2037 |
test(reqStat==KErrNone);
|
sl@0
|
2038 |
file.Close();
|
sl@0
|
2039 |
|
sl@0
|
2040 |
// RFs::Delete()
|
sl@0
|
2041 |
test.Next(_L("RFs::Delete()"));
|
sl@0
|
2042 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2043 |
test(reqStat==KRequestPending);
|
sl@0
|
2044 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
|
sl@0
|
2045 |
test(r==KErrNone);
|
sl@0
|
2046 |
User::WaitForRequest(reqStat);
|
sl@0
|
2047 |
test(reqStat==KErrNone);
|
sl@0
|
2048 |
|
sl@0
|
2049 |
// RFile::Replace()
|
sl@0
|
2050 |
test.Next(_L("RFile::Replace()"));
|
sl@0
|
2051 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2052 |
test(reqStat==KRequestPending);
|
sl@0
|
2053 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"),EFileRead|EFileWrite);
|
sl@0
|
2054 |
test(r==KErrNone);
|
sl@0
|
2055 |
User::WaitForRequest(reqStat);
|
sl@0
|
2056 |
test(reqStat==KErrNone);
|
sl@0
|
2057 |
file.Close();
|
sl@0
|
2058 |
|
sl@0
|
2059 |
// RFs::Delete()
|
sl@0
|
2060 |
test.Next(_L("RFs::Delete()"));
|
sl@0
|
2061 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2062 |
test(reqStat==KRequestPending);
|
sl@0
|
2063 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
|
sl@0
|
2064 |
test(r==KErrNone);
|
sl@0
|
2065 |
User::WaitForRequest(reqStat);
|
sl@0
|
2066 |
test(reqStat==KErrNone);
|
sl@0
|
2067 |
|
sl@0
|
2068 |
// RFs::SetVolumeLabel() - should only be notification when monitoring relevant TNotifyTypes
|
sl@0
|
2069 |
test.Next(_L("RFs::SetVolumeLabel"));
|
sl@0
|
2070 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2071 |
|
sl@0
|
2072 |
TInt driveNum=CurrentDrive();
|
sl@0
|
2073 |
TVolumeInfo volInfo;
|
sl@0
|
2074 |
TFileName currentVolName;
|
sl@0
|
2075 |
|
sl@0
|
2076 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2077 |
test(r==KErrNone);
|
sl@0
|
2078 |
test(reqStat==KRequestPending);
|
sl@0
|
2079 |
currentVolName=volInfo.iName;
|
sl@0
|
2080 |
|
sl@0
|
2081 |
r=TheFs.SetVolumeLabel(_L("VOL"),driveNum);
|
sl@0
|
2082 |
if (r==KErrNone)
|
sl@0
|
2083 |
{
|
sl@0
|
2084 |
User::WaitForRequest(reqStat);
|
sl@0
|
2085 |
test(reqStat==KErrNone);
|
sl@0
|
2086 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2087 |
test(r==KErrNone);
|
sl@0
|
2088 |
test(volInfo.iName==_L("VOL"));
|
sl@0
|
2089 |
// Test notification occurs under ENotifyDisk
|
sl@0
|
2090 |
fs.NotifyChange(ENotifyDisk,reqStat,path);
|
sl@0
|
2091 |
test(reqStat==KRequestPending);
|
sl@0
|
2092 |
r=TheFs.SetVolumeLabel(_L("ABCDEFGHIJK"),driveNum);
|
sl@0
|
2093 |
test(r==KErrNone);
|
sl@0
|
2094 |
User::WaitForRequest(reqStat);
|
sl@0
|
2095 |
test(reqStat==KErrNone);
|
sl@0
|
2096 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2097 |
test(r==KErrNone);
|
sl@0
|
2098 |
|
sl@0
|
2099 |
test(volInfo.iName==_L("ABCDEFGHIJK"));
|
sl@0
|
2100 |
|
sl@0
|
2101 |
// Test notification does not occur under ENotifyAttributes
|
sl@0
|
2102 |
fs.NotifyChange(ENotifyAttributes,reqStat,path);
|
sl@0
|
2103 |
r=TheFs.SetVolumeLabel(_L("TROPICANA"),driveNum);
|
sl@0
|
2104 |
test(r==KErrNone);
|
sl@0
|
2105 |
test(reqStat==KRequestPending);
|
sl@0
|
2106 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2107 |
test(r==KErrNone);
|
sl@0
|
2108 |
|
sl@0
|
2109 |
test(volInfo.iName==_L("TROPICANA"));
|
sl@0
|
2110 |
|
sl@0
|
2111 |
fs.NotifyChangeCancel(reqStat);
|
sl@0
|
2112 |
User::WaitForRequest(reqStat);
|
sl@0
|
2113 |
test(reqStat==KErrCancel);
|
sl@0
|
2114 |
// Test notification occurs under ENotifyEntry
|
sl@0
|
2115 |
fs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
2116 |
test(reqStat==KRequestPending);
|
sl@0
|
2117 |
r=TheFs.SetVolumeLabel(currentVolName,driveNum);
|
sl@0
|
2118 |
test(r==KErrNone);
|
sl@0
|
2119 |
User::WaitForRequest(reqStat);
|
sl@0
|
2120 |
test(reqStat==KErrNone);
|
sl@0
|
2121 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2122 |
test(r==KErrNone);
|
sl@0
|
2123 |
test(volInfo.iName==currentVolName);
|
sl@0
|
2124 |
}
|
sl@0
|
2125 |
|
sl@0
|
2126 |
else // RFs::SetVolumeLabel() doesn't work on subst drives
|
sl@0
|
2127 |
{
|
sl@0
|
2128 |
fs.NotifyChangeCancel();
|
sl@0
|
2129 |
User::WaitForRequest(reqStat);
|
sl@0
|
2130 |
test.Printf(_L("Cannot set volume label on a substed drive\n"));
|
sl@0
|
2131 |
}
|
sl@0
|
2132 |
|
sl@0
|
2133 |
|
sl@0
|
2134 |
// RFs::Rename()
|
sl@0
|
2135 |
|
sl@0
|
2136 |
test.Next(_L("RFs::Rename()"));
|
sl@0
|
2137 |
fs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
2138 |
test(reqStat==KRequestPending);
|
sl@0
|
2139 |
r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Toto.doc"));
|
sl@0
|
2140 |
test(r==KErrNone);
|
sl@0
|
2141 |
User::WaitForRequest(reqStat);
|
sl@0
|
2142 |
test(reqStat==KErrNone);
|
sl@0
|
2143 |
|
sl@0
|
2144 |
r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Toto.doc"),_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"));
|
sl@0
|
2145 |
test(r==KErrNone);
|
sl@0
|
2146 |
|
sl@0
|
2147 |
#if defined(__WINS__)
|
sl@0
|
2148 |
if(gSessionPath[0]=='Y'||gSessionPath[0]=='X')
|
sl@0
|
2149 |
#endif
|
sl@0
|
2150 |
{
|
sl@0
|
2151 |
test.Next(_L("RFs::Rename() with max path length"));
|
sl@0
|
2152 |
TFileName longName=_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\");
|
sl@0
|
2153 |
while(longName.Length()<(KMaxFileName-2))
|
sl@0
|
2154 |
longName+=_L("a");
|
sl@0
|
2155 |
r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),longName);
|
sl@0
|
2156 |
test(r==KErrNone);
|
sl@0
|
2157 |
fs.NotifyChange(ENotifyEntry,reqStat,longName);
|
sl@0
|
2158 |
test(reqStat==KRequestPending);
|
sl@0
|
2159 |
r=TheFs.Rename(longName,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"));
|
sl@0
|
2160 |
test(r==KErrNone);
|
sl@0
|
2161 |
User::WaitForRequest(reqStat);
|
sl@0
|
2162 |
test(reqStat==KErrNone);
|
sl@0
|
2163 |
}
|
sl@0
|
2164 |
|
sl@0
|
2165 |
fs.Close();
|
sl@0
|
2166 |
}
|
sl@0
|
2167 |
|
sl@0
|
2168 |
|
sl@0
|
2169 |
static void Test15()
|
sl@0
|
2170 |
|
sl@0
|
2171 |
{
|
sl@0
|
2172 |
//
|
sl@0
|
2173 |
// Repeat Test15 operations in a subtree of that monitored, and ensure notification
|
sl@0
|
2174 |
// occurs for a variety of RFile and RFs operations
|
sl@0
|
2175 |
//
|
sl@0
|
2176 |
RFs fs; // Session to be notified when a change occurs
|
sl@0
|
2177 |
TInt r=fs.Connect();
|
sl@0
|
2178 |
test(r==KErrNone);
|
sl@0
|
2179 |
r=fs.SetSessionPath(gSessionPath);
|
sl@0
|
2180 |
test(r==KErrNone);
|
sl@0
|
2181 |
|
sl@0
|
2182 |
// RFile::Write() to a file in the subtree
|
sl@0
|
2183 |
test.Next(_L("RFile::Write()"));
|
sl@0
|
2184 |
TFileName path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
2185 |
TRequestStatus reqStat(KRequestPending);
|
sl@0
|
2186 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2187 |
|
sl@0
|
2188 |
RFile file;
|
sl@0
|
2189 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
|
sl@0
|
2190 |
test(r==KErrNone);
|
sl@0
|
2191 |
test(reqStat==KRequestPending);
|
sl@0
|
2192 |
r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
|
sl@0
|
2193 |
file.Close();
|
sl@0
|
2194 |
User::WaitForRequest(reqStat);
|
sl@0
|
2195 |
test(reqStat==KErrNone);
|
sl@0
|
2196 |
|
sl@0
|
2197 |
// RFile::Read() a file within the monitored directory - no notification for reads
|
sl@0
|
2198 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2199 |
TBuf8<100> temp;
|
sl@0
|
2200 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
|
sl@0
|
2201 |
test(r==KErrNone);
|
sl@0
|
2202 |
test(reqStat==KRequestPending);
|
sl@0
|
2203 |
r=file.Read(0,temp,100);
|
sl@0
|
2204 |
test(reqStat==KRequestPending);
|
sl@0
|
2205 |
|
sl@0
|
2206 |
// RFile::SetAtt() of a file within the monitored directory
|
sl@0
|
2207 |
test.Next(_L("RFile::SetAtt()"));
|
sl@0
|
2208 |
r=file.SetAtt(KEntryAttNormal,KEntryAttHidden);
|
sl@0
|
2209 |
test(r==KErrNone);
|
sl@0
|
2210 |
User::WaitForRequest(reqStat);
|
sl@0
|
2211 |
test(reqStat==KErrNone);
|
sl@0
|
2212 |
|
sl@0
|
2213 |
// RFile::SetSize() of a file within the monitored directory
|
sl@0
|
2214 |
test.Next(_L("RFile::SetSize()"));
|
sl@0
|
2215 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2216 |
test(reqStat==KRequestPending);
|
sl@0
|
2217 |
r=file.SetSize(256);
|
sl@0
|
2218 |
test(r==KErrNone);
|
sl@0
|
2219 |
User::WaitForRequest(reqStat);
|
sl@0
|
2220 |
test(reqStat==KErrNone);
|
sl@0
|
2221 |
file.Close();
|
sl@0
|
2222 |
|
sl@0
|
2223 |
// RFile::Temp() to create a temp file in the subtree
|
sl@0
|
2224 |
test.Next(_L("RFile::Temp()"));
|
sl@0
|
2225 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2226 |
test(reqStat==KRequestPending);
|
sl@0
|
2227 |
TFileName fileName;
|
sl@0
|
2228 |
r=file.Temp(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\"),fileName,EFileWrite);
|
sl@0
|
2229 |
test(r==KErrNone);
|
sl@0
|
2230 |
User::WaitForRequest(reqStat);
|
sl@0
|
2231 |
test(reqStat==KErrNone);
|
sl@0
|
2232 |
file.Close();
|
sl@0
|
2233 |
|
sl@0
|
2234 |
// RFile::SetModified() to change modification time of a file within monitored dir
|
sl@0
|
2235 |
test.Next(_L("RFile::SetModified()"));
|
sl@0
|
2236 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2237 |
TTime now;
|
sl@0
|
2238 |
now.HomeTime();
|
sl@0
|
2239 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
|
sl@0
|
2240 |
test(r==KErrNone);
|
sl@0
|
2241 |
test(reqStat==KRequestPending);
|
sl@0
|
2242 |
file.SetModified(now);
|
sl@0
|
2243 |
file.Close();
|
sl@0
|
2244 |
User::WaitForRequest(reqStat);
|
sl@0
|
2245 |
test(reqStat==KErrNone);
|
sl@0
|
2246 |
|
sl@0
|
2247 |
// RFs::Entry() to change a directory entry within the monitored directory
|
sl@0
|
2248 |
test.Next(_L("RFs::Entry()"));
|
sl@0
|
2249 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2250 |
TEntry entry;
|
sl@0
|
2251 |
r=TheFs.Entry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),entry);
|
sl@0
|
2252 |
test(reqStat==KRequestPending);
|
sl@0
|
2253 |
now.HomeTime();
|
sl@0
|
2254 |
r=TheFs.SetEntry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),now,KEntryAttHidden,KEntryAttNormal);
|
sl@0
|
2255 |
test(r==KErrNone);
|
sl@0
|
2256 |
User::WaitForRequest(reqStat);
|
sl@0
|
2257 |
test(reqStat==KErrNone);
|
sl@0
|
2258 |
|
sl@0
|
2259 |
// RFile::Set() to change file's modification time and attributes
|
sl@0
|
2260 |
test.Next(_L("RFile::Set()"));
|
sl@0
|
2261 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2262 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
|
sl@0
|
2263 |
test(r==KErrNone);
|
sl@0
|
2264 |
test(reqStat==KRequestPending);
|
sl@0
|
2265 |
now.HomeTime();
|
sl@0
|
2266 |
r=file.Set(now,KEntryAttNormal,KEntryAttHidden);
|
sl@0
|
2267 |
file.Close();
|
sl@0
|
2268 |
User::WaitForRequest(reqStat);
|
sl@0
|
2269 |
test(reqStat==KErrNone);
|
sl@0
|
2270 |
|
sl@0
|
2271 |
// RFs::SetDriveName()
|
sl@0
|
2272 |
test.Next(_L("RFs::SetDriveName()"));
|
sl@0
|
2273 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2274 |
test(reqStat==KRequestPending);
|
sl@0
|
2275 |
User::After(KNotifyChangeAfter);
|
sl@0
|
2276 |
r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVETEST"));
|
sl@0
|
2277 |
test(r==KErrNone);
|
sl@0
|
2278 |
User::WaitForRequest(reqStat);
|
sl@0
|
2279 |
test(reqStat==KErrNone);
|
sl@0
|
2280 |
fs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
2281 |
r=TheFs.SetDriveName(KDefaultDrive,_L("TEST"));
|
sl@0
|
2282 |
test(r==KErrNone);
|
sl@0
|
2283 |
test(reqStat==KRequestPending);
|
sl@0
|
2284 |
User::After(KNotifyChangeAfter);
|
sl@0
|
2285 |
fs.NotifyChangeCancel(reqStat);
|
sl@0
|
2286 |
User::WaitForRequest(reqStat);
|
sl@0
|
2287 |
test(reqStat==KErrCancel);
|
sl@0
|
2288 |
fs.NotifyChange(ENotifyDisk,reqStat,path);
|
sl@0
|
2289 |
User::After(KNotifyChangeAfter);
|
sl@0
|
2290 |
r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVE"));
|
sl@0
|
2291 |
test(r==KErrNone);
|
sl@0
|
2292 |
test(reqStat==KRequestPending);
|
sl@0
|
2293 |
fs.NotifyChangeCancel(reqStat);
|
sl@0
|
2294 |
User::WaitForRequest(reqStat);
|
sl@0
|
2295 |
test(reqStat==KErrCancel);
|
sl@0
|
2296 |
|
sl@0
|
2297 |
// RFs::MkDir()
|
sl@0
|
2298 |
test.Next(_L("RFs::MkDir()"));
|
sl@0
|
2299 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2300 |
test(reqStat==KRequestPending);
|
sl@0
|
2301 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
|
sl@0
|
2302 |
test(r==KErrNone);
|
sl@0
|
2303 |
User::WaitForRequest(reqStat);
|
sl@0
|
2304 |
test(reqStat==KErrNone);
|
sl@0
|
2305 |
|
sl@0
|
2306 |
// RFs::RmDir()
|
sl@0
|
2307 |
test.Next(_L("RFs::RmDir()"));
|
sl@0
|
2308 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2309 |
test(reqStat==KRequestPending);
|
sl@0
|
2310 |
r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
|
sl@0
|
2311 |
test(r==KErrNone);
|
sl@0
|
2312 |
User::WaitForRequest(reqStat);
|
sl@0
|
2313 |
test(reqStat==KErrNone);
|
sl@0
|
2314 |
|
sl@0
|
2315 |
// RFile::Create()
|
sl@0
|
2316 |
test.Next(_L("RFile::Create()"));
|
sl@0
|
2317 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2318 |
test(reqStat==KRequestPending);
|
sl@0
|
2319 |
r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"),EFileRead|EFileWrite);
|
sl@0
|
2320 |
test(r==KErrNone);
|
sl@0
|
2321 |
User::WaitForRequest(reqStat);
|
sl@0
|
2322 |
test(reqStat==KErrNone);
|
sl@0
|
2323 |
file.Close();
|
sl@0
|
2324 |
|
sl@0
|
2325 |
// RFs::Delete()
|
sl@0
|
2326 |
test.Next(_L("RFs::Delete()"));
|
sl@0
|
2327 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2328 |
test(reqStat==KRequestPending);
|
sl@0
|
2329 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
|
sl@0
|
2330 |
test(r==KErrNone);
|
sl@0
|
2331 |
User::WaitForRequest(reqStat);
|
sl@0
|
2332 |
test(reqStat==KErrNone);
|
sl@0
|
2333 |
|
sl@0
|
2334 |
// RFile::Replace()
|
sl@0
|
2335 |
test.Next(_L("RFile::Replace()"));
|
sl@0
|
2336 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2337 |
test(reqStat==KRequestPending);
|
sl@0
|
2338 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"),EFileRead|EFileWrite);
|
sl@0
|
2339 |
test(r==KErrNone);
|
sl@0
|
2340 |
User::WaitForRequest(reqStat);
|
sl@0
|
2341 |
test(reqStat==KErrNone);
|
sl@0
|
2342 |
file.Close();
|
sl@0
|
2343 |
|
sl@0
|
2344 |
// RFs::Delete()
|
sl@0
|
2345 |
test.Next(_L("RFs::Delete()"));
|
sl@0
|
2346 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2347 |
test(reqStat==KRequestPending);
|
sl@0
|
2348 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
|
sl@0
|
2349 |
test(r==KErrNone);
|
sl@0
|
2350 |
User::WaitForRequest(reqStat);
|
sl@0
|
2351 |
test(reqStat==KErrNone);
|
sl@0
|
2352 |
|
sl@0
|
2353 |
// RFs::SetVolumeLabel() - should be notification under relevant TNotifyType monitoring
|
sl@0
|
2354 |
// The operation is non-path specific so all outstanding interested requests are notified
|
sl@0
|
2355 |
test.Next(_L("RFs::SetVolumeLabel()"));
|
sl@0
|
2356 |
|
sl@0
|
2357 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2358 |
|
sl@0
|
2359 |
TInt driveNum=CurrentDrive();
|
sl@0
|
2360 |
TVolumeInfo volInfo;
|
sl@0
|
2361 |
TFileName currentVolName;
|
sl@0
|
2362 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2363 |
test(r==KErrNone);
|
sl@0
|
2364 |
test(reqStat==KRequestPending);
|
sl@0
|
2365 |
currentVolName=volInfo.iName;
|
sl@0
|
2366 |
|
sl@0
|
2367 |
r=TheFs.SetVolumeLabel(_L("VOL"),driveNum);
|
sl@0
|
2368 |
if (r==KErrNone)
|
sl@0
|
2369 |
{
|
sl@0
|
2370 |
User::WaitForRequest(reqStat);
|
sl@0
|
2371 |
test(reqStat==KErrNone);
|
sl@0
|
2372 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2373 |
test(r==KErrNone);
|
sl@0
|
2374 |
test(volInfo.iName==_L("VOL"));
|
sl@0
|
2375 |
// Test notification occurs under ENotifyDisk
|
sl@0
|
2376 |
fs.NotifyChange(ENotifyDisk,reqStat,path);
|
sl@0
|
2377 |
test(reqStat==KRequestPending);
|
sl@0
|
2378 |
r=TheFs.SetVolumeLabel(_L("ABCDEFGHIJK"),driveNum);
|
sl@0
|
2379 |
test(r==KErrNone);
|
sl@0
|
2380 |
User::WaitForRequest(reqStat);
|
sl@0
|
2381 |
test(reqStat==KErrNone);
|
sl@0
|
2382 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2383 |
test(r==KErrNone);
|
sl@0
|
2384 |
|
sl@0
|
2385 |
test(volInfo.iName==_L("ABCDEFGHIJK"));
|
sl@0
|
2386 |
|
sl@0
|
2387 |
// Test notification does not occur under ENotifyAttributes
|
sl@0
|
2388 |
fs.NotifyChange(ENotifyAttributes,reqStat,path);
|
sl@0
|
2389 |
r=TheFs.SetVolumeLabel(_L("TROPICANA"),driveNum);
|
sl@0
|
2390 |
test(r==KErrNone);
|
sl@0
|
2391 |
test(reqStat==KRequestPending);
|
sl@0
|
2392 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2393 |
test(r==KErrNone);
|
sl@0
|
2394 |
|
sl@0
|
2395 |
test(volInfo.iName==_L("TROPICANA"));
|
sl@0
|
2396 |
|
sl@0
|
2397 |
fs.NotifyChangeCancel(reqStat);
|
sl@0
|
2398 |
User::WaitForRequest(reqStat);
|
sl@0
|
2399 |
test(reqStat==KErrCancel);
|
sl@0
|
2400 |
// Test notification occurs under ENotifyEntry
|
sl@0
|
2401 |
fs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
2402 |
test(reqStat==KRequestPending);
|
sl@0
|
2403 |
r=TheFs.SetVolumeLabel(currentVolName,driveNum);
|
sl@0
|
2404 |
test(r==KErrNone);
|
sl@0
|
2405 |
User::WaitForRequest(reqStat);
|
sl@0
|
2406 |
test(reqStat==KErrNone);
|
sl@0
|
2407 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2408 |
test(r==KErrNone);
|
sl@0
|
2409 |
test(volInfo.iName==currentVolName);
|
sl@0
|
2410 |
}
|
sl@0
|
2411 |
|
sl@0
|
2412 |
else // RFs::SetVolumeLabel() doesn't work on subst drives
|
sl@0
|
2413 |
{
|
sl@0
|
2414 |
fs.NotifyChangeCancel();
|
sl@0
|
2415 |
User::WaitForRequest(reqStat);
|
sl@0
|
2416 |
test.Printf(_L("Cannot set volume label on a substed drive\n"));
|
sl@0
|
2417 |
}
|
sl@0
|
2418 |
|
sl@0
|
2419 |
|
sl@0
|
2420 |
|
sl@0
|
2421 |
// Test that notification is made when change is made to monitored directory
|
sl@0
|
2422 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2423 |
test(reqStat==KRequestPending);
|
sl@0
|
2424 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
|
sl@0
|
2425 |
test(r==KErrNone);
|
sl@0
|
2426 |
User::WaitForRequest(reqStat);
|
sl@0
|
2427 |
test(reqStat==KErrNone);
|
sl@0
|
2428 |
|
sl@0
|
2429 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2430 |
test(reqStat==KRequestPending);
|
sl@0
|
2431 |
r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
|
sl@0
|
2432 |
test(r==KErrNone);
|
sl@0
|
2433 |
User::WaitForRequest(reqStat);
|
sl@0
|
2434 |
test(reqStat==KErrNone);
|
sl@0
|
2435 |
fs.Close();
|
sl@0
|
2436 |
}
|
sl@0
|
2437 |
|
sl@0
|
2438 |
|
sl@0
|
2439 |
static void Test16()
|
sl@0
|
2440 |
|
sl@0
|
2441 |
{
|
sl@0
|
2442 |
//
|
sl@0
|
2443 |
// Repeat Test15 operations in a subtree of that monitored, and ensure notification
|
sl@0
|
2444 |
// does occur for a variety of file operations when subtree watching is on
|
sl@0
|
2445 |
//
|
sl@0
|
2446 |
RFs fs;
|
sl@0
|
2447 |
TInt r=fs.Connect(); // Session to be notified when a change occurs
|
sl@0
|
2448 |
test(r==KErrNone);
|
sl@0
|
2449 |
r=fs.SetSessionPath(gSessionPath);
|
sl@0
|
2450 |
test(r==KErrNone);
|
sl@0
|
2451 |
|
sl@0
|
2452 |
// RFile::Write() to a file in the subtree
|
sl@0
|
2453 |
TFileName path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
2454 |
TRequestStatus reqStat(KRequestPending);
|
sl@0
|
2455 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2456 |
|
sl@0
|
2457 |
RFile file;
|
sl@0
|
2458 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
|
sl@0
|
2459 |
test(r==KErrNone);
|
sl@0
|
2460 |
test(reqStat==KRequestPending);
|
sl@0
|
2461 |
r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
|
sl@0
|
2462 |
file.Close();
|
sl@0
|
2463 |
User::WaitForRequest(reqStat);
|
sl@0
|
2464 |
test(reqStat==KErrNone);
|
sl@0
|
2465 |
|
sl@0
|
2466 |
// RFile::Read() a file within the monitored directory - no notification for reads
|
sl@0
|
2467 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2468 |
TBuf8<100> temp;
|
sl@0
|
2469 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
|
sl@0
|
2470 |
test(r==KErrNone);
|
sl@0
|
2471 |
test(reqStat==KRequestPending);
|
sl@0
|
2472 |
r=file.Read(0,temp,100);
|
sl@0
|
2473 |
test(reqStat==KRequestPending);
|
sl@0
|
2474 |
|
sl@0
|
2475 |
// RFile::SetAtt() of a file within the monitored directory
|
sl@0
|
2476 |
r=file.SetAtt(KEntryAttNormal,KEntryAttHidden);
|
sl@0
|
2477 |
test(r==KErrNone);
|
sl@0
|
2478 |
User::WaitForRequest(reqStat);
|
sl@0
|
2479 |
test(reqStat==KErrNone);
|
sl@0
|
2480 |
|
sl@0
|
2481 |
// RFile::SetSize() of a file within the monitored directory
|
sl@0
|
2482 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2483 |
test(reqStat==KRequestPending);
|
sl@0
|
2484 |
r=file.SetSize(256);
|
sl@0
|
2485 |
test(r==KErrNone);
|
sl@0
|
2486 |
User::WaitForRequest(reqStat);
|
sl@0
|
2487 |
test(reqStat==KErrNone);
|
sl@0
|
2488 |
file.Close();
|
sl@0
|
2489 |
|
sl@0
|
2490 |
|
sl@0
|
2491 |
// RFile::SetModified() to change modification time of a file within monitored dir
|
sl@0
|
2492 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2493 |
TTime now;
|
sl@0
|
2494 |
now.HomeTime();
|
sl@0
|
2495 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
|
sl@0
|
2496 |
test(r==KErrNone);
|
sl@0
|
2497 |
test(reqStat==KRequestPending);
|
sl@0
|
2498 |
file.SetModified(now);
|
sl@0
|
2499 |
file.Close();
|
sl@0
|
2500 |
User::WaitForRequest(reqStat);
|
sl@0
|
2501 |
test(reqStat==KErrNone);
|
sl@0
|
2502 |
|
sl@0
|
2503 |
// RFs::Entry() to change a directory entry within the monitored directory
|
sl@0
|
2504 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2505 |
TEntry entry;
|
sl@0
|
2506 |
r=TheFs.Entry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),entry);
|
sl@0
|
2507 |
test(reqStat==KRequestPending);
|
sl@0
|
2508 |
now.HomeTime();
|
sl@0
|
2509 |
r=TheFs.SetEntry(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),now,KEntryAttHidden,KEntryAttNormal);
|
sl@0
|
2510 |
test(r==KErrNone);
|
sl@0
|
2511 |
User::WaitForRequest(reqStat);
|
sl@0
|
2512 |
test(reqStat==KErrNone);
|
sl@0
|
2513 |
|
sl@0
|
2514 |
// RFile::Set() to change file's modification time and attributes
|
sl@0
|
2515 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2516 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),EFileRead|EFileWrite);
|
sl@0
|
2517 |
test(r==KErrNone);
|
sl@0
|
2518 |
test(reqStat==KRequestPending);
|
sl@0
|
2519 |
now.HomeTime();
|
sl@0
|
2520 |
r=file.Set(now,KEntryAttNormal,KEntryAttHidden);
|
sl@0
|
2521 |
file.Close();
|
sl@0
|
2522 |
User::WaitForRequest(reqStat);
|
sl@0
|
2523 |
test(reqStat==KErrNone);
|
sl@0
|
2524 |
|
sl@0
|
2525 |
// RFs::SetDriveName() - should be no notification ever with extended notification
|
sl@0
|
2526 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2527 |
test(reqStat==KRequestPending);
|
sl@0
|
2528 |
User::After(KNotifyChangeAfter);
|
sl@0
|
2529 |
r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVETEST"));
|
sl@0
|
2530 |
test(r==KErrNone);
|
sl@0
|
2531 |
User::WaitForRequest(reqStat);
|
sl@0
|
2532 |
test(reqStat==KErrNone);
|
sl@0
|
2533 |
fs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
2534 |
User::After(KNotifyChangeAfter);
|
sl@0
|
2535 |
r=TheFs.SetDriveName(KDefaultDrive,_L("TEST"));
|
sl@0
|
2536 |
test(r==KErrNone);
|
sl@0
|
2537 |
test(reqStat==KRequestPending);
|
sl@0
|
2538 |
fs.NotifyChangeCancel(reqStat);
|
sl@0
|
2539 |
User::WaitForRequest(reqStat);
|
sl@0
|
2540 |
fs.NotifyChange(ENotifyDisk,reqStat,path);
|
sl@0
|
2541 |
User::After(KNotifyChangeAfter);
|
sl@0
|
2542 |
r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVE"));
|
sl@0
|
2543 |
test(r==KErrNone);
|
sl@0
|
2544 |
test(reqStat==KRequestPending);
|
sl@0
|
2545 |
fs.NotifyChangeCancel(reqStat);
|
sl@0
|
2546 |
User::WaitForRequest(reqStat);
|
sl@0
|
2547 |
test(reqStat==KErrCancel);
|
sl@0
|
2548 |
|
sl@0
|
2549 |
|
sl@0
|
2550 |
// RFs::MkDir()
|
sl@0
|
2551 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2552 |
test(reqStat==KRequestPending);
|
sl@0
|
2553 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
|
sl@0
|
2554 |
test(r==KErrNone);
|
sl@0
|
2555 |
User::WaitForRequest(reqStat);
|
sl@0
|
2556 |
test(reqStat==KErrNone);
|
sl@0
|
2557 |
|
sl@0
|
2558 |
// RFs::RmDir()
|
sl@0
|
2559 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2560 |
test(reqStat==KRequestPending);
|
sl@0
|
2561 |
r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\EMERALD_CITY\\"));
|
sl@0
|
2562 |
test(r==KErrNone);
|
sl@0
|
2563 |
User::WaitForRequest(reqStat);
|
sl@0
|
2564 |
test(reqStat==KErrNone);
|
sl@0
|
2565 |
|
sl@0
|
2566 |
// RFile::Create()
|
sl@0
|
2567 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2568 |
test(reqStat==KRequestPending);
|
sl@0
|
2569 |
r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"),EFileRead|EFileWrite);
|
sl@0
|
2570 |
test(r==KErrNone);
|
sl@0
|
2571 |
User::WaitForRequest(reqStat);
|
sl@0
|
2572 |
test(reqStat==KErrNone);
|
sl@0
|
2573 |
file.Close();
|
sl@0
|
2574 |
|
sl@0
|
2575 |
// RFs::Delete()
|
sl@0
|
2576 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2577 |
test(reqStat==KRequestPending);
|
sl@0
|
2578 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
|
sl@0
|
2579 |
test(r==KErrNone);
|
sl@0
|
2580 |
User::WaitForRequest(reqStat);
|
sl@0
|
2581 |
test(reqStat==KErrNone);
|
sl@0
|
2582 |
|
sl@0
|
2583 |
// RFile::Replace()
|
sl@0
|
2584 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2585 |
test(reqStat==KRequestPending);
|
sl@0
|
2586 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"),EFileRead|EFileWrite);
|
sl@0
|
2587 |
test(r==KErrNone);
|
sl@0
|
2588 |
User::WaitForRequest(reqStat);
|
sl@0
|
2589 |
test(reqStat==KErrNone);
|
sl@0
|
2590 |
file.Close();
|
sl@0
|
2591 |
|
sl@0
|
2592 |
// RFs::Delete()
|
sl@0
|
2593 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2594 |
test(reqStat==KRequestPending);
|
sl@0
|
2595 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Good_Witch.bat"));
|
sl@0
|
2596 |
test(r==KErrNone);
|
sl@0
|
2597 |
User::WaitForRequest(reqStat);
|
sl@0
|
2598 |
test(reqStat==KErrNone);
|
sl@0
|
2599 |
|
sl@0
|
2600 |
// RFs::SetVolumeLabel()
|
sl@0
|
2601 |
// Not path specific, so all outstanding requests of correct TNotifyType are notified
|
sl@0
|
2602 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2603 |
TInt driveNum=CurrentDrive();
|
sl@0
|
2604 |
TVolumeInfo volInfo;
|
sl@0
|
2605 |
TFileName currentVolName;
|
sl@0
|
2606 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2607 |
test(r==KErrNone);
|
sl@0
|
2608 |
test(reqStat==KRequestPending);
|
sl@0
|
2609 |
currentVolName=volInfo.iName;
|
sl@0
|
2610 |
|
sl@0
|
2611 |
r=TheFs.SetVolumeLabel(_L("VOL"),driveNum);
|
sl@0
|
2612 |
if (r==KErrNone)
|
sl@0
|
2613 |
{
|
sl@0
|
2614 |
User::WaitForRequest(reqStat);
|
sl@0
|
2615 |
test(reqStat==KErrNone);
|
sl@0
|
2616 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2617 |
test(r==KErrNone);
|
sl@0
|
2618 |
test(volInfo.iName==_L("VOL"));
|
sl@0
|
2619 |
// Test notification occurs under ENotifyDisk
|
sl@0
|
2620 |
fs.NotifyChange(ENotifyDisk,reqStat,path);
|
sl@0
|
2621 |
test(reqStat==KRequestPending);
|
sl@0
|
2622 |
r=TheFs.SetVolumeLabel(_L("ABCDEFGHIJK"),driveNum);
|
sl@0
|
2623 |
test(r==KErrNone);
|
sl@0
|
2624 |
User::WaitForRequest(reqStat);
|
sl@0
|
2625 |
test(reqStat==KErrNone);
|
sl@0
|
2626 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2627 |
test(r==KErrNone);
|
sl@0
|
2628 |
|
sl@0
|
2629 |
test(volInfo.iName==_L("ABCDEFGHIJK"));
|
sl@0
|
2630 |
|
sl@0
|
2631 |
// Test notification does not occur under ENotifyAttributes
|
sl@0
|
2632 |
fs.NotifyChange(ENotifyAttributes,reqStat,path);
|
sl@0
|
2633 |
r=TheFs.SetVolumeLabel(_L("TROPICANA"),driveNum);
|
sl@0
|
2634 |
test(r==KErrNone);
|
sl@0
|
2635 |
test(reqStat==KRequestPending);
|
sl@0
|
2636 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2637 |
test(r==KErrNone);
|
sl@0
|
2638 |
|
sl@0
|
2639 |
test(volInfo.iName==_L("TROPICANA"));
|
sl@0
|
2640 |
|
sl@0
|
2641 |
fs.NotifyChangeCancel(reqStat);
|
sl@0
|
2642 |
User::WaitForRequest(reqStat);
|
sl@0
|
2643 |
test(reqStat==KErrCancel);
|
sl@0
|
2644 |
// Test notification occurs under ENotifyEntry
|
sl@0
|
2645 |
fs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
2646 |
test(reqStat==KRequestPending);
|
sl@0
|
2647 |
r=TheFs.SetVolumeLabel(currentVolName,driveNum);
|
sl@0
|
2648 |
test(r==KErrNone);
|
sl@0
|
2649 |
User::WaitForRequest(reqStat);
|
sl@0
|
2650 |
test(reqStat==KErrNone);
|
sl@0
|
2651 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
2652 |
test(r==KErrNone);
|
sl@0
|
2653 |
test(volInfo.iName==currentVolName);
|
sl@0
|
2654 |
}
|
sl@0
|
2655 |
|
sl@0
|
2656 |
else // RFs::SetVolumeLabel() doesn't work on subst drives
|
sl@0
|
2657 |
{
|
sl@0
|
2658 |
fs.NotifyChangeCancel();
|
sl@0
|
2659 |
User::WaitForRequest(reqStat);
|
sl@0
|
2660 |
test.Printf(_L("Cannot set volume label on a substed drive\n"));
|
sl@0
|
2661 |
}
|
sl@0
|
2662 |
|
sl@0
|
2663 |
// RFs::Rename()
|
sl@0
|
2664 |
fs.NotifyChange(ENotifyEntry,reqStat,path);
|
sl@0
|
2665 |
test(reqStat==KRequestPending);
|
sl@0
|
2666 |
r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Dorothy.doc"),_L("\\F32-TST\\NOTIFY\\MUNCHKINS\\Toto.doc"));
|
sl@0
|
2667 |
test(r==KErrNone);
|
sl@0
|
2668 |
User::WaitForRequest(reqStat);
|
sl@0
|
2669 |
test(reqStat==KErrNone);
|
sl@0
|
2670 |
|
sl@0
|
2671 |
// Test that notification is made when change is made to monitored directory
|
sl@0
|
2672 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2673 |
test(reqStat==KRequestPending);
|
sl@0
|
2674 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
|
sl@0
|
2675 |
test(r==KErrNone);
|
sl@0
|
2676 |
User::WaitForRequest(reqStat);
|
sl@0
|
2677 |
test(reqStat==KErrNone);
|
sl@0
|
2678 |
|
sl@0
|
2679 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2680 |
test(reqStat==KRequestPending);
|
sl@0
|
2681 |
r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
|
sl@0
|
2682 |
test(r==KErrNone);
|
sl@0
|
2683 |
User::WaitForRequest(reqStat);
|
sl@0
|
2684 |
test(reqStat==KErrNone);
|
sl@0
|
2685 |
fs.Close();
|
sl@0
|
2686 |
}
|
sl@0
|
2687 |
|
sl@0
|
2688 |
|
sl@0
|
2689 |
static void Test17()
|
sl@0
|
2690 |
//
|
sl@0
|
2691 |
// Test multiple requests from a single session
|
sl@0
|
2692 |
//
|
sl@0
|
2693 |
{
|
sl@0
|
2694 |
|
sl@0
|
2695 |
test.Next(_L("Test reads and writes do not cause notification under ENotifyEntry"));
|
sl@0
|
2696 |
|
sl@0
|
2697 |
RFile file;
|
sl@0
|
2698 |
TInt r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
|
sl@0
|
2699 |
test(r==KErrNone);
|
sl@0
|
2700 |
file.Close();
|
sl@0
|
2701 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\koala.txt"),EFileRead|EFileWrite);
|
sl@0
|
2702 |
test(r==KErrNone);
|
sl@0
|
2703 |
file.Close();
|
sl@0
|
2704 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\dingo.txt"),EFileRead|EFileWrite);
|
sl@0
|
2705 |
test(r==KErrNone);
|
sl@0
|
2706 |
file.Close();
|
sl@0
|
2707 |
|
sl@0
|
2708 |
RFs fs;
|
sl@0
|
2709 |
r=fs.Connect();
|
sl@0
|
2710 |
test(r==KErrNone);
|
sl@0
|
2711 |
r=fs.SetSessionPath(gSessionPath);
|
sl@0
|
2712 |
test(r==KErrNone);
|
sl@0
|
2713 |
|
sl@0
|
2714 |
TRequestStatus reqStat1(KRequestPending);
|
sl@0
|
2715 |
TFileName path1=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
2716 |
fs.NotifyChange(ENotifyEntry,reqStat1,path1);
|
sl@0
|
2717 |
|
sl@0
|
2718 |
TRequestStatus status1(KRequestPending);
|
sl@0
|
2719 |
TRequestStatus status2(KRequestPending);
|
sl@0
|
2720 |
TRequestStatus status3(KRequestPending);
|
sl@0
|
2721 |
TRequestStatus status4(KRequestPending);
|
sl@0
|
2722 |
TRequestStatus status5(KRequestPending);
|
sl@0
|
2723 |
TRequestStatus status6(KRequestPending);
|
sl@0
|
2724 |
|
sl@0
|
2725 |
TRequestStatus statusExtended1(KRequestPending);
|
sl@0
|
2726 |
TRequestStatus statusExtended2(KRequestPending);
|
sl@0
|
2727 |
TRequestStatus statusExtended3(KRequestPending);
|
sl@0
|
2728 |
TRequestStatus statusExtended4(KRequestPending);
|
sl@0
|
2729 |
TRequestStatus statusExtended5(KRequestPending);
|
sl@0
|
2730 |
TRequestStatus statusExtended6(KRequestPending);
|
sl@0
|
2731 |
|
sl@0
|
2732 |
// Request multiple notifications using standard change notification request
|
sl@0
|
2733 |
fs.NotifyChange(ENotifyEntry,status1);
|
sl@0
|
2734 |
fs.NotifyChange(ENotifyEntry,status2);
|
sl@0
|
2735 |
fs.NotifyChange(ENotifyEntry,status3);
|
sl@0
|
2736 |
fs.NotifyChange(ENotifyEntry,status4);
|
sl@0
|
2737 |
fs.NotifyChange(ENotifyEntry,status5);
|
sl@0
|
2738 |
fs.NotifyChange(ENotifyEntry,status6);
|
sl@0
|
2739 |
|
sl@0
|
2740 |
// Request multiple notifications using extended change notification request
|
sl@0
|
2741 |
fs.NotifyChange(ENotifyEntry,statusExtended1,path1);
|
sl@0
|
2742 |
fs.NotifyChange(ENotifyEntry,statusExtended2,path1);
|
sl@0
|
2743 |
fs.NotifyChange(ENotifyEntry,statusExtended3,path1);
|
sl@0
|
2744 |
fs.NotifyChange(ENotifyEntry,statusExtended4,path1);
|
sl@0
|
2745 |
fs.NotifyChange(ENotifyEntry,statusExtended5,path1);
|
sl@0
|
2746 |
fs.NotifyChange(ENotifyEntry,statusExtended6,path1);
|
sl@0
|
2747 |
|
sl@0
|
2748 |
TRequestStatus reqStat2(KRequestPending);
|
sl@0
|
2749 |
TFileName path2=_L("\\F32-TST\\NOTIFY\\kangaroo.txt");
|
sl@0
|
2750 |
fs.NotifyChange(ENotifyEntry,reqStat2,path2);
|
sl@0
|
2751 |
|
sl@0
|
2752 |
TRequestStatus reqStat3(KRequestPending);
|
sl@0
|
2753 |
TFileName path3=_L("\\F32-TST\\NOTIFY\\koala.txt");
|
sl@0
|
2754 |
fs.NotifyChange(ENotifyEntry,reqStat3,path3);
|
sl@0
|
2755 |
|
sl@0
|
2756 |
TRequestStatus reqStat4(KRequestPending);
|
sl@0
|
2757 |
TFileName path4=_L("\\F32-TST\\NOTIFY\\dingo.txt");
|
sl@0
|
2758 |
fs.NotifyChange(ENotifyEntry,reqStat4,path4);
|
sl@0
|
2759 |
|
sl@0
|
2760 |
|
sl@0
|
2761 |
r=gSleepThread.CreateLocal(0);
|
sl@0
|
2762 |
test(r==KErrNone);
|
sl@0
|
2763 |
RThread thread1;
|
sl@0
|
2764 |
r=thread1.Create(_L("TestThread1"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
|
sl@0
|
2765 |
test(r==KErrNone);
|
sl@0
|
2766 |
thread1.Resume();
|
sl@0
|
2767 |
gSleepThread.Wait();
|
sl@0
|
2768 |
|
sl@0
|
2769 |
test(status1==KRequestPending);
|
sl@0
|
2770 |
test(status2==KRequestPending);
|
sl@0
|
2771 |
test(status3==KRequestPending);
|
sl@0
|
2772 |
test(status4==KRequestPending);
|
sl@0
|
2773 |
test(status5==KRequestPending);
|
sl@0
|
2774 |
test(status6==KRequestPending);
|
sl@0
|
2775 |
|
sl@0
|
2776 |
test(statusExtended1==KRequestPending);
|
sl@0
|
2777 |
test(statusExtended2==KRequestPending);
|
sl@0
|
2778 |
test(statusExtended3==KRequestPending);
|
sl@0
|
2779 |
test(statusExtended4==KRequestPending);
|
sl@0
|
2780 |
test(statusExtended5==KRequestPending);
|
sl@0
|
2781 |
test(statusExtended6==KRequestPending);
|
sl@0
|
2782 |
|
sl@0
|
2783 |
test(reqStat1==KRequestPending);
|
sl@0
|
2784 |
test(reqStat2==KRequestPending);
|
sl@0
|
2785 |
test(reqStat3==KRequestPending);
|
sl@0
|
2786 |
test(reqStat4==KRequestPending);
|
sl@0
|
2787 |
|
sl@0
|
2788 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
|
sl@0
|
2789 |
test(r==KErrNone);
|
sl@0
|
2790 |
User::WaitForRequest(reqStat1);
|
sl@0
|
2791 |
test(reqStat1==KErrNone);
|
sl@0
|
2792 |
User::WaitForRequest(status1);
|
sl@0
|
2793 |
test(status1==KErrNone);
|
sl@0
|
2794 |
User::WaitForRequest(status2);
|
sl@0
|
2795 |
test(status2==KErrNone);
|
sl@0
|
2796 |
User::WaitForRequest(status3);
|
sl@0
|
2797 |
test(status3==KErrNone);
|
sl@0
|
2798 |
User::WaitForRequest(status4);
|
sl@0
|
2799 |
test(status4==KErrNone);
|
sl@0
|
2800 |
User::WaitForRequest(status5);
|
sl@0
|
2801 |
test(status5==KErrNone);
|
sl@0
|
2802 |
User::WaitForRequest(status6);
|
sl@0
|
2803 |
test(status6==KErrNone);
|
sl@0
|
2804 |
|
sl@0
|
2805 |
User::WaitForRequest(statusExtended1);
|
sl@0
|
2806 |
test(statusExtended1==KErrNone);
|
sl@0
|
2807 |
User::WaitForRequest(statusExtended2);
|
sl@0
|
2808 |
test(statusExtended2==KErrNone);
|
sl@0
|
2809 |
User::WaitForRequest(statusExtended3);
|
sl@0
|
2810 |
test(statusExtended3==KErrNone);
|
sl@0
|
2811 |
User::WaitForRequest(statusExtended4);
|
sl@0
|
2812 |
test(statusExtended4==KErrNone);
|
sl@0
|
2813 |
User::WaitForRequest(statusExtended5);
|
sl@0
|
2814 |
test(statusExtended5==KErrNone);
|
sl@0
|
2815 |
User::WaitForRequest(statusExtended6);
|
sl@0
|
2816 |
test(statusExtended6==KErrNone);
|
sl@0
|
2817 |
|
sl@0
|
2818 |
User::WaitForRequest(reqStat2);
|
sl@0
|
2819 |
test(reqStat2==KErrNone);
|
sl@0
|
2820 |
test(reqStat3==KRequestPending);
|
sl@0
|
2821 |
test(reqStat4==KRequestPending);
|
sl@0
|
2822 |
fs.NotifyChangeCancel(); // Cancels both remaining notification requests
|
sl@0
|
2823 |
|
sl@0
|
2824 |
User::WaitForRequest(reqStat3);
|
sl@0
|
2825 |
User::WaitForRequest(reqStat4);
|
sl@0
|
2826 |
|
sl@0
|
2827 |
gSleepThread.Close();
|
sl@0
|
2828 |
thread1.Close();
|
sl@0
|
2829 |
|
sl@0
|
2830 |
test.Next(_L("Test reads and writes do cause notification under ENotifyAll"));
|
sl@0
|
2831 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\kangaroo.txt"),EFileRead|EFileWrite);
|
sl@0
|
2832 |
test(r==KErrNone);
|
sl@0
|
2833 |
file.Close();
|
sl@0
|
2834 |
|
sl@0
|
2835 |
fs.NotifyChange(ENotifyAll,reqStat1,path1);
|
sl@0
|
2836 |
fs.NotifyChange(ENotifyEntry,reqStat2,path2);
|
sl@0
|
2837 |
fs.NotifyChange(ENotifyAll,reqStat3,path3);
|
sl@0
|
2838 |
fs.NotifyChange(ENotifyEntry,reqStat4,path4);
|
sl@0
|
2839 |
test(reqStat1==KRequestPending);
|
sl@0
|
2840 |
test(reqStat2==KRequestPending);
|
sl@0
|
2841 |
test(reqStat3==KRequestPending);
|
sl@0
|
2842 |
test(reqStat4==KRequestPending);
|
sl@0
|
2843 |
|
sl@0
|
2844 |
r=gSleepThread.CreateLocal(0);
|
sl@0
|
2845 |
test(r==KErrNone);
|
sl@0
|
2846 |
RThread thread2;
|
sl@0
|
2847 |
r=thread2.Create(_L("TestThread2"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
|
sl@0
|
2848 |
test(r==KErrNone);
|
sl@0
|
2849 |
thread2.Resume();
|
sl@0
|
2850 |
gSleepThread.Wait();
|
sl@0
|
2851 |
|
sl@0
|
2852 |
User::WaitForRequest(reqStat1);
|
sl@0
|
2853 |
test(reqStat1==KErrNone);
|
sl@0
|
2854 |
test(reqStat2==KRequestPending);
|
sl@0
|
2855 |
User::WaitForRequest(reqStat3);
|
sl@0
|
2856 |
test(reqStat3==KErrNone);
|
sl@0
|
2857 |
test(reqStat4==KRequestPending);
|
sl@0
|
2858 |
|
sl@0
|
2859 |
gSleepThread.Close();
|
sl@0
|
2860 |
thread2.Close();
|
sl@0
|
2861 |
|
sl@0
|
2862 |
fs.NotifyChange(ENotifyAll,reqStat1,path1);
|
sl@0
|
2863 |
fs.NotifyChange(ENotifyAll,reqStat3,path3);
|
sl@0
|
2864 |
|
sl@0
|
2865 |
test(reqStat1==KRequestPending);
|
sl@0
|
2866 |
test(reqStat2==KRequestPending);
|
sl@0
|
2867 |
test(reqStat3==KRequestPending);
|
sl@0
|
2868 |
test(reqStat4==KRequestPending);
|
sl@0
|
2869 |
|
sl@0
|
2870 |
r=gSleepThread.CreateLocal(0);
|
sl@0
|
2871 |
test(r==KErrNone);
|
sl@0
|
2872 |
RThread thread3;
|
sl@0
|
2873 |
r=thread3.Create(_L("TestThread3"),ThreadEntryPoint,0x4000,KHeapSize,KHeapSize,(TAny*)ETest5);
|
sl@0
|
2874 |
test(r==KErrNone);
|
sl@0
|
2875 |
thread3.Resume();
|
sl@0
|
2876 |
gSleepThread.Wait();
|
sl@0
|
2877 |
|
sl@0
|
2878 |
User::WaitForRequest(reqStat1);
|
sl@0
|
2879 |
test(reqStat1==KErrNone);
|
sl@0
|
2880 |
test(reqStat2==KRequestPending); // Monitoring with ENotifyEntry
|
sl@0
|
2881 |
User::WaitForRequest(reqStat3);
|
sl@0
|
2882 |
test(reqStat3==KErrNone);
|
sl@0
|
2883 |
test(reqStat4==KRequestPending); // Monitoring with ENotifyEntry
|
sl@0
|
2884 |
|
sl@0
|
2885 |
RFs fs2;
|
sl@0
|
2886 |
r=fs2.Connect();
|
sl@0
|
2887 |
test(r==KErrNone);
|
sl@0
|
2888 |
r=fs2.SetSessionPath(gSessionPath);
|
sl@0
|
2889 |
test(r==KErrNone);
|
sl@0
|
2890 |
|
sl@0
|
2891 |
TRequestStatus reqStat(KRequestPending);
|
sl@0
|
2892 |
fs2.NotifyChange(ENotifyEntry,reqStat);
|
sl@0
|
2893 |
test(reqStat==KRequestPending);
|
sl@0
|
2894 |
|
sl@0
|
2895 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\kangaroo.txt"));
|
sl@0
|
2896 |
test(r==KErrNone);
|
sl@0
|
2897 |
User::WaitForRequest(reqStat2);
|
sl@0
|
2898 |
test(reqStat2==KErrNone);
|
sl@0
|
2899 |
test(reqStat4==KRequestPending);
|
sl@0
|
2900 |
User::WaitForRequest(reqStat);
|
sl@0
|
2901 |
test(reqStat==KErrNone);
|
sl@0
|
2902 |
|
sl@0
|
2903 |
fs2.NotifyChange(ENotifyAll,reqStat);
|
sl@0
|
2904 |
test(reqStat==KRequestPending);
|
sl@0
|
2905 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\koala.txt"));
|
sl@0
|
2906 |
test(r==KErrNone);
|
sl@0
|
2907 |
User::WaitForRequest(reqStat);
|
sl@0
|
2908 |
test(reqStat==KErrNone);
|
sl@0
|
2909 |
test(reqStat4==KRequestPending);
|
sl@0
|
2910 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\dingo.txt"));
|
sl@0
|
2911 |
test(r==KErrNone);
|
sl@0
|
2912 |
User::WaitForRequest(reqStat4);
|
sl@0
|
2913 |
test(reqStat4==KErrNone);
|
sl@0
|
2914 |
|
sl@0
|
2915 |
gSleepThread.Close();
|
sl@0
|
2916 |
thread3.Close();
|
sl@0
|
2917 |
fs.Close();
|
sl@0
|
2918 |
}
|
sl@0
|
2919 |
|
sl@0
|
2920 |
static void Test18()
|
sl@0
|
2921 |
|
sl@0
|
2922 |
{
|
sl@0
|
2923 |
//
|
sl@0
|
2924 |
// Test notification request succeeds or fails as appropriate to the notification type
|
sl@0
|
2925 |
// with all file operations which result in notifications
|
sl@0
|
2926 |
// enum TNotifyType {ENotifyEntry=0x00,ENotifyAll=0x01,ENotifyFile=0x04,ENotifyDir=0x08,
|
sl@0
|
2927 |
// ENotifyAttributes=0x10,ENotifyWrite=0x20,ENotifyDisk=0x40};
|
sl@0
|
2928 |
//
|
sl@0
|
2929 |
RFs fs;
|
sl@0
|
2930 |
TInt r=fs.Connect(); // Session to be notified of any changes
|
sl@0
|
2931 |
test(r==KErrNone);
|
sl@0
|
2932 |
r=fs.SetSessionPath(gSessionPath);
|
sl@0
|
2933 |
test(r==KErrNone);
|
sl@0
|
2934 |
|
sl@0
|
2935 |
// RFile::Write() to a file within the monitored directory
|
sl@0
|
2936 |
test.Next(_L("RFile::Write()"));
|
sl@0
|
2937 |
TFileName path=_L("\\F32-TST\\NOTIFY\\NewFile.txt");
|
sl@0
|
2938 |
TRequestStatus reqStat(KRequestPending);
|
sl@0
|
2939 |
TRequestStatus reqStat2(KRequestPending);
|
sl@0
|
2940 |
TRequestStatus reqStat3(KRequestPending);
|
sl@0
|
2941 |
TRequestStatus reqStat4(KRequestPending);
|
sl@0
|
2942 |
TRequestStatus reqStat5(KRequestPending);
|
sl@0
|
2943 |
TRequestStatus reqStat6(KRequestPending);
|
sl@0
|
2944 |
TRequestStatus reqStat7(KRequestPending);
|
sl@0
|
2945 |
|
sl@0
|
2946 |
|
sl@0
|
2947 |
RFile file;
|
sl@0
|
2948 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite);
|
sl@0
|
2949 |
test(r==KErrNone);
|
sl@0
|
2950 |
|
sl@0
|
2951 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
2952 |
fs.NotifyChange(ENotifyFile,reqStat2,path);
|
sl@0
|
2953 |
fs.NotifyChange(ENotifyWrite,reqStat3,path);
|
sl@0
|
2954 |
fs.NotifyChange(ENotifyDir,reqStat4,path);
|
sl@0
|
2955 |
fs.NotifyChange(ENotifyEntry,reqStat5,path);
|
sl@0
|
2956 |
fs.NotifyChange(ENotifyAttributes,reqStat6,path);
|
sl@0
|
2957 |
fs.NotifyChange(ENotifyDisk,reqStat7,path);
|
sl@0
|
2958 |
|
sl@0
|
2959 |
|
sl@0
|
2960 |
test(reqStat==KRequestPending);
|
sl@0
|
2961 |
test(reqStat2==KRequestPending);
|
sl@0
|
2962 |
test(reqStat3==KRequestPending);
|
sl@0
|
2963 |
User::WaitForRequest(reqStat4);
|
sl@0
|
2964 |
test(reqStat4==KErrArgument); // Cannot monitor a file with ENotifyDir
|
sl@0
|
2965 |
test(reqStat5==KRequestPending);
|
sl@0
|
2966 |
test(reqStat6==KRequestPending);
|
sl@0
|
2967 |
fs.NotifyChange(ENotifyEntry,reqStat4,path);
|
sl@0
|
2968 |
test(reqStat4==KRequestPending);
|
sl@0
|
2969 |
|
sl@0
|
2970 |
r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
|
sl@0
|
2971 |
file.Close();
|
sl@0
|
2972 |
|
sl@0
|
2973 |
User::WaitForRequest(reqStat);
|
sl@0
|
2974 |
test(reqStat==KErrNone);
|
sl@0
|
2975 |
test(reqStat2==KRequestPending); // Monitoring with ENotifyFile
|
sl@0
|
2976 |
User::WaitForRequest(reqStat3);
|
sl@0
|
2977 |
test(reqStat3==KErrNone);
|
sl@0
|
2978 |
test(reqStat4==KRequestPending); // Monitoring with ENotifyEntry
|
sl@0
|
2979 |
test(reqStat5==KRequestPending);
|
sl@0
|
2980 |
test(reqStat6==KRequestPending);
|
sl@0
|
2981 |
test(reqStat7==KRequestPending);
|
sl@0
|
2982 |
fs.NotifyChangeCancel(); // Cancels all outstanding notification requests
|
sl@0
|
2983 |
|
sl@0
|
2984 |
User::WaitForRequest(reqStat2);
|
sl@0
|
2985 |
test(reqStat2==KErrCancel);
|
sl@0
|
2986 |
User::WaitForRequest(reqStat4);
|
sl@0
|
2987 |
test(reqStat4==KErrCancel);
|
sl@0
|
2988 |
User::WaitForRequest(reqStat5);
|
sl@0
|
2989 |
test(reqStat5==KErrCancel);
|
sl@0
|
2990 |
User::WaitForRequest(reqStat6);
|
sl@0
|
2991 |
test(reqStat6==KErrCancel);
|
sl@0
|
2992 |
User::WaitForRequest(reqStat7);
|
sl@0
|
2993 |
test(reqStat7==KErrCancel);
|
sl@0
|
2994 |
|
sl@0
|
2995 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite);
|
sl@0
|
2996 |
test(r==KErrNone);
|
sl@0
|
2997 |
|
sl@0
|
2998 |
// RFile::SetAtt() of a file within the monitored directory
|
sl@0
|
2999 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3000 |
fs.NotifyChange(ENotifyFile,reqStat2,path);
|
sl@0
|
3001 |
fs.NotifyChange(ENotifyEntry,reqStat3,path);
|
sl@0
|
3002 |
fs.NotifyChange(ENotifyAttributes,reqStat4,path);
|
sl@0
|
3003 |
fs.NotifyChange(ENotifyDir,reqStat5,path);
|
sl@0
|
3004 |
fs.NotifyChange(ENotifyWrite,reqStat6,path);
|
sl@0
|
3005 |
fs.NotifyChange(ENotifyDisk,reqStat7,path);
|
sl@0
|
3006 |
|
sl@0
|
3007 |
test(reqStat==KRequestPending);
|
sl@0
|
3008 |
test(reqStat2==KRequestPending);
|
sl@0
|
3009 |
test(reqStat3==KRequestPending);
|
sl@0
|
3010 |
test(reqStat4==KRequestPending);
|
sl@0
|
3011 |
User::WaitForRequest(reqStat5);
|
sl@0
|
3012 |
test(reqStat5==KErrArgument);
|
sl@0
|
3013 |
test(reqStat6==KRequestPending);
|
sl@0
|
3014 |
test(reqStat7==KRequestPending);
|
sl@0
|
3015 |
|
sl@0
|
3016 |
test.Next(_L("RFile::SetAtt()"));
|
sl@0
|
3017 |
r=file.SetAtt(KEntryAttSystem,KEntryAttNormal);
|
sl@0
|
3018 |
test(r==KErrNone);
|
sl@0
|
3019 |
User::WaitForRequest(reqStat);
|
sl@0
|
3020 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3021 |
test(reqStat==KErrNone);
|
sl@0
|
3022 |
test(reqStat2==KRequestPending); // Monitoring with ENotifyFile
|
sl@0
|
3023 |
test(reqStat3==KRequestPending); // Monitoring with ENotifyEntry
|
sl@0
|
3024 |
test(reqStat4==KErrNone); // Monitoring a file - can't use ENotifyDir
|
sl@0
|
3025 |
test(reqStat6==KRequestPending);
|
sl@0
|
3026 |
test(reqStat7==KRequestPending);
|
sl@0
|
3027 |
|
sl@0
|
3028 |
fs.NotifyChange(ENotifyWrite,reqStat,path);
|
sl@0
|
3029 |
test(reqStat==KRequestPending);
|
sl@0
|
3030 |
fs.NotifyChange(ENotifyDir,reqStat4,path);
|
sl@0
|
3031 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3032 |
test(reqStat4==KErrArgument);
|
sl@0
|
3033 |
r=file.SetAtt(KEntryAttNormal,KEntryAttSystem);
|
sl@0
|
3034 |
test(r==KErrNone);
|
sl@0
|
3035 |
test(reqStat==KRequestPending); // Monitoring with ENotifyWrite
|
sl@0
|
3036 |
fs.NotifyChangeCancel(); // Cancel outstanding notification request
|
sl@0
|
3037 |
|
sl@0
|
3038 |
User::WaitForRequest(reqStat);
|
sl@0
|
3039 |
test(reqStat==KErrCancel);
|
sl@0
|
3040 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3041 |
test(reqStat2==KErrCancel);
|
sl@0
|
3042 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3043 |
test(reqStat3==KErrCancel);
|
sl@0
|
3044 |
User::WaitForRequest(reqStat6);
|
sl@0
|
3045 |
test(reqStat6==KErrCancel);
|
sl@0
|
3046 |
User::WaitForRequest(reqStat7);
|
sl@0
|
3047 |
test(reqStat7==KErrCancel);
|
sl@0
|
3048 |
|
sl@0
|
3049 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3050 |
fs.NotifyChange(ENotifyFile,reqStat2,path);
|
sl@0
|
3051 |
fs.NotifyChange(ENotifyEntry,reqStat3,path);
|
sl@0
|
3052 |
fs.NotifyChange(ENotifyAttributes,reqStat4,path);
|
sl@0
|
3053 |
|
sl@0
|
3054 |
test(reqStat==KRequestPending);
|
sl@0
|
3055 |
test(reqStat2==KRequestPending);
|
sl@0
|
3056 |
test(reqStat3==KRequestPending);
|
sl@0
|
3057 |
test(reqStat4==KRequestPending);
|
sl@0
|
3058 |
|
sl@0
|
3059 |
// RFile::SetSize() of a file within the monitored directory
|
sl@0
|
3060 |
test.Next(_L("RFile::SetSize()"));
|
sl@0
|
3061 |
r=file.SetSize(256);
|
sl@0
|
3062 |
test(r==KErrNone);
|
sl@0
|
3063 |
User::WaitForRequest(reqStat);
|
sl@0
|
3064 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3065 |
test(reqStat==KErrNone);
|
sl@0
|
3066 |
test(reqStat2==KRequestPending); // Monitoring with ENotifyFile
|
sl@0
|
3067 |
test(reqStat3==KRequestPending); // Monitoring with ENotifyEntry
|
sl@0
|
3068 |
test(reqStat4==KErrNone);
|
sl@0
|
3069 |
|
sl@0
|
3070 |
fs.NotifyChange(ENotifyWrite,reqStat,path);
|
sl@0
|
3071 |
test(reqStat==KRequestPending);
|
sl@0
|
3072 |
fs.NotifyChange(ENotifyDir,reqStat4,path);
|
sl@0
|
3073 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3074 |
test(reqStat4==KErrArgument);
|
sl@0
|
3075 |
r=file.SetSize(200);
|
sl@0
|
3076 |
test(r==KErrNone);
|
sl@0
|
3077 |
User::After(1000000);
|
sl@0
|
3078 |
test(reqStat==KRequestPending); // Monitoring with ENotifyWrite
|
sl@0
|
3079 |
|
sl@0
|
3080 |
file.Close();
|
sl@0
|
3081 |
fs.NotifyChangeCancel(); // Cancels all outstanding notification requests
|
sl@0
|
3082 |
|
sl@0
|
3083 |
User::WaitForRequest(reqStat);
|
sl@0
|
3084 |
test(reqStat==KErrCancel);
|
sl@0
|
3085 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3086 |
test(reqStat2==KErrCancel);
|
sl@0
|
3087 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3088 |
test(reqStat3==KErrCancel);
|
sl@0
|
3089 |
|
sl@0
|
3090 |
// RFile::Temp() to create a temp file within the monitored directory
|
sl@0
|
3091 |
test.Next(_L("RFile::Temp()"));
|
sl@0
|
3092 |
path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
3093 |
|
sl@0
|
3094 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3095 |
fs.NotifyChange(ENotifyDir,reqStat2,path);
|
sl@0
|
3096 |
fs.NotifyChange(ENotifyEntry,reqStat3,path);
|
sl@0
|
3097 |
fs.NotifyChange(ENotifyAttributes,reqStat4,path);
|
sl@0
|
3098 |
|
sl@0
|
3099 |
test(reqStat==KRequestPending);
|
sl@0
|
3100 |
test(reqStat2==KRequestPending);
|
sl@0
|
3101 |
test(reqStat3==KRequestPending);
|
sl@0
|
3102 |
test(reqStat4==KRequestPending);
|
sl@0
|
3103 |
|
sl@0
|
3104 |
TFileName fileName;
|
sl@0
|
3105 |
r=file.Temp(TheFs,path,fileName,EFileWrite);
|
sl@0
|
3106 |
test(r==KErrNone);
|
sl@0
|
3107 |
User::WaitForRequest(reqStat);
|
sl@0
|
3108 |
test(reqStat==KErrNone);
|
sl@0
|
3109 |
test(reqStat2==KRequestPending);
|
sl@0
|
3110 |
test(reqStat3==KRequestPending); // Monitoring ENotifyEntry
|
sl@0
|
3111 |
test(reqStat4==KRequestPending); // Monitoring ENotifyAttributes
|
sl@0
|
3112 |
file.Close();
|
sl@0
|
3113 |
fs.NotifyChangeCancel();
|
sl@0
|
3114 |
|
sl@0
|
3115 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3116 |
test(reqStat2==KErrCancel);
|
sl@0
|
3117 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3118 |
test(reqStat3==KErrCancel);
|
sl@0
|
3119 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3120 |
test(reqStat4==KErrCancel);
|
sl@0
|
3121 |
|
sl@0
|
3122 |
fs.NotifyChange(ENotifyFile,reqStat,path);
|
sl@0
|
3123 |
fs.NotifyChange(ENotifyDisk,reqStat2,path);
|
sl@0
|
3124 |
fs.NotifyChange(ENotifyWrite,reqStat3,path);
|
sl@0
|
3125 |
r=file.Temp(TheFs,path,fileName,EFileWrite);
|
sl@0
|
3126 |
test(r==KErrNone);
|
sl@0
|
3127 |
test(reqStat==KRequestPending); // Monitoring ENotifyFile
|
sl@0
|
3128 |
test(reqStat2==KRequestPending); // Monitoring ENotifyDisk
|
sl@0
|
3129 |
test(reqStat3==KRequestPending); // Monitoring ENotifyWrite
|
sl@0
|
3130 |
file.Close();
|
sl@0
|
3131 |
|
sl@0
|
3132 |
fs.NotifyChangeCancel(); // Cancels all outstanding notification requests
|
sl@0
|
3133 |
|
sl@0
|
3134 |
User::WaitForRequest(reqStat);
|
sl@0
|
3135 |
test(reqStat==KErrCancel);
|
sl@0
|
3136 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3137 |
test(reqStat2==KErrCancel);
|
sl@0
|
3138 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3139 |
test(reqStat3==KErrCancel);
|
sl@0
|
3140 |
|
sl@0
|
3141 |
// RFile::SetModified() to change modification time of a file within monitored dir
|
sl@0
|
3142 |
test.Next(_L("RFile::SetModified()"));
|
sl@0
|
3143 |
path=_L("\\F32-TST\\NOTIFY\\NewFile.txt");
|
sl@0
|
3144 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3145 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3146 |
fs.NotifyChange(ENotifyAttributes,reqStat3,path);
|
sl@0
|
3147 |
fs.NotifyChange(ENotifyFile,reqStat4,path);
|
sl@0
|
3148 |
|
sl@0
|
3149 |
test(reqStat==KRequestPending);
|
sl@0
|
3150 |
test(reqStat2==KRequestPending);
|
sl@0
|
3151 |
test(reqStat3==KRequestPending);
|
sl@0
|
3152 |
test(reqStat4==KRequestPending);
|
sl@0
|
3153 |
|
sl@0
|
3154 |
TTime now;
|
sl@0
|
3155 |
now.HomeTime();
|
sl@0
|
3156 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite);
|
sl@0
|
3157 |
test(r==KErrNone);
|
sl@0
|
3158 |
test(reqStat==KRequestPending);
|
sl@0
|
3159 |
file.SetModified(now);
|
sl@0
|
3160 |
file.Close();
|
sl@0
|
3161 |
User::WaitForRequest(reqStat);
|
sl@0
|
3162 |
test(reqStat==KErrNone);
|
sl@0
|
3163 |
test(reqStat2==KRequestPending);
|
sl@0
|
3164 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3165 |
test(reqStat3==KErrNone);
|
sl@0
|
3166 |
test(reqStat4==KRequestPending);
|
sl@0
|
3167 |
fs.NotifyChangeCancel();
|
sl@0
|
3168 |
|
sl@0
|
3169 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3170 |
test(reqStat2==KErrCancel);
|
sl@0
|
3171 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3172 |
test(reqStat4==KErrCancel);
|
sl@0
|
3173 |
|
sl@0
|
3174 |
// RFs::SetEntry() to change a directory entry within the monitored directory
|
sl@0
|
3175 |
test.Next(_L("RFs::SetEntry()"));
|
sl@0
|
3176 |
TEntry entry;
|
sl@0
|
3177 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3178 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3179 |
fs.NotifyChange(ENotifyAttributes,reqStat3,path);
|
sl@0
|
3180 |
fs.NotifyChange(ENotifyDisk,reqStat4,path);
|
sl@0
|
3181 |
|
sl@0
|
3182 |
test(reqStat==KRequestPending);
|
sl@0
|
3183 |
test(reqStat2==KRequestPending);
|
sl@0
|
3184 |
test(reqStat3==KRequestPending);
|
sl@0
|
3185 |
test(reqStat4==KRequestPending);
|
sl@0
|
3186 |
|
sl@0
|
3187 |
r=TheFs.Entry(_L("\\F32-TST\\NOTIFY\\NewFile.txt"),entry);
|
sl@0
|
3188 |
test(reqStat==KRequestPending);
|
sl@0
|
3189 |
now.HomeTime();
|
sl@0
|
3190 |
r=TheFs.SetEntry(_L("\\F32-TST\\NOTIFY\\NewFile.txt"),now,KEntryAttHidden,KEntryAttNormal);
|
sl@0
|
3191 |
test(r==KErrNone);
|
sl@0
|
3192 |
User::WaitForRequest(reqStat);
|
sl@0
|
3193 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3194 |
test(reqStat==KErrNone);
|
sl@0
|
3195 |
test(reqStat2==KRequestPending);
|
sl@0
|
3196 |
test(reqStat3==KErrNone);
|
sl@0
|
3197 |
test(reqStat4==KRequestPending);
|
sl@0
|
3198 |
fs.NotifyChangeCancel();
|
sl@0
|
3199 |
|
sl@0
|
3200 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3201 |
test(reqStat2==KErrCancel);
|
sl@0
|
3202 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3203 |
test(reqStat4==KErrCancel);
|
sl@0
|
3204 |
|
sl@0
|
3205 |
// RFile::Set() to change file's modification time and attributes
|
sl@0
|
3206 |
test.Next(_L("RFile::Set()"));
|
sl@0
|
3207 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3208 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3209 |
fs.NotifyChange(ENotifyAttributes,reqStat3,path);
|
sl@0
|
3210 |
fs.NotifyChange(ENotifyWrite,reqStat4,path);
|
sl@0
|
3211 |
|
sl@0
|
3212 |
test(reqStat==KRequestPending);
|
sl@0
|
3213 |
test(reqStat2==KRequestPending);
|
sl@0
|
3214 |
test(reqStat3==KRequestPending);
|
sl@0
|
3215 |
test(reqStat4==KRequestPending);
|
sl@0
|
3216 |
|
sl@0
|
3217 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileWrite);
|
sl@0
|
3218 |
test(r==KErrNone);
|
sl@0
|
3219 |
test(reqStat==KRequestPending);
|
sl@0
|
3220 |
now.HomeTime();
|
sl@0
|
3221 |
r=file.Set(now,KEntryAttNormal,KEntryAttHidden);
|
sl@0
|
3222 |
file.Close();
|
sl@0
|
3223 |
User::WaitForRequest(reqStat);
|
sl@0
|
3224 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3225 |
test(reqStat==KErrNone);
|
sl@0
|
3226 |
test(reqStat2==KRequestPending);
|
sl@0
|
3227 |
test(reqStat3==KErrNone);
|
sl@0
|
3228 |
test(reqStat4==KRequestPending);
|
sl@0
|
3229 |
fs.NotifyChangeCancel();
|
sl@0
|
3230 |
|
sl@0
|
3231 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3232 |
test(reqStat2==KErrCancel);
|
sl@0
|
3233 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3234 |
test(reqStat4==KErrCancel);
|
sl@0
|
3235 |
|
sl@0
|
3236 |
// RFs::SetDriveName()
|
sl@0
|
3237 |
|
sl@0
|
3238 |
test.Next(_L("RFs::SetDriveName()"));
|
sl@0
|
3239 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3240 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3241 |
fs.NotifyChange(ENotifyDisk,reqStat3,path);
|
sl@0
|
3242 |
fs.NotifyChange(ENotifyAttributes,reqStat4,path);
|
sl@0
|
3243 |
|
sl@0
|
3244 |
test(reqStat==KRequestPending);
|
sl@0
|
3245 |
test(reqStat2==KRequestPending);
|
sl@0
|
3246 |
test(reqStat3==KRequestPending);
|
sl@0
|
3247 |
test(reqStat4==KRequestPending);
|
sl@0
|
3248 |
User::After(KNotifyChangeAfter);
|
sl@0
|
3249 |
|
sl@0
|
3250 |
r=TheFs.SetDriveName(KDefaultDrive,_L("DRIVETEST"));
|
sl@0
|
3251 |
test(r==KErrNone);
|
sl@0
|
3252 |
User::WaitForRequest(reqStat);
|
sl@0
|
3253 |
test(reqStat==KErrNone);
|
sl@0
|
3254 |
test(reqStat2==KRequestPending);
|
sl@0
|
3255 |
test(reqStat3==KRequestPending);
|
sl@0
|
3256 |
test(reqStat4==KRequestPending);
|
sl@0
|
3257 |
fs.NotifyChangeCancel();
|
sl@0
|
3258 |
|
sl@0
|
3259 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3260 |
test(reqStat2==KErrCancel);
|
sl@0
|
3261 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3262 |
test(reqStat3==KErrCancel);
|
sl@0
|
3263 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3264 |
test(reqStat4==KErrCancel);
|
sl@0
|
3265 |
|
sl@0
|
3266 |
// RFs::MkDir()
|
sl@0
|
3267 |
test.Next(_L("RFs::MkDir()"));
|
sl@0
|
3268 |
path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
3269 |
|
sl@0
|
3270 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3271 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3272 |
fs.NotifyChange(ENotifyDir,reqStat3,path);
|
sl@0
|
3273 |
fs.NotifyChange(ENotifyFile,reqStat4,path);
|
sl@0
|
3274 |
|
sl@0
|
3275 |
test(reqStat==KRequestPending);
|
sl@0
|
3276 |
test(reqStat2==KRequestPending);
|
sl@0
|
3277 |
test(reqStat3==KRequestPending);
|
sl@0
|
3278 |
test(reqStat4==KRequestPending);
|
sl@0
|
3279 |
|
sl@0
|
3280 |
r=TheFs.MkDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
|
sl@0
|
3281 |
test(r==KErrNone);
|
sl@0
|
3282 |
User::WaitForRequest(reqStat);
|
sl@0
|
3283 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3284 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3285 |
test(reqStat==KErrNone);
|
sl@0
|
3286 |
test(reqStat2==KErrNone);
|
sl@0
|
3287 |
test(reqStat3==KErrNone);
|
sl@0
|
3288 |
test(reqStat4==KRequestPending);
|
sl@0
|
3289 |
|
sl@0
|
3290 |
// RFs::RmDir()
|
sl@0
|
3291 |
test.Next(_L("RFs::RmDir()"));
|
sl@0
|
3292 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3293 |
fs.NotifyChange(ENotifyDir,reqStat2,path);
|
sl@0
|
3294 |
fs.NotifyChange(ENotifyWrite,reqStat3,path);
|
sl@0
|
3295 |
|
sl@0
|
3296 |
test(reqStat==KRequestPending);
|
sl@0
|
3297 |
test(reqStat2==KRequestPending);
|
sl@0
|
3298 |
test(reqStat3==KRequestPending);
|
sl@0
|
3299 |
|
sl@0
|
3300 |
r=TheFs.RmDir(_L("\\F32-TST\\NOTIFY\\EMERALD_CITY\\"));
|
sl@0
|
3301 |
test(r==KErrNone);
|
sl@0
|
3302 |
User::WaitForRequest(reqStat);
|
sl@0
|
3303 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3304 |
test(reqStat==KErrNone);
|
sl@0
|
3305 |
test(reqStat2==KErrNone);
|
sl@0
|
3306 |
test(reqStat3==KRequestPending);
|
sl@0
|
3307 |
test(reqStat4==KRequestPending);
|
sl@0
|
3308 |
fs.NotifyChangeCancel();
|
sl@0
|
3309 |
|
sl@0
|
3310 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3311 |
test(reqStat3==KErrCancel);
|
sl@0
|
3312 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3313 |
test(reqStat4==KErrCancel);
|
sl@0
|
3314 |
|
sl@0
|
3315 |
// RFile::Create()
|
sl@0
|
3316 |
test.Next(_L("RFile::Create()"));
|
sl@0
|
3317 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3318 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3319 |
fs.NotifyChange(ENotifyDir,reqStat3,path);
|
sl@0
|
3320 |
fs.NotifyChange(ENotifyFile,reqStat4,path);
|
sl@0
|
3321 |
|
sl@0
|
3322 |
test(reqStat==KRequestPending);
|
sl@0
|
3323 |
test(reqStat2==KRequestPending);
|
sl@0
|
3324 |
test(reqStat3==KRequestPending);
|
sl@0
|
3325 |
test(reqStat4==KRequestPending);
|
sl@0
|
3326 |
|
sl@0
|
3327 |
r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\Good_Witch.bat"),EFileRead|EFileWrite);
|
sl@0
|
3328 |
test(r==KErrNone);
|
sl@0
|
3329 |
User::WaitForRequest(reqStat);
|
sl@0
|
3330 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3331 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3332 |
test(reqStat==KErrNone);
|
sl@0
|
3333 |
test(reqStat2==KErrNone);
|
sl@0
|
3334 |
test(reqStat3==KRequestPending); // Monitoring ENotifyDir
|
sl@0
|
3335 |
test(reqStat4==KErrNone);
|
sl@0
|
3336 |
file.Close();
|
sl@0
|
3337 |
fs.NotifyChangeCancel(reqStat3);
|
sl@0
|
3338 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3339 |
|
sl@0
|
3340 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3341 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3342 |
fs.NotifyChange(ENotifyDisk,reqStat3,path);
|
sl@0
|
3343 |
fs.NotifyChange(ENotifyWrite,reqStat4,path);
|
sl@0
|
3344 |
|
sl@0
|
3345 |
test(reqStat==KRequestPending);
|
sl@0
|
3346 |
test(reqStat2==KRequestPending);
|
sl@0
|
3347 |
test(reqStat3==KRequestPending);
|
sl@0
|
3348 |
test(reqStat4==KRequestPending);
|
sl@0
|
3349 |
|
sl@0
|
3350 |
r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\Bad_Witch.bat"),EFileRead|EFileWrite);
|
sl@0
|
3351 |
test(r==KErrNone);
|
sl@0
|
3352 |
User::WaitForRequest(reqStat);
|
sl@0
|
3353 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3354 |
test(reqStat==KErrNone);
|
sl@0
|
3355 |
test(reqStat2==KErrNone);
|
sl@0
|
3356 |
test(reqStat3==KRequestPending);
|
sl@0
|
3357 |
test(reqStat4==KRequestPending);
|
sl@0
|
3358 |
file.Close();
|
sl@0
|
3359 |
fs.NotifyChangeCancel();
|
sl@0
|
3360 |
|
sl@0
|
3361 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3362 |
test(reqStat3==KErrCancel);
|
sl@0
|
3363 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3364 |
test(reqStat4==KErrCancel);
|
sl@0
|
3365 |
|
sl@0
|
3366 |
// RFs::Delete()
|
sl@0
|
3367 |
test.Next(_L("RFs::Delete()"));
|
sl@0
|
3368 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3369 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3370 |
fs.NotifyChange(ENotifyDir,reqStat3,path);
|
sl@0
|
3371 |
fs.NotifyChange(ENotifyFile,reqStat4,path);
|
sl@0
|
3372 |
|
sl@0
|
3373 |
test(reqStat==KRequestPending);
|
sl@0
|
3374 |
test(reqStat2==KRequestPending);
|
sl@0
|
3375 |
test(reqStat3==KRequestPending);
|
sl@0
|
3376 |
test(reqStat4==KRequestPending);
|
sl@0
|
3377 |
|
sl@0
|
3378 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Good_Witch.bat"));
|
sl@0
|
3379 |
test(r==KErrNone);
|
sl@0
|
3380 |
User::WaitForRequest(reqStat);
|
sl@0
|
3381 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3382 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3383 |
test(reqStat==KErrNone);
|
sl@0
|
3384 |
test(reqStat2==KErrNone);
|
sl@0
|
3385 |
test(reqStat3==KRequestPending); // Monitoring ENotifyDir
|
sl@0
|
3386 |
test(reqStat4==KErrNone);
|
sl@0
|
3387 |
fs.NotifyChangeCancel(reqStat3);
|
sl@0
|
3388 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3389 |
test(reqStat3==KErrCancel);
|
sl@0
|
3390 |
|
sl@0
|
3391 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3392 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3393 |
fs.NotifyChange(ENotifyAttributes,reqStat3,path);
|
sl@0
|
3394 |
fs.NotifyChange(ENotifyAll,reqStat4,path);
|
sl@0
|
3395 |
|
sl@0
|
3396 |
test(reqStat==KRequestPending);
|
sl@0
|
3397 |
test(reqStat2==KRequestPending);
|
sl@0
|
3398 |
test(reqStat3==KRequestPending);
|
sl@0
|
3399 |
test(reqStat4==KRequestPending);
|
sl@0
|
3400 |
|
sl@0
|
3401 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Bad_Witch.bat"));
|
sl@0
|
3402 |
test(r==KErrNone);
|
sl@0
|
3403 |
User::WaitForRequest(reqStat);
|
sl@0
|
3404 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3405 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3406 |
test(reqStat==KErrNone);
|
sl@0
|
3407 |
test(reqStat2==KErrNone);
|
sl@0
|
3408 |
test(reqStat3==KRequestPending);
|
sl@0
|
3409 |
test(reqStat4==KErrNone);
|
sl@0
|
3410 |
fs.NotifyChangeCancel(reqStat3);
|
sl@0
|
3411 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3412 |
test(reqStat3==KErrCancel);
|
sl@0
|
3413 |
|
sl@0
|
3414 |
// RFile::Replace()
|
sl@0
|
3415 |
test.Next(_L("RFile::Replace()"));
|
sl@0
|
3416 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3417 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3418 |
fs.NotifyChange(ENotifyFile,reqStat3,path);
|
sl@0
|
3419 |
fs.NotifyChange(ENotifyDir,reqStat4,path);
|
sl@0
|
3420 |
|
sl@0
|
3421 |
test(reqStat==KRequestPending);
|
sl@0
|
3422 |
test(reqStat2==KRequestPending);
|
sl@0
|
3423 |
test(reqStat3==KRequestPending);
|
sl@0
|
3424 |
test(reqStat4==KRequestPending);
|
sl@0
|
3425 |
|
sl@0
|
3426 |
r=file.Replace(TheFs,_L("\\F32-TST\\NOTIFY\\Good_Witch.bat"),EFileRead|EFileWrite);
|
sl@0
|
3427 |
test(r==KErrNone);
|
sl@0
|
3428 |
User::WaitForRequest(reqStat);
|
sl@0
|
3429 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3430 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3431 |
test(reqStat==KErrNone);
|
sl@0
|
3432 |
test(reqStat2==KErrNone);
|
sl@0
|
3433 |
test(reqStat3==KErrNone);
|
sl@0
|
3434 |
test(reqStat4==KRequestPending);
|
sl@0
|
3435 |
file.Close();
|
sl@0
|
3436 |
fs.NotifyChangeCancel();
|
sl@0
|
3437 |
|
sl@0
|
3438 |
test(reqStat==KErrNone);
|
sl@0
|
3439 |
test(reqStat2==KErrNone);
|
sl@0
|
3440 |
test(reqStat3==KErrNone);
|
sl@0
|
3441 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3442 |
test(reqStat4==KErrCancel);
|
sl@0
|
3443 |
|
sl@0
|
3444 |
// RFs::Delete()
|
sl@0
|
3445 |
test.Next(_L("RFs::Delete()"));
|
sl@0
|
3446 |
path=_L("\\F32-TST\\NOTIFY\\Good_Witch.bat");
|
sl@0
|
3447 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3448 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3449 |
fs.NotifyChange(ENotifyFile,reqStat3,path);
|
sl@0
|
3450 |
fs.NotifyChange(ENotifyDir,reqStat4,path);
|
sl@0
|
3451 |
|
sl@0
|
3452 |
test(reqStat==KRequestPending);
|
sl@0
|
3453 |
test(reqStat2==KRequestPending);
|
sl@0
|
3454 |
test(reqStat3==KRequestPending);
|
sl@0
|
3455 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3456 |
test(reqStat4==KErrArgument);
|
sl@0
|
3457 |
|
sl@0
|
3458 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Good_Witch.bat"));
|
sl@0
|
3459 |
test(r==KErrNone);
|
sl@0
|
3460 |
User::WaitForRequest(reqStat);
|
sl@0
|
3461 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3462 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3463 |
test(reqStat==KErrNone);
|
sl@0
|
3464 |
test(reqStat2==KErrNone);
|
sl@0
|
3465 |
test(reqStat3==KErrNone);
|
sl@0
|
3466 |
test(reqStat4==KErrArgument);
|
sl@0
|
3467 |
|
sl@0
|
3468 |
// RFs::SetVolumeLabel()
|
sl@0
|
3469 |
test.Next(_L("RFs::SetVolumeLabel()"));
|
sl@0
|
3470 |
path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
3471 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3472 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3473 |
fs.NotifyChange(ENotifyFile,reqStat3,path);
|
sl@0
|
3474 |
fs.NotifyChange(ENotifyDir,reqStat4,path);
|
sl@0
|
3475 |
fs.NotifyChange(ENotifyWrite,reqStat5,path);
|
sl@0
|
3476 |
fs.NotifyChange(ENotifyAttributes,reqStat6,path);
|
sl@0
|
3477 |
fs.NotifyChange(ENotifyDisk,reqStat7,path);
|
sl@0
|
3478 |
|
sl@0
|
3479 |
test(reqStat==KRequestPending);
|
sl@0
|
3480 |
test(reqStat2==KRequestPending);
|
sl@0
|
3481 |
test(reqStat3==KRequestPending);
|
sl@0
|
3482 |
test(reqStat4==KRequestPending);
|
sl@0
|
3483 |
test(reqStat5==KRequestPending);
|
sl@0
|
3484 |
test(reqStat6==KRequestPending);
|
sl@0
|
3485 |
test(reqStat7==KRequestPending);
|
sl@0
|
3486 |
|
sl@0
|
3487 |
TInt driveNum=CurrentDrive();
|
sl@0
|
3488 |
TVolumeInfo volInfo;
|
sl@0
|
3489 |
TFileName currentVolName;
|
sl@0
|
3490 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
3491 |
test(r==KErrNone);
|
sl@0
|
3492 |
test(reqStat==KRequestPending);
|
sl@0
|
3493 |
currentVolName=volInfo.iName;
|
sl@0
|
3494 |
|
sl@0
|
3495 |
r=TheFs.SetVolumeLabel(_L("VOL"),driveNum);
|
sl@0
|
3496 |
if (r==KErrNone)
|
sl@0
|
3497 |
{
|
sl@0
|
3498 |
User::WaitForRequest(reqStat);
|
sl@0
|
3499 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3500 |
User::WaitForRequest(reqStat7);
|
sl@0
|
3501 |
|
sl@0
|
3502 |
test(reqStat==KErrNone);
|
sl@0
|
3503 |
test(reqStat2==KErrNone);
|
sl@0
|
3504 |
test(reqStat3==KRequestPending);
|
sl@0
|
3505 |
test(reqStat4==KRequestPending);
|
sl@0
|
3506 |
test(reqStat5==KRequestPending);
|
sl@0
|
3507 |
test(reqStat6==KRequestPending);
|
sl@0
|
3508 |
test(reqStat7==KErrNone);
|
sl@0
|
3509 |
|
sl@0
|
3510 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3511 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3512 |
fs.NotifyChange(ENotifyDisk,reqStat7,path);
|
sl@0
|
3513 |
|
sl@0
|
3514 |
test(reqStat==KRequestPending);
|
sl@0
|
3515 |
test(reqStat2==KRequestPending);
|
sl@0
|
3516 |
test(reqStat7==KRequestPending);
|
sl@0
|
3517 |
|
sl@0
|
3518 |
r=TheFs.SetVolumeLabel(currentVolName,driveNum);
|
sl@0
|
3519 |
test(r==KErrNone);
|
sl@0
|
3520 |
|
sl@0
|
3521 |
User::WaitForRequest(reqStat);
|
sl@0
|
3522 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3523 |
User::WaitForRequest(reqStat7);
|
sl@0
|
3524 |
|
sl@0
|
3525 |
test(reqStat==KErrNone);
|
sl@0
|
3526 |
test(reqStat2==KErrNone);
|
sl@0
|
3527 |
test(reqStat3==KRequestPending);
|
sl@0
|
3528 |
test(reqStat4==KRequestPending);
|
sl@0
|
3529 |
test(reqStat5==KRequestPending);
|
sl@0
|
3530 |
test(reqStat6==KRequestPending);
|
sl@0
|
3531 |
test(reqStat7==KErrNone);
|
sl@0
|
3532 |
|
sl@0
|
3533 |
r=TheFs.Volume(volInfo,driveNum);
|
sl@0
|
3534 |
test(r==KErrNone);
|
sl@0
|
3535 |
test(volInfo.iName==currentVolName);
|
sl@0
|
3536 |
|
sl@0
|
3537 |
fs.NotifyChangeCancel();
|
sl@0
|
3538 |
|
sl@0
|
3539 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3540 |
test(reqStat3==KErrCancel);
|
sl@0
|
3541 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3542 |
test(reqStat4==KErrCancel);
|
sl@0
|
3543 |
User::WaitForRequest(reqStat5);
|
sl@0
|
3544 |
test(reqStat5==KErrCancel);
|
sl@0
|
3545 |
User::WaitForRequest(reqStat6);
|
sl@0
|
3546 |
test(reqStat6==KErrCancel);
|
sl@0
|
3547 |
}
|
sl@0
|
3548 |
|
sl@0
|
3549 |
else // RFs::SetVolumeLabel() doesn't work on subst drives
|
sl@0
|
3550 |
{
|
sl@0
|
3551 |
fs.NotifyChangeCancel();
|
sl@0
|
3552 |
User::WaitForRequest(reqStat);
|
sl@0
|
3553 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3554 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3555 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3556 |
User::WaitForRequest(reqStat5);
|
sl@0
|
3557 |
User::WaitForRequest(reqStat6);
|
sl@0
|
3558 |
User::WaitForRequest(reqStat7);
|
sl@0
|
3559 |
test.Printf(_L("Cannot set volume label on a substed drive!\n"));
|
sl@0
|
3560 |
}
|
sl@0
|
3561 |
|
sl@0
|
3562 |
|
sl@0
|
3563 |
// RFile::Rename()
|
sl@0
|
3564 |
test.Next(_L("RFile::Rename()"));
|
sl@0
|
3565 |
path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
3566 |
|
sl@0
|
3567 |
file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileShareExclusive|EFileWrite);
|
sl@0
|
3568 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3569 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3570 |
fs.NotifyChange(ENotifyFile,reqStat3,path);
|
sl@0
|
3571 |
fs.NotifyChange(ENotifyDir,reqStat4,path);
|
sl@0
|
3572 |
|
sl@0
|
3573 |
test(reqStat==KRequestPending);
|
sl@0
|
3574 |
test(reqStat2==KRequestPending);
|
sl@0
|
3575 |
test(reqStat3==KRequestPending);
|
sl@0
|
3576 |
test(reqStat4==KRequestPending);
|
sl@0
|
3577 |
|
sl@0
|
3578 |
r=file.Rename(_L("\\F32-TST\\NOTIFY\\OldFile.abc"));
|
sl@0
|
3579 |
test(r==KErrNone||r==KErrAlreadyExists);
|
sl@0
|
3580 |
User::WaitForRequest(reqStat);
|
sl@0
|
3581 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3582 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3583 |
test(reqStat==KErrNone);
|
sl@0
|
3584 |
test(reqStat2==KErrNone);
|
sl@0
|
3585 |
test(reqStat3==KErrNone);
|
sl@0
|
3586 |
test(reqStat4==KRequestPending); // Monitoring ENotifyDir
|
sl@0
|
3587 |
file.Close();
|
sl@0
|
3588 |
fs.NotifyChangeCancel();
|
sl@0
|
3589 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3590 |
test(reqStat4==KErrCancel);
|
sl@0
|
3591 |
|
sl@0
|
3592 |
path=_L("\\F32-TST\\NOTIFY\\OldFile.abc");
|
sl@0
|
3593 |
|
sl@0
|
3594 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\OldFile.abc"),EFileShareExclusive|EFileWrite);
|
sl@0
|
3595 |
test(r==KErrNone);
|
sl@0
|
3596 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3597 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3598 |
fs.NotifyChange(ENotifyFile,reqStat3,path);
|
sl@0
|
3599 |
fs.NotifyChange(ENotifyDir,reqStat4,path);
|
sl@0
|
3600 |
|
sl@0
|
3601 |
test(reqStat==KRequestPending);
|
sl@0
|
3602 |
test(reqStat2==KRequestPending);
|
sl@0
|
3603 |
test(reqStat3==KRequestPending);
|
sl@0
|
3604 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3605 |
test(reqStat4==KErrArgument);
|
sl@0
|
3606 |
|
sl@0
|
3607 |
r=file.Rename(_L("\\F32-TST\\NOTIFY\\NewFile.xyz"));
|
sl@0
|
3608 |
test(r==KErrNone);
|
sl@0
|
3609 |
User::WaitForRequest(reqStat);
|
sl@0
|
3610 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3611 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3612 |
test(reqStat==KErrNone);
|
sl@0
|
3613 |
test(reqStat2==KErrNone);
|
sl@0
|
3614 |
test(reqStat3==KErrNone);
|
sl@0
|
3615 |
test(reqStat4==KErrArgument);
|
sl@0
|
3616 |
file.Close();
|
sl@0
|
3617 |
|
sl@0
|
3618 |
// RFs::Rename()
|
sl@0
|
3619 |
test.Next(_L("RFs::Rename()"));
|
sl@0
|
3620 |
path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
3621 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3622 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3623 |
fs.NotifyChange(ENotifyFile,reqStat3,path);
|
sl@0
|
3624 |
fs.NotifyChange(ENotifyDir,reqStat4,path);
|
sl@0
|
3625 |
|
sl@0
|
3626 |
test(reqStat==KRequestPending);
|
sl@0
|
3627 |
test(reqStat2==KRequestPending);
|
sl@0
|
3628 |
test(reqStat3==KRequestPending);
|
sl@0
|
3629 |
test(reqStat4==KRequestPending);
|
sl@0
|
3630 |
|
sl@0
|
3631 |
r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\NewFile.xyz"),_L("\\F32-TST\\NOTIFY\\NewerFile.cat"));
|
sl@0
|
3632 |
test(r==KErrNone);
|
sl@0
|
3633 |
User::WaitForRequest(reqStat);
|
sl@0
|
3634 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3635 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3636 |
test(reqStat==KErrNone);
|
sl@0
|
3637 |
test(reqStat2==KErrNone);
|
sl@0
|
3638 |
test(reqStat3==KErrNone);
|
sl@0
|
3639 |
test(reqStat4==KRequestPending); // Changed a file not a directory entry
|
sl@0
|
3640 |
fs.NotifyChangeCancel();
|
sl@0
|
3641 |
|
sl@0
|
3642 |
test(reqStat==KErrNone);
|
sl@0
|
3643 |
test(reqStat2==KErrNone);
|
sl@0
|
3644 |
test(reqStat3==KErrNone);
|
sl@0
|
3645 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3646 |
test(reqStat4==KErrCancel);
|
sl@0
|
3647 |
|
sl@0
|
3648 |
path=_L("\\F32-TST\\NOTIFY\\NewerFile.cat");
|
sl@0
|
3649 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3650 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3651 |
fs.NotifyChange(ENotifyFile,reqStat3,path);
|
sl@0
|
3652 |
fs.NotifyChange(ENotifyDir,reqStat4,path);
|
sl@0
|
3653 |
|
sl@0
|
3654 |
test(reqStat==KRequestPending);
|
sl@0
|
3655 |
test(reqStat2==KRequestPending);
|
sl@0
|
3656 |
test(reqStat3==KRequestPending);
|
sl@0
|
3657 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3658 |
test(reqStat4==KErrArgument);
|
sl@0
|
3659 |
|
sl@0
|
3660 |
r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\NewerFile.cat"),_L("\\F32-TST\\NOTIFY\\Original.dog"));
|
sl@0
|
3661 |
test(r==KErrNone);
|
sl@0
|
3662 |
User::WaitForRequest(reqStat);
|
sl@0
|
3663 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3664 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3665 |
test(reqStat==KErrNone);
|
sl@0
|
3666 |
test(reqStat2==KErrNone);
|
sl@0
|
3667 |
test(reqStat3==KErrNone);
|
sl@0
|
3668 |
|
sl@0
|
3669 |
path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
3670 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3671 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3672 |
fs.NotifyChange(ENotifyFile,reqStat3,path);
|
sl@0
|
3673 |
fs.NotifyChange(ENotifyDir,reqStat4,path);
|
sl@0
|
3674 |
|
sl@0
|
3675 |
test(reqStat==KRequestPending);
|
sl@0
|
3676 |
test(reqStat2==KRequestPending);
|
sl@0
|
3677 |
test(reqStat3==KRequestPending);
|
sl@0
|
3678 |
test(reqStat4==KRequestPending);
|
sl@0
|
3679 |
|
sl@0
|
3680 |
r=TheFs.Rename(_L("\\F32-TST\\NOTIFY\\"),_L("\\F32-TST\\NOTIFY_TEMP\\"));
|
sl@0
|
3681 |
test(r==KErrNone);
|
sl@0
|
3682 |
User::WaitForRequest(reqStat);
|
sl@0
|
3683 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3684 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3685 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3686 |
test(reqStat==KErrNone);
|
sl@0
|
3687 |
test(reqStat2==KErrNone);
|
sl@0
|
3688 |
test(reqStat3==KErrNone); // Changed a directory entry but notified anyway despite
|
sl@0
|
3689 |
test(reqStat4==KErrNone); // requesting file notification only because the path we
|
sl@0
|
3690 |
// were monitoring has changed
|
sl@0
|
3691 |
|
sl@0
|
3692 |
path=_L("\\F32-TST\\NOTIFY_TEMP\\Original.dog");
|
sl@0
|
3693 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3694 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3695 |
fs.NotifyChange(ENotifyFile,reqStat3,path);
|
sl@0
|
3696 |
fs.NotifyChange(ENotifyDir,reqStat4,path);
|
sl@0
|
3697 |
|
sl@0
|
3698 |
test(reqStat==KRequestPending);
|
sl@0
|
3699 |
test(reqStat2==KRequestPending);
|
sl@0
|
3700 |
test(reqStat3==KRequestPending);
|
sl@0
|
3701 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3702 |
test(reqStat4==KErrArgument);
|
sl@0
|
3703 |
|
sl@0
|
3704 |
r=TheFs.Rename(_L("\\F32-TST\\NOTIFY_TEMP\\"),_L("\\F32-TST\\NOTIFY\\"));
|
sl@0
|
3705 |
test(r==KErrNone);
|
sl@0
|
3706 |
User::WaitForRequest(reqStat);
|
sl@0
|
3707 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3708 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3709 |
test(reqStat==KErrNone); // Modified a directory above the level at which we
|
sl@0
|
3710 |
test(reqStat2==KErrNone); // are monitoring for changes - we must be notified
|
sl@0
|
3711 |
test(reqStat3==KErrNone); // anyway because the path has changed
|
sl@0
|
3712 |
|
sl@0
|
3713 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3714 |
test(reqStat==KRequestPending);
|
sl@0
|
3715 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3716 |
test(reqStat2==KRequestPending);
|
sl@0
|
3717 |
fs.NotifyChange(ENotifyFile,reqStat3,path);
|
sl@0
|
3718 |
test(reqStat3==KRequestPending);
|
sl@0
|
3719 |
|
sl@0
|
3720 |
fs.NotifyChangeCancel(reqStat);
|
sl@0
|
3721 |
User::WaitForRequest(reqStat);
|
sl@0
|
3722 |
test(reqStat==KErrCancel);
|
sl@0
|
3723 |
fs.NotifyChangeCancel(reqStat2);
|
sl@0
|
3724 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3725 |
test(reqStat2==KErrCancel);
|
sl@0
|
3726 |
fs.NotifyChangeCancel(reqStat3);
|
sl@0
|
3727 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3728 |
test(reqStat3==KErrCancel);
|
sl@0
|
3729 |
|
sl@0
|
3730 |
path=_L("\\F32-TST\\NOTIFY\\Original.dog");
|
sl@0
|
3731 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3732 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3733 |
fs.NotifyChange(ENotifyFile,reqStat3,path);
|
sl@0
|
3734 |
|
sl@0
|
3735 |
test(reqStat==KRequestPending);
|
sl@0
|
3736 |
test(reqStat2==KRequestPending);
|
sl@0
|
3737 |
test(reqStat3==KRequestPending);
|
sl@0
|
3738 |
|
sl@0
|
3739 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Original.dog"));
|
sl@0
|
3740 |
test(r==KErrNone);
|
sl@0
|
3741 |
User::WaitForRequest(reqStat);
|
sl@0
|
3742 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3743 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3744 |
test(reqStat==KErrNone);
|
sl@0
|
3745 |
test(reqStat2==KErrNone);
|
sl@0
|
3746 |
test(reqStat3==KErrNone);
|
sl@0
|
3747 |
|
sl@0
|
3748 |
path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
3749 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3750 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3751 |
fs.NotifyChange(ENotifyDir,reqStat3,path);
|
sl@0
|
3752 |
|
sl@0
|
3753 |
test(reqStat==KRequestPending);
|
sl@0
|
3754 |
test(reqStat2==KRequestPending);
|
sl@0
|
3755 |
test(reqStat3==KRequestPending);
|
sl@0
|
3756 |
|
sl@0
|
3757 |
r=TheFs.Rename(_L("\\F32-TST\\"),_L("\\F32-TEST\\"));
|
sl@0
|
3758 |
test(r==KErrNone);
|
sl@0
|
3759 |
User::WaitForRequest(reqStat);
|
sl@0
|
3760 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3761 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3762 |
test(reqStat==KErrNone); // Modified a directory above the level at which we
|
sl@0
|
3763 |
test(reqStat2==KErrNone); // are monitoring for changes but we receive notification
|
sl@0
|
3764 |
test(reqStat3==KErrNone); // because the notification path has been changed
|
sl@0
|
3765 |
|
sl@0
|
3766 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3767 |
// Notification request is submitted, despite the subject's disappearance
|
sl@0
|
3768 |
test(reqStat==KRequestPending);
|
sl@0
|
3769 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3770 |
// Notification request is submitted, despite the subject's disappearance
|
sl@0
|
3771 |
test(reqStat2==KRequestPending);
|
sl@0
|
3772 |
fs.NotifyChange(ENotifyFile,reqStat3,path);
|
sl@0
|
3773 |
// Notification request is submitted, despite the subject's disappearance
|
sl@0
|
3774 |
test(reqStat3==KRequestPending);
|
sl@0
|
3775 |
|
sl@0
|
3776 |
fs.NotifyChangeCancel(reqStat);
|
sl@0
|
3777 |
User::WaitForRequest(reqStat);
|
sl@0
|
3778 |
test(reqStat==KErrCancel);
|
sl@0
|
3779 |
fs.NotifyChangeCancel(reqStat2);
|
sl@0
|
3780 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3781 |
test(reqStat2==KErrCancel);
|
sl@0
|
3782 |
fs.NotifyChangeCancel(reqStat3);
|
sl@0
|
3783 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3784 |
test(reqStat3==KErrCancel);
|
sl@0
|
3785 |
|
sl@0
|
3786 |
path=_L("\\F32-TEST\\NOTIFY\\");
|
sl@0
|
3787 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3788 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3789 |
fs.NotifyChange(ENotifyDir,reqStat3,path);
|
sl@0
|
3790 |
|
sl@0
|
3791 |
test(reqStat==KRequestPending);
|
sl@0
|
3792 |
test(reqStat2==KRequestPending);
|
sl@0
|
3793 |
test(reqStat3==KRequestPending);
|
sl@0
|
3794 |
|
sl@0
|
3795 |
r=TheFs.Rename(_L("\\F32-TEST\\NOTIFY\\"),_L("\\F32-TEST\\NOTIFY_CHANGED\\"));
|
sl@0
|
3796 |
test(r==KErrNone);
|
sl@0
|
3797 |
|
sl@0
|
3798 |
User::WaitForRequest(reqStat);
|
sl@0
|
3799 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3800 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3801 |
|
sl@0
|
3802 |
test(reqStat==KErrNone); // Rename the directory we were monitoring
|
sl@0
|
3803 |
test(reqStat2==KErrNone);
|
sl@0
|
3804 |
test(reqStat3==KErrNone);
|
sl@0
|
3805 |
|
sl@0
|
3806 |
// Tidy up the test directory before continuing (while testing notifications of renaming to the monitored directory)
|
sl@0
|
3807 |
|
sl@0
|
3808 |
path=_L("\\F32-TST\\NOTIFY_CHANGED\\");
|
sl@0
|
3809 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3810 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3811 |
fs.NotifyChange(ENotifyDir,reqStat3,path);
|
sl@0
|
3812 |
fs.NotifyChange(ENotifyFile,reqStat4,path);
|
sl@0
|
3813 |
|
sl@0
|
3814 |
test(reqStat==KRequestPending);
|
sl@0
|
3815 |
test(reqStat2==KRequestPending);
|
sl@0
|
3816 |
test(reqStat3==KRequestPending);
|
sl@0
|
3817 |
test(reqStat4==KRequestPending);
|
sl@0
|
3818 |
|
sl@0
|
3819 |
r=TheFs.Rename(_L("\\F32-TEST\\"),_L("\\F32-TST\\"));
|
sl@0
|
3820 |
test(r==KErrNone);
|
sl@0
|
3821 |
|
sl@0
|
3822 |
User::WaitForRequest(reqStat);
|
sl@0
|
3823 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3824 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3825 |
|
sl@0
|
3826 |
test(reqStat==KErrNone); // Renaming to (under) the directory we were monitoring
|
sl@0
|
3827 |
test(reqStat2==KErrNone);
|
sl@0
|
3828 |
test(reqStat3==KErrNone);
|
sl@0
|
3829 |
test(reqStat4==KRequestPending);
|
sl@0
|
3830 |
|
sl@0
|
3831 |
fs.NotifyChangeCancel(reqStat4);
|
sl@0
|
3832 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3833 |
test(reqStat4==KErrCancel);
|
sl@0
|
3834 |
|
sl@0
|
3835 |
path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
3836 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3837 |
fs.NotifyChange(ENotifyEntry,reqStat2,path);
|
sl@0
|
3838 |
fs.NotifyChange(ENotifyDir,reqStat3,path);
|
sl@0
|
3839 |
fs.NotifyChange(ENotifyFile,reqStat4,path);
|
sl@0
|
3840 |
|
sl@0
|
3841 |
test(reqStat==KRequestPending);
|
sl@0
|
3842 |
test(reqStat2==KRequestPending);
|
sl@0
|
3843 |
test(reqStat3==KRequestPending);
|
sl@0
|
3844 |
test(reqStat4==KRequestPending);
|
sl@0
|
3845 |
|
sl@0
|
3846 |
r=TheFs.Rename(_L("\\F32-TST\\NOTIFY_CHANGED\\"),_L("\\F32-TST\\NOTIFY\\"));
|
sl@0
|
3847 |
test(r==KErrNone);
|
sl@0
|
3848 |
|
sl@0
|
3849 |
User::WaitForRequest(reqStat);
|
sl@0
|
3850 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3851 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3852 |
|
sl@0
|
3853 |
test(reqStat==KErrNone); // Renaming to the directory we were monitoring
|
sl@0
|
3854 |
test(reqStat2==KErrNone);
|
sl@0
|
3855 |
test(reqStat3==KErrNone);
|
sl@0
|
3856 |
test(reqStat4==KRequestPending);
|
sl@0
|
3857 |
|
sl@0
|
3858 |
fs.NotifyChangeCancel(reqStat4);
|
sl@0
|
3859 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3860 |
test(reqStat4==KErrCancel);
|
sl@0
|
3861 |
|
sl@0
|
3862 |
// Test combinations of notify types
|
sl@0
|
3863 |
test.Next(_L("Test combinations of notify types"));
|
sl@0
|
3864 |
|
sl@0
|
3865 |
path=_L("\\F32-TST\\NOTIFY\\");
|
sl@0
|
3866 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3867 |
fs.NotifyChange((TNotifyType)(KGenericEntryChange|ENotifyAttributes),reqStat2,path);
|
sl@0
|
3868 |
fs.NotifyChange((TNotifyType)(ENotifyDir|ENotifyFile),reqStat3,path);
|
sl@0
|
3869 |
fs.NotifyChange((TNotifyType)(ENotifyDisk|ENotifyAttributes),reqStat4,path);
|
sl@0
|
3870 |
|
sl@0
|
3871 |
test(reqStat==KRequestPending);
|
sl@0
|
3872 |
test(reqStat2==KRequestPending);
|
sl@0
|
3873 |
test(reqStat3==KRequestPending);
|
sl@0
|
3874 |
test(reqStat4==KRequestPending);
|
sl@0
|
3875 |
|
sl@0
|
3876 |
r=file.Create(TheFs,_L("\\F32-TST\\NOTIFY\\Munchkin.msg"),EFileRead|EFileWrite);
|
sl@0
|
3877 |
test(r==KErrNone);
|
sl@0
|
3878 |
User::WaitForRequest(reqStat);
|
sl@0
|
3879 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3880 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3881 |
test(reqStat==KErrNone);
|
sl@0
|
3882 |
test(reqStat2==KErrNone);
|
sl@0
|
3883 |
test(reqStat3==KErrNone);
|
sl@0
|
3884 |
test(reqStat4==KRequestPending); // Monitoring ENotifyAttributes|ENotifyDisk
|
sl@0
|
3885 |
file.Close();
|
sl@0
|
3886 |
fs.NotifyChangeCancel(reqStat4);
|
sl@0
|
3887 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3888 |
test(reqStat4==KErrCancel);
|
sl@0
|
3889 |
|
sl@0
|
3890 |
// RFile::SetModified()
|
sl@0
|
3891 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3892 |
fs.NotifyChange((TNotifyType)(KGenericEntryChange|ENotifyAttributes),reqStat2,path);
|
sl@0
|
3893 |
fs.NotifyChange((TNotifyType)(ENotifyDir|ENotifyFile),reqStat3,path);
|
sl@0
|
3894 |
fs.NotifyChange((TNotifyType)(ENotifyDisk|ENotifyAttributes),reqStat4,path);
|
sl@0
|
3895 |
|
sl@0
|
3896 |
test(reqStat==KRequestPending);
|
sl@0
|
3897 |
test(reqStat2==KRequestPending);
|
sl@0
|
3898 |
test(reqStat3==KRequestPending);
|
sl@0
|
3899 |
test(reqStat4==KRequestPending);
|
sl@0
|
3900 |
|
sl@0
|
3901 |
TTime nowTime;
|
sl@0
|
3902 |
nowTime.HomeTime();
|
sl@0
|
3903 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\Munchkin.msg"),EFileRead|EFileWrite);
|
sl@0
|
3904 |
test(r==KErrNone);
|
sl@0
|
3905 |
test(reqStat==KRequestPending);
|
sl@0
|
3906 |
file.SetModified(now);
|
sl@0
|
3907 |
file.Close();
|
sl@0
|
3908 |
User::WaitForRequest(reqStat);
|
sl@0
|
3909 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3910 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3911 |
test(reqStat==KErrNone);
|
sl@0
|
3912 |
test(reqStat2==KErrNone);
|
sl@0
|
3913 |
test(reqStat3==KRequestPending);
|
sl@0
|
3914 |
test(reqStat4==KErrNone);
|
sl@0
|
3915 |
fs.NotifyChangeCancel();
|
sl@0
|
3916 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3917 |
test(reqStat3==KErrCancel);
|
sl@0
|
3918 |
|
sl@0
|
3919 |
// RFile::Write()
|
sl@0
|
3920 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3921 |
fs.NotifyChange((TNotifyType)(KGenericEntryChange|ENotifyAttributes),reqStat2,path);
|
sl@0
|
3922 |
fs.NotifyChange((TNotifyType)(ENotifyFile|ENotifyWrite),reqStat3,path);
|
sl@0
|
3923 |
fs.NotifyChange((TNotifyType)(ENotifyDir|ENotifyWrite),reqStat4,path);
|
sl@0
|
3924 |
|
sl@0
|
3925 |
test(reqStat==KRequestPending);
|
sl@0
|
3926 |
test(reqStat2==KRequestPending);
|
sl@0
|
3927 |
test(reqStat3==KRequestPending);
|
sl@0
|
3928 |
test(reqStat4==KRequestPending);
|
sl@0
|
3929 |
|
sl@0
|
3930 |
r=file.Open(TheFs,_L("\\F32-TST\\NOTIFY\\Munchkin.msg"),EFileRead|EFileWrite);
|
sl@0
|
3931 |
test(r==KErrNone);
|
sl@0
|
3932 |
r=file.Write(0,_L8("Pay no attention to the man behind the curtain"));
|
sl@0
|
3933 |
file.Close();
|
sl@0
|
3934 |
User::WaitForRequest(reqStat);
|
sl@0
|
3935 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3936 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3937 |
test(reqStat==KErrNone);
|
sl@0
|
3938 |
test(reqStat2==KRequestPending);
|
sl@0
|
3939 |
test(reqStat3==KErrNone);
|
sl@0
|
3940 |
test(reqStat4==KErrNone);
|
sl@0
|
3941 |
fs.NotifyChangeCancel(reqStat2); // Cancels all outstanding notification requests
|
sl@0
|
3942 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3943 |
test(reqStat2==KErrCancel);
|
sl@0
|
3944 |
|
sl@0
|
3945 |
// RFs::Delete()
|
sl@0
|
3946 |
test.Next(_L("RFs::Delete()"));
|
sl@0
|
3947 |
fs.NotifyChange(ENotifyAll,reqStat,path);
|
sl@0
|
3948 |
fs.NotifyChange((TNotifyType)(KGenericEntryChange|ENotifyAttributes),reqStat2,path);
|
sl@0
|
3949 |
fs.NotifyChange((TNotifyType)(ENotifyFile|ENotifyWrite),reqStat3,path);
|
sl@0
|
3950 |
fs.NotifyChange((TNotifyType)(ENotifyDir|ENotifyWrite),reqStat4,path);
|
sl@0
|
3951 |
|
sl@0
|
3952 |
test(reqStat==KRequestPending);
|
sl@0
|
3953 |
test(reqStat2==KRequestPending);
|
sl@0
|
3954 |
test(reqStat3==KRequestPending);
|
sl@0
|
3955 |
test(reqStat4==KRequestPending);
|
sl@0
|
3956 |
|
sl@0
|
3957 |
r=TheFs.Delete(_L("\\F32-TST\\NOTIFY\\Munchkin.msg"));
|
sl@0
|
3958 |
test(r==KErrNone);
|
sl@0
|
3959 |
User::WaitForRequest(reqStat);
|
sl@0
|
3960 |
User::WaitForRequest(reqStat2);
|
sl@0
|
3961 |
User::WaitForRequest(reqStat3);
|
sl@0
|
3962 |
test(reqStat==KErrNone);
|
sl@0
|
3963 |
test(reqStat2==KErrNone);
|
sl@0
|
3964 |
test(reqStat3==KErrNone);
|
sl@0
|
3965 |
test(reqStat4==KRequestPending);
|
sl@0
|
3966 |
fs.NotifyChangeCancel(reqStat4);
|
sl@0
|
3967 |
User::WaitForRequest(reqStat4);
|
sl@0
|
3968 |
test(reqStat4==KErrCancel);
|
sl@0
|
3969 |
|
sl@0
|
3970 |
fs.Close();
|
sl@0
|
3971 |
}
|
sl@0
|
3972 |
|
sl@0
|
3973 |
#if defined __EPOC32__ && defined __INCLUDE_MANUAL_TESTS__
|
sl@0
|
3974 |
// Manual media change test
|
sl@0
|
3975 |
// assumes the media is intially present and then prompts
|
sl@0
|
3976 |
// the user to remove the media
|
sl@0
|
3977 |
static void Test99()
|
sl@0
|
3978 |
{
|
sl@0
|
3979 |
TBuf<64> b;
|
sl@0
|
3980 |
b.Format(_L("Test Manual Media change notification (socket:%d)"),gSocketNumber);
|
sl@0
|
3981 |
test.Next(b);
|
sl@0
|
3982 |
TRequestStatus reqStat=0;
|
sl@0
|
3983 |
|
sl@0
|
3984 |
RFs fs;
|
sl@0
|
3985 |
TInt r=fs.Connect();
|
sl@0
|
3986 |
test(r==KErrNone);
|
sl@0
|
3987 |
|
sl@0
|
3988 |
TDriveInfo driveInfo;
|
sl@0
|
3989 |
TInt driveNum = EDriveC + SocketToDrive[gSocketNumber];
|
sl@0
|
3990 |
|
sl@0
|
3991 |
// verify TDriveInfo.iType == EMediaHardDisk
|
sl@0
|
3992 |
r = fs.Drive(driveInfo, driveNum);
|
sl@0
|
3993 |
test (r == KErrNone);
|
sl@0
|
3994 |
test.Printf(_L("iType = %d\n"), driveInfo.iType);
|
sl@0
|
3995 |
test(driveInfo.iType == EMediaHardDisk);
|
sl@0
|
3996 |
|
sl@0
|
3997 |
|
sl@0
|
3998 |
// ask the user to eject the media
|
sl@0
|
3999 |
TheFs.NotifyChange(ENotifyEntry,reqStat);
|
sl@0
|
4000 |
test(reqStat==KRequestPending);
|
sl@0
|
4001 |
test.Printf(_L("Please eject media on drive %C...\n"), 'A' + driveNum);
|
sl@0
|
4002 |
User::WaitForRequest(reqStat);
|
sl@0
|
4003 |
test.Printf(_L("Done.\n"));
|
sl@0
|
4004 |
TInt reqInt=reqStat.Int();
|
sl@0
|
4005 |
test(reqInt==KErrNone);
|
sl@0
|
4006 |
User::WaitForRequest(reqStat);
|
sl@0
|
4007 |
|
sl@0
|
4008 |
// verify TDriveInfo.iType == EMediaNotPresent
|
sl@0
|
4009 |
r = fs.Drive(driveInfo, driveNum);
|
sl@0
|
4010 |
test (r == KErrNone);
|
sl@0
|
4011 |
test.Printf(_L("iType = %d\n"), driveInfo.iType);
|
sl@0
|
4012 |
test(driveInfo.iType == EMediaNotPresent);
|
sl@0
|
4013 |
|
sl@0
|
4014 |
|
sl@0
|
4015 |
// ask the user to re-insert the media
|
sl@0
|
4016 |
TheFs.NotifyChange(ENotifyEntry,reqStat);
|
sl@0
|
4017 |
test(reqStat==KRequestPending);
|
sl@0
|
4018 |
test.Printf(_L("Please re-insert media...\n"));
|
sl@0
|
4019 |
User::WaitForRequest(reqStat);
|
sl@0
|
4020 |
test.Printf(_L("Done.\n"));
|
sl@0
|
4021 |
reqInt = reqStat.Int();
|
sl@0
|
4022 |
test(reqInt==KErrNone);
|
sl@0
|
4023 |
User::WaitForRequest(reqStat);
|
sl@0
|
4024 |
|
sl@0
|
4025 |
// verify TDriveInfo.iType == EMediaHardDisk
|
sl@0
|
4026 |
r = fs.Drive(driveInfo, driveNum);
|
sl@0
|
4027 |
test (r == KErrNone);
|
sl@0
|
4028 |
test.Printf(_L("iType = %d\n"), driveInfo.iType);
|
sl@0
|
4029 |
test(driveInfo.iType == EMediaHardDisk);
|
sl@0
|
4030 |
|
sl@0
|
4031 |
fs.Close();
|
sl@0
|
4032 |
}
|
sl@0
|
4033 |
#endif // __INCLUDE_MANUAL_TESTS__
|
sl@0
|
4034 |
|
sl@0
|
4035 |
|
sl@0
|
4036 |
//---------------------------------------------
|
sl@0
|
4037 |
//! @SYMTestCaseID PBASE-T_NOTIFY-0042
|
sl@0
|
4038 |
//! @SYMTestType UT
|
sl@0
|
4039 |
//! @SYMREQ REQ5664
|
sl@0
|
4040 |
//! @SYMTestCaseDesc Test asynchronous RFile API's
|
sl@0
|
4041 |
//! @SYMTestActions Test normal asynchronous read, share modes, read cancellation, race conditions
|
sl@0
|
4042 |
//! (with RFile::SetSize() and RFile::Write()), multiple asynchronous readers.
|
sl@0
|
4043 |
//! @SYMTestExpectedResults Expected behaviour reached.
|
sl@0
|
4044 |
//! @SYMTestPriority High
|
sl@0
|
4045 |
//! @SYMTestStatus Implemented
|
sl@0
|
4046 |
//---------------------------------------------
|
sl@0
|
4047 |
static void TestAsyncReader()
|
sl@0
|
4048 |
//
|
sl@0
|
4049 |
// Test asynchronous read notifications
|
sl@0
|
4050 |
//
|
sl@0
|
4051 |
{
|
sl@0
|
4052 |
TRequestStatus readStat1(KRequestPending);
|
sl@0
|
4053 |
TRequestStatus readStat2(KRequestPending);
|
sl@0
|
4054 |
TRequestStatus thrdStat(KRequestPending);
|
sl@0
|
4055 |
|
sl@0
|
4056 |
MakeFile(_L("\\F32-TST\\NOTIFY\\NewFile.Txt"));
|
sl@0
|
4057 |
|
sl@0
|
4058 |
test.Next(_L("Test original behaviour of asynchronous read API"));
|
sl@0
|
4059 |
RFile reader;
|
sl@0
|
4060 |
TInt r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileShareAny);
|
sl@0
|
4061 |
test(r==KErrNone);
|
sl@0
|
4062 |
TBuf8<596> readBuf;
|
sl@0
|
4063 |
reader.Read(0, readBuf, 100, readStat1);
|
sl@0
|
4064 |
User::WaitForRequest(readStat1);
|
sl@0
|
4065 |
test(readStat1==KErrNone);
|
sl@0
|
4066 |
test(readBuf.Length()==0);
|
sl@0
|
4067 |
reader.Close();
|
sl@0
|
4068 |
|
sl@0
|
4069 |
test.Next(_L("Test asynchronous read fails in EFileShareExclusive mode"));
|
sl@0
|
4070 |
r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareExclusive);
|
sl@0
|
4071 |
test(r==KErrArgument);
|
sl@0
|
4072 |
|
sl@0
|
4073 |
test.Next(_L("Test asynchronous read fails in EFileShareReadersOnly mode"));
|
sl@0
|
4074 |
r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareReadersOnly);
|
sl@0
|
4075 |
test(r==KErrArgument);
|
sl@0
|
4076 |
|
sl@0
|
4077 |
test.Next(_L("Test asynchronous read is cancelled when file is closed"));
|
sl@0
|
4078 |
r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
|
sl@0
|
4079 |
test(r==KErrNone);
|
sl@0
|
4080 |
reader.Read(0, readBuf, 100, readStat1);
|
sl@0
|
4081 |
test(readStat1==KRequestPending);
|
sl@0
|
4082 |
reader.Close();
|
sl@0
|
4083 |
User::WaitForRequest(readStat1);
|
sl@0
|
4084 |
test(readStat1==KErrCancel);
|
sl@0
|
4085 |
|
sl@0
|
4086 |
test.Next(_L("Test asynchronous read can be cancelled"));
|
sl@0
|
4087 |
r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
|
sl@0
|
4088 |
test(r==KErrNone);
|
sl@0
|
4089 |
reader.Read(0, readBuf, 100, readStat1);
|
sl@0
|
4090 |
test(readStat1==KRequestPending);
|
sl@0
|
4091 |
reader.ReadCancel(readStat1);
|
sl@0
|
4092 |
User::WaitForRequest(readStat1);
|
sl@0
|
4093 |
test(readStat1==KErrCancel);
|
sl@0
|
4094 |
reader.Close();
|
sl@0
|
4095 |
|
sl@0
|
4096 |
// DEF105438: File server thread safety issues
|
sl@0
|
4097 |
// Up the priority of this thread so that we can cancel the request before the drive thread
|
sl@0
|
4098 |
// runs (to test whether cancelling still works...)
|
sl@0
|
4099 |
test.Next(_L("Test asynchronous read is cancelled when running at high priority"));
|
sl@0
|
4100 |
r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileShareAny);
|
sl@0
|
4101 |
test(r==KErrNone);
|
sl@0
|
4102 |
RThread thisThread;
|
sl@0
|
4103 |
thisThread.SetPriority(EPriorityRealTime);
|
sl@0
|
4104 |
reader.Read(0, readBuf, 100, readStat1);
|
sl@0
|
4105 |
test(readStat1==KRequestPending);
|
sl@0
|
4106 |
reader.ReadCancel(readStat1);
|
sl@0
|
4107 |
test.Printf(_L("readStat1 %d"), readStat1.Int());
|
sl@0
|
4108 |
User::WaitForRequest(readStat1);
|
sl@0
|
4109 |
test(readStat1==KErrCancel);
|
sl@0
|
4110 |
reader.Close();
|
sl@0
|
4111 |
thisThread.SetPriority(EPriorityNormal);
|
sl@0
|
4112 |
|
sl@0
|
4113 |
test.Next(_L("Test asynchronous read is notified due to RFile::SetSize()"));
|
sl@0
|
4114 |
r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileWrite|EFileShareAny);
|
sl@0
|
4115 |
test(r==KErrNone);
|
sl@0
|
4116 |
reader.Read(0, readBuf, 100, readStat1);
|
sl@0
|
4117 |
test(readStat1==KRequestPending);
|
sl@0
|
4118 |
r = reader.SetSize(100);
|
sl@0
|
4119 |
test(r==KErrNone);
|
sl@0
|
4120 |
User::WaitForRequest(readStat1);
|
sl@0
|
4121 |
test(readStat1==KErrNone);
|
sl@0
|
4122 |
test(readBuf.Length() == 100);
|
sl@0
|
4123 |
r=reader.SetSize(0);
|
sl@0
|
4124 |
test(r==KErrNone);
|
sl@0
|
4125 |
reader.Close();
|
sl@0
|
4126 |
|
sl@0
|
4127 |
test.Next(_L("Test asynchronous read is notified due to RFile::Write()"));
|
sl@0
|
4128 |
r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileWrite|EFileShareAny);
|
sl@0
|
4129 |
test(r==KErrNone);
|
sl@0
|
4130 |
reader.Read(0, readBuf, 26, readStat1);
|
sl@0
|
4131 |
test(readStat1==KRequestPending);
|
sl@0
|
4132 |
RFile writer;
|
sl@0
|
4133 |
r=writer.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileWrite|EFileShareAny);
|
sl@0
|
4134 |
writer.Write(_L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
|
sl@0
|
4135 |
User::WaitForRequest(readStat1);
|
sl@0
|
4136 |
test(readStat1==KErrNone);
|
sl@0
|
4137 |
test(readBuf.Length() == 26);
|
sl@0
|
4138 |
reader.Close();
|
sl@0
|
4139 |
writer.Close();
|
sl@0
|
4140 |
|
sl@0
|
4141 |
test.Next(_L("Test multiple asynchronous readers notified from separate thread"));
|
sl@0
|
4142 |
r=reader.Open(TheFs,_L("\\F32-TST\\NOTIFY\\NewFile.txt"),EFileRead|EFileReadAsyncAll|EFileWrite|EFileShareAny);
|
sl@0
|
4143 |
test(r==KErrNone);
|
sl@0
|
4144 |
r=reader.SetSize(0);
|
sl@0
|
4145 |
test(r==KErrNone);
|
sl@0
|
4146 |
const TInt KReadLen = 26;
|
sl@0
|
4147 |
test.Printf(_L(">Read%d[%d]\n"), 0, KReadLen);
|
sl@0
|
4148 |
reader.Read(0, readBuf, KReadLen, readStat1);
|
sl@0
|
4149 |
TBuf8<596> readBuf2;
|
sl@0
|
4150 |
test.Printf(_L(">Read%d[%d]\n"), 1, KReadLen);
|
sl@0
|
4151 |
reader.Read(KReadLen, readBuf2, KReadLen, readStat2);
|
sl@0
|
4152 |
test(readStat1==KRequestPending);
|
sl@0
|
4153 |
test(readStat2==KRequestPending);
|
sl@0
|
4154 |
|
sl@0
|
4155 |
RThread thread;
|
sl@0
|
4156 |
r=thread.Create(_L("MyThread"),ThreadEntryPoint,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)ETest12);
|
sl@0
|
4157 |
test(r==KErrNone);
|
sl@0
|
4158 |
thread.Logon(thrdStat);
|
sl@0
|
4159 |
thread.Resume();
|
sl@0
|
4160 |
thread.Close();
|
sl@0
|
4161 |
|
sl@0
|
4162 |
RTimer timer;
|
sl@0
|
4163 |
TRequestStatus timerStat(KRequestPending);
|
sl@0
|
4164 |
timer.CreateLocal();
|
sl@0
|
4165 |
timer.After(timerStat, 30000000); // 30 seconds timeout (the following async test should take 10 seconds)
|
sl@0
|
4166 |
test(timerStat==KRequestPending);
|
sl@0
|
4167 |
|
sl@0
|
4168 |
#define ODDPASS (pass&0x01)
|
sl@0
|
4169 |
#define REQSTAT (ODDPASS ? readStat2 : readStat1)
|
sl@0
|
4170 |
#define PENDSTAT (ODDPASS ? readStat1 : readStat2)
|
sl@0
|
4171 |
#define COMPLEN (ODDPASS ? KReadLen : (pass+1)*KReadLen)
|
sl@0
|
4172 |
#define READLEN (ODDPASS ? KReadLen : (pass+3)*KReadLen)
|
sl@0
|
4173 |
#define READPOS (ODDPASS ? (pass+2)*KReadLen : 0)
|
sl@0
|
4174 |
#define READBUF (ODDPASS ? readBuf2 : readBuf)
|
sl@0
|
4175 |
|
sl@0
|
4176 |
TInt pass = 0;
|
sl@0
|
4177 |
FOREVER
|
sl@0
|
4178 |
{
|
sl@0
|
4179 |
User::WaitForRequest(REQSTAT, timerStat);
|
sl@0
|
4180 |
test(REQSTAT==KErrNone);
|
sl@0
|
4181 |
test(timerStat==KRequestPending);
|
sl@0
|
4182 |
test(READBUF.Length() == COMPLEN);
|
sl@0
|
4183 |
test(READBUF.Right(KReadLen) == _L8("ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
|
sl@0
|
4184 |
test.Printf(_L(">Read%d[%d]\n"), pass&0x01, READLEN);
|
sl@0
|
4185 |
reader.Read(READPOS, READBUF, READLEN, REQSTAT);
|
sl@0
|
4186 |
test(REQSTAT==KRequestPending);
|
sl@0
|
4187 |
if(++pass==10)
|
sl@0
|
4188 |
break;
|
sl@0
|
4189 |
}
|
sl@0
|
4190 |
|
sl@0
|
4191 |
test.Next(_L("Close reader and test multiple outstanding requests are cancelled"));
|
sl@0
|
4192 |
timer.Close();
|
sl@0
|
4193 |
User::WaitForRequest(timerStat);
|
sl@0
|
4194 |
reader.Close();
|
sl@0
|
4195 |
User::WaitForRequest(readStat1);
|
sl@0
|
4196 |
test(readStat1==KErrCancel);
|
sl@0
|
4197 |
User::WaitForRequest(readStat2);
|
sl@0
|
4198 |
test(readStat2==KErrCancel);
|
sl@0
|
4199 |
|
sl@0
|
4200 |
User::WaitForRequest(thrdStat);
|
sl@0
|
4201 |
test(thrdStat==KErrNone);
|
sl@0
|
4202 |
}
|
sl@0
|
4203 |
|
sl@0
|
4204 |
|
sl@0
|
4205 |
//-----------------------------------------------------------------------
|
sl@0
|
4206 |
|
sl@0
|
4207 |
/**
|
sl@0
|
4208 |
Testing that TheFs.NotifyChange() works for the root directory of the drive
|
sl@0
|
4209 |
*/
|
sl@0
|
4210 |
void TestRootDirNotifyChange()
|
sl@0
|
4211 |
{
|
sl@0
|
4212 |
test.Next(_L("Testing RFs::NotifyChange() on drive's root directory."));
|
sl@0
|
4213 |
|
sl@0
|
4214 |
TInt nRes;
|
sl@0
|
4215 |
TRequestStatus reqStatNotify1(KRequestPending);
|
sl@0
|
4216 |
|
sl@0
|
4217 |
_LIT(KTestPath, "\\"); //-- root dir, actually
|
sl@0
|
4218 |
|
sl@0
|
4219 |
//-- set up notifier
|
sl@0
|
4220 |
TheFs.NotifyChange(ENotifyAll, reqStatNotify1, KTestPath);
|
sl@0
|
4221 |
test(reqStatNotify1.Int() == KRequestPending);
|
sl@0
|
4222 |
|
sl@0
|
4223 |
//-- create a file in the root dir
|
sl@0
|
4224 |
RFile file;
|
sl@0
|
4225 |
TFileName fileName(KTestPath);
|
sl@0
|
4226 |
|
sl@0
|
4227 |
fileName.Append(_L("TestFile.tst"));
|
sl@0
|
4228 |
|
sl@0
|
4229 |
nRes=file.Replace(TheFs, fileName, EFileWrite|EFileRead);
|
sl@0
|
4230 |
test(nRes == KErrNone || nRes ==KErrAlreadyExists);
|
sl@0
|
4231 |
file.Close();
|
sl@0
|
4232 |
|
sl@0
|
4233 |
//-- check that the notifier worked
|
sl@0
|
4234 |
User::WaitForRequest(reqStatNotify1);
|
sl@0
|
4235 |
test(reqStatNotify1.Int() == KErrNone);
|
sl@0
|
4236 |
|
sl@0
|
4237 |
}
|
sl@0
|
4238 |
|
sl@0
|
4239 |
|
sl@0
|
4240 |
|
sl@0
|
4241 |
//-----------------------------------------------------------------------
|
sl@0
|
4242 |
|
sl@0
|
4243 |
//
|
sl@0
|
4244 |
// Do all tests
|
sl@0
|
4245 |
//
|
sl@0
|
4246 |
GLDEF_C void CallTestsL()
|
sl@0
|
4247 |
{
|
sl@0
|
4248 |
|
sl@0
|
4249 |
CreateTestDirectory(_L("\\F32-TST\\NOTIFY\\"));
|
sl@0
|
4250 |
|
sl@0
|
4251 |
// Test RFs::NotifyChange()
|
sl@0
|
4252 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4253 |
Test1();
|
sl@0
|
4254 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4255 |
Test2();
|
sl@0
|
4256 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4257 |
Test3();
|
sl@0
|
4258 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4259 |
Test4();
|
sl@0
|
4260 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4261 |
Test5();
|
sl@0
|
4262 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4263 |
|
sl@0
|
4264 |
#if defined (__EPOC32__)//we have no removable media on Emulator yet .. ??? we do now
|
sl@0
|
4265 |
#if defined __INCLUDE_MANUAL_TESTS__
|
sl@0
|
4266 |
|
sl@0
|
4267 |
// Media change notification on every socket supported
|
sl@0
|
4268 |
TInt i;
|
sl@0
|
4269 |
for (i=0; i<KMaxPBusSockets; i++)
|
sl@0
|
4270 |
SocketToDrive[i]=-1;
|
sl@0
|
4271 |
TDriveInfoV1Buf dinfo;
|
sl@0
|
4272 |
UserHal::DriveInfo(dinfo);
|
sl@0
|
4273 |
TDriveInfoV1 &di=dinfo();
|
sl@0
|
4274 |
TInt driveCount=dinfo().iTotalSupportedDrives;
|
sl@0
|
4275 |
TInt socketCount=dinfo().iTotalSockets;
|
sl@0
|
4276 |
TInt drv;
|
sl@0
|
4277 |
test.Printf(_L("Socket count: %d\n"), socketCount);
|
sl@0
|
4278 |
TUint32 mask=~(0xffffffffu<<socketCount);
|
sl@0
|
4279 |
|
sl@0
|
4280 |
for (drv=0; drv<driveCount; drv++)
|
sl@0
|
4281 |
{
|
sl@0
|
4282 |
TBool flag=EFalse;
|
sl@0
|
4283 |
RLocalDrive d;
|
sl@0
|
4284 |
TInt r=d.Connect(drv,flag);
|
sl@0
|
4285 |
|
sl@0
|
4286 |
//Not all the drives are used at present
|
sl@0
|
4287 |
if (r == KErrNotSupported)
|
sl@0
|
4288 |
continue;
|
sl@0
|
4289 |
|
sl@0
|
4290 |
test(r==KErrNone);
|
sl@0
|
4291 |
TInt sockNum = 0;
|
sl@0
|
4292 |
if (d.IsRemovable(sockNum)>0)
|
sl@0
|
4293 |
{
|
sl@0
|
4294 |
if (mask & (1<<sockNum))
|
sl@0
|
4295 |
{
|
sl@0
|
4296 |
SocketToDrive[sockNum]=drv;
|
sl@0
|
4297 |
mask &= ~(1<<sockNum);
|
sl@0
|
4298 |
}
|
sl@0
|
4299 |
}
|
sl@0
|
4300 |
d.Close();
|
sl@0
|
4301 |
}
|
sl@0
|
4302 |
|
sl@0
|
4303 |
|
sl@0
|
4304 |
// Manual media change test
|
sl@0
|
4305 |
for (gSocketNumber=socketCount-1; gSocketNumber>=0; gSocketNumber--)
|
sl@0
|
4306 |
{
|
sl@0
|
4307 |
if (SocketToDrive[gSocketNumber] != -1)
|
sl@0
|
4308 |
{
|
sl@0
|
4309 |
test.Printf(_L("Testing socket %u, drive %u...\n"),
|
sl@0
|
4310 |
gSocketNumber, SocketToDrive[gSocketNumber]);
|
sl@0
|
4311 |
Test99();
|
sl@0
|
4312 |
}
|
sl@0
|
4313 |
}
|
sl@0
|
4314 |
#endif
|
sl@0
|
4315 |
Test6();
|
sl@0
|
4316 |
#endif
|
sl@0
|
4317 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4318 |
Test7();
|
sl@0
|
4319 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4320 |
|
sl@0
|
4321 |
|
sl@0
|
4322 |
#if defined (__EPOC32__)//we have no removable media on Emulator yet
|
sl@0
|
4323 |
|
sl@0
|
4324 |
// Test RFs::NotifyChange() extended notification
|
sl@0
|
4325 |
TInt uid;
|
sl@0
|
4326 |
test(HAL::Get(HAL::EMachineUid,uid)==KErrNone);
|
sl@0
|
4327 |
if(uid!=HAL::EMachineUid_Cogent && uid!=HAL::EMachineUid_IQ80310 &&
|
sl@0
|
4328 |
uid != HAL::EMachineUid_Integrator && uid!=HAL::EMachineUid_X86PC)
|
sl@0
|
4329 |
MediaChangeExtendedNotification();
|
sl@0
|
4330 |
|
sl@0
|
4331 |
#endif
|
sl@0
|
4332 |
|
sl@0
|
4333 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4334 |
TestRequestAhead();
|
sl@0
|
4335 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4336 |
Test8();
|
sl@0
|
4337 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4338 |
Test9();
|
sl@0
|
4339 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4340 |
Test10();
|
sl@0
|
4341 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4342 |
Test11();
|
sl@0
|
4343 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4344 |
Test12();
|
sl@0
|
4345 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4346 |
Test13();
|
sl@0
|
4347 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4348 |
Test14();
|
sl@0
|
4349 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4350 |
Test15();
|
sl@0
|
4351 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4352 |
Test16();
|
sl@0
|
4353 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4354 |
Test17();
|
sl@0
|
4355 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4356 |
Test18();
|
sl@0
|
4357 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4358 |
TestAsyncReader();
|
sl@0
|
4359 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4360 |
DeleteTestDirectory();
|
sl@0
|
4361 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4362 |
TestRootDirNotifyChange();
|
sl@0
|
4363 |
CHECK_NO_PENDING_REQUESTS;
|
sl@0
|
4364 |
}
|