Update contrib.
1 // Copyright (c) 2002-2010 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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
18 #include "t_logutil2.h"
21 #define UNUSED_VAR(a) a = a
23 RTest TheTest(_L("t_logview1"));
25 const TInt KTestLogNumberCharsToMatch = 9; // should be the same as KLogNumberCharsToMatch defined in LogServ\src\LOGFILTQ.CPP
26 const TInt KTestEventNum = 10;
27 const TUid KTestEventUid = {0x10005393};
28 const TLogDurationType KTestDurationType = 0x12;
29 const TLogContactItemId KTestContact = 0x1234;
30 _LIT(KTestEventDesc, "Test Event");
31 _LIT(KTestRemoteParty, "Test Remote Party");
32 _LIT(KTestDirection, "Test Direction");
33 _LIT(KTestStatus, "Test Status");
34 _LIT(KTestNumber, "Test Number");
35 _LIT(KThreadSemaphoreName, "T_VIEW1_TEST_CODE");
38 TBool TheMatchingIsEnabled = EFalse;
40 #define TEST_LOG_UID KTestEventUid
42 //View's DoCancel() test
43 void DoViewCancelTestL(CTestActive& aActive, CLogViewEvent& aView)
45 //Call FirstL() and cancel the operation
47 (void)aView.FirstL(aActive.iStatus);
49 TEST(!aView.IsActive());
50 CActiveScheduler::Start();
51 TEST2(aActive.iStatus.Int(), KErrCancel);
53 //Call FirstL(). View cursor positioned on the first record.
55 (void)aView.FirstL(aActive.iStatus);
56 CActiveScheduler::Start();
57 TEST2(aActive.iStatus.Int(), KErrNone);
59 //Call NextL() and cancel the operation
61 (void)aView.NextL(aActive.iStatus);
63 TEST(!aView.IsActive());
64 CActiveScheduler::Start();
65 TEST2(aActive.iStatus.Int(), KErrCancel);
67 //Call LastL() and cancel the operation
69 (void)aView.LastL(aActive.iStatus);
71 TEST(!aView.IsActive());
72 CActiveScheduler::Start();
73 TEST2(aActive.iStatus.Int(), KErrCancel);
75 //Call LastL(). View cursor positioned on the last record.
77 (void)aView.LastL(aActive.iStatus);
78 CActiveScheduler::Start();
79 TEST2(aActive.iStatus.Int(), KErrNone);
81 //Call PreviousL() and cancel the operation
83 (void)aView.PreviousL(aActive.iStatus);
85 TEST(!aView.IsActive());
86 CActiveScheduler::Start();
87 TEST2(aActive.iStatus.Int(), KErrCancel);
91 @SYMTestCaseID SYSLIB-LOGENG-CT-0851
92 @SYMTestCaseDesc Tests for adding event types to the log
94 @SYMTestActions Tests for adding events,check event count,clearing all the events
95 @SYMTestExpectedResults Test must not fail
98 LOCAL_C void TestEventViewL(CLogClient& aClient)
100 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0851 "));
101 CLogEvent* event = CLogEvent::NewL();
102 CleanupStack::PushL(event);
103 event->SetEventType(KLogCallEventTypeUid);
105 CTestActive* active = new(ELeave)CTestActive();
106 CleanupStack::PushL(active);
109 for(count = 0; count < KTestEventNum; count++)
112 aClient.AddEvent(*event, active->iStatus);
113 CActiveScheduler::Start();
114 TEST2(active->iStatus.Int(), KErrNone);
117 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
118 changeObs->SetActive();
120 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
121 CleanupStack::PushL(view);
123 CLogFilter* filter = CLogFilter::NewL();
124 CleanupStack::PushL(filter);
126 count = view->CountL();
128 TBool res = view->SetFilterL(*filter, active->iStatus);
132 count = KTestEventNum;
135 CActiveScheduler::Start();
136 TEST2(active->iStatus.Int(), KErrNone);
138 const TInt viewCount = view->CountL();
139 TEST2(viewCount, KTestEventNum);
140 const TLogId eventId = view->Event().Id();
144 while(view->NextL(active->iStatus));
148 while(view->PreviousL(active->iStatus))
151 CActiveScheduler::Start();
152 TEST2(active->iStatus.Int(), KErrNone);
154 TEST2(view->CountL(), KTestEventNum);
156 TEST2(view->Event().Id(), id);
158 TEST2(count, KTestEventNum - 1);
161 res = view->FirstL(active->iStatus);
163 CActiveScheduler::Start();
164 TEST2(active->iStatus.Int(), KErrNone);
167 res = view->LastL(active->iStatus);
169 CActiveScheduler::Start();
170 TEST2(active->iStatus.Int(), KErrNone);
172 // Nothing has changed in the view yet
173 TEST(!changeObs->HaveChanges());
175 DoViewCancelTestL(*active, *view);
179 now+=(TTimeIntervalDays) 1;
181 // Clear all the events
183 aClient.ClearLog(now, active->iStatus);
184 CActiveScheduler::Start();
185 TEST2(active->iStatus.Int(), KErrNone);
187 res = view->SetFilterL(*filter, active->iStatus);
189 TEST2(view->CountL(), 0);
190 res = view->FirstL(active->iStatus);
192 res = view->LastL(active->iStatus);
194 res = view->NextL(active->iStatus);
196 res = view->PreviousL(active->iStatus);
199 CleanupStack::PopAndDestroy(5, event); // filter, view, changeObs, active, event
201 CLogSchedulerTimer* timer = CLogSchedulerTimer::NewLC();
202 timer->Wait(10 * 1000000);
203 CleanupStack::PopAndDestroy(timer);
207 @SYMTestCaseID SYSLIB-LOGENG-CT-0852
208 @SYMTestCaseDesc Tests for adding event types to the filter list
209 @SYMTestPriority High
210 @SYMTestActions Set the configuration data of event type.Add the event type to the filter and
211 compare the configuration data of event type and from filter view.
212 @SYMTestExpectedResults Test must not fail
215 LOCAL_C void TestViewFilterL(CLogClient& aClient, CLogFilter& aFilter)
217 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0852 "));
218 CLogViewEvent* view = CLogViewEvent::NewL(aClient);
219 CleanupStack::PushL(view);
221 CLogEvent* event = CLogEvent::NewL();
222 CleanupStack::PushL(event);
224 event->SetEventType(KTestEventUid);
225 event->SetRemoteParty(aFilter.RemoteParty());
226 event->SetDirection(aFilter.Direction());
227 event->SetDurationType(aFilter.DurationType());
228 event->SetStatus(aFilter.Status());
229 event->SetContact(aFilter.Contact());
230 event->SetNumber(aFilter.Number());
232 CTestActive* active = new(ELeave)CTestActive();
233 CleanupStack::PushL(active);
235 if (view->SetFilterL(aFilter, active->iStatus))
238 CActiveScheduler::Start();
239 TEST2(active->iStatus.Int(), KErrNone);
242 TInt total = view->CountL();
245 aClient.AddEvent(*event, active->iStatus);
246 CActiveScheduler::Start();
247 TEST2(active->iStatus.Int(), KErrNone);
249 TBool res = view->SetFilterL(aFilter, active->iStatus);
252 CActiveScheduler::Start();
253 TEST2(active->iStatus.Int(), KErrNone);
255 TEST2(view->CountL(), total + 1);
257 TEST2(event->EventType().iUid, KTestEventUid.iUid);
258 TEST(event->RemoteParty() == aFilter.RemoteParty());
259 TEST(event->Direction() == aFilter.Direction());
260 TEST2(event->DurationType(), aFilter.DurationType());
261 TEST(event->Status() == aFilter.Status());
262 TEST2(event->Contact(), aFilter.Contact());
263 TEST(event->Number() == aFilter.Number());
270 while(view->NextL(active->iStatus))
273 TEST(count <= total + 1);
276 CActiveScheduler::Start();
277 TEST2(active->iStatus.Int(), KErrNone);
279 TEST(now >= event->Time());
281 if (aFilter.EventType() != KNullUid)
282 TEST2(event->EventType().iUid, aFilter.EventType().iUid);
284 if (aFilter.RemoteParty().Length() > 0)
285 TEST(event->RemoteParty() == aFilter.RemoteParty());
287 if (aFilter.Direction().Length() > 0)
288 TEST(event->Direction() == aFilter.Direction());
290 if (aFilter.DurationType() != KLogNullDurationType)
291 TEST2(event->DurationType(), aFilter.DurationType());
293 if (aFilter.Status().Length() > 0)
294 TEST(event->Status() == aFilter.Status());
296 if (aFilter.Contact() > KLogNullContactId)
297 TEST2(event->Contact(), aFilter.Contact());
299 if (aFilter.Number().Length() > 0)
300 TEST(event->Number() == aFilter.Number());
303 TEST2(count, total + 1);
305 CleanupStack::PopAndDestroy(3); // active, event, view;
309 @SYMTestCaseID SYSLIB-LOGENG-CT-0853
310 @SYMTestCaseDesc Tests for filtering the log view
311 @SYMTestPriority High
312 @SYMTestActions Tests for the log view filter,which is set with different configuration data
313 @SYMTestExpectedResults Test must not fail
316 LOCAL_C void TestEventViewFilter1L(CLogClient& aClient)
318 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0853 "));
319 CTestActive* active = new(ELeave)CTestActive();
320 CleanupStack::PushL(active);
322 // Create a test event type
323 CLogEventType* type = CLogEventType::NewL();
324 CleanupStack::PushL(type);
326 type->SetUid(KTestEventUid);
327 type->SetDescription(KTestEventDesc);
328 type->SetLoggingEnabled(ETrue);
330 // Register the event type
332 aClient.AddEventType(*type, active->iStatus);
333 CActiveScheduler::Start();
334 TEST2(active->iStatus.Int(), KErrNone);
336 CleanupStack::PopAndDestroy(); // type
338 CLogFilter* filter = CLogFilter::NewL();
339 CleanupStack::PushL(filter);
341 filter->SetEventType(KTestEventUid);
342 TestViewFilterL(aClient, *filter);
344 filter->SetEventType(KTestEventUid);
345 filter->SetRemoteParty(KTestRemoteParty);
346 TestViewFilterL(aClient, *filter);
348 filter->SetEventType(KTestEventUid);
349 filter->SetRemoteParty(KTestRemoteParty);
350 filter->SetDirection(KTestDirection);
351 TestViewFilterL(aClient, *filter);
353 filter->SetEventType(KTestEventUid);
354 filter->SetRemoteParty(KTestRemoteParty);
355 filter->SetDirection(KTestDirection);
356 filter->SetDurationType(KTestDurationType);
357 TestViewFilterL(aClient, *filter);
359 filter->SetEventType(KTestEventUid);
360 filter->SetRemoteParty(KTestRemoteParty);
361 filter->SetDirection(KTestDirection);
362 filter->SetDurationType(KTestDurationType);
363 filter->SetStatus(KTestStatus);
364 TestViewFilterL(aClient, *filter);
366 filter->SetEventType(KTestEventUid);
367 filter->SetRemoteParty(KTestRemoteParty);
368 filter->SetDirection(KTestDirection);
369 filter->SetDurationType(KTestDurationType);
370 filter->SetStatus(KTestStatus);
371 filter->SetContact(KTestContact);
372 TestViewFilterL(aClient, *filter);
374 filter->SetEventType(KTestEventUid);
375 filter->SetRemoteParty(KTestRemoteParty);
376 filter->SetDirection(KTestDirection);
377 filter->SetDurationType(KTestDurationType);
378 filter->SetStatus(KTestStatus);
379 filter->SetContact(KTestContact);
380 filter->SetNumber(KTestNumber);
381 TestViewFilterL(aClient, *filter);
383 CleanupStack::PopAndDestroy(); // filter
385 filter = CLogFilter::NewL();
386 CleanupStack::PushL(filter);
388 filter->SetRemoteParty(KTestRemoteParty);
389 TestViewFilterL(aClient, *filter);
391 filter->SetRemoteParty(KTestRemoteParty);
392 filter->SetDirection(KTestDirection);
393 TestViewFilterL(aClient, *filter);
395 filter->SetRemoteParty(KTestRemoteParty);
396 filter->SetDirection(KTestDirection);
397 filter->SetDurationType(KTestDurationType);
398 TestViewFilterL(aClient, *filter);
400 filter->SetRemoteParty(KTestRemoteParty);
401 filter->SetDirection(KTestDirection);
402 filter->SetDurationType(KTestDurationType);
403 filter->SetStatus(KTestStatus);
404 TestViewFilterL(aClient, *filter);
406 filter->SetRemoteParty(KTestRemoteParty);
407 filter->SetDirection(KTestDirection);
408 filter->SetDurationType(KTestDurationType);
409 filter->SetStatus(KTestStatus);
410 filter->SetContact(KTestContact);
411 TestViewFilterL(aClient, *filter);
413 filter->SetRemoteParty(KTestRemoteParty);
414 filter->SetDirection(KTestDirection);
415 filter->SetDurationType(KTestDurationType);
416 filter->SetStatus(KTestStatus);
417 filter->SetContact(KTestContact);
418 filter->SetNumber(KTestNumber);
419 TestViewFilterL(aClient, *filter);
421 CleanupStack::PopAndDestroy(); // filter
423 filter = CLogFilter::NewL();
424 CleanupStack::PushL(filter);
426 filter->SetDirection(KTestDirection);
427 TestViewFilterL(aClient, *filter);
429 filter->SetDirection(KTestDirection);
430 filter->SetDurationType(KTestDurationType);
431 TestViewFilterL(aClient, *filter);
433 filter->SetDirection(KTestDirection);
434 filter->SetDurationType(KTestDurationType);
435 filter->SetStatus(KTestStatus);
436 TestViewFilterL(aClient, *filter);
438 filter->SetDirection(KTestDirection);
439 filter->SetDurationType(KTestDurationType);
440 filter->SetStatus(KTestStatus);
441 filter->SetContact(KTestContact);
442 TestViewFilterL(aClient, *filter);
444 filter->SetDirection(KTestDirection);
445 filter->SetDurationType(KTestDurationType);
446 filter->SetStatus(KTestStatus);
447 filter->SetContact(KTestContact);
448 filter->SetNumber(KTestNumber);
449 TestViewFilterL(aClient, *filter);
451 CleanupStack::PopAndDestroy(); // filter
453 filter = CLogFilter::NewL();
454 CleanupStack::PushL(filter);
456 filter->SetDurationType(KTestDurationType);
457 TestViewFilterL(aClient, *filter);
459 filter->SetDurationType(KTestDurationType);
460 filter->SetStatus(KTestStatus);
461 TestViewFilterL(aClient, *filter);
463 filter->SetDurationType(KTestDurationType);
464 filter->SetStatus(KTestStatus);
465 filter->SetContact(KTestContact);
466 TestViewFilterL(aClient, *filter);
468 filter->SetDurationType(KTestDurationType);
469 filter->SetStatus(KTestStatus);
470 filter->SetContact(KTestContact);
471 filter->SetNumber(KTestNumber);
472 TestViewFilterL(aClient, *filter);
474 CleanupStack::PopAndDestroy(); // filter
476 filter = CLogFilter::NewL();
477 CleanupStack::PushL(filter);
479 filter->SetStatus(KTestStatus);
480 TestViewFilterL(aClient, *filter);
482 filter->SetStatus(KTestStatus);
483 filter->SetContact(KTestContact);
484 TestViewFilterL(aClient, *filter);
486 filter->SetStatus(KTestStatus);
487 filter->SetContact(KTestContact);
488 filter->SetNumber(KTestNumber);
489 TestViewFilterL(aClient, *filter);
491 CleanupStack::PopAndDestroy(); // filter
493 filter = CLogFilter::NewL();
494 CleanupStack::PushL(filter);
496 filter->SetContact(KTestContact);
497 TestViewFilterL(aClient, *filter);
499 filter->SetContact(KTestContact);
500 filter->SetNumber(KTestNumber);
501 TestViewFilterL(aClient, *filter);
503 CleanupStack::PopAndDestroy(); // filter
505 filter = CLogFilter::NewL();
506 CleanupStack::PushL(filter);
508 filter->SetNumber(KTestNumber);
509 TestViewFilterL(aClient, *filter);
511 CleanupStack::PopAndDestroy(2); // filter, active
515 @SYMTestCaseID SYSLIB-LOGENG-CT-0854
516 @SYMTestCaseDesc Tests for filtering list event types
517 @SYMTestPriority High
518 @SYMTestActions Get the count of all event types,call,data,fax events.
519 Add some event types to the filter,test for the new count
520 Check for non existing event type.
521 @SYMTestExpectedResults Test must not fail
524 LOCAL_C void TestEventViewFilter2L(CLogClient& aClient)
526 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0854 "));
527 CTestActive* active = new(ELeave)CTestActive();
528 CleanupStack::PushL(active);
530 CLogViewEvent* view = CLogViewEvent::NewL(aClient);
531 CleanupStack::PushL(view);
533 CLogFilter* filter = CLogFilter::NewL();
534 CleanupStack::PushL(filter);
536 // Get total count of all events
537 if (view->SetFilterL(*filter, active->iStatus))
540 CActiveScheduler::Start();
541 TEST2(active->iStatus.Int(), KErrNone);
543 TInt total = view->CountL();
545 filter->SetEventType(KLogCallEventTypeUid);
547 // Get number of call events
548 if (view->SetFilterL(*filter, active->iStatus))
551 CActiveScheduler::Start();
552 TEST2(active->iStatus.Int(), KErrNone);
554 TInt calls = view->CountL();
556 filter->SetEventType(KLogDataEventTypeUid);
558 // Get number of data events
559 if (view->SetFilterL(*filter, active->iStatus))
562 CActiveScheduler::Start();
563 TEST2(active->iStatus.Int(), KErrNone);
565 TInt data = view->CountL();
567 filter->SetEventType(KLogFaxEventTypeUid);
569 // Get number of fax events
570 if (view->SetFilterL(*filter, active->iStatus))
573 CActiveScheduler::Start();
574 TEST2(active->iStatus.Int(), KErrNone);
576 TInt fax = view->CountL();
578 filter->SetEventType(KLogLbsSelfLocateEventTypeUid);
580 // Get number of Lbs self locate events
581 if (view->SetFilterL(*filter, active->iStatus))
584 CActiveScheduler::Start();
585 TEST2(active->iStatus.Int(), KErrNone);
587 TInt lbsSelf = view->CountL();
589 filter->SetEventType(KLogLbsExternalLocateEventTypeUid);
591 // Get number of Lbs self locate events
592 if (view->SetFilterL(*filter, active->iStatus))
595 CActiveScheduler::Start();
596 TEST2(active->iStatus.Int(), KErrNone);
598 TInt lbsExternal = view->CountL();
600 filter->SetEventType(KLogLbsTransmitLocationEventTypeUid);
602 // Get number of Lbs transmit location events
603 if (view->SetFilterL(*filter, active->iStatus))
606 CActiveScheduler::Start();
607 TEST2(active->iStatus.Int(), KErrNone);
609 TInt lbsXmitLoc = view->CountL();
611 filter->SetEventType(KLogLbsNetworkLocateEventTypeUid);
613 // Get number of Lbs network locate events
614 if (view->SetFilterL(*filter, active->iStatus))
617 CActiveScheduler::Start();
618 TEST2(active->iStatus.Int(), KErrNone);
620 TInt lbsNetwork = view->CountL();
622 filter->SetEventType(KLogLbsAssistanceDataEventTypeUid);
624 // Get number of Lbs assistance data events
625 if (view->SetFilterL(*filter, active->iStatus))
628 CActiveScheduler::Start();
629 TEST2(active->iStatus.Int(), KErrNone);
631 TInt lbsAssistance = view->CountL();
633 CLogEvent* event = CLogEvent::NewL();
634 CleanupStack::PushL(event);
636 event->SetEventType(KLogCallEventTypeUid);
638 // Add two call events
640 aClient.AddEvent(*event, active->iStatus);
641 CActiveScheduler::Start();
642 TEST2(active->iStatus.Int(), KErrNone);
645 aClient.AddEvent(*event, active->iStatus);
646 CActiveScheduler::Start();
647 TEST2(active->iStatus.Int(), KErrNone);
649 event->SetEventType(KLogDataEventTypeUid);
651 // Add two data events
653 aClient.AddEvent(*event, active->iStatus);
654 CActiveScheduler::Start();
655 TEST2(active->iStatus.Int(), KErrNone);
658 aClient.AddEvent(*event, active->iStatus);
659 CActiveScheduler::Start();
660 TEST2(active->iStatus.Int(), KErrNone);
662 // Filter all event types
663 filter->SetEventType(KNullUid);
665 // Get view of all events
667 TBool res = view->SetFilterL(*filter, active->iStatus);
669 CActiveScheduler::Start();
670 TEST2(active->iStatus.Int(), KErrNone);
672 // Check the count is correct
673 TEST2(view->CountL(), total + 4);
675 filter->SetEventType(KLogCallEventTypeUid);
677 // Get view of call events
679 res = view->SetFilterL(*filter, active->iStatus);
681 CActiveScheduler::Start();
682 TEST2(active->iStatus.Int(), KErrNone);
684 TEST2(view->CountL(), calls + 2);
686 filter->SetEventType(KLogDataEventTypeUid);
688 // Get view of data events
690 res = view->SetFilterL(*filter, active->iStatus);
692 CActiveScheduler::Start();
693 TEST2(active->iStatus.Int(), KErrNone);
695 TEST2(view->CountL(), data + 2);
697 filter->SetEventType(KLogFaxEventTypeUid);
699 // Get view of fax events
700 if (view->SetFilterL(*filter, active->iStatus))
703 CActiveScheduler::Start();
704 TEST2(active->iStatus.Int(), KErrNone);
706 TEST2(view->CountL(), fax);
708 filter->SetEventType(KLogLbsSelfLocateEventTypeUid);
710 // Get number of Lbs self locate events
711 if (view->SetFilterL(*filter, active->iStatus))
714 CActiveScheduler::Start();
715 TEST2(active->iStatus.Int(), KErrNone);
717 TEST2(view->CountL(), lbsSelf);
719 filter->SetEventType(KLogLbsExternalLocateEventTypeUid);
721 // Get number of Lbs self locate events
722 if (view->SetFilterL(*filter, active->iStatus))
725 CActiveScheduler::Start();
726 TEST2(active->iStatus.Int(), KErrNone);
728 TEST2(view->CountL(), lbsExternal);
730 filter->SetEventType(KLogLbsTransmitLocationEventTypeUid);
732 // Get number of Lbs transmit location events
733 if (view->SetFilterL(*filter, active->iStatus))
736 CActiveScheduler::Start();
737 TEST2(active->iStatus.Int(), KErrNone);
739 TEST2(view->CountL(), lbsXmitLoc);
741 filter->SetEventType(KLogLbsNetworkLocateEventTypeUid);
743 // Get number of Lbs network locate events
744 if (view->SetFilterL(*filter, active->iStatus))
747 CActiveScheduler::Start();
748 TEST2(active->iStatus.Int(), KErrNone);
750 TEST2(view->CountL(), lbsNetwork);
752 filter->SetEventType(KLogLbsAssistanceDataEventTypeUid);
754 // Get number of Lbs assistance data events
755 if (view->SetFilterL(*filter, active->iStatus))
758 CActiveScheduler::Start();
759 TEST2(active->iStatus.Int(), KErrNone);
761 TEST2(view->CountL(), lbsAssistance);
763 // Test a non existing event type
764 filter->SetEventType(TUid::Uid(0x12345678));
765 res = view->SetFilterL(*filter, active->iStatus);
767 TEST2(view->CountL(), 0);
769 CleanupStack::PopAndDestroy(4); // view, filter, event, active
773 @SYMTestCaseID SYSLIB-LOGENG-CT-0855
774 @SYMTestCaseDesc Tests for CLogViewRecent::SetRecentListL() function
775 @SYMTestPriority High
776 @SYMTestActions Tests for the count of events,outgoing calls.
777 @SYMTestExpectedResults Test must not fail
780 LOCAL_C void TestRecentView1L(CLogClient& aClient)
782 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0855 "));
783 CLogEvent* event = CLogEvent::NewL();
784 CleanupStack::PushL(event);
786 CTestActive* active = new(ELeave)CTestActive();
787 CleanupStack::PushL(active);
789 CLogViewRecent* view = CLogViewRecent::NewL(aClient);
790 CleanupStack::PushL(view);
793 TBuf<KLogMaxDirectionLength> buf;
794 aClient.GetString(buf, R_LOG_DIR_IN);
796 event->SetEventType(KLogCallEventTypeUid);
797 event->SetDirection(buf);
800 for(count = 0; count < KTestEventNum; count++)
802 event->SetContact(count);
805 aClient.AddEvent(*event, active->iStatus);
806 CActiveScheduler::Start();
807 TEST2(active->iStatus.Int(), KErrNone);
810 TEST2(view->CountL(), 0);
811 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
815 count = KTestEventNum;
818 CActiveScheduler::Start();
819 TEST2(active->iStatus.Int(), KErrNone);
821 TEST2(view->CountL(), KTestEventNum);
822 TEST2(view->RecentList(), KLogRecentIncomingCalls);
825 while(view->NextL(active->iStatus));
827 TEST2(view->CountL(), KTestEventNum);
830 while(view->PreviousL(active->iStatus))
833 CActiveScheduler::Start();
834 TEST2(active->iStatus.Int(), KErrNone);
836 TEST2(view->CountL(), KTestEventNum);
837 TEST2(view->RecentList(), KLogRecentIncomingCalls);
840 TEST2(count, KTestEventNum - 1);
843 res = view->FirstL(active->iStatus);
845 CActiveScheduler::Start();
846 TEST2(active->iStatus.Int(), KErrNone);
849 res = view->LastL(active->iStatus);
851 CActiveScheduler::Start();
852 TEST2(active->iStatus.Int(), KErrNone);
854 TEST2(view->CountL(), KTestEventNum);
857 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
859 count = view->CountL();
861 CleanupStack::PopAndDestroy(view);
863 view = CLogViewRecent::NewL(aClient);
864 CleanupStack::PushL(view);
865 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
867 TEST2(view->CountL(), KTestEventNum);
869 CActiveScheduler::Start();
870 TEST2(active->iStatus.Int(), KErrNone);
872 aClient.GetString(buf, R_LOG_DIR_OUT);
874 event->SetEventType(KLogCallEventTypeUid);
875 event->SetDirection(buf);
877 for(count = 0; count < KTestEventNum; count++)
879 event->SetContact(count);
882 aClient.AddEvent(*event, active->iStatus);
883 CActiveScheduler::Start();
884 TEST2(active->iStatus.Int(), KErrNone);
887 count = view->CountL();
888 TEST2(count, KTestEventNum);
889 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
893 count = KTestEventNum;
896 CActiveScheduler::Start();
897 TEST2(active->iStatus.Int(), KErrNone);
899 TEST2(view->CountL(), KTestEventNum);
900 TEST2(view->RecentList(), KLogRecentOutgoingCalls);
903 while(view->NextL(active->iStatus));
905 TEST2(view->CountL(), KTestEventNum);
908 while(view->PreviousL(active->iStatus))
911 CActiveScheduler::Start();
912 TEST2(active->iStatus.Int(), KErrNone);
914 TEST2(view->CountL(), KTestEventNum);
915 TEST2(view->RecentList(), KLogRecentOutgoingCalls);
918 TEST2(count, KTestEventNum - 1);
921 res = view->FirstL(active->iStatus);
923 CActiveScheduler::Start();
924 TEST2(active->iStatus.Int(), KErrNone);
927 res = view->LastL(active->iStatus);
929 CActiveScheduler::Start();
930 TEST2(active->iStatus.Int(), KErrNone);
933 aClient.GetString(buf, R_LOG_DIR_MISSED);
935 event->SetEventType(KLogCallEventTypeUid);
936 event->SetDirection(buf);
938 TEST2(view->CountL(), KTestEventNum);
939 res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
941 TEST2(view->CountL(), 0);
943 for(count = 0; count < KTestEventNum; count++)
945 event->SetContact(count);
948 aClient.AddEvent(*event, active->iStatus);
949 CActiveScheduler::Start();
950 TEST2(active->iStatus.Int(), KErrNone);
952 // Test INC123066 - LogView not updated if log count is zero at
953 // time of SetFilterL.
954 TEST2(view->CountL(), count+1);
959 count = KTestEventNum;
960 while(view->NextL(active->iStatus))
963 CActiveScheduler::Start();
964 TEST2(active->iStatus.Int(), KErrNone);
966 TEST2(view->CountL(), KTestEventNum);
967 TEST2(view->RecentList(), KLogRecentMissedCalls);
973 while(view->PreviousL(active->iStatus))
976 CActiveScheduler::Start();
977 TEST2(active->iStatus.Int(), KErrNone);
979 TEST2(view->CountL(), KTestEventNum);
980 TEST2(view->RecentList(), KLogRecentMissedCalls);
983 TEST2(count, KTestEventNum - 1);
986 res = view->FirstL(active->iStatus);
988 CActiveScheduler::Start();
989 TEST2(active->iStatus.Int(), KErrNone);
992 res = view->LastL(active->iStatus);
994 CActiveScheduler::Start();
995 TEST2(active->iStatus.Int(), KErrNone);
998 TEST2(view->CountL(), KTestEventNum);
999 res = view->SetRecentListL(KLogNullRecentList, active->iStatus);
1003 count = KTestEventNum * 3;
1004 TEST2(view->CountL(), count);
1007 CActiveScheduler::Start();
1008 TEST2(active->iStatus.Int(), KErrNone);
1010 TEST2(view->CountL(), KTestEventNum * 3);
1013 while(view->NextL(active->iStatus));
1017 while(view->PreviousL(active->iStatus))
1020 CActiveScheduler::Start();
1021 TEST2(active->iStatus.Int(), KErrNone);
1023 TEST2(view->CountL(), KTestEventNum * 3);
1026 TEST2(count, KTestEventNum * 3 - 1);
1029 res = view->FirstL(active->iStatus);
1031 CActiveScheduler::Start();
1032 TEST2(active->iStatus.Int(), KErrNone);
1035 res = view->LastL(active->iStatus);
1037 CActiveScheduler::Start();
1038 TEST2(active->iStatus.Int(), KErrNone);
1040 CleanupStack::PopAndDestroy(3); // view, active, event
1041 theLog.Write(_L8("Test 3.1 OK\n"));
1045 @SYMTestCaseID SYSLIB-LOGENG-CT-0856
1046 @SYMTestCaseDesc Tests for CLogViewRecent::SetRecentListL(),DuplicatesL() functions
1047 @SYMTestPriority High
1048 @SYMTestActions Tests for the count of events in the log
1049 @SYMTestExpectedResults Test must not fail
1052 LOCAL_C void TestRecentView2L(CLogClient& aClient)
1054 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0856 "));
1057 CLogEvent* event = CLogEvent::NewL();
1058 CleanupStack::PushL(event);
1060 CTestActive* active = new(ELeave)CTestActive();
1061 CleanupStack::PushL(active);
1063 CLogViewRecent* view = CLogViewRecent::NewL(aClient);
1064 CleanupStack::PushL(view);
1066 TEST2(view->CountL(), 0);
1067 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1070 CActiveScheduler::Start();
1071 TEST2(active->iStatus.Int(), KErrNone);
1072 count = view->CountL();
1073 TEST2(count, KTestEventNum);
1075 aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus);
1077 CActiveScheduler::Start();
1078 TEST2(active->iStatus.Int(), KErrNone);
1080 count = view->CountL();
1083 CleanupStack::PopAndDestroy(view);
1084 view = CLogViewRecent::NewL(aClient);
1085 CleanupStack::PushL(view);
1089 TBuf<KLogMaxDirectionLength> buf;
1090 aClient.GetString(buf, R_LOG_DIR_IN);
1092 event->SetEventType(KLogCallEventTypeUid);
1093 event->SetDirection(buf);
1095 // All fields are null, they should all be duplicates
1096 for(count = 0; count < KTestEventNum; count++)
1099 aClient.AddEvent(*event, active->iStatus);
1100 CActiveScheduler::Start();
1101 TEST2(active->iStatus.Int(), KErrNone);
1104 TEST2(view->CountL(), 0);
1107 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1110 CActiveScheduler::Start();
1111 TEST2(active->iStatus.Int(), KErrNone);
1112 TEST2(view->CountL(), 1);
1114 CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient);
1115 CleanupStack::PushL(dView);
1117 res = view->DuplicatesL(*dView, active->iStatus);
1120 CActiveScheduler::Start();
1121 TEST2(active->iStatus.Int(), KErrNone);
1122 TEST2(dView->CountL(), KTestEventNum - 1);
1124 CleanupStack::PopAndDestroy(4); // view, active, event, dView
1128 @SYMTestCaseID SYSLIB-LOGENG-CT-0857
1129 @SYMTestCaseDesc Tests for CLogViewRecent::RemoveL() functions
1130 @SYMTestPriority High
1131 @SYMTestActions Add the recently view events to the view.Remove the items and check for the count.
1132 @SYMTestExpectedResults Test must not fail
1135 LOCAL_C void TestRecentRemove1L(CLogClient& aClient)
1137 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0857 "));
1138 CTestActive* active = new(ELeave)CTestActive();
1139 CleanupStack::PushL(active);
1141 CLogViewRecent* view = CLogViewRecent::NewL(aClient);
1142 CleanupStack::PushL(view);
1144 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1147 CActiveScheduler::Start();
1148 TEST2(active->iStatus.Int(), KErrNone);
1150 TInt count = view->CountL();
1152 while(view->RemoveL(active->iStatus))
1154 TEST2(view->CountL(), count - 1);
1155 count = view->CountL();
1158 CActiveScheduler::Start();
1159 TEST2(active->iStatus.Int(), KErrNone);
1161 TEST2(view->CountL(), 0);
1163 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
1166 CActiveScheduler::Start();
1167 TEST2(active->iStatus.Int(), KErrNone);
1168 TEST2(view->CountL(), KTestEventNum);
1170 aClient.ClearLog(KLogRecentOutgoingCalls, active->iStatus);
1172 CActiveScheduler::Start();
1173 TEST2(active->iStatus.Int(), KErrNone);
1174 TEST2(view->CountL(), 0);
1176 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
1179 res = view->SetRecentListL(KLogNullRecentList, active->iStatus);
1182 CActiveScheduler::Start();
1183 TEST2(active->iStatus.Int(), KErrNone);
1184 TEST2(view->CountL(), KTestEventNum);
1186 aClient.ClearLog(KLogNullRecentList, active->iStatus);
1188 CActiveScheduler::Start();
1189 TEST2(active->iStatus.Int(), KErrNone);
1191 res = view->SetRecentListL(KLogNullRecentList, active->iStatus);
1193 TEST2(view->CountL(), 0);
1195 CleanupStack::PopAndDestroy(2); // view, active
1199 @SYMTestCaseID SYSLIB-LOGENG-CT-0858
1200 @SYMTestCaseDesc Tests for CLogViewRecent::RemoveL() functions
1201 @SYMTestPriority High
1202 @SYMTestActions Add the recently view events to the two logviewrecents.Remove the items and check for the count of the first logview.
1203 @SYMTestExpectedResults Test must not fail
1206 LOCAL_C void TestRecentRemove2L(CLogClient& aClient)
1208 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0858 "));
1209 CLogEvent* event = CLogEvent::NewL();
1210 CleanupStack::PushL(event);
1212 CTestActive* active = new(ELeave)CTestActive();
1213 CleanupStack::PushL(active);
1215 CLogViewRecent* view1 = CLogViewRecent::NewL(aClient);
1216 CleanupStack::PushL(view1);
1219 TBuf<KLogMaxDirectionLength> buf;
1220 aClient.GetString(buf, R_LOG_DIR_IN);
1222 event->SetEventType(KLogCallEventTypeUid);
1223 event->SetDirection(buf);
1226 for(count = 0; count < KTestEventNum; count++)
1228 event->SetContact(count);
1231 aClient.AddEvent(*event, active->iStatus);
1232 CActiveScheduler::Start();
1233 TEST2(active->iStatus.Int(), KErrNone);
1236 // Create another invalid view and remove an event using it
1237 CLogViewRecent* view2 = CLogViewRecent::NewL(aClient);
1238 CleanupStack::PushL(view2);
1240 TEST2(view1->CountL(), 0);
1241 TBool res = view1->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1243 TEST2(view1->CountL(), KTestEventNum);
1248 CActiveScheduler::Start();
1249 TEST2(active->iStatus.Int(), KErrNone);
1250 view2->RemoveL(view1->Event().Id());
1252 while(view1->NextL(active->iStatus));
1254 aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus);
1256 CActiveScheduler::Start();
1257 TEST2(active->iStatus.Int(), KErrNone);
1258 TEST2(view1->CountL(), 0);
1260 CleanupStack::PopAndDestroy(4); // view2, view1, active, event
1264 @SYMTestCaseID SYSLIB-LOGENG-CT-0859
1265 @SYMTestCaseDesc Tests for CLogViewDuplicate::SetRecentListL(),DuplicatesL() functions
1266 @SYMTestPriority High
1267 @SYMTestActions Tests for the count of events and the event ID
1268 @SYMTestExpectedResults Test must not fail
1271 LOCAL_C void TestDuplicateViewL(CLogClient& aClient)
1273 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0859 "));
1274 CTestActive* active = new(ELeave)CTestActive();
1275 CleanupStack::PushL(active);
1277 CLogViewRecent* view = CLogViewRecent::NewL(aClient);
1278 CleanupStack::PushL(view);
1280 CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient);
1281 CleanupStack::PushL(dView);
1283 TEST2(dView->CountL(), 0);
1285 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1287 TEST2(view->CountL(), 0);
1289 res = view->DuplicatesL(*dView, active->iStatus);
1291 TEST2(dView->CountL(), 0);
1294 TBuf<KLogMaxDirectionLength> incoming;
1295 aClient.GetString(incoming, R_LOG_DIR_IN);
1297 CLogEvent* event = CLogEvent::NewL();
1298 CleanupStack::PushL(event);
1300 event->SetEventType(KLogCallEventTypeUid);
1301 event->SetDirection(incoming);
1302 event->SetRemoteParty(KTestRemoteParty);
1303 event->SetContact(KTestContact);
1304 event->SetNumber(KTestNumber);
1307 aClient.AddEvent(*event, active->iStatus);
1308 CActiveScheduler::Start();
1309 TEST2(active->iStatus.Int(), KErrNone);
1311 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1314 CActiveScheduler::Start();
1315 TEST2(active->iStatus.Int(), KErrNone);
1317 TEST2(view->CountL(), 1);
1318 res = view->FirstL(active->iStatus);
1321 CActiveScheduler::Start();
1322 TEST2(active->iStatus.Int(), KErrNone);
1323 TEST2(view->Event().Id(), event->Id());
1325 TEST2(dView->CountL(), 0);
1327 event->SetRemoteParty(KTestRemoteParty);
1328 event->SetContact(KTestContact);
1329 event->SetNumber(KNullDesC);
1331 //Add event with Number field set to NULL
1333 aClient.AddEvent(*event, active->iStatus);
1334 CActiveScheduler::Start();
1335 TEST2(active->iStatus.Int(), KErrNone);
1337 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1340 CActiveScheduler::Start();
1341 TEST2(active->iStatus.Int(), KErrNone);
1343 TEST2(view->CountL(), 2);
1344 res = view->FirstL(active->iStatus);
1347 CActiveScheduler::Start();
1348 TEST2(active->iStatus.Int(), KErrNone);
1349 TEST2(view->Event().Id(), event->Id());
1351 res = view->DuplicatesL(*dView, active->iStatus);
1354 TEST2(dView->CountL(), 0);
1356 event->SetRemoteParty(KTestRemoteParty);
1357 event->SetContact(KLogNullContactId);
1358 event->SetNumber(KNullDesC);
1360 //Add event with Number field set to NULL & Contact set to -1
1362 aClient.AddEvent(*event, active->iStatus);
1363 CActiveScheduler::Start();
1364 TEST2(active->iStatus.Int(), KErrNone);
1366 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1369 CActiveScheduler::Start();
1370 TEST2(active->iStatus.Int(), KErrNone);
1372 TEST2(view->CountL(), 3);
1373 res = view->FirstL(active->iStatus);
1376 CActiveScheduler::Start();
1377 TEST2(active->iStatus.Int(), KErrNone);
1378 TEST2(view->Event().Id(), event->Id());
1380 res = view->DuplicatesL(*dView, active->iStatus);
1383 TEST2(dView->CountL(), 0);
1385 event->SetRemoteParty(KNullDesC);
1386 event->SetContact(KLogNullContactId);
1387 event->SetNumber(KNullDesC);
1389 //Add event with Number, Remote Party field set to NULL & Contact set to -1
1391 aClient.AddEvent(*event, active->iStatus);
1392 CActiveScheduler::Start();
1393 TEST2(active->iStatus.Int(), KErrNone);
1395 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1398 CActiveScheduler::Start();
1399 TEST2(active->iStatus.Int(), KErrNone);
1401 TEST2(view->CountL(), 4);
1403 res = view->DuplicatesL(*dView, active->iStatus);
1406 TEST2(dView->CountL(), 0);
1408 TLogId lastId = event->Id();
1410 //Add event with Number, Remote Party field set to NULL & Contact set to -1
1412 aClient.AddEvent(*event, active->iStatus);
1413 CActiveScheduler::Start();
1414 TEST2(active->iStatus.Int(), KErrNone);
1416 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1419 CActiveScheduler::Start();
1420 TEST2(active->iStatus.Int(), KErrNone);
1422 TEST2(view->CountL(), 4);
1424 res = view->DuplicatesL(*dView, active->iStatus);
1427 CActiveScheduler::Start();
1428 TEST2(active->iStatus.Int(), KErrNone);
1430 TEST2(dView->CountL(), 1);
1431 TEST2(dView->Event().Id(), lastId);
1433 CleanupStack::PopAndDestroy(4); // event, dView, view, active
1437 @SYMTestCaseID SYSLIB-LOGENG-CT-0860
1438 @SYMTestCaseDesc Tests for CLogViewDuplicate::RemoveL() functions
1439 @SYMTestPriority High
1440 @SYMTestActions Tests for removing the events and test for the count
1441 @SYMTestExpectedResults Test must not fail
1444 LOCAL_C void TestDuplicateRemoveL(CLogClient& aClient)
1446 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0860 "));
1447 CTestActive* active = new(ELeave)CTestActive();
1448 CleanupStack::PushL(active);
1450 CLogViewRecent* view = CLogViewRecent::NewL(aClient);
1451 CleanupStack::PushL(view);
1453 CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient);
1454 CleanupStack::PushL(dView);
1456 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1459 CActiveScheduler::Start();
1460 TEST2(active->iStatus.Int(), KErrNone);
1462 //The incoming call list should have count as 4. These calls were added in
1463 //...the previous function named TestDuplicateViewL()
1464 TEST2(view->CountL(), 4);
1466 res = view->DuplicatesL(*dView, active->iStatus);
1469 CActiveScheduler::Start();
1470 TEST2(active->iStatus.Int(), KErrNone);
1472 TLogId id = dView->Event().Id();
1473 TEST2(dView->CountL(), 1);
1475 res = dView->RemoveL(active->iStatus);
1478 TEST2(dView->CountL(), 0);
1480 res = dView->RemoveL(active->iStatus);
1482 TEST2(dView->CountL(), 0);
1484 TEST2(view->CountL(), 4);
1486 CleanupStack::PopAndDestroy(3); // dView, view, active
1490 @SYMTestCaseID SYSLIB-LOGENG-CT-0861
1491 @SYMTestCaseDesc Tests for purging on log engine
1492 @SYMTestPriority High
1493 @SYMTestActions Tests for changing the log engine configuration,add event and test for retrieving them back.
1494 Set up a purge which clears the log and reset the log configuration
1495 @SYMTestExpectedResults Test must not fail
1498 LOCAL_C void TestPurgeOnSetup1L(CLogClient& aClient)
1500 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0861 "));
1501 CTestActive* active = new(ELeave)CTestActive();
1502 CleanupStack::PushL(active);
1504 User::After(0x100000);
1507 now.UniversalTime();
1509 // Clear all the events
1511 aClient.ClearLog(now, active->iStatus);
1512 CActiveScheduler::Start();
1513 TEST2(active->iStatus.Int(), KErrNone);
1515 CLogEvent* event = CLogEvent::NewL();
1516 CleanupStack::PushL(event);
1517 event->SetEventType(KLogCallEventTypeUid);
1521 // Get log configuration
1523 aClient.GetConfig(config, active->iStatus);
1524 CActiveScheduler::Start();
1525 TEST2(active->iStatus.Int(), KErrNone);
1527 // Set the maximum log age
1528 TInt oldAge = config.iMaxEventAge;
1529 config.iMaxEventAge = 10; // 10 seconds!
1531 // Change the log engine config
1533 aClient.ChangeConfig(config, active->iStatus);
1534 CActiveScheduler::Start();
1535 TEST2(active->iStatus.Int(), KErrNone);
1538 aClient.AddEvent(*event, active->iStatus);
1539 CActiveScheduler::Start();
1540 TEST2(active->iStatus.Int(), KErrNone);
1542 // Check that the event can be retrieved
1544 aClient.GetEvent(*event, active->iStatus);
1545 CActiveScheduler::Start();
1546 TEST2(active->iStatus.Int(), KErrNone);
1548 // Wait for 15 seconds (just to be safe)
1549 User::After(15000000);
1551 // Check that the event can be retrieved
1553 aClient.GetEvent(*event, active->iStatus);
1554 CActiveScheduler::Start();
1555 TEST2(active->iStatus.Int(), KErrNone);
1557 // Check that the event can still be retrieved
1559 aClient.GetEvent(*event, active->iStatus);
1560 CActiveScheduler::Start();
1561 TEST2(active->iStatus.Int(), KErrNone);
1563 // Check that the event can still be retrieved
1565 aClient.GetEvent(*event, active->iStatus);
1566 CActiveScheduler::Start();
1567 TEST2(active->iStatus.Int(), KErrNone);
1569 CLogViewEvent* view = CLogViewEvent::NewL(aClient);
1570 CleanupStack::PushL(view);
1572 CLogFilter* filter = CLogFilter::NewL();
1573 CleanupStack::PushL(filter);
1575 // Setup a view which should purge the event - hence no events in view!
1576 TBool res = view->SetFilterL(*filter, active->iStatus);
1580 config.iMaxEventAge = oldAge;
1582 // Change the log engine config
1584 aClient.ChangeConfig(config, active->iStatus);
1585 CActiveScheduler::Start();
1586 TEST2(active->iStatus.Int(), KErrNone);
1588 CleanupStack::PopAndDestroy(4); // filter, view, active, event
1592 @SYMTestCaseID SYSLIB-LOGENG-CT-0862
1593 @SYMTestCaseDesc Tests for purging on log engine
1594 @SYMTestPriority High
1595 @SYMTestActions Clear the events from the log,set the log engine age to maximum.Change the configuration,and test adding and retrieving the events.
1596 Set up a purge which clears the log and reset the log configuration
1597 @SYMTestExpectedResults Test must not fail
1600 LOCAL_C void TestPurgeOnSetup2L(CLogClient& aClient)
1602 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0862 "));
1603 CTestActive* active1 = new(ELeave)CTestActive();
1604 CleanupStack::PushL(active1);
1606 CTestActive* active2 = new(ELeave)CTestActive();
1607 CleanupStack::PushL(active2);
1609 User::After(0x100000);
1612 now.UniversalTime();
1614 // Clear all the events
1616 aClient.ClearLog(now, active1->iStatus);
1617 CActiveScheduler::Start();
1618 TEST2(active1->iStatus.Int(), KErrNone);
1620 CLogEvent* event = CLogEvent::NewL();
1621 CleanupStack::PushL(event);
1622 event->SetEventType(KLogCallEventTypeUid);
1626 // Get log configuration
1628 aClient.GetConfig(config, active1->iStatus);
1629 CActiveScheduler::Start();
1630 TEST2(active1->iStatus.Int(), KErrNone);
1632 // Set the maximum log age
1633 TInt oldAge = config.iMaxEventAge;
1634 config.iMaxEventAge = 10; // 10 seconds!
1636 // Change the log engine config
1638 aClient.ChangeConfig(config, active1->iStatus);
1639 CActiveScheduler::Start();
1640 TEST2(active1->iStatus.Int(), KErrNone);
1643 aClient.AddEvent(*event, active1->iStatus);
1644 CActiveScheduler::Start();
1645 TEST2(active1->iStatus.Int(), KErrNone);
1647 // Check that the event can be retrieved
1649 aClient.GetEvent(*event, active1->iStatus);
1650 CActiveScheduler::Start();
1651 TEST2(active1->iStatus.Int(), KErrNone);
1653 // Wait for 15 seconds (just to be safe)
1654 User::After(15000000);
1656 // Check that the event can be retrieved
1658 aClient.GetEvent(*event, active1->iStatus);
1659 CActiveScheduler::Start();
1660 TEST2(active1->iStatus.Int(), KErrNone);
1662 // Check that the event can still be retrieved
1664 aClient.GetEvent(*event, active1->iStatus);
1665 CActiveScheduler::Start();
1666 TEST2(active1->iStatus.Int(), KErrNone);
1668 // Check that the event can still be retrieved
1670 aClient.GetEvent(*event, active1->iStatus);
1671 CActiveScheduler::Start();
1672 TEST2(active1->iStatus.Int(), KErrNone);
1674 CLogViewEvent* view1 = CLogViewEvent::NewL(aClient);
1675 CleanupStack::PushL(view1);
1677 CLogViewEvent* view2 = CLogViewEvent::NewL(aClient);
1678 CleanupStack::PushL(view2);
1680 CLogFilter* filter = CLogFilter::NewL();
1681 CleanupStack::PushL(filter);
1683 // Setup a view which should purge the event - hence no events in view!
1684 TBool res = view1->SetFilterL(*filter, active1->iStatus);
1686 res = view2->SetFilterL(*filter, active2->iStatus);
1690 config.iMaxEventAge = oldAge;
1692 // Change the log engine config
1694 aClient.ChangeConfig(config, active1->iStatus);
1695 CActiveScheduler::Start();
1696 TEST2(active1->iStatus.Int(), KErrNone);
1698 CleanupStack::PopAndDestroy(6); // filter, view1, view2, active1, active2, event
1702 @SYMTestCaseID SYSLIB-LOGENG-CT-0863
1703 @SYMTestCaseDesc Tests for purge on CLogViewRecent
1704 @SYMTestPriority High
1705 @SYMTestActions Set the log engine maximum log size and recent log size.Change the configuration and add events to the log
1706 Tests the count to be less than or equal to recent logsize.
1707 @SYMTestExpectedResults Test must not fail
1710 LOCAL_C void TestViewPurgeL(CLogClient& aClient)
1712 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0863 "));
1713 CTestActive* active = new(ELeave)CTestActive();
1714 CleanupStack::PushL(active);
1718 aClient.GetConfig(config, active->iStatus);
1720 CActiveScheduler::Start();
1721 TEST2(active->iStatus.Int(), KErrNone);
1722 TEST2(config.iMaxLogSize, 1000);
1724 config.iMaxLogSize = 2000;
1725 config.iMaxRecentLogSize = 20;
1727 aClient.ChangeConfig(config, active->iStatus);
1729 CActiveScheduler::Start();
1730 TEST2(active->iStatus.Int(), KErrNone);
1732 CLogEvent* event = CLogEvent::NewL();
1733 CleanupStack::PushL(event);
1735 CLogViewRecent* view = CLogViewRecent::NewL(aClient);
1736 CleanupStack::PushL(view);
1739 TBuf<KLogMaxDirectionLength> buf;
1740 aClient.GetString(buf, R_LOG_DIR_IN);
1742 event->SetEventType(KLogCallEventTypeUid);
1743 event->SetDirection(buf);
1745 for(TInt count = 0; count < config.iMaxRecentLogSize * 2; count++)
1747 event->SetContact(count);
1750 aClient.AddEvent(*event, active->iStatus);
1751 CActiveScheduler::Start();
1752 TEST2(active->iStatus.Int(), KErrNone);
1754 TBool res = view->SetRecentListL(KLogNullRecentList, active->iStatus);
1757 CActiveScheduler::Start();
1758 TEST2(active->iStatus.Int(), KErrNone);
1759 TEST(view->CountL() <= config.iMaxRecentLogSize);
1762 CleanupStack::PopAndDestroy(3); // active, event, view
1766 @SYMTestCaseID SYSLIB-LOGENG-CT-0864
1767 @SYMTestCaseDesc Tests for the functionality of CLogViewDuplicate class
1768 @SYMTestPriority High
1769 @SYMTestActions Tests for clearing the duplicate events
1770 @SYMTestExpectedResults Test must not fail
1773 LOCAL_C void TestClearDuplicatesL(CLogClient& aClient)
1775 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0864 "));
1776 CTestActive* active = new(ELeave)CTestActive();
1777 CleanupStack::PushL(active);
1779 aClient.ClearLog(KLogNullRecentList, active->iStatus);
1781 CActiveScheduler::Start();
1782 TEST2(active->iStatus.Int(), KErrNone);
1784 CLogViewRecent* view = CLogViewRecent::NewL(aClient);
1785 CleanupStack::PushL(view);
1787 CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient);
1788 CleanupStack::PushL(dView);
1790 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1793 TBuf<KLogMaxDirectionLength> incoming;
1794 aClient.GetString(incoming, R_LOG_DIR_IN);
1796 TBuf<KLogMaxDirectionLength> outgoing;
1797 aClient.GetString(outgoing, R_LOG_DIR_OUT);
1799 TBuf<KLogMaxDirectionLength> missed;
1800 aClient.GetString(missed, R_LOG_DIR_MISSED);
1802 CLogEvent* event = CLogEvent::NewL();
1803 CleanupStack::PushL(event);
1805 event->SetEventType(KLogCallEventTypeUid);
1807 // Add 5 recent events to each list - with 5 duplicates each
1810 event->SetDirection(incoming);
1812 for(recent = 1; recent <= 5; recent++)
1814 event->SetContact(recent);
1815 for(TInt duplicate = 1; duplicate <= 6; duplicate++)
1818 aClient.AddEvent(*event, active->iStatus);
1819 CActiveScheduler::Start();
1820 TEST2(active->iStatus.Int(), KErrNone);
1825 event->SetDirection(outgoing);
1826 for(recent = 1; recent <= 5; recent++)
1828 event->SetContact(recent);
1829 for(TInt duplicate = 1; duplicate <= 6; duplicate++)
1832 aClient.AddEvent(*event, active->iStatus);
1833 CActiveScheduler::Start();
1834 TEST2(active->iStatus.Int(), KErrNone);
1839 event->SetDirection(missed);
1840 for(recent = 1; recent <= 5; recent++)
1842 event->SetContact(recent);
1843 for(TInt duplicate = 1; duplicate <= 6; duplicate++)
1846 aClient.AddEvent(*event, active->iStatus);
1847 CActiveScheduler::Start();
1848 TEST2(active->iStatus.Int(), KErrNone);
1853 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
1855 TEST2(view->CountL(), 5);
1860 CActiveScheduler::Start();
1861 TEST2(active->iStatus.Int(), KErrNone);
1863 res = view->DuplicatesL(*dView, active->iStatus);
1865 TEST2(dView->CountL(), 5);
1867 CActiveScheduler::Start();
1868 TEST2(active->iStatus.Int(), KErrNone);
1870 while(view->NextL(active->iStatus));
1873 res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
1875 TEST2(view->CountL(), 5);
1880 CActiveScheduler::Start();
1881 TEST2(active->iStatus.Int(), KErrNone);
1883 res = view->DuplicatesL(*dView, active->iStatus);
1885 TEST2(dView->CountL(), 5);
1887 CActiveScheduler::Start();
1888 TEST2(active->iStatus.Int(), KErrNone);
1890 while(view->NextL(active->iStatus));
1893 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1895 TEST2(view->CountL(), 5);
1900 CActiveScheduler::Start();
1901 TEST2(active->iStatus.Int(), KErrNone);
1903 res = view->DuplicatesL(*dView, active->iStatus);
1905 TEST2(dView->CountL(), 5);
1907 CActiveScheduler::Start();
1908 TEST2(active->iStatus.Int(), KErrNone);
1910 while(view->NextL(active->iStatus));
1912 // Clear duplicates for incoming
1913 view->ClearDuplicatesL();
1914 TEST2(view->CountL(), 5);
1916 // Recent list should be unchanged
1917 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1919 TEST2(view->CountL(), 5);
1924 CActiveScheduler::Start();
1925 TEST2(active->iStatus.Int(), KErrNone);
1927 // No duplicates should exist for this view now
1928 res = view->DuplicatesL(*dView, active->iStatus);
1930 TEST2(dView->CountL(), 0);
1932 while(view->NextL(active->iStatus));
1934 // Check outgoing is unchanged
1935 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
1937 TEST2(view->CountL(), 5);
1942 CActiveScheduler::Start();
1943 TEST2(active->iStatus.Int(), KErrNone);
1945 res = view->DuplicatesL(*dView, active->iStatus);
1947 TEST2(dView->CountL(), 5);
1949 CActiveScheduler::Start();
1950 TEST2(active->iStatus.Int(), KErrNone);
1952 while(view->NextL(active->iStatus));
1954 // Check missed is unchanged
1955 res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
1957 TEST2(view->CountL(), 5);
1962 CActiveScheduler::Start();
1963 TEST2(active->iStatus.Int(), KErrNone);
1965 res = view->DuplicatesL(*dView, active->iStatus);
1967 TEST2(dView->CountL(), 5);
1969 CActiveScheduler::Start();
1970 TEST2(active->iStatus.Int(), KErrNone);
1972 while(view->NextL(active->iStatus));
1974 // Clear duplicates for missed
1975 view->ClearDuplicatesL();
1976 TEST2(view->CountL(), 5);
1978 // Recent list should be unchanged
1979 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
1981 TEST2(view->CountL(), 5);
1986 CActiveScheduler::Start();
1987 TEST2(active->iStatus.Int(), KErrNone);
1989 // No duplicates should exist for this view now
1990 res = view->DuplicatesL(*dView, active->iStatus);
1992 TEST2(dView->CountL(), 0);
1994 while(view->NextL(active->iStatus));
1996 // Missed recent list should be unchanged
1997 res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
1999 TEST2(view->CountL(), 5);
2004 CActiveScheduler::Start();
2005 TEST2(active->iStatus.Int(), KErrNone);
2007 // No duplicates should exist for this view now
2008 res = view->DuplicatesL(*dView, active->iStatus);
2010 TEST2(dView->CountL(), 0);
2012 while(view->NextL(active->iStatus));
2014 // Check outgoing is unchanged
2015 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
2017 TEST2(view->CountL(), 5);
2022 CActiveScheduler::Start();
2023 TEST2(active->iStatus.Int(), KErrNone);
2025 res = view->DuplicatesL(*dView, active->iStatus);
2027 TEST2(dView->CountL(), 5);
2029 CActiveScheduler::Start();
2030 TEST2(active->iStatus.Int(), KErrNone);
2032 while(view->NextL(active->iStatus));
2034 // Clear duplicates for outgoing
2035 view->ClearDuplicatesL();
2036 TEST2(view->CountL(), 5);
2038 // Recent list should be unchanged
2039 res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
2041 TEST2(view->CountL(), 5);
2046 CActiveScheduler::Start();
2047 TEST2(active->iStatus.Int(), KErrNone);
2049 // No duplicates should exist for this view now
2050 res = view->DuplicatesL(*dView, active->iStatus);
2052 TEST2(dView->CountL(), 0);
2054 while(view->NextL(active->iStatus));
2056 // Missed recent list should be unchanged
2057 res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
2059 TEST2(view->CountL(), 5);
2064 CActiveScheduler::Start();
2065 TEST2(active->iStatus.Int(), KErrNone);
2067 // No duplicates should exist for this view now
2068 res = view->DuplicatesL(*dView, active->iStatus);
2070 TEST2(dView->CountL(), 0);
2072 while(view->NextL(active->iStatus));
2074 // Check outgoing is unchanged
2075 res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
2077 TEST2(view->CountL(), 5);
2082 CActiveScheduler::Start();
2083 TEST2(active->iStatus.Int(), KErrNone);
2085 // No duplicates should exist for this view now
2086 res = view->DuplicatesL(*dView, active->iStatus);
2088 TEST2(dView->CountL(), 0);
2090 while(view->NextL(active->iStatus));
2092 CleanupStack::PopAndDestroy(4); // event, dView, view, active
2096 @SYMTestCaseID SYSLIB-LOGENG-CT-0865
2097 @SYMTestCaseDesc Test for the functionality of CLogViewEvent class
2098 @SYMTestPriority High
2099 @SYMTestActions Set an event with a number,add the event to the client.Tests for matching a number from the view
2100 @SYMTestExpectedResults Test must not fail
2103 LOCAL_C void TestPhoneNumberMatchingL(CLogClient& aClient)
2105 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0865 "));
2106 TestUtils::DeleteDatabaseL();
2108 CTestActive* active = new(ELeave)CTestActive();
2109 CleanupStack::PushL(active);
2111 CLogEvent* event = CLogEvent::NewL();
2112 CleanupStack::PushL(event);
2114 event->SetEventType(KLogCallEventTypeUid);
2115 TBuf<KLogMaxDirectionLength> missed;
2116 aClient.GetString(missed, R_LOG_DIR_MISSED);
2117 event->SetDirection(missed);
2121 for(i = 0; i < 10; i++)
2125 number.Insert(0, digit);
2126 event->SetNumber(number);
2128 aClient.AddEvent(*event, active->iStatus);
2130 CActiveScheduler::Start();
2131 TEST2(active->iStatus.Int(), KErrNone);
2134 CLogFilter* filter = CLogFilter::NewL();
2135 CleanupStack::PushL(filter);
2137 CLogViewEvent* view = CLogViewEvent::NewL(aClient);
2138 CleanupStack::PushL(view);
2140 TBool res = view->SetFilterL(*filter, active->iStatus);
2143 CActiveScheduler::Start();
2144 TEST2(active->iStatus.Int(), KErrNone);
2145 TEST2(view->CountL(), 10);
2148 for(i = 0; i < 10; i++)
2152 number.Insert(0, digit);
2153 filter->SetNumber(number);
2155 // This is testing phone number matching
2156 res = view->SetFilterL(*filter, active->iStatus);
2159 CActiveScheduler::Start();
2160 TEST2(active->iStatus.Int(), KErrNone);
2162 // Phone numbers with KTestLogNumberCharsToMatch characters or above can match with each other
2163 TEST2(view->CountL(), (number.Length() < KTestLogNumberCharsToMatch) ? 1 : 11-KTestLogNumberCharsToMatch);
2166 CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
2167 CleanupStack::PushL(recent);
2169 CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient);
2170 CleanupStack::PushL(duplicate);
2172 res = recent->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
2175 CActiveScheduler::Start();
2176 TEST2(active->iStatus.Int(), KErrNone);
2177 TEST2(recent->CountL(), KTestLogNumberCharsToMatch);
2179 res = recent->DuplicatesL(*duplicate, active->iStatus);
2181 TEST2(duplicate->CountL(), 10-KTestLogNumberCharsToMatch);
2183 // Check the first recent event has duplicates
2187 CActiveScheduler::Start();
2188 TEST2(active->iStatus.Int(), KErrNone);
2190 TPtrC number1(recent->Event().Number().Right(KTestLogNumberCharsToMatch));
2191 TPtrC number2(duplicate->Event().Number().Right(KTestLogNumberCharsToMatch));
2192 TEST(number1 == number2);
2194 while(duplicate->NextL(active->iStatus));
2196 // Check none of the others have duplicates
2197 while(recent->NextL(active->iStatus))
2200 CActiveScheduler::Start();
2201 TEST2(active->iStatus.Int(), KErrNone);
2202 res = recent->DuplicatesL(*duplicate, active->iStatus);
2206 CleanupStack::PopAndDestroy(6); // duplicate, recent, view, filter, event, active
2210 @SYMTestCaseID SYSLIB-LOGENG-CT-3472
2211 @SYMTestCaseDesc Tests duplicate number matching correctly compares and matches the last 9 digits
2212 @SYMTestPriority High
2213 @SYMTestActions Create and add several numbers to client, check that duplicates are correctly removed
2214 @SYMTestExpectedResults Number with the same last 9 digits should get matched as duplicates
2217 LOCAL_C void INC105010L(CLogClient& aClient)
2219 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-3472 "));
2220 TestUtils::DeleteDatabaseL();
2222 CTestActive* active = new(ELeave)CTestActive();
2223 CleanupStack::PushL(active);
2225 CLogEvent* event = CLogEvent::NewL();
2226 CleanupStack::PushL(event);
2228 event->SetEventType(KLogCallEventTypeUid);
2229 TBuf<KLogMaxDirectionLength> missed;
2230 aClient.GetString(missed, R_LOG_DIR_MISSED);
2231 event->SetDirection(missed);
2233 _LIT(KTestNumber1, "0401234567"); // unique
2234 _LIT(KTestNumber2, "0421234567"); // unique
2235 _LIT(KTestNumber3, "0521234567"); // unique
2236 _LIT(KTestNumber4, "9521234567"); // duplicate
2237 _LIT(KTestNumber5, "9521234567"); // duplicate
2241 // add events for the above numbers
2242 event->SetNumber(KTestNumber1);
2243 aClient.AddEvent(*event, active->iStatus);
2245 CActiveScheduler::Start();
2246 TEST2(active->iStatus.Int(), KErrNone);
2248 event->SetNumber(KTestNumber2);
2249 aClient.AddEvent(*event, active->iStatus);
2251 CActiveScheduler::Start();
2252 TEST2(active->iStatus.Int(), KErrNone);
2254 event->SetNumber(KTestNumber3);
2255 aClient.AddEvent(*event, active->iStatus);
2257 CActiveScheduler::Start();
2258 TEST2(active->iStatus.Int(), KErrNone);
2260 event->SetNumber(KTestNumber4);
2261 aClient.AddEvent(*event, active->iStatus);
2263 CActiveScheduler::Start();
2264 TEST2(active->iStatus.Int(), KErrNone);
2266 event->SetNumber(KTestNumber5);
2267 aClient.AddEvent(*event, active->iStatus);
2269 CActiveScheduler::Start();
2270 TEST2(active->iStatus.Int(), KErrNone);
2272 CLogFilter* filter = CLogFilter::NewL();
2273 CleanupStack::PushL(filter);
2275 CLogViewEvent* view = CLogViewEvent::NewL(aClient);
2276 CleanupStack::PushL(view);
2278 // check 5 entries in log
2279 TBool res = view->SetFilterL(*filter, active->iStatus);
2282 CActiveScheduler::Start();
2283 TEST2(active->iStatus.Int(), KErrNone);
2284 TEST2(view->CountL(), 5);
2286 CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
2287 CleanupStack::PushL(recent);
2289 CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient);
2290 CleanupStack::PushL(duplicate);
2292 // check only 3 entries in recent calls view
2293 res = recent->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
2296 CActiveScheduler::Start();
2297 TEST2(active->iStatus.Int(), KErrNone);
2298 TInt rrr = recent->CountL();
2299 TEST2(recent->CountL(), 3);
2301 // and that there are 2 duplicates
2302 res = recent->DuplicatesL(*duplicate, active->iStatus);
2305 CActiveScheduler::Start();
2306 TEST2(active->iStatus.Int(), KErrNone);
2308 TInt ddd = duplicate->CountL();
2309 TEST2(duplicate->CountL(), 2);
2311 CleanupStack::PopAndDestroy(6);
2317 @SYMTestCaseID SYSLIB-LOGENG-CT-0866
2318 @SYMTestCaseDesc Tests for CLogViewEvent::SetFlagsL() function
2319 @SYMTestPriority High
2320 @SYMTestActions Add events to the log and set the flags.Check if all the flags are set.
2321 Clear all the flags and set half view of the flags.Check if only all view of the flags are set.
2322 @SYMTestExpectedResults Test must not fail
2325 LOCAL_C void TestRecentFlagsL(CLogClient& aClient)
2327 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0866 "));
2328 TestUtils::DeleteDatabaseL();
2330 CLogEvent* event = CLogEvent::NewL();
2331 CleanupStack::PushL(event);
2333 CTestActive* active = new(ELeave)CTestActive();
2334 CleanupStack::PushL(active);
2336 CLogViewRecent* view = CLogViewRecent::NewL(aClient);
2337 CleanupStack::PushL(view);
2340 TBuf<KLogMaxDirectionLength> buf;
2341 aClient.GetString(buf, R_LOG_DIR_IN);
2343 event->SetEventType(KLogCallEventTypeUid);
2344 event->SetDirection(buf);
2347 for(count = 0; count < KTestEventNum; count++)
2349 event->SetContact(count);
2352 aClient.AddEvent(*event, active->iStatus);
2353 CActiveScheduler::Start();
2354 TEST2(active->iStatus.Int(), KErrNone);
2357 TEST2(view->CountL(), 0);
2358 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
2361 CActiveScheduler::Start();
2362 TEST2(active->iStatus.Int(), KErrNone);
2363 TEST2(view->CountL(), KTestEventNum);
2365 // Set all flags in view
2366 const TLogFlags KAllFlagsSet = 15; // (BIN) 1,1,1,1
2367 view->SetFlagsL(KAllFlagsSet);
2369 // Check we can move to the first record
2370 res = view->FirstL(active->iStatus);
2373 // Check all flags are now set
2374 count = KTestEventNum;
2377 CActiveScheduler::Start();
2378 TEST2(active->iStatus.Int(), KErrNone);
2380 TEST2(view->CountL(), KTestEventNum);
2381 TEST2(view->RecentList(), KLogRecentIncomingCalls);
2383 const TLogFlags flags = view->Event().Flags();
2384 TEST2(flags, KAllFlagsSet);
2387 while(view->NextL(active->iStatus));
2390 TEST2(view->CountL(), KTestEventNum);
2392 // Clear all flags in view
2393 const TLogFlags KAllFlagsCleared = 0; // (BIN) 0,0,0,0
2394 view->SetFlagsL(KAllFlagsCleared);
2395 TEST2(view->CountL(), KTestEventNum);
2397 // Check we can move to the first record
2398 res = view->FirstL(active->iStatus);
2401 // Check all flags are now set
2402 count = KTestEventNum;
2405 CActiveScheduler::Start();
2406 TEST2(active->iStatus.Int(), KErrNone);
2408 TEST2(view->CountL(), KTestEventNum);
2409 TEST2(view->RecentList(), KLogRecentIncomingCalls);
2411 const TLogFlags flags = view->Event().Flags();
2412 TEST2(flags, KAllFlagsCleared);
2415 while(view->NextL(active->iStatus));
2418 TEST2(view->CountL(), KTestEventNum);
2420 // Set lower half flags in view
2421 const TLogFlags KLowerHalfFlagsSet = 3; // (BIN) 1,1,0,0
2422 view->SetFlagsL(KLowerHalfFlagsSet);
2424 // Check we can move to the first record
2425 res = view->FirstL(active->iStatus);
2428 // Check all flags are now set
2429 count = KTestEventNum;
2432 CActiveScheduler::Start();
2433 TEST2(active->iStatus.Int(), KErrNone);
2435 TEST2(view->CountL(), KTestEventNum);
2436 TEST2(view->RecentList(), KLogRecentIncomingCalls);
2438 const TLogFlags flags = view->Event().Flags();
2439 TEST2(flags, KLowerHalfFlagsSet);
2442 while(view->NextL(active->iStatus));
2445 TEST2(view->CountL(), KTestEventNum);
2447 CleanupStack::PopAndDestroy(3, event); // view, active, event
2451 @SYMTestCaseID SYSLIB-LOGENG-CT-0867
2452 @SYMTestCaseDesc Tests for CLogViewEvent::SetFlagsL() function
2453 @SYMTestPriority High
2454 @SYMTestActions Add events to the log and set the flags.Check if flags for only the events in view are set.
2455 @SYMTestExpectedResults Test must not fail
2458 LOCAL_C void TestViewFlagsL(CLogClient& aClient)
2460 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0867 "));
2461 TestUtils::DeleteDatabaseL();
2463 CLogEvent* event = CLogEvent::NewL();
2464 CleanupStack::PushL(event);
2466 CTestActive* active = new(ELeave)CTestActive();
2467 CleanupStack::PushL(active);
2469 CLogViewEvent* view = CLogViewEvent::NewL(aClient);
2470 CleanupStack::PushL(view);
2473 TBuf<KLogMaxDirectionLength> buf;
2474 aClient.GetString(buf, R_LOG_DIR_IN);
2476 event->SetEventType(KLogCallEventTypeUid);
2477 event->SetDirection(buf);
2479 event->SetNumber(_L("123"));
2481 aClient.AddEvent(*event, active->iStatus);
2482 CActiveScheduler::Start();
2483 TEST2(active->iStatus.Int(), KErrNone);
2484 TLogId testId = event->Id();
2485 event->SetNumber(KNullDesC);
2486 TheTest.Printf(_L(" Event flags: 0x%X\r\n"), event->Flags());
2489 for(count = 0; count < KTestEventNum; count++)
2491 event->SetContact(count + 1);
2494 aClient.AddEvent(*event, active->iStatus);
2495 CActiveScheduler::Start();
2496 TEST2(active->iStatus.Int(), KErrNone);
2499 TEST2(view->CountL(), 0);
2501 CLogFilter* filter = CLogFilter::NewL();
2502 CleanupStack::PushL(filter);
2503 filter->SetNullFields(ELogNumberField);
2505 TEST2(view->CountL(), 0);
2506 TBool res = view->SetFilterL(*filter, active->iStatus);
2509 CActiveScheduler::Start();
2510 TEST2(active->iStatus.Int(), KErrNone);
2511 TEST2(view->CountL(), KTestEventNum);
2513 // Set all flags in view
2514 const TLogFlags KAllFlagsSet = 15; // (BIN) 1,1,1,1
2515 view->SetFlagsL(KAllFlagsSet);
2517 // Check flags only set for events in the view
2519 event->SetId(testId);
2520 aClient.GetEvent(*event, active->iStatus);
2521 CActiveScheduler::Start();
2522 TEST2(active->iStatus.Int(), KErrNone);
2523 if( TheMatchingIsEnabled)
2524 {//This check will fail if the first AddEvent() call in this function didn't perform contact matching
2525 TEST2(event->Flags(), KLogEventContactSearched);
2529 TEST2(event->Flags(), 0);
2532 // Check we can move to the first record
2533 res = view->FirstL(active->iStatus);
2536 // Check all flags are now set
2537 count = KTestEventNum;
2540 CActiveScheduler::Start();
2541 TEST2(active->iStatus.Int(), KErrNone);
2543 TEST2(view->CountL(), KTestEventNum);
2545 const TLogFlags flags = view->Event().Flags();
2546 TEST2(flags, KAllFlagsSet);
2549 while(view->NextL(active->iStatus));
2552 TEST2(view->CountL(), KTestEventNum);
2554 // Clear all flags in view
2555 const TLogFlags KAllFlagsCleared = 0; // (BIN) 0,0,0,0
2556 view->SetFlagsL(KAllFlagsCleared);
2557 TEST2(view->CountL(), KTestEventNum);
2559 // Check flags only set for events in the view
2561 event->SetId(testId);
2562 aClient.GetEvent(*event, active->iStatus);
2563 CActiveScheduler::Start();
2564 TEST2(active->iStatus.Int(), KErrNone);
2565 if( TheMatchingIsEnabled)
2567 TEST2(event->Flags(), KLogEventContactSearched);
2571 TEST2(event->Flags(), 0);
2574 // Check we can move to the first record
2575 res = view->FirstL(active->iStatus);
2578 // Check all flags are now set
2579 count = KTestEventNum;
2582 CActiveScheduler::Start();
2583 TEST2(active->iStatus.Int(), KErrNone);
2585 TEST2(view->CountL(), KTestEventNum);
2587 const TLogFlags flags = view->Event().Flags();
2588 TEST2(flags, KAllFlagsCleared);
2591 while(view->NextL(active->iStatus));
2594 TEST2(view->CountL(), KTestEventNum);
2596 // Set lower half flags in view
2597 const TLogFlags KLowerHalfFlagsSet = 3; // (BIN) 1,1,0,0
2598 view->SetFlagsL(KLowerHalfFlagsSet);
2600 // Check flags only set for events in the view
2602 event->SetId(testId);
2603 aClient.GetEvent(*event, active->iStatus);
2604 CActiveScheduler::Start();
2605 TEST2(active->iStatus.Int(), KErrNone);
2606 if( TheMatchingIsEnabled)
2608 TEST2(event->Flags(), KLogEventContactSearched);
2612 TEST2(event->Flags(), 0);
2615 // Check we can move to the first record
2616 res = view->FirstL(active->iStatus);
2619 // Check all flags are now set
2620 count = KTestEventNum;
2623 CActiveScheduler::Start();
2624 TEST2(active->iStatus.Int(), KErrNone);
2626 TEST2(view->CountL(), KTestEventNum);
2628 const TLogFlags flags = view->Event().Flags();
2629 TEST2(flags, KLowerHalfFlagsSet);
2632 while(view->NextL(active->iStatus));
2635 TEST2(view->CountL(), KTestEventNum);
2637 CleanupStack::PopAndDestroy(4, event); // filter, view, active, event
2641 @SYMTestCaseID SYSLIB-LOGENG-CT-0868
2642 @SYMTestCaseDesc Tests for CLogViewChangeObserver::HaveChanges(),Changes() functions
2643 @SYMTestPriority High
2644 @SYMTestActions Check for observing changes while adding and deleting events
2645 @SYMTestExpectedResults Test must not fail
2648 LOCAL_C void TestViewChangeEvents1L(CLogClient& aClient)
2650 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0868 "));
2651 TestUtils::DeleteDatabaseL();
2653 CLogEvent* event = CLogEvent::NewL();
2654 CleanupStack::PushL(event);
2656 CLogFilter* filter = CLogFilter::NewL();
2657 CleanupStack::PushL(filter);
2658 filter->SetContact(KTestContact);
2659 filter->SetEventType(KLogPacketDataEventTypeUid);
2661 CTestActive* active = new(ELeave)CTestActive();
2662 CleanupStack::PushL(active);
2664 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
2665 changeObs->SetActive();
2667 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
2668 CleanupStack::PushL(view);
2671 TBuf<KLogMaxDirectionLength> buf;
2672 aClient.GetString(buf, R_LOG_DIR_IN);
2674 event->SetEventType(KLogPacketDataEventTypeUid);
2675 event->SetDirection(buf);
2676 event->SetContact(KTestContact);
2680 for(count = 0; count < KTestEventNum; count++)
2683 aClient.AddEvent(*event, active->iStatus);
2684 CActiveScheduler::Start();
2685 TEST2(active->iStatus.Int(), KErrNone);
2686 User::After(1 * 1000000);
2689 TEST2(view->CountL(), 0);
2691 TBool res = view->SetFilterL(*filter, active->iStatus);
2693 CActiveScheduler::Start();
2694 TEST2(active->iStatus.Int(), KErrNone);
2695 TEST2(view->CountL(), KTestEventNum);
2697 count = KTestEventNum;
2698 res = view->FirstL(active->iStatus);
2702 CActiveScheduler::Start();
2703 TEST2(active->iStatus.Int(), KErrNone);
2705 TEST2(view->CountL(), KTestEventNum);
2706 const TLogId eventId = view->Event().Id();
2707 TLogId id = --count;
2710 while(view->NextL(active->iStatus));
2716 TLogDatabaseChangeType type;
2717 CLogChangeDefinition* changes;
2719 // Add an event and check for changes
2721 aClient.AddEvent(*event, active->iStatus);
2722 changes = changeObs->WaitForChangesLC();
2723 if (active->IsActive())
2724 CActiveScheduler::Start();
2725 TEST2(active->iStatus.Int(), KErrNone);
2726 count = view->CountL();
2727 TEST2(count, KTestEventNum+1);
2729 changeCount = changes->Count();
2730 for(i=0; i<changeCount; i++)
2732 type = changes->At(i, logId, viewIndex);
2733 TheTest.Printf(_L("Change Type: %d, logId: %d, viewIndex: %d\n"), type, logId, viewIndex);
2736 // Check the change was as expected
2737 TEST2(changes->Count(), 1);
2738 type = changes->At(0, logId, viewIndex);
2739 TEST2(type, ELogChangeTypeEventAdded);
2740 TEST2(viewIndex, 0); // first (newest) event in the view
2742 const TLogId expectedLogId = ((TLogId) KTestEventNum);
2743 TEST2(logId, expectedLogId);
2745 CleanupStack::PopAndDestroy(changes);
2747 // Check view navigation
2749 res = view->FirstL(active->iStatus);
2754 CActiveScheduler::Start();
2755 TEST2(active->iStatus.Int(), KErrNone);
2756 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
2758 while(view->NextL(active->iStatus));
2759 TheTest.Printf(_L("==\n"));
2761 res = view->FirstL(active->iStatus);
2764 CActiveScheduler::Start();
2765 TEST2(active->iStatus.Int(), KErrNone);
2767 // Delete some events
2768 TEST(KTestEventNum >= 10);
2769 changeObs->StartCollectingChanges();
2770 for(i=1; i<KTestEventNum; i+=2)
2773 aClient.DeleteEvent(TLogId(i), active->iStatus);
2774 CActiveScheduler::Start();
2775 TEST2(active->iStatus.Int(), KErrNone);
2779 changeCount = changeObs->Changes().Count();
2780 TEST2(changeCount, 5); // 1,3,5,7,9
2781 for(i=0; i<changeCount; i++)
2783 TEST2(changeObs->Changes().At(i, logId, viewIndex), ELogChangeTypeEventDeleted);
2784 TEST2(logId, TLogId(2*i + 1));
2785 TEST2(viewIndex, 10 - ((2*i) + 1));
2788 // Add a new event that shouldn't appear in the view
2789 changeObs->StartCollectingChanges();
2790 event->SetContact(TLogContactItemId(0));
2792 aClient.AddEvent(*event, active->iStatus);
2793 CActiveScheduler::Start();
2794 TEST2(active->iStatus.Int(), KErrNone);
2795 count = view->CountL();
2796 TEST2(count, KTestEventNum + 1 - 5);
2797 TEST2(event->Id(), KTestEventNum + 1);
2800 TEST(!changeObs->HaveChanges());
2802 // Check view navigation
2804 res = view->FirstL(active->iStatus);
2809 CActiveScheduler::Start();
2810 TEST2(active->iStatus.Int(), KErrNone);
2811 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
2813 while(view->NextL(active->iStatus));
2814 TheTest.Printf(_L("==\n"));
2816 res = view->FirstL(active->iStatus);
2819 CActiveScheduler::Start();
2820 TEST2(active->iStatus.Int(), KErrNone);
2822 // Delete event which isn't in view
2823 changeObs->StartCollectingChanges();
2825 aClient.DeleteEvent(event->Id(), active->iStatus);
2826 CActiveScheduler::Start();
2827 TEST2(active->iStatus.Int(), KErrNone);
2828 count = view->CountL();
2829 TEST2(count, KTestEventNum + 1 - 5);
2832 TEST(!changeObs->HaveChanges());
2834 // Check view navigation
2836 res = view->FirstL(active->iStatus);
2841 CActiveScheduler::Start();
2842 TEST2(active->iStatus.Int(), KErrNone);
2843 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
2845 while(view->NextL(active->iStatus));
2846 TheTest.Printf(_L("==\n"));
2848 res = view->FirstL(active->iStatus);
2851 CActiveScheduler::Start();
2852 TEST2(active->iStatus.Int(), KErrNone);
2854 // Add a new event again that shouldn't appear in the view
2855 changeObs->StartCollectingChanges();
2856 event->SetContact(TLogContactItemId(0));
2858 aClient.AddEvent(*event, active->iStatus);
2859 CActiveScheduler::Start();
2860 TEST2(active->iStatus.Int(), KErrNone);
2861 count = view->CountL();
2862 TEST2(count, KTestEventNum + 1 - 5);
2863 TEST2(event->Id(), KTestEventNum + 2);
2866 TEST(!changeObs->HaveChanges());
2868 // Check view navigation
2870 res = view->FirstL(active->iStatus);
2875 CActiveScheduler::Start();
2876 TEST2(active->iStatus.Int(), KErrNone);
2877 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
2879 while(view->NextL(active->iStatus));
2880 TheTest.Printf(_L("==\n"));
2882 res = view->FirstL(active->iStatus);
2885 CActiveScheduler::Start();
2886 TEST2(active->iStatus.Int(), KErrNone);
2888 // Change event so that it appears in the view
2889 changeObs->StartCollectingChanges();
2890 event->SetContact(KTestContact);
2892 aClient.ChangeEvent(*event, active->iStatus);
2893 CActiveScheduler::Start();
2894 TEST2(active->iStatus.Int(), KErrNone);
2895 count = view->CountL();
2896 TEST2(count, KTestEventNum + 2 - 5);
2897 TEST2(event->Id(), KTestEventNum + 2); // Shouldn't change
2900 changeCount = changeObs->Changes().Count();
2901 TEST2(changeCount, 1);
2902 type = changeObs->Changes().At(0, logId, viewIndex);
2903 TEST2(type, ELogChangeTypeEventAdded);
2904 TEST2(logId, KTestEventNum + 2);
2905 TEST2(viewIndex, 0);
2907 // Check view navigation
2909 res = view->FirstL(active->iStatus);
2914 CActiveScheduler::Start();
2915 TEST2(active->iStatus.Int(), KErrNone);
2916 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
2918 while(view->NextL(active->iStatus));
2919 TheTest.Printf(_L("==\n"));
2921 res = view->FirstL(active->iStatus);
2924 CActiveScheduler::Start();
2925 TEST2(active->iStatus.Int(), KErrNone);
2927 // Simply change an event in the view
2928 changeObs->StartCollectingChanges();
2929 event->SetDescription(_L("Test"));
2931 aClient.ChangeEvent(*event, active->iStatus);
2932 CActiveScheduler::Start();
2933 TEST2(active->iStatus.Int(), KErrNone);
2934 count = view->CountL();
2935 TEST2(count, KTestEventNum + 2 - 5); // Shouldn't change
2936 TEST2(event->Id(), KTestEventNum + 2); // Shouldn't change
2939 changeCount = changeObs->Changes().Count();
2940 TEST2(changeCount, 1);
2941 type = changeObs->Changes().At(0, logId, viewIndex);
2942 TEST2(type, ELogChangeTypeEventChanged);
2943 TEST2(logId, KTestEventNum + 2);
2944 TEST2(viewIndex, 0);
2946 // Change an event in the view so that it is deleted
2947 changeObs->StartCollectingChanges();
2948 event->SetContact(0);
2950 aClient.ChangeEvent(*event, active->iStatus);
2951 CActiveScheduler::Start();
2952 TEST2(active->iStatus.Int(), KErrNone);
2953 count = view->CountL();
2954 TEST2(count, KTestEventNum + 2 - 5 - 1); // one less now
2957 changeCount = changeObs->Changes().Count();
2958 TEST2(changeCount, 1);
2959 type = changeObs->Changes().At(0, logId, viewIndex);
2960 TEST2(type, ELogChangeTypeEventDeleted);
2961 TEST2(logId, KTestEventNum + 2);
2962 TEST2(viewIndex, 0);
2964 // Navigate part way through the view so we have
2965 // a cursor position part way through...
2967 count = view->CountL();
2968 res = view->FirstL(active->iStatus);
2973 CActiveScheduler::Start();
2974 TEST2(active->iStatus.Int(), KErrNone);
2975 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
2977 while(view->NextL(active->iStatus));
2978 TheTest.Printf(_L("==\n"));
2980 TEST2(view->Event().Id(), TLogId(0));
2983 TLogId savedId = view->Event().Id();
2986 res = view->PreviousL(active->iStatus);
2989 CActiveScheduler::Start();
2990 TEST2(active->iStatus.Int(), KErrNone);
2993 changeObs->StartCollectingChanges();
2994 event->SetContact(KTestContact);
2996 aClient.AddEvent(*event, active->iStatus);
2997 CActiveScheduler::Start();
2998 TEST2(active->iStatus.Int(), KErrNone);
2999 count = view->CountL();
3000 TEST2(count, KTestEventNum + 2 - 5); // one more now
3001 TEST2(event->Id(), KTestEventNum + 3);
3004 changeCount = changeObs->Changes().Count();
3005 TEST2(changeCount, 1);
3006 type = changeObs->Changes().At(0, logId, viewIndex);
3007 TEST2(type, ELogChangeTypeEventAdded);
3008 TEST2(logId, KTestEventNum + 3);
3009 TEST2(viewIndex, 0);
3011 // Check we can still go forward to the last record
3012 res = view->NextL(active->iStatus);
3015 CActiveScheduler::Start();
3016 TEST2(active->iStatus.Int(), KErrNone);
3017 TEST2(view->Event().Id(), savedId);
3020 res = view->PreviousL(active->iStatus);
3023 CActiveScheduler::Start();
3024 TEST2(active->iStatus.Int(), KErrNone);
3026 // Delete current record
3027 savedId = view->Event().Id();
3028 changeObs->StartCollectingChanges();
3030 aClient.DeleteEvent(savedId, active->iStatus);
3031 CActiveScheduler::Start();
3032 TEST2(active->iStatus.Int(), KErrNone);
3033 count = view->CountL();
3034 TEST2(count, KTestEventNum + 2 - 5 - 1); // one less
3037 changeCount = changeObs->Changes().Count();
3038 TEST2(changeCount, 1);
3039 type = changeObs->Changes().At(0, logId, viewIndex);
3040 TEST2(type, ELogChangeTypeEventDeleted);
3041 TEST2(logId, savedId);
3042 TEST2(viewIndex, KTestEventNum + 2 - 5 - 2); // last but one event
3044 // Check we're now at the end of the view
3045 res = view->NextL(active->iStatus);
3048 // Go to the first record
3049 res = view->FirstL(active->iStatus);
3052 CActiveScheduler::Start();
3053 TEST2(active->iStatus.Int(), KErrNone);
3055 // Delete the first record
3056 savedId = view->Event().Id();
3057 changeObs->StartCollectingChanges();
3059 aClient.DeleteEvent(savedId, active->iStatus);
3060 CActiveScheduler::Start();
3061 TEST2(active->iStatus.Int(), KErrNone);
3062 count = view->CountL();
3063 TEST2(count, KTestEventNum - 5);
3066 changeCount = changeObs->Changes().Count();
3067 TEST2(changeCount, 1);
3068 type = changeObs->Changes().At(0, logId, viewIndex);
3069 TEST2(type, ELogChangeTypeEventDeleted);
3070 TEST2(logId, savedId);
3071 TEST2(viewIndex, 0); // first item
3073 // Check 'next' navigation can be performed correctly
3075 view->NextL(active->iStatus);
3079 CActiveScheduler::Start();
3080 TEST2(active->iStatus.Int(), KErrNone);
3083 while(view->NextL(active->iStatus));
3084 TEST2(count, KTestEventNum - 5 - 1);
3086 // Check last record
3087 savedId = view->Event().Id();
3088 res = view->LastL(active->iStatus);
3091 CActiveScheduler::Start();
3092 TEST2(active->iStatus.Int(), KErrNone);
3093 TEST2(savedId, view->Event().Id());
3095 // Delete the last record
3096 savedId = view->Event().Id();
3097 changeObs->StartCollectingChanges();
3099 aClient.DeleteEvent(savedId, active->iStatus);
3100 CActiveScheduler::Start();
3101 TEST2(active->iStatus.Int(), KErrNone);
3102 count = view->CountL();
3103 TEST2(count, KTestEventNum - 6);
3106 changeCount = changeObs->Changes().Count();
3107 TEST2(changeCount, 1);
3108 type = changeObs->Changes().At(0, logId, viewIndex);
3109 TEST2(type, ELogChangeTypeEventDeleted);
3110 TEST2(logId, savedId);
3111 TEST2(viewIndex, count); // There's now one less item, and we deleted the last item of the previous view
3113 // Check we're still at the end of the view
3114 res = view->NextL(active->iStatus);
3117 CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event
3120 CBaBackupSessionWrapper* theBackup = NULL;
3122 LOCAL_C TBool IsLogOpenL()
3124 return TestUtils::IsDatabaseOpenL();
3127 LOCAL_C void TestLogOpenL()
3132 LOCAL_C void TestLogClosedL()
3134 TEST(!IsLogOpenL());
3137 LOCAL_C void StartBackupL()
3139 User::InfoPrint(_L("Backup"));
3141 TDriveUnit driveUnit(EDriveC);
3142 TDriveName name = driveUnit.Name();
3145 LEAVE_IF_ERROR(parse.Set(KLogDatabaseName, &name, NULL));
3149 theBackup = CBaBackupSessionWrapper::NewL();
3151 theBackup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
3152 User::After(1000000);
3155 LOCAL_C void EndBackupL()
3159 User::After(1000000);
3162 LOCAL_C void DelayL(TInt aDelay)
3164 CTestTimer* timer = CTestTimer::NewL();
3165 timer->After(aDelay);
3166 CActiveScheduler::Start();
3171 @SYMTestCaseID SYSLIB-LOGENG-CT-0869
3172 @SYMTestCaseDesc Tests for CLogViewChangeObserver::HaveChanges(),CLogViewChangeObserver::Changes() functions
3173 @SYMTestPriority High
3174 @SYMTestActions Check for observing changes while adding,deleting events.Check for observing changes after a backup.
3175 Check for navigating the view.Test for KErrNone condition.
3176 @SYMTestExpectedResults Test must not fail
3179 LOCAL_C void TestViewChangeEvents1aL(CLogClient& aClient)
3181 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0869 "));
3182 TestUtils::DeleteDatabaseL();
3184 CLogEvent* event = CLogEvent::NewL();
3185 CleanupStack::PushL(event);
3187 CLogFilter* filter = CLogFilter::NewL();
3188 CleanupStack::PushL(filter);
3189 filter->SetContact(KTestContact);
3190 filter->SetEventType(KLogPacketDataEventTypeUid);
3192 CTestActive* active = new(ELeave)CTestActive();
3193 CleanupStack::PushL(active);
3195 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
3196 changeObs->SetActive();
3198 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
3199 CleanupStack::PushL(view);
3202 TBuf<KLogMaxDirectionLength> buf;
3203 aClient.GetString(buf, R_LOG_DIR_IN);
3205 event->SetEventType(KLogPacketDataEventTypeUid);
3206 event->SetDirection(buf);
3207 event->SetContact(KTestContact);
3211 for(count = 0; count < KTestEventNum; count++)
3214 aClient.AddEvent(*event, active->iStatus);
3215 CActiveScheduler::Start();
3216 TEST2(active->iStatus.Int(), KErrNone);
3217 User::After(1 * 1000000);
3220 TEST2(view->CountL(), 0);
3222 TEST(view->SetFilterL(*filter, active->iStatus));
3223 CActiveScheduler::Start();
3224 TEST2(active->iStatus.Int(), KErrNone);
3225 TEST2(view->CountL(), KTestEventNum);
3227 count = KTestEventNum;
3228 TEST(view->FirstL(active->iStatus));
3231 CActiveScheduler::Start();
3232 TEST2(active->iStatus.Int(), KErrNone);
3234 TEST2(view->CountL(), KTestEventNum);
3235 const TLogId eventId = view->Event().Id();
3236 TEST2(eventId, (TLogId)--count);
3238 while(view->NextL(active->iStatus));
3244 TLogDatabaseChangeType type;
3245 CLogChangeDefinition* changes;
3247 // Add an event and check for changes
3249 aClient.AddEvent(*event, active->iStatus);
3250 changes = changeObs->WaitForChangesLC();
3251 if (active->IsActive())
3252 CActiveScheduler::Start();
3253 TEST2(active->iStatus.Int(), KErrNone);
3254 count = view->CountL();
3255 TEST2(count, KTestEventNum+1);
3257 changeCount = changes->Count();
3258 for(i=0; i<changeCount; i++)
3260 type = changes->At(i, logId, viewIndex);
3261 TheTest.Printf(_L("Change Type: %d, logId: %d, viewIndex: %d"), type, logId, viewIndex);
3264 // Check the change was as expected
3265 TEST2(changes->Count(), 1);
3266 type = changes->At(0, logId, viewIndex);
3267 TEST2(type, ELogChangeTypeEventAdded);
3268 TEST2(viewIndex, 0); // first (newest) event in the view
3270 const TLogId expectedLogId = ((TLogId) KTestEventNum);
3271 TEST2(logId, expectedLogId);
3273 CleanupStack::PopAndDestroy(changes);
3275 // Check view navigation
3277 TEST(view->FirstL(active->iStatus));
3281 CActiveScheduler::Start();
3282 TEST2(active->iStatus.Int(), KErrNone);
3283 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
3285 while(view->NextL(active->iStatus));
3286 TheTest.Printf(_L("==\n"));
3288 TEST(view->FirstL(active->iStatus));
3290 CActiveScheduler::Start();
3291 TEST2(active->iStatus.Int(), KErrNone);
3293 // Check that changes work after a backup
3301 // Delete some events
3302 TEST(KTestEventNum >= 10);
3303 changeObs->StartCollectingChanges();
3304 for(i=1; i<KTestEventNum; i+=2)
3307 aClient.DeleteEvent(TLogId(i), active->iStatus);
3308 CActiveScheduler::Start();
3309 TEST2(active->iStatus.Int(), KErrNone);
3313 changeCount = changeObs->Changes().Count();
3314 TEST2(changeCount, 5); // 1,3,5,7,9
3315 for(i=0; i<changeCount; i++)
3317 TEST2(changeObs->Changes().At(i, logId, viewIndex), ELogChangeTypeEventDeleted);
3318 TEST2(logId, TLogId(2*i + 1));
3319 TEST2(viewIndex, 10 - ((2*i) + 1));
3322 // Check that changes work after a backup
3329 // Add a new event that shouldn't appear in the view
3330 changeObs->StartCollectingChanges();
3331 event->SetContact(TLogContactItemId(0));
3333 aClient.AddEvent(*event, active->iStatus);
3334 CActiveScheduler::Start();
3335 TEST2(active->iStatus.Int(), KErrNone);
3336 count = view->CountL();
3337 TEST2(count, KTestEventNum + 1 - 5);
3338 TEST2(event->Id(), KTestEventNum + 1);
3341 TEST(!changeObs->HaveChanges());
3343 // Check view navigation
3345 TEST(view->FirstL(active->iStatus));
3349 CActiveScheduler::Start();
3350 TEST2(active->iStatus.Int(), KErrNone);
3351 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
3353 while(view->NextL(active->iStatus));
3354 TheTest.Printf(_L("==\n"));
3356 TEST(view->FirstL(active->iStatus));
3358 CActiveScheduler::Start();
3359 TEST2(active->iStatus.Int(), KErrNone);
3361 // Check that changes work after a backup
3368 // Delete event which isn't in view
3369 changeObs->StartCollectingChanges();
3371 aClient.DeleteEvent(event->Id(), active->iStatus);
3372 CActiveScheduler::Start();
3373 TEST2(active->iStatus.Int(), KErrNone);
3374 count = view->CountL();
3375 TEST2(count, KTestEventNum + 1 - 5);
3378 TEST(!changeObs->HaveChanges());
3380 // Check view navigation
3382 TEST(view->FirstL(active->iStatus));
3386 CActiveScheduler::Start();
3387 TEST2(active->iStatus.Int(), KErrNone);
3388 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
3390 while(view->NextL(active->iStatus));
3391 TheTest.Printf(_L("==\n"));
3393 TEST(view->FirstL(active->iStatus));
3395 CActiveScheduler::Start();
3396 TEST2(active->iStatus.Int(), KErrNone);
3398 // Check that changes work after a backup
3405 // Add a new event again that shouldn't appear in the view
3406 changeObs->StartCollectingChanges();
3407 event->SetContact(TLogContactItemId(0));
3409 aClient.AddEvent(*event, active->iStatus);
3410 CActiveScheduler::Start();
3411 TEST2(active->iStatus.Int(), KErrNone);
3412 count = view->CountL();
3413 TEST2(count, KTestEventNum + 1 - 5);
3414 TEST2(event->Id(), KTestEventNum + 2);
3417 TEST(!changeObs->HaveChanges());
3419 // Check view navigation
3421 TEST(view->FirstL(active->iStatus));
3425 CActiveScheduler::Start();
3426 TEST2(active->iStatus.Int(), KErrNone);
3427 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
3429 while(view->NextL(active->iStatus));
3430 TheTest.Printf(_L("==\n"));
3432 TEST(view->FirstL(active->iStatus));
3434 CActiveScheduler::Start();
3435 TEST2(active->iStatus.Int(), KErrNone);
3437 // Check that changes work after a backup
3444 // Change event so that it appears in the view
3445 changeObs->StartCollectingChanges();
3446 event->SetContact(KTestContact);
3448 aClient.ChangeEvent(*event, active->iStatus);
3449 CActiveScheduler::Start();
3450 TEST2(active->iStatus.Int(), KErrNone);
3451 count = view->CountL();
3452 TEST2(count, KTestEventNum + 2 - 5);
3453 TEST2(event->Id(), KTestEventNum + 2); // Shouldn't change
3456 changeCount = changeObs->Changes().Count();
3457 TEST2(changeCount, 1);
3458 type = changeObs->Changes().At(0, logId, viewIndex);
3459 TEST2(type, ELogChangeTypeEventAdded);
3460 TEST2(logId, KTestEventNum + 2);
3461 TEST2(viewIndex, 0);
3463 // Check view navigation
3465 TEST(view->FirstL(active->iStatus));
3469 CActiveScheduler::Start();
3470 TEST2(active->iStatus.Int(), KErrNone);
3471 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
3473 while(view->NextL(active->iStatus));
3474 TheTest.Printf(_L("==\n"));
3476 TEST(view->FirstL(active->iStatus));
3478 CActiveScheduler::Start();
3479 TEST2(active->iStatus.Int(), KErrNone);
3481 // Check that changes work after a backup
3488 // Simply change an event in the view
3489 changeObs->StartCollectingChanges();
3490 event->SetDescription(_L("Test"));
3492 aClient.ChangeEvent(*event, active->iStatus);
3493 CActiveScheduler::Start();
3494 TEST2(active->iStatus.Int(), KErrNone);
3495 count = view->CountL();
3496 TEST2(count, KTestEventNum + 2 - 5); // Shouldn't change
3497 TEST2(event->Id(), KTestEventNum + 2); // Shouldn't change
3500 changeCount = changeObs->Changes().Count();
3501 TEST2(changeCount, 1);
3502 type = changeObs->Changes().At(0, logId, viewIndex);
3503 TEST2(type, ELogChangeTypeEventChanged);
3504 TEST2(logId, KTestEventNum + 2);
3505 TEST2(viewIndex, 0);
3507 // Check that changes work after a backup
3514 // Change an event in the view so that it is deleted
3515 changeObs->StartCollectingChanges();
3516 event->SetContact(0);
3518 aClient.ChangeEvent(*event, active->iStatus);
3519 CActiveScheduler::Start();
3520 TEST2(active->iStatus.Int(), KErrNone);
3521 count = view->CountL();
3522 TEST2(count, KTestEventNum + 2 - 5 - 1); // one less now
3525 changeCount = changeObs->Changes().Count();
3526 TEST2(changeCount, 1);
3527 type = changeObs->Changes().At(0, logId, viewIndex);
3528 TEST2(type, ELogChangeTypeEventDeleted);
3529 TEST2(logId, KTestEventNum + 2);
3530 TEST2(viewIndex, 0);
3532 // Navigate part way through the view so we have
3533 // a cursor position part way through...
3535 count = view->CountL();
3536 TEST(view->FirstL(active->iStatus));
3540 CActiveScheduler::Start();
3541 TEST2(active->iStatus.Int(), KErrNone);
3542 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
3544 while(view->NextL(active->iStatus));
3545 TheTest.Printf(_L("==\n"));
3547 TEST2(view->Event().Id(), TLogId(0));
3550 TLogId savedId = view->Event().Id();
3553 TEST(view->PreviousL(active->iStatus));
3555 CActiveScheduler::Start();
3556 TEST2(active->iStatus.Int(), KErrNone);
3558 // Check that changes work after a backup
3566 changeObs->StartCollectingChanges();
3567 event->SetContact(KTestContact);
3569 aClient.AddEvent(*event, active->iStatus);
3570 CActiveScheduler::Start();
3571 TEST2(active->iStatus.Int(), KErrNone);
3572 count = view->CountL();
3573 TEST2(count, KTestEventNum + 2 - 5); // one more now
3574 TEST2(event->Id(), KTestEventNum + 3);
3577 changeCount = changeObs->Changes().Count();
3578 TEST2(changeCount, 1);
3579 type = changeObs->Changes().At(0, logId, viewIndex);
3580 TEST2(type, ELogChangeTypeEventAdded);
3581 TEST2(logId, KTestEventNum + 3);
3582 TEST2(viewIndex, 0);
3584 // Check we can still go forward to the last record
3585 TEST(view->NextL(active->iStatus));
3587 CActiveScheduler::Start();
3588 TEST2(active->iStatus.Int(), KErrNone);
3589 TEST2(view->Event().Id(), savedId);
3592 TEST(view->PreviousL(active->iStatus));
3594 CActiveScheduler::Start();
3595 TEST2(active->iStatus.Int(), KErrNone);
3597 // Check that changes work after a backup
3604 // Delete current record
3605 savedId = view->Event().Id();
3606 changeObs->StartCollectingChanges();
3608 aClient.DeleteEvent(savedId, active->iStatus);
3609 CActiveScheduler::Start();
3610 TEST2(active->iStatus.Int(), KErrNone);
3611 count = view->CountL();
3612 TEST2(count, KTestEventNum + 2 - 5 - 1); // one less
3615 changeCount = changeObs->Changes().Count();
3616 TEST2(changeCount, 1);
3617 type = changeObs->Changes().At(0, logId, viewIndex);
3618 TEST2(type, ELogChangeTypeEventDeleted);
3619 TEST2(logId, savedId);
3620 TEST2(viewIndex, KTestEventNum + 2 - 5 - 2); // last but one event
3622 // Check we're now at the end of the view
3623 TEST(!view->NextL(active->iStatus));
3625 // Go to the first record
3626 TEST(view->FirstL(active->iStatus));
3628 CActiveScheduler::Start();
3629 TEST2(active->iStatus.Int(), KErrNone);
3631 // Check that changes work after a backup
3638 // Delete the first record
3639 savedId = view->Event().Id();
3640 changeObs->StartCollectingChanges();
3642 aClient.DeleteEvent(savedId, active->iStatus);
3643 CActiveScheduler::Start();
3644 TEST2(active->iStatus.Int(), KErrNone);
3645 count = view->CountL();
3646 TEST2(count, KTestEventNum - 5);
3649 changeCount = changeObs->Changes().Count();
3650 TEST2(changeCount, 1);
3651 type = changeObs->Changes().At(0, logId, viewIndex);
3652 TEST2(type, ELogChangeTypeEventDeleted);
3653 TEST2(logId, savedId);
3654 TEST2(viewIndex, 0); // first item
3656 // Check 'next' navigation can be performed correctly
3658 view->NextL(active->iStatus);
3662 CActiveScheduler::Start();
3663 TEST2(active->iStatus.Int(), KErrNone);
3666 while(view->NextL(active->iStatus));
3667 TEST2(count, KTestEventNum - 5 - 1);
3669 // Check last record
3670 savedId = view->Event().Id();
3671 TEST(view->LastL(active->iStatus));
3673 CActiveScheduler::Start();
3674 TEST2(active->iStatus.Int(), KErrNone);
3675 TEST2(savedId, view->Event().Id());
3677 // Check that changes work after a backup
3684 // Delete the last record
3685 savedId = view->Event().Id();
3686 changeObs->StartCollectingChanges();
3688 aClient.DeleteEvent(savedId, active->iStatus);
3689 CActiveScheduler::Start();
3690 TEST2(active->iStatus.Int(), KErrNone);
3691 count = view->CountL();
3692 TEST2(count, KTestEventNum - 6);
3695 changeCount = changeObs->Changes().Count();
3696 TEST2(changeCount, 1);
3697 type = changeObs->Changes().At(0, logId, viewIndex);
3698 TEST2(type, ELogChangeTypeEventDeleted);
3699 TEST2(logId, savedId);
3700 TEST2(viewIndex, count); // There's now one less item, and we deleted the last item of the previous view
3702 // Check we're still at the end of the view
3703 TEST(!view->NextL(active->iStatus));
3705 CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event
3709 @SYMTestCaseID SYSLIB-LOGENG-CT-0870
3710 @SYMTestCaseDesc Tests for CLogViewChangeObserver::HaveChanges(),Changes() functions
3711 @SYMTestPriority High
3712 @SYMTestActions Check for observing changes while adding,deleting events.Check for observing changes after a backup.
3713 Check for observing changes while traversing through the events in the view.
3714 Delete everything in the view and make sure we can't navigate anymore.
3715 @SYMTestExpectedResults Test must not fail
3718 LOCAL_C void TestViewChangeEvents2L(CLogClient& aClient)
3720 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0870 "));
3724 TBuf<1> description; description.SetLength(1);
3728 TLogDatabaseChangeType type;
3729 TLogId runningNewId = 0;
3731 const TInt KChangeEventTest2NumberOfEventsInView = 7;
3732 TestUtils::DeleteDatabaseL();
3734 CLogEvent* event = CLogEvent::NewL();
3735 CleanupStack::PushL(event);
3737 CLogFilter* filter = CLogFilter::NewL();
3738 CleanupStack::PushL(filter);
3739 filter->SetContact(KTestContact);
3741 CTestActive* active = new(ELeave)CTestActive();
3742 CleanupStack::PushL(active);
3744 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
3745 changeObs->SetActive();
3747 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
3748 CleanupStack::PushL(view);
3751 TBuf<KLogMaxDirectionLength> buf;
3752 aClient.GetString(buf, R_LOG_DIR_IN);
3754 event->SetEventType(KLogPacketDataEventTypeUid);
3755 event->SetDirection(buf);
3757 for(count = 0; count < KChangeEventTest2NumberOfEventsInView; count++)
3759 // Have to create one event which isn't in the view by default, but
3760 // when it 'appears' will be part way through
3761 if (count == 3 && description[0] != TUint16('Z'))
3763 description[0] = TUint16('Z');
3764 event->SetContact(0);
3766 // Go back and do this one again but with a real view entry this time, i.e. 'D'
3771 description[0] = TUint16('A' + KChangeEventTest2NumberOfEventsInView - count);
3772 event->SetContact(KTestContact);
3774 event->SetDescription(description);
3777 aClient.AddEvent(*event, active->iStatus);
3778 CActiveScheduler::Start();
3779 TEST2(active->iStatus.Int(), KErrNone);
3780 TEST2(event->Id(), runningNewId++);
3781 User::After(1 * 1000000);
3784 TEST2(view->CountL(), 0);
3786 TBool res =view->SetFilterL(*filter, active->iStatus);
3788 CActiveScheduler::Start();
3789 TEST2(active->iStatus.Int(), KErrNone);
3790 count = view->CountL();
3791 TEST2(count, KChangeEventTest2NumberOfEventsInView);
3793 res = view->FirstL(active->iStatus);
3798 CActiveScheduler::Start();
3799 TEST2(active->iStatus.Int(), KErrNone);
3800 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
3802 while(view->NextL(active->iStatus));
3804 // Check addition change events
3805 res = view->FirstL(active->iStatus);
3808 CActiveScheduler::Start();
3809 TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
3810 TEST2(view->Event().Id(), 7);
3812 // Add a new entry - should appear as the first item in the view
3813 description[0] = TUint16('X');
3814 event->SetDescription(description);
3816 changeObs->StartCollectingChanges();
3818 aClient.AddEvent(*event, active->iStatus);
3819 CActiveScheduler::Start();
3820 TEST2(active->iStatus.Int(), KErrNone);
3821 TEST2(event->Id(), runningNewId++);
3824 changeCount = changeObs->Changes().Count();
3825 TEST2(changeCount, 1);
3826 type = changeObs->Changes().At(0, logId, viewIndex);
3827 TEST2(type, ELogChangeTypeEventAdded);
3828 TEST2(logId, runningNewId-1);
3829 TEST2(viewIndex, 0); // 8, [7], 6, 5, 4, 2, 1, 0
3831 // Check we can go forward
3832 res = view->NextL(active->iStatus);
3835 CActiveScheduler::Start();
3836 TEST2(active->iStatus.Int(), KErrNone);
3837 TEST2(view->Event().Id(), TLogId(6)); // 8, 7, [6], 5, 4, 2, 1, 0
3839 // Check we can now go back (new first entry)
3840 res = view->PreviousL(active->iStatus);
3843 CActiveScheduler::Start();
3844 TEST2(active->iStatus.Int(), KErrNone); // 8, [7], 6, 5, 4, 2, 1, 0
3845 TEST2(view->Event().Id(), 7);
3846 res = view->PreviousL(active->iStatus);
3849 CActiveScheduler::Start();
3850 TEST2(active->iStatus.Int(), KErrNone); // [8], 7, 6, 5, 4, 2, 1, 0
3851 TEST2(view->Event().Id(), TLogId(KChangeEventTest2NumberOfEventsInView+1));
3853 // Delete added event
3854 changeObs->ResetChanges();
3855 changeCount = changeObs->Changes().Count();
3856 TEST2(changeCount, 0);
3858 aClient.DeleteEvent(view->Event().Id(), active->iStatus);
3859 CActiveScheduler::Start();
3860 TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
3862 // Check deletion changes
3863 changeCount = changeObs->Changes().Count();
3864 TEST2(changeCount, 1);
3865 type = changeObs->Changes().At(0, logId, viewIndex);
3866 TEST2(type, ELogChangeTypeEventDeleted);
3867 TEST2(logId, runningNewId-1);
3868 TEST2(viewIndex, 0);
3870 // Go to end of view
3871 res = view->LastL(active->iStatus);
3874 CActiveScheduler::Start();
3875 TEST2(active->iStatus.Int(), KErrNone);
3876 TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0]
3879 description[0] = TUint16('X');
3880 event->SetDescription(description);
3882 changeObs->StartCollectingChanges();
3884 aClient.AddEvent(*event, active->iStatus);
3885 CActiveScheduler::Start();
3886 TEST2(active->iStatus.Int(), KErrNone);
3887 TEST2(event->Id(), runningNewId++);
3890 changeCount = changeObs->Changes().Count();
3891 TEST2(changeCount, 1);
3892 type = changeObs->Changes().At(0, logId, viewIndex);
3893 TEST2(type, ELogChangeTypeEventAdded);
3894 TEST2(logId, runningNewId-1);
3895 TEST2(viewIndex, 0); // 9, 7, 6, 5, 4, 2, 1, [0]
3897 // Check we can't go forward
3898 res = view->NextL(active->iStatus);
3901 // Go back to the first record
3902 res = view->FirstL(active->iStatus);
3905 CActiveScheduler::Start();
3906 TEST2(active->iStatus.Int(), KErrNone);
3907 TEST2(view->Event().Id(), TLogId(runningNewId-1)); // 9, 7, 6, 5, 4, 2, 1, [0]
3909 // Delete added event
3910 changeObs->ResetChanges();
3912 aClient.DeleteEvent(view->Event().Id(), active->iStatus);
3913 CActiveScheduler::Start();
3914 TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
3916 // Check deletion changes
3917 changeCount = changeObs->Changes().Count();
3918 TEST2(changeCount, 1);
3919 type = changeObs->Changes().At(0, logId, viewIndex);
3920 TEST2(type, ELogChangeTypeEventDeleted);
3921 TEST2(logId, runningNewId-1);
3922 TEST2(viewIndex, 0);
3924 // Go part way through view
3925 res = view->NextL(active->iStatus);
3928 CActiveScheduler::Start();
3929 TEST2(active->iStatus.Int(), KErrNone);
3930 TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0
3931 res = view->NextL(active->iStatus);
3934 CActiveScheduler::Start();
3935 TEST2(active->iStatus.Int(), KErrNone);
3936 TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 2, 1, 0
3939 description[0] = TUint16('X');
3940 event->SetDescription(description);
3942 changeObs->StartCollectingChanges();
3944 aClient.AddEvent(*event, active->iStatus);
3945 CActiveScheduler::Start();
3946 TEST2(active->iStatus.Int(), KErrNone);
3947 TEST2(event->Id(), runningNewId++);
3950 changeCount = changeObs->Changes().Count();
3951 TEST2(changeCount, 1);
3952 type = changeObs->Changes().At(0, logId, viewIndex);
3953 TEST2(type, ELogChangeTypeEventAdded);
3954 TEST2(logId, runningNewId-1);
3955 TEST2(viewIndex, 0); // 10, 7, 6, [5], 4, 2, 1, 0
3956 changeObs->ResetChanges();
3958 // Work back to beginning
3959 res = view->PreviousL(active->iStatus);
3962 CActiveScheduler::Start();
3963 TEST2(active->iStatus.Int(), KErrNone);
3964 TEST2(view->Event().Id(), TLogId(6)); // 10, 7, [6], 5, 4, 2, 1, 0
3965 res = view->PreviousL(active->iStatus);
3968 CActiveScheduler::Start();
3969 TEST2(active->iStatus.Int(), KErrNone);
3970 TEST2(view->Event().Id(), TLogId(7)); // 10, [7], 6, 5, 4, 2, 1, 0
3971 res = view->PreviousL(active->iStatus);
3974 CActiveScheduler::Start();
3975 TEST2(active->iStatus.Int(), KErrNone);
3976 TEST2(view->Event().Id(), runningNewId-1); // [10], 7, 6, 5, 4, 2, 1, 0
3978 // Delete added event
3979 changeCount = changeObs->Changes().Count();
3980 TEST2(changeCount, 0);
3982 aClient.DeleteEvent(view->Event().Id(), active->iStatus);
3983 CActiveScheduler::Start();
3984 TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
3986 // Check deletion changes
3987 changeCount = changeObs->Changes().Count();
3988 TEST2(changeCount, 1);
3989 type = changeObs->Changes().At(0, logId, viewIndex);
3990 TEST2(type, ELogChangeTypeEventDeleted);
3991 TEST2(logId, runningNewId-1);
3992 TEST2(viewIndex, 0);
3993 changeObs->ResetChanges();
3995 // Go back to the first record
3996 res = view->FirstL(active->iStatus);
3999 CActiveScheduler::Start();
4000 TEST2(active->iStatus.Int(), KErrNone);
4001 TEST2(view->Event().Id(), TLogId(7)); // [7], 6, 5, 4, 2, 1, 0
4003 // Move one record forward
4004 res = view->NextL(active->iStatus);
4007 CActiveScheduler::Start();
4008 TEST2(active->iStatus.Int(), KErrNone);
4009 TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0
4011 // Change 'Z' event so that it now appears in the view
4012 changeCount = changeObs->Changes().Count();
4013 TEST2(changeCount, 0);
4015 event->SetId(TLogId(3));
4016 aClient.GetEvent(*event, active->iStatus);
4017 CActiveScheduler::Start();
4018 TEST2(active->iStatus.Int(), KErrNone);
4020 event->SetContact(KTestContact);
4022 changeObs->StartCollectingChanges();
4023 aClient.ChangeEvent(*event, active->iStatus);
4024 CActiveScheduler::Start();
4025 TEST2(active->iStatus.Int(), KErrNone);
4026 count = view->CountL();
4027 TEST2(count, KChangeEventTest2NumberOfEventsInView+1);
4030 changeCount = changeObs->Changes().Count();
4031 TEST2(changeCount, 1);
4032 type = changeObs->Changes().At(0, logId, viewIndex);
4033 TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view
4034 TEST2(logId, TLogId(3));
4035 TEST2(viewIndex, 4); // 7, [6], 5, 4, 3, 2, 1, 0
4036 changeObs->ResetChanges();
4038 // Move forwards and check
4039 res = view->NextL(active->iStatus);
4042 CActiveScheduler::Start();
4043 TEST2(active->iStatus.Int(), KErrNone);
4044 TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 3, 2, 1, 0
4045 res = view->NextL(active->iStatus);
4048 CActiveScheduler::Start();
4049 TEST2(active->iStatus.Int(), KErrNone);
4050 TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0
4051 res = view->NextL(active->iStatus);
4054 CActiveScheduler::Start();
4055 TEST2(active->iStatus.Int(), KErrNone);
4056 TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0
4058 // Change 'Z' event so that its now missing from the view again
4059 changeCount = changeObs->Changes().Count();
4060 TEST2(changeCount, 0);
4062 event->SetId(TLogId(3));
4063 aClient.GetEvent(*event, active->iStatus);
4064 CActiveScheduler::Start();
4065 TEST2(active->iStatus.Int(), KErrNone);
4067 event->SetContact(0);
4069 changeObs->StartCollectingChanges();
4070 aClient.ChangeEvent(*event, active->iStatus);
4071 CActiveScheduler::Start();
4072 TEST2(active->iStatus.Int(), KErrNone);
4073 count = view->CountL();
4074 TEST2(count, KChangeEventTest2NumberOfEventsInView);
4077 changeCount = changeObs->Changes().Count();
4078 TEST2(changeCount, 1);
4079 type = changeObs->Changes().At(0, logId, viewIndex);
4080 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4081 TEST2(logId, TLogId(3));
4082 TEST2(viewIndex, 4); // 7, 6, 5, 4, [2], 1, 0
4083 changeObs->ResetChanges();
4085 // Move forwards and check
4086 res = view->NextL(active->iStatus);
4089 CActiveScheduler::Start();
4090 TEST2(active->iStatus.Int(), KErrNone);
4091 TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0
4092 res = view->NextL(active->iStatus);
4095 CActiveScheduler::Start();
4096 TEST2(active->iStatus.Int(), KErrNone);
4097 TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0]
4100 res = view->PreviousL(active->iStatus);
4103 CActiveScheduler::Start();
4104 TEST2(active->iStatus.Int(), KErrNone);
4105 TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0
4106 changeCount = changeObs->Changes().Count();
4107 TEST2(changeCount, 0);
4109 // Change 'Z' event so that it now appears in the view
4111 event->SetId(TLogId(3));
4112 aClient.GetEvent(*event, active->iStatus);
4113 CActiveScheduler::Start();
4114 TEST2(active->iStatus.Int(), KErrNone);
4116 event->SetContact(KTestContact);
4118 changeObs->StartCollectingChanges();
4119 aClient.ChangeEvent(*event, active->iStatus);
4120 CActiveScheduler::Start();
4121 TEST2(active->iStatus.Int(), KErrNone);
4122 count = view->CountL();
4123 TEST2(count, KChangeEventTest2NumberOfEventsInView+1);
4126 changeCount = changeObs->Changes().Count();
4127 TEST2(changeCount, 1);
4128 type = changeObs->Changes().At(0, logId, viewIndex);
4129 TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view
4130 TEST2(logId, TLogId(3));
4131 TEST2(viewIndex, 4); // 7, 6, 5, 4, 3, 2, [1], 0
4132 changeObs->ResetChanges();
4134 // Check can only move forward one more record
4135 res = view->NextL(active->iStatus);
4138 CActiveScheduler::Start();
4139 TEST2(active->iStatus.Int(), KErrNone);
4140 TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 3, 2, 1, [0]
4142 // Move back until we are before the inserted record
4143 res = view->PreviousL(active->iStatus);
4146 CActiveScheduler::Start();
4147 TEST2(active->iStatus.Int(), KErrNone);
4148 TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 3, 2, [1], 0
4149 res = view->PreviousL(active->iStatus);
4152 CActiveScheduler::Start();
4153 TEST2(active->iStatus.Int(), KErrNone);
4154 TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, 3, [2], 1, 0
4155 res = view->PreviousL(active->iStatus);
4158 CActiveScheduler::Start();
4159 TEST2(active->iStatus.Int(), KErrNone);
4160 TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0
4161 res = view->PreviousL(active->iStatus);
4164 CActiveScheduler::Start();
4165 TEST2(active->iStatus.Int(), KErrNone);
4166 TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0
4167 changeCount = changeObs->Changes().Count();
4168 TEST2(changeCount, 0);
4170 // Change 'Z' event so that its now missing from the view again
4172 event->SetId(TLogId(3));
4173 aClient.GetEvent(*event, active->iStatus);
4174 CActiveScheduler::Start();
4175 TEST2(active->iStatus.Int(), KErrNone);
4177 event->SetContact(0);
4179 changeObs->StartCollectingChanges();
4180 aClient.ChangeEvent(*event, active->iStatus);
4181 CActiveScheduler::Start();
4182 TEST2(active->iStatus.Int(), KErrNone);
4183 count = view->CountL();
4184 TEST2(count, KChangeEventTest2NumberOfEventsInView);
4187 changeCount = changeObs->Changes().Count();
4188 TEST2(changeCount, 1);
4189 type = changeObs->Changes().At(0, logId, viewIndex);
4190 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4191 TEST2(logId, TLogId(3));
4192 TEST2(viewIndex, 4); // 7, 6, 5, [4], 2, 1, 0
4193 changeObs->ResetChanges();
4195 // Check navigating to the end of the view
4196 res = view->NextL(active->iStatus);
4199 CActiveScheduler::Start();
4200 TEST2(active->iStatus.Int(), KErrNone);
4201 TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, [2], 1, 0
4202 res = view->NextL(active->iStatus);
4205 CActiveScheduler::Start();
4206 TEST2(active->iStatus.Int(), KErrNone);
4207 TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0
4208 res = view->NextL(active->iStatus);
4211 CActiveScheduler::Start();
4212 TEST2(active->iStatus.Int(), KErrNone);
4213 TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0]
4214 changeCount = changeObs->Changes().Count();
4215 TEST2(changeCount, 0);
4216 res = view->NextL(active->iStatus);
4219 // Delete everything in the view and make sure we can't navigate anymore.
4221 aClient.DeleteEvent(TLogId(4), active->iStatus);
4222 CActiveScheduler::Start();
4223 TEST2(active->iStatus.Int(), KErrNone);
4224 count = view->CountL();
4225 TEST2(count, KChangeEventTest2NumberOfEventsInView - 1);
4226 changeCount = changeObs->Changes().Count();
4227 TEST2(changeCount, 1);
4228 type = changeObs->Changes().At(0, logId, viewIndex);
4229 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4230 TEST2(logId, TLogId(4));
4231 TEST2(viewIndex, 3); // 7, 6, 5, 2, 1, [0]
4232 changeObs->ResetChanges();
4235 aClient.DeleteEvent(TLogId(7), active->iStatus);
4236 CActiveScheduler::Start();
4237 TEST2(active->iStatus.Int(), KErrNone);
4238 count = view->CountL();
4239 TEST2(count, KChangeEventTest2NumberOfEventsInView - 2);
4240 changeCount = changeObs->Changes().Count();
4241 TEST2(changeCount, 1);
4242 type = changeObs->Changes().At(0, logId, viewIndex);
4243 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4244 TEST2(logId, TLogId(7));
4245 TEST2(viewIndex, 0); // 6, 5, 2, 1, [0]
4246 changeObs->ResetChanges();
4249 aClient.DeleteEvent(TLogId(0), active->iStatus);
4250 CActiveScheduler::Start();
4251 TEST2(active->iStatus.Int(), KErrNone);
4252 count = view->CountL();
4253 TEST2(count, KChangeEventTest2NumberOfEventsInView - 3);
4254 changeCount = changeObs->Changes().Count();
4255 TEST2(changeCount, 1);
4256 type = changeObs->Changes().At(0, logId, viewIndex);
4257 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4258 TEST2(logId, TLogId(0));
4259 TEST2(viewIndex, 4); // 6, 5, 2, [1]
4260 changeObs->ResetChanges();
4263 aClient.DeleteEvent(TLogId(5), active->iStatus);
4264 CActiveScheduler::Start();
4265 TEST2(active->iStatus.Int(), KErrNone);
4266 count = view->CountL();
4267 TEST2(count, KChangeEventTest2NumberOfEventsInView - 4);
4268 changeCount = changeObs->Changes().Count();
4269 TEST2(changeCount, 1);
4270 type = changeObs->Changes().At(0, logId, viewIndex);
4271 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4272 TEST2(logId, TLogId(5));
4273 TEST2(viewIndex, 1); // 6, 2, [1]
4274 changeObs->ResetChanges();
4277 aClient.DeleteEvent(TLogId(2), active->iStatus);
4278 CActiveScheduler::Start();
4279 TEST2(active->iStatus.Int(), KErrNone);
4280 count = view->CountL();
4281 TEST2(count, KChangeEventTest2NumberOfEventsInView - 5);
4282 changeCount = changeObs->Changes().Count();
4283 TEST2(changeCount, 1);
4284 type = changeObs->Changes().At(0, logId, viewIndex);
4285 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4286 TEST2(logId, TLogId(2));
4287 TEST2(viewIndex, 1); // 6, [1]
4288 changeObs->ResetChanges();
4291 aClient.DeleteEvent(TLogId(6), active->iStatus);
4292 CActiveScheduler::Start();
4293 TEST2(active->iStatus.Int(), KErrNone);
4294 count = view->CountL();
4295 TEST2(count, KChangeEventTest2NumberOfEventsInView - 6);
4296 changeCount = changeObs->Changes().Count();
4297 TEST2(changeCount, 1);
4298 type = changeObs->Changes().At(0, logId, viewIndex);
4299 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4300 TEST2(logId, TLogId(6));
4301 TEST2(viewIndex, 0); // [1]
4302 changeObs->ResetChanges();
4304 // Check we can't go backwards or forwards
4305 res = view->NextL(active->iStatus);
4307 res = view->PreviousL(active->iStatus);
4309 res = view->FirstL(active->iStatus);
4312 CActiveScheduler::Start();
4313 TEST2(active->iStatus.Int(), KErrNone);
4314 TEST2(view->Event().Id(), TLogId(1)); // [1]
4315 res = view->LastL(active->iStatus);
4318 CActiveScheduler::Start();
4319 TEST2(active->iStatus.Int(), KErrNone);
4320 TEST2(view->Event().Id(), TLogId(1)); // [1]
4322 // Delete last event in view
4324 aClient.DeleteEvent(TLogId(1), active->iStatus);
4325 CActiveScheduler::Start();
4326 TEST2(active->iStatus.Int(), KErrNone);
4327 count = view->CountL();
4328 TEST2(count, KChangeEventTest2NumberOfEventsInView - 7);
4329 changeCount = changeObs->Changes().Count();
4330 TEST2(changeCount, 1);
4331 type = changeObs->Changes().At(0, logId, viewIndex);
4332 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4333 TEST2(logId, TLogId(1));
4334 TEST2(viewIndex, 0); // *Empty*
4335 changeObs->ResetChanges();
4337 // Check we can't navigate
4338 res = view->NextL(active->iStatus);
4340 res = view->PreviousL(active->iStatus);
4342 res = view->FirstL(active->iStatus);
4344 res = view->LastL(active->iStatus);
4347 CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event
4351 @SYMTestCaseID SYSLIB-LOGENG-CT-0871
4352 @SYMTestCaseDesc Tests for CLogViewChangeObserver::HaveChanges(),Changes() functions
4353 @SYMTestPriority High
4354 @SYMTestActions Check for observing changes while adding,deleting events.Check for observing changes after a backup.
4355 Check for observing changes while traversing through the events in the view.
4356 Delete everything in the view and make sure we can't navigate anymore.
4357 @SYMTestExpectedResults Test must not fail
4360 LOCAL_C void TestViewChangeEvents2aL(CLogClient& aClient)
4362 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0871 "));
4366 TBuf<1> description; description.SetLength(1);
4370 TLogDatabaseChangeType type;
4371 TLogId runningNewId = 0;
4373 const TInt KChangeEventTest2NumberOfEventsInView = 7;
4374 TestUtils::DeleteDatabaseL();
4376 CLogEvent* event = CLogEvent::NewL();
4377 CleanupStack::PushL(event);
4379 CLogFilter* filter = CLogFilter::NewL();
4380 CleanupStack::PushL(filter);
4381 filter->SetContact(KTestContact);
4383 CTestActive* active = new(ELeave)CTestActive();
4384 CleanupStack::PushL(active);
4386 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
4387 changeObs->SetActive();
4389 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
4390 CleanupStack::PushL(view);
4393 TBuf<KLogMaxDirectionLength> buf;
4394 aClient.GetString(buf, R_LOG_DIR_IN);
4396 event->SetEventType(KLogPacketDataEventTypeUid);
4397 event->SetDirection(buf);
4399 for(count = 0; count < KChangeEventTest2NumberOfEventsInView; count++)
4401 // Have to create one event which isn't in the view by default, but
4402 // when it 'appears' will be part way through
4403 if (count == 3 && description[0] != TUint16('Z'))
4405 description[0] = TUint16('Z');
4406 event->SetContact(0);
4408 // Go back and do this one again but with a real view entry this time, i.e. 'D'
4413 description[0] = TUint16('A' + KChangeEventTest2NumberOfEventsInView - count);
4414 event->SetContact(KTestContact);
4416 event->SetDescription(description);
4419 aClient.AddEvent(*event, active->iStatus);
4420 CActiveScheduler::Start();
4421 TEST2(active->iStatus.Int(), KErrNone);
4422 TEST2(event->Id(), runningNewId++);
4423 User::After(1 * 1000000);
4426 TEST2(view->CountL(), 0);
4428 TEST(view->SetFilterL(*filter, active->iStatus));
4429 CActiveScheduler::Start();
4430 TEST2(active->iStatus.Int(), KErrNone);
4431 count = view->CountL();
4432 TEST2(count, KChangeEventTest2NumberOfEventsInView);
4435 TEST(view->FirstL(active->iStatus));
4439 CActiveScheduler::Start();
4440 TEST2(active->iStatus.Int(), KErrNone);
4441 TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
4443 while(view->NextL(active->iStatus));
4445 // Check addition change events
4446 TEST(view->FirstL(active->iStatus));
4448 CActiveScheduler::Start();
4449 TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
4450 TEST2(view->Event().Id(), 7);
4452 // Add a new entry - should appear as the first item in the view
4453 description[0] = TUint16('X');
4454 event->SetDescription(description);
4456 // Check that changes work after a backup
4464 changeObs->StartCollectingChanges();
4466 aClient.AddEvent(*event, active->iStatus);
4467 CActiveScheduler::Start();
4468 TEST2(active->iStatus.Int(), KErrNone);
4469 TEST2(event->Id(), runningNewId++);
4472 changeCount = changeObs->Changes().Count();
4473 TEST2(changeCount, 1);
4474 type = changeObs->Changes().At(0, logId, viewIndex);
4475 TEST2(type, ELogChangeTypeEventAdded);
4476 TEST2(logId, runningNewId-1);
4477 TEST2(viewIndex, 0); // 8, [7], 6, 5, 4, 2, 1, 0
4479 // Check we can go forward
4480 TEST(view->NextL(active->iStatus));
4482 CActiveScheduler::Start();
4483 TEST2(active->iStatus.Int(), KErrNone);
4484 TEST2(view->Event().Id(), TLogId(6)); // 8, 7, [6], 5, 4, 2, 1, 0
4486 // Check we can now go back (new first entry)
4487 TEST(view->PreviousL(active->iStatus));
4489 CActiveScheduler::Start();
4490 TEST2(active->iStatus.Int(), KErrNone); // 8, [7], 6, 5, 4, 2, 1, 0
4491 TEST2(view->Event().Id(), 7);
4492 TEST(view->PreviousL(active->iStatus));
4494 CActiveScheduler::Start();
4495 TEST2(active->iStatus.Int(), KErrNone); // [8], 7, 6, 5, 4, 2, 1, 0
4496 TEST2(view->Event().Id(), TLogId(KChangeEventTest2NumberOfEventsInView+1));
4498 // Delete added event
4499 changeObs->ResetChanges();
4500 changeCount = changeObs->Changes().Count();
4501 TEST2(changeCount, 0);
4503 aClient.DeleteEvent(view->Event().Id(), active->iStatus);
4504 CActiveScheduler::Start();
4505 TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
4507 // Check deletion changes
4508 changeCount = changeObs->Changes().Count();
4509 TEST2(changeCount, 1);
4510 type = changeObs->Changes().At(0, logId, viewIndex);
4511 TEST2(type, ELogChangeTypeEventDeleted);
4512 TEST2(logId, runningNewId-1);
4513 TEST2(viewIndex, 0);
4515 // Go to end of view
4516 TEST(view->LastL(active->iStatus));
4518 CActiveScheduler::Start();
4519 TEST2(active->iStatus.Int(), KErrNone);
4520 TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0]
4523 description[0] = TUint16('X');
4524 event->SetDescription(description);
4526 // Check that changes work after a backup
4534 changeObs->StartCollectingChanges();
4536 aClient.AddEvent(*event, active->iStatus);
4537 CActiveScheduler::Start();
4538 TEST2(active->iStatus.Int(), KErrNone);
4539 TEST2(event->Id(), runningNewId++);
4542 changeCount = changeObs->Changes().Count();
4543 TEST2(changeCount, 1);
4544 type = changeObs->Changes().At(0, logId, viewIndex);
4545 TEST2(type, ELogChangeTypeEventAdded);
4546 TEST2(logId, runningNewId-1);
4547 TEST2(viewIndex, 0); // 9, 7, 6, 5, 4, 2, 1, [0]
4549 // Check we can't go forward
4550 TEST(!view->NextL(active->iStatus));
4552 // Go back to the first record
4553 TEST(view->FirstL(active->iStatus));
4555 CActiveScheduler::Start();
4556 TEST2(active->iStatus.Int(), KErrNone);
4557 TEST2(view->Event().Id(), TLogId(runningNewId-1)); // 9, 7, 6, 5, 4, 2, 1, [0]
4559 // Delete added event
4560 changeObs->ResetChanges();
4562 aClient.DeleteEvent(view->Event().Id(), active->iStatus);
4563 CActiveScheduler::Start();
4564 TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
4566 // Check deletion changes
4567 changeCount = changeObs->Changes().Count();
4568 TEST2(changeCount, 1);
4569 type = changeObs->Changes().At(0, logId, viewIndex);
4570 TEST2(type, ELogChangeTypeEventDeleted);
4571 TEST2(logId, runningNewId-1);
4572 TEST2(viewIndex, 0);
4574 // Go part way through view
4575 TEST(view->NextL(active->iStatus));
4577 CActiveScheduler::Start();
4578 TEST2(active->iStatus.Int(), KErrNone);
4579 TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0
4580 TEST(view->NextL(active->iStatus));
4582 CActiveScheduler::Start();
4583 TEST2(active->iStatus.Int(), KErrNone);
4584 TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 2, 1, 0
4587 description[0] = TUint16('X');
4588 event->SetDescription(description);
4590 // Check that changes work after a backup
4598 changeObs->StartCollectingChanges();
4600 aClient.AddEvent(*event, active->iStatus);
4601 CActiveScheduler::Start();
4602 TEST2(active->iStatus.Int(), KErrNone);
4603 TEST2(event->Id(), runningNewId++);
4606 changeCount = changeObs->Changes().Count();
4607 TEST2(changeCount, 1);
4608 type = changeObs->Changes().At(0, logId, viewIndex);
4609 TEST2(type, ELogChangeTypeEventAdded);
4610 TEST2(logId, runningNewId-1);
4611 TEST2(viewIndex, 0); // 10, 7, 6, [5], 4, 2, 1, 0
4612 changeObs->ResetChanges();
4614 // Work back to beginning
4615 TEST(view->PreviousL(active->iStatus));
4617 CActiveScheduler::Start();
4618 TEST2(active->iStatus.Int(), KErrNone);
4619 TEST2(view->Event().Id(), TLogId(6)); // 10, 7, [6], 5, 4, 2, 1, 0
4620 TEST(view->PreviousL(active->iStatus));
4622 CActiveScheduler::Start();
4623 TEST2(active->iStatus.Int(), KErrNone);
4624 TEST2(view->Event().Id(), TLogId(7)); // 10, [7], 6, 5, 4, 2, 1, 0
4625 TEST(view->PreviousL(active->iStatus));
4627 CActiveScheduler::Start();
4628 TEST2(active->iStatus.Int(), KErrNone);
4629 TEST2(view->Event().Id(), runningNewId-1); // [10], 7, 6, 5, 4, 2, 1, 0
4631 // Delete added event
4632 changeCount = changeObs->Changes().Count();
4633 TEST2(changeCount, 0);
4635 aClient.DeleteEvent(view->Event().Id(), active->iStatus);
4636 CActiveScheduler::Start();
4637 TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
4639 // Check deletion changes
4640 changeCount = changeObs->Changes().Count();
4641 TEST2(changeCount, 1);
4642 type = changeObs->Changes().At(0, logId, viewIndex);
4643 TEST2(type, ELogChangeTypeEventDeleted);
4644 TEST2(logId, runningNewId-1);
4645 TEST2(viewIndex, 0);
4646 changeObs->ResetChanges();
4648 // Go back to the first record
4649 TEST(view->FirstL(active->iStatus));
4651 CActiveScheduler::Start();
4652 TEST2(active->iStatus.Int(), KErrNone);
4653 TEST2(view->Event().Id(), TLogId(7)); // [7], 6, 5, 4, 2, 1, 0
4655 // Move one record forward
4656 TEST(view->NextL(active->iStatus));
4658 CActiveScheduler::Start();
4659 TEST2(active->iStatus.Int(), KErrNone);
4660 TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0
4662 // Change 'Z' event so that it now appears in the view
4663 changeCount = changeObs->Changes().Count();
4664 TEST2(changeCount ,0);
4666 event->SetId(TLogId(3));
4667 aClient.GetEvent(*event, active->iStatus);
4668 CActiveScheduler::Start();
4669 TEST2(active->iStatus.Int(), KErrNone);
4671 event->SetContact(KTestContact);
4674 // Check that changes work after a backup
4681 changeObs->StartCollectingChanges();
4682 aClient.ChangeEvent(*event, active->iStatus);
4683 CActiveScheduler::Start();
4684 TEST2(active->iStatus.Int(), KErrNone);
4685 count = view->CountL();
4686 TEST2(count, KChangeEventTest2NumberOfEventsInView+1);
4689 changeCount = changeObs->Changes().Count();
4690 TEST2(changeCount, 1);
4691 type = changeObs->Changes().At(0, logId, viewIndex);
4692 TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view
4693 TEST2(logId, TLogId(3));
4694 TEST2(viewIndex, 4); // 7, [6], 5, 4, 3, 2, 1, 0
4695 changeObs->ResetChanges();
4697 // Move forwards and check
4698 TEST(view->NextL(active->iStatus));
4700 CActiveScheduler::Start();
4701 TEST2(active->iStatus.Int(), KErrNone);
4702 TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 3, 2, 1, 0
4703 TEST(view->NextL(active->iStatus));
4705 CActiveScheduler::Start();
4706 TEST2(active->iStatus.Int(), KErrNone);
4707 TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0
4708 TEST(view->NextL(active->iStatus));
4710 CActiveScheduler::Start();
4711 TEST2(active->iStatus.Int(), KErrNone);
4712 TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0
4714 // Change 'Z' event so that its now missing from the view again
4715 changeCount = changeObs->Changes().Count();
4716 TEST2(changeCount ,0);
4718 event->SetId(TLogId(3));
4719 aClient.GetEvent(*event, active->iStatus);
4720 CActiveScheduler::Start();
4721 TEST2(active->iStatus.Int(), KErrNone);
4723 event->SetContact(0);
4726 // Check that changes work after a backup
4733 changeObs->StartCollectingChanges();
4734 aClient.ChangeEvent(*event, active->iStatus);
4735 CActiveScheduler::Start();
4736 TEST2(active->iStatus.Int(), KErrNone);
4737 count = view->CountL();
4738 TEST2(count, KChangeEventTest2NumberOfEventsInView);
4741 changeCount = changeObs->Changes().Count();
4742 TEST2(changeCount, 1);
4743 type = changeObs->Changes().At(0, logId, viewIndex);
4744 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4745 TEST2(logId, TLogId(3));
4746 TEST2(viewIndex, 4); // 7, 6, 5, 4, [2], 1, 0
4747 changeObs->ResetChanges();
4749 // Move forwards and check
4750 TEST(view->NextL(active->iStatus));
4752 CActiveScheduler::Start();
4753 TEST2(active->iStatus.Int(), KErrNone);
4754 TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0
4755 TEST(view->NextL(active->iStatus));
4757 CActiveScheduler::Start();
4758 TEST2(active->iStatus.Int(), KErrNone);
4759 TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0]
4762 TEST(view->PreviousL(active->iStatus));
4764 CActiveScheduler::Start();
4765 TEST2(active->iStatus.Int(), KErrNone);
4766 TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0
4767 changeCount = changeObs->Changes().Count();
4768 TEST2(changeCount ,0);
4770 // Change 'Z' event so that it now appears in the view
4772 event->SetId(TLogId(3));
4773 aClient.GetEvent(*event, active->iStatus);
4774 CActiveScheduler::Start();
4775 TEST2(active->iStatus.Int(), KErrNone);
4777 event->SetContact(KTestContact);
4780 // Check that changes work after a backup
4787 changeObs->StartCollectingChanges();
4788 aClient.ChangeEvent(*event, active->iStatus);
4789 CActiveScheduler::Start();
4790 TEST2(active->iStatus.Int(), KErrNone);
4791 count = view->CountL();
4792 TEST2(count, KChangeEventTest2NumberOfEventsInView+1);
4795 changeCount = changeObs->Changes().Count();
4796 TEST2(changeCount, 1);
4797 type = changeObs->Changes().At(0, logId, viewIndex);
4798 TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view
4799 TEST2(logId, TLogId(3));
4800 TEST2(viewIndex, 4); // 7, 6, 5, 4, 3, 2, [1], 0
4801 changeObs->ResetChanges();
4803 // Check can only move forward one more record
4804 TEST(view->NextL(active->iStatus));
4806 CActiveScheduler::Start();
4807 TEST2(active->iStatus.Int(), KErrNone);
4808 TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 3, 2, 1, [0]
4810 // Move back until we are before the inserted record
4811 TEST(view->PreviousL(active->iStatus));
4813 CActiveScheduler::Start();
4814 TEST2(active->iStatus.Int(), KErrNone);
4815 TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 3, 2, [1], 0
4816 TEST(view->PreviousL(active->iStatus));
4818 CActiveScheduler::Start();
4819 TEST2(active->iStatus.Int(), KErrNone);
4820 TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, 3, [2], 1, 0
4821 TEST(view->PreviousL(active->iStatus));
4823 CActiveScheduler::Start();
4824 TEST2(active->iStatus.Int(), KErrNone);
4825 TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0
4826 TEST(view->PreviousL(active->iStatus));
4828 CActiveScheduler::Start();
4829 TEST2(active->iStatus.Int(), KErrNone);
4830 TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0
4831 changeCount = changeObs->Changes().Count();
4832 TEST2(changeCount ,0);
4834 // Change 'Z' event so that its now missing from the view again
4836 event->SetId(TLogId(3));
4837 aClient.GetEvent(*event, active->iStatus);
4838 CActiveScheduler::Start();
4839 TEST2(active->iStatus.Int(), KErrNone);
4841 event->SetContact(0);
4844 // Check that changes work after a backup
4851 changeObs->StartCollectingChanges();
4852 aClient.ChangeEvent(*event, active->iStatus);
4853 CActiveScheduler::Start();
4854 TEST2(active->iStatus.Int(), KErrNone);
4855 count = view->CountL();
4856 TEST2(count, KChangeEventTest2NumberOfEventsInView);
4859 changeCount = changeObs->Changes().Count();
4860 TEST2(changeCount, 1);
4861 type = changeObs->Changes().At(0, logId, viewIndex);
4862 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4863 TEST2(logId, TLogId(3));
4864 TEST2(viewIndex, 4); // 7, 6, 5, [4], 2, 1, 0
4865 changeObs->ResetChanges();
4867 // Check navigating to the end of the view
4868 TEST(view->NextL(active->iStatus));
4870 CActiveScheduler::Start();
4871 TEST2(active->iStatus.Int(), KErrNone);
4872 TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, [2], 1, 0
4873 TEST(view->NextL(active->iStatus));
4875 CActiveScheduler::Start();
4876 TEST2(active->iStatus.Int(), KErrNone);
4877 TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0
4878 TEST(view->NextL(active->iStatus));
4880 CActiveScheduler::Start();
4881 TEST2(active->iStatus.Int(), KErrNone);
4882 TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0]
4883 changeCount = changeObs->Changes().Count();
4884 TEST2(changeCount ,0);
4885 TEST(!view->NextL(active->iStatus));
4887 // Delete everything in the view and make sure we can't navigate anymore.
4889 aClient.DeleteEvent(TLogId(4), active->iStatus);
4890 CActiveScheduler::Start();
4891 TEST2(active->iStatus.Int(), KErrNone);
4892 count = view->CountL();
4893 TEST2(count, KChangeEventTest2NumberOfEventsInView - 1);
4894 changeCount = changeObs->Changes().Count();
4895 TEST2(changeCount, 1);
4896 type = changeObs->Changes().At(0, logId, viewIndex);
4897 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4898 TEST2(logId, TLogId(4));
4899 TEST2(viewIndex, 3); // 7, 6, 5, 2, 1, [0]
4900 changeObs->ResetChanges();
4903 aClient.DeleteEvent(TLogId(7), active->iStatus);
4904 CActiveScheduler::Start();
4905 TEST2(active->iStatus.Int(), KErrNone);
4906 count = view->CountL();
4907 TEST2(count, KChangeEventTest2NumberOfEventsInView - 2);
4908 changeCount = changeObs->Changes().Count();
4909 TEST2(changeCount, 1);
4910 type = changeObs->Changes().At(0, logId, viewIndex);
4911 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4912 TEST2(logId, TLogId(7));
4913 TEST2(viewIndex, 0); // 6, 5, 2, 1, [0]
4914 changeObs->ResetChanges();
4917 aClient.DeleteEvent(TLogId(0), active->iStatus);
4918 CActiveScheduler::Start();
4919 TEST2(active->iStatus.Int(), KErrNone);
4920 count = view->CountL();
4921 TEST2(count, KChangeEventTest2NumberOfEventsInView - 3);
4922 changeCount = changeObs->Changes().Count();
4923 TEST2(changeCount, 1);
4924 type = changeObs->Changes().At(0, logId, viewIndex);
4925 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4926 TEST2(logId, TLogId(0));
4927 TEST2(viewIndex, 4); // 6, 5, 2, [1]
4928 changeObs->ResetChanges();
4931 aClient.DeleteEvent(TLogId(5), active->iStatus);
4932 CActiveScheduler::Start();
4933 TEST2(active->iStatus.Int(), KErrNone);
4934 count = view->CountL();
4935 TEST2(count, KChangeEventTest2NumberOfEventsInView - 4);
4936 changeCount = changeObs->Changes().Count();
4937 TEST2(changeCount, 1);
4938 type = changeObs->Changes().At(0, logId, viewIndex);
4939 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4940 TEST2(logId, TLogId(5));
4941 TEST2(viewIndex, 1); // 6, 2, [1]
4942 changeObs->ResetChanges();
4945 aClient.DeleteEvent(TLogId(2), active->iStatus);
4946 CActiveScheduler::Start();
4947 TEST2(active->iStatus.Int(), KErrNone);
4948 count = view->CountL();
4949 TEST2(count, KChangeEventTest2NumberOfEventsInView - 5);
4950 changeCount = changeObs->Changes().Count();
4951 TEST2(changeCount, 1);
4952 type = changeObs->Changes().At(0, logId, viewIndex);
4953 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4954 TEST2(logId, TLogId(2));
4955 TEST2(viewIndex, 1); // 6, [1]
4956 changeObs->ResetChanges();
4959 aClient.DeleteEvent(TLogId(6), active->iStatus);
4960 CActiveScheduler::Start();
4961 TEST2(active->iStatus.Int(), KErrNone);
4962 count = view->CountL();
4963 TEST2(count, KChangeEventTest2NumberOfEventsInView - 6);
4964 changeCount = changeObs->Changes().Count();
4965 TEST2(changeCount, 1);
4966 type = changeObs->Changes().At(0, logId, viewIndex);
4967 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4968 TEST2(logId, TLogId(6));
4969 TEST2(viewIndex, 0); // [1]
4970 changeObs->ResetChanges();
4972 // Check we can't go backwards or forwards
4973 TEST(!view->NextL(active->iStatus));
4974 TEST(!view->PreviousL(active->iStatus));
4975 TEST(view->FirstL(active->iStatus));
4977 CActiveScheduler::Start();
4978 TEST2(active->iStatus.Int(), KErrNone);
4979 TEST2(view->Event().Id(), TLogId(1)); // [1]
4980 TEST(view->LastL(active->iStatus));
4982 CActiveScheduler::Start();
4983 TEST2(active->iStatus.Int(), KErrNone);
4984 TEST2(view->Event().Id(), TLogId(1)); // [1]
4986 // Delete last event in view
4988 aClient.DeleteEvent(TLogId(1), active->iStatus);
4989 CActiveScheduler::Start();
4990 TEST2(active->iStatus.Int(), KErrNone);
4991 count = view->CountL();
4992 TEST2(count, KChangeEventTest2NumberOfEventsInView - 7);
4993 changeCount = changeObs->Changes().Count();
4994 TEST2(changeCount, 1);
4995 type = changeObs->Changes().At(0, logId, viewIndex);
4996 TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
4997 TEST2(logId, TLogId(1));
4998 TEST2(viewIndex, 0); // *Empty*
4999 changeObs->ResetChanges();
5001 // Check we can't navigate
5002 TEST(!view->NextL(active->iStatus));
5003 TEST(!view->PreviousL(active->iStatus));
5004 TEST(!view->FirstL(active->iStatus));
5005 TEST(!view->LastL(active->iStatus));
5007 CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event
5011 @SYMTestCaseID SYSLIB-LOGENG-CT-0872
5012 @SYMTestCaseDesc Filtering log view test
5013 @SYMTestPriority High
5014 @SYMTestActions Add the Voice call,FAX,SMS event types to the log client.
5015 Set all the event types to filter list.Check for the correct event types and no errors
5016 @SYMTestExpectedResults Test must not fail
5019 LOCAL_C void TestViewFilteringDefect1L(CLogClient& aClient)
5021 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0872 "));
5022 CLogEvent* event = CLogEvent::NewL();
5023 CleanupStack::PushL(event);
5025 CTestActive* active = new(ELeave) CTestActive();
5026 CleanupStack::PushL(active);
5029 event->SetEventType(KLogCallEventTypeUid);
5031 aClient.AddEvent(*event, active->iStatus);
5032 CActiveScheduler::Start();
5033 TEST2(active->iStatus.Int(), KErrNone);
5034 const TLogId event1 = event->Id();
5037 event->SetEventType(KLogFaxEventTypeUid);
5039 aClient.AddEvent(*event, active->iStatus);
5040 CActiveScheduler::Start();
5041 TEST2(active->iStatus.Int(), KErrNone);
5042 const TLogId event2 = event->Id();
5045 // SMS, CONTACT SEARCHED
5046 event->SetEventType(KLogShortMessageEventTypeUid);
5047 event->SetFlags(KLogEventContactSearched);
5049 aClient.AddEvent(*event, active->iStatus);
5050 CActiveScheduler::Start();
5051 TEST2(active->iStatus.Int(), KErrNone);
5052 const TLogId event3 = event->Id();
5054 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
5055 changeObs->SetActive();
5057 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
5058 CleanupStack::PushL(view);
5060 CLogFilterList* filterList = new(ELeave) CLogFilterList();
5061 CleanupStack::PushL(filterList);
5063 CLogFilter* filter1 = CLogFilter::NewL();
5064 CleanupStack::PushL(filter1);
5065 filter1->SetEventType(KLogCallEventTypeUid); // ALL VOICE CALL EVENTS
5066 filterList->AppendL(filter1);
5068 CLogFilter* filter2 = CLogFilter::NewL();
5069 CleanupStack::PushL(filter2);
5070 filter2->SetEventType(KLogShortMessageEventTypeUid); // ALL SMS's WHERE CONTACTS SEARCH FLAG IS SET
5071 filter2->SetFlags(KLogEventContactSearched);
5072 filterList->AppendL(filter2);
5074 TInt count = view->CountL();
5076 TBool res = view->SetFilterParseFilterByFilterL(*filterList, active->iStatus);
5078 CleanupStack::PopAndDestroy(3, filterList);
5081 CActiveScheduler::Start();
5082 TEST2(active->iStatus.Int(), KErrNone);
5083 count = view->CountL();
5086 // Check correct events
5090 res = view->FirstL(active->iStatus);
5092 CActiveScheduler::Start();
5093 TEST2(active->iStatus.Int(), KErrNone);
5094 eventId = view->Event().Id();
5095 TEST2(eventId, event3);
5098 res = view->NextL(active->iStatus);
5100 CActiveScheduler::Start();
5101 TEST2(active->iStatus.Int(), KErrNone);
5102 eventId = view->Event().Id();
5103 TEST2(eventId, event1);
5105 CleanupStack::PopAndDestroy(4, event);
5111 static TInt TestDeletingViewWithinObserverCallbackL_CallbackFn(TAny* aView)
5113 CLogViewEvent* view = reinterpret_cast<CLogViewEvent*>(aView);
5121 static void TestDeletingViewWithinObserverCallbackL_ThreadFunctionL()
5124 LEAVE_IF_ERROR(fsSession.Connect());
5125 CleanupClosePushL(fsSession);
5127 CLogClient* client = CLogClient::NewL(fsSession);
5128 CleanupStack::PushL(client);
5130 CLogEvent* event = CLogEvent::NewL();
5131 CleanupStack::PushL(event);
5132 event->SetEventType(KLogCallEventTypeUid);
5134 CTestActive* active = new(ELeave) CTestActive();
5135 CleanupStack::PushL(active);
5137 // Wait for main test code thread
5138 RSemaphore semaphore;
5139 const TInt error = semaphore.OpenGlobal(KThreadSemaphoreName);
5140 LEAVE_IF_ERROR(error);
5142 // Add 5 recent events to the list
5143 TBuf<KLogMaxDirectionLength> incoming;
5144 client->GetString(incoming, R_LOG_DIR_IN);
5145 event->SetDirection(incoming);
5148 for(TInt recent = 1; recent <= 5; recent++)
5150 event->SetContact(recent);
5151 for(TInt duplicate = 1; duplicate <= 6; duplicate++)
5154 client->AddEvent(*event, active->iStatus);
5155 CActiveScheduler::Start();
5156 __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 1));
5160 // Wait now until the main thread says we can delete all events
5162 User::After(5 * 1000000);
5165 // Clear the duplicates which should result in a batch of changes
5166 // in the other thread
5167 CLogViewRecent* view = CLogViewRecent::NewL(*client);
5168 CleanupStack::PushL(view);
5170 __ASSERT_ALWAYS(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus), User::Panic(_L("ThreadPanic"), 2));
5171 __ASSERT_ALWAYS(view->CountL() == 5, User::Panic(_L("ThreadPanic"), 3));
5173 CActiveScheduler::Start();
5174 __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 4));
5177 view->ClearDuplicatesL();
5178 __ASSERT_ALWAYS(view->CountL() == 5, User::Panic(_L("ThreadPanic"), 5));
5181 CleanupStack::PopAndDestroy(view);
5183 CleanupStack::PopAndDestroy(4, &fsSession); // active, event, client, fsSession
5189 static TInt TestDeletingViewWithinObserverCallbackL_ThreadFunction(TAny* /*aData*/)
5191 CTrapCleanup* cleanup = CTrapCleanup::New();
5193 return KErrNoMemory;
5194 CActiveScheduler* scheduler = new CActiveScheduler();
5196 return KErrNoMemory;
5197 CActiveScheduler::Install(scheduler);
5199 TRAPD(err, TestDeletingViewWithinObserverCallbackL_ThreadFunctionL());
5209 @SYMTestCaseID SYSLIB-LOGENG-CT-0873
5210 @SYMTestCaseDesc Tests for observing changes within a callback
5211 @SYMTestPriority High
5212 @SYMTestActions Check for observing changes within a callback
5213 @SYMTestExpectedResults Test must not fail
5216 LOCAL_C void TestDeletingViewWithinObserverCallbackL(CLogClient& aClient)
5218 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0873 "));
5219 TestUtils::DeleteDatabaseL();
5223 CTestActive* active = new(ELeave) CTestActive();
5224 CleanupStack::PushL(active);
5226 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
5228 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
5229 CleanupStack::PushL(view);
5231 CLogFilter* filter = CLogFilter::NewL();
5232 CleanupStack::PushL(filter);
5233 filter->SetEventType(KLogCallEventTypeUid);
5234 TBool res = view->SetFilterL(*filter, active->iStatus);
5236 CleanupStack::PopAndDestroy(filter);
5238 // Create semaphore so we can control other thread
5239 RSemaphore semaphore;
5240 error = semaphore.CreateGlobal(KThreadSemaphoreName, 0);
5241 LEAVE_IF_ERROR(error);
5242 CleanupClosePushL(semaphore);
5244 // Create thread which adds two events
5246 error = thread.Create(_L("T_VIEW1_OBS_EVENT_CREATION_THREAD"), TestDeletingViewWithinObserverCallbackL_ThreadFunction, 10 * 1024, 5 * 1024, 20 * 1024, NULL);
5247 LEAVE_IF_ERROR(error);
5248 CleanupClosePushL(thread);
5250 // Start the worker thread going
5252 User::After(1 * 100000);
5256 CLogChangeDefinition* changes = changeObs->WaitForChangesLC(TCallBack(TestDeletingViewWithinObserverCallbackL_CallbackFn, view), CLogViewChangeObserver::EStopOnChanges);
5258 // Check the changes
5259 TEST2(changes->Count(), 1);
5260 TEST2(changes->At(0), ELogChangeTypeEventAdded);
5263 TLogDatabaseChangeType dbChangeType = changes->At(0, logId);
5264 TEST2(dbChangeType, ELogChangeTypeEventAdded);
5266 TInt viewIndex = -1;
5267 dbChangeType = changes->At(0, logId, viewIndex);
5269 TEST2(viewIndex, 0);
5270 //Find a change position by the log id
5271 TInt pos = changes->Find(logId);
5273 pos = changes->Find(8125347);
5274 TEST2(pos, KErrNotFound);
5275 //Find a change position by the log id and the change type
5276 pos = changes->Find(logId, dbChangeType);
5278 pos = changes->Find(432837, ELogChangeTypeEventChanged);
5279 TEST2(pos, KErrNotFound);
5280 //Find a view position by the view index
5281 pos = changes->FindByViewIndex(viewIndex);
5283 pos = changes->FindByViewIndex(33939);
5284 TEST2(pos, KErrNotFound);
5285 //Stream out the changes to a buffer
5287 RDesWriteStream strmOut(strmBuf);
5288 changes->ExternalizeL(strmOut);
5291 CleanupStack::PopAndDestroy(changes);
5293 //Re-create changes from the buffer
5294 RDesReadStream strmIn(strmBuf);
5295 changes = CLogChangeDefinition::NewL(strmIn);
5296 dbChangeType = changes->At(0, logId);
5297 TEST2(dbChangeType, ELogChangeTypeEventAdded);
5301 // The view should be deleted...
5302 CleanupStack::PopAndDestroy(&thread);
5303 CleanupStack::PopAndDestroy(&semaphore);
5305 CleanupStack::Pop(); // view
5306 CleanupStack::PopAndDestroy(2, active); // changeObs, active
5316 inline TThreadData() : iArray(NULL), iStopThread(EFalse) { }
5318 RArray<TLogId>* iArray;
5322 // Slave Thread for the TestNavigationWhilstBusyL() test.
5323 // This runs continuously while aThreadData.iStopThread is False.
5324 static void TestNavigationWhilstBusyL_ThreadFunctionL(TThreadData& aThreadData)
5333 const static TNextOp KOpTable[] =
5335 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5336 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5337 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5338 EAdd, EAdd, EAdd, EAdd, EAdd, EDelete, EAdd, EAdd, EAdd, EAdd,
5339 EAdd, EAdd, EAdd, EDelete, EDelete, EDelete, EAdd, EAdd, EAdd, EAdd,
5340 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5341 EAdd, EAdd, EAdd, EDelete, EDelete, EDelete, EAdd, EAdd, EAdd, EAdd,
5342 EDelete, EDelete, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5343 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5344 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5345 EAdd, EAdd, EAdd, EDelete, EDelete, EDelete, EAdd, EAdd, EAdd, EAdd,
5346 EDelete, EDelete, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5347 EAdd, EAdd, 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, EDelete, EAdd, EAdd, EAdd, EAdd,
5350 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5351 EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete,
5352 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5353 EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete,
5354 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5355 EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete,
5356 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5357 EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete,
5358 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5359 EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete,
5360 EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd,
5362 const static TInt KIndexTable[] =
5364 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5365 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5366 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5367 -1, -1, -1, -1, -1, 0, -1, -1, -1, -1,
5368 -1, -1, -1, 0, 4, 20, -1, -1, -1, -1,
5369 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5370 -1, -1, -1, 0, 1, 0, -1, -1, -1, -1,
5371 25, 8, -1, -1, -1, -1, -1, -1, -1, -1,
5372 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5373 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5374 -1, -1, -1, 2, 4, 15, -1, -1, -1, -1,
5375 0, 0, -1, -1, -1, -1, -1, -1, -1, -1,
5376 -1, -1, -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, 0, -1, -1, -1, -1,
5379 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5380 -1, 0, -1, 30, -1, 0, -1, 31, -1, 14,
5381 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5382 -1, 10, -1, 2, -1, 0, -1, 24, -1, 11,
5383 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5384 -1, 0, -1, 10, -1, 0, -1, 12, -1, 5,
5385 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5386 -1, 15, -1, 9, -1, 0, -1, 19, -1, 25,
5387 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5388 -1, 0, -1, 1, -1, 0, -1, 7, -1, 31,
5389 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
5391 const static TInt KDelayTable[] =
5393 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001,
5394 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001,
5395 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001,
5396 0001, 0001, 0001, 0001, 0001, 0001, 0002, 0002, 0002, 0002,
5397 0002, 0002, 0002, 0001, 0001, 0001, 0002, 0002, 0002, 0002,
5398 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002,
5399 0002, 0002, 0002, 0001, 0002, 0001, 0002, 0002, 0002, 0002,
5400 2500, 8000, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002,
5401 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002,
5402 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002,
5403 0002, 0002, 0002, 2000, 4000000, 1500, 0002, 0002, 0002, 0002,
5404 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002,
5405 0002, 0002, 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, 0001, 0002, 0002, 0002, 0002,
5408 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
5409 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
5410 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
5411 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
5412 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000,
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,
5420 const TInt KOpCount = sizeof(KOpTable) / sizeof(TNextOp);
5423 TInt TotalDeletes = 0;
5426 LEAVE_IF_ERROR(fsSession.Connect());
5427 CleanupClosePushL(fsSession);
5429 CLogClient* client = CLogClient::NewL(fsSession);
5430 CleanupStack::PushL(client);
5432 CLogEvent* event = CLogEvent::NewL();
5433 CleanupStack::PushL(event);
5434 event->SetEventType(TEST_LOG_UID);
5436 CTestActive* active = new(ELeave) CTestActive();
5437 CleanupStack::PushL(active);
5439 // Add 5 recent events to the list
5440 TBuf<KLogMaxDirectionLength> incoming;
5441 client->GetString(incoming, R_LOG_DIR_IN);
5442 event->SetDirection(incoming);
5444 CLogSchedulerTimer* timer = CLogSchedulerTimer::NewLC();
5449 while(!(aThreadData.iStopThread))
5451 const TInt op = KOpTable[i];
5457 event->SetContact(i);
5459 client->AddEvent(*event, active->iStatus);
5460 CActiveScheduler::Start();
5461 __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 1));
5463 LEAVE_IF_ERROR(aThreadData.iArray->Append(event->Id()));
5464 // TheTest.Printf(_L("EAdd: i:%d count:%d, id:%d\n"), i, aThreadData.iArray->Count(), event->Id());
5466 // Have to wait for a minimum of 1 ms here because otherwise DMBS sorts records (by time)
5467 // in an arbitrary manor
5468 // If this occurs this test will fail the logId == arrayId test below, as the order
5469 // will be different between the logeng and arrayOfIds[].
5470 const TInt timeToWait = KDelayTable[i];
5472 timer->Wait(timeToWait);
5474 timer->Wait(500000);
5481 const TInt index = KIndexTable[i];
5482 const TLogId logId = (*aThreadData.iArray)[index];
5483 RDebug::Print(_L("EDelete index[%i]=%d id:%d\n"),i, index, logId);
5485 client->DeleteEvent(logId, active->iStatus);
5486 CActiveScheduler::Start();
5487 if (active->iStatus != KErrNone)
5489 /* This happens if the LogID is not present in the log,
5490 so the LogEngine cannot find the event to delete.
5491 This can happen if the log is full, as it will start
5492 deleting the old events itself */
5493 RDebug::Print(_L("Delete failed error:%d\n"), active->iStatus.Int());
5494 __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 2));
5496 aThreadData.iArray->Remove(index);
5504 now.UniversalTime();
5505 now += TTimeIntervalDays(1);
5509 client->ClearLog(now, active->iStatus);
5510 CActiveScheduler::Start();
5511 __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 3));
5512 aThreadData.iArray->Reset();
5514 RDebug::Print(_L("TEST CODE: Log cleared\n"));
5519 if (++i >= KOpCount)
5526 RDebug::Print(_L("Repeats:%d TotalAdds:%d TotalDeletes:%d = %d\n"),Repeat,TotalAdds, TotalDeletes, count);
5528 CleanupStack::PopAndDestroy(timer);
5531 CleanupStack::PopAndDestroy(4, &fsSession);
5534 // Slave Thread for the TestNavigationWhilstBusyL() test.
5536 static TInt TestNavigationWhilstBusyL_ThreadFunction(TAny* aData)
5538 TThreadData* threadData = reinterpret_cast<TThreadData*>(aData);
5540 CTrapCleanup* cleanup = CTrapCleanup::New();
5542 return KErrNoMemory;
5543 CActiveScheduler* scheduler = new CActiveScheduler();
5545 return KErrNoMemory;
5546 CActiveScheduler::Install(scheduler);
5548 TRAPD(err, TestNavigationWhilstBusyL_ThreadFunctionL(*threadData));
5558 This tests using the Logeng while it is busy. It starts a new thread which adds and deletes events
5559 using the data in KOpTable[] and KIndexTable[]. It then checks the database while the new thread is
5562 @SYMTestCaseID SYSLIB-LOGENG-CT-0874
5563 @SYMTestCaseDesc Tests for navigation while Log engine is busy.
5564 @SYMTestPriority High
5565 @SYMTestActions Start a new thread which adds and deletes events
5566 using the data in defined tables.It then checks the database while the new thread is running.
5567 @SYMTestExpectedResults Test must not fail
5570 LOCAL_C void TestNavigationWhilstBusyL(CLogClient& aClient)
5572 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0874 "));
5573 TestUtils::DeleteDatabaseL();
5578 CTestActive* active = new(ELeave) CTestActive();
5579 CleanupStack::PushL(active);
5581 CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
5583 // Create a test event type - TEST_LOG_UID
5584 CLogEventType* type = CLogEventType::NewL();
5585 CleanupStack::PushL(type);
5587 type->SetUid(TEST_LOG_UID);
5588 type->SetDescription(KTestEventDesc);
5589 type->SetLoggingEnabled(ETrue);
5590 TheTest.Printf(_L("\nTest event type added %x\n"),TEST_LOG_UID );
5592 // Register the event type
5594 aClient.AddEventType(*type, active->iStatus);
5595 CActiveScheduler::Start();
5596 TEST2(active->iStatus.Int(), KErrNone);
5598 CleanupStack::PopAndDestroy(); // type
5600 CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
5601 CleanupStack::PushL(view);
5603 CLogFilter* filter = CLogFilter::NewL();
5604 CleanupStack::PushL(filter);
5605 filter->SetEventType(TEST_LOG_UID);
5606 TBool res = view->SetFilterL(*filter, active->iStatus);
5609 // increase the default log size
5611 const TInt kMaxLogSize = 2000;
5612 Config.iMaxLogSize = kMaxLogSize;
5613 aClient.ChangeConfig( Config, active->iStatus);
5615 CActiveScheduler::Start();
5616 TEST2(active->iStatus.Int(), KErrNone);
5618 // Shared data between this and the worker thread
5619 RArray<TLogId> arrayOfIds(100);
5620 CleanupClosePushL(arrayOfIds);
5621 TThreadData threadData;
5622 threadData.iArray = &arrayOfIds;
5624 // Create thread which adds two events
5626 RHeap& heap = User::Heap();
5627 error = thread.Create(_L("T_VIEW1_OBS_EVENT_CREATION_THREAD2"), TestNavigationWhilstBusyL_ThreadFunction, 10 * 1024, &heap, &threadData);
5628 LEAVE_IF_ERROR(error);
5629 CleanupClosePushL(thread);
5631 // Start the worker thread going
5634 // Suspend this thread
5635 TheTest.Printf(_L("TEST CODE: Suspending thread for 2 seconds\n"));
5636 CLogSchedulerTimer* timer = CLogSchedulerTimer::NewLC();
5637 timer->Wait(10 * 1000000);
5639 // Apply the filter now there are some records
5640 TheTest.Printf(_L("TEST CODE: Setting filter again - should be some records now\n"));
5641 res = view->SetFilterL(*filter, active->iStatus);
5644 CActiveScheduler::Start();
5645 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
5646 count = view->CountL();
5649 // Navigate around (up and down) whilst events are being created
5650 count = view->CountL();
5651 res = view->FirstL(active->iStatus);
5655 CActiveScheduler::Start();
5656 TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
5658 if (active->iStatus == KErrNone)
5659 TEST(view->Event().Id() != KLogNullId);
5661 while(view->NextL(active->iStatus));
5663 timer->Wait(5 * 1000000);
5664 count = view->CountL();
5665 res = view->FirstL(active->iStatus);
5669 CActiveScheduler::Start();
5670 TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
5672 if (active->iStatus == KErrNone)
5673 TEST(view->Event().Id() != KLogNullId);
5675 while(view->NextL(active->iStatus));
5677 timer->Wait(5 * 1000000);
5678 count = view->CountL();
5679 res = view->LastL(active->iStatus);
5683 CActiveScheduler::Start();
5684 TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
5686 if (active->iStatus == KErrNone)
5687 TEST(view->Event().Id() != KLogNullId);
5689 while(view->PreviousL(active->iStatus));
5691 timer->Wait(5 * 1000000);
5692 count = view->CountL();
5693 res = view->FirstL(active->iStatus);
5697 CActiveScheduler::Start();
5698 TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
5700 if (active->iStatus == KErrNone)
5701 TEST(view->Event().Id() != KLogNullId);
5703 while(view->NextL(active->iStatus));
5705 timer->Wait(5 * 1000000);
5706 count = view->CountL();
5707 res = view->LastL(active->iStatus);
5711 CActiveScheduler::Start();
5712 TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
5714 if (active->iStatus == KErrNone)
5715 TEST(view->Event().Id() != KLogNullId);
5717 while(view->PreviousL(active->iStatus));
5719 timer->Wait(5 * 1000000);
5720 count = view->CountL();
5721 res = view->LastL(active->iStatus);
5725 CActiveScheduler::Start();
5726 TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
5728 if (active->iStatus == KErrNone)
5729 TEST(view->Event().Id() != KLogNullId);
5731 while(view->PreviousL(active->iStatus));
5733 // STOP THE WORKER THREAD
5734 threadData.iStopThread = ETrue;
5735 TheTest.Printf(_L("Stopping worker thread\n"));
5736 timer->Wait(30 * 1000000);
5738 // do some checks on the log
5739 TLogConfig logConfig;
5740 aClient.GetConfig( logConfig, active->iStatus);
5742 CActiveScheduler::Start();
5743 TEST2(active->iStatus.Int(), KErrNone);
5744 TheTest.Printf(_L("MaxLogSize:%ld MaxRecentLogSize:%d\n"),
5745 logConfig.iMaxLogSize, logConfig.iMaxRecentLogSize );
5746 TEST(logConfig.iMaxLogSize > logConfig.iMaxRecentLogSize);
5748 /* Check the log has not overflowed.
5749 If this fails either increase the log size or reduce the time the
5750 worker thread has been running
5752 TEST(arrayOfIds.Count() < kMaxLogSize);
5754 // Loop though the logevents created by the worker thread and compare against the
5755 // data stored in arrayOfIds.
5756 res = view->LastL(active->iStatus);
5761 CActiveScheduler::Start();
5762 TEST2(active->iStatus.Int(), KErrNone);
5764 const TLogId logId = view->Event().Id();
5765 const TLogId arrayId = arrayOfIds[count];
5766 if (logId != arrayId)
5767 TheTest.Printf(_L("Events[%d] - array:%5d, id:%5d ****\n"), count, arrayId, logId);
5768 // Note: If this test fails the fist thing to check is the time delay after EAdd.
5769 // If several events get the same time stamp, the order is arbitrary and the test fails here.
5770 TEST2(logId, arrayId);
5773 while(view->PreviousL(active->iStatus));
5775 CleanupStack::PopAndDestroy(timer);
5776 CleanupStack::PopAndDestroy(&thread);
5777 CleanupStack::PopAndDestroy(&arrayOfIds);
5778 CleanupStack::PopAndDestroy(filter);
5779 CleanupStack::PopAndDestroy(view);
5780 CleanupStack::PopAndDestroy(2, active); // changeObs, active
5784 @SYMTestCaseID SYSLIB-LOGENG-CT-4014
5785 @SYMTestCaseDesc Tests CLogView::CountL works correctly after SetFilterL returns no event.
5786 @SYMTestPriority High
5787 @SYMTestActions 1. ClearLog.
5789 3. Add events and check count.
5790 4. Step through the added events.
5791 @SYMTestExpectedResults 2 - SetFilterL indicates no event in view.
5792 3. CountL method returns correct number of events.
5793 4. Can step through the added events.
5797 LOCAL_C void INC123066L(CLogClient& aClient)
5799 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-4014 "));
5800 CLogEvent* event = CLogEvent::NewL();
5801 CleanupStack::PushL(event);
5802 event->SetEventType(KLogCallEventTypeUid);
5804 CTestActive* active = new(ELeave)CTestActive();
5805 CleanupStack::PushL(active);
5807 // deliberately not using CLogViewChangeObserver
5809 CLogViewEvent* view = CLogViewEvent::NewL(aClient);
5810 CleanupStack::PushL(view);
5812 CLogFilter* filter = CLogFilter::NewL();
5813 CleanupStack::PushL(filter);
5815 // Clear all the events
5817 now.UniversalTime();
5818 now += TTimeIntervalDays(1);
5820 aClient.ClearLog(now, active->iStatus);
5821 CActiveScheduler::Start();
5822 TEST2(active->iStatus.Int(), KErrNone);
5824 TBool res = view->SetFilterL(*filter, active->iStatus);
5828 for(count = 0; count < KTestEventNum; count++)
5831 aClient.AddEvent(*event, active->iStatus);
5832 CActiveScheduler::Start();
5833 TEST2(active->iStatus.Int(), KErrNone);
5835 TEST2(view->CountL(), count+1);
5838 // save the most recent logId for checking.
5839 TLogId lastLogId = event->Id();
5841 // Can iterate over the added events
5842 for (count = 0; count < KTestEventNum; count++)
5845 TEST( view->NextL(active->iStatus) );
5846 CActiveScheduler::Start();
5847 TEST2(active->iStatus.Int(), KErrNone);
5849 TLogId id = view->Event().Id();
5850 // Most recent event is first. Oldest event is last.
5851 TEST2((lastLogId - count), id);
5854 CleanupStack::PopAndDestroy(4, event); // filter, view, active, event
5856 // See same test using CLogViewRecent in TestRecentView1L.
5860 @SYMTestCaseID PDS-LOGENG-CT-4017
5861 @SYMTestCaseDesc Tests Handling of CLogViewRecent::SetRecentListL when
5862 Remote Party string contains single quote character
5863 @SYMTestPriority High
5864 @SYMTestActions 1. Create 10 Incoming call events from 3 different
5865 Remote Parties using single quotes in strings
5866 2. Call CLogViewRecent::SetRecentListL.
5867 3. Check that duplicate entries have been deleted and only
5870 @SYMTestExpectedResults SetRecentListL indicates 3 events in view
5873 LOCAL_C void INC136334L(CLogClient& aClient)
5875 TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-CT-4017 "));
5876 CLogEvent* event = CLogEvent::NewL();
5877 CleanupStack::PushL(event);
5879 CTestActive* active = new(ELeave)CTestActive();
5880 CleanupStack::PushL(active);
5882 CLogViewRecent* view = CLogViewRecent::NewL(aClient);
5883 CleanupStack::PushL(view);
5886 TBuf<KLogMaxDirectionLength> buf;
5887 aClient.GetString(buf, R_LOG_DIR_IN);
5889 event->SetEventType(KLogCallEventTypeUid);
5890 event->SetDirection(buf);
5893 //Add 10 missed calls from 3 different contacts
5894 //These should result in only 3 entries int he log as
5895 //duplicates should be deleted.
5896 for(count = 0; count < KTestEventNum; count++)
5898 //Use a string with a single quote
5899 event->SetRemoteParty(_L("Sam's Wife"));
5902 aClient.AddEvent(*event, active->iStatus);
5903 CActiveScheduler::Start();
5904 TEST2(active->iStatus.Int(), KErrNone);
5906 //Use a string with multiple single quotes
5907 event->SetRemoteParty(_L("'Sam's W'i'f'e'''''''"));
5910 aClient.AddEvent(*event, active->iStatus);
5911 CActiveScheduler::Start();
5912 TEST2(active->iStatus.Int(), KErrNone);
5914 //Use a string with no single quotes
5915 event->SetRemoteParty(_L("Sams Wife"));
5918 aClient.AddEvent(*event, active->iStatus);
5919 CActiveScheduler::Start();
5920 TEST2(active->iStatus.Int(), KErrNone);
5924 TEST2(view->CountL(), 0);
5925 TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
5928 //All of the duplicate entries should be deleted and there should
5929 //only be 3 events in the log
5931 CActiveScheduler::Start();
5932 TEST2(active->iStatus.Int(), KErrNone);
5933 TEST2(view->CountL(), 3);
5935 //Clear the log for he next test
5936 aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus);
5938 CActiveScheduler::Start();
5939 TEST2(active->iStatus.Int(), KErrNone);
5941 count = view->CountL();
5944 CleanupStack::PopAndDestroy(3); // view, active, event
5952 TheMatchingIsEnabled = TestUtils::MatchingEnabledL();
5954 TestUtils::Initialize(_L("t_logview1"));
5955 TestUtils::DeleteDatabaseL();
5957 CLogClient* client = CLogClient::NewL(theFs);
5958 CleanupStack::PushL(client);
5960 CLogChangeNotifier* notifier = CLogChangeNotifier::NewL();
5961 CleanupStack::PushL(notifier);
5963 TheTest.Start(_L("Event View With No Filter"));
5965 TestEventViewL(*client);
5966 theLog.Write(_L8("Test 1 OK\n"));
5968 TheTest.Next(_L("Event View Filter alternative"));
5969 TestViewFilteringDefect1L(*client);
5970 theLog.Write(_L8("Test 2 OK\n"));
5971 TheTest.Next(_L("Event View With Filter"));
5972 TestEventViewFilter1L(*client);
5973 TestEventViewFilter2L(*client);
5974 TheTest.Next(_L("INC123066 - LogView not updated if SetFilterL found no event"));
5975 INC123066L(*client);
5976 theLog.Write(_L8("Test 3 OK\n"));
5978 TheTest.Next(_L("Recent View"));
5979 TestRecentView1L(*client);
5980 TestRecentView2L(*client);
5981 theLog.Write(_L8("Test 4 OK\n"));
5983 TheTest.Next(_L("Removing recent events"));
5984 TestRecentRemove1L(*client);
5985 TestRecentRemove2L(*client);
5986 theLog.Write(_L8("Test 5 OK\n"));
5988 TheTest.Next(_L("Duplicate View"));
5989 TestDuplicateViewL(*client);
5990 theLog.Write(_L8("Test 6 OK\n"));
5992 TheTest.Next(_L("Removing duplicate events"));
5993 TestDuplicateRemoveL(*client);
5994 theLog.Write(_L8("Test 7 OK\n"));
5996 TheTest.Next(_L("Check purge performed on view setup"));
5997 TestPurgeOnSetup1L(*client);
5998 TestPurgeOnSetup2L(*client);
5999 theLog.Write(_L8("Test 8 OK\n"));
6001 TheTest.Next(_L("View Purging"));
6002 TestViewPurgeL(*client);
6003 theLog.Write(_L8("Test 9 OK\n"));
6005 TheTest.Next(_L("Clearing duplicate lists"));
6006 TestClearDuplicatesL(*client);
6007 theLog.Write(_L8("Test 10 OK\n"));
6009 TheTest.Next(_L("Phone number matching"));
6010 TestPhoneNumberMatchingL(*client);
6011 theLog.Write(_L8("Test 11 OK\n"));
6013 TheTest.Next(_L("view flags setting/clearing"));
6014 TestViewFlagsL(*client);
6015 theLog.Write(_L8("Test 12 OK\n"));
6017 TheTest.Next(_L("Recent view flags setting/clearing"));
6018 TestRecentFlagsL(*client);
6019 theLog.Write(_L8("Test 13 OK\n"));
6021 TheTest.Next(_L("View change tests 1"));
6022 TestViewChangeEvents1L(*client);
6023 TestViewChangeEvents1aL(*client);
6024 theLog.Write(_L8("Test 14 OK\n"));
6026 TheTest.Next(_L("View change tests 2"));
6027 TestViewChangeEvents2L(*client);
6028 TestViewChangeEvents2aL(*client);
6029 theLog.Write(_L8("Test 15 OK\n"));
6031 TheTest.Next(_L("View deletion from within callback"));
6032 TestDeletingViewWithinObserverCallbackL(*client);
6033 theLog.Write(_L8("Test 16 OK\n"));
6035 TheTest.Next(_L("Test navigation whilst events are added"));
6036 TestNavigationWhilstBusyL(*client);
6037 theLog.Write(_L8("Test 17 OK\n"));
6039 TheTest.Next(_L("Defect INC105010 - phone number matching"));
6040 INC105010L(*client);
6041 theLog.Write(_L8("Test 18 OK\n"));
6043 TheTest.Next(_L("INC136334 - The miss call log won't show if you have ' in your contact"));
6044 INC136334L(*client);
6045 theLog.Write(_L8("Test 19 OK\n"));
6047 CleanupStack::PopAndDestroy(2); // notifier, client;