|
1 // Copyright (c) 2004-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 "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 // |
|
15 |
|
16 #include "t_cenrep_helper.h" |
|
17 #include <centralrepository.h> |
|
18 #include <e32test.h> |
|
19 #include <f32file.h> |
|
20 #include "../cenrepsrv/srvreqs.h" |
|
21 #include "../common/inc/srvdefs.h" |
|
22 #include "../cenrepsrv/srvparams.h" |
|
23 |
|
24 using namespace NCentralRepositoryConstants; |
|
25 |
|
26 RTest TheTest(_L("Central Repository Tests")); |
|
27 |
|
28 TBool OomTesting; |
|
29 |
|
30 const TUid KUidTestRepository1 = { 0x00000001 }; |
|
31 const TUid KUidCreTestRepository1 = { 0x22222221 }; |
|
32 const TUid KUidTestRepository2 = { 0x00000002 }; |
|
33 |
|
34 const TUid KUidCorruptRepository = { 0x00000003 }; |
|
35 const TUid KUidResetTestRepository = { 0x00000004 }; |
|
36 |
|
37 const TUid KUidDriveCRepository = { 0x00000010 }; |
|
38 |
|
39 const TUid KUidDriveCOnlyRepository = { 0x00000013 }; |
|
40 |
|
41 // |
|
42 // Test repository 1 |
|
43 // |
|
44 |
|
45 const TUint32 KNonExisitentSetting = 0; |
|
46 |
|
47 const TInt KNumSettings = 9; |
|
48 |
|
49 const TUint32 KInt1 = 1; |
|
50 const TInt KInt1_InitialValue = 1; |
|
51 const TInt KInt1_UpdatedValue = 73; |
|
52 const TUint32 KInt3 = 257; |
|
53 const TUint32 KNewInt = 1000; |
|
54 |
|
55 const TUint32 KReal1 = 2; |
|
56 const TReal KReal1_InitialValue = 2.732; |
|
57 const TReal KReal1_UpdatedValue = 72.8; |
|
58 const TUint32 KReal2 = 8; |
|
59 const TReal KReal2_InitialValue = 1.5; |
|
60 const TUint32 KReal3 = 17; |
|
61 const TUint32 KNewReal = 2000; |
|
62 |
|
63 const TUint32 KString1 = 5; |
|
64 _LIT(KString1_InitialValue, "test\\\"string\""); |
|
65 _LIT(KString1_UpdatedValue, "another one"); |
|
66 const TUint32 KString2 = 12; |
|
67 _LIT8(KString2_8BitValue, "string"); |
|
68 |
|
69 const TUint32 KString12 = 12; |
|
70 const TUint32 KNewString8 = 3000; |
|
71 const TUint32 KNewString16 = 4000; |
|
72 |
|
73 const TUint32 KNewSetting1 = 0x2001; |
|
74 const TUint32 KNewSetting2 = 0x2002; |
|
75 const TUint32 KNewSetting3 = 0x2003; |
|
76 const TUint32 KNewSetting4 = 0x2004; |
|
77 const TUint32 KNewSetting5 = 0x2005; |
|
78 const TUint32 KNewSetting6 = 0x2006; |
|
79 const TUint32 KNewSetting7 = 0x2007; |
|
80 const TUint32 KNewSetting8 = 0x2008; |
|
81 |
|
82 const TInt32 KNewSetting1Value = 4567; |
|
83 const TReal KNewSetting2Value = 45.67; |
|
84 _LIT(KNewSetting3Value, "a unicode str"); |
|
85 _LIT8(KNewSetting4Value, "an ascii str"); |
|
86 const TInt32 KNewSetting5Value = 2389; |
|
87 const TReal KNewSetting6Value = 23.89; |
|
88 _LIT(KNewSetting7Value, "another unicode str"); |
|
89 _LIT8(KNewSetting8Value, "another ascii str"); |
|
90 |
|
91 |
|
92 // |
|
93 // Test repository 2 |
|
94 // |
|
95 |
|
96 const TInt KIntB1 = 807; |
|
97 const TInt KIntB1_InitialValue = 100; |
|
98 |
|
99 |
|
100 |
|
101 /////////////////////////////////////////////////////////////////////////////////////// |
|
102 /////////////////////////////////////////////////////////////////////////////////////// |
|
103 //Test macroses and functions |
|
104 |
|
105 LOCAL_C void CheckL(TInt aValue, TInt aLine) |
|
106 { |
|
107 if(!aValue) |
|
108 { |
|
109 CleanupCDriveL(); |
|
110 TheTest(EFalse, aLine); |
|
111 } |
|
112 } |
|
113 LOCAL_C void CheckL(TInt aValue, TInt aExpected, TInt aLine) |
|
114 { |
|
115 if(aValue != aExpected) |
|
116 { |
|
117 CleanupCDriveL(); |
|
118 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
119 TheTest(EFalse, aLine); |
|
120 } |
|
121 } |
|
122 #define TEST(arg) ::CheckL((arg), __LINE__) |
|
123 #define TEST2(aValue, aExpected) ::CheckL(aValue, aExpected, __LINE__) |
|
124 |
|
125 /////////////////////////////////////////////////////////////////////////////////////// |
|
126 /////////////////////////////////////////////////////////////////////////////////////// |
|
127 |
|
128 LOCAL_C void KillCentRepServerL() |
|
129 { |
|
130 _LIT(KCentralRepositoryServerName, "Centralrepositorysrv"); |
|
131 _LIT(KProcessKillProcess, "t_processkillprocess.exe"); |
|
132 |
|
133 TRequestStatus stat; |
|
134 RProcess p; |
|
135 User::LeaveIfError(p.Create(KProcessKillProcess, KCentralRepositoryServerName)); |
|
136 |
|
137 // Asynchronous logon: completes when process terminates with process |
|
138 // exit code |
|
139 p.Logon(stat); |
|
140 p.Resume(); |
|
141 User::WaitForRequest(stat); |
|
142 |
|
143 TExitType exitType = p.ExitType(); |
|
144 TInt exitReason = p.ExitReason(); |
|
145 |
|
146 _LIT(KKillServerFailed, "Killing Central Repository Server Failed"); |
|
147 __ASSERT_ALWAYS(exitType == EExitKill, User::Panic(KKillServerFailed, exitReason)); |
|
148 |
|
149 p.Close(); |
|
150 User::LeaveIfError(exitReason); |
|
151 } |
|
152 |
|
153 //This function resets the KUidTestRepository1 repository |
|
154 //to its intial state to remove any changes made to the repository during |
|
155 //previous tests |
|
156 LOCAL_C void ResetTestRepositoryL() |
|
157 { |
|
158 CRepository* repository; |
|
159 |
|
160 User::LeaveIfNull(repository = CRepository::NewLC(KUidTestRepository1)); |
|
161 TInt r = repository->Reset(); |
|
162 TEST2(r, KErrNone); |
|
163 CleanupStack::PopAndDestroy(repository); |
|
164 } |
|
165 |
|
166 //This function restores the state of the files required for this test |
|
167 //Existing files are deleted and then the required files are copied |
|
168 //back from the Z drive to the c drive |
|
169 LOCAL_C void RestoreTestFilesL() |
|
170 { |
|
171 //Delete all files from C:\\private\\10202BE9\\persists\\ dir |
|
172 //and C:\\private\\10202BE9\\ dir |
|
173 CleanupCDriveL(); |
|
174 |
|
175 RFs fs; |
|
176 User::LeaveIfError(fs.Connect()); |
|
177 CleanupClosePushL(fs); |
|
178 |
|
179 CFileMan* fm = CFileMan::NewL(fs); |
|
180 CleanupStack::PushL(fm); |
|
181 |
|
182 // _LIT(KPersistTargetPath, "c:\\private\\10202BE9\\persists\\*.txt"); |
|
183 _LIT(KPersistTargetPath, "z:\\private\\10202BE9\\*.txt"); |
|
184 _LIT(KPersistSourcePath, "Z:\\private\\10202BE9\\*.txc"); |
|
185 _LIT(KInstallTargetPath, "C:\\private\\10202BE9\\*.txt"); |
|
186 _LIT(KInstallSourcePath, "Z:\\private\\10202BE9\\*.txi"); |
|
187 |
|
188 //copy test files from Z: to C: |
|
189 CopyTestFilesL(*fm,KPersistSourcePath, KPersistTargetPath); |
|
190 CopyTestFilesL(*fm,KInstallSourcePath, KInstallTargetPath); |
|
191 |
|
192 CleanupStack::PopAndDestroy(2); |
|
193 |
|
194 } |
|
195 |
|
196 |
|
197 /** |
|
198 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-1297 |
|
199 @SYMTestCaseDesc Tests for creation and opening a central repository |
|
200 @SYMTestPriority High |
|
201 @SYMTestActions Tests for CRepository::NewLC(),CRepository::Get() functions |
|
202 @SYMTestExpectedResults Test must not fail |
|
203 @SYMREQ REQ0000 |
|
204 */ |
|
205 LOCAL_C void OpenRepositoryL() |
|
206 { |
|
207 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1297 ")); |
|
208 CRepository* repositoryA; |
|
209 CRepository* repositoryB; |
|
210 |
|
211 TInt r; |
|
212 |
|
213 // When an attempt is made to open a central repository in this test the result will |
|
214 // be that a new session (+ subsession) will be created with the server. For subsequent |
|
215 // central repository openings subsessions are then created under the same server. |
|
216 // Note that by placing the CRepository creation calls in the following order we |
|
217 // are exercising among other things the following scenarios: |
|
218 // 1. Session is opened and first subsession is created. Error occurs, whole session |
|
219 // is pulled down. |
|
220 // 2. Session is opened and first subsession is successfully created. 2nd subsession |
|
221 // is opened. Error occurs with 2nd subsession. 2nd subsession is pulled down. Session |
|
222 // and first sub-sesssion remain up. (DEF105089) |
|
223 |
|
224 TRAP(r, CRepository::NewL(TUid::Null())); |
|
225 if(OomTesting && r==KErrNoMemory) |
|
226 User::Leave(KErrNoMemory); |
|
227 TEST2(r, KErrNotFound); |
|
228 |
|
229 repositoryB = CRepository::NewLC(KUidTestRepository2); |
|
230 |
|
231 TRAP(r, CRepository::NewL(KUidCorruptRepository)); |
|
232 if(OomTesting && r==KErrNoMemory) |
|
233 User::Leave(KErrNoMemory); |
|
234 TEST2(r, KErrCorrupt); |
|
235 |
|
236 repositoryA = CRepository::NewLC(KUidTestRepository1); |
|
237 |
|
238 TInt a; |
|
239 r = repositoryA->Get(KInt1, a); |
|
240 TEST2(r, KErrNone); |
|
241 TEST(a==KInt1_InitialValue); |
|
242 |
|
243 r = repositoryB->Get(KIntB1, a); |
|
244 TEST2(r, KErrNone); |
|
245 TEST(a==KIntB1_InitialValue); |
|
246 |
|
247 CleanupStack::PopAndDestroy(repositoryA); |
|
248 |
|
249 r = repositoryB->Get(KIntB1, a); |
|
250 TEST2(r, KErrNone); |
|
251 TEST(a==KIntB1_InitialValue); |
|
252 |
|
253 CleanupStack::PopAndDestroy(repositoryB); |
|
254 } |
|
255 |
|
256 /** |
|
257 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-1298 |
|
258 @SYMTestCaseDesc Tests for CRepository's Integer,Real,String's Get and Set functions |
|
259 @SYMTestPriority High |
|
260 @SYMTestActions Tests for CRepository::Get(),CRepository::Set() functions |
|
261 @SYMTestExpectedResults Test must not fail |
|
262 @SYMREQ REQ0000 |
|
263 */ |
|
264 LOCAL_C void GetSetL(const TUid& aUid) |
|
265 { |
|
266 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1298 ")); |
|
267 CRepository* repository; |
|
268 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
269 |
|
270 _LIT8(KString12_InitialValue, "string"); |
|
271 TPtrC8 p8(KString12_InitialValue); |
|
272 |
|
273 _LIT(KString11_InitialValue, "string"); |
|
274 TPtrC p16(KString11_InitialValue); |
|
275 |
|
276 TBuf8<20> str8; |
|
277 TBuf<20> str; |
|
278 TInt i = 0; |
|
279 |
|
280 // |
|
281 // Integer get/set |
|
282 // |
|
283 |
|
284 TInt r = repository->Get(KNonExisitentSetting, i); |
|
285 TEST2(r, KErrNotFound); |
|
286 TEST(i==0); |
|
287 |
|
288 r = repository->Get(KReal1, i); |
|
289 TEST2(r, KErrArgument); |
|
290 TEST(i==0); |
|
291 |
|
292 r = repository->Get(KInt1, i); |
|
293 TEST2(r, KErrNone); |
|
294 TEST(i==KInt1_InitialValue); |
|
295 |
|
296 r = repository->Get(KNonExisitentSetting, i); |
|
297 TEST2(r, KErrNotFound); |
|
298 |
|
299 r = repository->Set(KNonExisitentSetting, 10); |
|
300 TEST2(r, KErrNone); |
|
301 |
|
302 //close and reopen rep to check set is persisted |
|
303 CleanupStack::PopAndDestroy(repository); |
|
304 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
305 |
|
306 r = repository->Get(KNonExisitentSetting, i); |
|
307 TEST2(r, KErrNone); |
|
308 TEST(i==10); |
|
309 |
|
310 r = repository->Delete(KNonExisitentSetting); |
|
311 TEST2(r, KErrNone); |
|
312 |
|
313 r = repository->Set(KReal1, 0); |
|
314 TEST2(r, KErrArgument); |
|
315 |
|
316 r = repository->Set(KInt1, KInt1_UpdatedValue); |
|
317 TEST2(r, KErrNone); |
|
318 |
|
319 //close and reopen rep to check set is persisted |
|
320 CleanupStack::PopAndDestroy(repository); |
|
321 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
322 |
|
323 r = repository->Get(KInt1, i); |
|
324 TEST2(r, KErrNone); |
|
325 TEST(i==KInt1_UpdatedValue); |
|
326 |
|
327 r = repository->Get(KInt1,str8); |
|
328 TEST2(r, KErrArgument); |
|
329 //checks if KInt was modified |
|
330 r = repository->Get(KInt1, i); |
|
331 TEST2(r, KErrNone); |
|
332 TEST(i==KInt1_UpdatedValue); |
|
333 |
|
334 r = repository->Set(KInt1, KString12_InitialValue); |
|
335 TEST2(r, KErrArgument); |
|
336 r = repository->Get(KInt1, i); |
|
337 TEST2(r, KErrNone); |
|
338 TEST(i==KInt1_UpdatedValue); |
|
339 |
|
340 r = repository->Get(KInt1,str); |
|
341 TEST2(r, KErrArgument); |
|
342 //checks if KInt was modified |
|
343 r = repository->Get(KInt1, i); |
|
344 TEST2(r, KErrNone); |
|
345 TEST(i==KInt1_UpdatedValue); |
|
346 |
|
347 r = repository->Set(KInt1, KString11_InitialValue); |
|
348 TEST2(r, KErrArgument); |
|
349 r = repository->Get(KInt1, i); |
|
350 TEST2(r, KErrNone); |
|
351 TEST(i==KInt1_UpdatedValue); |
|
352 // |
|
353 // Real get/set |
|
354 // |
|
355 |
|
356 TReal y = 0; |
|
357 |
|
358 r = repository->Get(KNonExisitentSetting, y); |
|
359 TEST2(r, KErrNotFound); |
|
360 TEST(y==0); |
|
361 |
|
362 r = repository->Get(KInt1, y); |
|
363 TEST2(r, KErrArgument); |
|
364 TEST(y==0); |
|
365 |
|
366 r = repository->Get(KReal1, y); |
|
367 TEST2(r, KErrNone); |
|
368 TEST(y==KReal1_InitialValue); |
|
369 |
|
370 r = repository->Get(KNonExisitentSetting, y); |
|
371 TEST2(r, KErrNotFound); |
|
372 |
|
373 r = repository->Set(KNonExisitentSetting, 0.0); |
|
374 TEST2(r, KErrNone); |
|
375 |
|
376 //close and reopen rep to check set is persisted |
|
377 CleanupStack::PopAndDestroy(repository); |
|
378 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
379 |
|
380 r = repository->Get(KNonExisitentSetting, y); |
|
381 TEST2(r, KErrNone); |
|
382 TEST(y == 0.0); |
|
383 |
|
384 r = repository->Delete(KNonExisitentSetting); |
|
385 TEST2(r, KErrNone); |
|
386 |
|
387 r = repository->Set(KInt1, 0.0); |
|
388 TEST2(r, KErrArgument); |
|
389 |
|
390 r = repository->Set(KReal1, KReal1_UpdatedValue); |
|
391 TEST2(r, KErrNone); |
|
392 |
|
393 //close and reopen rep to check set is persisted |
|
394 CleanupStack::PopAndDestroy(repository); |
|
395 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
396 |
|
397 r = repository->Get(KReal1, y); |
|
398 TEST2(r, KErrNone); |
|
399 TEST(y==KReal1_UpdatedValue); |
|
400 |
|
401 r = repository->Get(KReal1,str8); |
|
402 TEST2(r, KErrArgument); |
|
403 //checks if KInt was modified |
|
404 r = repository->Get(KReal1, y); |
|
405 TEST2(r, KErrNone); |
|
406 TEST(y==KReal1_UpdatedValue); |
|
407 |
|
408 r = repository->Get(KReal1,str); |
|
409 TEST2(r, KErrArgument); |
|
410 //checks if KInt was modified |
|
411 r = repository->Get(KReal1, y); |
|
412 TEST2(r, KErrNone); |
|
413 TEST(y==KReal1_UpdatedValue); |
|
414 |
|
415 r = repository->Set(KReal1, KString12_InitialValue); |
|
416 TEST2(r, KErrArgument); |
|
417 r = repository->Get(KReal1, y); |
|
418 TEST2(r, KErrNone); |
|
419 TEST(y==KReal1_UpdatedValue); |
|
420 |
|
421 r = repository->Set(KReal1, KString11_InitialValue); |
|
422 TEST2(r, KErrArgument); |
|
423 r = repository->Get(KReal1, y); |
|
424 TEST2(r, KErrNone); |
|
425 TEST(y==KReal1_UpdatedValue); |
|
426 |
|
427 // |
|
428 // String get/set |
|
429 // |
|
430 r = repository->Get(KNonExisitentSetting, str); |
|
431 TEST2(r, KErrNotFound); |
|
432 TEST(str.Length()==0); |
|
433 |
|
434 r = repository->Get(KInt1, str); |
|
435 TEST2(r, KErrArgument); |
|
436 TEST(str.Length()==0); |
|
437 |
|
438 r = repository->Get(KString1, str); |
|
439 TEST2(r, KErrNone); |
|
440 TEST(str==KString1_InitialValue); |
|
441 |
|
442 TBuf<10> tooShort; |
|
443 r = repository->Get(KString1, tooShort); |
|
444 TEST2(r, KErrOverflow); |
|
445 TEST(tooShort.Length()==10); |
|
446 |
|
447 r = repository->Get(KNonExisitentSetting, str); |
|
448 TEST2(r, KErrNotFound); |
|
449 |
|
450 r = repository->Set(KNonExisitentSetting, KString1_UpdatedValue); |
|
451 TEST2(r, KErrNone); |
|
452 |
|
453 //close and reopen rep to check set is persisted |
|
454 CleanupStack::PopAndDestroy(repository); |
|
455 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
456 |
|
457 r = repository->Get(KNonExisitentSetting, str); |
|
458 TEST2(r, KErrNone); |
|
459 TEST(str==KString1_UpdatedValue); |
|
460 |
|
461 r = repository->Delete(KNonExisitentSetting); |
|
462 TEST2(r, KErrNone); |
|
463 |
|
464 r = repository->Set(KInt1, str); |
|
465 TEST2(r, KErrArgument); |
|
466 |
|
467 r = repository->Set(KString1, KString1_UpdatedValue); |
|
468 TEST2(r, KErrNone); |
|
469 |
|
470 //close and reopen rep to check set is persisted |
|
471 CleanupStack::PopAndDestroy(repository); |
|
472 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
473 |
|
474 r = repository->Get(KString1, str); |
|
475 TEST2(r, KErrNone); |
|
476 TEST(str==KString1_UpdatedValue); |
|
477 |
|
478 //testing the new feature: creating an 8 bit string from ini file. |
|
479 r = repository->Get(KString12, str8); |
|
480 TEST2(r, KErrNone); |
|
481 TEST(str8==KString12_InitialValue); |
|
482 |
|
483 //get 8-bit string with int |
|
484 r = repository->Get(KString12, i); |
|
485 TEST2(r, KErrArgument); |
|
486 r = repository->Get(KString12, str8); |
|
487 TEST2(r, KErrNone); |
|
488 TEST(str8==KString12_InitialValue); |
|
489 |
|
490 //get 8-bit string with real |
|
491 r = repository->Get(KString12, y); |
|
492 TEST2(r, KErrArgument); |
|
493 r = repository->Get(KString12, str8); |
|
494 TEST2(r, KErrNone); |
|
495 TEST(str8==KString12_InitialValue); |
|
496 |
|
497 //set 8-bit string with int |
|
498 r = repository->Set(KString12, i); |
|
499 TEST2(r, KErrArgument); |
|
500 r = repository->Get(KString12, str8); |
|
501 TEST2(r, KErrNone); |
|
502 TEST(str8==KString12_InitialValue); |
|
503 |
|
504 //set 8-bit string with real |
|
505 r = repository->Set(KString12, y); |
|
506 TEST2(r, KErrArgument); |
|
507 r = repository->Get(KString12, str8); |
|
508 TEST2(r, KErrNone); |
|
509 TEST(str8==KString12_InitialValue); |
|
510 |
|
511 |
|
512 //get 16-bit string with int |
|
513 r = repository->Get(KString1,i); |
|
514 TEST2(r, KErrArgument); |
|
515 //checks if a string was modified |
|
516 r = repository->Get(KString1, str); |
|
517 TEST2(r, KErrNone); |
|
518 TEST(str==KString1_UpdatedValue); |
|
519 |
|
520 //get 16-bit string with real |
|
521 r = repository->Get(KString1,y); |
|
522 TEST2(r, KErrArgument); |
|
523 //checks if a string was modified |
|
524 r = repository->Get(KString1, str); |
|
525 TEST2(r, KErrNone); |
|
526 TEST(str==KString1_UpdatedValue); |
|
527 |
|
528 //set 16-bit string with int |
|
529 r = repository->Set(KString1,i); |
|
530 TEST2(r, KErrArgument); |
|
531 //checks if a string was modified |
|
532 r = repository->Get(KString1, str); |
|
533 TEST2(r, KErrNone); |
|
534 TEST(str==KString1_UpdatedValue); |
|
535 |
|
536 //set 16-bit string with real |
|
537 r = repository->Set(KString1,y); |
|
538 TEST2(r, KErrArgument); |
|
539 //checks if a string was modified |
|
540 r = repository->Get(KString1, str); |
|
541 TEST2(r, KErrNone); |
|
542 TEST(str==KString1_UpdatedValue); |
|
543 |
|
544 const TInt KStringLengthTooBig = KMaxUnicodeStringLength + 1; |
|
545 TBuf<KStringLengthTooBig> tooBig; |
|
546 tooBig.SetLength(KStringLengthTooBig); |
|
547 r = repository->Set(KString1, tooBig); |
|
548 TEST2(r, KErrArgument); |
|
549 |
|
550 //- Test null descriptors |
|
551 r = repository->Set(KString1, KNullDesC); |
|
552 TEST2(r, KErrNone); |
|
553 |
|
554 CleanupStack::PopAndDestroy(repository); |
|
555 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
556 |
|
557 r = repository->Get(KString1, str); |
|
558 TEST2(r, KErrNone); |
|
559 TEST(str==KNullDesC); |
|
560 |
|
561 r = repository->Set(KString1, KString1_UpdatedValue); |
|
562 TEST2(r, KErrNone); |
|
563 |
|
564 //close and reopen rep to check set is persisted |
|
565 CleanupStack::PopAndDestroy(repository); |
|
566 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
567 |
|
568 r = repository->Get(KString1, str); |
|
569 TEST2(r, KErrNone); |
|
570 TEST(str==KString1_UpdatedValue); |
|
571 //- |
|
572 |
|
573 // Check that the SetGetParameters interface returns KErrNotSupported in the default macro configuration |
|
574 #if !defined(__CENTREP_SERVER_PERFTEST__) && !defined(__CENTREP_SERVER_MEMTEST__) && !defined(__CENTREP_SERVER_CACHETEST__) |
|
575 TIpcArgs args; |
|
576 r = SetGetParameters(args); |
|
577 TEST2(r, KErrNotSupported); |
|
578 #endif |
|
579 |
|
580 CleanupStack::PopAndDestroy(repository); |
|
581 } |
|
582 |
|
583 /** |
|
584 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-1299 |
|
585 @SYMTestCaseDesc Tests for CRepository class's find operations |
|
586 @SYMTestPriority High |
|
587 @SYMTestActions Tests for CRepository::FindL(),CRepository::FindEqL(),CRepository::FindNeqL() functions |
|
588 @SYMTestExpectedResults Test must not fail |
|
589 @SYMREQ REQ0000 |
|
590 */ |
|
591 LOCAL_C void FindL() |
|
592 { |
|
593 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1299 ")); |
|
594 CRepository* repository; |
|
595 User::LeaveIfNull(repository = CRepository::NewLC(KUidTestRepository1)); |
|
596 |
|
597 RArray<TUint32> foundIds; |
|
598 |
|
599 TInt r = KErrNone; |
|
600 TInt leaveCode = KErrNone; |
|
601 TRAP(leaveCode, r = repository->FindL(0, 0, foundIds)); |
|
602 if (leaveCode != KErrNone) |
|
603 r = leaveCode ; |
|
604 |
|
605 if(OomTesting && r==KErrNoMemory) |
|
606 { |
|
607 foundIds.Close(); |
|
608 User::Leave(KErrNoMemory); |
|
609 } |
|
610 |
|
611 TEST2(r, KErrNone); |
|
612 TEST(foundIds.Count()==KNumSettings); |
|
613 foundIds.Reset(); |
|
614 |
|
615 /***************************************************************************************/ |
|
616 //Tests for FindL |
|
617 /***************************************************************************************/ |
|
618 TRAP(leaveCode, r = repository->FindL(23, 0, foundIds)); // 23 - just a random number, value is not important |
|
619 if (leaveCode != KErrNone) |
|
620 r = leaveCode ; |
|
621 if(OomTesting && r==KErrNoMemory) |
|
622 { |
|
623 foundIds.Close(); |
|
624 User::Leave(KErrNoMemory); |
|
625 } |
|
626 TEST2(r, KErrNone); |
|
627 TEST(foundIds.Count()==KNumSettings); |
|
628 foundIds.Reset(); |
|
629 |
|
630 |
|
631 TRAP(leaveCode, r=repository->FindL(0, 2, foundIds)); |
|
632 if (leaveCode != KErrNone) |
|
633 r = leaveCode ; |
|
634 if(OomTesting && r==KErrNoMemory) |
|
635 { |
|
636 foundIds.Close(); |
|
637 User::Leave(KErrNoMemory); |
|
638 } |
|
639 TEST2(r, KErrNone); |
|
640 TEST(foundIds.Count()==6); |
|
641 foundIds.Reset(); |
|
642 |
|
643 |
|
644 TRAP(leaveCode, r=repository->FindL(4, 6, foundIds)); |
|
645 if (leaveCode != KErrNone) |
|
646 r = leaveCode ; |
|
647 if(OomTesting && r==KErrNoMemory) |
|
648 { |
|
649 foundIds.Close(); |
|
650 User::Leave(KErrNoMemory); |
|
651 } |
|
652 TEST2(r, KErrNone); |
|
653 TEST(foundIds.Count()==2); |
|
654 foundIds.Reset(); |
|
655 |
|
656 |
|
657 |
|
658 TRAP(leaveCode, r= repository->FindL(15, 15, foundIds)); |
|
659 if (leaveCode != KErrNone) |
|
660 r = leaveCode ; |
|
661 if(OomTesting && r==KErrNoMemory) |
|
662 { |
|
663 foundIds.Close(); |
|
664 User::Leave(KErrNoMemory); |
|
665 } |
|
666 TEST2(r, KErrNotFound); |
|
667 TEST(foundIds.Count()==0); |
|
668 |
|
669 |
|
670 /***************************************************************************************/ |
|
671 //Tests for FindEqL for Int |
|
672 /***************************************************************************************/ |
|
673 TRAP(leaveCode, r= repository->FindEqL(0, 0, KInt1_UpdatedValue, foundIds)); |
|
674 if (leaveCode != KErrNone) |
|
675 r = leaveCode ; |
|
676 if(OomTesting && r==KErrNoMemory) |
|
677 { |
|
678 foundIds.Close(); |
|
679 User::Leave(KErrNoMemory); |
|
680 } |
|
681 TEST2(r, KErrNone); |
|
682 TEST(foundIds.Count()==1); |
|
683 TEST(foundIds[0]==KInt1); |
|
684 foundIds.Reset(); |
|
685 |
|
686 |
|
687 TRAP(leaveCode, r= repository->FindEqL(0, 0, 0, foundIds)); |
|
688 if (leaveCode != KErrNone) |
|
689 r = leaveCode ; |
|
690 if(OomTesting && r==KErrNoMemory) |
|
691 { |
|
692 foundIds.Close(); |
|
693 User::Leave(KErrNoMemory); |
|
694 } |
|
695 TEST2(r, KErrNotFound); |
|
696 TEST(foundIds.Count()==0); |
|
697 |
|
698 |
|
699 /***************************************************************************************/ |
|
700 //Tests for FindEqL for Real |
|
701 /***************************************************************************************/ |
|
702 TRAP(leaveCode, r= repository->FindEqL(0, 0, KReal2_InitialValue, foundIds)); |
|
703 if (leaveCode != KErrNone) |
|
704 r = leaveCode ; |
|
705 if(OomTesting && r==KErrNoMemory) |
|
706 { |
|
707 foundIds.Close(); |
|
708 User::Leave(KErrNoMemory); |
|
709 } |
|
710 TEST2(r, KErrNone); |
|
711 TEST(foundIds.Count()==2); |
|
712 TEST(foundIds[0]==KReal2); |
|
713 TEST(foundIds[1]==KReal3); |
|
714 foundIds.Reset(); |
|
715 |
|
716 |
|
717 TRAP(leaveCode, r= repository->FindEqL(0, 0, 7.7, foundIds)); |
|
718 if (leaveCode != KErrNone) |
|
719 r = leaveCode ; |
|
720 if(OomTesting && r==KErrNoMemory) |
|
721 { |
|
722 foundIds.Close(); |
|
723 User::Leave(KErrNoMemory); |
|
724 } |
|
725 TEST2(r, KErrNotFound); |
|
726 TEST(foundIds.Count()==0); |
|
727 |
|
728 |
|
729 /***************************************************************************************/ |
|
730 //Tests for FindEqL for String |
|
731 /***************************************************************************************/ |
|
732 TRAP(leaveCode, r= repository->FindEqL(0, 0, KString1_UpdatedValue, foundIds)); |
|
733 if (leaveCode != KErrNone) |
|
734 r = leaveCode ; |
|
735 if(OomTesting && r==KErrNoMemory) |
|
736 { |
|
737 foundIds.Close(); |
|
738 User::Leave(KErrNoMemory); |
|
739 } |
|
740 TEST2(r, KErrNone); |
|
741 TEST(foundIds.Count()==1); |
|
742 TEST(foundIds[0]==KString1); |
|
743 foundIds.Reset(); |
|
744 |
|
745 _LIT(KFoo, "foo"); |
|
746 |
|
747 TRAP(leaveCode, r= repository->FindEqL(0, 0, KFoo, foundIds)); |
|
748 if (leaveCode != KErrNone) |
|
749 r = leaveCode ; |
|
750 if(OomTesting && r==KErrNoMemory) |
|
751 { |
|
752 foundIds.Close(); |
|
753 User::Leave(KErrNoMemory); |
|
754 } |
|
755 TEST2(r, KErrNotFound); |
|
756 TEST(foundIds.Count()==0); |
|
757 |
|
758 /***************************************************************************************/ |
|
759 //Tests for FindEqL for String8 |
|
760 /***************************************************************************************/ |
|
761 TRAP(leaveCode, r= repository->FindEqL(0, 0, KString2_8BitValue, foundIds)); |
|
762 if (leaveCode != KErrNone) |
|
763 r = leaveCode ; |
|
764 if(OomTesting && r==KErrNoMemory) |
|
765 { |
|
766 foundIds.Close(); |
|
767 User::Leave(KErrNoMemory); |
|
768 } |
|
769 TEST2(r, KErrNone); |
|
770 TEST(foundIds.Count()==1); |
|
771 TEST(foundIds[0]==KString2); |
|
772 foundIds.Reset(); |
|
773 |
|
774 _LIT8(KFoo8, "foo"); |
|
775 |
|
776 TRAP(leaveCode, r= repository->FindEqL(0, 0, KFoo8, foundIds)); |
|
777 if (leaveCode != KErrNone) |
|
778 r = leaveCode ; |
|
779 if(OomTesting && r==KErrNoMemory) |
|
780 { |
|
781 foundIds.Close(); |
|
782 User::Leave(KErrNoMemory); |
|
783 } |
|
784 TEST2(r, KErrNotFound); |
|
785 TEST(foundIds.Count()==0); |
|
786 |
|
787 /***************************************************************************************/ |
|
788 //Tests for FindNeqL for Int |
|
789 /***************************************************************************************/ |
|
790 TRAP(leaveCode, r= repository->FindNeqL(0, 0, KInt1_UpdatedValue, foundIds)); |
|
791 if (leaveCode != KErrNone) |
|
792 r = leaveCode ; |
|
793 if(OomTesting && r==KErrNoMemory) |
|
794 { |
|
795 foundIds.Close(); |
|
796 User::Leave(KErrNoMemory); |
|
797 } |
|
798 TEST2(r, KErrNone); |
|
799 TEST(foundIds.Count()==8); |
|
800 TEST2(foundIds.Find(KInt1), KErrNotFound); |
|
801 foundIds.Reset(); |
|
802 |
|
803 |
|
804 TRAP(leaveCode, r= repository->FindNeqL(25, 25, KInt1_UpdatedValue, foundIds)); |
|
805 if (leaveCode != KErrNone) |
|
806 r = leaveCode ; |
|
807 if(OomTesting && r==KErrNoMemory) |
|
808 { |
|
809 foundIds.Close(); |
|
810 User::Leave(KErrNoMemory); |
|
811 } |
|
812 TEST2(r, KErrNotFound); |
|
813 TEST(foundIds.Count()==0); |
|
814 |
|
815 |
|
816 /***************************************************************************************/ |
|
817 //Tests for FindNeqL for Real |
|
818 /***************************************************************************************/ |
|
819 TRAP(leaveCode, r= repository->FindNeqL(0, 0, KReal1_UpdatedValue, foundIds)); |
|
820 if (leaveCode != KErrNone) |
|
821 r = leaveCode ; |
|
822 if(OomTesting && r==KErrNoMemory) |
|
823 { |
|
824 foundIds.Close(); |
|
825 User::Leave(KErrNoMemory); |
|
826 } |
|
827 TEST2(r, KErrNone); |
|
828 TEST(foundIds.Count()==8); |
|
829 TEST2(foundIds.Find(KReal1), KErrNotFound); |
|
830 foundIds.Reset(); |
|
831 |
|
832 |
|
833 TRAP(leaveCode,r= repository->FindNeqL(25, 25, KReal1_UpdatedValue, foundIds)); |
|
834 if (leaveCode != KErrNone) |
|
835 r = leaveCode ; |
|
836 if(OomTesting && r==KErrNoMemory) |
|
837 { |
|
838 foundIds.Close(); |
|
839 User::Leave(KErrNoMemory); |
|
840 } |
|
841 TEST2(r, KErrNotFound); |
|
842 TEST(foundIds.Count()==0); |
|
843 |
|
844 |
|
845 /***************************************************************************************/ |
|
846 //Tests for FindNeqL for String |
|
847 /***************************************************************************************/ |
|
848 TRAP(leaveCode, r= repository->FindNeqL(0, 0, KString1_UpdatedValue, foundIds)); |
|
849 if (leaveCode != KErrNone) |
|
850 r = leaveCode ; |
|
851 if(OomTesting && r==KErrNoMemory) |
|
852 { |
|
853 foundIds.Close(); |
|
854 User::Leave(KErrNoMemory); |
|
855 } |
|
856 TEST2(r, KErrNone); |
|
857 TEST(foundIds.Count()==8); |
|
858 TEST2(foundIds.Find(KString1), KErrNotFound); |
|
859 foundIds.Reset(); |
|
860 |
|
861 |
|
862 TRAP(leaveCode, r= repository->FindNeqL(25, 25, KString1_UpdatedValue, foundIds)); |
|
863 if (leaveCode != KErrNone) |
|
864 r = leaveCode ; |
|
865 if(OomTesting && r==KErrNoMemory) |
|
866 { |
|
867 foundIds.Close(); |
|
868 User::Leave(KErrNoMemory); |
|
869 } |
|
870 TEST2(r, KErrNotFound); |
|
871 TEST(foundIds.Count()==0); |
|
872 |
|
873 /***************************************************************************************/ |
|
874 //Tests for FindNeqL for String8 |
|
875 /***************************************************************************************/ |
|
876 TRAP(leaveCode, r= repository->FindNeqL(0, 0, KString2_8BitValue, foundIds)); |
|
877 if (leaveCode != KErrNone) |
|
878 r = leaveCode ; |
|
879 if(OomTesting && r==KErrNoMemory) |
|
880 { |
|
881 foundIds.Close(); |
|
882 User::Leave(KErrNoMemory); |
|
883 } |
|
884 TEST2(r, KErrNone); |
|
885 TEST(foundIds.Count()==8); |
|
886 TEST2(foundIds.Find(KString2), KErrNotFound); |
|
887 foundIds.Reset(); |
|
888 |
|
889 |
|
890 TRAP(leaveCode, r= repository->FindNeqL(25, 25, KString2_8BitValue, foundIds)); |
|
891 if (leaveCode != KErrNone) |
|
892 r = leaveCode ; |
|
893 if(OomTesting && r==KErrNoMemory) |
|
894 { |
|
895 foundIds.Close(); |
|
896 User::Leave(KErrNoMemory); |
|
897 } |
|
898 TEST2(r, KErrNotFound); |
|
899 TEST(foundIds.Count()==0); |
|
900 |
|
901 CleanupStack::PopAndDestroy(repository); |
|
902 } |
|
903 |
|
904 /** |
|
905 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-1300 |
|
906 @SYMTestCaseDesc CRepository class functionality test |
|
907 @SYMTestPriority High |
|
908 @SYMTestActions Test for CRepository::NotifyRequest() functions |
|
909 @SYMTestExpectedResults Test must not fail |
|
910 @SYMREQ REQ0000 |
|
911 */ |
|
912 LOCAL_C void NotifyL() |
|
913 { |
|
914 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1300 ")); |
|
915 CRepository* repository; |
|
916 User::LeaveIfNull(repository = CRepository::NewLC(KUidTestRepository1)); |
|
917 |
|
918 TInt r = KErrNone; |
|
919 TInt intval; |
|
920 TRequestStatus intStatus; |
|
921 TRequestStatus realStatus; |
|
922 TRequestStatus stringStatus; |
|
923 RThread thisThread; |
|
924 |
|
925 // |
|
926 // Notification on non-existent setting |
|
927 // |
|
928 r = repository->NotifyRequest(KNonExisitentSetting, intStatus); |
|
929 TEST2(r, KErrNotFound); |
|
930 |
|
931 // |
|
932 // Basic notification |
|
933 // |
|
934 r = repository->NotifyRequest(KInt1, intStatus); |
|
935 TEST2(r, KErrNone); |
|
936 |
|
937 r = repository->NotifyRequest(KReal1, realStatus); |
|
938 TEST2(r, KErrNone); |
|
939 |
|
940 r = repository->NotifyRequest(KString1, stringStatus); |
|
941 TEST2(r, KErrNone); |
|
942 |
|
943 |
|
944 // Setting to the same value should not cause a notification |
|
945 r = repository->Get(KInt1, intval); |
|
946 TEST2(r, KErrNone); |
|
947 r = repository->Set(KInt1, intval); |
|
948 TEST2(r, KErrNone); |
|
949 TEST(intStatus==KRequestPending); |
|
950 TEST(realStatus==KRequestPending); |
|
951 TEST(stringStatus==KRequestPending); |
|
952 TEST(thisThread.RequestCount()==0); |
|
953 |
|
954 // First change to setting should cause notification |
|
955 r = repository->Set(KInt1, 0); |
|
956 TEST2(r, KErrNone); |
|
957 User::WaitForAnyRequest(); |
|
958 TEST(intStatus==KInt1); |
|
959 TEST(realStatus==KRequestPending); |
|
960 TEST(stringStatus==KRequestPending); |
|
961 |
|
962 // Second change to setting should not cause notification |
|
963 intStatus = 7777; |
|
964 r = repository->Set(KInt1, 0); |
|
965 TEST2(r, KErrNone); |
|
966 TEST(intStatus==7777); |
|
967 TEST(realStatus==KRequestPending); |
|
968 TEST(stringStatus==KRequestPending); |
|
969 TEST(thisThread.RequestCount()==0); |
|
970 |
|
971 |
|
972 // Setting to the same value should not cause a notification |
|
973 TReal realval; |
|
974 r = repository->Get(KReal1, realval); |
|
975 TEST2(r, KErrNone); |
|
976 r = repository->Set(KReal1, realval); |
|
977 TEST2(r, KErrNone); |
|
978 TEST(intStatus==7777); |
|
979 TEST(realStatus==KRequestPending); |
|
980 TEST(stringStatus==KRequestPending); |
|
981 TEST(thisThread.RequestCount()==0); |
|
982 |
|
983 r = repository->Set(KReal1, 0.0); |
|
984 TEST2(r, KErrNone); |
|
985 User::WaitForAnyRequest(); |
|
986 TEST(intStatus==7777); |
|
987 TEST(realStatus==KReal1); |
|
988 TEST(stringStatus==KRequestPending); |
|
989 |
|
990 |
|
991 // Setting to the same value should not cause a notification |
|
992 realStatus = 8888; |
|
993 TBuf<20> stringval; |
|
994 r = repository->Get(KString1, stringval); |
|
995 TEST2(r, KErrNone); |
|
996 r = repository->Set(KString1, stringval); |
|
997 TEST2(r, KErrNone); |
|
998 TEST(intStatus==7777); |
|
999 TEST(realStatus==8888); |
|
1000 TEST(stringStatus==KRequestPending); |
|
1001 TEST(thisThread.RequestCount()==0); |
|
1002 |
|
1003 _LIT(KStringValue2, "string2"); |
|
1004 r = repository->Set(KString1, KStringValue2); |
|
1005 TEST2(r, KErrNone); |
|
1006 User::WaitForAnyRequest(); |
|
1007 TEST(intStatus==7777); |
|
1008 TEST(realStatus==8888); |
|
1009 TEST(stringStatus==KString1); |
|
1010 |
|
1011 |
|
1012 // |
|
1013 // Cancelling single notifications |
|
1014 // |
|
1015 r = repository->NotifyRequest(KInt1, intStatus); |
|
1016 TEST2(r, KErrNone); |
|
1017 r = repository->NotifyCancel(KInt1); |
|
1018 TEST2(r, KErrNone); |
|
1019 User::WaitForAnyRequest(); |
|
1020 TEST(intStatus==KUnspecifiedKey); |
|
1021 |
|
1022 intStatus = 7777; |
|
1023 r = repository->NotifyRequest(KReal1, realStatus); |
|
1024 TEST2(r, KErrNone); |
|
1025 r = repository->Set(KInt1, 1); |
|
1026 TEST2(r, KErrNone); |
|
1027 r = repository->Set(KReal1, 1.1); |
|
1028 TEST2(r, KErrNone); |
|
1029 User::WaitForAnyRequest(); |
|
1030 TEST(intStatus==7777); |
|
1031 TEST(realStatus==KReal1); |
|
1032 TEST(thisThread.RequestCount()==0); |
|
1033 |
|
1034 |
|
1035 // |
|
1036 // Cancelling all notifications |
|
1037 // |
|
1038 realStatus = 8888; |
|
1039 r = repository->NotifyRequest(KInt1, intStatus); |
|
1040 TEST2(r, KErrNone); |
|
1041 r = repository->NotifyRequest(KReal1, realStatus); |
|
1042 TEST2(r, KErrNone); |
|
1043 |
|
1044 r = repository->NotifyCancelAll(); |
|
1045 TEST2(r, KErrNone); |
|
1046 User::WaitForAnyRequest(); |
|
1047 User::WaitForAnyRequest(); |
|
1048 TEST(intStatus==KUnspecifiedKey); |
|
1049 TEST(realStatus==KUnspecifiedKey); |
|
1050 |
|
1051 intStatus = 7777; |
|
1052 realStatus = 8888; |
|
1053 r = repository->Set(KInt1, 2); |
|
1054 TEST2(r, KErrNone); |
|
1055 r = repository->Set(KReal1, 2.2); |
|
1056 TEST2(r, KErrNone); |
|
1057 TEST(intStatus==7777); |
|
1058 TEST(realStatus==8888); |
|
1059 TEST(thisThread.RequestCount()==0); |
|
1060 |
|
1061 |
|
1062 // |
|
1063 // Group notifications |
|
1064 // |
|
1065 r = repository->NotifyRequest(0, ~(KInt1+KReal1), intStatus); |
|
1066 TEST2(r, KErrNone); |
|
1067 |
|
1068 r = repository->Set(KInt3, 3); |
|
1069 TEST2(r, KErrNone); |
|
1070 TEST(intStatus==KRequestPending); |
|
1071 TEST(thisThread.RequestCount()==0); |
|
1072 |
|
1073 r = repository->Set(KInt1, 3); |
|
1074 TEST2(r, KErrNone); |
|
1075 User::WaitForAnyRequest(); |
|
1076 TEST(intStatus==KInt1); |
|
1077 |
|
1078 r = repository->NotifyRequest(0, ~(KInt1+KReal1), intStatus); |
|
1079 TEST2(r, KErrNone); |
|
1080 |
|
1081 r = repository->Set(KReal1, 3.3); |
|
1082 TEST2(r, KErrNone); |
|
1083 User::WaitForAnyRequest(); |
|
1084 TEST(intStatus==KReal1); |
|
1085 |
|
1086 |
|
1087 // |
|
1088 // Cancelling group notifications |
|
1089 // |
|
1090 r = repository->NotifyRequest(0, ~(KInt1+KReal1), intStatus); |
|
1091 TEST2(r, KErrNone); |
|
1092 r = repository->NotifyCancel(0, ~(KInt1+KReal1)); |
|
1093 TEST2(r, KErrNone); |
|
1094 User::WaitForAnyRequest(); |
|
1095 TEST(intStatus==KUnspecifiedKey); |
|
1096 |
|
1097 r = repository->Set(KInt1, 3); |
|
1098 TEST2(r, KErrNone); |
|
1099 TEST(intStatus==KUnspecifiedKey); |
|
1100 TEST(thisThread.RequestCount()==0); |
|
1101 |
|
1102 r = repository->NotifyRequest(KInt1, intStatus); |
|
1103 TEST2(r, KErrNone); |
|
1104 r = repository->NotifyRequest(0, ~(KInt1+KReal1), realStatus); |
|
1105 TEST2(r, KErrNone); |
|
1106 r = repository->NotifyCancelAll(); |
|
1107 TEST2(r, KErrNone); |
|
1108 User::WaitForAnyRequest(); |
|
1109 User::WaitForAnyRequest(); |
|
1110 TEST(intStatus==KUnspecifiedKey); |
|
1111 TEST(realStatus==KUnspecifiedKey); |
|
1112 |
|
1113 r = repository->Set(KInt1, 4); |
|
1114 TEST2(r, KErrNone); |
|
1115 TEST(intStatus==KUnspecifiedKey); |
|
1116 TEST(realStatus==KUnspecifiedKey); |
|
1117 TEST(thisThread.RequestCount()==0); |
|
1118 |
|
1119 CleanupStack::PopAndDestroy(repository); |
|
1120 } |
|
1121 |
|
1122 /** |
|
1123 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-3400 |
|
1124 @SYMTestCaseDesc CRepository class functionality test |
|
1125 @SYMTestPriority High |
|
1126 @SYMTestActions Negative tests exercising CRepository::NotifyCancel() functions |
|
1127 Tests check that central repository notifier works properly when |
|
1128 client cancels multiple, non-existent notifications, and also |
|
1129 multiple and non-existent group notificatins in a variety of combinations. |
|
1130 @SYMTestExpectedResults There are 2 main points that we need to check in this test: |
|
1131 1) when we are cancelling multiple notifications server-side function should |
|
1132 always return KErrNone or KErrNotFound preventing client requests from waitng |
|
1133 indefinitely |
|
1134 2) IPC handling function should convert any error returned from the server |
|
1135 to KErrNone so that the client-side function NotifyCancel always returns KErrNone |
|
1136 (for more nformation on this requirement see DEF061504) |
|
1137 @SYMDEF INC102413 |
|
1138 */ |
|
1139 LOCAL_C void CancelNotificationsL() |
|
1140 { |
|
1141 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-3400 ")); |
|
1142 CRepository* repository; |
|
1143 User::LeaveIfNull(repository = CRepository::NewLC(KUidTestRepository1)); |
|
1144 |
|
1145 TInt r = KErrNone; |
|
1146 TRequestStatus intStatus; |
|
1147 TRequestStatus realStatus1; |
|
1148 TRequestStatus realStatus2; |
|
1149 TRequestStatus realStatus3; |
|
1150 RThread thisThread; |
|
1151 |
|
1152 // |
|
1153 // Cancelling non-existent notifications |
|
1154 // |
|
1155 r = repository->NotifyCancel(KInt1); |
|
1156 TEST2(r, KErrNone); |
|
1157 |
|
1158 // |
|
1159 // Cancelling multiple notifications |
|
1160 // This test step checks that NotifyCancel function returns correct |
|
1161 // value KErrNone regardless of the number of registered notifiers |
|
1162 // |
|
1163 r = repository->NotifyRequest(KReal1, realStatus1); |
|
1164 TEST2(r, KErrNone); |
|
1165 r = repository->NotifyRequest(KReal2, realStatus2); |
|
1166 TEST2(r, KErrNone); |
|
1167 r = repository->NotifyRequest(KReal3, realStatus3); |
|
1168 TEST2(r, KErrNone); |
|
1169 |
|
1170 r = repository->NotifyCancel(KReal3); |
|
1171 TEST2(r, KErrNone); |
|
1172 r = repository->NotifyCancel(KReal2); |
|
1173 TEST2(r, KErrNone); |
|
1174 r = repository->NotifyCancel(KReal1); |
|
1175 TEST2(r, KErrNone); |
|
1176 TEST2(thisThread.RequestCount(),3); |
|
1177 User::WaitForAnyRequest(); |
|
1178 TEST(realStatus3==KUnspecifiedKey); |
|
1179 User::WaitForAnyRequest(); |
|
1180 TEST(realStatus2==KUnspecifiedKey); |
|
1181 User::WaitForAnyRequest(); |
|
1182 TEST(realStatus1==KUnspecifiedKey); |
|
1183 TEST2(thisThread.RequestCount(),0); |
|
1184 |
|
1185 // check that all notificatioins were actually cancelled and we will not |
|
1186 // get a notification when we change the settings |
|
1187 realStatus1 = 7777; |
|
1188 realStatus2 = 8888; |
|
1189 realStatus3 = 9999; |
|
1190 r = repository->NotifyRequest(KInt1, intStatus); |
|
1191 TEST2(r, KErrNone); |
|
1192 r = repository->Set(KReal1, 1.0); |
|
1193 TEST2(r, KErrNone); |
|
1194 r = repository->Set(KReal2, 2.0); |
|
1195 TEST2(r, KErrNone); |
|
1196 r = repository->Set(KReal3, 3.0); |
|
1197 TEST2(r, KErrNone); |
|
1198 r = repository->Set(KInt1, 2); |
|
1199 TEST2(r, KErrNone); |
|
1200 User::WaitForAnyRequest(); |
|
1201 TEST(realStatus1==7777); |
|
1202 TEST(realStatus2==8888); |
|
1203 TEST(realStatus3==9999); |
|
1204 TEST(intStatus==KInt1); |
|
1205 TEST2(thisThread.RequestCount(),0); |
|
1206 |
|
1207 // |
|
1208 // Cancelling all notifications when no notifications exist |
|
1209 // |
|
1210 r = repository->NotifyCancelAll(); |
|
1211 TEST2(r, KErrNone); |
|
1212 |
|
1213 // |
|
1214 // Cancelling group notifications where some of the notifications have not been set up |
|
1215 // |
|
1216 //first make sure that all the settings exist |
|
1217 r = repository->Set(KReal1, 2.0); |
|
1218 r = repository->Set(KReal2, 3.0); |
|
1219 r = repository->Set(KReal3, 4.0); |
|
1220 //This mask notify request sets up notifies for a number of keys including KReal1 and KReal2 |
|
1221 r = repository->NotifyRequest(0, ~(KReal1+KReal2), realStatus1); |
|
1222 TEST2(r, KErrNone); |
|
1223 //This mask notify request cancels notifies for a number of keys including KReal1 and KReal3 |
|
1224 r = repository->NotifyCancel(0, ~(KReal1+KReal3)); |
|
1225 TEST2(r, KErrNone); |
|
1226 //check that notification request for the setting KReal1 has not been cancelled |
|
1227 r = repository->Set(KReal1, 1.0); |
|
1228 User::WaitForAnyRequest(); |
|
1229 TEST2(r, KErrNone); |
|
1230 TEST(realStatus1==KReal1); |
|
1231 |
|
1232 // |
|
1233 // Cancelling multiple group notifications |
|
1234 // |
|
1235 //set up notification requests for 2 different groups of settings and then cancel them |
|
1236 // one by one in the reverse order checking that we get an expected return value |
|
1237 //This mask notify request sets up notifies for a number of keys including KInt1 and KReal3 |
|
1238 r = repository->NotifyRequest(0, ~(KInt1+KReal3), realStatus1); |
|
1239 TEST2(r, KErrNone); |
|
1240 //This mask notify request sets up notifies for a number of keys including KReal1 and KReal2 |
|
1241 r = repository->NotifyRequest(0, ~(KReal1+KReal2), realStatus2); |
|
1242 TEST2(r, KErrNone); |
|
1243 |
|
1244 //This mask notify request cancels notifies for a number of keys including KReal1 and KReal2 |
|
1245 r = repository->NotifyCancel(0, ~(KReal1+KReal2)); |
|
1246 TEST2(r, KErrNone); |
|
1247 //This mask notify request cancels notifies for a number of keys including KInt1 and KReal3 |
|
1248 r = repository->NotifyCancel(0, ~(KInt1+KReal3)); |
|
1249 TEST2(r, KErrNone); |
|
1250 User::WaitForAnyRequest(); |
|
1251 User::WaitForAnyRequest(); |
|
1252 TEST(realStatus1==KUnspecifiedKey); |
|
1253 TEST(realStatus2==KUnspecifiedKey); |
|
1254 |
|
1255 // |
|
1256 // Cancelling non-existent group notifications |
|
1257 // |
|
1258 r = repository->NotifyCancel(0, ~(KInt1+KReal3)); |
|
1259 TEST2(r, KErrNone); |
|
1260 |
|
1261 //restore the repository value for the later tests to use |
|
1262 r = repository->Set(KInt1, 1); |
|
1263 TEST2(r, KErrNone); |
|
1264 |
|
1265 CleanupStack::PopAndDestroy(repository); |
|
1266 } |
|
1267 |
|
1268 /** |
|
1269 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-1301 |
|
1270 @SYMTestCaseDesc Tests for creation and deletion of new settings for CRepository class |
|
1271 @SYMTestPriority High |
|
1272 @SYMTestActions Test for CRepository::Create(),CRepository::Delete() functions |
|
1273 @SYMTestExpectedResults Test must not fail |
|
1274 @SYMREQ REQ0000 |
|
1275 */ |
|
1276 LOCAL_C void CreateDeleteL(const TUid& aUid) |
|
1277 { |
|
1278 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1301 ")); |
|
1279 CRepository* repository; |
|
1280 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1281 |
|
1282 TInt x; |
|
1283 TReal y; |
|
1284 TBuf8<20> z8; |
|
1285 TBuf16<20> z16; |
|
1286 |
|
1287 /***************************************************************************************/ |
|
1288 //test int create |
|
1289 /***************************************************************************************/ |
|
1290 TInt r = repository->Get(KNewInt, x); |
|
1291 TEST2(r, KErrNotFound); |
|
1292 |
|
1293 const TInt KIntValue = 1234; |
|
1294 r = repository->Create(KNewInt, KIntValue); |
|
1295 TEST2(r, KErrNone); |
|
1296 |
|
1297 //close and reopen rep to check create is persisted |
|
1298 CleanupStack::PopAndDestroy(repository); |
|
1299 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1300 |
|
1301 r = repository->Get(KNewInt, x); |
|
1302 TEST2(r, KErrNone); |
|
1303 TEST(x==KIntValue); |
|
1304 |
|
1305 r = repository->Delete(KNewInt); |
|
1306 TEST2(r, KErrNone); |
|
1307 |
|
1308 r = repository->Get(KNewInt, x); |
|
1309 TEST2(r, KErrNotFound); |
|
1310 |
|
1311 // close and reopen rep to check delete is persisted |
|
1312 CleanupStack::PopAndDestroy(repository); |
|
1313 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1314 r = repository->Get(KNewInt, x); |
|
1315 TEST2(r, KErrNotFound); |
|
1316 |
|
1317 |
|
1318 // test int create - second run |
|
1319 r = repository->Create(KNewInt, KIntValue); |
|
1320 TEST2(r, KErrNone); |
|
1321 |
|
1322 //close and reopen rep to check create is persisted |
|
1323 CleanupStack::PopAndDestroy(repository); |
|
1324 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1325 |
|
1326 r = repository->Get(KNewInt, x); |
|
1327 TEST2(r, KErrNone); |
|
1328 TEST(x==KIntValue); |
|
1329 |
|
1330 r = repository->Delete(KNewInt); |
|
1331 TEST2(r, KErrNone); |
|
1332 |
|
1333 // close and reopen rep to check delete is persisted |
|
1334 CleanupStack::PopAndDestroy(repository); |
|
1335 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1336 |
|
1337 r = repository->Get(KNewInt, x); |
|
1338 TEST2(r, KErrNotFound); |
|
1339 |
|
1340 |
|
1341 /***************************************************************************************/ |
|
1342 //test real create |
|
1343 /***************************************************************************************/ |
|
1344 |
|
1345 r = repository->Get(KNewReal, y); |
|
1346 TEST2(r, KErrNotFound); |
|
1347 |
|
1348 const TReal KRealValue = 5678.0; |
|
1349 r = repository->Create(KNewReal, KRealValue); |
|
1350 TEST2(r, KErrNone); |
|
1351 |
|
1352 //close and reopen rep to check create is persisted |
|
1353 CleanupStack::PopAndDestroy(repository); |
|
1354 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1355 |
|
1356 r = repository->Get(KNewReal, y); |
|
1357 TEST2(r, KErrNone); |
|
1358 TEST(y==KRealValue); |
|
1359 |
|
1360 r = repository->Delete(KNewReal); |
|
1361 TEST2(r, KErrNone); |
|
1362 |
|
1363 // close and reopen rep to check delete is persisted |
|
1364 CleanupStack::PopAndDestroy(repository); |
|
1365 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1366 |
|
1367 r = repository->Get(KNewReal, y); |
|
1368 TEST2(r, KErrNotFound); |
|
1369 |
|
1370 //create real - second run |
|
1371 r = repository->Create(KNewReal, KRealValue); |
|
1372 TEST2(r, KErrNone); |
|
1373 |
|
1374 //close and reopen rep to check create is persisted |
|
1375 CleanupStack::PopAndDestroy(repository); |
|
1376 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1377 |
|
1378 r = repository->Get(KNewReal, y); |
|
1379 TEST2(r, KErrNone); |
|
1380 TEST(y==KRealValue); |
|
1381 |
|
1382 r = repository->Delete(KNewReal); |
|
1383 TEST2(r, KErrNone); |
|
1384 |
|
1385 // close and reopen rep to check delete is persisted |
|
1386 CleanupStack::PopAndDestroy(repository); |
|
1387 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1388 |
|
1389 r = repository->Get(KNewReal, x); |
|
1390 TEST2(r, KErrNotFound); |
|
1391 |
|
1392 /***************************************************************************************/ |
|
1393 //test string8 create |
|
1394 /***************************************************************************************/ |
|
1395 |
|
1396 r = repository->Get(KNewString8, z8); |
|
1397 TEST2(r, KErrNotFound); |
|
1398 |
|
1399 _LIT8(KString8Value, "ABCDEF"); |
|
1400 r = repository->Create(KNewString8, KString8Value); |
|
1401 TEST2(r, KErrNone); |
|
1402 |
|
1403 //close and reopen rep to check create is persisted |
|
1404 CleanupStack::PopAndDestroy(repository); |
|
1405 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1406 |
|
1407 r = repository->Get(KNewString8, z8); |
|
1408 TEST2(r, KErrNone); |
|
1409 TEST(z8==KString8Value); |
|
1410 |
|
1411 r = repository->Delete(KNewString8); |
|
1412 TEST2(r, KErrNone); |
|
1413 |
|
1414 // close and reopen rep to check delete is persisted |
|
1415 CleanupStack::PopAndDestroy(repository); |
|
1416 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1417 |
|
1418 r = repository->Get(KNewString8, z8); |
|
1419 TEST2(r, KErrNotFound); |
|
1420 |
|
1421 r = repository->Create(KNewString8, KString8Value); |
|
1422 TEST2(r, KErrNone); |
|
1423 |
|
1424 //close and reopen rep to check create is persisted |
|
1425 CleanupStack::PopAndDestroy(repository); |
|
1426 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1427 |
|
1428 r = repository->Get(KNewString8, z8); |
|
1429 TEST2(r, KErrNone); |
|
1430 TEST(z8==KString8Value); |
|
1431 |
|
1432 r = repository->Delete(KNewString8); |
|
1433 TEST2(r, KErrNone); |
|
1434 |
|
1435 // close and reopen rep to check delete is persisted |
|
1436 CleanupStack::PopAndDestroy(repository); |
|
1437 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1438 |
|
1439 //second run |
|
1440 r = repository->Get(KNewString8, x); |
|
1441 TEST2(r, KErrNotFound); |
|
1442 |
|
1443 /***************************************************************************************/ |
|
1444 //test string16 create |
|
1445 /***************************************************************************************/ |
|
1446 |
|
1447 r = repository->Get(KNewString16, z16); |
|
1448 TEST2(r, KErrNotFound); |
|
1449 |
|
1450 _LIT(KString16Value, "ghijklmn"); |
|
1451 r = repository->Create(KNewString16, KString16Value); |
|
1452 TEST2(r, KErrNone); |
|
1453 |
|
1454 //close and reopen rep to check create is persisted |
|
1455 CleanupStack::PopAndDestroy(repository); |
|
1456 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1457 |
|
1458 r = repository->Get(KNewString16, z16); |
|
1459 TEST2(r, KErrNone); |
|
1460 TEST(z16==KString16Value); |
|
1461 |
|
1462 r = repository->Delete(KNewString16); |
|
1463 TEST2(r, KErrNone); |
|
1464 |
|
1465 // close and reopen rep to check delete is persisted |
|
1466 CleanupStack::PopAndDestroy(repository); |
|
1467 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1468 |
|
1469 r = repository->Get(KNewString16, z16); |
|
1470 TEST2(r, KErrNotFound); |
|
1471 |
|
1472 r = repository->Create(KNewString16, KString16Value); |
|
1473 TEST2(r, KErrNone); |
|
1474 |
|
1475 //close and reopen rep to check create is persisted |
|
1476 CleanupStack::PopAndDestroy(repository); |
|
1477 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1478 |
|
1479 r = repository->Get(KNewString16, z16); |
|
1480 TEST2(r, KErrNone); |
|
1481 TEST(z16==KString16Value); |
|
1482 |
|
1483 r = repository->Delete(KNewString16); |
|
1484 TEST2(r, KErrNone); |
|
1485 |
|
1486 CleanupStack::PopAndDestroy(repository); |
|
1487 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1488 |
|
1489 r = repository->Get(KNewString16, x); |
|
1490 TEST2(r, KErrNotFound); |
|
1491 |
|
1492 CleanupStack::PopAndDestroy(repository); |
|
1493 |
|
1494 /***************************************************************************************/ |
|
1495 //test create all kinds and delete with mask |
|
1496 /***************************************************************************************/ |
|
1497 |
|
1498 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1499 |
|
1500 //first check that none of the settings exist in the repository |
|
1501 r = repository->Get(KNewSetting1, x); |
|
1502 TEST2(r, KErrNotFound); |
|
1503 |
|
1504 r = repository->Get(KNewSetting2, y); |
|
1505 TEST2(r, KErrNotFound); |
|
1506 |
|
1507 r = repository->Get(KNewSetting3, z8); |
|
1508 TEST2(r, KErrNotFound); |
|
1509 |
|
1510 r = repository->Get(KNewSetting4, z16); |
|
1511 TEST2(r, KErrNotFound); |
|
1512 |
|
1513 r = repository->Get(KNewSetting5, x); |
|
1514 TEST2(r, KErrNotFound); |
|
1515 |
|
1516 r = repository->Get(KNewSetting6, y); |
|
1517 TEST2(r, KErrNotFound); |
|
1518 |
|
1519 r = repository->Get(KNewSetting7, z8); |
|
1520 TEST2(r, KErrNotFound); |
|
1521 |
|
1522 r = repository->Get(KNewSetting8, z16); |
|
1523 TEST2(r, KErrNotFound); |
|
1524 |
|
1525 //now create all of the new settings |
|
1526 x = KNewSetting1Value; |
|
1527 r = repository->Create(KNewSetting1, x); |
|
1528 TEST2(r, KErrNone); |
|
1529 |
|
1530 r = repository->Create(KNewSetting2, KNewSetting2Value); |
|
1531 TEST2(r, KErrNone); |
|
1532 |
|
1533 r = repository->Create(KNewSetting3, KNewSetting3Value); |
|
1534 TEST2(r, KErrNone); |
|
1535 |
|
1536 r = repository->Create(KNewSetting4, KNewSetting4Value); |
|
1537 TEST2(r, KErrNone); |
|
1538 |
|
1539 x = KNewSetting5Value; |
|
1540 r = repository->Create(KNewSetting5, x); |
|
1541 TEST2(r, KErrNone); |
|
1542 |
|
1543 r = repository->Create(KNewSetting6, KNewSetting6Value); |
|
1544 TEST2(r, KErrNone); |
|
1545 |
|
1546 r = repository->Create(KNewSetting7, KNewSetting7Value); |
|
1547 TEST2(r, KErrNone); |
|
1548 |
|
1549 r = repository->Create(KNewSetting8, KNewSetting8Value); |
|
1550 TEST2(r, KErrNone); |
|
1551 |
|
1552 //close and reopen rep to check create is persisted |
|
1553 CleanupStack::PopAndDestroy(repository); |
|
1554 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1555 |
|
1556 //check that the new settings exist in the repository |
|
1557 r = repository->Get(KNewSetting1, x); |
|
1558 TEST(x == KNewSetting1Value); |
|
1559 TEST2(r, KErrNone); |
|
1560 |
|
1561 r = repository->Get(KNewSetting2, y); |
|
1562 TEST(y == KNewSetting2Value); |
|
1563 TEST2(r, KErrNone); |
|
1564 |
|
1565 r = repository->Get(KNewSetting3, z16); |
|
1566 TEST(z16 == KNewSetting3Value); |
|
1567 TEST2(r, KErrNone); |
|
1568 |
|
1569 r = repository->Get(KNewSetting4, z8); |
|
1570 TEST(z8 == KNewSetting4Value); |
|
1571 TEST2(r, KErrNone); |
|
1572 |
|
1573 r = repository->Get(KNewSetting5, x); |
|
1574 TEST(x == KNewSetting5Value); |
|
1575 TEST2(r, KErrNone); |
|
1576 |
|
1577 r = repository->Get(KNewSetting6, y); |
|
1578 TEST(y == KNewSetting6Value); |
|
1579 TEST2(r, KErrNone); |
|
1580 |
|
1581 r = repository->Get(KNewSetting7, z16); |
|
1582 TEST(z16 == KNewSetting7Value); |
|
1583 TEST2(r, KErrNone); |
|
1584 |
|
1585 r = repository->Get(KNewSetting8, z8); |
|
1586 TEST(z8 == KNewSetting8Value); |
|
1587 TEST2(r, KErrNone); |
|
1588 |
|
1589 // delete the settings |
|
1590 TUint32 errorKey = 0; |
|
1591 r = repository->Delete(0x00002000, 0xFFFFFF00, errorKey); |
|
1592 TEST2(errorKey, KUnspecifiedKey); |
|
1593 TEST2(r, KErrNone); |
|
1594 |
|
1595 // close and reopen rep to check delete is persisted |
|
1596 CleanupStack::PopAndDestroy(repository); |
|
1597 User::LeaveIfNull(repository = CRepository::NewLC(aUid)); |
|
1598 |
|
1599 //check that none of the settings exist in the repository |
|
1600 r = repository->Get(KNewSetting1, x); |
|
1601 TEST2(r, KErrNotFound); |
|
1602 |
|
1603 r = repository->Get(KNewSetting2, y); |
|
1604 TEST2(r, KErrNotFound); |
|
1605 |
|
1606 r = repository->Get(KNewSetting3, z16); |
|
1607 TEST2(r, KErrNotFound); |
|
1608 |
|
1609 r = repository->Get(KNewSetting4, z8); |
|
1610 TEST2(r, KErrNotFound); |
|
1611 |
|
1612 r = repository->Get(KNewSetting5, x); |
|
1613 TEST2(r, KErrNotFound); |
|
1614 |
|
1615 r = repository->Get(KNewSetting6, y); |
|
1616 TEST2(r, KErrNotFound); |
|
1617 |
|
1618 r = repository->Get(KNewSetting7, z16); |
|
1619 TEST2(r, KErrNotFound); |
|
1620 |
|
1621 r = repository->Get(KNewSetting8, z8); |
|
1622 TEST2(r, KErrNotFound); |
|
1623 |
|
1624 CleanupStack::PopAndDestroy(repository); |
|
1625 } |
|
1626 |
|
1627 /** |
|
1628 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-1302 |
|
1629 @SYMTestCaseDesc Multi client test |
|
1630 @SYMTestPriority High |
|
1631 @SYMTestActions Tests for CRepository::Get(),CRepository::Set() functions |
|
1632 @SYMTestExpectedResults Test must not fail |
|
1633 @SYMREQ REQ0000 |
|
1634 */ |
|
1635 LOCAL_C void MultiClientL() |
|
1636 { |
|
1637 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1302 ")); |
|
1638 CRepository* repository1; |
|
1639 User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1)); |
|
1640 CRepository* repository2; |
|
1641 User::LeaveIfNull(repository2 = CRepository::NewLC(KUidTestRepository1)); |
|
1642 |
|
1643 // |
|
1644 // Get/Set |
|
1645 // |
|
1646 TInt i; |
|
1647 TInt r = repository1->Set(KInt1, 0); |
|
1648 TEST2(r, KErrNone); |
|
1649 r = repository2->Get(KInt1, i); |
|
1650 TEST2(r, KErrNone); |
|
1651 TEST(i==0); |
|
1652 |
|
1653 r = repository2->Set(KInt1, 123); |
|
1654 TEST2(r, KErrNone); |
|
1655 r = repository1->Get(KInt1, i); |
|
1656 TEST2(r, KErrNone); |
|
1657 TEST(i==123); |
|
1658 |
|
1659 // |
|
1660 // Notification |
|
1661 // |
|
1662 TRequestStatus status; |
|
1663 r = repository1->NotifyRequest(KInt1, status); |
|
1664 TEST2(r, KErrNone); |
|
1665 |
|
1666 r = repository2->Set(KInt1, 0); |
|
1667 TEST2(r, KErrNone); |
|
1668 User::WaitForAnyRequest(); |
|
1669 TEST(status==KInt1); |
|
1670 |
|
1671 CleanupStack::PopAndDestroy(2); |
|
1672 } |
|
1673 |
|
1674 /** |
|
1675 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-1303 |
|
1676 @SYMTestCaseDesc Tests for resetting the new changes on CRepository |
|
1677 @SYMTestPriority High |
|
1678 @SYMTestActions Tests for CRepository::Reset() function |
|
1679 Tests for reset on a single setting that exists in the original ROM-based settings. |
|
1680 Tests for reset for a single setting that does not exist in the original ROM-based settings. |
|
1681 Tests for repository-wide reset for a repository that exists on ROM. |
|
1682 Tests for repository-wide reset for a repository that does not exist on ROM. |
|
1683 @SYMTestExpectedResults Test must not fail |
|
1684 @SYMREQ REQ0000 |
|
1685 */ |
|
1686 LOCAL_C void ResetL() |
|
1687 { |
|
1688 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1303 ")); |
|
1689 CRepository* repositoryA; |
|
1690 User::LeaveIfNull(repositoryA = CRepository::NewLC(KUidTestRepository1)); |
|
1691 |
|
1692 // |
|
1693 // Test reset on a single setting that exists in the |
|
1694 // original ROM-based settings (we'll use KInt1) |
|
1695 // |
|
1696 |
|
1697 // Ensure KInt1 is set to a different value to its initial value |
|
1698 TInt r = repositoryA->Set(KInt1, KInt1_InitialValue+10); |
|
1699 TEST2(r, KErrNone); |
|
1700 |
|
1701 // We're testing we get a notification on a reset as well |
|
1702 TRequestStatus s; |
|
1703 r = repositoryA->NotifyRequest(KInt1, s); |
|
1704 TEST2(r, KErrNone); |
|
1705 |
|
1706 r = repositoryA->Reset(KInt1); |
|
1707 TEST2(r, KErrNone); |
|
1708 |
|
1709 // Check we got a notifiation |
|
1710 RThread thisThread; |
|
1711 |
|
1712 TEST2(thisThread.RequestCount(), 1); |
|
1713 User::WaitForAnyRequest(); |
|
1714 TEST(s==KInt1); |
|
1715 |
|
1716 // Check KInt1 now has the right value |
|
1717 TInt x; |
|
1718 r = repositoryA->Get(KInt1, x); |
|
1719 TEST2(r, KErrNone); |
|
1720 TEST(x==KInt1_InitialValue); |
|
1721 |
|
1722 // A second reset should not generate notification |
|
1723 // as value has not changed |
|
1724 r = repositoryA->NotifyRequest(KInt1, s); |
|
1725 TEST2(r, KErrNone); |
|
1726 r = repositoryA->Reset(KInt1); |
|
1727 TEST2(r, KErrNone); |
|
1728 |
|
1729 // |
|
1730 // Test reset for a single setting that does not exist |
|
1731 // in the original ROM-based settings. |
|
1732 // |
|
1733 const TInt KIntValue = 1234; |
|
1734 r = repositoryA->Create(KNewInt, KIntValue); |
|
1735 TEST2(r, KErrNone); |
|
1736 |
|
1737 // We're testing we get a notification on a reset as well |
|
1738 r = repositoryA->NotifyRequest(KNewInt, s); |
|
1739 TEST2(r, KErrNone); |
|
1740 |
|
1741 r = repositoryA->Reset(KNewInt); |
|
1742 TEST2(r, KErrNone); |
|
1743 |
|
1744 // Check we got a notifiation |
|
1745 TEST2(thisThread.RequestCount(), 1); |
|
1746 User::WaitForAnyRequest(); |
|
1747 TEST(s==KNewInt); |
|
1748 |
|
1749 // Check KNewInt has been deleted |
|
1750 r = repositoryA->Get(KNewInt, x); |
|
1751 TEST2(r, KErrNotFound); |
|
1752 |
|
1753 CleanupStack::PopAndDestroy(repositoryA); |
|
1754 User::WaitForAnyRequest(); //cancellation of request |
|
1755 TEST2(thisThread.RequestCount(), 0); |
|
1756 |
|
1757 // |
|
1758 // Test reset for a single setting in a repository that |
|
1759 // does not exist on ROM. |
|
1760 // |
|
1761 const TInt KSettingKey = KNonExisitentSetting; |
|
1762 const TInt KInitialValue = 10; |
|
1763 |
|
1764 CRepository* repositoryB; |
|
1765 User::LeaveIfNull(repositoryB = CRepository::NewLC(KUidDriveCOnlyRepository)); |
|
1766 |
|
1767 r = repositoryB->Create(KSettingKey, KInitialValue); |
|
1768 TEST2(r, KErrNone); |
|
1769 |
|
1770 // We're testing we get a notification on a reset as well |
|
1771 r = repositoryB->NotifyRequest(KSettingKey, s); |
|
1772 TEST2(r, KErrNone); |
|
1773 |
|
1774 r = repositoryB->Reset(KSettingKey); |
|
1775 TEST2(r, KErrNone); |
|
1776 |
|
1777 // Check we got a notifiation |
|
1778 TEST2(thisThread.RequestCount(), 1); |
|
1779 User::WaitForAnyRequest(); |
|
1780 TEST(s==KSettingKey); |
|
1781 |
|
1782 // Check KSettingKey has been deleted |
|
1783 r = repositoryB->Get(KSettingKey, x); |
|
1784 TEST2(r, KErrNotFound); |
|
1785 |
|
1786 CleanupStack::PopAndDestroy(repositoryB); |
|
1787 // |
|
1788 // Test repository-wide reset for a repository |
|
1789 // that exists on ROM. |
|
1790 // |
|
1791 CRepository* repositoryC; |
|
1792 User::LeaveIfNull(repositoryC = CRepository::NewLC(KUidResetTestRepository)); |
|
1793 |
|
1794 const TInt KNewSetting1 = 5; |
|
1795 const TInt KNewSetting2 = 6; |
|
1796 r = repositoryC->Create(KNewSetting1, 0); |
|
1797 TEST2(r, KErrNone); |
|
1798 r = repositoryC->Create(KNewSetting2, 0); |
|
1799 TEST2(r, KErrNone); |
|
1800 |
|
1801 r = repositoryC->Create(65, 1); |
|
1802 TEST2(r, KErrNone); |
|
1803 |
|
1804 r = repositoryC->Set(70, 1); |
|
1805 TEST2(r, KErrNone); |
|
1806 |
|
1807 r = repositoryC->Create(80, 1); |
|
1808 TEST2(r, KErrNone); |
|
1809 |
|
1810 r = repositoryC->Create(90, 1); |
|
1811 TEST2(r, KErrNone); |
|
1812 |
|
1813 r = repositoryC->NotifyRequest(0, 0, s); |
|
1814 TEST2(r, KErrNone); |
|
1815 |
|
1816 r = repositoryC->Reset(); |
|
1817 TEST2(r, KErrNone); |
|
1818 TEST(thisThread.RequestCount()==1); |
|
1819 User::WaitForAnyRequest(); |
|
1820 TEST(s==KUnspecifiedKey); |
|
1821 |
|
1822 r = repositoryC->Get(10, x); |
|
1823 TEST2(r, KErrNone); |
|
1824 TEST(x==10); |
|
1825 |
|
1826 r = repositoryC->Get(40, x); |
|
1827 TEST2(r, KErrNone); |
|
1828 TEST(x==0); |
|
1829 |
|
1830 r = repositoryC->Get(50, x); |
|
1831 TEST2(r, KErrNone); |
|
1832 TEST(x==0); |
|
1833 |
|
1834 r = repositoryC->Get(60, x); |
|
1835 TEST2(r, KErrNone); |
|
1836 TEST(x==0); |
|
1837 |
|
1838 r = repositoryC->Get(70, x); |
|
1839 TEST2(r, KErrNone); |
|
1840 TEST(x==0); |
|
1841 |
|
1842 TBuf<10> z; |
|
1843 r = repositoryC->Get(20, z); |
|
1844 TEST2(r, KErrNone); |
|
1845 TEST(z==_L("string")); |
|
1846 |
|
1847 TReal y; |
|
1848 r = repositoryC->Get(30, y); |
|
1849 TEST2(r, KErrNone); |
|
1850 TEST(y==1); |
|
1851 |
|
1852 r = repositoryC->Get(5, x); |
|
1853 TEST2(r, KErrNotFound); |
|
1854 r = repositoryC->Get(6, x); |
|
1855 TEST2(r, KErrNotFound); |
|
1856 r = repositoryC->Get(65, x); |
|
1857 TEST2(r, KErrNotFound); |
|
1858 r = repositoryC->Get(80, x); |
|
1859 TEST2(r, KErrNotFound); |
|
1860 r = repositoryC->Get(90, x); |
|
1861 TEST2(r, KErrNotFound); |
|
1862 |
|
1863 CleanupStack::PopAndDestroy(repositoryC); |
|
1864 |
|
1865 // |
|
1866 // Test repository-wide reset for a repository |
|
1867 // that does not exist on ROM. |
|
1868 // |
|
1869 CRepository* repositoryD; |
|
1870 User::LeaveIfNull(repositoryD = CRepository::NewLC(KUidDriveCOnlyRepository)); |
|
1871 |
|
1872 r = repositoryD->Create(KSettingKey, KInitialValue); |
|
1873 TEST2(r, KErrNone); |
|
1874 |
|
1875 // We're testing we get a notification on a reset as well |
|
1876 r = repositoryD->NotifyRequest(KSettingKey, s); |
|
1877 TEST2(r, KErrNone); |
|
1878 |
|
1879 r = repositoryD->Reset(); |
|
1880 TEST2(r, KErrNone); |
|
1881 |
|
1882 // Check we got a notifiation |
|
1883 TEST(thisThread.RequestCount()==1); |
|
1884 User::WaitForAnyRequest(); |
|
1885 TEST(s==KUnspecifiedKey); |
|
1886 |
|
1887 // Check KSettingKey has been deleted |
|
1888 r = repositoryD->Get(KSettingKey, x); |
|
1889 TEST2(r, KErrNotFound); |
|
1890 |
|
1891 // Recreate KSettingKey |
|
1892 r = repositoryD->Create(KSettingKey, 10); |
|
1893 TEST2(r, KErrNone); |
|
1894 |
|
1895 // Reset KSettingKey only |
|
1896 r = repositoryD->Reset(KSettingKey); |
|
1897 TEST2(r, KErrNone); |
|
1898 |
|
1899 // Check KSettingKey has been deleted |
|
1900 r = repositoryD->Get(KSettingKey, x); |
|
1901 TEST2(r, KErrNotFound); |
|
1902 |
|
1903 CleanupStack::PopAndDestroy(repositoryD); |
|
1904 } |
|
1905 |
|
1906 LOCAL_C void ResetCreL() |
|
1907 { |
|
1908 CRepository* repositoryA; |
|
1909 TInt r = KErrNone; |
|
1910 TRequestStatus s; |
|
1911 TInt x; |
|
1912 RThread thisThread; |
|
1913 |
|
1914 User::LeaveIfNull(repositoryA = CRepository::NewLC(KUidCreTestRepository1)); |
|
1915 |
|
1916 // test for .cre file |
|
1917 // Test reset on a single setting that exists in the |
|
1918 // original ROM-based settings (we'll use KInt1) |
|
1919 // |
|
1920 |
|
1921 // Ensure KInt1 is set to a different value to its initial value |
|
1922 r = repositoryA->Set(KInt1, KInt1_InitialValue+10); |
|
1923 TEST2(r, KErrNone); |
|
1924 |
|
1925 CleanupStack::PopAndDestroy(repositoryA); |
|
1926 User::LeaveIfNull(repositoryA = CRepository::NewLC(KUidCreTestRepository1)); |
|
1927 |
|
1928 // We're testing we get a notification on a reset as well |
|
1929 r = repositoryA->NotifyRequest(KInt1, s); |
|
1930 TEST2(r, KErrNone); |
|
1931 |
|
1932 r = repositoryA->Reset(KInt1); |
|
1933 TEST2(r, KErrNone); |
|
1934 |
|
1935 // Check we got a notifiation |
|
1936 TEST2(thisThread.RequestCount(), 1); |
|
1937 User::WaitForAnyRequest(); |
|
1938 TEST(s == KInt1); |
|
1939 |
|
1940 CleanupStack::PopAndDestroy(repositoryA); |
|
1941 User::LeaveIfNull(repositoryA = CRepository::NewLC(KUidCreTestRepository1)); |
|
1942 |
|
1943 // Check KInt1 now has the right value |
|
1944 r = repositoryA->Get(KInt1, x); |
|
1945 TEST2(r, KErrNone); |
|
1946 TEST2(x, KInt1_InitialValue); |
|
1947 |
|
1948 // A second reset should not generate notification |
|
1949 // as value has not changed |
|
1950 r = repositoryA->NotifyRequest(KInt1, s); |
|
1951 TEST2(r, KErrNone); |
|
1952 |
|
1953 r = repositoryA->Reset(KInt1); |
|
1954 TEST2(r, KErrNone); |
|
1955 TEST2(thisThread.RequestCount(), 0); |
|
1956 |
|
1957 CleanupStack::PopAndDestroy(repositoryA); |
|
1958 User::LeaveIfNull(repositoryA = CRepository::NewLC(KUidCreTestRepository1)); |
|
1959 // |
|
1960 // Test reset for a single setting that does not exist |
|
1961 // in the original ROM-based settings. |
|
1962 // |
|
1963 const TInt KIntValue = 1234; |
|
1964 r = repositoryA->Create(KNewInt, KIntValue); |
|
1965 TEST2(r, KErrNone); |
|
1966 |
|
1967 CleanupStack::PopAndDestroy(repositoryA); |
|
1968 User::WaitForAnyRequest();//this is the cancellation of last notify request |
|
1969 TEST2(thisThread.RequestCount(), 0); |
|
1970 |
|
1971 User::LeaveIfNull(repositoryA = CRepository::NewLC(KUidCreTestRepository1)); |
|
1972 |
|
1973 // We're testing we get a notification on a reset as well |
|
1974 r = repositoryA->NotifyRequest(KNewInt, s); |
|
1975 TEST2(r, KErrNone); |
|
1976 |
|
1977 r = repositoryA->Reset(KNewInt); |
|
1978 TEST2(r, KErrNone); |
|
1979 |
|
1980 // Check we got a notifiation |
|
1981 TEST2(thisThread.RequestCount(), 1); |
|
1982 User::WaitForAnyRequest(); |
|
1983 TEST(s == KNewInt); |
|
1984 |
|
1985 CleanupStack::PopAndDestroy(repositoryA); |
|
1986 User::LeaveIfNull(repositoryA = CRepository::NewLC(KUidCreTestRepository1)); |
|
1987 |
|
1988 // Check KNewInt has been deleted |
|
1989 r = repositoryA->Get(KNewInt, x); |
|
1990 TEST2(r, KErrNotFound); |
|
1991 |
|
1992 CleanupStack::PopAndDestroy(repositoryA); |
|
1993 User::LeaveIfNull(repositoryA = CRepository::NewLC(KUidCreTestRepository1)); |
|
1994 |
|
1995 // Reset entire repository |
|
1996 r = repositoryA->Reset(); |
|
1997 TEST2(r, KErrNone); |
|
1998 |
|
1999 CleanupStack::PopAndDestroy(repositoryA); |
|
2000 } |
|
2001 |
|
2002 /** |
|
2003 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-1304 |
|
2004 @SYMTestCaseDesc Tests for initialising file searching |
|
2005 @SYMTestPriority High |
|
2006 @SYMTestActions Tests for CRepository::Get() function |
|
2007 @SYMTestExpectedResults Test must not fail |
|
2008 @SYMREQ REQ0000 |
|
2009 */ |
|
2010 LOCAL_C void IniFileSearching() |
|
2011 { |
|
2012 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1304 ")); |
|
2013 const TInt KSettingKey = 1; |
|
2014 |
|
2015 _LIT(KDriveZ, "drive z"); |
|
2016 |
|
2017 const TInt KBufLen = 7; // = Max of 3 above string lengths |
|
2018 |
|
2019 // |
|
2020 // File on drive C should take precedence |
|
2021 // |
|
2022 CRepository* repository = CRepository::NewL(KUidDriveCRepository); |
|
2023 |
|
2024 TBuf<KBufLen> str; |
|
2025 TInt r = repository->Get(KSettingKey, str); |
|
2026 TEST2(r, KErrNone); |
|
2027 TEST(str==KDriveZ); |
|
2028 |
|
2029 delete repository; |
|
2030 } |
|
2031 |
|
2032 /** |
|
2033 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-1305 |
|
2034 @SYMTestCaseDesc Tests for creating new repository on drive C: |
|
2035 @SYMTestPriority High |
|
2036 @SYMTestActions Tests for CRepository::NewL() function |
|
2037 @SYMTestExpectedResults Test must not fail |
|
2038 @SYMREQ REQ0000 |
|
2039 */ |
|
2040 LOCAL_C void RepositoryOnDriveC() |
|
2041 { |
|
2042 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1305 ")); |
|
2043 const TInt KSettingKey = KNonExisitentSetting; |
|
2044 const TInt KInitialValue = 10; |
|
2045 |
|
2046 CRepository* repository = CRepository::NewL(KUidDriveCOnlyRepository); |
|
2047 CleanupStack::PushL(repository); |
|
2048 |
|
2049 TInt val; |
|
2050 TInt r = repository->Get(KSettingKey, val); |
|
2051 TEST2(r, KErrNotFound); |
|
2052 |
|
2053 r = repository->Create(KSettingKey, KInitialValue); |
|
2054 TEST2(r, KErrNone); |
|
2055 |
|
2056 r = repository->Get(KSettingKey, val); |
|
2057 TEST2(r, KErrNone); |
|
2058 TEST(val==KInitialValue); |
|
2059 |
|
2060 CleanupStack::PopAndDestroy(repository); |
|
2061 repository = CRepository::NewL(KUidDriveCOnlyRepository); |
|
2062 CleanupStack::PushL(repository); |
|
2063 |
|
2064 r = repository->Get(KSettingKey, val); |
|
2065 TEST2(r, KErrNone); |
|
2066 TEST(val==KInitialValue); |
|
2067 |
|
2068 r = repository->Set(KSettingKey, KInitialValue+1); |
|
2069 TEST2(r, KErrNone); |
|
2070 |
|
2071 r = repository->Get(KSettingKey, val); |
|
2072 TEST2(r, KErrNone); |
|
2073 TEST(val==KInitialValue+1); |
|
2074 |
|
2075 r = repository->Delete(KSettingKey); |
|
2076 TEST2(r, KErrNone); |
|
2077 |
|
2078 CleanupStack::PopAndDestroy(repository); |
|
2079 repository = CRepository::NewL(KUidDriveCOnlyRepository); |
|
2080 CleanupStack::PushL(repository); |
|
2081 |
|
2082 r = repository->Get(KSettingKey, val); |
|
2083 TEST2(r, KErrNotFound); |
|
2084 |
|
2085 CleanupStack::PopAndDestroy(repository); |
|
2086 } |
|
2087 |
|
2088 /** |
|
2089 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-1656 |
|
2090 @SYMTestCaseDesc Notify-only client optimization test |
|
2091 @SYMTestPriority High |
|
2092 @SYMTestActions Tests for on-demand loading in API calls after in-session |
|
2093 unloading of repositories. Also tests for notification functionality. |
|
2094 @SYMTestExpectedResults Test must not fail |
|
2095 @SYMPREQ PREQ1228 |
|
2096 */ |
|
2097 LOCAL_C void NotifyOnlyL() |
|
2098 { |
|
2099 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-1656 ")); |
|
2100 CRepository* repository1; |
|
2101 User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1)); |
|
2102 |
|
2103 // check that functions work |
|
2104 TInt i; |
|
2105 TInt r = repository1->Get(KInt1, i); |
|
2106 TEST2(r, KErrNone); |
|
2107 TEST(i==1); |
|
2108 |
|
2109 CleanupStack::PopAndDestroy(); |
|
2110 // Kill the server to force clearing the cache |
|
2111 KillCentRepServerL(); |
|
2112 User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1)); |
|
2113 |
|
2114 r = repository1->Set(KInt1, i); |
|
2115 TEST2(r, KErrNone); |
|
2116 |
|
2117 CleanupStack::PopAndDestroy(); |
|
2118 // Kill the server to force clearing the cache |
|
2119 KillCentRepServerL(); |
|
2120 User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1)); |
|
2121 |
|
2122 const TInt KIntValue = 1234; |
|
2123 r = repository1->Create(KNewInt, KIntValue); |
|
2124 TEST2(r, KErrNone); |
|
2125 |
|
2126 CleanupStack::PopAndDestroy(); |
|
2127 // Kill the server to force clearing the cache |
|
2128 KillCentRepServerL(); |
|
2129 User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1)); |
|
2130 |
|
2131 RArray<TUint32> foundIds; |
|
2132 TInt leaveCode = KErrNone; |
|
2133 TRAP(leaveCode, r= repository1->FindEqL(0, 0, KIntValue, foundIds)); |
|
2134 if (leaveCode != KErrNone) |
|
2135 r = leaveCode ; |
|
2136 if(OomTesting && r==KErrNoMemory) |
|
2137 { |
|
2138 foundIds.Close(); |
|
2139 User::Leave(KErrNoMemory); |
|
2140 } |
|
2141 TEST2(r, KErrNone); |
|
2142 TEST(foundIds.Count()==1); |
|
2143 TEST(foundIds[0]==KNewInt); |
|
2144 foundIds.Reset(); |
|
2145 |
|
2146 CleanupStack::PopAndDestroy(); |
|
2147 // Kill the server to force clearing the cache |
|
2148 KillCentRepServerL(); |
|
2149 User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1)); |
|
2150 |
|
2151 r = repository1->Delete(KNewInt); |
|
2152 TEST2(r, KErrNone); |
|
2153 |
|
2154 CleanupStack::PopAndDestroy(); |
|
2155 |
|
2156 // check that multiple clients work |
|
2157 User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1)); |
|
2158 |
|
2159 r = repository1->Get(KInt1, i); |
|
2160 TEST2(r, KErrNone); |
|
2161 TEST(i==1); |
|
2162 |
|
2163 CleanupStack::PopAndDestroy(); |
|
2164 // Kill the server to force clearing the cache |
|
2165 KillCentRepServerL(); |
|
2166 User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1)); |
|
2167 |
|
2168 CRepository* repository2; |
|
2169 User::LeaveIfNull(repository2 = CRepository::NewLC(KUidTestRepository1)); |
|
2170 |
|
2171 r = repository2->Get(KInt1, i); |
|
2172 TEST2(r, KErrNone); |
|
2173 TEST(i==1); |
|
2174 |
|
2175 r = repository1->Get(KInt1, i); |
|
2176 TEST2(r, KErrNone); |
|
2177 TEST(i==1); |
|
2178 |
|
2179 CleanupStack::PopAndDestroy(2); |
|
2180 |
|
2181 // check that notifications work |
|
2182 User::LeaveIfNull(repository1 = CRepository::NewLC(KUidTestRepository1)); |
|
2183 TRequestStatus status1; |
|
2184 r = repository1->NotifyRequest(KInt1, status1); |
|
2185 TEST2(r, KErrNone); |
|
2186 |
|
2187 User::LeaveIfNull(repository2 = CRepository::NewLC(KUidTestRepository1)); |
|
2188 r = repository2->Set(KInt1, 0); |
|
2189 TEST2(r, KErrNone); |
|
2190 User::WaitForAnyRequest(); |
|
2191 TEST(status1==KInt1); |
|
2192 |
|
2193 r = repository1->NotifyRequest(KInt1, status1); |
|
2194 TEST2(r, KErrNone); |
|
2195 |
|
2196 CleanupRepositoryCache(); |
|
2197 |
|
2198 r = repository2->Set(KInt1, 2); |
|
2199 TEST2(r, KErrNone); |
|
2200 User::WaitForAnyRequest(); |
|
2201 TEST(status1==KInt1); |
|
2202 |
|
2203 r = repository1->NotifyRequest(KInt1, status1); |
|
2204 TEST2(r, KErrNone); |
|
2205 |
|
2206 CRepository* repository3; |
|
2207 User::LeaveIfNull(repository3 = CRepository::NewLC(KUidTestRepository1)); |
|
2208 TRequestStatus status3; |
|
2209 r = repository3->NotifyRequest(KInt1, status3); |
|
2210 TEST2(r, KErrNone); |
|
2211 |
|
2212 r = repository2->Set(KInt1, 0); |
|
2213 TEST2(r, KErrNone); |
|
2214 User::WaitForAnyRequest(); |
|
2215 TEST(status1==KInt1); |
|
2216 TEST(status3==KInt1); |
|
2217 |
|
2218 r = repository1->NotifyRequest(KInt1, status1); |
|
2219 TEST2(r, KErrNone); |
|
2220 r = repository3->NotifyRequest(KInt1, status3); |
|
2221 TEST2(r, KErrNone); |
|
2222 |
|
2223 CleanupRepositoryCache(); |
|
2224 |
|
2225 r = repository2->Set(KInt1, 1); |
|
2226 TEST2(r, KErrNone); |
|
2227 User::WaitForAnyRequest(); |
|
2228 TEST(status1==KInt1); |
|
2229 TEST(status3==KInt1); |
|
2230 |
|
2231 CleanupStack::PopAndDestroy(3); |
|
2232 // Kill the server to force clearing the cache |
|
2233 KillCentRepServerL(); |
|
2234 User::LeaveIfNull(repository3 = CRepository::NewLC(KUidTestRepository1)); |
|
2235 |
|
2236 r = repository3->Get(KInt1, i); |
|
2237 TEST2(r, KErrNone); |
|
2238 TEST(i==1); |
|
2239 |
|
2240 CleanupStack::PopAndDestroy(); |
|
2241 } |
|
2242 /** |
|
2243 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-0494 |
|
2244 @SYMTestCaseDesc Tests the various functions on CentralRepository |
|
2245 @SYMTestPriority High |
|
2246 @SYMTestActions Tests the get/set,find,notify,create/delete, |
|
2247 file searching in repository,the repository on drive c only |
|
2248 Tests for multiple clients,for restoring factory settings. |
|
2249 @SYMTestExpectedResults Test must not fail |
|
2250 @SYMREQ REQ0000 |
|
2251 */ |
|
2252 LOCAL_C void FuncTestsL() |
|
2253 { |
|
2254 TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-0494 Open/Close repository ")); |
|
2255 OpenRepositoryL(); |
|
2256 |
|
2257 TheTest.Next(_L("Get/Set .ini")); |
|
2258 GetSetL(KUidTestRepository1); |
|
2259 |
|
2260 TheTest.Next(_L("Get/Set .cre")); |
|
2261 GetSetL(KUidCreTestRepository1); |
|
2262 |
|
2263 TheTest.Next(_L("Find")); |
|
2264 FindL(); |
|
2265 |
|
2266 TheTest.Next(_L("Notify")); |
|
2267 NotifyL(); |
|
2268 |
|
2269 TheTest.Next(_L("Create/Delete .ini")); |
|
2270 CreateDeleteL(KUidTestRepository1); |
|
2271 |
|
2272 TheTest.Next(_L("Create/Delete .cre")); |
|
2273 CreateDeleteL(KUidCreTestRepository1); |
|
2274 |
|
2275 TheTest.Next(_L("Initialisation file searching")); |
|
2276 IniFileSearching(); |
|
2277 |
|
2278 TheTest.Next(_L("Repository on Drive C only")); |
|
2279 RepositoryOnDriveC(); |
|
2280 |
|
2281 TheTest.Next(_L("Multiple clients")); |
|
2282 MultiClientL(); |
|
2283 |
|
2284 TheTest.Next(_L("Restore factory settings")); |
|
2285 ResetL(); |
|
2286 |
|
2287 TheTest.Next(_L("Restore factory settings from binary based rep")); |
|
2288 ResetCreL(); |
|
2289 |
|
2290 TheTest.Next(_L("Negative testing for the notification cancelling")); |
|
2291 CancelNotificationsL(); |
|
2292 |
|
2293 TheTest.Next(_L("Notify-only client optimizations")); |
|
2294 NotifyOnlyL(); |
|
2295 |
|
2296 TheTest.End(); |
|
2297 } |
|
2298 |
|
2299 /** |
|
2300 OomTest |
|
2301 Function to convert a test into an OOM test |
|
2302 |
|
2303 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-0495 |
|
2304 @SYMTestCaseDesc Out of memory test |
|
2305 @SYMTestPriority High |
|
2306 @SYMTestActions Tests for running out of memory |
|
2307 @SYMTestExpectedResults Test must not fail |
|
2308 @SYMREQ REQ0000 |
|
2309 */ |
|
2310 LOCAL_C void OomTest(void (*testFuncL)()) |
|
2311 { |
|
2312 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-0495 ")); |
|
2313 TInt error; |
|
2314 TInt count = 0; |
|
2315 |
|
2316 do |
|
2317 { |
|
2318 User::__DbgSetAllocFail(RHeap::EUser, RHeap::EFailNext, ++count); |
|
2319 User::__DbgMarkStart(RHeap::EUser); |
|
2320 |
|
2321 // find out the number of open handles |
|
2322 TInt startProcessHandleCount; |
|
2323 TInt startThreadHandleCount; |
|
2324 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
2325 |
|
2326 TRAP(error, (testFuncL)()); |
|
2327 |
|
2328 // check that no handles have leaked |
|
2329 TInt endProcessHandleCount; |
|
2330 TInt endThreadHandleCount; |
|
2331 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
2332 |
|
2333 TEST2(endProcessHandleCount, startProcessHandleCount); |
|
2334 TEST2(endThreadHandleCount, startThreadHandleCount); |
|
2335 |
|
2336 User::__DbgMarkEnd(RHeap::EUser, 0); |
|
2337 } while(error == KErrNoMemory); |
|
2338 |
|
2339 _LIT(KTestFailed, "Out of memory test failure on iteration %d\n"); |
|
2340 __ASSERT_ALWAYS(error==KErrNone, TheTest.Panic(error, KTestFailed, count)); |
|
2341 |
|
2342 User::__DbgSetAllocFail(RHeap::EUser, RHeap::ENone, 1); |
|
2343 } |
|
2344 |
|
2345 LOCAL_C void OomTestsL() |
|
2346 { |
|
2347 TheTest.Start(_L("Open/Close repository")); |
|
2348 OomTest(OpenRepositoryL); |
|
2349 |
|
2350 TheTest.Next(_L("GetSet for KUidTestRepository1")); |
|
2351 GetSetL(KUidTestRepository1); |
|
2352 TheTest.Next(_L("GetSet for KUidCreTestRepository1")); |
|
2353 GetSetL(KUidCreTestRepository1); |
|
2354 |
|
2355 TheTest.Next(_L("Find")); |
|
2356 OomTest(FindL); |
|
2357 |
|
2358 TheTest.End(); |
|
2359 } |
|
2360 |
|
2361 //This function tests the replacement of RFile with RFileBuf in CIniFileOut class (inifile.h) |
|
2362 //It shows that there is approx. 20% (LUBBOCK) performance boost when using simple "Set" |
|
2363 //operations. It may be even better when using "Commit" functionality. |
|
2364 static void PerformanceTestL() |
|
2365 { |
|
2366 CRepository* repository = CRepository::NewL(KUidDriveCOnlyRepository); |
|
2367 CleanupStack::PushL(repository); |
|
2368 //Test settings IDs |
|
2369 const TUint KIntId = 101; |
|
2370 const TUint KRealId = 102; |
|
2371 const TUint KDes16Id = 103; |
|
2372 const TUint KDes8Id = 104; |
|
2373 //Create test settings |
|
2374 TInt err = repository->Create(KIntId, 1); |
|
2375 TEST2(err, KErrNone); |
|
2376 err = repository->Create(KRealId, 1.1); |
|
2377 TEST2(err, KErrNone); |
|
2378 err = repository->Create(KDes16Id, _L16("DES16")); |
|
2379 TEST2(err, KErrNone); |
|
2380 err = repository->Create(KDes8Id, _L8("DES8")); |
|
2381 TEST2(err, KErrNone); |
|
2382 //Performance test |
|
2383 TBuf16<32> buf16; |
|
2384 TBuf8<32> buf8; |
|
2385 TUint timeStart = User::TickCount(); |
|
2386 for(TInt i=0;i<500;++i) |
|
2387 { |
|
2388 buf16.Zero(); |
|
2389 buf16.AppendNum(i); |
|
2390 buf8.Zero(); |
|
2391 buf8.AppendNum(i); |
|
2392 |
|
2393 TInt err = repository->Set(KIntId, i); |
|
2394 TEST2(err, KErrNone); |
|
2395 err = repository->Set(KRealId, (TReal)i); |
|
2396 TEST2(err, KErrNone); |
|
2397 err = repository->Set(KDes16Id, buf16); |
|
2398 TEST2(err, KErrNone); |
|
2399 err = repository->Set(KDes8Id, buf8); |
|
2400 TEST2(err, KErrNone); |
|
2401 } |
|
2402 TUint timeEnd = User::TickCount(); |
|
2403 CleanupStack::PopAndDestroy(repository); |
|
2404 TheTest.Printf(_L("\nPerformanceTestL - %d ticks\n"), timeEnd-timeStart); |
|
2405 } |
|
2406 |
|
2407 /** |
|
2408 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-0497 |
|
2409 @SYMTestCaseDesc CentralRepository functionality test |
|
2410 @SYMTestPriority High |
|
2411 @SYMTestActions Wrapper function calling up test functions |
|
2412 @SYMTestExpectedResults Test must not fail |
|
2413 @SYMREQ REQ0000 |
|
2414 */ |
|
2415 LOCAL_C void MainL() |
|
2416 { |
|
2417 TheTest.Start(_L(" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-0497 Functional tests ")); |
|
2418 OomTesting = EFalse; |
|
2419 // Existance of caching functionality invalidates some tests and |
|
2420 // makes them fail. So cleanup cace. |
|
2421 RestoreTestFilesL(); |
|
2422 FuncTestsL(); |
|
2423 |
|
2424 TheTest.Next(_L("Out-of-memory tests")); |
|
2425 OomTesting = ETrue; |
|
2426 //Reset the KUidTestRepository1 which was modified by the previous test |
|
2427 //and is used in the next test. |
|
2428 ResetTestRepositoryL(); |
|
2429 OomTestsL(); |
|
2430 |
|
2431 TheTest.Next(_L("Performance test")); |
|
2432 PerformanceTestL(); |
|
2433 |
|
2434 TheTest.Next(_L("Clean out C: files")); |
|
2435 CleanupCDriveL(); |
|
2436 |
|
2437 TheTest.End(); |
|
2438 TheTest.Close(); |
|
2439 } |
|
2440 |
|
2441 TInt E32Main() |
|
2442 { |
|
2443 __UHEAP_MARK; |
|
2444 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
2445 if(!cleanup) |
|
2446 return KErrNoMemory; |
|
2447 |
|
2448 TRAPD(err, MainL()); |
|
2449 if (err != KErrNone) |
|
2450 User::Panic(_L("Testing failed: "), err); |
|
2451 |
|
2452 delete cleanup; |
|
2453 __UHEAP_MARKEND; |
|
2454 |
|
2455 return 0; |
|
2456 } |