|
1 // Copyright (c) 2002-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 <s32file.h> |
|
17 #include <s32mem.h> |
|
18 #include <e32math.h> |
|
19 |
|
20 #include "TEST.H" |
|
21 #include <logview.h> |
|
22 |
|
23 #undef test //there is a "test" macro which hides "RTest test" declaration. |
|
24 |
|
25 #define UNUSED_VAR(a) a = a |
|
26 |
|
27 RTest test(_L("Log View Test Harness Number 1")); |
|
28 |
|
29 const TInt KTestLogNumberCharsToMatch = 9; // should be the same as KLogNumberCharsToMatch defined in LogServ\src\LOGFILTQ.CPP |
|
30 const TInt KTestEventNum = 10; |
|
31 const TUid KTestEventUid = {0x10005393}; |
|
32 const TLogDurationType KTestDurationType = 0x12; |
|
33 const TLogContactItemId KTestContact = 0x1234; |
|
34 _LIT(KTestEventDesc, "Test Event"); |
|
35 _LIT(KTestRemoteParty, "Test Remote Party"); |
|
36 _LIT(KTestDirection, "Test Direction"); |
|
37 _LIT(KTestStatus, "Test Status"); |
|
38 _LIT(KTestNumber, "Test Number"); |
|
39 _LIT(KThreadSemaphoreName, "T_VIEW1_TEST_CODE"); |
|
40 |
|
41 |
|
42 TBool TheMatchingIsEnabled = EFalse; |
|
43 |
|
44 #define TEST_LOG_UID KTestEventUid |
|
45 |
|
46 //View's DoCancel() test |
|
47 void DoViewCancelTestL(CTestActive& aActive, CLogViewEvent& aView) |
|
48 { |
|
49 //Call FirstL() and cancel the operation |
|
50 aActive.StartL(); |
|
51 (void)aView.FirstL(aActive.iStatus); |
|
52 aView.Cancel(); |
|
53 TEST(!aView.IsActive()); |
|
54 CActiveScheduler::Start(); |
|
55 TEST2(aActive.iStatus.Int(), KErrCancel); |
|
56 |
|
57 //Call FirstL(). View cursor positioned on the first record. |
|
58 aActive.StartL(); |
|
59 (void)aView.FirstL(aActive.iStatus); |
|
60 CActiveScheduler::Start(); |
|
61 TEST2(aActive.iStatus.Int(), KErrNone); |
|
62 |
|
63 //Call NextL() and cancel the operation |
|
64 aActive.StartL(); |
|
65 (void)aView.NextL(aActive.iStatus); |
|
66 aView.Cancel(); |
|
67 TEST(!aView.IsActive()); |
|
68 CActiveScheduler::Start(); |
|
69 TEST2(aActive.iStatus.Int(), KErrCancel); |
|
70 |
|
71 //Call LastL() and cancel the operation |
|
72 aActive.StartL(); |
|
73 (void)aView.LastL(aActive.iStatus); |
|
74 aView.Cancel(); |
|
75 TEST(!aView.IsActive()); |
|
76 CActiveScheduler::Start(); |
|
77 TEST2(aActive.iStatus.Int(), KErrCancel); |
|
78 |
|
79 //Call LastL(). View cursor positioned on the last record. |
|
80 aActive.StartL(); |
|
81 (void)aView.LastL(aActive.iStatus); |
|
82 CActiveScheduler::Start(); |
|
83 TEST2(aActive.iStatus.Int(), KErrNone); |
|
84 |
|
85 //Call PreviousL() and cancel the operation |
|
86 aActive.StartL(); |
|
87 (void)aView.PreviousL(aActive.iStatus); |
|
88 aView.Cancel(); |
|
89 TEST(!aView.IsActive()); |
|
90 CActiveScheduler::Start(); |
|
91 TEST2(aActive.iStatus.Int(), KErrCancel); |
|
92 } |
|
93 |
|
94 /** |
|
95 @SYMTestCaseID SYSLIB-LOGENG-CT-0851 |
|
96 @SYMTestCaseDesc Tests for adding event types to the log |
|
97 @SYMTestPriority High |
|
98 @SYMTestActions Tests for adding events,check event count,clearing all the events |
|
99 @SYMTestExpectedResults Test must not fail |
|
100 @SYMREQ REQ0000 |
|
101 */ |
|
102 LOCAL_C void TestEventViewL(CLogClient& aClient) |
|
103 { |
|
104 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0851 ")); |
|
105 CLogEvent* event = CLogEvent::NewL(); |
|
106 CleanupStack::PushL(event); |
|
107 event->SetEventType(KLogCallEventTypeUid); |
|
108 |
|
109 CTestActive* active = new(ELeave)CTestActive(); |
|
110 CleanupStack::PushL(active); |
|
111 |
|
112 TInt count; |
|
113 for(count = 0; count < KTestEventNum; count++) |
|
114 { |
|
115 active->StartL(); |
|
116 aClient.AddEvent(*event, active->iStatus); |
|
117 CActiveScheduler::Start(); |
|
118 TEST2(active->iStatus.Int(), KErrNone); |
|
119 } |
|
120 |
|
121 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); |
|
122 changeObs->SetActive(); |
|
123 |
|
124 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); |
|
125 CleanupStack::PushL(view); |
|
126 |
|
127 CLogFilter* filter = CLogFilter::NewL(); |
|
128 CleanupStack::PushL(filter); |
|
129 |
|
130 count = view->CountL(); |
|
131 TEST2(count, 0); |
|
132 TBool res = view->SetFilterL(*filter, active->iStatus); |
|
133 TEST(res); |
|
134 |
|
135 // Move forward |
|
136 count = KTestEventNum; |
|
137 do { |
|
138 active->StartL(); |
|
139 CActiveScheduler::Start(); |
|
140 TEST2(active->iStatus.Int(), KErrNone); |
|
141 |
|
142 const TInt viewCount = view->CountL(); |
|
143 TEST2(viewCount, KTestEventNum); |
|
144 const TLogId eventId = view->Event().Id(); |
|
145 TLogId id = --count; |
|
146 TEST2(eventId, id); |
|
147 } |
|
148 while(view->NextL(active->iStatus)); |
|
149 TEST2(count, 0); |
|
150 |
|
151 // Move back |
|
152 while(view->PreviousL(active->iStatus)) |
|
153 { |
|
154 active->StartL(); |
|
155 CActiveScheduler::Start(); |
|
156 TEST2(active->iStatus.Int(), KErrNone); |
|
157 |
|
158 TEST2(view->CountL(), KTestEventNum); |
|
159 TLogId id = ++count; |
|
160 TEST2(view->Event().Id(), id); |
|
161 } |
|
162 TEST(count == KTestEventNum - 1); |
|
163 |
|
164 active->StartL(); |
|
165 res = view->FirstL(active->iStatus); |
|
166 TEST(res); |
|
167 CActiveScheduler::Start(); |
|
168 TEST2(active->iStatus.Int(), KErrNone); |
|
169 |
|
170 active->StartL(); |
|
171 res = view->LastL(active->iStatus); |
|
172 TEST(res); |
|
173 CActiveScheduler::Start(); |
|
174 TEST2(active->iStatus.Int(), KErrNone); |
|
175 |
|
176 // Nothing has changed in the view yet |
|
177 TEST(!changeObs->HaveChanges()); |
|
178 |
|
179 DoViewCancelTestL(*active, *view); |
|
180 |
|
181 TTime now; |
|
182 now.UniversalTime(); |
|
183 now+=(TTimeIntervalDays) 1; |
|
184 |
|
185 // Clear all the events |
|
186 active->StartL(); |
|
187 aClient.ClearLog(now, active->iStatus); |
|
188 CActiveScheduler::Start(); |
|
189 TEST2(active->iStatus.Int(), KErrNone); |
|
190 |
|
191 res = view->SetFilterL(*filter, active->iStatus); |
|
192 TEST(!res); |
|
193 TEST2(view->CountL(), 0); |
|
194 res = view->FirstL(active->iStatus); |
|
195 TEST(!res); |
|
196 res = view->LastL(active->iStatus); |
|
197 TEST(!res); |
|
198 res = view->NextL(active->iStatus); |
|
199 TEST(!res); |
|
200 res = view->PreviousL(active->iStatus); |
|
201 TEST(!res); |
|
202 |
|
203 CleanupStack::PopAndDestroy(5, event); // filter, view, changeObs, active, event |
|
204 |
|
205 CLogSchedulerTimer* timer = CLogSchedulerTimer::NewLC(); |
|
206 timer->Wait(10 * 1000000); |
|
207 CleanupStack::PopAndDestroy(timer); |
|
208 } |
|
209 |
|
210 /** |
|
211 @SYMTestCaseID SYSLIB-LOGENG-CT-0852 |
|
212 @SYMTestCaseDesc Tests for adding event types to the filter list |
|
213 @SYMTestPriority High |
|
214 @SYMTestActions Set the configuration data of event type.Add the event type to the filter and |
|
215 compare the configuration data of event type and from filter view. |
|
216 @SYMTestExpectedResults Test must not fail |
|
217 @SYMREQ REQ0000 |
|
218 */ |
|
219 LOCAL_C void TestViewFilterL(CLogClient& aClient, CLogFilter& aFilter) |
|
220 { |
|
221 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0852 ")); |
|
222 CLogViewEvent* view = CLogViewEvent::NewL(aClient); |
|
223 CleanupStack::PushL(view); |
|
224 |
|
225 CLogEvent* event = CLogEvent::NewL(); |
|
226 CleanupStack::PushL(event); |
|
227 |
|
228 event->SetEventType(KTestEventUid); |
|
229 event->SetRemoteParty(aFilter.RemoteParty()); |
|
230 event->SetDirection(aFilter.Direction()); |
|
231 event->SetDurationType(aFilter.DurationType()); |
|
232 event->SetStatus(aFilter.Status()); |
|
233 event->SetContact(aFilter.Contact()); |
|
234 event->SetNumber(aFilter.Number()); |
|
235 |
|
236 CTestActive* active = new(ELeave)CTestActive(); |
|
237 CleanupStack::PushL(active); |
|
238 |
|
239 if (view->SetFilterL(aFilter, active->iStatus)) |
|
240 { |
|
241 active->StartL(); |
|
242 CActiveScheduler::Start(); |
|
243 TEST2(active->iStatus.Int(), KErrNone); |
|
244 } |
|
245 |
|
246 TInt total = view->CountL(); |
|
247 |
|
248 active->StartL(); |
|
249 aClient.AddEvent(*event, active->iStatus); |
|
250 CActiveScheduler::Start(); |
|
251 TEST2(active->iStatus.Int(), KErrNone); |
|
252 |
|
253 TBool res = view->SetFilterL(aFilter, active->iStatus); |
|
254 TEST(res); |
|
255 active->StartL(); |
|
256 CActiveScheduler::Start(); |
|
257 TEST2(active->iStatus.Int(), KErrNone); |
|
258 |
|
259 TEST(view->CountL() == total + 1); |
|
260 |
|
261 TEST(event->EventType() == KTestEventUid); |
|
262 TEST(event->RemoteParty() == aFilter.RemoteParty()); |
|
263 TEST(event->Direction() == aFilter.Direction()); |
|
264 TEST(event->DurationType() == aFilter.DurationType()); |
|
265 TEST(event->Status() == aFilter.Status()); |
|
266 TEST(event->Contact() == aFilter.Contact()); |
|
267 TEST(event->Number() == aFilter.Number()); |
|
268 |
|
269 TTime now; |
|
270 now.UniversalTime(); |
|
271 |
|
272 TInt count = 1; |
|
273 |
|
274 while(view->NextL(active->iStatus)) |
|
275 { |
|
276 count++; |
|
277 TEST(count <= total + 1); |
|
278 |
|
279 active->StartL(); |
|
280 CActiveScheduler::Start(); |
|
281 TEST2(active->iStatus.Int(), KErrNone); |
|
282 |
|
283 TEST(now >= event->Time()); |
|
284 |
|
285 if (aFilter.EventType() != KNullUid) |
|
286 TEST(event->EventType() == aFilter.EventType()); |
|
287 |
|
288 if (aFilter.RemoteParty().Length() > 0) |
|
289 TEST(event->RemoteParty() == aFilter.RemoteParty()); |
|
290 |
|
291 if (aFilter.Direction().Length() > 0) |
|
292 TEST(event->Direction() == aFilter.Direction()); |
|
293 |
|
294 if (aFilter.DurationType() != KLogNullDurationType) |
|
295 TEST(event->DurationType() == aFilter.DurationType()); |
|
296 |
|
297 if (aFilter.Status().Length() > 0) |
|
298 TEST(event->Status() == aFilter.Status()); |
|
299 |
|
300 if (aFilter.Contact() > KLogNullContactId) |
|
301 TEST(event->Contact() == aFilter.Contact()); |
|
302 |
|
303 if (aFilter.Number().Length() > 0) |
|
304 TEST(event->Number() == aFilter.Number()); |
|
305 } |
|
306 |
|
307 TEST(count == total + 1); |
|
308 |
|
309 CleanupStack::PopAndDestroy(3); // active, event, view; |
|
310 } |
|
311 |
|
312 /** |
|
313 @SYMTestCaseID SYSLIB-LOGENG-CT-0853 |
|
314 @SYMTestCaseDesc Tests for filtering the log view |
|
315 @SYMTestPriority High |
|
316 @SYMTestActions Tests for the log view filter,which is set with different configuration data |
|
317 @SYMTestExpectedResults Test must not fail |
|
318 @SYMREQ REQ0000 |
|
319 */ |
|
320 LOCAL_C void TestEventViewFilter1L(CLogClient& aClient) |
|
321 { |
|
322 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0853 ")); |
|
323 CTestActive* active = new(ELeave)CTestActive(); |
|
324 CleanupStack::PushL(active); |
|
325 |
|
326 // Create a test event type |
|
327 CLogEventType* type = CLogEventType::NewL(); |
|
328 CleanupStack::PushL(type); |
|
329 |
|
330 type->SetUid(KTestEventUid); |
|
331 type->SetDescription(KTestEventDesc); |
|
332 type->SetLoggingEnabled(ETrue); |
|
333 |
|
334 // Register the event type |
|
335 active->StartL(); |
|
336 aClient.AddEventType(*type, active->iStatus); |
|
337 CActiveScheduler::Start(); |
|
338 TEST2(active->iStatus.Int(), KErrNone); |
|
339 |
|
340 CleanupStack::PopAndDestroy(); // type |
|
341 |
|
342 CLogFilter* filter = CLogFilter::NewL(); |
|
343 CleanupStack::PushL(filter); |
|
344 |
|
345 filter->SetEventType(KTestEventUid); |
|
346 TestViewFilterL(aClient, *filter); |
|
347 |
|
348 filter->SetEventType(KTestEventUid); |
|
349 filter->SetRemoteParty(KTestRemoteParty); |
|
350 TestViewFilterL(aClient, *filter); |
|
351 |
|
352 filter->SetEventType(KTestEventUid); |
|
353 filter->SetRemoteParty(KTestRemoteParty); |
|
354 filter->SetDirection(KTestDirection); |
|
355 TestViewFilterL(aClient, *filter); |
|
356 |
|
357 filter->SetEventType(KTestEventUid); |
|
358 filter->SetRemoteParty(KTestRemoteParty); |
|
359 filter->SetDirection(KTestDirection); |
|
360 filter->SetDurationType(KTestDurationType); |
|
361 TestViewFilterL(aClient, *filter); |
|
362 |
|
363 filter->SetEventType(KTestEventUid); |
|
364 filter->SetRemoteParty(KTestRemoteParty); |
|
365 filter->SetDirection(KTestDirection); |
|
366 filter->SetDurationType(KTestDurationType); |
|
367 filter->SetStatus(KTestStatus); |
|
368 TestViewFilterL(aClient, *filter); |
|
369 |
|
370 filter->SetEventType(KTestEventUid); |
|
371 filter->SetRemoteParty(KTestRemoteParty); |
|
372 filter->SetDirection(KTestDirection); |
|
373 filter->SetDurationType(KTestDurationType); |
|
374 filter->SetStatus(KTestStatus); |
|
375 filter->SetContact(KTestContact); |
|
376 TestViewFilterL(aClient, *filter); |
|
377 |
|
378 filter->SetEventType(KTestEventUid); |
|
379 filter->SetRemoteParty(KTestRemoteParty); |
|
380 filter->SetDirection(KTestDirection); |
|
381 filter->SetDurationType(KTestDurationType); |
|
382 filter->SetStatus(KTestStatus); |
|
383 filter->SetContact(KTestContact); |
|
384 filter->SetNumber(KTestNumber); |
|
385 TestViewFilterL(aClient, *filter); |
|
386 |
|
387 CleanupStack::PopAndDestroy(); // filter |
|
388 |
|
389 filter = CLogFilter::NewL(); |
|
390 CleanupStack::PushL(filter); |
|
391 |
|
392 filter->SetRemoteParty(KTestRemoteParty); |
|
393 TestViewFilterL(aClient, *filter); |
|
394 |
|
395 filter->SetRemoteParty(KTestRemoteParty); |
|
396 filter->SetDirection(KTestDirection); |
|
397 TestViewFilterL(aClient, *filter); |
|
398 |
|
399 filter->SetRemoteParty(KTestRemoteParty); |
|
400 filter->SetDirection(KTestDirection); |
|
401 filter->SetDurationType(KTestDurationType); |
|
402 TestViewFilterL(aClient, *filter); |
|
403 |
|
404 filter->SetRemoteParty(KTestRemoteParty); |
|
405 filter->SetDirection(KTestDirection); |
|
406 filter->SetDurationType(KTestDurationType); |
|
407 filter->SetStatus(KTestStatus); |
|
408 TestViewFilterL(aClient, *filter); |
|
409 |
|
410 filter->SetRemoteParty(KTestRemoteParty); |
|
411 filter->SetDirection(KTestDirection); |
|
412 filter->SetDurationType(KTestDurationType); |
|
413 filter->SetStatus(KTestStatus); |
|
414 filter->SetContact(KTestContact); |
|
415 TestViewFilterL(aClient, *filter); |
|
416 |
|
417 filter->SetRemoteParty(KTestRemoteParty); |
|
418 filter->SetDirection(KTestDirection); |
|
419 filter->SetDurationType(KTestDurationType); |
|
420 filter->SetStatus(KTestStatus); |
|
421 filter->SetContact(KTestContact); |
|
422 filter->SetNumber(KTestNumber); |
|
423 TestViewFilterL(aClient, *filter); |
|
424 |
|
425 CleanupStack::PopAndDestroy(); // filter |
|
426 |
|
427 filter = CLogFilter::NewL(); |
|
428 CleanupStack::PushL(filter); |
|
429 |
|
430 filter->SetDirection(KTestDirection); |
|
431 TestViewFilterL(aClient, *filter); |
|
432 |
|
433 filter->SetDirection(KTestDirection); |
|
434 filter->SetDurationType(KTestDurationType); |
|
435 TestViewFilterL(aClient, *filter); |
|
436 |
|
437 filter->SetDirection(KTestDirection); |
|
438 filter->SetDurationType(KTestDurationType); |
|
439 filter->SetStatus(KTestStatus); |
|
440 TestViewFilterL(aClient, *filter); |
|
441 |
|
442 filter->SetDirection(KTestDirection); |
|
443 filter->SetDurationType(KTestDurationType); |
|
444 filter->SetStatus(KTestStatus); |
|
445 filter->SetContact(KTestContact); |
|
446 TestViewFilterL(aClient, *filter); |
|
447 |
|
448 filter->SetDirection(KTestDirection); |
|
449 filter->SetDurationType(KTestDurationType); |
|
450 filter->SetStatus(KTestStatus); |
|
451 filter->SetContact(KTestContact); |
|
452 filter->SetNumber(KTestNumber); |
|
453 TestViewFilterL(aClient, *filter); |
|
454 |
|
455 CleanupStack::PopAndDestroy(); // filter |
|
456 |
|
457 filter = CLogFilter::NewL(); |
|
458 CleanupStack::PushL(filter); |
|
459 |
|
460 filter->SetDurationType(KTestDurationType); |
|
461 TestViewFilterL(aClient, *filter); |
|
462 |
|
463 filter->SetDurationType(KTestDurationType); |
|
464 filter->SetStatus(KTestStatus); |
|
465 TestViewFilterL(aClient, *filter); |
|
466 |
|
467 filter->SetDurationType(KTestDurationType); |
|
468 filter->SetStatus(KTestStatus); |
|
469 filter->SetContact(KTestContact); |
|
470 TestViewFilterL(aClient, *filter); |
|
471 |
|
472 filter->SetDurationType(KTestDurationType); |
|
473 filter->SetStatus(KTestStatus); |
|
474 filter->SetContact(KTestContact); |
|
475 filter->SetNumber(KTestNumber); |
|
476 TestViewFilterL(aClient, *filter); |
|
477 |
|
478 CleanupStack::PopAndDestroy(); // filter |
|
479 |
|
480 filter = CLogFilter::NewL(); |
|
481 CleanupStack::PushL(filter); |
|
482 |
|
483 filter->SetStatus(KTestStatus); |
|
484 TestViewFilterL(aClient, *filter); |
|
485 |
|
486 filter->SetStatus(KTestStatus); |
|
487 filter->SetContact(KTestContact); |
|
488 TestViewFilterL(aClient, *filter); |
|
489 |
|
490 filter->SetStatus(KTestStatus); |
|
491 filter->SetContact(KTestContact); |
|
492 filter->SetNumber(KTestNumber); |
|
493 TestViewFilterL(aClient, *filter); |
|
494 |
|
495 CleanupStack::PopAndDestroy(); // filter |
|
496 |
|
497 filter = CLogFilter::NewL(); |
|
498 CleanupStack::PushL(filter); |
|
499 |
|
500 filter->SetContact(KTestContact); |
|
501 TestViewFilterL(aClient, *filter); |
|
502 |
|
503 filter->SetContact(KTestContact); |
|
504 filter->SetNumber(KTestNumber); |
|
505 TestViewFilterL(aClient, *filter); |
|
506 |
|
507 CleanupStack::PopAndDestroy(); // filter |
|
508 |
|
509 filter = CLogFilter::NewL(); |
|
510 CleanupStack::PushL(filter); |
|
511 |
|
512 filter->SetNumber(KTestNumber); |
|
513 TestViewFilterL(aClient, *filter); |
|
514 |
|
515 CleanupStack::PopAndDestroy(2); // filter, active |
|
516 } |
|
517 |
|
518 /** |
|
519 @SYMTestCaseID SYSLIB-LOGENG-CT-0854 |
|
520 @SYMTestCaseDesc Tests for filtering list event types |
|
521 @SYMTestPriority High |
|
522 @SYMTestActions Get the count of all event types,call,data,fax events. |
|
523 Add some event types to the filter,test for the new count |
|
524 Check for non existing event type. |
|
525 @SYMTestExpectedResults Test must not fail |
|
526 @SYMREQ REQ0000 |
|
527 */ |
|
528 LOCAL_C void TestEventViewFilter2L(CLogClient& aClient) |
|
529 { |
|
530 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0854 ")); |
|
531 CTestActive* active = new(ELeave)CTestActive(); |
|
532 CleanupStack::PushL(active); |
|
533 |
|
534 CLogViewEvent* view = CLogViewEvent::NewL(aClient); |
|
535 CleanupStack::PushL(view); |
|
536 |
|
537 CLogFilter* filter = CLogFilter::NewL(); |
|
538 CleanupStack::PushL(filter); |
|
539 |
|
540 // Get total count of all events |
|
541 if (view->SetFilterL(*filter, active->iStatus)) |
|
542 { |
|
543 active->StartL(); |
|
544 CActiveScheduler::Start(); |
|
545 TEST2(active->iStatus.Int(), KErrNone); |
|
546 } |
|
547 TInt total = view->CountL(); |
|
548 |
|
549 filter->SetEventType(KLogCallEventTypeUid); |
|
550 |
|
551 // Get number of call events |
|
552 if (view->SetFilterL(*filter, active->iStatus)) |
|
553 { |
|
554 active->StartL(); |
|
555 CActiveScheduler::Start(); |
|
556 TEST2(active->iStatus.Int(), KErrNone); |
|
557 } |
|
558 TInt calls = view->CountL(); |
|
559 |
|
560 filter->SetEventType(KLogDataEventTypeUid); |
|
561 |
|
562 // Get number of data events |
|
563 if (view->SetFilterL(*filter, active->iStatus)) |
|
564 { |
|
565 active->StartL(); |
|
566 CActiveScheduler::Start(); |
|
567 TEST2(active->iStatus.Int(), KErrNone); |
|
568 } |
|
569 TInt data = view->CountL(); |
|
570 |
|
571 filter->SetEventType(KLogFaxEventTypeUid); |
|
572 |
|
573 // Get number of fax events |
|
574 if (view->SetFilterL(*filter, active->iStatus)) |
|
575 { |
|
576 active->StartL(); |
|
577 CActiveScheduler::Start(); |
|
578 TEST2(active->iStatus.Int(), KErrNone); |
|
579 } |
|
580 TInt fax = view->CountL(); |
|
581 |
|
582 filter->SetEventType(KLogLbsSelfLocateEventTypeUid); |
|
583 |
|
584 // Get number of Lbs self locate events |
|
585 if (view->SetFilterL(*filter, active->iStatus)) |
|
586 { |
|
587 active->StartL(); |
|
588 CActiveScheduler::Start(); |
|
589 TEST2(active->iStatus.Int(), KErrNone); |
|
590 } |
|
591 TInt lbsSelf = view->CountL(); |
|
592 |
|
593 filter->SetEventType(KLogLbsExternalLocateEventTypeUid); |
|
594 |
|
595 // Get number of Lbs self locate events |
|
596 if (view->SetFilterL(*filter, active->iStatus)) |
|
597 { |
|
598 active->StartL(); |
|
599 CActiveScheduler::Start(); |
|
600 TEST2(active->iStatus.Int(), KErrNone); |
|
601 } |
|
602 TInt lbsExternal = view->CountL(); |
|
603 |
|
604 filter->SetEventType(KLogLbsTransmitLocationEventTypeUid); |
|
605 |
|
606 // Get number of Lbs transmit location events |
|
607 if (view->SetFilterL(*filter, active->iStatus)) |
|
608 { |
|
609 active->StartL(); |
|
610 CActiveScheduler::Start(); |
|
611 TEST2(active->iStatus.Int(), KErrNone); |
|
612 } |
|
613 TInt lbsXmitLoc = view->CountL(); |
|
614 |
|
615 filter->SetEventType(KLogLbsNetworkLocateEventTypeUid); |
|
616 |
|
617 // Get number of Lbs network locate events |
|
618 if (view->SetFilterL(*filter, active->iStatus)) |
|
619 { |
|
620 active->StartL(); |
|
621 CActiveScheduler::Start(); |
|
622 TEST2(active->iStatus.Int(), KErrNone); |
|
623 } |
|
624 TInt lbsNetwork = view->CountL(); |
|
625 |
|
626 filter->SetEventType(KLogLbsAssistanceDataEventTypeUid); |
|
627 |
|
628 // Get number of Lbs assistance data events |
|
629 if (view->SetFilterL(*filter, active->iStatus)) |
|
630 { |
|
631 active->StartL(); |
|
632 CActiveScheduler::Start(); |
|
633 TEST2(active->iStatus.Int(), KErrNone); |
|
634 } |
|
635 TInt lbsAssistance = view->CountL(); |
|
636 |
|
637 CLogEvent* event = CLogEvent::NewL(); |
|
638 CleanupStack::PushL(event); |
|
639 |
|
640 event->SetEventType(KLogCallEventTypeUid); |
|
641 |
|
642 // Add two call events |
|
643 active->StartL(); |
|
644 aClient.AddEvent(*event, active->iStatus); |
|
645 CActiveScheduler::Start(); |
|
646 TEST2(active->iStatus.Int(), KErrNone); |
|
647 |
|
648 active->StartL(); |
|
649 aClient.AddEvent(*event, active->iStatus); |
|
650 CActiveScheduler::Start(); |
|
651 TEST2(active->iStatus.Int(), KErrNone); |
|
652 |
|
653 event->SetEventType(KLogDataEventTypeUid); |
|
654 |
|
655 // Add two data events |
|
656 active->StartL(); |
|
657 aClient.AddEvent(*event, active->iStatus); |
|
658 CActiveScheduler::Start(); |
|
659 TEST2(active->iStatus.Int(), KErrNone); |
|
660 |
|
661 active->StartL(); |
|
662 aClient.AddEvent(*event, active->iStatus); |
|
663 CActiveScheduler::Start(); |
|
664 TEST2(active->iStatus.Int(), KErrNone); |
|
665 |
|
666 // Filter all event types |
|
667 filter->SetEventType(KNullUid); |
|
668 |
|
669 // Get view of all events |
|
670 active->StartL(); |
|
671 TBool res = view->SetFilterL(*filter, active->iStatus); |
|
672 TEST(res); |
|
673 CActiveScheduler::Start(); |
|
674 TEST2(active->iStatus.Int(), KErrNone); |
|
675 |
|
676 // Check the count is correct |
|
677 TEST(view->CountL() == total + 4); |
|
678 |
|
679 filter->SetEventType(KLogCallEventTypeUid); |
|
680 |
|
681 // Get view of call events |
|
682 active->StartL(); |
|
683 res = view->SetFilterL(*filter, active->iStatus); |
|
684 TEST(res); |
|
685 CActiveScheduler::Start(); |
|
686 TEST2(active->iStatus.Int(), KErrNone); |
|
687 |
|
688 TEST(view->CountL() == calls + 2); |
|
689 |
|
690 filter->SetEventType(KLogDataEventTypeUid); |
|
691 |
|
692 // Get view of data events |
|
693 active->StartL(); |
|
694 res = view->SetFilterL(*filter, active->iStatus); |
|
695 TEST(res); |
|
696 CActiveScheduler::Start(); |
|
697 TEST2(active->iStatus.Int(), KErrNone); |
|
698 |
|
699 TEST(view->CountL() == data + 2); |
|
700 |
|
701 filter->SetEventType(KLogFaxEventTypeUid); |
|
702 |
|
703 // Get view of fax events |
|
704 if (view->SetFilterL(*filter, active->iStatus)) |
|
705 { |
|
706 active->StartL(); |
|
707 CActiveScheduler::Start(); |
|
708 TEST2(active->iStatus.Int(), KErrNone); |
|
709 } |
|
710 TEST2(view->CountL(), fax); |
|
711 |
|
712 filter->SetEventType(KLogLbsSelfLocateEventTypeUid); |
|
713 |
|
714 // Get number of Lbs self locate events |
|
715 if (view->SetFilterL(*filter, active->iStatus)) |
|
716 { |
|
717 active->StartL(); |
|
718 CActiveScheduler::Start(); |
|
719 TEST2(active->iStatus.Int(), KErrNone); |
|
720 } |
|
721 TEST2(view->CountL(), lbsSelf); |
|
722 |
|
723 filter->SetEventType(KLogLbsExternalLocateEventTypeUid); |
|
724 |
|
725 // Get number of Lbs self locate events |
|
726 if (view->SetFilterL(*filter, active->iStatus)) |
|
727 { |
|
728 active->StartL(); |
|
729 CActiveScheduler::Start(); |
|
730 TEST2(active->iStatus.Int(), KErrNone); |
|
731 } |
|
732 TEST2(view->CountL(), lbsExternal); |
|
733 |
|
734 filter->SetEventType(KLogLbsTransmitLocationEventTypeUid); |
|
735 |
|
736 // Get number of Lbs transmit location events |
|
737 if (view->SetFilterL(*filter, active->iStatus)) |
|
738 { |
|
739 active->StartL(); |
|
740 CActiveScheduler::Start(); |
|
741 TEST2(active->iStatus.Int(), KErrNone); |
|
742 } |
|
743 TEST2(view->CountL(), lbsXmitLoc); |
|
744 |
|
745 filter->SetEventType(KLogLbsNetworkLocateEventTypeUid); |
|
746 |
|
747 // Get number of Lbs network locate events |
|
748 if (view->SetFilterL(*filter, active->iStatus)) |
|
749 { |
|
750 active->StartL(); |
|
751 CActiveScheduler::Start(); |
|
752 TEST2(active->iStatus.Int(), KErrNone); |
|
753 } |
|
754 TEST2(view->CountL(), lbsNetwork); |
|
755 |
|
756 filter->SetEventType(KLogLbsAssistanceDataEventTypeUid); |
|
757 |
|
758 // Get number of Lbs assistance data events |
|
759 if (view->SetFilterL(*filter, active->iStatus)) |
|
760 { |
|
761 active->StartL(); |
|
762 CActiveScheduler::Start(); |
|
763 TEST2(active->iStatus.Int(), KErrNone); |
|
764 } |
|
765 TEST2(view->CountL(), lbsAssistance); |
|
766 |
|
767 // Test a non existing event type |
|
768 filter->SetEventType(TUid::Uid(0x12345678)); |
|
769 res = view->SetFilterL(*filter, active->iStatus); |
|
770 TEST(!res); |
|
771 TEST2(view->CountL(), 0); |
|
772 |
|
773 CleanupStack::PopAndDestroy(4); // view, filter, event, active |
|
774 } |
|
775 |
|
776 /** |
|
777 @SYMTestCaseID SYSLIB-LOGENG-CT-0855 |
|
778 @SYMTestCaseDesc Tests for CLogViewRecent::SetRecentListL() function |
|
779 @SYMTestPriority High |
|
780 @SYMTestActions Tests for the count of events,outgoing calls. |
|
781 @SYMTestExpectedResults Test must not fail |
|
782 @SYMREQ REQ0000 |
|
783 */ |
|
784 LOCAL_C void TestRecentView1L(CLogClient& aClient) |
|
785 { |
|
786 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0855 ")); |
|
787 CLogEvent* event = CLogEvent::NewL(); |
|
788 CleanupStack::PushL(event); |
|
789 |
|
790 CTestActive* active = new(ELeave)CTestActive(); |
|
791 CleanupStack::PushL(active); |
|
792 |
|
793 CLogViewRecent* view = CLogViewRecent::NewL(aClient); |
|
794 CleanupStack::PushL(view); |
|
795 |
|
796 // Incoming |
|
797 TBuf<KLogMaxDirectionLength> buf; |
|
798 aClient.GetString(buf, R_LOG_DIR_IN); |
|
799 |
|
800 event->SetEventType(KLogCallEventTypeUid); |
|
801 event->SetDirection(buf); |
|
802 |
|
803 TInt count; |
|
804 for(count = 0; count < KTestEventNum; count++) |
|
805 { |
|
806 event->SetContact(count); |
|
807 |
|
808 active->StartL(); |
|
809 aClient.AddEvent(*event, active->iStatus); |
|
810 CActiveScheduler::Start(); |
|
811 TEST2(active->iStatus.Int(), KErrNone); |
|
812 } |
|
813 |
|
814 TEST2(view->CountL(), 0); |
|
815 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
816 TEST(res); |
|
817 |
|
818 // Move forward |
|
819 count = KTestEventNum; |
|
820 do { |
|
821 active->StartL(); |
|
822 CActiveScheduler::Start(); |
|
823 TEST2(active->iStatus.Int(), KErrNone); |
|
824 |
|
825 TEST2(view->CountL(), KTestEventNum); |
|
826 TEST2(view->RecentList(), KLogRecentIncomingCalls); |
|
827 count--; |
|
828 } |
|
829 while(view->NextL(active->iStatus)); |
|
830 TEST2(count, 0); |
|
831 TEST2(view->CountL(), KTestEventNum); |
|
832 |
|
833 // Move back |
|
834 while(view->PreviousL(active->iStatus)) |
|
835 { |
|
836 active->StartL(); |
|
837 CActiveScheduler::Start(); |
|
838 TEST2(active->iStatus.Int(), KErrNone); |
|
839 |
|
840 TEST2(view->CountL(), KTestEventNum); |
|
841 TEST2(view->RecentList(), KLogRecentIncomingCalls); |
|
842 count++; |
|
843 } |
|
844 TEST(count == KTestEventNum - 1); |
|
845 |
|
846 active->StartL(); |
|
847 res = view->FirstL(active->iStatus); |
|
848 TEST(res); |
|
849 CActiveScheduler::Start(); |
|
850 TEST2(active->iStatus.Int(), KErrNone); |
|
851 |
|
852 active->StartL(); |
|
853 res = view->LastL(active->iStatus); |
|
854 TEST(res); |
|
855 CActiveScheduler::Start(); |
|
856 TEST2(active->iStatus.Int(), KErrNone); |
|
857 |
|
858 TEST2(view->CountL(), KTestEventNum); |
|
859 |
|
860 // Outgoing |
|
861 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); |
|
862 TEST(!res); |
|
863 count = view->CountL(); |
|
864 TEST2(count, 0); |
|
865 CleanupStack::PopAndDestroy(view); |
|
866 // |
|
867 view = CLogViewRecent::NewL(aClient); |
|
868 CleanupStack::PushL(view); |
|
869 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
870 TEST(res); |
|
871 TEST2(view->CountL(), KTestEventNum); |
|
872 active->StartL(); |
|
873 CActiveScheduler::Start(); |
|
874 TEST2(active->iStatus.Int(), KErrNone); |
|
875 |
|
876 aClient.GetString(buf, R_LOG_DIR_OUT); |
|
877 |
|
878 event->SetEventType(KLogCallEventTypeUid); |
|
879 event->SetDirection(buf); |
|
880 |
|
881 for(count = 0; count < KTestEventNum; count++) |
|
882 { |
|
883 event->SetContact(count); |
|
884 |
|
885 active->StartL(); |
|
886 aClient.AddEvent(*event, active->iStatus); |
|
887 CActiveScheduler::Start(); |
|
888 TEST2(active->iStatus.Int(), KErrNone); |
|
889 } |
|
890 |
|
891 count = view->CountL(); |
|
892 TEST2(count, KTestEventNum); |
|
893 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); |
|
894 TEST(res); |
|
895 |
|
896 // Move forward |
|
897 count = KTestEventNum; |
|
898 do { |
|
899 active->StartL(); |
|
900 CActiveScheduler::Start(); |
|
901 TEST2(active->iStatus.Int(), KErrNone); |
|
902 |
|
903 TEST2(view->CountL(), KTestEventNum); |
|
904 TEST2(view->RecentList(), KLogRecentOutgoingCalls); |
|
905 count--; |
|
906 } |
|
907 while(view->NextL(active->iStatus)); |
|
908 TEST2(count, 0); |
|
909 TEST2(view->CountL(), KTestEventNum); |
|
910 |
|
911 // Move back |
|
912 while(view->PreviousL(active->iStatus)) |
|
913 { |
|
914 active->StartL(); |
|
915 CActiveScheduler::Start(); |
|
916 TEST2(active->iStatus.Int(), KErrNone); |
|
917 |
|
918 TEST2(view->CountL(), KTestEventNum); |
|
919 TEST2(view->RecentList(), KLogRecentOutgoingCalls); |
|
920 count++; |
|
921 } |
|
922 TEST(count == KTestEventNum - 1); |
|
923 |
|
924 active->StartL(); |
|
925 res = view->FirstL(active->iStatus); |
|
926 TEST(res); |
|
927 CActiveScheduler::Start(); |
|
928 TEST2(active->iStatus.Int(), KErrNone); |
|
929 |
|
930 active->StartL(); |
|
931 res = view->LastL(active->iStatus); |
|
932 TEST(res); |
|
933 CActiveScheduler::Start(); |
|
934 TEST2(active->iStatus.Int(), KErrNone); |
|
935 |
|
936 // Missed |
|
937 aClient.GetString(buf, R_LOG_DIR_MISSED); |
|
938 |
|
939 event->SetEventType(KLogCallEventTypeUid); |
|
940 event->SetDirection(buf); |
|
941 |
|
942 TEST2(view->CountL(), KTestEventNum); |
|
943 res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus); |
|
944 TEST(!res); |
|
945 TEST2(view->CountL(), 0); |
|
946 |
|
947 for(count = 0; count < KTestEventNum; count++) |
|
948 { |
|
949 event->SetContact(count); |
|
950 |
|
951 active->StartL(); |
|
952 aClient.AddEvent(*event, active->iStatus); |
|
953 CActiveScheduler::Start(); |
|
954 TEST2(active->iStatus.Int(), KErrNone); |
|
955 |
|
956 // Test INC123066 - LogView not updated if log count is zero at |
|
957 // time of SetFilterL. |
|
958 TEST2(view->CountL(), count+1); |
|
959 } |
|
960 |
|
961 |
|
962 // Move forward |
|
963 count = KTestEventNum; |
|
964 while(view->NextL(active->iStatus)) |
|
965 { |
|
966 active->StartL(); |
|
967 CActiveScheduler::Start(); |
|
968 TEST2(active->iStatus.Int(), KErrNone); |
|
969 |
|
970 TEST2(view->CountL(), KTestEventNum); |
|
971 TEST2(view->RecentList(), KLogRecentMissedCalls); |
|
972 count--; |
|
973 } |
|
974 TEST2(count, 0); |
|
975 |
|
976 // Move back |
|
977 while(view->PreviousL(active->iStatus)) |
|
978 { |
|
979 active->StartL(); |
|
980 CActiveScheduler::Start(); |
|
981 TEST2(active->iStatus.Int(), KErrNone); |
|
982 |
|
983 TEST2(view->CountL(), KTestEventNum); |
|
984 TEST2(view->RecentList(), KLogRecentMissedCalls); |
|
985 count++; |
|
986 } |
|
987 TEST(count == KTestEventNum - 1); |
|
988 |
|
989 active->StartL(); |
|
990 res = view->FirstL(active->iStatus); |
|
991 TEST(res); |
|
992 CActiveScheduler::Start(); |
|
993 TEST2(active->iStatus.Int(), KErrNone); |
|
994 |
|
995 active->StartL(); |
|
996 res = view->LastL(active->iStatus); |
|
997 TEST(res); |
|
998 CActiveScheduler::Start(); |
|
999 TEST2(active->iStatus.Int(), KErrNone); |
|
1000 |
|
1001 // All |
|
1002 TEST2(view->CountL(), KTestEventNum); |
|
1003 res = view->SetRecentListL(KLogNullRecentList, active->iStatus); |
|
1004 TEST(res); |
|
1005 |
|
1006 // Move forward |
|
1007 count = KTestEventNum * 3; |
|
1008 TEST2(view->CountL(), count); |
|
1009 do { |
|
1010 active->StartL(); |
|
1011 CActiveScheduler::Start(); |
|
1012 TEST2(active->iStatus.Int(), KErrNone); |
|
1013 |
|
1014 TEST(view->CountL() == KTestEventNum * 3); |
|
1015 count--; |
|
1016 } |
|
1017 while(view->NextL(active->iStatus)); |
|
1018 TEST2(count, 0); |
|
1019 |
|
1020 // Move back |
|
1021 while(view->PreviousL(active->iStatus)) |
|
1022 { |
|
1023 active->StartL(); |
|
1024 CActiveScheduler::Start(); |
|
1025 TEST2(active->iStatus.Int(), KErrNone); |
|
1026 |
|
1027 TEST(view->CountL() == KTestEventNum * 3); |
|
1028 count++; |
|
1029 } |
|
1030 TEST(count == KTestEventNum * 3 - 1); |
|
1031 |
|
1032 active->StartL(); |
|
1033 res = view->FirstL(active->iStatus); |
|
1034 TEST(res); |
|
1035 CActiveScheduler::Start(); |
|
1036 TEST2(active->iStatus.Int(), KErrNone); |
|
1037 |
|
1038 active->StartL(); |
|
1039 res = view->LastL(active->iStatus); |
|
1040 TEST(res); |
|
1041 CActiveScheduler::Start(); |
|
1042 TEST2(active->iStatus.Int(), KErrNone); |
|
1043 |
|
1044 CleanupStack::PopAndDestroy(3); // view, active, event |
|
1045 theLog.Write(_L8("Test 3.1 OK\n")); |
|
1046 } |
|
1047 |
|
1048 /** |
|
1049 @SYMTestCaseID SYSLIB-LOGENG-CT-0856 |
|
1050 @SYMTestCaseDesc Tests for CLogViewRecent::SetRecentListL(),DuplicatesL() functions |
|
1051 @SYMTestPriority High |
|
1052 @SYMTestActions Tests for the count of events in the log |
|
1053 @SYMTestExpectedResults Test must not fail |
|
1054 @SYMREQ REQ0000 |
|
1055 */ |
|
1056 LOCAL_C void TestRecentView2L(CLogClient& aClient) |
|
1057 { |
|
1058 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0856 ")); |
|
1059 TInt count; |
|
1060 |
|
1061 CLogEvent* event = CLogEvent::NewL(); |
|
1062 CleanupStack::PushL(event); |
|
1063 |
|
1064 CTestActive* active = new(ELeave)CTestActive(); |
|
1065 CleanupStack::PushL(active); |
|
1066 |
|
1067 CLogViewRecent* view = CLogViewRecent::NewL(aClient); |
|
1068 CleanupStack::PushL(view); |
|
1069 |
|
1070 TEST2(view->CountL(), 0); |
|
1071 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1072 TEST(res); |
|
1073 active->StartL(); |
|
1074 CActiveScheduler::Start(); |
|
1075 TEST2(active->iStatus.Int(), KErrNone); |
|
1076 count = view->CountL(); |
|
1077 TEST2(count, KTestEventNum); |
|
1078 |
|
1079 aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus); |
|
1080 active->StartL(); |
|
1081 CActiveScheduler::Start(); |
|
1082 TEST2(active->iStatus.Int(), KErrNone); |
|
1083 |
|
1084 count = view->CountL(); |
|
1085 TEST2(count, 0); |
|
1086 |
|
1087 CleanupStack::PopAndDestroy(view); |
|
1088 view = CLogViewRecent::NewL(aClient); |
|
1089 CleanupStack::PushL(view); |
|
1090 |
|
1091 |
|
1092 // Incoming |
|
1093 TBuf<KLogMaxDirectionLength> buf; |
|
1094 aClient.GetString(buf, R_LOG_DIR_IN); |
|
1095 |
|
1096 event->SetEventType(KLogCallEventTypeUid); |
|
1097 event->SetDirection(buf); |
|
1098 |
|
1099 // All fields are null, they should all be duplicates |
|
1100 for(count = 0; count < KTestEventNum; count++) |
|
1101 { |
|
1102 active->StartL(); |
|
1103 aClient.AddEvent(*event, active->iStatus); |
|
1104 CActiveScheduler::Start(); |
|
1105 TEST2(active->iStatus.Int(), KErrNone); |
|
1106 } |
|
1107 |
|
1108 TEST2(view->CountL(), 0); |
|
1109 |
|
1110 // Move forward |
|
1111 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1112 TEST(res); |
|
1113 active->StartL(); |
|
1114 CActiveScheduler::Start(); |
|
1115 TEST2(active->iStatus.Int(), KErrNone); |
|
1116 TEST2(view->CountL(), 1); |
|
1117 |
|
1118 CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient); |
|
1119 CleanupStack::PushL(dView); |
|
1120 |
|
1121 res = view->DuplicatesL(*dView, active->iStatus); |
|
1122 TEST(res); |
|
1123 active->StartL(); |
|
1124 CActiveScheduler::Start(); |
|
1125 TEST2(active->iStatus.Int(), KErrNone); |
|
1126 TEST(dView->CountL() == KTestEventNum - 1); |
|
1127 |
|
1128 CleanupStack::PopAndDestroy(4); // view, active, event, dView |
|
1129 } |
|
1130 |
|
1131 /** |
|
1132 @SYMTestCaseID SYSLIB-LOGENG-CT-0857 |
|
1133 @SYMTestCaseDesc Tests for CLogViewRecent::RemoveL() functions |
|
1134 @SYMTestPriority High |
|
1135 @SYMTestActions Add the recently view events to the view.Remove the items and check for the count. |
|
1136 @SYMTestExpectedResults Test must not fail |
|
1137 @SYMREQ REQ0000 |
|
1138 */ |
|
1139 LOCAL_C void TestRecentRemove1L(CLogClient& aClient) |
|
1140 { |
|
1141 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0857 ")); |
|
1142 CTestActive* active = new(ELeave)CTestActive(); |
|
1143 CleanupStack::PushL(active); |
|
1144 |
|
1145 CLogViewRecent* view = CLogViewRecent::NewL(aClient); |
|
1146 CleanupStack::PushL(view); |
|
1147 |
|
1148 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1149 TEST(res); |
|
1150 active->StartL(); |
|
1151 CActiveScheduler::Start(); |
|
1152 TEST2(active->iStatus.Int(), KErrNone); |
|
1153 |
|
1154 TInt count = view->CountL(); |
|
1155 |
|
1156 while(view->RemoveL(active->iStatus)) |
|
1157 { |
|
1158 TEST(view->CountL() == count - 1); |
|
1159 count = view->CountL(); |
|
1160 |
|
1161 active->StartL(); |
|
1162 CActiveScheduler::Start(); |
|
1163 TEST2(active->iStatus.Int(), KErrNone); |
|
1164 } |
|
1165 TEST2(view->CountL(), 0); |
|
1166 |
|
1167 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); |
|
1168 TEST(res); |
|
1169 active->StartL(); |
|
1170 CActiveScheduler::Start(); |
|
1171 TEST2(active->iStatus.Int(), KErrNone); |
|
1172 TEST2(view->CountL(), KTestEventNum); |
|
1173 |
|
1174 aClient.ClearLog(KLogRecentOutgoingCalls, active->iStatus); |
|
1175 active->StartL(); |
|
1176 CActiveScheduler::Start(); |
|
1177 TEST2(active->iStatus.Int(), KErrNone); |
|
1178 TEST2(view->CountL(), 0); |
|
1179 |
|
1180 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); |
|
1181 TEST(!res); |
|
1182 |
|
1183 res = view->SetRecentListL(KLogNullRecentList, active->iStatus); |
|
1184 TEST(res); |
|
1185 active->StartL(); |
|
1186 CActiveScheduler::Start(); |
|
1187 TEST2(active->iStatus.Int(), KErrNone); |
|
1188 TEST2(view->CountL(), KTestEventNum); |
|
1189 |
|
1190 aClient.ClearLog(KLogNullRecentList, active->iStatus); |
|
1191 active->StartL(); |
|
1192 CActiveScheduler::Start(); |
|
1193 TEST2(active->iStatus.Int(), KErrNone); |
|
1194 |
|
1195 res = view->SetRecentListL(KLogNullRecentList, active->iStatus); |
|
1196 TEST(!res); |
|
1197 TEST2(view->CountL(), 0); |
|
1198 |
|
1199 CleanupStack::PopAndDestroy(2); // view, active |
|
1200 } |
|
1201 |
|
1202 /** |
|
1203 @SYMTestCaseID SYSLIB-LOGENG-CT-0858 |
|
1204 @SYMTestCaseDesc Tests for CLogViewRecent::RemoveL() functions |
|
1205 @SYMTestPriority High |
|
1206 @SYMTestActions Add the recently view events to the two logviewrecents.Remove the items and check for the count of the first logview. |
|
1207 @SYMTestExpectedResults Test must not fail |
|
1208 @SYMREQ REQ0000 |
|
1209 */ |
|
1210 LOCAL_C void TestRecentRemove2L(CLogClient& aClient) |
|
1211 { |
|
1212 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0858 ")); |
|
1213 CLogEvent* event = CLogEvent::NewL(); |
|
1214 CleanupStack::PushL(event); |
|
1215 |
|
1216 CTestActive* active = new(ELeave)CTestActive(); |
|
1217 CleanupStack::PushL(active); |
|
1218 |
|
1219 CLogViewRecent* view1 = CLogViewRecent::NewL(aClient); |
|
1220 CleanupStack::PushL(view1); |
|
1221 |
|
1222 // Incoming |
|
1223 TBuf<KLogMaxDirectionLength> buf; |
|
1224 aClient.GetString(buf, R_LOG_DIR_IN); |
|
1225 |
|
1226 event->SetEventType(KLogCallEventTypeUid); |
|
1227 event->SetDirection(buf); |
|
1228 |
|
1229 TInt count; |
|
1230 for(count = 0; count < KTestEventNum; count++) |
|
1231 { |
|
1232 event->SetContact(count); |
|
1233 |
|
1234 active->StartL(); |
|
1235 aClient.AddEvent(*event, active->iStatus); |
|
1236 CActiveScheduler::Start(); |
|
1237 TEST2(active->iStatus.Int(), KErrNone); |
|
1238 } |
|
1239 |
|
1240 // Create another invalid view and remove an event using it |
|
1241 CLogViewRecent* view2 = CLogViewRecent::NewL(aClient); |
|
1242 CleanupStack::PushL(view2); |
|
1243 |
|
1244 TEST2(view1->CountL(), 0); |
|
1245 TBool res = view1->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1246 TEST(res); |
|
1247 TEST2(view1->CountL(), KTestEventNum); |
|
1248 |
|
1249 do |
|
1250 { |
|
1251 active->StartL(); |
|
1252 CActiveScheduler::Start(); |
|
1253 TEST2(active->iStatus.Int(), KErrNone); |
|
1254 view2->RemoveL(view1->Event().Id()); |
|
1255 } |
|
1256 while(view1->NextL(active->iStatus)); |
|
1257 |
|
1258 aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus); |
|
1259 active->StartL(); |
|
1260 CActiveScheduler::Start(); |
|
1261 TEST2(active->iStatus.Int(), KErrNone); |
|
1262 TEST2(view1->CountL(), 0); |
|
1263 |
|
1264 CleanupStack::PopAndDestroy(4); // view2, view1, active, event |
|
1265 } |
|
1266 |
|
1267 /** |
|
1268 @SYMTestCaseID SYSLIB-LOGENG-CT-0859 |
|
1269 @SYMTestCaseDesc Tests for CLogViewDuplicate::SetRecentListL(),DuplicatesL() functions |
|
1270 @SYMTestPriority High |
|
1271 @SYMTestActions Tests for the count of events and the event ID |
|
1272 @SYMTestExpectedResults Test must not fail |
|
1273 @SYMREQ REQ0000 |
|
1274 */ |
|
1275 LOCAL_C void TestDuplicateViewL(CLogClient& aClient) |
|
1276 { |
|
1277 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0859 ")); |
|
1278 CTestActive* active = new(ELeave)CTestActive(); |
|
1279 CleanupStack::PushL(active); |
|
1280 |
|
1281 CLogViewRecent* view = CLogViewRecent::NewL(aClient); |
|
1282 CleanupStack::PushL(view); |
|
1283 |
|
1284 CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient); |
|
1285 CleanupStack::PushL(dView); |
|
1286 |
|
1287 TEST2(dView->CountL(), 0); |
|
1288 |
|
1289 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1290 TEST(!res); |
|
1291 TEST2(view->CountL(), 0); |
|
1292 |
|
1293 res = view->DuplicatesL(*dView, active->iStatus); |
|
1294 TEST(!res); |
|
1295 TEST2(dView->CountL(), 0); |
|
1296 |
|
1297 // Incoming |
|
1298 TBuf<KLogMaxDirectionLength> incoming; |
|
1299 aClient.GetString(incoming, R_LOG_DIR_IN); |
|
1300 |
|
1301 CLogEvent* event = CLogEvent::NewL(); |
|
1302 CleanupStack::PushL(event); |
|
1303 |
|
1304 event->SetEventType(KLogCallEventTypeUid); |
|
1305 event->SetDirection(incoming); |
|
1306 event->SetRemoteParty(KTestRemoteParty); |
|
1307 event->SetContact(KTestContact); |
|
1308 event->SetNumber(KTestNumber); |
|
1309 |
|
1310 active->StartL(); |
|
1311 aClient.AddEvent(*event, active->iStatus); |
|
1312 CActiveScheduler::Start(); |
|
1313 TEST2(active->iStatus.Int(), KErrNone); |
|
1314 |
|
1315 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1316 TEST(res); |
|
1317 active->StartL(); |
|
1318 CActiveScheduler::Start(); |
|
1319 TEST2(active->iStatus.Int(), KErrNone); |
|
1320 |
|
1321 TEST2(view->CountL(), 1); |
|
1322 res = view->FirstL(active->iStatus); |
|
1323 TEST(res); |
|
1324 active->StartL(); |
|
1325 CActiveScheduler::Start(); |
|
1326 TEST2(active->iStatus.Int(), KErrNone); |
|
1327 TEST2(view->Event().Id(), event->Id()); |
|
1328 |
|
1329 TEST2(dView->CountL(), 0); |
|
1330 |
|
1331 event->SetRemoteParty(KTestRemoteParty); |
|
1332 event->SetContact(KTestContact); |
|
1333 event->SetNumber(KNullDesC); |
|
1334 |
|
1335 //Add event with Number field set to NULL |
|
1336 active->StartL(); |
|
1337 aClient.AddEvent(*event, active->iStatus); |
|
1338 CActiveScheduler::Start(); |
|
1339 TEST2(active->iStatus.Int(), KErrNone); |
|
1340 |
|
1341 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1342 TEST(res); |
|
1343 active->StartL(); |
|
1344 CActiveScheduler::Start(); |
|
1345 TEST2(active->iStatus.Int(), KErrNone); |
|
1346 |
|
1347 TEST2(view->CountL(), 2); |
|
1348 res = view->FirstL(active->iStatus); |
|
1349 TEST(res); |
|
1350 active->StartL(); |
|
1351 CActiveScheduler::Start(); |
|
1352 TEST2(active->iStatus.Int(), KErrNone); |
|
1353 TEST2(view->Event().Id(), event->Id()); |
|
1354 |
|
1355 res = view->DuplicatesL(*dView, active->iStatus); |
|
1356 TEST(!res); |
|
1357 |
|
1358 TEST2(dView->CountL(), 0); |
|
1359 |
|
1360 event->SetRemoteParty(KTestRemoteParty); |
|
1361 event->SetContact(KLogNullContactId); |
|
1362 event->SetNumber(KNullDesC); |
|
1363 |
|
1364 //Add event with Number field set to NULL & Contact set to -1 |
|
1365 active->StartL(); |
|
1366 aClient.AddEvent(*event, active->iStatus); |
|
1367 CActiveScheduler::Start(); |
|
1368 TEST2(active->iStatus.Int(), KErrNone); |
|
1369 |
|
1370 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1371 TEST(res); |
|
1372 active->StartL(); |
|
1373 CActiveScheduler::Start(); |
|
1374 TEST2(active->iStatus.Int(), KErrNone); |
|
1375 |
|
1376 TEST2(view->CountL(), 3); |
|
1377 res = view->FirstL(active->iStatus); |
|
1378 TEST(res); |
|
1379 active->StartL(); |
|
1380 CActiveScheduler::Start(); |
|
1381 TEST2(active->iStatus.Int(), KErrNone); |
|
1382 TEST2(view->Event().Id(), event->Id()); |
|
1383 |
|
1384 res = view->DuplicatesL(*dView, active->iStatus); |
|
1385 TEST(!res); |
|
1386 |
|
1387 TEST2(dView->CountL(), 0); |
|
1388 |
|
1389 event->SetRemoteParty(KNullDesC); |
|
1390 event->SetContact(KLogNullContactId); |
|
1391 event->SetNumber(KNullDesC); |
|
1392 |
|
1393 //Add event with Number, Remote Party field set to NULL & Contact set to -1 |
|
1394 active->StartL(); |
|
1395 aClient.AddEvent(*event, active->iStatus); |
|
1396 CActiveScheduler::Start(); |
|
1397 TEST2(active->iStatus.Int(), KErrNone); |
|
1398 |
|
1399 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1400 TEST(res); |
|
1401 active->StartL(); |
|
1402 CActiveScheduler::Start(); |
|
1403 TEST2(active->iStatus.Int(), KErrNone); |
|
1404 |
|
1405 TEST2(view->CountL(), 4); |
|
1406 |
|
1407 res = view->DuplicatesL(*dView, active->iStatus); |
|
1408 TEST(!res); |
|
1409 |
|
1410 TEST2(dView->CountL(), 0); |
|
1411 |
|
1412 TLogId lastId = event->Id(); |
|
1413 |
|
1414 //Add event with Number, Remote Party field set to NULL & Contact set to -1 |
|
1415 active->StartL(); |
|
1416 aClient.AddEvent(*event, active->iStatus); |
|
1417 CActiveScheduler::Start(); |
|
1418 TEST2(active->iStatus.Int(), KErrNone); |
|
1419 |
|
1420 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1421 TEST(res); |
|
1422 active->StartL(); |
|
1423 CActiveScheduler::Start(); |
|
1424 TEST2(active->iStatus.Int(), KErrNone); |
|
1425 |
|
1426 TEST2(view->CountL(), 4); |
|
1427 |
|
1428 res = view->DuplicatesL(*dView, active->iStatus); |
|
1429 TEST(res); |
|
1430 active->StartL(); |
|
1431 CActiveScheduler::Start(); |
|
1432 TEST2(active->iStatus.Int(), KErrNone); |
|
1433 |
|
1434 TEST2(dView->CountL(), 1); |
|
1435 TEST2(dView->Event().Id(), lastId); |
|
1436 |
|
1437 CleanupStack::PopAndDestroy(4); // event, dView, view, active |
|
1438 } |
|
1439 |
|
1440 /** |
|
1441 @SYMTestCaseID SYSLIB-LOGENG-CT-0860 |
|
1442 @SYMTestCaseDesc Tests for CLogViewDuplicate::RemoveL() functions |
|
1443 @SYMTestPriority High |
|
1444 @SYMTestActions Tests for removing the events and test for the count |
|
1445 @SYMTestExpectedResults Test must not fail |
|
1446 @SYMREQ REQ0000 |
|
1447 */ |
|
1448 LOCAL_C void TestDuplicateRemoveL(CLogClient& aClient) |
|
1449 { |
|
1450 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0860 ")); |
|
1451 CTestActive* active = new(ELeave)CTestActive(); |
|
1452 CleanupStack::PushL(active); |
|
1453 |
|
1454 CLogViewRecent* view = CLogViewRecent::NewL(aClient); |
|
1455 CleanupStack::PushL(view); |
|
1456 |
|
1457 CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient); |
|
1458 CleanupStack::PushL(dView); |
|
1459 |
|
1460 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1461 TEST(res); |
|
1462 active->StartL(); |
|
1463 CActiveScheduler::Start(); |
|
1464 TEST2(active->iStatus.Int(), KErrNone); |
|
1465 |
|
1466 //The incoming call list should have count as 4. These calls were added in |
|
1467 //...the previous function named TestDuplicateViewL() |
|
1468 TEST2(view->CountL(), 4); |
|
1469 |
|
1470 res = view->DuplicatesL(*dView, active->iStatus); |
|
1471 TEST(res); |
|
1472 active->StartL(); |
|
1473 CActiveScheduler::Start(); |
|
1474 TEST2(active->iStatus.Int(), KErrNone); |
|
1475 |
|
1476 TLogId id = dView->Event().Id(); |
|
1477 TEST2(dView->CountL(), 1); |
|
1478 |
|
1479 res = dView->RemoveL(active->iStatus); |
|
1480 TEST(!res); |
|
1481 |
|
1482 TEST2(dView->CountL(), 0); |
|
1483 |
|
1484 res = dView->RemoveL(active->iStatus); |
|
1485 TEST(!res); |
|
1486 TEST2(dView->CountL(), 0); |
|
1487 |
|
1488 TEST2(view->CountL(), 4); |
|
1489 |
|
1490 CleanupStack::PopAndDestroy(3); // dView, view, active |
|
1491 } |
|
1492 |
|
1493 /** |
|
1494 @SYMTestCaseID SYSLIB-LOGENG-CT-0861 |
|
1495 @SYMTestCaseDesc Tests for purging on log engine |
|
1496 @SYMTestPriority High |
|
1497 @SYMTestActions Tests for changing the log engine configuration,add event and test for retrieving them back. |
|
1498 Set up a purge which clears the log and reset the log configuration |
|
1499 @SYMTestExpectedResults Test must not fail |
|
1500 @SYMREQ REQ0000 |
|
1501 */ |
|
1502 LOCAL_C void TestPurgeOnSetup1L(CLogClient& aClient) |
|
1503 { |
|
1504 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0861 ")); |
|
1505 CTestActive* active = new(ELeave)CTestActive(); |
|
1506 CleanupStack::PushL(active); |
|
1507 |
|
1508 User::After(0x100000); |
|
1509 |
|
1510 TTime now; |
|
1511 now.UniversalTime(); |
|
1512 |
|
1513 // Clear all the events |
|
1514 active->StartL(); |
|
1515 aClient.ClearLog(now, active->iStatus); |
|
1516 CActiveScheduler::Start(); |
|
1517 TEST2(active->iStatus.Int(), KErrNone); |
|
1518 |
|
1519 CLogEvent* event = CLogEvent::NewL(); |
|
1520 CleanupStack::PushL(event); |
|
1521 event->SetEventType(KLogCallEventTypeUid); |
|
1522 |
|
1523 TLogConfig config; |
|
1524 |
|
1525 // Get log configuration |
|
1526 active->StartL(); |
|
1527 aClient.GetConfig(config, active->iStatus); |
|
1528 CActiveScheduler::Start(); |
|
1529 TEST2(active->iStatus.Int(), KErrNone); |
|
1530 |
|
1531 // Set the maximum log age |
|
1532 TInt oldAge = config.iMaxEventAge; |
|
1533 config.iMaxEventAge = 10; // 10 seconds! |
|
1534 |
|
1535 // Change the log engine config |
|
1536 active->StartL(); |
|
1537 aClient.ChangeConfig(config, active->iStatus); |
|
1538 CActiveScheduler::Start(); |
|
1539 TEST2(active->iStatus.Int(), KErrNone); |
|
1540 |
|
1541 active->StartL(); |
|
1542 aClient.AddEvent(*event, active->iStatus); |
|
1543 CActiveScheduler::Start(); |
|
1544 TEST2(active->iStatus.Int(), KErrNone); |
|
1545 |
|
1546 // Check that the event can be retrieved |
|
1547 active->StartL(); |
|
1548 aClient.GetEvent(*event, active->iStatus); |
|
1549 CActiveScheduler::Start(); |
|
1550 TEST2(active->iStatus.Int(), KErrNone); |
|
1551 |
|
1552 // Wait for 15 seconds (just to be safe) |
|
1553 User::After(15000000); |
|
1554 |
|
1555 // Check that the event can be retrieved |
|
1556 active->StartL(); |
|
1557 aClient.GetEvent(*event, active->iStatus); |
|
1558 CActiveScheduler::Start(); |
|
1559 TEST2(active->iStatus.Int(), KErrNone); |
|
1560 |
|
1561 // Check that the event can still be retrieved |
|
1562 active->StartL(); |
|
1563 aClient.GetEvent(*event, active->iStatus); |
|
1564 CActiveScheduler::Start(); |
|
1565 TEST2(active->iStatus.Int(), KErrNone); |
|
1566 |
|
1567 // Check that the event can still be retrieved |
|
1568 active->StartL(); |
|
1569 aClient.GetEvent(*event, active->iStatus); |
|
1570 CActiveScheduler::Start(); |
|
1571 TEST2(active->iStatus.Int(), KErrNone); |
|
1572 |
|
1573 CLogViewEvent* view = CLogViewEvent::NewL(aClient); |
|
1574 CleanupStack::PushL(view); |
|
1575 |
|
1576 CLogFilter* filter = CLogFilter::NewL(); |
|
1577 CleanupStack::PushL(filter); |
|
1578 |
|
1579 // Setup a view which should purge the event - hence no events in view! |
|
1580 TBool res = view->SetFilterL(*filter, active->iStatus); |
|
1581 TEST(!res); |
|
1582 |
|
1583 // Reset the config |
|
1584 config.iMaxEventAge = oldAge; |
|
1585 |
|
1586 // Change the log engine config |
|
1587 active->StartL(); |
|
1588 aClient.ChangeConfig(config, active->iStatus); |
|
1589 CActiveScheduler::Start(); |
|
1590 TEST2(active->iStatus.Int(), KErrNone); |
|
1591 |
|
1592 CleanupStack::PopAndDestroy(4); // filter, view, active, event |
|
1593 } |
|
1594 |
|
1595 /** |
|
1596 @SYMTestCaseID SYSLIB-LOGENG-CT-0862 |
|
1597 @SYMTestCaseDesc Tests for purging on log engine |
|
1598 @SYMTestPriority High |
|
1599 @SYMTestActions Clear the events from the log,set the log engine age to maximum.Change the configuration,and test adding and retrieving the events. |
|
1600 Set up a purge which clears the log and reset the log configuration |
|
1601 @SYMTestExpectedResults Test must not fail |
|
1602 @SYMREQ REQ0000 |
|
1603 */ |
|
1604 LOCAL_C void TestPurgeOnSetup2L(CLogClient& aClient) |
|
1605 { |
|
1606 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0862 ")); |
|
1607 CTestActive* active1 = new(ELeave)CTestActive(); |
|
1608 CleanupStack::PushL(active1); |
|
1609 |
|
1610 CTestActive* active2 = new(ELeave)CTestActive(); |
|
1611 CleanupStack::PushL(active2); |
|
1612 |
|
1613 User::After(0x100000); |
|
1614 |
|
1615 TTime now; |
|
1616 now.UniversalTime(); |
|
1617 |
|
1618 // Clear all the events |
|
1619 active1->StartL(); |
|
1620 aClient.ClearLog(now, active1->iStatus); |
|
1621 CActiveScheduler::Start(); |
|
1622 TEST2(active1->iStatus.Int(), KErrNone); |
|
1623 |
|
1624 CLogEvent* event = CLogEvent::NewL(); |
|
1625 CleanupStack::PushL(event); |
|
1626 event->SetEventType(KLogCallEventTypeUid); |
|
1627 |
|
1628 TLogConfig config; |
|
1629 |
|
1630 // Get log configuration |
|
1631 active1->StartL(); |
|
1632 aClient.GetConfig(config, active1->iStatus); |
|
1633 CActiveScheduler::Start(); |
|
1634 TEST2(active1->iStatus.Int(), KErrNone); |
|
1635 |
|
1636 // Set the maximum log age |
|
1637 TInt oldAge = config.iMaxEventAge; |
|
1638 config.iMaxEventAge = 10; // 10 seconds! |
|
1639 |
|
1640 // Change the log engine config |
|
1641 active1->StartL(); |
|
1642 aClient.ChangeConfig(config, active1->iStatus); |
|
1643 CActiveScheduler::Start(); |
|
1644 TEST2(active1->iStatus.Int(), KErrNone); |
|
1645 |
|
1646 active1->StartL(); |
|
1647 aClient.AddEvent(*event, active1->iStatus); |
|
1648 CActiveScheduler::Start(); |
|
1649 TEST2(active1->iStatus.Int(), KErrNone); |
|
1650 |
|
1651 // Check that the event can be retrieved |
|
1652 active1->StartL(); |
|
1653 aClient.GetEvent(*event, active1->iStatus); |
|
1654 CActiveScheduler::Start(); |
|
1655 TEST2(active1->iStatus.Int(), KErrNone); |
|
1656 |
|
1657 // Wait for 15 seconds (just to be safe) |
|
1658 User::After(15000000); |
|
1659 |
|
1660 // Check that the event can be retrieved |
|
1661 active1->StartL(); |
|
1662 aClient.GetEvent(*event, active1->iStatus); |
|
1663 CActiveScheduler::Start(); |
|
1664 TEST2(active1->iStatus.Int(), KErrNone); |
|
1665 |
|
1666 // Check that the event can still be retrieved |
|
1667 active1->StartL(); |
|
1668 aClient.GetEvent(*event, active1->iStatus); |
|
1669 CActiveScheduler::Start(); |
|
1670 TEST2(active1->iStatus.Int(), KErrNone); |
|
1671 |
|
1672 // Check that the event can still be retrieved |
|
1673 active1->StartL(); |
|
1674 aClient.GetEvent(*event, active1->iStatus); |
|
1675 CActiveScheduler::Start(); |
|
1676 TEST2(active1->iStatus.Int(), KErrNone); |
|
1677 |
|
1678 CLogViewEvent* view1 = CLogViewEvent::NewL(aClient); |
|
1679 CleanupStack::PushL(view1); |
|
1680 |
|
1681 CLogViewEvent* view2 = CLogViewEvent::NewL(aClient); |
|
1682 CleanupStack::PushL(view2); |
|
1683 |
|
1684 CLogFilter* filter = CLogFilter::NewL(); |
|
1685 CleanupStack::PushL(filter); |
|
1686 |
|
1687 // Setup a view which should purge the event - hence no events in view! |
|
1688 TBool res = view1->SetFilterL(*filter, active1->iStatus); |
|
1689 TEST(!res); |
|
1690 res = view2->SetFilterL(*filter, active2->iStatus); |
|
1691 TEST(!res); |
|
1692 |
|
1693 // Reset the config |
|
1694 config.iMaxEventAge = oldAge; |
|
1695 |
|
1696 // Change the log engine config |
|
1697 active1->StartL(); |
|
1698 aClient.ChangeConfig(config, active1->iStatus); |
|
1699 CActiveScheduler::Start(); |
|
1700 TEST2(active1->iStatus.Int(), KErrNone); |
|
1701 |
|
1702 CleanupStack::PopAndDestroy(6); // filter, view1, view2, active1, active2, event |
|
1703 } |
|
1704 |
|
1705 /** |
|
1706 @SYMTestCaseID SYSLIB-LOGENG-CT-0863 |
|
1707 @SYMTestCaseDesc Tests for purge on CLogViewRecent |
|
1708 @SYMTestPriority High |
|
1709 @SYMTestActions Set the log engine maximum log size and recent log size.Change the configuration and add events to the log |
|
1710 Tests the count to be less than or equal to recent logsize. |
|
1711 @SYMTestExpectedResults Test must not fail |
|
1712 @SYMREQ REQ0000 |
|
1713 */ |
|
1714 LOCAL_C void TestViewPurgeL(CLogClient& aClient) |
|
1715 { |
|
1716 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0863 ")); |
|
1717 CTestActive* active = new(ELeave)CTestActive(); |
|
1718 CleanupStack::PushL(active); |
|
1719 |
|
1720 TLogConfig config; |
|
1721 |
|
1722 aClient.GetConfig(config, active->iStatus); |
|
1723 active->StartL(); |
|
1724 CActiveScheduler::Start(); |
|
1725 TEST2(active->iStatus.Int(), KErrNone); |
|
1726 |
|
1727 TEST2(config.iMaxLogSize, 1000); |
|
1728 TEST(config.iMaxRecentLogSize = 10); |
|
1729 |
|
1730 config.iMaxLogSize = 2000; |
|
1731 config.iMaxRecentLogSize = 20; |
|
1732 |
|
1733 aClient.ChangeConfig(config, active->iStatus); |
|
1734 active->StartL(); |
|
1735 CActiveScheduler::Start(); |
|
1736 TEST2(active->iStatus.Int(), KErrNone); |
|
1737 |
|
1738 CLogEvent* event = CLogEvent::NewL(); |
|
1739 CleanupStack::PushL(event); |
|
1740 |
|
1741 CLogViewRecent* view = CLogViewRecent::NewL(aClient); |
|
1742 CleanupStack::PushL(view); |
|
1743 |
|
1744 // Incoming |
|
1745 TBuf<KLogMaxDirectionLength> buf; |
|
1746 aClient.GetString(buf, R_LOG_DIR_IN); |
|
1747 |
|
1748 event->SetEventType(KLogCallEventTypeUid); |
|
1749 event->SetDirection(buf); |
|
1750 |
|
1751 for(TInt count = 0; count < config.iMaxRecentLogSize * 2; count++) |
|
1752 { |
|
1753 event->SetContact(count); |
|
1754 |
|
1755 active->StartL(); |
|
1756 aClient.AddEvent(*event, active->iStatus); |
|
1757 CActiveScheduler::Start(); |
|
1758 TEST2(active->iStatus.Int(), KErrNone); |
|
1759 |
|
1760 TBool res = view->SetRecentListL(KLogNullRecentList, active->iStatus); |
|
1761 TEST(res); |
|
1762 active->StartL(); |
|
1763 CActiveScheduler::Start(); |
|
1764 TEST2(active->iStatus.Int(), KErrNone); |
|
1765 TEST(view->CountL() <= config.iMaxRecentLogSize); |
|
1766 } |
|
1767 |
|
1768 CleanupStack::PopAndDestroy(3); // active, event, view |
|
1769 } |
|
1770 |
|
1771 /** |
|
1772 @SYMTestCaseID SYSLIB-LOGENG-CT-0864 |
|
1773 @SYMTestCaseDesc Tests for the functionality of CLogViewDuplicate class |
|
1774 @SYMTestPriority High |
|
1775 @SYMTestActions Tests for clearing the duplicate events |
|
1776 @SYMTestExpectedResults Test must not fail |
|
1777 @SYMREQ REQ0000 |
|
1778 */ |
|
1779 LOCAL_C void TestClearDuplicatesL(CLogClient& aClient) |
|
1780 { |
|
1781 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0864 ")); |
|
1782 CTestActive* active = new(ELeave)CTestActive(); |
|
1783 CleanupStack::PushL(active); |
|
1784 |
|
1785 aClient.ClearLog(KLogNullRecentList, active->iStatus); |
|
1786 active->StartL(); |
|
1787 CActiveScheduler::Start(); |
|
1788 TEST2(active->iStatus.Int(), KErrNone); |
|
1789 |
|
1790 CLogViewRecent* view = CLogViewRecent::NewL(aClient); |
|
1791 CleanupStack::PushL(view); |
|
1792 |
|
1793 CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient); |
|
1794 CleanupStack::PushL(dView); |
|
1795 |
|
1796 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1797 TEST(!res); |
|
1798 |
|
1799 TBuf<KLogMaxDirectionLength> incoming; |
|
1800 aClient.GetString(incoming, R_LOG_DIR_IN); |
|
1801 |
|
1802 TBuf<KLogMaxDirectionLength> outgoing; |
|
1803 aClient.GetString(outgoing, R_LOG_DIR_OUT); |
|
1804 |
|
1805 TBuf<KLogMaxDirectionLength> missed; |
|
1806 aClient.GetString(missed, R_LOG_DIR_MISSED); |
|
1807 |
|
1808 CLogEvent* event = CLogEvent::NewL(); |
|
1809 CleanupStack::PushL(event); |
|
1810 |
|
1811 event->SetEventType(KLogCallEventTypeUid); |
|
1812 |
|
1813 // Add 5 recent events to each list - with 5 duplicates each |
|
1814 |
|
1815 // Incoming |
|
1816 event->SetDirection(incoming); |
|
1817 TInt recent; |
|
1818 for(recent = 1; recent <= 5; recent++) |
|
1819 { |
|
1820 event->SetContact(recent); |
|
1821 for(TInt duplicate = 1; duplicate <= 6; duplicate++) |
|
1822 { |
|
1823 active->StartL(); |
|
1824 aClient.AddEvent(*event, active->iStatus); |
|
1825 CActiveScheduler::Start(); |
|
1826 TEST2(active->iStatus.Int(), KErrNone); |
|
1827 } |
|
1828 } |
|
1829 |
|
1830 // Outgoing |
|
1831 event->SetDirection(outgoing); |
|
1832 for(recent = 1; recent <= 5; recent++) |
|
1833 { |
|
1834 event->SetContact(recent); |
|
1835 for(TInt duplicate = 1; duplicate <= 6; duplicate++) |
|
1836 { |
|
1837 active->StartL(); |
|
1838 aClient.AddEvent(*event, active->iStatus); |
|
1839 CActiveScheduler::Start(); |
|
1840 TEST2(active->iStatus.Int(), KErrNone); |
|
1841 } |
|
1842 } |
|
1843 |
|
1844 // Missed |
|
1845 event->SetDirection(missed); |
|
1846 for(recent = 1; recent <= 5; recent++) |
|
1847 { |
|
1848 event->SetContact(recent); |
|
1849 for(TInt duplicate = 1; duplicate <= 6; duplicate++) |
|
1850 { |
|
1851 active->StartL(); |
|
1852 aClient.AddEvent(*event, active->iStatus); |
|
1853 CActiveScheduler::Start(); |
|
1854 TEST2(active->iStatus.Int(), KErrNone); |
|
1855 } |
|
1856 } |
|
1857 |
|
1858 // Check outgoing |
|
1859 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); |
|
1860 TEST(res); |
|
1861 TEST2(view->CountL(), 5); |
|
1862 |
|
1863 do |
|
1864 { |
|
1865 active->StartL(); |
|
1866 CActiveScheduler::Start(); |
|
1867 TEST2(active->iStatus.Int(), KErrNone); |
|
1868 |
|
1869 res = view->DuplicatesL(*dView, active->iStatus); |
|
1870 TEST(res); |
|
1871 TEST2(dView->CountL(), 5); |
|
1872 active->StartL(); |
|
1873 CActiveScheduler::Start(); |
|
1874 TEST2(active->iStatus.Int(), KErrNone); |
|
1875 } |
|
1876 while(view->NextL(active->iStatus)); |
|
1877 |
|
1878 // Check missed |
|
1879 res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus); |
|
1880 TEST(res); |
|
1881 TEST2(view->CountL(), 5); |
|
1882 |
|
1883 do |
|
1884 { |
|
1885 active->StartL(); |
|
1886 CActiveScheduler::Start(); |
|
1887 TEST2(active->iStatus.Int(), KErrNone); |
|
1888 |
|
1889 res = view->DuplicatesL(*dView, active->iStatus); |
|
1890 TEST(res); |
|
1891 TEST2(dView->CountL(), 5); |
|
1892 active->StartL(); |
|
1893 CActiveScheduler::Start(); |
|
1894 TEST2(active->iStatus.Int(), KErrNone); |
|
1895 } |
|
1896 while(view->NextL(active->iStatus)); |
|
1897 |
|
1898 // Check incoming |
|
1899 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1900 TEST(res); |
|
1901 TEST2(view->CountL(), 5); |
|
1902 |
|
1903 do |
|
1904 { |
|
1905 active->StartL(); |
|
1906 CActiveScheduler::Start(); |
|
1907 TEST2(active->iStatus.Int(), KErrNone); |
|
1908 |
|
1909 res = view->DuplicatesL(*dView, active->iStatus); |
|
1910 TEST(res); |
|
1911 TEST2(dView->CountL(), 5); |
|
1912 active->StartL(); |
|
1913 CActiveScheduler::Start(); |
|
1914 TEST2(active->iStatus.Int(), KErrNone); |
|
1915 } |
|
1916 while(view->NextL(active->iStatus)); |
|
1917 |
|
1918 // Clear duplicates for incoming |
|
1919 view->ClearDuplicatesL(); |
|
1920 TEST2(view->CountL(), 5); |
|
1921 |
|
1922 // Recent list should be unchanged |
|
1923 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1924 TEST(res); |
|
1925 TEST2(view->CountL(), 5); |
|
1926 |
|
1927 do |
|
1928 { |
|
1929 active->StartL(); |
|
1930 CActiveScheduler::Start(); |
|
1931 TEST2(active->iStatus.Int(), KErrNone); |
|
1932 |
|
1933 // No duplicates should exist for this view now |
|
1934 res = view->DuplicatesL(*dView, active->iStatus); |
|
1935 TEST(!res); |
|
1936 TEST2(dView->CountL(), 0); |
|
1937 } |
|
1938 while(view->NextL(active->iStatus)); |
|
1939 |
|
1940 // Check outgoing is unchanged |
|
1941 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); |
|
1942 TEST(res); |
|
1943 TEST2(view->CountL(), 5); |
|
1944 |
|
1945 do |
|
1946 { |
|
1947 active->StartL(); |
|
1948 CActiveScheduler::Start(); |
|
1949 TEST2(active->iStatus.Int(), KErrNone); |
|
1950 |
|
1951 res = view->DuplicatesL(*dView, active->iStatus); |
|
1952 TEST(res); |
|
1953 TEST2(dView->CountL(), 5); |
|
1954 active->StartL(); |
|
1955 CActiveScheduler::Start(); |
|
1956 TEST2(active->iStatus.Int(), KErrNone); |
|
1957 } |
|
1958 while(view->NextL(active->iStatus)); |
|
1959 |
|
1960 // Check missed is unchanged |
|
1961 res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus); |
|
1962 TEST(res); |
|
1963 TEST2(view->CountL(), 5); |
|
1964 |
|
1965 do |
|
1966 { |
|
1967 active->StartL(); |
|
1968 CActiveScheduler::Start(); |
|
1969 TEST2(active->iStatus.Int(), KErrNone); |
|
1970 |
|
1971 res = view->DuplicatesL(*dView, active->iStatus); |
|
1972 TEST(res); |
|
1973 TEST2(dView->CountL(), 5); |
|
1974 active->StartL(); |
|
1975 CActiveScheduler::Start(); |
|
1976 TEST2(active->iStatus.Int(), KErrNone); |
|
1977 } |
|
1978 while(view->NextL(active->iStatus)); |
|
1979 |
|
1980 // Clear duplicates for missed |
|
1981 view->ClearDuplicatesL(); |
|
1982 TEST2(view->CountL(), 5); |
|
1983 |
|
1984 // Recent list should be unchanged |
|
1985 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
1986 TEST(res); |
|
1987 TEST2(view->CountL(), 5); |
|
1988 |
|
1989 do |
|
1990 { |
|
1991 active->StartL(); |
|
1992 CActiveScheduler::Start(); |
|
1993 TEST2(active->iStatus.Int(), KErrNone); |
|
1994 |
|
1995 // No duplicates should exist for this view now |
|
1996 res = view->DuplicatesL(*dView, active->iStatus); |
|
1997 TEST(!res); |
|
1998 TEST2(dView->CountL(), 0); |
|
1999 } |
|
2000 while(view->NextL(active->iStatus)); |
|
2001 |
|
2002 // Missed recent list should be unchanged |
|
2003 res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus); |
|
2004 TEST(res); |
|
2005 TEST2(view->CountL(), 5); |
|
2006 |
|
2007 do |
|
2008 { |
|
2009 active->StartL(); |
|
2010 CActiveScheduler::Start(); |
|
2011 TEST2(active->iStatus.Int(), KErrNone); |
|
2012 |
|
2013 // No duplicates should exist for this view now |
|
2014 res = view->DuplicatesL(*dView, active->iStatus); |
|
2015 TEST(!res); |
|
2016 TEST2(dView->CountL(), 0); |
|
2017 } |
|
2018 while(view->NextL(active->iStatus)); |
|
2019 |
|
2020 // Check outgoing is unchanged |
|
2021 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); |
|
2022 TEST(res); |
|
2023 TEST2(view->CountL(), 5); |
|
2024 |
|
2025 do |
|
2026 { |
|
2027 active->StartL(); |
|
2028 CActiveScheduler::Start(); |
|
2029 TEST2(active->iStatus.Int(), KErrNone); |
|
2030 |
|
2031 res = view->DuplicatesL(*dView, active->iStatus); |
|
2032 TEST(res); |
|
2033 TEST2(dView->CountL(), 5); |
|
2034 active->StartL(); |
|
2035 CActiveScheduler::Start(); |
|
2036 TEST2(active->iStatus.Int(), KErrNone); |
|
2037 } |
|
2038 while(view->NextL(active->iStatus)); |
|
2039 |
|
2040 // Clear duplicates for outgoing |
|
2041 view->ClearDuplicatesL(); |
|
2042 TEST2(view->CountL(), 5); |
|
2043 |
|
2044 // Recent list should be unchanged |
|
2045 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
2046 TEST(res); |
|
2047 TEST2(view->CountL(), 5); |
|
2048 |
|
2049 do |
|
2050 { |
|
2051 active->StartL(); |
|
2052 CActiveScheduler::Start(); |
|
2053 TEST2(active->iStatus.Int(), KErrNone); |
|
2054 |
|
2055 // No duplicates should exist for this view now |
|
2056 res = view->DuplicatesL(*dView, active->iStatus); |
|
2057 TEST(!res); |
|
2058 TEST2(dView->CountL(), 0); |
|
2059 } |
|
2060 while(view->NextL(active->iStatus)); |
|
2061 |
|
2062 // Missed recent list should be unchanged |
|
2063 res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus); |
|
2064 TEST(res); |
|
2065 TEST2(view->CountL(), 5); |
|
2066 |
|
2067 do |
|
2068 { |
|
2069 active->StartL(); |
|
2070 CActiveScheduler::Start(); |
|
2071 TEST2(active->iStatus.Int(), KErrNone); |
|
2072 |
|
2073 // No duplicates should exist for this view now |
|
2074 res = view->DuplicatesL(*dView, active->iStatus); |
|
2075 TEST(!res); |
|
2076 TEST2(dView->CountL(), 0); |
|
2077 } |
|
2078 while(view->NextL(active->iStatus)); |
|
2079 |
|
2080 // Check outgoing is unchanged |
|
2081 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); |
|
2082 TEST(res); |
|
2083 TEST2(view->CountL(), 5); |
|
2084 |
|
2085 do |
|
2086 { |
|
2087 active->StartL(); |
|
2088 CActiveScheduler::Start(); |
|
2089 TEST2(active->iStatus.Int(), KErrNone); |
|
2090 |
|
2091 // No duplicates should exist for this view now |
|
2092 res = view->DuplicatesL(*dView, active->iStatus); |
|
2093 TEST(!res); |
|
2094 TEST2(dView->CountL(), 0); |
|
2095 } |
|
2096 while(view->NextL(active->iStatus)); |
|
2097 |
|
2098 CleanupStack::PopAndDestroy(4); // event, dView, view, active |
|
2099 } |
|
2100 |
|
2101 /** |
|
2102 @SYMTestCaseID SYSLIB-LOGENG-CT-0865 |
|
2103 @SYMTestCaseDesc Test for the functionality of CLogViewEvent class |
|
2104 @SYMTestPriority High |
|
2105 @SYMTestActions Set an event with a number,add the event to the client.Tests for matching a number from the view |
|
2106 @SYMTestExpectedResults Test must not fail |
|
2107 @SYMREQ REQ0000 |
|
2108 */ |
|
2109 LOCAL_C void TestPhoneNumberMatchingL(CLogClient& aClient) |
|
2110 { |
|
2111 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0865 ")); |
|
2112 TestUtils::DeleteDatabaseL(); |
|
2113 |
|
2114 CTestActive* active = new(ELeave)CTestActive(); |
|
2115 CleanupStack::PushL(active); |
|
2116 |
|
2117 CLogEvent* event = CLogEvent::NewL(); |
|
2118 CleanupStack::PushL(event); |
|
2119 |
|
2120 event->SetEventType(KLogCallEventTypeUid); |
|
2121 TBuf<KLogMaxDirectionLength> missed; |
|
2122 aClient.GetString(missed, R_LOG_DIR_MISSED); |
|
2123 event->SetDirection(missed); |
|
2124 |
|
2125 TLogString number; |
|
2126 TInt i; |
|
2127 for(i = 0; i < 10; i++) |
|
2128 { |
|
2129 TBuf<1> digit; |
|
2130 digit.Num(i); |
|
2131 number.Insert(0, digit); |
|
2132 event->SetNumber(number); |
|
2133 |
|
2134 aClient.AddEvent(*event, active->iStatus); |
|
2135 active->StartL(); |
|
2136 CActiveScheduler::Start(); |
|
2137 TEST2(active->iStatus.Int(), KErrNone); |
|
2138 } |
|
2139 |
|
2140 CLogFilter* filter = CLogFilter::NewL(); |
|
2141 CleanupStack::PushL(filter); |
|
2142 |
|
2143 CLogViewEvent* view = CLogViewEvent::NewL(aClient); |
|
2144 CleanupStack::PushL(view); |
|
2145 |
|
2146 TBool res = view->SetFilterL(*filter, active->iStatus); |
|
2147 TEST(res); |
|
2148 active->StartL(); |
|
2149 CActiveScheduler::Start(); |
|
2150 TEST2(active->iStatus.Int(), KErrNone); |
|
2151 TEST2(view->CountL(), 10); |
|
2152 |
|
2153 number.Zero(); |
|
2154 for(i = 0; i < 10; i++) |
|
2155 { |
|
2156 TBuf<1> digit; |
|
2157 digit.Num(i); |
|
2158 number.Insert(0, digit); |
|
2159 filter->SetNumber(number); |
|
2160 |
|
2161 // This is testing phone number matching |
|
2162 res = view->SetFilterL(*filter, active->iStatus); |
|
2163 TEST(res); |
|
2164 active->StartL(); |
|
2165 CActiveScheduler::Start(); |
|
2166 TEST2(active->iStatus.Int(), KErrNone); |
|
2167 |
|
2168 // Phone numbers with KTestLogNumberCharsToMatch characters or above can match with each other |
|
2169 TEST2(view->CountL(), (number.Length() < KTestLogNumberCharsToMatch) ? 1 : 11-KTestLogNumberCharsToMatch); |
|
2170 } |
|
2171 |
|
2172 CLogViewRecent* recent = CLogViewRecent::NewL(aClient); |
|
2173 CleanupStack::PushL(recent); |
|
2174 |
|
2175 CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient); |
|
2176 CleanupStack::PushL(duplicate); |
|
2177 |
|
2178 res = recent->SetRecentListL(KLogRecentMissedCalls, active->iStatus); |
|
2179 TEST(res); |
|
2180 active->StartL(); |
|
2181 CActiveScheduler::Start(); |
|
2182 TEST2(active->iStatus.Int(), KErrNone); |
|
2183 TEST2(recent->CountL(), KTestLogNumberCharsToMatch); |
|
2184 |
|
2185 res = recent->DuplicatesL(*duplicate, active->iStatus); |
|
2186 TEST(res); |
|
2187 TEST2(duplicate->CountL(), 10-KTestLogNumberCharsToMatch); |
|
2188 |
|
2189 // Check the first recent event has duplicates |
|
2190 do |
|
2191 { |
|
2192 active->StartL(); |
|
2193 CActiveScheduler::Start(); |
|
2194 TEST2(active->iStatus.Int(), KErrNone); |
|
2195 |
|
2196 TPtrC number1(recent->Event().Number().Right(KTestLogNumberCharsToMatch)); |
|
2197 TPtrC number2(duplicate->Event().Number().Right(KTestLogNumberCharsToMatch)); |
|
2198 TEST(number1 == number2); |
|
2199 } |
|
2200 while(duplicate->NextL(active->iStatus)); |
|
2201 |
|
2202 // Check none of the others have duplicates |
|
2203 while(recent->NextL(active->iStatus)) |
|
2204 { |
|
2205 active->StartL(); |
|
2206 CActiveScheduler::Start(); |
|
2207 TEST2(active->iStatus.Int(), KErrNone); |
|
2208 res = recent->DuplicatesL(*duplicate, active->iStatus); |
|
2209 TEST(!res); |
|
2210 } |
|
2211 |
|
2212 CleanupStack::PopAndDestroy(6); // duplicate, recent, view, filter, event, active |
|
2213 } |
|
2214 |
|
2215 /** |
|
2216 @SYMTestCaseID SYSLIB-LOGENG-CT-3472 |
|
2217 @SYMTestCaseDesc Tests duplicate number matching correctly compares and matches the last 9 digits |
|
2218 @SYMTestPriority High |
|
2219 @SYMTestActions Create and add several numbers to client, check that duplicates are correctly removed |
|
2220 @SYMTestExpectedResults Number with the same last 9 digits should get matched as duplicates |
|
2221 @SYMDEF INC105010 |
|
2222 */ |
|
2223 LOCAL_C void INC105010L(CLogClient& aClient) |
|
2224 { |
|
2225 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-3472 ")); |
|
2226 TestUtils::DeleteDatabaseL(); |
|
2227 |
|
2228 CTestActive* active = new(ELeave)CTestActive(); |
|
2229 CleanupStack::PushL(active); |
|
2230 |
|
2231 CLogEvent* event = CLogEvent::NewL(); |
|
2232 CleanupStack::PushL(event); |
|
2233 |
|
2234 event->SetEventType(KLogCallEventTypeUid); |
|
2235 TBuf<KLogMaxDirectionLength> missed; |
|
2236 aClient.GetString(missed, R_LOG_DIR_MISSED); |
|
2237 event->SetDirection(missed); |
|
2238 |
|
2239 _LIT(KTestNumber1, "0401234567"); // unique |
|
2240 _LIT(KTestNumber2, "0421234567"); // unique |
|
2241 _LIT(KTestNumber3, "0521234567"); // unique |
|
2242 _LIT(KTestNumber4, "9521234567"); // duplicate |
|
2243 _LIT(KTestNumber5, "9521234567"); // duplicate |
|
2244 |
|
2245 TLogString number; |
|
2246 |
|
2247 // add events for the above numbers |
|
2248 event->SetNumber(KTestNumber1); |
|
2249 aClient.AddEvent(*event, active->iStatus); |
|
2250 active->StartL(); |
|
2251 CActiveScheduler::Start(); |
|
2252 TEST2(active->iStatus.Int(), KErrNone); |
|
2253 |
|
2254 event->SetNumber(KTestNumber2); |
|
2255 aClient.AddEvent(*event, active->iStatus); |
|
2256 active->StartL(); |
|
2257 CActiveScheduler::Start(); |
|
2258 TEST2(active->iStatus.Int(), KErrNone); |
|
2259 |
|
2260 event->SetNumber(KTestNumber3); |
|
2261 aClient.AddEvent(*event, active->iStatus); |
|
2262 active->StartL(); |
|
2263 CActiveScheduler::Start(); |
|
2264 TEST2(active->iStatus.Int(), KErrNone); |
|
2265 |
|
2266 event->SetNumber(KTestNumber4); |
|
2267 aClient.AddEvent(*event, active->iStatus); |
|
2268 active->StartL(); |
|
2269 CActiveScheduler::Start(); |
|
2270 TEST2(active->iStatus.Int(), KErrNone); |
|
2271 |
|
2272 event->SetNumber(KTestNumber5); |
|
2273 aClient.AddEvent(*event, active->iStatus); |
|
2274 active->StartL(); |
|
2275 CActiveScheduler::Start(); |
|
2276 TEST2(active->iStatus.Int(), KErrNone); |
|
2277 |
|
2278 CLogFilter* filter = CLogFilter::NewL(); |
|
2279 CleanupStack::PushL(filter); |
|
2280 |
|
2281 CLogViewEvent* view = CLogViewEvent::NewL(aClient); |
|
2282 CleanupStack::PushL(view); |
|
2283 |
|
2284 // check 5 entries in log |
|
2285 TBool res = view->SetFilterL(*filter, active->iStatus); |
|
2286 TEST(res); |
|
2287 active->StartL(); |
|
2288 CActiveScheduler::Start(); |
|
2289 TEST2(active->iStatus.Int(), KErrNone); |
|
2290 TEST2(view->CountL(), 5); |
|
2291 |
|
2292 CLogViewRecent* recent = CLogViewRecent::NewL(aClient); |
|
2293 CleanupStack::PushL(recent); |
|
2294 |
|
2295 CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient); |
|
2296 CleanupStack::PushL(duplicate); |
|
2297 |
|
2298 // check only 3 entries in recent calls view |
|
2299 res = recent->SetRecentListL(KLogRecentMissedCalls, active->iStatus); |
|
2300 TEST(res); |
|
2301 active->StartL(); |
|
2302 CActiveScheduler::Start(); |
|
2303 TEST2(active->iStatus.Int(), KErrNone); |
|
2304 TInt rrr = recent->CountL(); |
|
2305 TEST2(recent->CountL(), 3); |
|
2306 |
|
2307 // and that there are 2 duplicates |
|
2308 res = recent->DuplicatesL(*duplicate, active->iStatus); |
|
2309 TEST(res); |
|
2310 active->StartL(); |
|
2311 CActiveScheduler::Start(); |
|
2312 TEST2(active->iStatus.Int(), KErrNone); |
|
2313 |
|
2314 TInt ddd = duplicate->CountL(); |
|
2315 TEST2(duplicate->CountL(), 2); |
|
2316 |
|
2317 CleanupStack::PopAndDestroy(6); |
|
2318 } |
|
2319 |
|
2320 |
|
2321 |
|
2322 /** |
|
2323 @SYMTestCaseID SYSLIB-LOGENG-CT-0866 |
|
2324 @SYMTestCaseDesc Tests for CLogViewEvent::SetFlagsL() function |
|
2325 @SYMTestPriority High |
|
2326 @SYMTestActions Add events to the log and set the flags.Check if all the flags are set. |
|
2327 Clear all the flags and set half view of the flags.Check if only all view of the flags are set. |
|
2328 @SYMTestExpectedResults Test must not fail |
|
2329 @SYMREQ REQ0000 |
|
2330 */ |
|
2331 LOCAL_C void TestRecentFlagsL(CLogClient& aClient) |
|
2332 { |
|
2333 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0866 ")); |
|
2334 TestUtils::DeleteDatabaseL(); |
|
2335 |
|
2336 CLogEvent* event = CLogEvent::NewL(); |
|
2337 CleanupStack::PushL(event); |
|
2338 |
|
2339 CTestActive* active = new(ELeave)CTestActive(); |
|
2340 CleanupStack::PushL(active); |
|
2341 |
|
2342 CLogViewRecent* view = CLogViewRecent::NewL(aClient); |
|
2343 CleanupStack::PushL(view); |
|
2344 |
|
2345 // Incoming |
|
2346 TBuf<KLogMaxDirectionLength> buf; |
|
2347 aClient.GetString(buf, R_LOG_DIR_IN); |
|
2348 |
|
2349 event->SetEventType(KLogCallEventTypeUid); |
|
2350 event->SetDirection(buf); |
|
2351 |
|
2352 TInt count; |
|
2353 for(count = 0; count < KTestEventNum; count++) |
|
2354 { |
|
2355 event->SetContact(count); |
|
2356 |
|
2357 active->StartL(); |
|
2358 aClient.AddEvent(*event, active->iStatus); |
|
2359 CActiveScheduler::Start(); |
|
2360 TEST2(active->iStatus.Int(), KErrNone); |
|
2361 } |
|
2362 |
|
2363 TEST2(view->CountL(), 0); |
|
2364 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
2365 TEST(res); |
|
2366 active->StartL(); |
|
2367 CActiveScheduler::Start(); |
|
2368 TEST2(active->iStatus.Int(), KErrNone); |
|
2369 TEST2(view->CountL(), KTestEventNum); |
|
2370 |
|
2371 // Set all flags in view |
|
2372 const TLogFlags KAllFlagsSet = 15; // (BIN) 1,1,1,1 |
|
2373 view->SetFlagsL(KAllFlagsSet); |
|
2374 |
|
2375 // Check we can move to the first record |
|
2376 res = view->FirstL(active->iStatus); |
|
2377 TEST(res); |
|
2378 |
|
2379 // Check all flags are now set |
|
2380 count = KTestEventNum; |
|
2381 do { |
|
2382 active->StartL(); |
|
2383 CActiveScheduler::Start(); |
|
2384 TEST2(active->iStatus.Int(), KErrNone); |
|
2385 // |
|
2386 TEST2(view->CountL(), KTestEventNum); |
|
2387 TEST2(view->RecentList(), KLogRecentIncomingCalls); |
|
2388 // |
|
2389 const TLogFlags flags = view->Event().Flags(); |
|
2390 TEST2(flags, KAllFlagsSet); |
|
2391 count--; |
|
2392 } |
|
2393 while(view->NextL(active->iStatus)); |
|
2394 |
|
2395 TEST2(count, 0); |
|
2396 TEST2(view->CountL(), KTestEventNum); |
|
2397 |
|
2398 // Clear all flags in view |
|
2399 const TLogFlags KAllFlagsCleared = 0; // (BIN) 0,0,0,0 |
|
2400 view->SetFlagsL(KAllFlagsCleared); |
|
2401 TEST2(view->CountL(), KTestEventNum); |
|
2402 |
|
2403 // Check we can move to the first record |
|
2404 res = view->FirstL(active->iStatus); |
|
2405 TEST(res); |
|
2406 |
|
2407 // Check all flags are now set |
|
2408 count = KTestEventNum; |
|
2409 do { |
|
2410 active->StartL(); |
|
2411 CActiveScheduler::Start(); |
|
2412 TEST2(active->iStatus.Int(), KErrNone); |
|
2413 // |
|
2414 TEST2(view->CountL(), KTestEventNum); |
|
2415 TEST2(view->RecentList(), KLogRecentIncomingCalls); |
|
2416 // |
|
2417 const TLogFlags flags = view->Event().Flags(); |
|
2418 TEST2(flags, KAllFlagsCleared); |
|
2419 count--; |
|
2420 } |
|
2421 while(view->NextL(active->iStatus)); |
|
2422 |
|
2423 TEST2(count, 0); |
|
2424 TEST2(view->CountL(), KTestEventNum); |
|
2425 |
|
2426 // Set lower half flags in view |
|
2427 const TLogFlags KLowerHalfFlagsSet = 3; // (BIN) 1,1,0,0 |
|
2428 view->SetFlagsL(KLowerHalfFlagsSet); |
|
2429 |
|
2430 // Check we can move to the first record |
|
2431 res = view->FirstL(active->iStatus); |
|
2432 TEST(res); |
|
2433 |
|
2434 // Check all flags are now set |
|
2435 count = KTestEventNum; |
|
2436 do { |
|
2437 active->StartL(); |
|
2438 CActiveScheduler::Start(); |
|
2439 TEST2(active->iStatus.Int(), KErrNone); |
|
2440 // |
|
2441 TEST2(view->CountL(), KTestEventNum); |
|
2442 TEST2(view->RecentList(), KLogRecentIncomingCalls); |
|
2443 // |
|
2444 const TLogFlags flags = view->Event().Flags(); |
|
2445 TEST2(flags, KLowerHalfFlagsSet); |
|
2446 count--; |
|
2447 } |
|
2448 while(view->NextL(active->iStatus)); |
|
2449 |
|
2450 TEST2(count, 0); |
|
2451 TEST2(view->CountL(), KTestEventNum); |
|
2452 |
|
2453 CleanupStack::PopAndDestroy(3, event); // view, active, event |
|
2454 } |
|
2455 |
|
2456 /** |
|
2457 @SYMTestCaseID SYSLIB-LOGENG-CT-0867 |
|
2458 @SYMTestCaseDesc Tests for CLogViewEvent::SetFlagsL() function |
|
2459 @SYMTestPriority High |
|
2460 @SYMTestActions Add events to the log and set the flags.Check if flags for only the events in view are set. |
|
2461 @SYMTestExpectedResults Test must not fail |
|
2462 @SYMREQ REQ0000 |
|
2463 */ |
|
2464 LOCAL_C void TestViewFlagsL(CLogClient& aClient) |
|
2465 { |
|
2466 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0867 ")); |
|
2467 TestUtils::DeleteDatabaseL(); |
|
2468 |
|
2469 CLogEvent* event = CLogEvent::NewL(); |
|
2470 CleanupStack::PushL(event); |
|
2471 |
|
2472 CTestActive* active = new(ELeave)CTestActive(); |
|
2473 CleanupStack::PushL(active); |
|
2474 |
|
2475 CLogViewEvent* view = CLogViewEvent::NewL(aClient); |
|
2476 CleanupStack::PushL(view); |
|
2477 |
|
2478 // Incoming |
|
2479 TBuf<KLogMaxDirectionLength> buf; |
|
2480 aClient.GetString(buf, R_LOG_DIR_IN); |
|
2481 |
|
2482 event->SetEventType(KLogCallEventTypeUid); |
|
2483 event->SetDirection(buf); |
|
2484 |
|
2485 event->SetNumber(_L("123")); |
|
2486 active->StartL(); |
|
2487 aClient.AddEvent(*event, active->iStatus); |
|
2488 CActiveScheduler::Start(); |
|
2489 TEST2(active->iStatus.Int(), KErrNone); |
|
2490 TLogId testId = event->Id(); |
|
2491 event->SetNumber(KNullDesC); |
|
2492 |
|
2493 TInt count; |
|
2494 for(count = 0; count < KTestEventNum; count++) |
|
2495 { |
|
2496 event->SetContact(count + 1); |
|
2497 |
|
2498 active->StartL(); |
|
2499 aClient.AddEvent(*event, active->iStatus); |
|
2500 CActiveScheduler::Start(); |
|
2501 TEST2(active->iStatus.Int(), KErrNone); |
|
2502 } |
|
2503 |
|
2504 TEST2(view->CountL(), 0); |
|
2505 |
|
2506 CLogFilter* filter = CLogFilter::NewL(); |
|
2507 CleanupStack::PushL(filter); |
|
2508 filter->SetNullFields(ELogNumberField); |
|
2509 |
|
2510 TEST2(view->CountL(), 0); |
|
2511 TBool res = view->SetFilterL(*filter, active->iStatus); |
|
2512 TEST(res); |
|
2513 active->StartL(); |
|
2514 CActiveScheduler::Start(); |
|
2515 TEST2(active->iStatus.Int(), KErrNone); |
|
2516 TEST2(view->CountL(), KTestEventNum); |
|
2517 |
|
2518 // Set all flags in view |
|
2519 const TLogFlags KAllFlagsSet = 15; // (BIN) 1,1,1,1 |
|
2520 view->SetFlagsL(KAllFlagsSet); |
|
2521 |
|
2522 // Check flags only set for events in the view |
|
2523 active->StartL(); |
|
2524 event->SetId(testId); |
|
2525 aClient.GetEvent(*event, active->iStatus); |
|
2526 CActiveScheduler::Start(); |
|
2527 TEST2(active->iStatus.Int(), KErrNone); |
|
2528 if( TheMatchingIsEnabled) |
|
2529 { |
|
2530 TEST2(event->Flags(), KLogEventContactSearched); |
|
2531 } |
|
2532 else |
|
2533 { |
|
2534 TEST2(event->Flags(), 0); |
|
2535 } |
|
2536 |
|
2537 // Check we can move to the first record |
|
2538 res = view->FirstL(active->iStatus); |
|
2539 TEST(res); |
|
2540 |
|
2541 // Check all flags are now set |
|
2542 count = KTestEventNum; |
|
2543 do { |
|
2544 active->StartL(); |
|
2545 CActiveScheduler::Start(); |
|
2546 TEST2(active->iStatus.Int(), KErrNone); |
|
2547 // |
|
2548 TEST2(view->CountL(), KTestEventNum); |
|
2549 // |
|
2550 const TLogFlags flags = view->Event().Flags(); |
|
2551 TEST2(flags, KAllFlagsSet); |
|
2552 count--; |
|
2553 } |
|
2554 while(view->NextL(active->iStatus)); |
|
2555 |
|
2556 TEST2(count, 0); |
|
2557 TEST2(view->CountL(), KTestEventNum); |
|
2558 |
|
2559 // Clear all flags in view |
|
2560 const TLogFlags KAllFlagsCleared = 0; // (BIN) 0,0,0,0 |
|
2561 view->SetFlagsL(KAllFlagsCleared); |
|
2562 TEST2(view->CountL(), KTestEventNum); |
|
2563 |
|
2564 // Check flags only set for events in the view |
|
2565 active->StartL(); |
|
2566 event->SetId(testId); |
|
2567 aClient.GetEvent(*event, active->iStatus); |
|
2568 CActiveScheduler::Start(); |
|
2569 TEST2(active->iStatus.Int(), KErrNone); |
|
2570 if( TheMatchingIsEnabled) |
|
2571 { |
|
2572 TEST2(event->Flags(), KLogEventContactSearched); |
|
2573 } |
|
2574 else |
|
2575 { |
|
2576 TEST2(event->Flags(), 0); |
|
2577 } |
|
2578 |
|
2579 // Check we can move to the first record |
|
2580 res = view->FirstL(active->iStatus); |
|
2581 TEST(res); |
|
2582 |
|
2583 // Check all flags are now set |
|
2584 count = KTestEventNum; |
|
2585 do { |
|
2586 active->StartL(); |
|
2587 CActiveScheduler::Start(); |
|
2588 TEST2(active->iStatus.Int(), KErrNone); |
|
2589 // |
|
2590 TEST2(view->CountL(), KTestEventNum); |
|
2591 // |
|
2592 const TLogFlags flags = view->Event().Flags(); |
|
2593 TEST2(flags, KAllFlagsCleared); |
|
2594 count--; |
|
2595 } |
|
2596 while(view->NextL(active->iStatus)); |
|
2597 |
|
2598 TEST2(count, 0); |
|
2599 TEST2(view->CountL(), KTestEventNum); |
|
2600 |
|
2601 // Set lower half flags in view |
|
2602 const TLogFlags KLowerHalfFlagsSet = 3; // (BIN) 1,1,0,0 |
|
2603 view->SetFlagsL(KLowerHalfFlagsSet); |
|
2604 |
|
2605 // Check flags only set for events in the view |
|
2606 active->StartL(); |
|
2607 event->SetId(testId); |
|
2608 aClient.GetEvent(*event, active->iStatus); |
|
2609 CActiveScheduler::Start(); |
|
2610 TEST2(active->iStatus.Int(), KErrNone); |
|
2611 if( TheMatchingIsEnabled) |
|
2612 { |
|
2613 TEST2(event->Flags(), KLogEventContactSearched); |
|
2614 } |
|
2615 else |
|
2616 { |
|
2617 TEST2(event->Flags(), 0); |
|
2618 } |
|
2619 |
|
2620 // Check we can move to the first record |
|
2621 res = view->FirstL(active->iStatus); |
|
2622 TEST(res); |
|
2623 |
|
2624 // Check all flags are now set |
|
2625 count = KTestEventNum; |
|
2626 do { |
|
2627 active->StartL(); |
|
2628 CActiveScheduler::Start(); |
|
2629 TEST2(active->iStatus.Int(), KErrNone); |
|
2630 // |
|
2631 TEST2(view->CountL(), KTestEventNum); |
|
2632 // |
|
2633 const TLogFlags flags = view->Event().Flags(); |
|
2634 TEST2(flags, KLowerHalfFlagsSet); |
|
2635 count--; |
|
2636 } |
|
2637 while(view->NextL(active->iStatus)); |
|
2638 |
|
2639 TEST2(count, 0); |
|
2640 TEST2(view->CountL(), KTestEventNum); |
|
2641 |
|
2642 CleanupStack::PopAndDestroy(4, event); // filter, view, active, event |
|
2643 } |
|
2644 |
|
2645 /** |
|
2646 @SYMTestCaseID SYSLIB-LOGENG-CT-0868 |
|
2647 @SYMTestCaseDesc Tests for CLogViewChangeObserver::HaveChanges(),Changes() functions |
|
2648 @SYMTestPriority High |
|
2649 @SYMTestActions Check for observing changes while adding and deleting events |
|
2650 @SYMTestExpectedResults Test must not fail |
|
2651 @SYMREQ REQ0000 |
|
2652 */ |
|
2653 LOCAL_C void TestViewChangeEvents1L(CLogClient& aClient) |
|
2654 { |
|
2655 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0868 ")); |
|
2656 TestUtils::DeleteDatabaseL(); |
|
2657 |
|
2658 CLogEvent* event = CLogEvent::NewL(); |
|
2659 CleanupStack::PushL(event); |
|
2660 |
|
2661 CLogFilter* filter = CLogFilter::NewL(); |
|
2662 CleanupStack::PushL(filter); |
|
2663 filter->SetContact(KTestContact); |
|
2664 filter->SetEventType(KLogPacketDataEventTypeUid); |
|
2665 |
|
2666 CTestActive* active = new(ELeave)CTestActive(); |
|
2667 CleanupStack::PushL(active); |
|
2668 |
|
2669 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); |
|
2670 changeObs->SetActive(); |
|
2671 |
|
2672 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); |
|
2673 CleanupStack::PushL(view); |
|
2674 |
|
2675 // Incoming |
|
2676 TBuf<KLogMaxDirectionLength> buf; |
|
2677 aClient.GetString(buf, R_LOG_DIR_IN); |
|
2678 |
|
2679 event->SetEventType(KLogPacketDataEventTypeUid); |
|
2680 event->SetDirection(buf); |
|
2681 event->SetContact(KTestContact); |
|
2682 |
|
2683 TInt i; |
|
2684 TInt count; |
|
2685 for(count = 0; count < KTestEventNum; count++) |
|
2686 { |
|
2687 active->StartL(); |
|
2688 aClient.AddEvent(*event, active->iStatus); |
|
2689 CActiveScheduler::Start(); |
|
2690 TEST2(active->iStatus.Int(), KErrNone); |
|
2691 User::After(1 * 1000000); |
|
2692 } |
|
2693 // |
|
2694 TEST2(view->CountL(), 0); |
|
2695 active->StartL(); |
|
2696 TBool res = view->SetFilterL(*filter, active->iStatus); |
|
2697 TEST(res); |
|
2698 CActiveScheduler::Start(); |
|
2699 TEST2(active->iStatus.Int(), KErrNone); |
|
2700 TEST2(view->CountL(), KTestEventNum); |
|
2701 // |
|
2702 count = KTestEventNum; |
|
2703 res = view->FirstL(active->iStatus); |
|
2704 TEST(res); |
|
2705 do { |
|
2706 active->StartL(); |
|
2707 CActiveScheduler::Start(); |
|
2708 TEST2(active->iStatus.Int(), KErrNone); |
|
2709 // |
|
2710 TEST2(view->CountL(), KTestEventNum); |
|
2711 const TLogId eventId = view->Event().Id(); |
|
2712 TLogId id = --count; |
|
2713 TEST2(eventId, id); |
|
2714 } |
|
2715 while(view->NextL(active->iStatus)); |
|
2716 |
|
2717 // Transients |
|
2718 TInt changeCount; |
|
2719 TLogId logId; |
|
2720 TInt viewIndex; |
|
2721 TLogDatabaseChangeType type; |
|
2722 CLogChangeDefinition* changes; |
|
2723 |
|
2724 // Add an event and check for changes |
|
2725 active->StartL(); |
|
2726 aClient.AddEvent(*event, active->iStatus); |
|
2727 changes = changeObs->WaitForChangesLC(); |
|
2728 if (active->IsActive()) |
|
2729 CActiveScheduler::Start(); |
|
2730 TEST2(active->iStatus.Int(), KErrNone); |
|
2731 count = view->CountL(); |
|
2732 TEST2(count, KTestEventNum+1); |
|
2733 |
|
2734 changeCount = changes->Count(); |
|
2735 for(i=0; i<changeCount; i++) |
|
2736 { |
|
2737 type = changes->At(i, logId, viewIndex); |
|
2738 RDebug::Print(_L("Change Type: %d, logId: %d, viewIndex: %d\n"), type, logId, viewIndex); |
|
2739 } |
|
2740 |
|
2741 // Check the change was as expected |
|
2742 TEST2(changes->Count(), 1); |
|
2743 type = changes->At(0, logId, viewIndex); |
|
2744 TEST2(type, ELogChangeTypeEventAdded); |
|
2745 TEST2(viewIndex, 0); // first (newest) event in the view |
|
2746 { |
|
2747 const TLogId expectedLogId = ((TLogId) KTestEventNum); |
|
2748 TEST2(logId, expectedLogId); |
|
2749 } |
|
2750 CleanupStack::PopAndDestroy(changes); |
|
2751 |
|
2752 // Check view navigation |
|
2753 i=0; |
|
2754 res = view->FirstL(active->iStatus); |
|
2755 TEST(res); |
|
2756 do |
|
2757 { |
|
2758 active->StartL(); |
|
2759 CActiveScheduler::Start(); |
|
2760 TEST2(active->iStatus.Int(), KErrNone); |
|
2761 RDebug::Print(_L("View Entry[%d]: Id: %d\n"), i++, view->Event().Id()); |
|
2762 } |
|
2763 while(view->NextL(active->iStatus)); |
|
2764 RDebug::Print(_L("==\n")); |
|
2765 TEST2(i, count); |
|
2766 res = view->FirstL(active->iStatus); |
|
2767 TEST(res); |
|
2768 active->StartL(); |
|
2769 CActiveScheduler::Start(); |
|
2770 TEST2(active->iStatus.Int(), KErrNone); |
|
2771 |
|
2772 // Delete some events |
|
2773 TEST(KTestEventNum >= 10); |
|
2774 changeObs->StartCollectingChanges(); |
|
2775 for(i=1; i<KTestEventNum; i+=2) |
|
2776 { |
|
2777 active->StartL(); |
|
2778 aClient.DeleteEvent(TLogId(i), active->iStatus); |
|
2779 CActiveScheduler::Start(); |
|
2780 TEST2(active->iStatus.Int(), KErrNone); |
|
2781 } |
|
2782 |
|
2783 // Check changes |
|
2784 changeCount = changeObs->Changes().Count(); |
|
2785 TEST2(changeCount, 5); // 1,3,5,7,9 |
|
2786 for(i=0; i<changeCount; i++) |
|
2787 { |
|
2788 TEST(changeObs->Changes().At(i, logId, viewIndex) == ELogChangeTypeEventDeleted); |
|
2789 TEST(logId == TLogId(2*i + 1)); |
|
2790 TEST(viewIndex == 10 - ((2*i) + 1)); |
|
2791 } |
|
2792 |
|
2793 // Add a new event that shouldn't appear in the view |
|
2794 changeObs->StartCollectingChanges(); |
|
2795 event->SetContact(TLogContactItemId(0)); |
|
2796 active->StartL(); |
|
2797 aClient.AddEvent(*event, active->iStatus); |
|
2798 CActiveScheduler::Start(); |
|
2799 TEST2(active->iStatus.Int(), KErrNone); |
|
2800 count = view->CountL(); |
|
2801 TEST(count == KTestEventNum + 1 - 5); |
|
2802 TEST(event->Id() == KTestEventNum + 1); |
|
2803 |
|
2804 // Check changes |
|
2805 TEST(!changeObs->HaveChanges()); |
|
2806 |
|
2807 // Check view navigation |
|
2808 i=0; |
|
2809 res = view->FirstL(active->iStatus); |
|
2810 TEST(res); |
|
2811 do |
|
2812 { |
|
2813 active->StartL(); |
|
2814 CActiveScheduler::Start(); |
|
2815 TEST2(active->iStatus.Int(), KErrNone); |
|
2816 RDebug::Print(_L("View Entry[%d]: Id: %d\n"), i++, view->Event().Id()); |
|
2817 } |
|
2818 while(view->NextL(active->iStatus)); |
|
2819 RDebug::Print(_L("==\n")); |
|
2820 TEST2(i, count); |
|
2821 res = view->FirstL(active->iStatus); |
|
2822 TEST(res); |
|
2823 active->StartL(); |
|
2824 CActiveScheduler::Start(); |
|
2825 TEST2(active->iStatus.Int(), KErrNone); |
|
2826 |
|
2827 // Delete event which isn't in view |
|
2828 changeObs->StartCollectingChanges(); |
|
2829 active->StartL(); |
|
2830 aClient.DeleteEvent(event->Id(), active->iStatus); |
|
2831 CActiveScheduler::Start(); |
|
2832 TEST2(active->iStatus.Int(), KErrNone); |
|
2833 count = view->CountL(); |
|
2834 TEST(count == KTestEventNum + 1 - 5); |
|
2835 |
|
2836 // Check changes |
|
2837 TEST(!changeObs->HaveChanges()); |
|
2838 |
|
2839 // Check view navigation |
|
2840 i=0; |
|
2841 res = view->FirstL(active->iStatus); |
|
2842 TEST(res); |
|
2843 do |
|
2844 { |
|
2845 active->StartL(); |
|
2846 CActiveScheduler::Start(); |
|
2847 TEST2(active->iStatus.Int(), KErrNone); |
|
2848 RDebug::Print(_L("View Entry[%d]: Id: %d\n"), i++, view->Event().Id()); |
|
2849 } |
|
2850 while(view->NextL(active->iStatus)); |
|
2851 RDebug::Print(_L("==\n")); |
|
2852 TEST2(i, count); |
|
2853 res = view->FirstL(active->iStatus); |
|
2854 TEST(res); |
|
2855 active->StartL(); |
|
2856 CActiveScheduler::Start(); |
|
2857 TEST2(active->iStatus.Int(), KErrNone); |
|
2858 |
|
2859 // Add a new event again that shouldn't appear in the view |
|
2860 changeObs->StartCollectingChanges(); |
|
2861 event->SetContact(TLogContactItemId(0)); |
|
2862 active->StartL(); |
|
2863 aClient.AddEvent(*event, active->iStatus); |
|
2864 CActiveScheduler::Start(); |
|
2865 TEST2(active->iStatus.Int(), KErrNone); |
|
2866 count = view->CountL(); |
|
2867 TEST(count == KTestEventNum + 1 - 5); |
|
2868 TEST(event->Id() == KTestEventNum + 2); |
|
2869 |
|
2870 // Check changes |
|
2871 TEST(!changeObs->HaveChanges()); |
|
2872 |
|
2873 // Check view navigation |
|
2874 i=0; |
|
2875 res = view->FirstL(active->iStatus); |
|
2876 TEST(res); |
|
2877 do |
|
2878 { |
|
2879 active->StartL(); |
|
2880 CActiveScheduler::Start(); |
|
2881 TEST2(active->iStatus.Int(), KErrNone); |
|
2882 RDebug::Print(_L("View Entry[%d]: Id: %d\n"), i++, view->Event().Id()); |
|
2883 } |
|
2884 while(view->NextL(active->iStatus)); |
|
2885 RDebug::Print(_L("==\n")); |
|
2886 TEST2(i, count); |
|
2887 res = view->FirstL(active->iStatus); |
|
2888 TEST(res); |
|
2889 active->StartL(); |
|
2890 CActiveScheduler::Start(); |
|
2891 TEST2(active->iStatus.Int(), KErrNone); |
|
2892 |
|
2893 // Change event so that it appears in the view |
|
2894 changeObs->StartCollectingChanges(); |
|
2895 event->SetContact(KTestContact); |
|
2896 active->StartL(); |
|
2897 aClient.ChangeEvent(*event, active->iStatus); |
|
2898 CActiveScheduler::Start(); |
|
2899 TEST2(active->iStatus.Int(), KErrNone); |
|
2900 count = view->CountL(); |
|
2901 TEST(count == KTestEventNum + 2 - 5); |
|
2902 TEST(event->Id() == KTestEventNum + 2); // Shouldn't change |
|
2903 |
|
2904 // Check changes |
|
2905 changeCount = changeObs->Changes().Count(); |
|
2906 TEST2(changeCount, 1); |
|
2907 type = changeObs->Changes().At(0, logId, viewIndex); |
|
2908 TEST2(type, ELogChangeTypeEventAdded); |
|
2909 TEST(logId == KTestEventNum + 2); |
|
2910 TEST2(viewIndex, 0); |
|
2911 |
|
2912 // Check view navigation |
|
2913 i=0; |
|
2914 res = view->FirstL(active->iStatus); |
|
2915 TEST(res); |
|
2916 do |
|
2917 { |
|
2918 active->StartL(); |
|
2919 CActiveScheduler::Start(); |
|
2920 TEST2(active->iStatus.Int(), KErrNone); |
|
2921 RDebug::Print(_L("View Entry[%d]: Id: %d\n"), i++, view->Event().Id()); |
|
2922 } |
|
2923 while(view->NextL(active->iStatus)); |
|
2924 RDebug::Print(_L("==\n")); |
|
2925 TEST2(i, count); |
|
2926 res = view->FirstL(active->iStatus); |
|
2927 TEST(res); |
|
2928 active->StartL(); |
|
2929 CActiveScheduler::Start(); |
|
2930 TEST2(active->iStatus.Int(), KErrNone); |
|
2931 |
|
2932 // Simply change an event in the view |
|
2933 changeObs->StartCollectingChanges(); |
|
2934 event->SetDescription(_L("Test")); |
|
2935 active->StartL(); |
|
2936 aClient.ChangeEvent(*event, active->iStatus); |
|
2937 CActiveScheduler::Start(); |
|
2938 TEST2(active->iStatus.Int(), KErrNone); |
|
2939 count = view->CountL(); |
|
2940 TEST(count == KTestEventNum + 2 - 5); // Shouldn't change |
|
2941 TEST(event->Id() == KTestEventNum + 2); // Shouldn't change |
|
2942 |
|
2943 // Check changes |
|
2944 changeCount = changeObs->Changes().Count(); |
|
2945 TEST2(changeCount, 1); |
|
2946 type = changeObs->Changes().At(0, logId, viewIndex); |
|
2947 TEST2(type, ELogChangeTypeEventChanged); |
|
2948 TEST(logId == KTestEventNum + 2); |
|
2949 TEST2(viewIndex, 0); |
|
2950 |
|
2951 // Change an event in the view so that it is deleted |
|
2952 changeObs->StartCollectingChanges(); |
|
2953 event->SetContact(0); |
|
2954 active->StartL(); |
|
2955 aClient.ChangeEvent(*event, active->iStatus); |
|
2956 CActiveScheduler::Start(); |
|
2957 TEST2(active->iStatus.Int(), KErrNone); |
|
2958 count = view->CountL(); |
|
2959 TEST(count == KTestEventNum + 2 - 5 - 1); // one less now |
|
2960 |
|
2961 // Check changes |
|
2962 changeCount = changeObs->Changes().Count(); |
|
2963 TEST2(changeCount, 1); |
|
2964 type = changeObs->Changes().At(0, logId, viewIndex); |
|
2965 TEST2(type, ELogChangeTypeEventDeleted); |
|
2966 TEST(logId == KTestEventNum + 2); |
|
2967 TEST2(viewIndex, 0); |
|
2968 |
|
2969 // Navigate part way through the view so we have |
|
2970 // a cursor position part way through... |
|
2971 i=0; |
|
2972 count = view->CountL(); |
|
2973 res = view->FirstL(active->iStatus); |
|
2974 TEST(res); |
|
2975 do |
|
2976 { |
|
2977 active->StartL(); |
|
2978 CActiveScheduler::Start(); |
|
2979 TEST2(active->iStatus.Int(), KErrNone); |
|
2980 RDebug::Print(_L("View Entry[%d]: Id: %d\n"), i++, view->Event().Id()); |
|
2981 } |
|
2982 while(view->NextL(active->iStatus)); |
|
2983 RDebug::Print(_L("==\n")); |
|
2984 TEST2(i, count); |
|
2985 TEST(view->Event().Id() == TLogId(0)); |
|
2986 |
|
2987 // Save id |
|
2988 TLogId savedId = view->Event().Id(); |
|
2989 |
|
2990 // Go one back |
|
2991 res = view->PreviousL(active->iStatus); |
|
2992 TEST(res); |
|
2993 active->StartL(); |
|
2994 CActiveScheduler::Start(); |
|
2995 TEST2(active->iStatus.Int(), KErrNone); |
|
2996 |
|
2997 // Insert something |
|
2998 changeObs->StartCollectingChanges(); |
|
2999 event->SetContact(KTestContact); |
|
3000 active->StartL(); |
|
3001 aClient.AddEvent(*event, active->iStatus); |
|
3002 CActiveScheduler::Start(); |
|
3003 TEST2(active->iStatus.Int(), KErrNone); |
|
3004 count = view->CountL(); |
|
3005 TEST(count == KTestEventNum + 2 - 5); // one more now |
|
3006 TEST(event->Id() == KTestEventNum + 3); |
|
3007 |
|
3008 // Check changes |
|
3009 changeCount = changeObs->Changes().Count(); |
|
3010 TEST2(changeCount, 1); |
|
3011 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3012 TEST(type == ELogChangeTypeEventAdded); |
|
3013 TEST(logId == KTestEventNum + 3); |
|
3014 TEST2(viewIndex, 0); |
|
3015 |
|
3016 // Check we can still go forward to the last record |
|
3017 res = view->NextL(active->iStatus); |
|
3018 TEST(res); |
|
3019 active->StartL(); |
|
3020 CActiveScheduler::Start(); |
|
3021 TEST2(active->iStatus.Int(), KErrNone); |
|
3022 TEST2(view->Event().Id(), savedId); |
|
3023 |
|
3024 // Go one back |
|
3025 res = view->PreviousL(active->iStatus); |
|
3026 TEST(res); |
|
3027 active->StartL(); |
|
3028 CActiveScheduler::Start(); |
|
3029 TEST2(active->iStatus.Int(), KErrNone); |
|
3030 |
|
3031 // Delete current record |
|
3032 savedId = view->Event().Id(); |
|
3033 changeObs->StartCollectingChanges(); |
|
3034 active->StartL(); |
|
3035 aClient.DeleteEvent(savedId, active->iStatus); |
|
3036 CActiveScheduler::Start(); |
|
3037 TEST2(active->iStatus.Int(), KErrNone); |
|
3038 count = view->CountL(); |
|
3039 TEST(count == KTestEventNum + 2 - 5 - 1); // one less |
|
3040 |
|
3041 // Check changes |
|
3042 changeCount = changeObs->Changes().Count(); |
|
3043 TEST2(changeCount, 1); |
|
3044 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3045 TEST2(type, ELogChangeTypeEventDeleted); |
|
3046 TEST2(logId, savedId); |
|
3047 TEST(viewIndex == KTestEventNum + 2 - 5 - 2); // last but one event |
|
3048 |
|
3049 // Check we're now at the end of the view |
|
3050 res = view->NextL(active->iStatus); |
|
3051 TEST(!res); |
|
3052 |
|
3053 // Go to the first record |
|
3054 res = view->FirstL(active->iStatus); |
|
3055 TEST(res); |
|
3056 active->StartL(); |
|
3057 CActiveScheduler::Start(); |
|
3058 TEST2(active->iStatus.Int(), KErrNone); |
|
3059 |
|
3060 // Delete the first record |
|
3061 savedId = view->Event().Id(); |
|
3062 changeObs->StartCollectingChanges(); |
|
3063 active->StartL(); |
|
3064 aClient.DeleteEvent(savedId, active->iStatus); |
|
3065 CActiveScheduler::Start(); |
|
3066 TEST2(active->iStatus.Int(), KErrNone); |
|
3067 count = view->CountL(); |
|
3068 TEST(count == KTestEventNum - 5); |
|
3069 |
|
3070 // Check changes |
|
3071 changeCount = changeObs->Changes().Count(); |
|
3072 TEST2(changeCount, 1); |
|
3073 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3074 TEST2(type, ELogChangeTypeEventDeleted); |
|
3075 TEST2(logId, savedId); |
|
3076 TEST2(viewIndex, 0); // first item |
|
3077 |
|
3078 // Check 'next' navigation can be performed correctly |
|
3079 count = 0; |
|
3080 view->NextL(active->iStatus); |
|
3081 do |
|
3082 { |
|
3083 active->StartL(); |
|
3084 CActiveScheduler::Start(); |
|
3085 TEST2(active->iStatus.Int(), KErrNone); |
|
3086 ++count; |
|
3087 } |
|
3088 while(view->NextL(active->iStatus)); |
|
3089 TEST(count == KTestEventNum - 5 - 1); |
|
3090 |
|
3091 // Check last record |
|
3092 savedId = view->Event().Id(); |
|
3093 res = view->LastL(active->iStatus); |
|
3094 TEST(res); |
|
3095 active->StartL(); |
|
3096 CActiveScheduler::Start(); |
|
3097 TEST2(active->iStatus.Int(), KErrNone); |
|
3098 TEST(savedId == view->Event().Id()); |
|
3099 |
|
3100 // Delete the last record |
|
3101 savedId = view->Event().Id(); |
|
3102 changeObs->StartCollectingChanges(); |
|
3103 active->StartL(); |
|
3104 aClient.DeleteEvent(savedId, active->iStatus); |
|
3105 CActiveScheduler::Start(); |
|
3106 TEST2(active->iStatus.Int(), KErrNone); |
|
3107 count = view->CountL(); |
|
3108 TEST(count == KTestEventNum - 6); |
|
3109 |
|
3110 // Check changes |
|
3111 changeCount = changeObs->Changes().Count(); |
|
3112 TEST2(changeCount, 1); |
|
3113 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3114 TEST2(type, ELogChangeTypeEventDeleted); |
|
3115 TEST2(logId, savedId); |
|
3116 TEST2(viewIndex, count); // There's now one less item, and we deleted the last item of the previous view |
|
3117 |
|
3118 // Check we're still at the end of the view |
|
3119 res = view->NextL(active->iStatus); |
|
3120 TEST(!res); |
|
3121 |
|
3122 CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event |
|
3123 } |
|
3124 |
|
3125 CBaBackupSessionWrapper* theBackup = NULL; |
|
3126 |
|
3127 LOCAL_C TBool IsLogOpenL() |
|
3128 { |
|
3129 return TestUtils::IsDatabaseOpenL(); |
|
3130 } |
|
3131 |
|
3132 LOCAL_C void TestLogOpenL() |
|
3133 { |
|
3134 test(IsLogOpenL()); |
|
3135 } |
|
3136 |
|
3137 LOCAL_C void TestLogClosedL() |
|
3138 { |
|
3139 test(!IsLogOpenL()); |
|
3140 } |
|
3141 |
|
3142 LOCAL_C void StartBackupL() |
|
3143 { |
|
3144 User::InfoPrint(_L("Backup")); |
|
3145 |
|
3146 TDriveUnit driveUnit(EDriveC); |
|
3147 TDriveName name = driveUnit.Name(); |
|
3148 |
|
3149 TParse parse; |
|
3150 LEAVE_IF_ERROR(parse.Set(KLogDatabaseName, &name, NULL)); |
|
3151 |
|
3152 delete theBackup; |
|
3153 theBackup = NULL; |
|
3154 theBackup = CBaBackupSessionWrapper::NewL(); |
|
3155 |
|
3156 theBackup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess); |
|
3157 User::After(1000000); |
|
3158 } |
|
3159 |
|
3160 LOCAL_C void EndBackupL() |
|
3161 { |
|
3162 delete theBackup; |
|
3163 theBackup = NULL; |
|
3164 User::After(1000000); |
|
3165 } |
|
3166 |
|
3167 LOCAL_C void DelayL(TInt aDelay) |
|
3168 { |
|
3169 CTestTimer* timer = CTestTimer::NewL(); |
|
3170 timer->After(aDelay); |
|
3171 CActiveScheduler::Start(); |
|
3172 delete timer; |
|
3173 } |
|
3174 |
|
3175 /** |
|
3176 @SYMTestCaseID SYSLIB-LOGENG-CT-0869 |
|
3177 @SYMTestCaseDesc Tests for CLogViewChangeObserver::HaveChanges(),CLogViewChangeObserver::Changes() functions |
|
3178 @SYMTestPriority High |
|
3179 @SYMTestActions Check for observing changes while adding,deleting events.Check for observing changes after a backup. |
|
3180 Check for navigating the view.Test for KErrNone condition. |
|
3181 @SYMTestExpectedResults Test must not fail |
|
3182 @SYMREQ REQ0000 |
|
3183 */ |
|
3184 LOCAL_C void TestViewChangeEvents1aL(CLogClient& aClient) |
|
3185 { |
|
3186 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0869 ")); |
|
3187 TestUtils::DeleteDatabaseL(); |
|
3188 |
|
3189 CLogEvent* event = CLogEvent::NewL(); |
|
3190 CleanupStack::PushL(event); |
|
3191 |
|
3192 CLogFilter* filter = CLogFilter::NewL(); |
|
3193 CleanupStack::PushL(filter); |
|
3194 filter->SetContact(KTestContact); |
|
3195 filter->SetEventType(KLogPacketDataEventTypeUid); |
|
3196 |
|
3197 CTestActive* active = new(ELeave)CTestActive(); |
|
3198 CleanupStack::PushL(active); |
|
3199 |
|
3200 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); |
|
3201 changeObs->SetActive(); |
|
3202 |
|
3203 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); |
|
3204 CleanupStack::PushL(view); |
|
3205 |
|
3206 // Incoming |
|
3207 TBuf<KLogMaxDirectionLength> buf; |
|
3208 aClient.GetString(buf, R_LOG_DIR_IN); |
|
3209 |
|
3210 event->SetEventType(KLogPacketDataEventTypeUid); |
|
3211 event->SetDirection(buf); |
|
3212 event->SetContact(KTestContact); |
|
3213 |
|
3214 TInt i; |
|
3215 TInt count; |
|
3216 for(count = 0; count < KTestEventNum; count++) |
|
3217 { |
|
3218 active->StartL(); |
|
3219 aClient.AddEvent(*event, active->iStatus); |
|
3220 CActiveScheduler::Start(); |
|
3221 test(active->iStatus == KErrNone); |
|
3222 User::After(1 * 1000000); |
|
3223 } |
|
3224 // |
|
3225 test(view->CountL() == 0); |
|
3226 active->StartL(); |
|
3227 test(view->SetFilterL(*filter, active->iStatus)); |
|
3228 CActiveScheduler::Start(); |
|
3229 test(active->iStatus == KErrNone); |
|
3230 test(view->CountL() == KTestEventNum); |
|
3231 // |
|
3232 count = KTestEventNum; |
|
3233 test(view->FirstL(active->iStatus)); |
|
3234 do { |
|
3235 active->StartL(); |
|
3236 CActiveScheduler::Start(); |
|
3237 test(active->iStatus == KErrNone); |
|
3238 // |
|
3239 test(view->CountL() == KTestEventNum); |
|
3240 const TLogId eventId = view->Event().Id(); |
|
3241 test(eventId == (TLogId)--count); |
|
3242 } |
|
3243 while(view->NextL(active->iStatus)); |
|
3244 |
|
3245 // Transients |
|
3246 TInt changeCount; |
|
3247 TLogId logId; |
|
3248 TInt viewIndex; |
|
3249 TLogDatabaseChangeType type; |
|
3250 CLogChangeDefinition* changes; |
|
3251 |
|
3252 // Add an event and check for changes |
|
3253 active->StartL(); |
|
3254 aClient.AddEvent(*event, active->iStatus); |
|
3255 changes = changeObs->WaitForChangesLC(); |
|
3256 if (active->IsActive()) |
|
3257 CActiveScheduler::Start(); |
|
3258 test(active->iStatus == KErrNone); |
|
3259 count = view->CountL(); |
|
3260 test(count == KTestEventNum+1); |
|
3261 |
|
3262 changeCount = changes->Count(); |
|
3263 for(i=0; i<changeCount; i++) |
|
3264 { |
|
3265 type = changes->At(i, logId, viewIndex); |
|
3266 RDebug::Print(_L("Change Type: %d, logId: %d, viewIndex: %d"), type, logId, viewIndex); |
|
3267 } |
|
3268 |
|
3269 // Check the change was as expected |
|
3270 test(changes->Count() == 1); |
|
3271 type = changes->At(0, logId, viewIndex); |
|
3272 test(type == ELogChangeTypeEventAdded); |
|
3273 test(viewIndex == 0); // first (newest) event in the view |
|
3274 { |
|
3275 const TLogId expectedLogId = ((TLogId) KTestEventNum); |
|
3276 test(logId == expectedLogId); |
|
3277 } |
|
3278 CleanupStack::PopAndDestroy(changes); |
|
3279 |
|
3280 // Check view navigation |
|
3281 i=0; |
|
3282 test(view->FirstL(active->iStatus)); |
|
3283 do |
|
3284 { |
|
3285 active->StartL(); |
|
3286 CActiveScheduler::Start(); |
|
3287 test(active->iStatus == KErrNone); |
|
3288 RDebug::Print(_L("View Entry[%d]: Id: %d"), i++, view->Event().Id()); |
|
3289 } |
|
3290 while(view->NextL(active->iStatus)); |
|
3291 RDebug::Print(_L("==\n")); |
|
3292 test(i == count); |
|
3293 test(view->FirstL(active->iStatus)); |
|
3294 active->StartL(); |
|
3295 CActiveScheduler::Start(); |
|
3296 test(active->iStatus == KErrNone); |
|
3297 |
|
3298 // Check that changes work after a backup |
|
3299 DelayL(1000000); |
|
3300 StartBackupL(); |
|
3301 DelayL(1000000); |
|
3302 TestLogClosedL(); |
|
3303 EndBackupL(); |
|
3304 TestLogOpenL(); |
|
3305 |
|
3306 // Delete some events |
|
3307 test(KTestEventNum >= 10); |
|
3308 changeObs->StartCollectingChanges(); |
|
3309 for(i=1; i<KTestEventNum; i+=2) |
|
3310 { |
|
3311 active->StartL(); |
|
3312 aClient.DeleteEvent(TLogId(i), active->iStatus); |
|
3313 CActiveScheduler::Start(); |
|
3314 test(active->iStatus == KErrNone); |
|
3315 } |
|
3316 |
|
3317 // Check changes |
|
3318 changeCount = changeObs->Changes().Count(); |
|
3319 test(changeCount == 5); // 1,3,5,7,9 |
|
3320 for(i=0; i<changeCount; i++) |
|
3321 { |
|
3322 test(changeObs->Changes().At(i, logId, viewIndex) == ELogChangeTypeEventDeleted); |
|
3323 test(logId == TLogId(2*i + 1)); |
|
3324 test(viewIndex == 10 - ((2*i) + 1)); |
|
3325 } |
|
3326 |
|
3327 // Check that changes work after a backup |
|
3328 StartBackupL(); |
|
3329 DelayL(1000000); |
|
3330 TestLogClosedL(); |
|
3331 EndBackupL(); |
|
3332 TestLogOpenL(); |
|
3333 |
|
3334 // Add a new event that shouldn't appear in the view |
|
3335 changeObs->StartCollectingChanges(); |
|
3336 event->SetContact(TLogContactItemId(0)); |
|
3337 active->StartL(); |
|
3338 aClient.AddEvent(*event, active->iStatus); |
|
3339 CActiveScheduler::Start(); |
|
3340 test(active->iStatus == KErrNone); |
|
3341 count = view->CountL(); |
|
3342 test(count == KTestEventNum + 1 - 5); |
|
3343 test(event->Id() == KTestEventNum + 1); |
|
3344 |
|
3345 // Check changes |
|
3346 test(!changeObs->HaveChanges()); |
|
3347 |
|
3348 // Check view navigation |
|
3349 i=0; |
|
3350 test(view->FirstL(active->iStatus)); |
|
3351 do |
|
3352 { |
|
3353 active->StartL(); |
|
3354 CActiveScheduler::Start(); |
|
3355 test(active->iStatus == KErrNone); |
|
3356 RDebug::Print(_L("View Entry[%d]: Id: %d"), i++, view->Event().Id()); |
|
3357 } |
|
3358 while(view->NextL(active->iStatus)); |
|
3359 RDebug::Print(_L("==\n")); |
|
3360 test(i == count); |
|
3361 test(view->FirstL(active->iStatus)); |
|
3362 active->StartL(); |
|
3363 CActiveScheduler::Start(); |
|
3364 test(active->iStatus == KErrNone); |
|
3365 |
|
3366 // Check that changes work after a backup |
|
3367 StartBackupL(); |
|
3368 DelayL(1000000); |
|
3369 TestLogClosedL(); |
|
3370 EndBackupL(); |
|
3371 TestLogOpenL(); |
|
3372 |
|
3373 // Delete event which isn't in view |
|
3374 changeObs->StartCollectingChanges(); |
|
3375 active->StartL(); |
|
3376 aClient.DeleteEvent(event->Id(), active->iStatus); |
|
3377 CActiveScheduler::Start(); |
|
3378 test(active->iStatus == KErrNone); |
|
3379 count = view->CountL(); |
|
3380 test(count == KTestEventNum + 1 - 5); |
|
3381 |
|
3382 // Check changes |
|
3383 test(!changeObs->HaveChanges()); |
|
3384 |
|
3385 // Check view navigation |
|
3386 i=0; |
|
3387 test(view->FirstL(active->iStatus)); |
|
3388 do |
|
3389 { |
|
3390 active->StartL(); |
|
3391 CActiveScheduler::Start(); |
|
3392 test(active->iStatus == KErrNone); |
|
3393 RDebug::Print(_L("View Entry[%d]: Id: %d"), i++, view->Event().Id()); |
|
3394 } |
|
3395 while(view->NextL(active->iStatus)); |
|
3396 RDebug::Print(_L("==\n")); |
|
3397 test(i == count); |
|
3398 test(view->FirstL(active->iStatus)); |
|
3399 active->StartL(); |
|
3400 CActiveScheduler::Start(); |
|
3401 test(active->iStatus == KErrNone); |
|
3402 |
|
3403 // Check that changes work after a backup |
|
3404 StartBackupL(); |
|
3405 DelayL(1000000); |
|
3406 TestLogClosedL(); |
|
3407 EndBackupL(); |
|
3408 TestLogOpenL(); |
|
3409 |
|
3410 // Add a new event again that shouldn't appear in the view |
|
3411 changeObs->StartCollectingChanges(); |
|
3412 event->SetContact(TLogContactItemId(0)); |
|
3413 active->StartL(); |
|
3414 aClient.AddEvent(*event, active->iStatus); |
|
3415 CActiveScheduler::Start(); |
|
3416 test(active->iStatus == KErrNone); |
|
3417 count = view->CountL(); |
|
3418 test(count == KTestEventNum + 1 - 5); |
|
3419 test(event->Id() == KTestEventNum + 2); |
|
3420 |
|
3421 // Check changes |
|
3422 test(!changeObs->HaveChanges()); |
|
3423 |
|
3424 // Check view navigation |
|
3425 i=0; |
|
3426 test(view->FirstL(active->iStatus)); |
|
3427 do |
|
3428 { |
|
3429 active->StartL(); |
|
3430 CActiveScheduler::Start(); |
|
3431 test(active->iStatus == KErrNone); |
|
3432 RDebug::Print(_L("View Entry[%d]: Id: %d"), i++, view->Event().Id()); |
|
3433 } |
|
3434 while(view->NextL(active->iStatus)); |
|
3435 RDebug::Print(_L("==\n")); |
|
3436 test(i == count); |
|
3437 test(view->FirstL(active->iStatus)); |
|
3438 active->StartL(); |
|
3439 CActiveScheduler::Start(); |
|
3440 test(active->iStatus == KErrNone); |
|
3441 |
|
3442 // Check that changes work after a backup |
|
3443 StartBackupL(); |
|
3444 DelayL(1000000); |
|
3445 TestLogClosedL(); |
|
3446 EndBackupL(); |
|
3447 TestLogOpenL(); |
|
3448 |
|
3449 // Change event so that it appears in the view |
|
3450 changeObs->StartCollectingChanges(); |
|
3451 event->SetContact(KTestContact); |
|
3452 active->StartL(); |
|
3453 aClient.ChangeEvent(*event, active->iStatus); |
|
3454 CActiveScheduler::Start(); |
|
3455 test(active->iStatus == KErrNone); |
|
3456 count = view->CountL(); |
|
3457 test(count == KTestEventNum + 2 - 5); |
|
3458 test(event->Id() == KTestEventNum + 2); // Shouldn't change |
|
3459 |
|
3460 // Check changes |
|
3461 changeCount = changeObs->Changes().Count(); |
|
3462 test(changeCount == 1); |
|
3463 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3464 test(type == ELogChangeTypeEventAdded); |
|
3465 test(logId == KTestEventNum + 2); |
|
3466 test(viewIndex == 0); |
|
3467 |
|
3468 // Check view navigation |
|
3469 i=0; |
|
3470 test(view->FirstL(active->iStatus)); |
|
3471 do |
|
3472 { |
|
3473 active->StartL(); |
|
3474 CActiveScheduler::Start(); |
|
3475 test(active->iStatus == KErrNone); |
|
3476 RDebug::Print(_L("View Entry[%d]: Id: %d"), i++, view->Event().Id()); |
|
3477 } |
|
3478 while(view->NextL(active->iStatus)); |
|
3479 RDebug::Print(_L("==\n")); |
|
3480 test(i == count); |
|
3481 test(view->FirstL(active->iStatus)); |
|
3482 active->StartL(); |
|
3483 CActiveScheduler::Start(); |
|
3484 test(active->iStatus == KErrNone); |
|
3485 |
|
3486 // Check that changes work after a backup |
|
3487 StartBackupL(); |
|
3488 DelayL(1000000); |
|
3489 TestLogClosedL(); |
|
3490 EndBackupL(); |
|
3491 TestLogOpenL(); |
|
3492 |
|
3493 // Simply change an event in the view |
|
3494 changeObs->StartCollectingChanges(); |
|
3495 event->SetDescription(_L("Test")); |
|
3496 active->StartL(); |
|
3497 aClient.ChangeEvent(*event, active->iStatus); |
|
3498 CActiveScheduler::Start(); |
|
3499 test(active->iStatus == KErrNone); |
|
3500 count = view->CountL(); |
|
3501 test(count == KTestEventNum + 2 - 5); // Shouldn't change |
|
3502 test(event->Id() == KTestEventNum + 2); // Shouldn't change |
|
3503 |
|
3504 // Check changes |
|
3505 changeCount = changeObs->Changes().Count(); |
|
3506 test(changeCount == 1); |
|
3507 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3508 test(type == ELogChangeTypeEventChanged); |
|
3509 test(logId == KTestEventNum + 2); |
|
3510 test(viewIndex == 0); |
|
3511 |
|
3512 // Check that changes work after a backup |
|
3513 StartBackupL(); |
|
3514 DelayL(1000000); |
|
3515 TestLogClosedL(); |
|
3516 EndBackupL(); |
|
3517 TestLogOpenL(); |
|
3518 |
|
3519 // Change an event in the view so that it is deleted |
|
3520 changeObs->StartCollectingChanges(); |
|
3521 event->SetContact(0); |
|
3522 active->StartL(); |
|
3523 aClient.ChangeEvent(*event, active->iStatus); |
|
3524 CActiveScheduler::Start(); |
|
3525 test(active->iStatus == KErrNone); |
|
3526 count = view->CountL(); |
|
3527 test(count == KTestEventNum + 2 - 5 - 1); // one less now |
|
3528 |
|
3529 // Check changes |
|
3530 changeCount = changeObs->Changes().Count(); |
|
3531 test(changeCount == 1); |
|
3532 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3533 test(type == ELogChangeTypeEventDeleted); |
|
3534 test(logId == KTestEventNum + 2); |
|
3535 test(viewIndex == 0); |
|
3536 |
|
3537 // Navigate part way through the view so we have |
|
3538 // a cursor position part way through... |
|
3539 i=0; |
|
3540 count = view->CountL(); |
|
3541 test(view->FirstL(active->iStatus)); |
|
3542 do |
|
3543 { |
|
3544 active->StartL(); |
|
3545 CActiveScheduler::Start(); |
|
3546 test(active->iStatus == KErrNone); |
|
3547 RDebug::Print(_L("View Entry[%d]: Id: %d"), i++, view->Event().Id()); |
|
3548 } |
|
3549 while(view->NextL(active->iStatus)); |
|
3550 RDebug::Print(_L("==\n")); |
|
3551 test(i == count); |
|
3552 test(view->Event().Id() == TLogId(0)); |
|
3553 |
|
3554 // Save id |
|
3555 TLogId savedId = view->Event().Id(); |
|
3556 |
|
3557 // Go one back |
|
3558 test(view->PreviousL(active->iStatus)); |
|
3559 active->StartL(); |
|
3560 CActiveScheduler::Start(); |
|
3561 test(active->iStatus == KErrNone); |
|
3562 |
|
3563 // Check that changes work after a backup |
|
3564 StartBackupL(); |
|
3565 DelayL(1000000); |
|
3566 TestLogClosedL(); |
|
3567 EndBackupL(); |
|
3568 TestLogOpenL(); |
|
3569 |
|
3570 // Insert something |
|
3571 changeObs->StartCollectingChanges(); |
|
3572 event->SetContact(KTestContact); |
|
3573 active->StartL(); |
|
3574 aClient.AddEvent(*event, active->iStatus); |
|
3575 CActiveScheduler::Start(); |
|
3576 test(active->iStatus == KErrNone); |
|
3577 count = view->CountL(); |
|
3578 test(count == KTestEventNum + 2 - 5); // one more now |
|
3579 test(event->Id() == KTestEventNum + 3); |
|
3580 |
|
3581 // Check changes |
|
3582 changeCount = changeObs->Changes().Count(); |
|
3583 test(changeCount == 1); |
|
3584 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3585 test(type == ELogChangeTypeEventAdded); |
|
3586 test(logId == KTestEventNum + 3); |
|
3587 test(viewIndex == 0); |
|
3588 |
|
3589 // Check we can still go forward to the last record |
|
3590 test(view->NextL(active->iStatus)); |
|
3591 active->StartL(); |
|
3592 CActiveScheduler::Start(); |
|
3593 test(active->iStatus == KErrNone); |
|
3594 test(view->Event().Id() == savedId); |
|
3595 |
|
3596 // Go one back |
|
3597 test(view->PreviousL(active->iStatus)); |
|
3598 active->StartL(); |
|
3599 CActiveScheduler::Start(); |
|
3600 test(active->iStatus == KErrNone); |
|
3601 |
|
3602 // Check that changes work after a backup |
|
3603 StartBackupL(); |
|
3604 DelayL(1000000); |
|
3605 TestLogClosedL(); |
|
3606 EndBackupL(); |
|
3607 TestLogOpenL(); |
|
3608 |
|
3609 // Delete current record |
|
3610 savedId = view->Event().Id(); |
|
3611 changeObs->StartCollectingChanges(); |
|
3612 active->StartL(); |
|
3613 aClient.DeleteEvent(savedId, active->iStatus); |
|
3614 CActiveScheduler::Start(); |
|
3615 test(active->iStatus == KErrNone); |
|
3616 count = view->CountL(); |
|
3617 test(count == KTestEventNum + 2 - 5 - 1); // one less |
|
3618 |
|
3619 // Check changes |
|
3620 changeCount = changeObs->Changes().Count(); |
|
3621 test(changeCount == 1); |
|
3622 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3623 test(type == ELogChangeTypeEventDeleted); |
|
3624 test(logId == savedId); |
|
3625 test(viewIndex == KTestEventNum + 2 - 5 - 2); // last but one event |
|
3626 |
|
3627 // Check we're now at the end of the view |
|
3628 test(!view->NextL(active->iStatus)); |
|
3629 |
|
3630 // Go to the first record |
|
3631 test(view->FirstL(active->iStatus)); |
|
3632 active->StartL(); |
|
3633 CActiveScheduler::Start(); |
|
3634 test(active->iStatus == KErrNone); |
|
3635 |
|
3636 // Check that changes work after a backup |
|
3637 StartBackupL(); |
|
3638 DelayL(1000000); |
|
3639 TestLogClosedL(); |
|
3640 EndBackupL(); |
|
3641 TestLogOpenL(); |
|
3642 |
|
3643 // Delete the first record |
|
3644 savedId = view->Event().Id(); |
|
3645 changeObs->StartCollectingChanges(); |
|
3646 active->StartL(); |
|
3647 aClient.DeleteEvent(savedId, active->iStatus); |
|
3648 CActiveScheduler::Start(); |
|
3649 test(active->iStatus == KErrNone); |
|
3650 count = view->CountL(); |
|
3651 test(count == KTestEventNum - 5); |
|
3652 |
|
3653 // Check changes |
|
3654 changeCount = changeObs->Changes().Count(); |
|
3655 test(changeCount == 1); |
|
3656 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3657 test(type == ELogChangeTypeEventDeleted); |
|
3658 test(logId == savedId); |
|
3659 test(viewIndex == 0); // first item |
|
3660 |
|
3661 // Check 'next' navigation can be performed correctly |
|
3662 count = 0; |
|
3663 view->NextL(active->iStatus); |
|
3664 do |
|
3665 { |
|
3666 active->StartL(); |
|
3667 CActiveScheduler::Start(); |
|
3668 test(active->iStatus == KErrNone); |
|
3669 ++count; |
|
3670 } |
|
3671 while(view->NextL(active->iStatus)); |
|
3672 test(count == KTestEventNum - 5 - 1); |
|
3673 |
|
3674 // Check last record |
|
3675 savedId = view->Event().Id(); |
|
3676 test(view->LastL(active->iStatus)); |
|
3677 active->StartL(); |
|
3678 CActiveScheduler::Start(); |
|
3679 test(active->iStatus == KErrNone); |
|
3680 test(savedId == view->Event().Id()); |
|
3681 |
|
3682 // Check that changes work after a backup |
|
3683 StartBackupL(); |
|
3684 DelayL(1000000); |
|
3685 TestLogClosedL(); |
|
3686 EndBackupL(); |
|
3687 TestLogOpenL(); |
|
3688 |
|
3689 // Delete the last record |
|
3690 savedId = view->Event().Id(); |
|
3691 changeObs->StartCollectingChanges(); |
|
3692 active->StartL(); |
|
3693 aClient.DeleteEvent(savedId, active->iStatus); |
|
3694 CActiveScheduler::Start(); |
|
3695 test(active->iStatus == KErrNone); |
|
3696 count = view->CountL(); |
|
3697 test(count == KTestEventNum - 6); |
|
3698 |
|
3699 // Check changes |
|
3700 changeCount = changeObs->Changes().Count(); |
|
3701 test(changeCount == 1); |
|
3702 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3703 test(type == ELogChangeTypeEventDeleted); |
|
3704 test(logId == savedId); |
|
3705 test(viewIndex == count); // There's now one less item, and we deleted the last item of the previous view |
|
3706 |
|
3707 // Check we're still at the end of the view |
|
3708 test(!view->NextL(active->iStatus)); |
|
3709 |
|
3710 CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event |
|
3711 } |
|
3712 |
|
3713 /** |
|
3714 @SYMTestCaseID SYSLIB-LOGENG-CT-0870 |
|
3715 @SYMTestCaseDesc Tests for CLogViewChangeObserver::HaveChanges(),Changes() functions |
|
3716 @SYMTestPriority High |
|
3717 @SYMTestActions Check for observing changes while adding,deleting events.Check for observing changes after a backup. |
|
3718 Check for observing changes while traversing through the events in the view. |
|
3719 Delete everything in the view and make sure we can't navigate anymore. |
|
3720 @SYMTestExpectedResults Test must not fail |
|
3721 @SYMREQ REQ0000 |
|
3722 */ |
|
3723 LOCAL_C void TestViewChangeEvents2L(CLogClient& aClient) |
|
3724 { |
|
3725 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0870 ")); |
|
3726 // Transients |
|
3727 TInt i=0; |
|
3728 TInt count; |
|
3729 TBuf<1> description; description.SetLength(1); |
|
3730 TInt changeCount; |
|
3731 TLogId logId; |
|
3732 TInt viewIndex; |
|
3733 TLogDatabaseChangeType type; |
|
3734 TLogId runningNewId = 0; |
|
3735 // |
|
3736 const TInt KChangeEventTest2NumberOfEventsInView = 7; |
|
3737 TestUtils::DeleteDatabaseL(); |
|
3738 |
|
3739 CLogEvent* event = CLogEvent::NewL(); |
|
3740 CleanupStack::PushL(event); |
|
3741 |
|
3742 CLogFilter* filter = CLogFilter::NewL(); |
|
3743 CleanupStack::PushL(filter); |
|
3744 filter->SetContact(KTestContact); |
|
3745 |
|
3746 CTestActive* active = new(ELeave)CTestActive(); |
|
3747 CleanupStack::PushL(active); |
|
3748 |
|
3749 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); |
|
3750 changeObs->SetActive(); |
|
3751 |
|
3752 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); |
|
3753 CleanupStack::PushL(view); |
|
3754 |
|
3755 // Add seed events |
|
3756 TBuf<KLogMaxDirectionLength> buf; |
|
3757 aClient.GetString(buf, R_LOG_DIR_IN); |
|
3758 |
|
3759 event->SetEventType(KLogPacketDataEventTypeUid); |
|
3760 event->SetDirection(buf); |
|
3761 // |
|
3762 for(count = 0; count < KChangeEventTest2NumberOfEventsInView; count++) |
|
3763 { |
|
3764 // Have to create one event which isn't in the view by default, but |
|
3765 // when it 'appears' will be part way through |
|
3766 if (count == 3 && description[0] != TUint16('Z')) |
|
3767 { |
|
3768 description[0] = TUint16('Z'); |
|
3769 event->SetContact(0); |
|
3770 |
|
3771 // Go back and do this one again but with a real view entry this time, i.e. 'D' |
|
3772 --count; |
|
3773 } |
|
3774 else |
|
3775 { |
|
3776 description[0] = TUint16('A' + KChangeEventTest2NumberOfEventsInView - count); |
|
3777 event->SetContact(KTestContact); |
|
3778 } |
|
3779 event->SetDescription(description); |
|
3780 // |
|
3781 active->StartL(); |
|
3782 aClient.AddEvent(*event, active->iStatus); |
|
3783 CActiveScheduler::Start(); |
|
3784 TEST2(active->iStatus.Int(), KErrNone); |
|
3785 TEST(event->Id() == runningNewId++); |
|
3786 User::After(1 * 1000000); |
|
3787 } |
|
3788 // |
|
3789 TEST2(view->CountL(), 0); |
|
3790 active->StartL(); |
|
3791 TBool res =view->SetFilterL(*filter, active->iStatus); |
|
3792 TEST(res); |
|
3793 CActiveScheduler::Start(); |
|
3794 TEST2(active->iStatus.Int(), KErrNone); |
|
3795 count = view->CountL(); |
|
3796 TEST2(count, KChangeEventTest2NumberOfEventsInView); |
|
3797 |
|
3798 res = view->FirstL(active->iStatus); |
|
3799 TEST(res); |
|
3800 do |
|
3801 { |
|
3802 active->StartL(); |
|
3803 CActiveScheduler::Start(); |
|
3804 TEST2(active->iStatus.Int(), KErrNone); |
|
3805 RDebug::Print(_L("View Entry[%d]: Id: %d\n"), i++, view->Event().Id()); |
|
3806 } |
|
3807 while(view->NextL(active->iStatus)); |
|
3808 |
|
3809 // Check addition change events |
|
3810 res = view->FirstL(active->iStatus); |
|
3811 TEST(res); |
|
3812 active->StartL(); |
|
3813 CActiveScheduler::Start(); |
|
3814 TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0 |
|
3815 TEST2(view->Event().Id(), 7); |
|
3816 |
|
3817 // Add a new entry - should appear as the first item in the view |
|
3818 description[0] = TUint16('X'); |
|
3819 event->SetDescription(description); |
|
3820 // |
|
3821 changeObs->StartCollectingChanges(); |
|
3822 active->StartL(); |
|
3823 aClient.AddEvent(*event, active->iStatus); |
|
3824 CActiveScheduler::Start(); |
|
3825 TEST2(active->iStatus.Int(), KErrNone); |
|
3826 TEST(event->Id() == runningNewId++); |
|
3827 |
|
3828 // Check changes |
|
3829 changeCount = changeObs->Changes().Count(); |
|
3830 TEST2(changeCount, 1); |
|
3831 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3832 TEST2(type, ELogChangeTypeEventAdded); |
|
3833 TEST(logId == runningNewId-1); |
|
3834 TEST2(viewIndex, 0); // 8, [7], 6, 5, 4, 2, 1, 0 |
|
3835 |
|
3836 // Check we can go forward |
|
3837 res = view->NextL(active->iStatus); |
|
3838 TEST(res); |
|
3839 active->StartL(); |
|
3840 CActiveScheduler::Start(); |
|
3841 TEST2(active->iStatus.Int(), KErrNone); |
|
3842 TEST2(view->Event().Id(), TLogId(6)); // 8, 7, [6], 5, 4, 2, 1, 0 |
|
3843 |
|
3844 // Check we can now go back (new first entry) |
|
3845 res = view->PreviousL(active->iStatus); |
|
3846 TEST(res); |
|
3847 active->StartL(); |
|
3848 CActiveScheduler::Start(); |
|
3849 TEST2(active->iStatus.Int(), KErrNone); // 8, [7], 6, 5, 4, 2, 1, 0 |
|
3850 TEST2(view->Event().Id(), 7); |
|
3851 res = view->PreviousL(active->iStatus); |
|
3852 TEST(res); |
|
3853 active->StartL(); |
|
3854 CActiveScheduler::Start(); |
|
3855 TEST2(active->iStatus.Int(), KErrNone); // [8], 7, 6, 5, 4, 2, 1, 0 |
|
3856 TEST(view->Event().Id() == TLogId(KChangeEventTest2NumberOfEventsInView+1)); |
|
3857 |
|
3858 // Delete added event |
|
3859 changeObs->ResetChanges(); |
|
3860 changeCount = changeObs->Changes().Count(); |
|
3861 TEST2(changeCount, 0); |
|
3862 active->StartL(); |
|
3863 aClient.DeleteEvent(view->Event().Id(), active->iStatus); |
|
3864 CActiveScheduler::Start(); |
|
3865 TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0 |
|
3866 |
|
3867 // Check deletion changes |
|
3868 changeCount = changeObs->Changes().Count(); |
|
3869 TEST2(changeCount, 1); |
|
3870 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3871 TEST2(type, ELogChangeTypeEventDeleted); |
|
3872 TEST(logId == runningNewId-1); |
|
3873 TEST2(viewIndex, 0); |
|
3874 |
|
3875 // Go to end of view |
|
3876 res = view->LastL(active->iStatus); |
|
3877 TEST(res); |
|
3878 active->StartL(); |
|
3879 CActiveScheduler::Start(); |
|
3880 TEST2(active->iStatus.Int(), KErrNone); |
|
3881 TEST(view->Event().Id() == TLogId(0)); // 7, 6, 5, 4, 2, 1, [0] |
|
3882 |
|
3883 // Add new event |
|
3884 description[0] = TUint16('X'); |
|
3885 event->SetDescription(description); |
|
3886 // |
|
3887 changeObs->StartCollectingChanges(); |
|
3888 active->StartL(); |
|
3889 aClient.AddEvent(*event, active->iStatus); |
|
3890 CActiveScheduler::Start(); |
|
3891 TEST2(active->iStatus.Int(), KErrNone); |
|
3892 TEST(event->Id() == runningNewId++); |
|
3893 |
|
3894 // Check changes |
|
3895 changeCount = changeObs->Changes().Count(); |
|
3896 TEST2(changeCount, 1); |
|
3897 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3898 TEST2(type, ELogChangeTypeEventAdded); |
|
3899 TEST(logId == runningNewId-1); |
|
3900 TEST2(viewIndex, 0); // 9, 7, 6, 5, 4, 2, 1, [0] |
|
3901 |
|
3902 // Check we can't go forward |
|
3903 res = view->NextL(active->iStatus); |
|
3904 TEST(!res); |
|
3905 |
|
3906 // Go back to the first record |
|
3907 res = view->FirstL(active->iStatus); |
|
3908 TEST(res); |
|
3909 active->StartL(); |
|
3910 CActiveScheduler::Start(); |
|
3911 TEST2(active->iStatus.Int(), KErrNone); |
|
3912 TEST(view->Event().Id() == TLogId(runningNewId-1)); // 9, 7, 6, 5, 4, 2, 1, [0] |
|
3913 |
|
3914 // Delete added event |
|
3915 changeObs->ResetChanges(); |
|
3916 active->StartL(); |
|
3917 aClient.DeleteEvent(view->Event().Id(), active->iStatus); |
|
3918 CActiveScheduler::Start(); |
|
3919 TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0 |
|
3920 |
|
3921 // Check deletion changes |
|
3922 changeCount = changeObs->Changes().Count(); |
|
3923 TEST2(changeCount, 1); |
|
3924 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3925 TEST2(type, ELogChangeTypeEventDeleted); |
|
3926 TEST(logId == runningNewId-1); |
|
3927 TEST2(viewIndex, 0); |
|
3928 |
|
3929 // Go part way through view |
|
3930 res = view->NextL(active->iStatus); |
|
3931 TEST(res); |
|
3932 active->StartL(); |
|
3933 CActiveScheduler::Start(); |
|
3934 TEST2(active->iStatus.Int(), KErrNone); |
|
3935 TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0 |
|
3936 res = view->NextL(active->iStatus); |
|
3937 TEST(res); |
|
3938 active->StartL(); |
|
3939 CActiveScheduler::Start(); |
|
3940 TEST2(active->iStatus.Int(), KErrNone); |
|
3941 TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 2, 1, 0 |
|
3942 |
|
3943 // Add new event |
|
3944 description[0] = TUint16('X'); |
|
3945 event->SetDescription(description); |
|
3946 // |
|
3947 changeObs->StartCollectingChanges(); |
|
3948 active->StartL(); |
|
3949 aClient.AddEvent(*event, active->iStatus); |
|
3950 CActiveScheduler::Start(); |
|
3951 TEST2(active->iStatus.Int(), KErrNone); |
|
3952 TEST(event->Id() == runningNewId++); |
|
3953 |
|
3954 // Check changes |
|
3955 changeCount = changeObs->Changes().Count(); |
|
3956 TEST2(changeCount, 1); |
|
3957 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3958 TEST2(type, ELogChangeTypeEventAdded); |
|
3959 TEST2(logId, runningNewId-1); |
|
3960 TEST2(viewIndex, 0); // 10, 7, 6, [5], 4, 2, 1, 0 |
|
3961 changeObs->ResetChanges(); |
|
3962 |
|
3963 // Work back to beginning |
|
3964 res = view->PreviousL(active->iStatus); |
|
3965 TEST(res); |
|
3966 active->StartL(); |
|
3967 CActiveScheduler::Start(); |
|
3968 TEST2(active->iStatus.Int(), KErrNone); |
|
3969 TEST2(view->Event().Id(), TLogId(6)); // 10, 7, [6], 5, 4, 2, 1, 0 |
|
3970 res = view->PreviousL(active->iStatus); |
|
3971 TEST(res); |
|
3972 active->StartL(); |
|
3973 CActiveScheduler::Start(); |
|
3974 TEST2(active->iStatus.Int(), KErrNone); |
|
3975 TEST2(view->Event().Id(), TLogId(7)); // 10, [7], 6, 5, 4, 2, 1, 0 |
|
3976 res = view->PreviousL(active->iStatus); |
|
3977 TEST(res); |
|
3978 active->StartL(); |
|
3979 CActiveScheduler::Start(); |
|
3980 TEST2(active->iStatus.Int(), KErrNone); |
|
3981 TEST2(view->Event().Id(), runningNewId-1); // [10], 7, 6, 5, 4, 2, 1, 0 |
|
3982 |
|
3983 // Delete added event |
|
3984 changeCount = changeObs->Changes().Count(); |
|
3985 TEST2(changeCount, 0); |
|
3986 active->StartL(); |
|
3987 aClient.DeleteEvent(view->Event().Id(), active->iStatus); |
|
3988 CActiveScheduler::Start(); |
|
3989 TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0 |
|
3990 |
|
3991 // Check deletion changes |
|
3992 changeCount = changeObs->Changes().Count(); |
|
3993 TEST2(changeCount, 1); |
|
3994 type = changeObs->Changes().At(0, logId, viewIndex); |
|
3995 TEST2(type, ELogChangeTypeEventDeleted); |
|
3996 TEST2(logId, runningNewId-1); |
|
3997 TEST2(viewIndex, 0); |
|
3998 changeObs->ResetChanges(); |
|
3999 |
|
4000 // Go back to the first record |
|
4001 res = view->FirstL(active->iStatus); |
|
4002 TEST(res); |
|
4003 active->StartL(); |
|
4004 CActiveScheduler::Start(); |
|
4005 TEST2(active->iStatus.Int(), KErrNone); |
|
4006 TEST2(view->Event().Id(), TLogId(7)); // [7], 6, 5, 4, 2, 1, 0 |
|
4007 |
|
4008 // Move one record forward |
|
4009 res = view->NextL(active->iStatus); |
|
4010 TEST(res); |
|
4011 active->StartL(); |
|
4012 CActiveScheduler::Start(); |
|
4013 TEST2(active->iStatus.Int(), KErrNone); |
|
4014 TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0 |
|
4015 |
|
4016 // Change 'Z' event so that it now appears in the view |
|
4017 changeCount = changeObs->Changes().Count(); |
|
4018 TEST2(changeCount, 0); |
|
4019 active->StartL(); |
|
4020 event->SetId(TLogId(3)); |
|
4021 aClient.GetEvent(*event, active->iStatus); |
|
4022 CActiveScheduler::Start(); |
|
4023 TEST2(active->iStatus.Int(), KErrNone); |
|
4024 // |
|
4025 event->SetContact(KTestContact); |
|
4026 active->StartL(); |
|
4027 changeObs->StartCollectingChanges(); |
|
4028 aClient.ChangeEvent(*event, active->iStatus); |
|
4029 CActiveScheduler::Start(); |
|
4030 TEST2(active->iStatus.Int(), KErrNone); |
|
4031 count = view->CountL(); |
|
4032 TEST(count == KChangeEventTest2NumberOfEventsInView+1); |
|
4033 |
|
4034 // Check changes |
|
4035 changeCount = changeObs->Changes().Count(); |
|
4036 TEST2(changeCount, 1); |
|
4037 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4038 TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view |
|
4039 TEST2(logId, TLogId(3)); |
|
4040 TEST2(viewIndex, 4); // 7, [6], 5, 4, 3, 2, 1, 0 |
|
4041 changeObs->ResetChanges(); |
|
4042 |
|
4043 // Move forwards and check |
|
4044 res = view->NextL(active->iStatus); |
|
4045 TEST(res); |
|
4046 active->StartL(); |
|
4047 CActiveScheduler::Start(); |
|
4048 TEST2(active->iStatus.Int(), KErrNone); |
|
4049 TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 3, 2, 1, 0 |
|
4050 res = view->NextL(active->iStatus); |
|
4051 TEST(res); |
|
4052 active->StartL(); |
|
4053 CActiveScheduler::Start(); |
|
4054 TEST2(active->iStatus.Int(), KErrNone); |
|
4055 TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0 |
|
4056 res = view->NextL(active->iStatus); |
|
4057 TEST(res); |
|
4058 active->StartL(); |
|
4059 CActiveScheduler::Start(); |
|
4060 TEST2(active->iStatus.Int(), KErrNone); |
|
4061 TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0 |
|
4062 |
|
4063 // Change 'Z' event so that its now missing from the view again |
|
4064 changeCount = changeObs->Changes().Count(); |
|
4065 TEST2(changeCount, 0); |
|
4066 active->StartL(); |
|
4067 event->SetId(TLogId(3)); |
|
4068 aClient.GetEvent(*event, active->iStatus); |
|
4069 CActiveScheduler::Start(); |
|
4070 TEST2(active->iStatus.Int(), KErrNone); |
|
4071 // |
|
4072 event->SetContact(0); |
|
4073 active->StartL(); |
|
4074 changeObs->StartCollectingChanges(); |
|
4075 aClient.ChangeEvent(*event, active->iStatus); |
|
4076 CActiveScheduler::Start(); |
|
4077 TEST2(active->iStatus.Int(), KErrNone); |
|
4078 count = view->CountL(); |
|
4079 TEST2(count, KChangeEventTest2NumberOfEventsInView); |
|
4080 |
|
4081 // Check changes |
|
4082 changeCount = changeObs->Changes().Count(); |
|
4083 TEST2(changeCount, 1); |
|
4084 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4085 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4086 TEST2(logId, TLogId(3)); |
|
4087 TEST2(viewIndex, 4); // 7, 6, 5, 4, [2], 1, 0 |
|
4088 changeObs->ResetChanges(); |
|
4089 |
|
4090 // Move forwards and check |
|
4091 res = view->NextL(active->iStatus); |
|
4092 TEST(res); |
|
4093 active->StartL(); |
|
4094 CActiveScheduler::Start(); |
|
4095 TEST2(active->iStatus.Int(), KErrNone); |
|
4096 TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0 |
|
4097 res = view->NextL(active->iStatus); |
|
4098 TEST(res); |
|
4099 active->StartL(); |
|
4100 CActiveScheduler::Start(); |
|
4101 TEST2(active->iStatus.Int(), KErrNone); |
|
4102 TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0] |
|
4103 |
|
4104 // Move back one |
|
4105 res = view->PreviousL(active->iStatus); |
|
4106 TEST(res); |
|
4107 active->StartL(); |
|
4108 CActiveScheduler::Start(); |
|
4109 TEST2(active->iStatus.Int(), KErrNone); |
|
4110 TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0 |
|
4111 changeCount = changeObs->Changes().Count(); |
|
4112 TEST2(changeCount, 0); |
|
4113 |
|
4114 // Change 'Z' event so that it now appears in the view |
|
4115 active->StartL(); |
|
4116 event->SetId(TLogId(3)); |
|
4117 aClient.GetEvent(*event, active->iStatus); |
|
4118 CActiveScheduler::Start(); |
|
4119 TEST2(active->iStatus.Int(), KErrNone); |
|
4120 // |
|
4121 event->SetContact(KTestContact); |
|
4122 active->StartL(); |
|
4123 changeObs->StartCollectingChanges(); |
|
4124 aClient.ChangeEvent(*event, active->iStatus); |
|
4125 CActiveScheduler::Start(); |
|
4126 TEST2(active->iStatus.Int(), KErrNone); |
|
4127 count = view->CountL(); |
|
4128 TEST2(count, KChangeEventTest2NumberOfEventsInView+1); |
|
4129 |
|
4130 // Check changes |
|
4131 changeCount = changeObs->Changes().Count(); |
|
4132 TEST2(changeCount, 1); |
|
4133 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4134 TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view |
|
4135 TEST2(logId, TLogId(3)); |
|
4136 TEST2(viewIndex, 4); // 7, 6, 5, 4, 3, 2, [1], 0 |
|
4137 changeObs->ResetChanges(); |
|
4138 |
|
4139 // Check can only move forward one more record |
|
4140 res = view->NextL(active->iStatus); |
|
4141 TEST(res); |
|
4142 active->StartL(); |
|
4143 CActiveScheduler::Start(); |
|
4144 TEST2(active->iStatus.Int(), KErrNone); |
|
4145 TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 3, 2, 1, [0] |
|
4146 |
|
4147 // Move back until we are before the inserted record |
|
4148 res = view->PreviousL(active->iStatus); |
|
4149 TEST(res); |
|
4150 active->StartL(); |
|
4151 CActiveScheduler::Start(); |
|
4152 TEST2(active->iStatus.Int(), KErrNone); |
|
4153 TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 3, 2, [1], 0 |
|
4154 res = view->PreviousL(active->iStatus); |
|
4155 TEST(res); |
|
4156 active->StartL(); |
|
4157 CActiveScheduler::Start(); |
|
4158 TEST2(active->iStatus.Int(), KErrNone); |
|
4159 TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, 3, [2], 1, 0 |
|
4160 res = view->PreviousL(active->iStatus); |
|
4161 TEST(res); |
|
4162 active->StartL(); |
|
4163 CActiveScheduler::Start(); |
|
4164 TEST2(active->iStatus.Int(), KErrNone); |
|
4165 TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0 |
|
4166 res = view->PreviousL(active->iStatus); |
|
4167 TEST(res); |
|
4168 active->StartL(); |
|
4169 CActiveScheduler::Start(); |
|
4170 TEST2(active->iStatus.Int(), KErrNone); |
|
4171 TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0 |
|
4172 changeCount = changeObs->Changes().Count(); |
|
4173 TEST2(changeCount, 0); |
|
4174 |
|
4175 // Change 'Z' event so that its now missing from the view again |
|
4176 active->StartL(); |
|
4177 event->SetId(TLogId(3)); |
|
4178 aClient.GetEvent(*event, active->iStatus); |
|
4179 CActiveScheduler::Start(); |
|
4180 TEST2(active->iStatus.Int(), KErrNone); |
|
4181 // |
|
4182 event->SetContact(0); |
|
4183 active->StartL(); |
|
4184 changeObs->StartCollectingChanges(); |
|
4185 aClient.ChangeEvent(*event, active->iStatus); |
|
4186 CActiveScheduler::Start(); |
|
4187 TEST2(active->iStatus.Int(), KErrNone); |
|
4188 count = view->CountL(); |
|
4189 TEST2(count, KChangeEventTest2NumberOfEventsInView); |
|
4190 |
|
4191 // Check changes |
|
4192 changeCount = changeObs->Changes().Count(); |
|
4193 TEST2(changeCount, 1); |
|
4194 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4195 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4196 TEST2(logId, TLogId(3)); |
|
4197 TEST2(viewIndex, 4); // 7, 6, 5, [4], 2, 1, 0 |
|
4198 changeObs->ResetChanges(); |
|
4199 |
|
4200 // Check navigating to the end of the view |
|
4201 res = view->NextL(active->iStatus); |
|
4202 TEST(res); |
|
4203 active->StartL(); |
|
4204 CActiveScheduler::Start(); |
|
4205 TEST2(active->iStatus.Int(), KErrNone); |
|
4206 TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, [2], 1, 0 |
|
4207 res = view->NextL(active->iStatus); |
|
4208 TEST(res); |
|
4209 active->StartL(); |
|
4210 CActiveScheduler::Start(); |
|
4211 TEST2(active->iStatus.Int(), KErrNone); |
|
4212 TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0 |
|
4213 res = view->NextL(active->iStatus); |
|
4214 TEST(res); |
|
4215 active->StartL(); |
|
4216 CActiveScheduler::Start(); |
|
4217 TEST2(active->iStatus.Int(), KErrNone); |
|
4218 TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0] |
|
4219 changeCount = changeObs->Changes().Count(); |
|
4220 TEST2(changeCount, 0); |
|
4221 res = view->NextL(active->iStatus); |
|
4222 TEST(!res); |
|
4223 |
|
4224 // Delete everything in the view and make sure we can't navigate anymore. |
|
4225 active->StartL(); |
|
4226 aClient.DeleteEvent(TLogId(4), active->iStatus); |
|
4227 CActiveScheduler::Start(); |
|
4228 TEST2(active->iStatus.Int(), KErrNone); |
|
4229 count = view->CountL(); |
|
4230 TEST(count == KChangeEventTest2NumberOfEventsInView - 1); |
|
4231 changeCount = changeObs->Changes().Count(); |
|
4232 TEST2(changeCount, 1); |
|
4233 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4234 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4235 TEST2(logId, TLogId(4)); |
|
4236 TEST2(viewIndex, 3); // 7, 6, 5, 2, 1, [0] |
|
4237 changeObs->ResetChanges(); |
|
4238 // |
|
4239 active->StartL(); |
|
4240 aClient.DeleteEvent(TLogId(7), active->iStatus); |
|
4241 CActiveScheduler::Start(); |
|
4242 TEST2(active->iStatus.Int(), KErrNone); |
|
4243 count = view->CountL(); |
|
4244 TEST(count == KChangeEventTest2NumberOfEventsInView - 2); |
|
4245 changeCount = changeObs->Changes().Count(); |
|
4246 TEST2(changeCount, 1); |
|
4247 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4248 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4249 TEST2(logId, TLogId(7)); |
|
4250 TEST2(viewIndex, 0); // 6, 5, 2, 1, [0] |
|
4251 changeObs->ResetChanges(); |
|
4252 // |
|
4253 active->StartL(); |
|
4254 aClient.DeleteEvent(TLogId(0), active->iStatus); |
|
4255 CActiveScheduler::Start(); |
|
4256 TEST2(active->iStatus.Int(), KErrNone); |
|
4257 count = view->CountL(); |
|
4258 TEST(count == KChangeEventTest2NumberOfEventsInView - 3); |
|
4259 changeCount = changeObs->Changes().Count(); |
|
4260 TEST2(changeCount, 1); |
|
4261 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4262 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4263 TEST2(logId, TLogId(0)); |
|
4264 TEST2(viewIndex, 4); // 6, 5, 2, [1] |
|
4265 changeObs->ResetChanges(); |
|
4266 // |
|
4267 active->StartL(); |
|
4268 aClient.DeleteEvent(TLogId(5), active->iStatus); |
|
4269 CActiveScheduler::Start(); |
|
4270 TEST2(active->iStatus.Int(), KErrNone); |
|
4271 count = view->CountL(); |
|
4272 TEST(count == KChangeEventTest2NumberOfEventsInView - 4); |
|
4273 changeCount = changeObs->Changes().Count(); |
|
4274 TEST2(changeCount, 1); |
|
4275 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4276 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4277 TEST2(logId, TLogId(5)); |
|
4278 TEST2(viewIndex, 1); // 6, 2, [1] |
|
4279 changeObs->ResetChanges(); |
|
4280 // |
|
4281 active->StartL(); |
|
4282 aClient.DeleteEvent(TLogId(2), active->iStatus); |
|
4283 CActiveScheduler::Start(); |
|
4284 TEST2(active->iStatus.Int(), KErrNone); |
|
4285 count = view->CountL(); |
|
4286 TEST(count == KChangeEventTest2NumberOfEventsInView - 5); |
|
4287 changeCount = changeObs->Changes().Count(); |
|
4288 TEST2(changeCount, 1); |
|
4289 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4290 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4291 TEST2(logId, TLogId(2)); |
|
4292 TEST2(viewIndex, 1); // 6, [1] |
|
4293 changeObs->ResetChanges(); |
|
4294 // |
|
4295 active->StartL(); |
|
4296 aClient.DeleteEvent(TLogId(6), active->iStatus); |
|
4297 CActiveScheduler::Start(); |
|
4298 TEST2(active->iStatus.Int(), KErrNone); |
|
4299 count = view->CountL(); |
|
4300 TEST(count == KChangeEventTest2NumberOfEventsInView - 6); |
|
4301 changeCount = changeObs->Changes().Count(); |
|
4302 TEST2(changeCount, 1); |
|
4303 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4304 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4305 TEST2(logId, TLogId(6)); |
|
4306 TEST2(viewIndex, 0); // [1] |
|
4307 changeObs->ResetChanges(); |
|
4308 |
|
4309 // Check we can't go backwards or forwards |
|
4310 res = view->NextL(active->iStatus); |
|
4311 TEST(!res); |
|
4312 res = view->PreviousL(active->iStatus); |
|
4313 TEST(!res); |
|
4314 res = view->FirstL(active->iStatus); |
|
4315 TEST(res); |
|
4316 active->StartL(); |
|
4317 CActiveScheduler::Start(); |
|
4318 TEST2(active->iStatus.Int(), KErrNone); |
|
4319 TEST2(view->Event().Id(), TLogId(1)); // [1] |
|
4320 res = view->LastL(active->iStatus); |
|
4321 TEST(res); |
|
4322 active->StartL(); |
|
4323 CActiveScheduler::Start(); |
|
4324 TEST2(active->iStatus.Int(), KErrNone); |
|
4325 TEST2(view->Event().Id(), TLogId(1)); // [1] |
|
4326 |
|
4327 // Delete last event in view |
|
4328 active->StartL(); |
|
4329 aClient.DeleteEvent(TLogId(1), active->iStatus); |
|
4330 CActiveScheduler::Start(); |
|
4331 TEST2(active->iStatus.Int(), KErrNone); |
|
4332 count = view->CountL(); |
|
4333 TEST(count == KChangeEventTest2NumberOfEventsInView - 7); |
|
4334 changeCount = changeObs->Changes().Count(); |
|
4335 TEST2(changeCount, 1); |
|
4336 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4337 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4338 TEST2(logId, TLogId(1)); |
|
4339 TEST2(viewIndex, 0); // *Empty* |
|
4340 changeObs->ResetChanges(); |
|
4341 |
|
4342 // Check we can't navigate |
|
4343 res = view->NextL(active->iStatus); |
|
4344 TEST(!res); |
|
4345 res = view->PreviousL(active->iStatus); |
|
4346 TEST(!res); |
|
4347 res = view->FirstL(active->iStatus); |
|
4348 TEST(!res); |
|
4349 res = view->LastL(active->iStatus); |
|
4350 TEST(!res); |
|
4351 |
|
4352 CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event |
|
4353 } |
|
4354 |
|
4355 /** |
|
4356 @SYMTestCaseID SYSLIB-LOGENG-CT-0871 |
|
4357 @SYMTestCaseDesc Tests for CLogViewChangeObserver::HaveChanges(),Changes() functions |
|
4358 @SYMTestPriority High |
|
4359 @SYMTestActions Check for observing changes while adding,deleting events.Check for observing changes after a backup. |
|
4360 Check for observing changes while traversing through the events in the view. |
|
4361 Delete everything in the view and make sure we can't navigate anymore. |
|
4362 @SYMTestExpectedResults Test must not fail |
|
4363 @SYMREQ REQ0000 |
|
4364 */ |
|
4365 LOCAL_C void TestViewChangeEvents2aL(CLogClient& aClient) |
|
4366 { |
|
4367 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0871 ")); |
|
4368 // Transients |
|
4369 TInt i=0; |
|
4370 TInt count; |
|
4371 TBuf<1> description; description.SetLength(1); |
|
4372 TInt changeCount; |
|
4373 TLogId logId; |
|
4374 TInt viewIndex; |
|
4375 TLogDatabaseChangeType type; |
|
4376 TLogId runningNewId = 0; |
|
4377 // |
|
4378 const TInt KChangeEventTest2NumberOfEventsInView = 7; |
|
4379 TestUtils::DeleteDatabaseL(); |
|
4380 |
|
4381 CLogEvent* event = CLogEvent::NewL(); |
|
4382 CleanupStack::PushL(event); |
|
4383 |
|
4384 CLogFilter* filter = CLogFilter::NewL(); |
|
4385 CleanupStack::PushL(filter); |
|
4386 filter->SetContact(KTestContact); |
|
4387 |
|
4388 CTestActive* active = new(ELeave)CTestActive(); |
|
4389 CleanupStack::PushL(active); |
|
4390 |
|
4391 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); |
|
4392 changeObs->SetActive(); |
|
4393 |
|
4394 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); |
|
4395 CleanupStack::PushL(view); |
|
4396 |
|
4397 // Add seed events |
|
4398 TBuf<KLogMaxDirectionLength> buf; |
|
4399 aClient.GetString(buf, R_LOG_DIR_IN); |
|
4400 |
|
4401 event->SetEventType(KLogPacketDataEventTypeUid); |
|
4402 event->SetDirection(buf); |
|
4403 // |
|
4404 for(count = 0; count < KChangeEventTest2NumberOfEventsInView; count++) |
|
4405 { |
|
4406 // Have to create one event which isn't in the view by default, but |
|
4407 // when it 'appears' will be part way through |
|
4408 if (count == 3 && description[0] != TUint16('Z')) |
|
4409 { |
|
4410 description[0] = TUint16('Z'); |
|
4411 event->SetContact(0); |
|
4412 |
|
4413 // Go back and do this one again but with a real view entry this time, i.e. 'D' |
|
4414 --count; |
|
4415 } |
|
4416 else |
|
4417 { |
|
4418 description[0] = TUint16('A' + KChangeEventTest2NumberOfEventsInView - count); |
|
4419 event->SetContact(KTestContact); |
|
4420 } |
|
4421 event->SetDescription(description); |
|
4422 // |
|
4423 active->StartL(); |
|
4424 aClient.AddEvent(*event, active->iStatus); |
|
4425 CActiveScheduler::Start(); |
|
4426 test(active->iStatus == KErrNone); |
|
4427 test(event->Id() == runningNewId++); |
|
4428 User::After(1 * 1000000); |
|
4429 } |
|
4430 // |
|
4431 test(view->CountL() == 0); |
|
4432 active->StartL(); |
|
4433 test(view->SetFilterL(*filter, active->iStatus)); |
|
4434 CActiveScheduler::Start(); |
|
4435 test(active->iStatus == KErrNone); |
|
4436 count = view->CountL(); |
|
4437 test(count == KChangeEventTest2NumberOfEventsInView); |
|
4438 |
|
4439 |
|
4440 test(view->FirstL(active->iStatus)); |
|
4441 do |
|
4442 { |
|
4443 active->StartL(); |
|
4444 CActiveScheduler::Start(); |
|
4445 test(active->iStatus == KErrNone); |
|
4446 RDebug::Print(_L("View Entry[%d]: Id: %d"), i++, view->Event().Id()); |
|
4447 } |
|
4448 while(view->NextL(active->iStatus)); |
|
4449 |
|
4450 // Check addition change events |
|
4451 test(view->FirstL(active->iStatus)); |
|
4452 active->StartL(); |
|
4453 CActiveScheduler::Start(); |
|
4454 test(active->iStatus == KErrNone); // [7], 6, 5, 4, 2, 1, 0 |
|
4455 test(view->Event().Id() == 7); |
|
4456 |
|
4457 // Add a new entry - should appear as the first item in the view |
|
4458 description[0] = TUint16('X'); |
|
4459 event->SetDescription(description); |
|
4460 |
|
4461 // Check that changes work after a backup |
|
4462 StartBackupL(); |
|
4463 DelayL(1000000); |
|
4464 TestLogClosedL(); |
|
4465 EndBackupL(); |
|
4466 TestLogOpenL(); |
|
4467 |
|
4468 // |
|
4469 changeObs->StartCollectingChanges(); |
|
4470 active->StartL(); |
|
4471 aClient.AddEvent(*event, active->iStatus); |
|
4472 CActiveScheduler::Start(); |
|
4473 test(active->iStatus == KErrNone); |
|
4474 test(event->Id() == runningNewId++); |
|
4475 |
|
4476 // Check changes |
|
4477 changeCount = changeObs->Changes().Count(); |
|
4478 test(changeCount == 1); |
|
4479 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4480 test(type == ELogChangeTypeEventAdded); |
|
4481 test(logId == runningNewId-1); |
|
4482 test(viewIndex == 0); // 8, [7], 6, 5, 4, 2, 1, 0 |
|
4483 |
|
4484 // Check we can go forward |
|
4485 test(view->NextL(active->iStatus)); |
|
4486 active->StartL(); |
|
4487 CActiveScheduler::Start(); |
|
4488 test(active->iStatus == KErrNone); |
|
4489 test(view->Event().Id() == TLogId(6)); // 8, 7, [6], 5, 4, 2, 1, 0 |
|
4490 |
|
4491 // Check we can now go back (new first entry) |
|
4492 test(view->PreviousL(active->iStatus)); |
|
4493 active->StartL(); |
|
4494 CActiveScheduler::Start(); |
|
4495 test(active->iStatus == KErrNone); // 8, [7], 6, 5, 4, 2, 1, 0 |
|
4496 test(view->Event().Id() == 7); |
|
4497 test(view->PreviousL(active->iStatus)); |
|
4498 active->StartL(); |
|
4499 CActiveScheduler::Start(); |
|
4500 test(active->iStatus == KErrNone); // [8], 7, 6, 5, 4, 2, 1, 0 |
|
4501 test(view->Event().Id() == TLogId(KChangeEventTest2NumberOfEventsInView+1)); |
|
4502 |
|
4503 // Delete added event |
|
4504 changeObs->ResetChanges(); |
|
4505 changeCount = changeObs->Changes().Count(); |
|
4506 test(changeCount == 0); |
|
4507 active->StartL(); |
|
4508 aClient.DeleteEvent(view->Event().Id(), active->iStatus); |
|
4509 CActiveScheduler::Start(); |
|
4510 test(active->iStatus == KErrNone); // [7], 6, 5, 4, 2, 1, 0 |
|
4511 |
|
4512 // Check deletion changes |
|
4513 changeCount = changeObs->Changes().Count(); |
|
4514 test(changeCount == 1); |
|
4515 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4516 test(type == ELogChangeTypeEventDeleted); |
|
4517 test(logId == runningNewId-1); |
|
4518 test(viewIndex == 0); |
|
4519 |
|
4520 // Go to end of view |
|
4521 test(view->LastL(active->iStatus)); |
|
4522 active->StartL(); |
|
4523 CActiveScheduler::Start(); |
|
4524 test(active->iStatus == KErrNone); |
|
4525 test(view->Event().Id() == TLogId(0)); // 7, 6, 5, 4, 2, 1, [0] |
|
4526 |
|
4527 // Add new event |
|
4528 description[0] = TUint16('X'); |
|
4529 event->SetDescription(description); |
|
4530 |
|
4531 // Check that changes work after a backup |
|
4532 StartBackupL(); |
|
4533 DelayL(1000000); |
|
4534 TestLogClosedL(); |
|
4535 EndBackupL(); |
|
4536 TestLogOpenL(); |
|
4537 |
|
4538 // |
|
4539 changeObs->StartCollectingChanges(); |
|
4540 active->StartL(); |
|
4541 aClient.AddEvent(*event, active->iStatus); |
|
4542 CActiveScheduler::Start(); |
|
4543 test(active->iStatus == KErrNone); |
|
4544 test(event->Id() == runningNewId++); |
|
4545 |
|
4546 // Check changes |
|
4547 changeCount = changeObs->Changes().Count(); |
|
4548 test(changeCount == 1); |
|
4549 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4550 test(type == ELogChangeTypeEventAdded); |
|
4551 test(logId == runningNewId-1); |
|
4552 test(viewIndex == 0); // 9, 7, 6, 5, 4, 2, 1, [0] |
|
4553 |
|
4554 // Check we can't go forward |
|
4555 test(!view->NextL(active->iStatus)); |
|
4556 |
|
4557 // Go back to the first record |
|
4558 test(view->FirstL(active->iStatus)); |
|
4559 active->StartL(); |
|
4560 CActiveScheduler::Start(); |
|
4561 test(active->iStatus == KErrNone); |
|
4562 test(view->Event().Id() == TLogId(runningNewId-1)); // 9, 7, 6, 5, 4, 2, 1, [0] |
|
4563 |
|
4564 // Delete added event |
|
4565 changeObs->ResetChanges(); |
|
4566 active->StartL(); |
|
4567 aClient.DeleteEvent(view->Event().Id(), active->iStatus); |
|
4568 CActiveScheduler::Start(); |
|
4569 test(active->iStatus == KErrNone); // [7], 6, 5, 4, 2, 1, 0 |
|
4570 |
|
4571 // Check deletion changes |
|
4572 changeCount = changeObs->Changes().Count(); |
|
4573 test(changeCount == 1); |
|
4574 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4575 test(type == ELogChangeTypeEventDeleted); |
|
4576 test(logId == runningNewId-1); |
|
4577 test(viewIndex == 0); |
|
4578 |
|
4579 // Go part way through view |
|
4580 test(view->NextL(active->iStatus)); |
|
4581 active->StartL(); |
|
4582 CActiveScheduler::Start(); |
|
4583 test(active->iStatus == KErrNone); |
|
4584 test(view->Event().Id() == TLogId(6)); // 7, [6], 5, 4, 2, 1, 0 |
|
4585 test(view->NextL(active->iStatus)); |
|
4586 active->StartL(); |
|
4587 CActiveScheduler::Start(); |
|
4588 test(active->iStatus == KErrNone); |
|
4589 test(view->Event().Id() == TLogId(5)); // 7, 6, [5], 4, 2, 1, 0 |
|
4590 |
|
4591 // Add new event |
|
4592 description[0] = TUint16('X'); |
|
4593 event->SetDescription(description); |
|
4594 |
|
4595 // Check that changes work after a backup |
|
4596 StartBackupL(); |
|
4597 DelayL(1000000); |
|
4598 TestLogClosedL(); |
|
4599 EndBackupL(); |
|
4600 TestLogOpenL(); |
|
4601 |
|
4602 // |
|
4603 changeObs->StartCollectingChanges(); |
|
4604 active->StartL(); |
|
4605 aClient.AddEvent(*event, active->iStatus); |
|
4606 CActiveScheduler::Start(); |
|
4607 test(active->iStatus == KErrNone); |
|
4608 test(event->Id() == runningNewId++); |
|
4609 |
|
4610 // Check changes |
|
4611 changeCount = changeObs->Changes().Count(); |
|
4612 test(changeCount == 1); |
|
4613 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4614 test(type == ELogChangeTypeEventAdded); |
|
4615 test(logId == runningNewId-1); |
|
4616 test(viewIndex == 0); // 10, 7, 6, [5], 4, 2, 1, 0 |
|
4617 changeObs->ResetChanges(); |
|
4618 |
|
4619 // Work back to beginning |
|
4620 test(view->PreviousL(active->iStatus)); |
|
4621 active->StartL(); |
|
4622 CActiveScheduler::Start(); |
|
4623 test(active->iStatus == KErrNone); |
|
4624 test(view->Event().Id() == TLogId(6)); // 10, 7, [6], 5, 4, 2, 1, 0 |
|
4625 test(view->PreviousL(active->iStatus)); |
|
4626 active->StartL(); |
|
4627 CActiveScheduler::Start(); |
|
4628 test(active->iStatus == KErrNone); |
|
4629 test(view->Event().Id() == TLogId(7)); // 10, [7], 6, 5, 4, 2, 1, 0 |
|
4630 test(view->PreviousL(active->iStatus)); |
|
4631 active->StartL(); |
|
4632 CActiveScheduler::Start(); |
|
4633 test(active->iStatus == KErrNone); |
|
4634 test(view->Event().Id() == runningNewId-1); // [10], 7, 6, 5, 4, 2, 1, 0 |
|
4635 |
|
4636 // Delete added event |
|
4637 changeCount = changeObs->Changes().Count(); |
|
4638 test(changeCount == 0); |
|
4639 active->StartL(); |
|
4640 aClient.DeleteEvent(view->Event().Id(), active->iStatus); |
|
4641 CActiveScheduler::Start(); |
|
4642 test(active->iStatus == KErrNone); // [7], 6, 5, 4, 2, 1, 0 |
|
4643 |
|
4644 // Check deletion changes |
|
4645 changeCount = changeObs->Changes().Count(); |
|
4646 test(changeCount == 1); |
|
4647 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4648 test(type == ELogChangeTypeEventDeleted); |
|
4649 test(logId == runningNewId-1); |
|
4650 test(viewIndex == 0); |
|
4651 changeObs->ResetChanges(); |
|
4652 |
|
4653 // Go back to the first record |
|
4654 test(view->FirstL(active->iStatus)); |
|
4655 active->StartL(); |
|
4656 CActiveScheduler::Start(); |
|
4657 test(active->iStatus == KErrNone); |
|
4658 test(view->Event().Id() == TLogId(7)); // [7], 6, 5, 4, 2, 1, 0 |
|
4659 |
|
4660 // Move one record forward |
|
4661 test(view->NextL(active->iStatus)); |
|
4662 active->StartL(); |
|
4663 CActiveScheduler::Start(); |
|
4664 test(active->iStatus == KErrNone); |
|
4665 test(view->Event().Id() == TLogId(6)); // 7, [6], 5, 4, 2, 1, 0 |
|
4666 |
|
4667 // Change 'Z' event so that it now appears in the view |
|
4668 changeCount = changeObs->Changes().Count(); |
|
4669 test(changeCount == 0); |
|
4670 active->StartL(); |
|
4671 event->SetId(TLogId(3)); |
|
4672 aClient.GetEvent(*event, active->iStatus); |
|
4673 CActiveScheduler::Start(); |
|
4674 test(active->iStatus == KErrNone); |
|
4675 // |
|
4676 event->SetContact(KTestContact); |
|
4677 active->StartL(); |
|
4678 |
|
4679 // Check that changes work after a backup |
|
4680 StartBackupL(); |
|
4681 DelayL(1000000); |
|
4682 TestLogClosedL(); |
|
4683 EndBackupL(); |
|
4684 TestLogOpenL(); |
|
4685 |
|
4686 changeObs->StartCollectingChanges(); |
|
4687 aClient.ChangeEvent(*event, active->iStatus); |
|
4688 CActiveScheduler::Start(); |
|
4689 test(active->iStatus == KErrNone); |
|
4690 count = view->CountL(); |
|
4691 test(count == KChangeEventTest2NumberOfEventsInView+1); |
|
4692 |
|
4693 // Check changes |
|
4694 changeCount = changeObs->Changes().Count(); |
|
4695 test(changeCount == 1); |
|
4696 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4697 test(type == ELogChangeTypeEventAdded); // Change resulted in an addition to the view |
|
4698 test(logId == TLogId(3)); |
|
4699 test(viewIndex == 4); // 7, [6], 5, 4, 3, 2, 1, 0 |
|
4700 changeObs->ResetChanges(); |
|
4701 |
|
4702 // Move forwards and check |
|
4703 test(view->NextL(active->iStatus)); |
|
4704 active->StartL(); |
|
4705 CActiveScheduler::Start(); |
|
4706 test(active->iStatus == KErrNone); |
|
4707 test(view->Event().Id() == TLogId(5)); // 7, 6, [5], 4, 3, 2, 1, 0 |
|
4708 test(view->NextL(active->iStatus)); |
|
4709 active->StartL(); |
|
4710 CActiveScheduler::Start(); |
|
4711 test(active->iStatus == KErrNone); |
|
4712 test(view->Event().Id() == TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0 |
|
4713 test(view->NextL(active->iStatus)); |
|
4714 active->StartL(); |
|
4715 CActiveScheduler::Start(); |
|
4716 test(active->iStatus == KErrNone); |
|
4717 test(view->Event().Id() == TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0 |
|
4718 |
|
4719 // Change 'Z' event so that its now missing from the view again |
|
4720 changeCount = changeObs->Changes().Count(); |
|
4721 test(changeCount == 0); |
|
4722 active->StartL(); |
|
4723 event->SetId(TLogId(3)); |
|
4724 aClient.GetEvent(*event, active->iStatus); |
|
4725 CActiveScheduler::Start(); |
|
4726 test(active->iStatus == KErrNone); |
|
4727 // |
|
4728 event->SetContact(0); |
|
4729 active->StartL(); |
|
4730 |
|
4731 // Check that changes work after a backup |
|
4732 StartBackupL(); |
|
4733 DelayL(1000000); |
|
4734 TestLogClosedL(); |
|
4735 EndBackupL(); |
|
4736 TestLogOpenL(); |
|
4737 |
|
4738 changeObs->StartCollectingChanges(); |
|
4739 aClient.ChangeEvent(*event, active->iStatus); |
|
4740 CActiveScheduler::Start(); |
|
4741 test(active->iStatus == KErrNone); |
|
4742 count = view->CountL(); |
|
4743 test(count == KChangeEventTest2NumberOfEventsInView); |
|
4744 |
|
4745 // Check changes |
|
4746 changeCount = changeObs->Changes().Count(); |
|
4747 test(changeCount == 1); |
|
4748 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4749 test(type == ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4750 test(logId == TLogId(3)); |
|
4751 test(viewIndex == 4); // 7, 6, 5, 4, [2], 1, 0 |
|
4752 changeObs->ResetChanges(); |
|
4753 |
|
4754 // Move forwards and check |
|
4755 test(view->NextL(active->iStatus)); |
|
4756 active->StartL(); |
|
4757 CActiveScheduler::Start(); |
|
4758 test(active->iStatus == KErrNone); |
|
4759 test(view->Event().Id() == TLogId(1)); // 7, 6, 5, 4, 2, [1], 0 |
|
4760 test(view->NextL(active->iStatus)); |
|
4761 active->StartL(); |
|
4762 CActiveScheduler::Start(); |
|
4763 test(active->iStatus == KErrNone); |
|
4764 test(view->Event().Id() == TLogId(0)); // 7, 6, 5, 4, 2, 1, [0] |
|
4765 |
|
4766 // Move back one |
|
4767 test(view->PreviousL(active->iStatus)); |
|
4768 active->StartL(); |
|
4769 CActiveScheduler::Start(); |
|
4770 test(active->iStatus == KErrNone); |
|
4771 test(view->Event().Id() == TLogId(1)); // 7, 6, 5, 4, 2, [1], 0 |
|
4772 changeCount = changeObs->Changes().Count(); |
|
4773 test(changeCount == 0); |
|
4774 |
|
4775 // Change 'Z' event so that it now appears in the view |
|
4776 active->StartL(); |
|
4777 event->SetId(TLogId(3)); |
|
4778 aClient.GetEvent(*event, active->iStatus); |
|
4779 CActiveScheduler::Start(); |
|
4780 test(active->iStatus == KErrNone); |
|
4781 // |
|
4782 event->SetContact(KTestContact); |
|
4783 active->StartL(); |
|
4784 |
|
4785 // Check that changes work after a backup |
|
4786 StartBackupL(); |
|
4787 DelayL(1000000); |
|
4788 TestLogClosedL(); |
|
4789 EndBackupL(); |
|
4790 TestLogOpenL(); |
|
4791 |
|
4792 changeObs->StartCollectingChanges(); |
|
4793 aClient.ChangeEvent(*event, active->iStatus); |
|
4794 CActiveScheduler::Start(); |
|
4795 test(active->iStatus == KErrNone); |
|
4796 count = view->CountL(); |
|
4797 test(count == KChangeEventTest2NumberOfEventsInView+1); |
|
4798 |
|
4799 // Check changes |
|
4800 changeCount = changeObs->Changes().Count(); |
|
4801 test(changeCount == 1); |
|
4802 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4803 test(type == ELogChangeTypeEventAdded); // Change resulted in an addition to the view |
|
4804 test(logId == TLogId(3)); |
|
4805 test(viewIndex == 4); // 7, 6, 5, 4, 3, 2, [1], 0 |
|
4806 changeObs->ResetChanges(); |
|
4807 |
|
4808 // Check can only move forward one more record |
|
4809 test(view->NextL(active->iStatus)); |
|
4810 active->StartL(); |
|
4811 CActiveScheduler::Start(); |
|
4812 test(active->iStatus == KErrNone); |
|
4813 test(view->Event().Id() == TLogId(0)); // 7, 6, 5, 4, 3, 2, 1, [0] |
|
4814 |
|
4815 // Move back until we are before the inserted record |
|
4816 test(view->PreviousL(active->iStatus)); |
|
4817 active->StartL(); |
|
4818 CActiveScheduler::Start(); |
|
4819 test(active->iStatus == KErrNone); |
|
4820 test(view->Event().Id() == TLogId(1)); // 7, 6, 5, 4, 3, 2, [1], 0 |
|
4821 test(view->PreviousL(active->iStatus)); |
|
4822 active->StartL(); |
|
4823 CActiveScheduler::Start(); |
|
4824 test(active->iStatus == KErrNone); |
|
4825 test(view->Event().Id() == TLogId(2)); // 7, 6, 5, 4, 3, [2], 1, 0 |
|
4826 test(view->PreviousL(active->iStatus)); |
|
4827 active->StartL(); |
|
4828 CActiveScheduler::Start(); |
|
4829 test(active->iStatus == KErrNone); |
|
4830 test(view->Event().Id() == TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0 |
|
4831 test(view->PreviousL(active->iStatus)); |
|
4832 active->StartL(); |
|
4833 CActiveScheduler::Start(); |
|
4834 test(active->iStatus == KErrNone); |
|
4835 test(view->Event().Id() == TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0 |
|
4836 changeCount = changeObs->Changes().Count(); |
|
4837 test(changeCount == 0); |
|
4838 |
|
4839 // Change 'Z' event so that its now missing from the view again |
|
4840 active->StartL(); |
|
4841 event->SetId(TLogId(3)); |
|
4842 aClient.GetEvent(*event, active->iStatus); |
|
4843 CActiveScheduler::Start(); |
|
4844 test(active->iStatus == KErrNone); |
|
4845 // |
|
4846 event->SetContact(0); |
|
4847 active->StartL(); |
|
4848 |
|
4849 // Check that changes work after a backup |
|
4850 StartBackupL(); |
|
4851 DelayL(1000000); |
|
4852 TestLogClosedL(); |
|
4853 EndBackupL(); |
|
4854 TestLogOpenL(); |
|
4855 |
|
4856 changeObs->StartCollectingChanges(); |
|
4857 aClient.ChangeEvent(*event, active->iStatus); |
|
4858 CActiveScheduler::Start(); |
|
4859 test(active->iStatus == KErrNone); |
|
4860 count = view->CountL(); |
|
4861 test(count == KChangeEventTest2NumberOfEventsInView); |
|
4862 |
|
4863 // Check changes |
|
4864 changeCount = changeObs->Changes().Count(); |
|
4865 test(changeCount == 1); |
|
4866 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4867 test(type == ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4868 test(logId == TLogId(3)); |
|
4869 test(viewIndex == 4); // 7, 6, 5, [4], 2, 1, 0 |
|
4870 changeObs->ResetChanges(); |
|
4871 |
|
4872 // Check navigating to the end of the view |
|
4873 test(view->NextL(active->iStatus)); |
|
4874 active->StartL(); |
|
4875 CActiveScheduler::Start(); |
|
4876 test(active->iStatus == KErrNone); |
|
4877 test(view->Event().Id() == TLogId(2)); // 7, 6, 5, 4, [2], 1, 0 |
|
4878 test(view->NextL(active->iStatus)); |
|
4879 active->StartL(); |
|
4880 CActiveScheduler::Start(); |
|
4881 test(active->iStatus == KErrNone); |
|
4882 test(view->Event().Id() == TLogId(1)); // 7, 6, 5, 4, 2, [1], 0 |
|
4883 test(view->NextL(active->iStatus)); |
|
4884 active->StartL(); |
|
4885 CActiveScheduler::Start(); |
|
4886 test(active->iStatus == KErrNone); |
|
4887 test(view->Event().Id() == TLogId(0)); // 7, 6, 5, 4, 2, 1, [0] |
|
4888 changeCount = changeObs->Changes().Count(); |
|
4889 test(changeCount == 0); |
|
4890 test(!view->NextL(active->iStatus)); |
|
4891 |
|
4892 // Delete everything in the view and make sure we can't navigate anymore. |
|
4893 active->StartL(); |
|
4894 aClient.DeleteEvent(TLogId(4), active->iStatus); |
|
4895 CActiveScheduler::Start(); |
|
4896 test(active->iStatus == KErrNone); |
|
4897 count = view->CountL(); |
|
4898 test(count == KChangeEventTest2NumberOfEventsInView - 1); |
|
4899 changeCount = changeObs->Changes().Count(); |
|
4900 test(changeCount == 1); |
|
4901 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4902 test(type == ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4903 test(logId == TLogId(4)); |
|
4904 test(viewIndex == 3); // 7, 6, 5, 2, 1, [0] |
|
4905 changeObs->ResetChanges(); |
|
4906 // |
|
4907 active->StartL(); |
|
4908 aClient.DeleteEvent(TLogId(7), active->iStatus); |
|
4909 CActiveScheduler::Start(); |
|
4910 test(active->iStatus == KErrNone); |
|
4911 count = view->CountL(); |
|
4912 test(count == KChangeEventTest2NumberOfEventsInView - 2); |
|
4913 changeCount = changeObs->Changes().Count(); |
|
4914 test(changeCount == 1); |
|
4915 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4916 test(type == ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4917 test(logId == TLogId(7)); |
|
4918 test(viewIndex == 0); // 6, 5, 2, 1, [0] |
|
4919 changeObs->ResetChanges(); |
|
4920 // |
|
4921 active->StartL(); |
|
4922 aClient.DeleteEvent(TLogId(0), active->iStatus); |
|
4923 CActiveScheduler::Start(); |
|
4924 test(active->iStatus == KErrNone); |
|
4925 count = view->CountL(); |
|
4926 test(count == KChangeEventTest2NumberOfEventsInView - 3); |
|
4927 changeCount = changeObs->Changes().Count(); |
|
4928 test(changeCount == 1); |
|
4929 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4930 test(type == ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4931 test(logId == TLogId(0)); |
|
4932 test(viewIndex == 4); // 6, 5, 2, [1] |
|
4933 changeObs->ResetChanges(); |
|
4934 // |
|
4935 active->StartL(); |
|
4936 aClient.DeleteEvent(TLogId(5), active->iStatus); |
|
4937 CActiveScheduler::Start(); |
|
4938 test(active->iStatus == KErrNone); |
|
4939 count = view->CountL(); |
|
4940 test(count == KChangeEventTest2NumberOfEventsInView - 4); |
|
4941 changeCount = changeObs->Changes().Count(); |
|
4942 test(changeCount == 1); |
|
4943 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4944 test(type == ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4945 test(logId == TLogId(5)); |
|
4946 test(viewIndex == 1); // 6, 2, [1] |
|
4947 changeObs->ResetChanges(); |
|
4948 // |
|
4949 active->StartL(); |
|
4950 aClient.DeleteEvent(TLogId(2), active->iStatus); |
|
4951 CActiveScheduler::Start(); |
|
4952 test(active->iStatus == KErrNone); |
|
4953 count = view->CountL(); |
|
4954 test(count == KChangeEventTest2NumberOfEventsInView - 5); |
|
4955 changeCount = changeObs->Changes().Count(); |
|
4956 test(changeCount == 1); |
|
4957 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4958 test(type == ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4959 test(logId == TLogId(2)); |
|
4960 test(viewIndex == 1); // 6, [1] |
|
4961 changeObs->ResetChanges(); |
|
4962 // |
|
4963 active->StartL(); |
|
4964 aClient.DeleteEvent(TLogId(6), active->iStatus); |
|
4965 CActiveScheduler::Start(); |
|
4966 test(active->iStatus == KErrNone); |
|
4967 count = view->CountL(); |
|
4968 test(count == KChangeEventTest2NumberOfEventsInView - 6); |
|
4969 changeCount = changeObs->Changes().Count(); |
|
4970 test(changeCount == 1); |
|
4971 type = changeObs->Changes().At(0, logId, viewIndex); |
|
4972 test(type == ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
4973 test(logId == TLogId(6)); |
|
4974 test(viewIndex == 0); // [1] |
|
4975 changeObs->ResetChanges(); |
|
4976 |
|
4977 // Check we can't go backwards or forwards |
|
4978 test(!view->NextL(active->iStatus)); |
|
4979 test(!view->PreviousL(active->iStatus)); |
|
4980 test(view->FirstL(active->iStatus)); |
|
4981 active->StartL(); |
|
4982 CActiveScheduler::Start(); |
|
4983 test(active->iStatus == KErrNone); |
|
4984 test(view->Event().Id() == TLogId(1)); // [1] |
|
4985 test(view->LastL(active->iStatus)); |
|
4986 active->StartL(); |
|
4987 CActiveScheduler::Start(); |
|
4988 test(active->iStatus == KErrNone); |
|
4989 test(view->Event().Id() == TLogId(1)); // [1] |
|
4990 |
|
4991 // Delete last event in view |
|
4992 active->StartL(); |
|
4993 aClient.DeleteEvent(TLogId(1), active->iStatus); |
|
4994 CActiveScheduler::Start(); |
|
4995 test(active->iStatus == KErrNone); |
|
4996 count = view->CountL(); |
|
4997 test(count == KChangeEventTest2NumberOfEventsInView - 7); |
|
4998 changeCount = changeObs->Changes().Count(); |
|
4999 test(changeCount == 1); |
|
5000 type = changeObs->Changes().At(0, logId, viewIndex); |
|
5001 test(type == ELogChangeTypeEventDeleted); // Change resulted in a removal from the view |
|
5002 test(logId == TLogId(1)); |
|
5003 test(viewIndex == 0); // *Empty* |
|
5004 changeObs->ResetChanges(); |
|
5005 |
|
5006 // Check we can't navigate |
|
5007 test(!view->NextL(active->iStatus)); |
|
5008 test(!view->PreviousL(active->iStatus)); |
|
5009 test(!view->FirstL(active->iStatus)); |
|
5010 test(!view->LastL(active->iStatus)); |
|
5011 |
|
5012 CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event |
|
5013 } |
|
5014 |
|
5015 /** |
|
5016 @SYMTestCaseID SYSLIB-LOGENG-CT-0872 |
|
5017 @SYMTestCaseDesc Filtering log view test |
|
5018 @SYMTestPriority High |
|
5019 @SYMTestActions Add the Voice call,FAX,SMS event types to the log client. |
|
5020 Set all the event types to filter list.Check for the correct event types and no errors |
|
5021 @SYMTestExpectedResults Test must not fail |
|
5022 @SYMREQ REQ0000 |
|
5023 */ |
|
5024 LOCAL_C void TestViewFilteringDefect1L(CLogClient& aClient) |
|
5025 { |
|
5026 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0872 ")); |
|
5027 CLogEvent* event = CLogEvent::NewL(); |
|
5028 CleanupStack::PushL(event); |
|
5029 |
|
5030 CTestActive* active = new(ELeave) CTestActive(); |
|
5031 CleanupStack::PushL(active); |
|
5032 |
|
5033 // VOICE CALL |
|
5034 event->SetEventType(KLogCallEventTypeUid); |
|
5035 active->StartL(); |
|
5036 aClient.AddEvent(*event, active->iStatus); |
|
5037 CActiveScheduler::Start(); |
|
5038 TEST2(active->iStatus.Int(), KErrNone); |
|
5039 const TLogId event1 = event->Id(); |
|
5040 |
|
5041 // FAX |
|
5042 event->SetEventType(KLogFaxEventTypeUid); |
|
5043 active->StartL(); |
|
5044 aClient.AddEvent(*event, active->iStatus); |
|
5045 CActiveScheduler::Start(); |
|
5046 TEST2(active->iStatus.Int(), KErrNone); |
|
5047 const TLogId event2 = event->Id(); |
|
5048 (void) event2; |
|
5049 |
|
5050 // SMS, CONTACT SEARCHED |
|
5051 event->SetEventType(KLogShortMessageEventTypeUid); |
|
5052 event->SetFlags(KLogEventContactSearched); |
|
5053 active->StartL(); |
|
5054 aClient.AddEvent(*event, active->iStatus); |
|
5055 CActiveScheduler::Start(); |
|
5056 TEST2(active->iStatus.Int(), KErrNone); |
|
5057 const TLogId event3 = event->Id(); |
|
5058 |
|
5059 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); |
|
5060 changeObs->SetActive(); |
|
5061 |
|
5062 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); |
|
5063 CleanupStack::PushL(view); |
|
5064 |
|
5065 CLogFilterList* filterList = new(ELeave) CLogFilterList(); |
|
5066 CleanupStack::PushL(filterList); |
|
5067 |
|
5068 CLogFilter* filter1 = CLogFilter::NewL(); |
|
5069 CleanupStack::PushL(filter1); |
|
5070 filter1->SetEventType(KLogCallEventTypeUid); // ALL VOICE CALL EVENTS |
|
5071 filterList->AppendL(filter1); |
|
5072 |
|
5073 CLogFilter* filter2 = CLogFilter::NewL(); |
|
5074 CleanupStack::PushL(filter2); |
|
5075 filter2->SetEventType(KLogShortMessageEventTypeUid); // ALL SMS's WHERE CONTACTS SEARCH FLAG IS SET |
|
5076 filter2->SetFlags(KLogEventContactSearched); |
|
5077 filterList->AppendL(filter2); |
|
5078 |
|
5079 TInt count = view->CountL(); |
|
5080 TEST2(count, 0); |
|
5081 TBool res = view->SetFilterParseFilterByFilterL(*filterList, active->iStatus); |
|
5082 TEST(res); |
|
5083 CleanupStack::PopAndDestroy(3, filterList); |
|
5084 |
|
5085 active->StartL(); |
|
5086 CActiveScheduler::Start(); |
|
5087 TEST2(active->iStatus.Int(), KErrNone); |
|
5088 count = view->CountL(); |
|
5089 TEST2(count, 2); |
|
5090 |
|
5091 // Check correct events |
|
5092 TLogId eventId; |
|
5093 // |
|
5094 active->StartL(); |
|
5095 res = view->FirstL(active->iStatus); |
|
5096 TEST(res); |
|
5097 CActiveScheduler::Start(); |
|
5098 TEST2(active->iStatus.Int(), KErrNone); |
|
5099 eventId = view->Event().Id(); |
|
5100 TEST2(eventId, event3); |
|
5101 // |
|
5102 active->StartL(); |
|
5103 res = view->NextL(active->iStatus); |
|
5104 TEST(res); |
|
5105 CActiveScheduler::Start(); |
|
5106 TEST2(active->iStatus.Int(), KErrNone); |
|
5107 eventId = view->Event().Id(); |
|
5108 TEST2(eventId, event1); |
|
5109 |
|
5110 CleanupStack::PopAndDestroy(4, event); |
|
5111 } |
|
5112 |
|
5113 // |
|
5114 // |
|
5115 // |
|
5116 static TInt TestDeletingViewWithinObserverCallbackL_CallbackFn(TAny* aView) |
|
5117 { |
|
5118 CLogViewEvent* view = reinterpret_cast<CLogViewEvent*>(aView); |
|
5119 delete view; |
|
5120 return KErrNone; |
|
5121 } |
|
5122 |
|
5123 // |
|
5124 // |
|
5125 // |
|
5126 static void TestDeletingViewWithinObserverCallbackL_ThreadFunctionL() |
|
5127 { |
|
5128 RFs fsSession; |
|
5129 LEAVE_IF_ERROR(fsSession.Connect()); |
|
5130 CleanupClosePushL(fsSession); |
|
5131 // |
|
5132 CLogClient* client = CLogClient::NewL(fsSession); |
|
5133 CleanupStack::PushL(client); |
|
5134 // |
|
5135 CLogEvent* event = CLogEvent::NewL(); |
|
5136 CleanupStack::PushL(event); |
|
5137 event->SetEventType(KLogCallEventTypeUid); |
|
5138 // |
|
5139 CTestActive* active = new(ELeave) CTestActive(); |
|
5140 CleanupStack::PushL(active); |
|
5141 |
|
5142 // Wait for main test code thread |
|
5143 RSemaphore semaphore; |
|
5144 const TInt error = semaphore.OpenGlobal(KThreadSemaphoreName); |
|
5145 LEAVE_IF_ERROR(error); |
|
5146 |
|
5147 // Add 5 recent events to the list |
|
5148 TBuf<KLogMaxDirectionLength> incoming; |
|
5149 client->GetString(incoming, R_LOG_DIR_IN); |
|
5150 event->SetDirection(incoming); |
|
5151 |
|
5152 // Incoming |
|
5153 for(TInt recent = 1; recent <= 5; recent++) |
|
5154 { |
|
5155 event->SetContact(recent); |
|
5156 for(TInt duplicate = 1; duplicate <= 6; duplicate++) |
|
5157 { |
|
5158 active->StartL(); |
|
5159 client->AddEvent(*event, active->iStatus); |
|
5160 CActiveScheduler::Start(); |
|
5161 __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 1)); |
|
5162 } |
|
5163 } |
|
5164 |
|
5165 // Wait now until the main thread says we can delete all events |
|
5166 semaphore.Signal(); |
|
5167 User::After(5 * 1000000); |
|
5168 semaphore.Wait(); |
|
5169 |
|
5170 // Clear the duplicates which should result in a batch of changes |
|
5171 // in the other thread |
|
5172 CLogViewRecent* view = CLogViewRecent::NewL(*client); |
|
5173 CleanupStack::PushL(view); |
|
5174 // |
|
5175 __ASSERT_ALWAYS(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus), User::Panic(_L("ThreadPanic"), 2)); |
|
5176 __ASSERT_ALWAYS(view->CountL() == 5, User::Panic(_L("ThreadPanic"), 3)); |
|
5177 active->StartL(); |
|
5178 CActiveScheduler::Start(); |
|
5179 __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 4)); |
|
5180 |
|
5181 // Now do the clear |
|
5182 view->ClearDuplicatesL(); |
|
5183 __ASSERT_ALWAYS(view->CountL() == 5, User::Panic(_L("ThreadPanic"), 5)); |
|
5184 |
|
5185 // Cleanup |
|
5186 CleanupStack::PopAndDestroy(view); |
|
5187 semaphore.Close(); |
|
5188 CleanupStack::PopAndDestroy(4, &fsSession); // active, event, client, fsSession |
|
5189 } |
|
5190 |
|
5191 // |
|
5192 // |
|
5193 // |
|
5194 static TInt TestDeletingViewWithinObserverCallbackL_ThreadFunction(TAny* /*aData*/) |
|
5195 { |
|
5196 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
5197 if (!cleanup) |
|
5198 return KErrNoMemory; |
|
5199 CActiveScheduler* scheduler = new CActiveScheduler(); |
|
5200 if (!scheduler) |
|
5201 return KErrNoMemory; |
|
5202 CActiveScheduler::Install(scheduler); |
|
5203 // |
|
5204 TRAPD(err, TestDeletingViewWithinObserverCallbackL_ThreadFunctionL()); |
|
5205 UNUSED_VAR(err); |
|
5206 // |
|
5207 delete scheduler; |
|
5208 delete cleanup; |
|
5209 // |
|
5210 return KErrNone; |
|
5211 } |
|
5212 |
|
5213 /** |
|
5214 @SYMTestCaseID SYSLIB-LOGENG-CT-0873 |
|
5215 @SYMTestCaseDesc Tests for observing changes within a callback |
|
5216 @SYMTestPriority High |
|
5217 @SYMTestActions Check for observing changes within a callback |
|
5218 @SYMTestExpectedResults Test must not fail |
|
5219 @SYMREQ REQ0000 |
|
5220 */ |
|
5221 LOCAL_C void TestDeletingViewWithinObserverCallbackL(CLogClient& aClient) |
|
5222 { |
|
5223 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0873 ")); |
|
5224 TestUtils::DeleteDatabaseL(); |
|
5225 |
|
5226 TInt error = 0; |
|
5227 // |
|
5228 CTestActive* active = new(ELeave) CTestActive(); |
|
5229 CleanupStack::PushL(active); |
|
5230 |
|
5231 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); |
|
5232 |
|
5233 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); |
|
5234 CleanupStack::PushL(view); |
|
5235 |
|
5236 CLogFilter* filter = CLogFilter::NewL(); |
|
5237 CleanupStack::PushL(filter); |
|
5238 filter->SetEventType(KLogCallEventTypeUid); |
|
5239 TBool res = view->SetFilterL(*filter, active->iStatus); |
|
5240 TEST(!res); |
|
5241 CleanupStack::PopAndDestroy(filter); |
|
5242 |
|
5243 // Create semaphore so we can control other thread |
|
5244 RSemaphore semaphore; |
|
5245 error = semaphore.CreateGlobal(KThreadSemaphoreName, 0); |
|
5246 LEAVE_IF_ERROR(error); |
|
5247 CleanupClosePushL(semaphore); |
|
5248 |
|
5249 // Create thread which adds two events |
|
5250 RThread thread; |
|
5251 error = thread.Create(_L("T_VIEW1_OBS_EVENT_CREATION_THREAD"), TestDeletingViewWithinObserverCallbackL_ThreadFunction, 10 * 1024, 5 * 1024, 20 * 1024, NULL); |
|
5252 LEAVE_IF_ERROR(error); |
|
5253 CleanupClosePushL(thread); |
|
5254 |
|
5255 // Start the worker thread going |
|
5256 thread.Resume(); |
|
5257 User::After(1 * 100000); |
|
5258 semaphore.Wait(); |
|
5259 |
|
5260 // Wait for changes |
|
5261 CLogChangeDefinition* changes = changeObs->WaitForChangesLC(TCallBack(TestDeletingViewWithinObserverCallbackL_CallbackFn, view), CLogViewChangeObserver::EStopOnChanges); |
|
5262 |
|
5263 // Check the changes |
|
5264 TEST2(changes->Count(), 1); |
|
5265 TEST2(changes->At(0), ELogChangeTypeEventAdded); |
|
5266 |
|
5267 TLogId logId = -1; |
|
5268 TLogDatabaseChangeType dbChangeType = changes->At(0, logId); |
|
5269 TEST2(dbChangeType, ELogChangeTypeEventAdded); |
|
5270 TEST2(logId, 0); |
|
5271 TInt viewIndex = -1; |
|
5272 dbChangeType = changes->At(0, logId, viewIndex); |
|
5273 TEST2(logId, 0); |
|
5274 TEST2(viewIndex, 0); |
|
5275 //Find a change position by the log id |
|
5276 TInt pos = changes->Find(logId); |
|
5277 TEST2(pos, 0); |
|
5278 pos = changes->Find(8125347); |
|
5279 TEST2(pos, KErrNotFound); |
|
5280 //Find a change position by the log id and the change type |
|
5281 pos = changes->Find(logId, dbChangeType); |
|
5282 TEST2(pos, 0); |
|
5283 pos = changes->Find(432837, ELogChangeTypeEventChanged); |
|
5284 TEST2(pos, KErrNotFound); |
|
5285 //Find a view position by the view index |
|
5286 pos = changes->FindByViewIndex(viewIndex); |
|
5287 TEST2(pos, 0); |
|
5288 pos = changes->FindByViewIndex(33939); |
|
5289 TEST2(pos, KErrNotFound); |
|
5290 //Stream out the changes to a buffer |
|
5291 TBuf8<100> strmBuf; |
|
5292 RDesWriteStream strmOut(strmBuf); |
|
5293 changes->ExternalizeL(strmOut); |
|
5294 strmOut.CommitL(); |
|
5295 |
|
5296 CleanupStack::PopAndDestroy(changes); |
|
5297 |
|
5298 //Re-create changes from the buffer |
|
5299 RDesReadStream strmIn(strmBuf); |
|
5300 changes = CLogChangeDefinition::NewL(strmIn); |
|
5301 dbChangeType = changes->At(0, logId); |
|
5302 TEST2(dbChangeType, ELogChangeTypeEventAdded); |
|
5303 TEST2(logId, 0); |
|
5304 delete changes; |
|
5305 |
|
5306 // The view should be deleted... |
|
5307 CleanupStack::PopAndDestroy(&thread); |
|
5308 CleanupStack::PopAndDestroy(&semaphore); |
|
5309 |
|
5310 CleanupStack::Pop(); // view |
|
5311 CleanupStack::PopAndDestroy(2, active); // changeObs, active |
|
5312 } |
|
5313 |
|
5314 |
|
5315 |
|
5316 // |
|
5317 // |
|
5318 // |
|
5319 struct TThreadData |
|
5320 { |
|
5321 inline TThreadData() : iArray(NULL), iStopThread(EFalse) { } |
|
5322 // |
|
5323 RArray<TLogId>* iArray; |
|
5324 TBool iStopThread; |
|
5325 }; |
|
5326 |
|
5327 // Slave Thread for the TestNavigationWhilstBusyL() test. |
|
5328 // This runs continuously while aThreadData.iStopThread is False. |
|
5329 static void TestNavigationWhilstBusyL_ThreadFunctionL(TThreadData& aThreadData) |
|
5330 { |
|
5331 enum TNextOp |
|
5332 { |
|
5333 EAdd = 0, |
|
5334 EDelete, |
|
5335 EClear, |
|
5336 }; |
|
5337 |
|
5338 const static TNextOp KOpTable[] = |
|
5339 { |
|
5340 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5341 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5342 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5343 EAdd, EAdd, EAdd, EAdd, EAdd, EDelete, EAdd, EAdd, EAdd, EAdd, |
|
5344 EAdd, EAdd, EAdd, EDelete, EDelete, EDelete, EAdd, EAdd, EAdd, EAdd, |
|
5345 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5346 EAdd, EAdd, EAdd, EDelete, EDelete, EDelete, EAdd, EAdd, EAdd, EAdd, |
|
5347 EDelete, EDelete, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5348 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5349 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5350 EAdd, EAdd, EAdd, EDelete, EDelete, EDelete, EAdd, EAdd, EAdd, EAdd, |
|
5351 EDelete, EDelete, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5352 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5353 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5354 EAdd, EAdd, EAdd, EAdd, EAdd, EDelete, EAdd, EAdd, EAdd, EAdd, |
|
5355 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5356 EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, |
|
5357 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5358 EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, |
|
5359 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5360 EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, |
|
5361 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5362 EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, |
|
5363 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5364 EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, |
|
5365 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, |
|
5366 }; |
|
5367 const static TInt KIndexTable[] = |
|
5368 { |
|
5369 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5370 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5371 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5372 -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, |
|
5373 -1, -1, -1, 0, 4, 20, -1, -1, -1, -1, |
|
5374 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5375 -1, -1, -1, 0, 1, 0, -1, -1, -1, -1, |
|
5376 25, 8, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5377 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5378 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5379 -1, -1, -1, 2, 4, 15, -1, -1, -1, -1, |
|
5380 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5381 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5382 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5383 -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, |
|
5384 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5385 -1, 0, -1, 30, -1, 0, -1, 31, -1, 14, |
|
5386 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5387 -1, 10, -1, 2, -1, 0, -1, 24, -1, 11, |
|
5388 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5389 -1, 0, -1, 10, -1, 0, -1, 12, -1, 5, |
|
5390 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5391 -1, 15, -1, 9, -1, 0, -1, 19, -1, 25, |
|
5392 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5393 -1, 0, -1, 1, -1, 0, -1, 7, -1, 31, |
|
5394 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
5395 }; |
|
5396 const static TInt KDelayTable[] = |
|
5397 { |
|
5398 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, |
|
5399 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, |
|
5400 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, |
|
5401 0001, 0001, 0001, 0001, 0001, 0001, 0002, 0002, 0002, 0002, |
|
5402 0002, 0002, 0002, 0001, 0001, 0001, 0002, 0002, 0002, 0002, |
|
5403 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, |
|
5404 0002, 0002, 0002, 0001, 0002, 0001, 0002, 0002, 0002, 0002, |
|
5405 2500, 8000, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, |
|
5406 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, |
|
5407 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, |
|
5408 0002, 0002, 0002, 2000, 4000000, 1500, 0002, 0002, 0002, 0002, |
|
5409 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, |
|
5410 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, |
|
5411 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, |
|
5412 0002, 0002, 0002, 0002, 0002, 0001, 0002, 0002, 0002, 0002, |
|
5413 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, |
|
5414 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, |
|
5415 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, |
|
5416 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, |
|
5417 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, |
|
5418 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, |
|
5419 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, |
|
5420 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, |
|
5421 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, |
|
5422 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, |
|
5423 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, |
|
5424 }; |
|
5425 const TInt KOpCount = sizeof(KOpTable) / sizeof(TNextOp); |
|
5426 |
|
5427 TInt TotalAdds = 0; |
|
5428 TInt TotalDeletes = 0; |
|
5429 |
|
5430 RFs fsSession; |
|
5431 LEAVE_IF_ERROR(fsSession.Connect()); |
|
5432 CleanupClosePushL(fsSession); |
|
5433 // |
|
5434 CLogClient* client = CLogClient::NewL(fsSession); |
|
5435 CleanupStack::PushL(client); |
|
5436 // |
|
5437 CLogEvent* event = CLogEvent::NewL(); |
|
5438 CleanupStack::PushL(event); |
|
5439 event->SetEventType(TEST_LOG_UID); |
|
5440 // |
|
5441 CTestActive* active = new(ELeave) CTestActive(); |
|
5442 CleanupStack::PushL(active); |
|
5443 |
|
5444 // Add 5 recent events to the list |
|
5445 TBuf<KLogMaxDirectionLength> incoming; |
|
5446 client->GetString(incoming, R_LOG_DIR_IN); |
|
5447 event->SetDirection(incoming); |
|
5448 |
|
5449 CLogSchedulerTimer* timer = CLogSchedulerTimer::NewLC(); |
|
5450 TInt count = 0; |
|
5451 TInt i=0; |
|
5452 TInt Repeat =0; |
|
5453 // |
|
5454 while(!(aThreadData.iStopThread)) |
|
5455 { |
|
5456 const TInt op = KOpTable[i]; |
|
5457 // |
|
5458 switch(op) |
|
5459 { |
|
5460 case EAdd: |
|
5461 { |
|
5462 event->SetContact(i); |
|
5463 active->StartL(); |
|
5464 client->AddEvent(*event, active->iStatus); |
|
5465 CActiveScheduler::Start(); |
|
5466 __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 1)); |
|
5467 ++count; |
|
5468 LEAVE_IF_ERROR(aThreadData.iArray->Append(event->Id())); |
|
5469 // RDebug::Print(_L("EAdd: i:%d count:%d, id:%d\n"), i, aThreadData.iArray->Count(), event->Id()); |
|
5470 |
|
5471 // Have to wait for a minimum of 1 ms here because otherwise DMBS sorts records (by time) |
|
5472 // in an arbitrary manor |
|
5473 // If this occurs this test will fail the logId == arrayId test below, as the order |
|
5474 // will be different between the logeng and arrayOfIds[]. |
|
5475 const TInt timeToWait = KDelayTable[i]; |
|
5476 if (timeToWait) |
|
5477 timer->Wait(timeToWait); |
|
5478 |
|
5479 timer->Wait(500000); |
|
5480 |
|
5481 TotalAdds++; |
|
5482 break; |
|
5483 } |
|
5484 case EDelete: |
|
5485 { |
|
5486 const TInt index = KIndexTable[i]; |
|
5487 const TLogId logId = (*aThreadData.iArray)[index]; |
|
5488 RDebug::Print(_L("EDelete index[%i]=%d id:%d\n"),i, index, logId); |
|
5489 active->StartL(); |
|
5490 client->DeleteEvent(logId, active->iStatus); |
|
5491 CActiveScheduler::Start(); |
|
5492 if (active->iStatus != KErrNone) |
|
5493 { |
|
5494 /* This happens if the LogID is not present in the log, |
|
5495 so the LogEngine cannot find the event to delete. |
|
5496 This can happen if the log is full, as it will start |
|
5497 deleting the old events itself */ |
|
5498 RDebug::Print(_L("Delete failed error:%d\n"), active->iStatus.Int()); |
|
5499 __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 2)); |
|
5500 } |
|
5501 aThreadData.iArray->Remove(index); |
|
5502 --count; |
|
5503 TotalDeletes++; |
|
5504 break; |
|
5505 } |
|
5506 case EClear: |
|
5507 { |
|
5508 TTime now; |
|
5509 now.UniversalTime(); |
|
5510 now += TTimeIntervalDays(1); |
|
5511 |
|
5512 // Clear log |
|
5513 active->StartL(); |
|
5514 client->ClearLog(now, active->iStatus); |
|
5515 CActiveScheduler::Start(); |
|
5516 __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 3)); |
|
5517 aThreadData.iArray->Reset(); |
|
5518 count = 0; |
|
5519 RDebug::Print(_L("TEST CODE: Log cleared\n")); |
|
5520 break; |
|
5521 } |
|
5522 } |
|
5523 |
|
5524 if (++i >= KOpCount) |
|
5525 { |
|
5526 i = 0; |
|
5527 Repeat++; |
|
5528 } |
|
5529 } |
|
5530 |
|
5531 RDebug::Print(_L("Repeats:%d TotalAdds:%d TotalDeletes:%d = %d\n"),Repeat,TotalAdds, TotalDeletes, count); |
|
5532 |
|
5533 CleanupStack::PopAndDestroy(timer); |
|
5534 |
|
5535 // Tidy up |
|
5536 CleanupStack::PopAndDestroy(4, &fsSession); |
|
5537 } |
|
5538 |
|
5539 // Slave Thread for the TestNavigationWhilstBusyL() test. |
|
5540 // |
|
5541 static TInt TestNavigationWhilstBusyL_ThreadFunction(TAny* aData) |
|
5542 { |
|
5543 TThreadData* threadData = reinterpret_cast<TThreadData*>(aData); |
|
5544 // |
|
5545 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
5546 if (!cleanup) |
|
5547 return KErrNoMemory; |
|
5548 CActiveScheduler* scheduler = new CActiveScheduler(); |
|
5549 if (!scheduler) |
|
5550 return KErrNoMemory; |
|
5551 CActiveScheduler::Install(scheduler); |
|
5552 // |
|
5553 TRAPD(err, TestNavigationWhilstBusyL_ThreadFunctionL(*threadData)); |
|
5554 UNUSED_VAR(err); |
|
5555 // |
|
5556 delete scheduler; |
|
5557 delete cleanup; |
|
5558 // |
|
5559 return KErrNone; |
|
5560 } |
|
5561 |
|
5562 /** |
|
5563 This tests using the Logeng while it is busy. It starts a new thread which adds and deletes events |
|
5564 using the data in KOpTable[] and KIndexTable[]. It then checks the database while the new thread is |
|
5565 running. |
|
5566 |
|
5567 @SYMTestCaseID SYSLIB-LOGENG-CT-0874 |
|
5568 @SYMTestCaseDesc Tests for navigation while Log engine is busy. |
|
5569 @SYMTestPriority High |
|
5570 @SYMTestActions Start a new thread which adds and deletes events |
|
5571 using the data in defined tables.It then checks the database while the new thread is running. |
|
5572 @SYMTestExpectedResults Test must not fail |
|
5573 @SYMREQ REQ0000 |
|
5574 */ |
|
5575 LOCAL_C void TestNavigationWhilstBusyL(CLogClient& aClient) |
|
5576 { |
|
5577 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0874 ")); |
|
5578 TestUtils::DeleteDatabaseL(); |
|
5579 |
|
5580 TInt error = 0; |
|
5581 TInt count = 0; |
|
5582 // |
|
5583 CTestActive* active = new(ELeave) CTestActive(); |
|
5584 CleanupStack::PushL(active); |
|
5585 |
|
5586 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); |
|
5587 |
|
5588 // Create a test event type - TEST_LOG_UID |
|
5589 CLogEventType* type = CLogEventType::NewL(); |
|
5590 CleanupStack::PushL(type); |
|
5591 |
|
5592 type->SetUid(TEST_LOG_UID); |
|
5593 type->SetDescription(KTestEventDesc); |
|
5594 type->SetLoggingEnabled(ETrue); |
|
5595 RDebug::Print(_L("\nTest event type added %x\n"),TEST_LOG_UID ); |
|
5596 |
|
5597 // Register the event type |
|
5598 active->StartL(); |
|
5599 aClient.AddEventType(*type, active->iStatus); |
|
5600 CActiveScheduler::Start(); |
|
5601 TEST2(active->iStatus.Int(), KErrNone); |
|
5602 |
|
5603 CleanupStack::PopAndDestroy(); // type |
|
5604 |
|
5605 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); |
|
5606 CleanupStack::PushL(view); |
|
5607 |
|
5608 CLogFilter* filter = CLogFilter::NewL(); |
|
5609 CleanupStack::PushL(filter); |
|
5610 filter->SetEventType(TEST_LOG_UID); |
|
5611 TBool res = view->SetFilterL(*filter, active->iStatus); |
|
5612 test(!res); |
|
5613 |
|
5614 // increase the default log size |
|
5615 TLogConfig Config; |
|
5616 const TInt kMaxLogSize = 2000; |
|
5617 Config.iMaxLogSize = kMaxLogSize; |
|
5618 aClient.ChangeConfig( Config, active->iStatus); |
|
5619 active->StartL(); |
|
5620 CActiveScheduler::Start(); |
|
5621 TEST2(active->iStatus.Int(), KErrNone); |
|
5622 |
|
5623 // Shared data between this and the worker thread |
|
5624 RArray<TLogId> arrayOfIds(100); |
|
5625 CleanupClosePushL(arrayOfIds); |
|
5626 TThreadData threadData; |
|
5627 threadData.iArray = &arrayOfIds; |
|
5628 |
|
5629 // Create thread which adds two events |
|
5630 RThread thread; |
|
5631 RHeap& heap = User::Heap(); |
|
5632 error = thread.Create(_L("T_VIEW1_OBS_EVENT_CREATION_THREAD2"), TestNavigationWhilstBusyL_ThreadFunction, 10 * 1024, &heap, &threadData); |
|
5633 LEAVE_IF_ERROR(error); |
|
5634 CleanupClosePushL(thread); |
|
5635 |
|
5636 // Start the worker thread going |
|
5637 thread.Resume(); |
|
5638 |
|
5639 // Suspend this thread |
|
5640 RDebug::Print(_L("TEST CODE: Suspending thread for 2 seconds\n")); |
|
5641 CLogSchedulerTimer* timer = CLogSchedulerTimer::NewLC(); |
|
5642 timer->Wait(10 * 1000000); |
|
5643 |
|
5644 // Apply the filter now there are some records |
|
5645 RDebug::Print(_L("TEST CODE: Setting filter again - should be some records now\n")); |
|
5646 res = view->SetFilterL(*filter, active->iStatus); |
|
5647 test(res); |
|
5648 active->StartL(); |
|
5649 CActiveScheduler::Start(); |
|
5650 test(active->iStatus == KErrNone || active->iStatus == KErrCancel); // KErrCancel when the worker thread clears the log at the same time as we are navigating to the first record |
|
5651 count = view->CountL(); |
|
5652 test(count > 0); |
|
5653 |
|
5654 // Navigate around (up and down) whilst events are being created |
|
5655 count = view->CountL(); |
|
5656 res = view->FirstL(active->iStatus); |
|
5657 test(res); |
|
5658 do { |
|
5659 active->StartL(); |
|
5660 CActiveScheduler::Start(); |
|
5661 test(active->iStatus == KErrNone || active->iStatus == KErrCancel); |
|
5662 count--; |
|
5663 if (active->iStatus == KErrNone) |
|
5664 test(view->Event().Id() != KLogNullId); |
|
5665 } |
|
5666 while(view->NextL(active->iStatus)); |
|
5667 |
|
5668 timer->Wait(5 * 1000000); |
|
5669 count = view->CountL(); |
|
5670 res = view->FirstL(active->iStatus); |
|
5671 test(res); |
|
5672 do { |
|
5673 active->StartL(); |
|
5674 CActiveScheduler::Start(); |
|
5675 test(active->iStatus == KErrNone || active->iStatus == KErrCancel); |
|
5676 count--; |
|
5677 if (active->iStatus == KErrNone) |
|
5678 test(view->Event().Id() != KLogNullId); |
|
5679 } |
|
5680 while(view->NextL(active->iStatus)); |
|
5681 |
|
5682 timer->Wait(5 * 1000000); |
|
5683 count = view->CountL(); |
|
5684 res = view->LastL(active->iStatus); |
|
5685 test(res); |
|
5686 do { |
|
5687 active->StartL(); |
|
5688 CActiveScheduler::Start(); |
|
5689 test(active->iStatus == KErrNone || active->iStatus == KErrCancel); |
|
5690 count--; |
|
5691 if (active->iStatus == KErrNone) |
|
5692 test(view->Event().Id() != KLogNullId); |
|
5693 } |
|
5694 while(view->PreviousL(active->iStatus)); |
|
5695 |
|
5696 timer->Wait(5 * 1000000); |
|
5697 count = view->CountL(); |
|
5698 res = view->FirstL(active->iStatus); |
|
5699 test(res); |
|
5700 do { |
|
5701 active->StartL(); |
|
5702 CActiveScheduler::Start(); |
|
5703 test(active->iStatus == KErrNone || active->iStatus == KErrCancel); |
|
5704 count--; |
|
5705 if (active->iStatus == KErrNone) |
|
5706 test(view->Event().Id() != KLogNullId); |
|
5707 } |
|
5708 while(view->NextL(active->iStatus)); |
|
5709 |
|
5710 timer->Wait(5 * 1000000); |
|
5711 count = view->CountL(); |
|
5712 res = view->LastL(active->iStatus); |
|
5713 test(res); |
|
5714 do { |
|
5715 active->StartL(); |
|
5716 CActiveScheduler::Start(); |
|
5717 test(active->iStatus == KErrNone || active->iStatus == KErrCancel); |
|
5718 count--; |
|
5719 if (active->iStatus == KErrNone) |
|
5720 test(view->Event().Id() != KLogNullId); |
|
5721 } |
|
5722 while(view->PreviousL(active->iStatus)); |
|
5723 |
|
5724 timer->Wait(5 * 1000000); |
|
5725 count = view->CountL(); |
|
5726 res = view->LastL(active->iStatus); |
|
5727 test(res); |
|
5728 do { |
|
5729 active->StartL(); |
|
5730 CActiveScheduler::Start(); |
|
5731 test(active->iStatus == KErrNone || active->iStatus == KErrCancel); |
|
5732 count--; |
|
5733 if (active->iStatus == KErrNone) |
|
5734 test(view->Event().Id() != KLogNullId); |
|
5735 } |
|
5736 while(view->PreviousL(active->iStatus)); |
|
5737 |
|
5738 // STOP THE WORKER THREAD |
|
5739 threadData.iStopThread = ETrue; |
|
5740 RDebug::Print(_L("Stopping worker thread\n")); |
|
5741 timer->Wait(30 * 1000000); |
|
5742 |
|
5743 // do some checks on the log |
|
5744 TLogConfig logConfig; |
|
5745 aClient.GetConfig( logConfig, active->iStatus); |
|
5746 active->StartL(); |
|
5747 CActiveScheduler::Start(); |
|
5748 TEST2(active->iStatus.Int(), KErrNone); |
|
5749 RDebug::Print(_L("MaxLogSize:%ld MaxRecentLogSize:%d\n"), |
|
5750 logConfig.iMaxLogSize, logConfig.iMaxRecentLogSize ); |
|
5751 test(logConfig.iMaxLogSize > logConfig.iMaxRecentLogSize); |
|
5752 |
|
5753 /* Check the log has not overflowed. |
|
5754 If this fails either increase the log size or reduce the time the |
|
5755 worker thread has been running |
|
5756 */ |
|
5757 test (arrayOfIds.Count() < kMaxLogSize); |
|
5758 |
|
5759 // Loop though the logevents created by the worker thread and compare against the |
|
5760 // data stored in arrayOfIds. |
|
5761 res = view->LastL(active->iStatus); |
|
5762 test(res); |
|
5763 count = 0; |
|
5764 do { |
|
5765 active->StartL(); |
|
5766 CActiveScheduler::Start(); |
|
5767 TEST2(active->iStatus.Int(), KErrNone); |
|
5768 |
|
5769 const TLogId logId = view->Event().Id(); |
|
5770 const TLogId arrayId = arrayOfIds[count]; |
|
5771 if (logId != arrayId) |
|
5772 RDebug::Print(_L("Events[%d] - array:%5d, id:%5d ****\n"), count, arrayId, logId); |
|
5773 // Note: If this test fails the fist thing to check is the time delay after EAdd. |
|
5774 // If several events get the same time stamp, the order is arbitrary and the test fails here. |
|
5775 test(logId == arrayId); |
|
5776 count++; |
|
5777 } |
|
5778 while(view->PreviousL(active->iStatus)); |
|
5779 |
|
5780 CleanupStack::PopAndDestroy(timer); |
|
5781 CleanupStack::PopAndDestroy(&thread); |
|
5782 CleanupStack::PopAndDestroy(&arrayOfIds); |
|
5783 CleanupStack::PopAndDestroy(filter); |
|
5784 CleanupStack::PopAndDestroy(view); |
|
5785 CleanupStack::PopAndDestroy(2, active); // changeObs, active |
|
5786 } |
|
5787 |
|
5788 /** |
|
5789 @SYMTestCaseID SYSLIB-LOGENG-CT-4014 |
|
5790 @SYMTestCaseDesc Tests CLogView::CountL works correctly after SetFilterL returns no event. |
|
5791 @SYMTestPriority High |
|
5792 @SYMTestActions 1. ClearLog. |
|
5793 2. SetFilterL. |
|
5794 3. Add events and check count. |
|
5795 4. Step through the added events. |
|
5796 @SYMTestExpectedResults 2 - SetFilterL indicates no event in view. |
|
5797 3. CountL method returns correct number of events. |
|
5798 4. Can step through the added events. |
|
5799 |
|
5800 @SYMDEF INC123066 |
|
5801 */ |
|
5802 LOCAL_C void INC123066L(CLogClient& aClient) |
|
5803 { |
|
5804 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-4014 ")); |
|
5805 CLogEvent* event = CLogEvent::NewL(); |
|
5806 CleanupStack::PushL(event); |
|
5807 event->SetEventType(KLogCallEventTypeUid); |
|
5808 |
|
5809 CTestActive* active = new(ELeave)CTestActive(); |
|
5810 CleanupStack::PushL(active); |
|
5811 |
|
5812 // deliberately not using CLogViewChangeObserver |
|
5813 |
|
5814 CLogViewEvent* view = CLogViewEvent::NewL(aClient); |
|
5815 CleanupStack::PushL(view); |
|
5816 |
|
5817 CLogFilter* filter = CLogFilter::NewL(); |
|
5818 CleanupStack::PushL(filter); |
|
5819 |
|
5820 // Clear all the events |
|
5821 TTime now; |
|
5822 now.UniversalTime(); |
|
5823 now += TTimeIntervalDays(1); |
|
5824 active->StartL(); |
|
5825 aClient.ClearLog(now, active->iStatus); |
|
5826 CActiveScheduler::Start(); |
|
5827 TEST2(active->iStatus.Int(), KErrNone); |
|
5828 |
|
5829 TBool res = view->SetFilterL(*filter, active->iStatus); |
|
5830 TEST2(res, 0); |
|
5831 |
|
5832 TInt count; |
|
5833 for(count = 0; count < KTestEventNum; count++) |
|
5834 { |
|
5835 active->StartL(); |
|
5836 aClient.AddEvent(*event, active->iStatus); |
|
5837 CActiveScheduler::Start(); |
|
5838 TEST2(active->iStatus.Int(), KErrNone); |
|
5839 |
|
5840 TEST2(view->CountL(), count+1); |
|
5841 } |
|
5842 |
|
5843 // save the most recent logId for checking. |
|
5844 TLogId lastLogId = event->Id(); |
|
5845 |
|
5846 // Can iterate over the added events |
|
5847 for (count = 0; count < KTestEventNum; count++) |
|
5848 { |
|
5849 active->StartL(); |
|
5850 TEST( view->NextL(active->iStatus) ); |
|
5851 CActiveScheduler::Start(); |
|
5852 TEST2(active->iStatus.Int(), KErrNone); |
|
5853 |
|
5854 TLogId id = view->Event().Id(); |
|
5855 // Most recent event is first. Oldest event is last. |
|
5856 TEST2((lastLogId - count), id); |
|
5857 } |
|
5858 |
|
5859 CleanupStack::PopAndDestroy(4, event); // filter, view, active, event |
|
5860 |
|
5861 // See same test using CLogViewRecent in TestRecentView1L. |
|
5862 } |
|
5863 |
|
5864 /** |
|
5865 @SYMTestCaseID PDS-LOGENG-CT-4017 |
|
5866 @SYMTestCaseDesc Tests Handling of CLogViewRecent::SetRecentListL when |
|
5867 Remote Party string contains single quote character |
|
5868 @SYMTestPriority High |
|
5869 @SYMTestActions 1. Create 10 Incoming call events from 3 different |
|
5870 Remote Parties using single quotes in strings |
|
5871 2. Call CLogViewRecent::SetRecentListL. |
|
5872 3. Check that duplicate entries have been deleted and only |
|
5873 3 events are showm |
|
5874 |
|
5875 @SYMTestExpectedResults SetRecentListL indicates 3 events in view |
|
5876 @SYMDEF INC136334 |
|
5877 */ |
|
5878 LOCAL_C void INC136334L(CLogClient& aClient) |
|
5879 { |
|
5880 test.Next(_L(" @SYMTestCaseID:PDS-LOGENG-CT-4017 ")); |
|
5881 CLogEvent* event = CLogEvent::NewL(); |
|
5882 CleanupStack::PushL(event); |
|
5883 |
|
5884 CTestActive* active = new(ELeave)CTestActive(); |
|
5885 CleanupStack::PushL(active); |
|
5886 |
|
5887 CLogViewRecent* view = CLogViewRecent::NewL(aClient); |
|
5888 CleanupStack::PushL(view); |
|
5889 |
|
5890 // Incoming |
|
5891 TBuf<KLogMaxDirectionLength> buf; |
|
5892 aClient.GetString(buf, R_LOG_DIR_IN); |
|
5893 |
|
5894 event->SetEventType(KLogCallEventTypeUid); |
|
5895 event->SetDirection(buf); |
|
5896 |
|
5897 TInt count; |
|
5898 //Add 10 missed calls from 3 different contacts |
|
5899 //These should result in only 3 entries int he log as |
|
5900 //duplicates should be deleted. |
|
5901 for(count = 0; count < KTestEventNum; count++) |
|
5902 { |
|
5903 //Use a string with a single quote |
|
5904 event->SetRemoteParty(_L("Sam's Wife")); |
|
5905 |
|
5906 active->StartL(); |
|
5907 aClient.AddEvent(*event, active->iStatus); |
|
5908 CActiveScheduler::Start(); |
|
5909 TEST2(active->iStatus.Int(), KErrNone); |
|
5910 |
|
5911 //Use a string with multiple single quotes |
|
5912 event->SetRemoteParty(_L("'Sam's W'i'f'e'''''''")); |
|
5913 |
|
5914 active->StartL(); |
|
5915 aClient.AddEvent(*event, active->iStatus); |
|
5916 CActiveScheduler::Start(); |
|
5917 TEST2(active->iStatus.Int(), KErrNone); |
|
5918 |
|
5919 //Use a string with no single quotes |
|
5920 event->SetRemoteParty(_L("Sams Wife")); |
|
5921 |
|
5922 active->StartL(); |
|
5923 aClient.AddEvent(*event, active->iStatus); |
|
5924 CActiveScheduler::Start(); |
|
5925 TEST2(active->iStatus.Int(), KErrNone); |
|
5926 |
|
5927 } |
|
5928 |
|
5929 TEST2(view->CountL(), 0); |
|
5930 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); |
|
5931 TEST(res); |
|
5932 |
|
5933 //All of the duplicate entries should be deleted and there should |
|
5934 //only be 3 events in the log |
|
5935 active->StartL(); |
|
5936 CActiveScheduler::Start(); |
|
5937 TEST2(active->iStatus.Int(), KErrNone); |
|
5938 TEST2(view->CountL(), 3); |
|
5939 |
|
5940 //Clear the log for he next test |
|
5941 aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus); |
|
5942 active->StartL(); |
|
5943 CActiveScheduler::Start(); |
|
5944 TEST2(active->iStatus.Int(), KErrNone); |
|
5945 |
|
5946 count = view->CountL(); |
|
5947 TEST2(count, 0); |
|
5948 |
|
5949 CleanupStack::PopAndDestroy(3); // view, active, event |
|
5950 |
|
5951 } |
|
5952 // |
|
5953 // |
|
5954 // |
|
5955 void doTestsL() |
|
5956 { |
|
5957 TheMatchingIsEnabled = TestUtils::MatchingEnabledL(); |
|
5958 |
|
5959 TestUtils::Initialize(_L("T_LOGVIEW1")); |
|
5960 TestUtils::DeleteDatabaseL(); |
|
5961 |
|
5962 CLogClient* client = CLogClient::NewL(theFs); |
|
5963 CleanupStack::PushL(client); |
|
5964 |
|
5965 CLogChangeNotifier* notifier = CLogChangeNotifier::NewL(); |
|
5966 CleanupStack::PushL(notifier); |
|
5967 |
|
5968 test.Start(_L("Event View With No Filter")); |
|
5969 |
|
5970 TestEventViewL(*client); |
|
5971 theLog.Write(_L8("Test 1 OK\n")); |
|
5972 |
|
5973 test.Next(_L("Event View Filter alternative")); |
|
5974 TestViewFilteringDefect1L(*client); |
|
5975 theLog.Write(_L8("Test 2 OK\n")); |
|
5976 test.Next(_L("Event View With Filter")); |
|
5977 TestEventViewFilter1L(*client); |
|
5978 TestEventViewFilter2L(*client); |
|
5979 test.Next(_L("INC123066 - LogView not updated if SetFilterL found no event")); |
|
5980 INC123066L(*client); |
|
5981 theLog.Write(_L8("Test 3 OK\n")); |
|
5982 |
|
5983 test.Next(_L("Recent View")); |
|
5984 TestRecentView1L(*client); |
|
5985 TestRecentView2L(*client); |
|
5986 theLog.Write(_L8("Test 4 OK\n")); |
|
5987 |
|
5988 test.Next(_L("Removing recent events")); |
|
5989 TestRecentRemove1L(*client); |
|
5990 TestRecentRemove2L(*client); |
|
5991 theLog.Write(_L8("Test 5 OK\n")); |
|
5992 |
|
5993 test.Next(_L("Duplicate View")); |
|
5994 TestDuplicateViewL(*client); |
|
5995 theLog.Write(_L8("Test 6 OK\n")); |
|
5996 |
|
5997 test.Next(_L("Removing duplicate events")); |
|
5998 TestDuplicateRemoveL(*client); |
|
5999 theLog.Write(_L8("Test 7 OK\n")); |
|
6000 |
|
6001 test.Next(_L("Check purge performed on view setup")); |
|
6002 TestPurgeOnSetup1L(*client); |
|
6003 TestPurgeOnSetup2L(*client); |
|
6004 theLog.Write(_L8("Test 8 OK\n")); |
|
6005 |
|
6006 test.Next(_L("View Purging")); |
|
6007 TestViewPurgeL(*client); |
|
6008 theLog.Write(_L8("Test 9 OK\n")); |
|
6009 |
|
6010 test.Next(_L("Clearing duplicate lists")); |
|
6011 TestClearDuplicatesL(*client); |
|
6012 theLog.Write(_L8("Test 10 OK\n")); |
|
6013 |
|
6014 test.Next(_L("Phone number matching")); |
|
6015 TestPhoneNumberMatchingL(*client); |
|
6016 theLog.Write(_L8("Test 11 OK\n")); |
|
6017 |
|
6018 test.Next(_L("view flags setting/clearing")); |
|
6019 TestViewFlagsL(*client); |
|
6020 theLog.Write(_L8("Test 12 OK\n")); |
|
6021 |
|
6022 test.Next(_L("Recent view flags setting/clearing")); |
|
6023 TestRecentFlagsL(*client); |
|
6024 theLog.Write(_L8("Test 13 OK\n")); |
|
6025 |
|
6026 test.Next(_L("View change tests 1")); |
|
6027 TestViewChangeEvents1L(*client); |
|
6028 TestViewChangeEvents1aL(*client); |
|
6029 theLog.Write(_L8("Test 14 OK\n")); |
|
6030 |
|
6031 test.Next(_L("View change tests 2")); |
|
6032 TestViewChangeEvents2L(*client); |
|
6033 TestViewChangeEvents2aL(*client); |
|
6034 theLog.Write(_L8("Test 15 OK\n")); |
|
6035 |
|
6036 test.Next(_L("View deletion from within callback")); |
|
6037 TestDeletingViewWithinObserverCallbackL(*client); |
|
6038 theLog.Write(_L8("Test 16 OK\n")); |
|
6039 |
|
6040 test.Next(_L("Test navigation whilst events are added")); |
|
6041 TestNavigationWhilstBusyL(*client); |
|
6042 theLog.Write(_L8("Test 17 OK\n")); |
|
6043 |
|
6044 test.Next(_L("Defect INC105010 - phone number matching")); |
|
6045 INC105010L(*client); |
|
6046 theLog.Write(_L8("Test 18 OK\n")); |
|
6047 |
|
6048 test.Next(_L("INC136334 - The miss call log won't show if you have ' in your contact")); |
|
6049 INC136334L(*client); |
|
6050 theLog.Write(_L8("Test 19 OK\n")); |
|
6051 |
|
6052 CleanupStack::PopAndDestroy(2); // notifier, client; |
|
6053 } |