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