sl@0: // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_logutil2.h" sl@0: #include sl@0: sl@0: #define UNUSED_VAR(a) a = a sl@0: sl@0: RTest TheTest(_L("t_logview1")); sl@0: sl@0: const TInt KTestLogNumberCharsToMatch = 9; // should be the same as KLogNumberCharsToMatch defined in LogServ\src\LOGFILTQ.CPP sl@0: const TInt KTestEventNum = 10; sl@0: const TUid KTestEventUid = {0x10005393}; sl@0: const TLogDurationType KTestDurationType = 0x12; sl@0: const TLogContactItemId KTestContact = 0x1234; sl@0: _LIT(KTestEventDesc, "Test Event"); sl@0: _LIT(KTestRemoteParty, "Test Remote Party"); sl@0: _LIT(KTestDirection, "Test Direction"); sl@0: _LIT(KTestStatus, "Test Status"); sl@0: _LIT(KTestNumber, "Test Number"); sl@0: _LIT(KThreadSemaphoreName, "T_VIEW1_TEST_CODE"); sl@0: sl@0: sl@0: TBool TheMatchingIsEnabled = EFalse; sl@0: sl@0: #define TEST_LOG_UID KTestEventUid sl@0: sl@0: //View's DoCancel() test sl@0: void DoViewCancelTestL(CTestActive& aActive, CLogViewEvent& aView) sl@0: { sl@0: //Call FirstL() and cancel the operation sl@0: aActive.StartL(); sl@0: (void)aView.FirstL(aActive.iStatus); sl@0: aView.Cancel(); sl@0: TEST(!aView.IsActive()); sl@0: CActiveScheduler::Start(); sl@0: TEST2(aActive.iStatus.Int(), KErrCancel); sl@0: sl@0: //Call FirstL(). View cursor positioned on the first record. sl@0: aActive.StartL(); sl@0: (void)aView.FirstL(aActive.iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(aActive.iStatus.Int(), KErrNone); sl@0: sl@0: //Call NextL() and cancel the operation sl@0: aActive.StartL(); sl@0: (void)aView.NextL(aActive.iStatus); sl@0: aView.Cancel(); sl@0: TEST(!aView.IsActive()); sl@0: CActiveScheduler::Start(); sl@0: TEST2(aActive.iStatus.Int(), KErrCancel); sl@0: sl@0: //Call LastL() and cancel the operation sl@0: aActive.StartL(); sl@0: (void)aView.LastL(aActive.iStatus); sl@0: aView.Cancel(); sl@0: TEST(!aView.IsActive()); sl@0: CActiveScheduler::Start(); sl@0: TEST2(aActive.iStatus.Int(), KErrCancel); sl@0: sl@0: //Call LastL(). View cursor positioned on the last record. sl@0: aActive.StartL(); sl@0: (void)aView.LastL(aActive.iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(aActive.iStatus.Int(), KErrNone); sl@0: sl@0: //Call PreviousL() and cancel the operation sl@0: aActive.StartL(); sl@0: (void)aView.PreviousL(aActive.iStatus); sl@0: aView.Cancel(); sl@0: TEST(!aView.IsActive()); sl@0: CActiveScheduler::Start(); sl@0: TEST2(aActive.iStatus.Int(), KErrCancel); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0851 sl@0: @SYMTestCaseDesc Tests for adding event types to the log sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for adding events,check event count,clearing all the events sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestEventViewL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0851 ")); sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: TInt count; sl@0: for(count = 0; count < KTestEventNum; count++) sl@0: { sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: sl@0: CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); sl@0: changeObs->SetActive(); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: count = view->CountL(); sl@0: TEST2(count, 0); sl@0: TBool res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(res); sl@0: sl@0: // Move forward sl@0: count = KTestEventNum; sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: const TInt viewCount = view->CountL(); sl@0: TEST2(viewCount, KTestEventNum); sl@0: const TLogId eventId = view->Event().Id(); sl@0: TLogId id = --count; sl@0: TEST2(eventId, id); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TEST2(count, 0); sl@0: sl@0: // Move back sl@0: while(view->PreviousL(active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: TLogId id = ++count; sl@0: TEST2(view->Event().Id(), id); sl@0: } sl@0: TEST2(count, KTestEventNum - 1); sl@0: sl@0: active->StartL(); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: active->StartL(); sl@0: res = view->LastL(active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Nothing has changed in the view yet sl@0: TEST(!changeObs->HaveChanges()); sl@0: sl@0: DoViewCancelTestL(*active, *view); sl@0: sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: now+=(TTimeIntervalDays) 1; sl@0: sl@0: // Clear all the events sl@0: active->StartL(); sl@0: aClient.ClearLog(now, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(!res); sl@0: TEST2(view->CountL(), 0); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(!res); sl@0: res = view->LastL(active->iStatus); sl@0: TEST(!res); sl@0: res = view->NextL(active->iStatus); sl@0: TEST(!res); sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(!res); sl@0: sl@0: CleanupStack::PopAndDestroy(5, event); // filter, view, changeObs, active, event sl@0: sl@0: CLogSchedulerTimer* timer = CLogSchedulerTimer::NewLC(); sl@0: timer->Wait(10 * 1000000); sl@0: CleanupStack::PopAndDestroy(timer); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0852 sl@0: @SYMTestCaseDesc Tests for adding event types to the filter list sl@0: @SYMTestPriority High sl@0: @SYMTestActions Set the configuration data of event type.Add the event type to the filter and sl@0: compare the configuration data of event type and from filter view. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestViewFilterL(CLogClient& aClient, CLogFilter& aFilter) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0852 ")); sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: event->SetEventType(KTestEventUid); sl@0: event->SetRemoteParty(aFilter.RemoteParty()); sl@0: event->SetDirection(aFilter.Direction()); sl@0: event->SetDurationType(aFilter.DurationType()); sl@0: event->SetStatus(aFilter.Status()); sl@0: event->SetContact(aFilter.Contact()); sl@0: event->SetNumber(aFilter.Number()); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: if (view->SetFilterL(aFilter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: sl@0: TInt total = view->CountL(); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TBool res = view->SetFilterL(aFilter, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), total + 1); sl@0: sl@0: TEST2(event->EventType().iUid, KTestEventUid.iUid); sl@0: TEST(event->RemoteParty() == aFilter.RemoteParty()); sl@0: TEST(event->Direction() == aFilter.Direction()); sl@0: TEST2(event->DurationType(), aFilter.DurationType()); sl@0: TEST(event->Status() == aFilter.Status()); sl@0: TEST2(event->Contact(), aFilter.Contact()); sl@0: TEST(event->Number() == aFilter.Number()); sl@0: sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: sl@0: TInt count = 1; sl@0: sl@0: while(view->NextL(active->iStatus)) sl@0: { sl@0: count++; sl@0: TEST(count <= total + 1); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST(now >= event->Time()); sl@0: sl@0: if (aFilter.EventType() != KNullUid) sl@0: TEST2(event->EventType().iUid, aFilter.EventType().iUid); sl@0: sl@0: if (aFilter.RemoteParty().Length() > 0) sl@0: TEST(event->RemoteParty() == aFilter.RemoteParty()); sl@0: sl@0: if (aFilter.Direction().Length() > 0) sl@0: TEST(event->Direction() == aFilter.Direction()); sl@0: sl@0: if (aFilter.DurationType() != KLogNullDurationType) sl@0: TEST2(event->DurationType(), aFilter.DurationType()); sl@0: sl@0: if (aFilter.Status().Length() > 0) sl@0: TEST(event->Status() == aFilter.Status()); sl@0: sl@0: if (aFilter.Contact() > KLogNullContactId) sl@0: TEST2(event->Contact(), aFilter.Contact()); sl@0: sl@0: if (aFilter.Number().Length() > 0) sl@0: TEST(event->Number() == aFilter.Number()); sl@0: } sl@0: sl@0: TEST2(count, total + 1); sl@0: sl@0: CleanupStack::PopAndDestroy(3); // active, event, view; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0853 sl@0: @SYMTestCaseDesc Tests for filtering the log view sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for the log view filter,which is set with different configuration data sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestEventViewFilter1L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0853 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: // Create a test event type sl@0: CLogEventType* type = CLogEventType::NewL(); sl@0: CleanupStack::PushL(type); sl@0: sl@0: type->SetUid(KTestEventUid); sl@0: type->SetDescription(KTestEventDesc); sl@0: type->SetLoggingEnabled(ETrue); sl@0: sl@0: // Register the event type sl@0: active->StartL(); sl@0: aClient.AddEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(); // type sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: filter->SetEventType(KTestEventUid); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetEventType(KTestEventUid); sl@0: filter->SetRemoteParty(KTestRemoteParty); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetEventType(KTestEventUid); sl@0: filter->SetRemoteParty(KTestRemoteParty); sl@0: filter->SetDirection(KTestDirection); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetEventType(KTestEventUid); sl@0: filter->SetRemoteParty(KTestRemoteParty); sl@0: filter->SetDirection(KTestDirection); sl@0: filter->SetDurationType(KTestDurationType); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetEventType(KTestEventUid); sl@0: filter->SetRemoteParty(KTestRemoteParty); sl@0: filter->SetDirection(KTestDirection); sl@0: filter->SetDurationType(KTestDurationType); sl@0: filter->SetStatus(KTestStatus); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetEventType(KTestEventUid); sl@0: filter->SetRemoteParty(KTestRemoteParty); sl@0: filter->SetDirection(KTestDirection); sl@0: filter->SetDurationType(KTestDurationType); sl@0: filter->SetStatus(KTestStatus); sl@0: filter->SetContact(KTestContact); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetEventType(KTestEventUid); sl@0: filter->SetRemoteParty(KTestRemoteParty); sl@0: filter->SetDirection(KTestDirection); sl@0: filter->SetDurationType(KTestDurationType); sl@0: filter->SetStatus(KTestStatus); sl@0: filter->SetContact(KTestContact); sl@0: filter->SetNumber(KTestNumber); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: CleanupStack::PopAndDestroy(); // filter sl@0: sl@0: filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: filter->SetRemoteParty(KTestRemoteParty); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetRemoteParty(KTestRemoteParty); sl@0: filter->SetDirection(KTestDirection); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetRemoteParty(KTestRemoteParty); sl@0: filter->SetDirection(KTestDirection); sl@0: filter->SetDurationType(KTestDurationType); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetRemoteParty(KTestRemoteParty); sl@0: filter->SetDirection(KTestDirection); sl@0: filter->SetDurationType(KTestDurationType); sl@0: filter->SetStatus(KTestStatus); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetRemoteParty(KTestRemoteParty); sl@0: filter->SetDirection(KTestDirection); sl@0: filter->SetDurationType(KTestDurationType); sl@0: filter->SetStatus(KTestStatus); sl@0: filter->SetContact(KTestContact); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetRemoteParty(KTestRemoteParty); sl@0: filter->SetDirection(KTestDirection); sl@0: filter->SetDurationType(KTestDurationType); sl@0: filter->SetStatus(KTestStatus); sl@0: filter->SetContact(KTestContact); sl@0: filter->SetNumber(KTestNumber); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: CleanupStack::PopAndDestroy(); // filter sl@0: sl@0: filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: filter->SetDirection(KTestDirection); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetDirection(KTestDirection); sl@0: filter->SetDurationType(KTestDurationType); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetDirection(KTestDirection); sl@0: filter->SetDurationType(KTestDurationType); sl@0: filter->SetStatus(KTestStatus); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetDirection(KTestDirection); sl@0: filter->SetDurationType(KTestDurationType); sl@0: filter->SetStatus(KTestStatus); sl@0: filter->SetContact(KTestContact); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetDirection(KTestDirection); sl@0: filter->SetDurationType(KTestDurationType); sl@0: filter->SetStatus(KTestStatus); sl@0: filter->SetContact(KTestContact); sl@0: filter->SetNumber(KTestNumber); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: CleanupStack::PopAndDestroy(); // filter sl@0: sl@0: filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: filter->SetDurationType(KTestDurationType); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetDurationType(KTestDurationType); sl@0: filter->SetStatus(KTestStatus); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetDurationType(KTestDurationType); sl@0: filter->SetStatus(KTestStatus); sl@0: filter->SetContact(KTestContact); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetDurationType(KTestDurationType); sl@0: filter->SetStatus(KTestStatus); sl@0: filter->SetContact(KTestContact); sl@0: filter->SetNumber(KTestNumber); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: CleanupStack::PopAndDestroy(); // filter sl@0: sl@0: filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: filter->SetStatus(KTestStatus); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetStatus(KTestStatus); sl@0: filter->SetContact(KTestContact); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetStatus(KTestStatus); sl@0: filter->SetContact(KTestContact); sl@0: filter->SetNumber(KTestNumber); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: CleanupStack::PopAndDestroy(); // filter sl@0: sl@0: filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: filter->SetContact(KTestContact); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: filter->SetContact(KTestContact); sl@0: filter->SetNumber(KTestNumber); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: CleanupStack::PopAndDestroy(); // filter sl@0: sl@0: filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: filter->SetNumber(KTestNumber); sl@0: TestViewFilterL(aClient, *filter); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // filter, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0854 sl@0: @SYMTestCaseDesc Tests for filtering list event types sl@0: @SYMTestPriority High sl@0: @SYMTestActions Get the count of all event types,call,data,fax events. sl@0: Add some event types to the filter,test for the new count sl@0: Check for non existing event type. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestEventViewFilter2L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0854 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: // Get total count of all events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TInt total = view->CountL(); sl@0: sl@0: filter->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: // Get number of call events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TInt calls = view->CountL(); sl@0: sl@0: filter->SetEventType(KLogDataEventTypeUid); sl@0: sl@0: // Get number of data events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TInt data = view->CountL(); sl@0: sl@0: filter->SetEventType(KLogFaxEventTypeUid); sl@0: sl@0: // Get number of fax events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TInt fax = view->CountL(); sl@0: sl@0: filter->SetEventType(KLogLbsSelfLocateEventTypeUid); sl@0: sl@0: // Get number of Lbs self locate events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TInt lbsSelf = view->CountL(); sl@0: sl@0: filter->SetEventType(KLogLbsExternalLocateEventTypeUid); sl@0: sl@0: // Get number of Lbs self locate events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TInt lbsExternal = view->CountL(); sl@0: sl@0: filter->SetEventType(KLogLbsTransmitLocationEventTypeUid); sl@0: sl@0: // Get number of Lbs transmit location events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TInt lbsXmitLoc = view->CountL(); sl@0: sl@0: filter->SetEventType(KLogLbsNetworkLocateEventTypeUid); sl@0: sl@0: // Get number of Lbs network locate events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TInt lbsNetwork = view->CountL(); sl@0: sl@0: filter->SetEventType(KLogLbsAssistanceDataEventTypeUid); sl@0: sl@0: // Get number of Lbs assistance data events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TInt lbsAssistance = view->CountL(); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: // Add two call events sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: event->SetEventType(KLogDataEventTypeUid); sl@0: sl@0: // Add two data events sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Filter all event types sl@0: filter->SetEventType(KNullUid); sl@0: sl@0: // Get view of all events sl@0: active->StartL(); sl@0: TBool res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Check the count is correct sl@0: TEST2(view->CountL(), total + 4); sl@0: sl@0: filter->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: // Get view of call events sl@0: active->StartL(); sl@0: res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), calls + 2); sl@0: sl@0: filter->SetEventType(KLogDataEventTypeUid); sl@0: sl@0: // Get view of data events sl@0: active->StartL(); sl@0: res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), data + 2); sl@0: sl@0: filter->SetEventType(KLogFaxEventTypeUid); sl@0: sl@0: // Get view of fax events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TEST2(view->CountL(), fax); sl@0: sl@0: filter->SetEventType(KLogLbsSelfLocateEventTypeUid); sl@0: sl@0: // Get number of Lbs self locate events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TEST2(view->CountL(), lbsSelf); sl@0: sl@0: filter->SetEventType(KLogLbsExternalLocateEventTypeUid); sl@0: sl@0: // Get number of Lbs self locate events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TEST2(view->CountL(), lbsExternal); sl@0: sl@0: filter->SetEventType(KLogLbsTransmitLocationEventTypeUid); sl@0: sl@0: // Get number of Lbs transmit location events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TEST2(view->CountL(), lbsXmitLoc); sl@0: sl@0: filter->SetEventType(KLogLbsNetworkLocateEventTypeUid); sl@0: sl@0: // Get number of Lbs network locate events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TEST2(view->CountL(), lbsNetwork); sl@0: sl@0: filter->SetEventType(KLogLbsAssistanceDataEventTypeUid); sl@0: sl@0: // Get number of Lbs assistance data events sl@0: if (view->SetFilterL(*filter, active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TEST2(view->CountL(), lbsAssistance); sl@0: sl@0: // Test a non existing event type sl@0: filter->SetEventType(TUid::Uid(0x12345678)); sl@0: res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(!res); sl@0: TEST2(view->CountL(), 0); sl@0: sl@0: CleanupStack::PopAndDestroy(4); // view, filter, event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0855 sl@0: @SYMTestCaseDesc Tests for CLogViewRecent::SetRecentListL() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for the count of events,outgoing calls. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestRecentView1L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0855 ")); sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewRecent* view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: // Incoming sl@0: TBuf buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: sl@0: TInt count; sl@0: for(count = 0; count < KTestEventNum; count++) sl@0: { sl@0: event->SetContact(count); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: sl@0: TEST2(view->CountL(), 0); sl@0: TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: sl@0: // Move forward sl@0: count = KTestEventNum; sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: TEST2(view->RecentList(), KLogRecentIncomingCalls); sl@0: count--; sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TEST2(count, 0); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: // Move back sl@0: while(view->PreviousL(active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: TEST2(view->RecentList(), KLogRecentIncomingCalls); sl@0: count++; sl@0: } sl@0: TEST2(count, KTestEventNum - 1); sl@0: sl@0: active->StartL(); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: active->StartL(); sl@0: res = view->LastL(active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: // Outgoing sl@0: res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); sl@0: TEST(!res); sl@0: count = view->CountL(); sl@0: TEST2(count, 0); sl@0: CleanupStack::PopAndDestroy(view); sl@0: // sl@0: view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: aClient.GetString(buf, R_LOG_DIR_OUT); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: sl@0: for(count = 0; count < KTestEventNum; count++) sl@0: { sl@0: event->SetContact(count); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum); sl@0: res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); sl@0: TEST(res); sl@0: sl@0: // Move forward sl@0: count = KTestEventNum; sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: TEST2(view->RecentList(), KLogRecentOutgoingCalls); sl@0: count--; sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TEST2(count, 0); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: // Move back sl@0: while(view->PreviousL(active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: TEST2(view->RecentList(), KLogRecentOutgoingCalls); sl@0: count++; sl@0: } sl@0: TEST2(count, KTestEventNum - 1); sl@0: sl@0: active->StartL(); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: active->StartL(); sl@0: res = view->LastL(active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Missed sl@0: aClient.GetString(buf, R_LOG_DIR_MISSED); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus); sl@0: TEST(!res); sl@0: TEST2(view->CountL(), 0); sl@0: sl@0: for(count = 0; count < KTestEventNum; count++) sl@0: { sl@0: event->SetContact(count); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Test INC123066 - LogView not updated if log count is zero at sl@0: // time of SetFilterL. sl@0: TEST2(view->CountL(), count+1); sl@0: } sl@0: sl@0: sl@0: // Move forward sl@0: count = KTestEventNum; sl@0: while(view->NextL(active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: TEST2(view->RecentList(), KLogRecentMissedCalls); sl@0: count--; sl@0: } sl@0: TEST2(count, 0); sl@0: sl@0: // Move back sl@0: while(view->PreviousL(active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: TEST2(view->RecentList(), KLogRecentMissedCalls); sl@0: count++; sl@0: } sl@0: TEST2(count, KTestEventNum - 1); sl@0: sl@0: active->StartL(); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: active->StartL(); sl@0: res = view->LastL(active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // All sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: res = view->SetRecentListL(KLogNullRecentList, active->iStatus); sl@0: TEST(res); sl@0: sl@0: // Move forward sl@0: count = KTestEventNum * 3; sl@0: TEST2(view->CountL(), count); sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), KTestEventNum * 3); sl@0: count--; sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TEST2(count, 0); sl@0: sl@0: // Move back sl@0: while(view->PreviousL(active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), KTestEventNum * 3); sl@0: count++; sl@0: } sl@0: TEST2(count, KTestEventNum * 3 - 1); sl@0: sl@0: active->StartL(); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: active->StartL(); sl@0: res = view->LastL(active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(3); // view, active, event sl@0: theLog.Write(_L8("Test 3.1 OK\n")); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0856 sl@0: @SYMTestCaseDesc Tests for CLogViewRecent::SetRecentListL(),DuplicatesL() functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for the count of events in the log sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestRecentView2L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0856 ")); sl@0: TInt count; sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewRecent* view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: TEST2(view->CountL(), 0); sl@0: TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum); sl@0: sl@0: aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: count = view->CountL(); sl@0: TEST2(count, 0); sl@0: sl@0: CleanupStack::PopAndDestroy(view); sl@0: view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: sl@0: // Incoming sl@0: TBuf buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: sl@0: // All fields are null, they should all be duplicates sl@0: for(count = 0; count < KTestEventNum; count++) sl@0: { sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: sl@0: TEST2(view->CountL(), 0); sl@0: sl@0: // Move forward sl@0: res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->CountL(), 1); sl@0: sl@0: CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient); sl@0: CleanupStack::PushL(dView); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(dView->CountL(), KTestEventNum - 1); sl@0: sl@0: CleanupStack::PopAndDestroy(4); // view, active, event, dView sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0857 sl@0: @SYMTestCaseDesc Tests for CLogViewRecent::RemoveL() functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Add the recently view events to the view.Remove the items and check for the count. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestRecentRemove1L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0857 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewRecent* view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TInt count = view->CountL(); sl@0: sl@0: while(view->RemoveL(active->iStatus)) sl@0: { sl@0: TEST2(view->CountL(), count - 1); sl@0: count = view->CountL(); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TEST2(view->CountL(), 0); sl@0: sl@0: res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: aClient.ClearLog(KLogRecentOutgoingCalls, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->CountL(), 0); sl@0: sl@0: res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); sl@0: TEST(!res); sl@0: sl@0: res = view->SetRecentListL(KLogNullRecentList, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: aClient.ClearLog(KLogNullRecentList, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->SetRecentListL(KLogNullRecentList, active->iStatus); sl@0: TEST(!res); sl@0: TEST2(view->CountL(), 0); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // view, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0858 sl@0: @SYMTestCaseDesc Tests for CLogViewRecent::RemoveL() functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Add the recently view events to the two logviewrecents.Remove the items and check for the count of the first logview. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestRecentRemove2L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0858 ")); sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewRecent* view1 = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view1); sl@0: sl@0: // Incoming sl@0: TBuf buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: sl@0: TInt count; sl@0: for(count = 0; count < KTestEventNum; count++) sl@0: { sl@0: event->SetContact(count); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: sl@0: // Create another invalid view and remove an event using it sl@0: CLogViewRecent* view2 = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view2); sl@0: sl@0: TEST2(view1->CountL(), 0); sl@0: TBool res = view1->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view1->CountL(), KTestEventNum); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: view2->RemoveL(view1->Event().Id()); sl@0: } sl@0: while(view1->NextL(active->iStatus)); sl@0: sl@0: aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view1->CountL(), 0); sl@0: sl@0: CleanupStack::PopAndDestroy(4); // view2, view1, active, event sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0859 sl@0: @SYMTestCaseDesc Tests for CLogViewDuplicate::SetRecentListL(),DuplicatesL() functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for the count of events and the event ID sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDuplicateViewL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0859 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewRecent* view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient); sl@0: CleanupStack::PushL(dView); sl@0: sl@0: TEST2(dView->CountL(), 0); sl@0: sl@0: TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(!res); sl@0: TEST2(view->CountL(), 0); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(!res); sl@0: TEST2(dView->CountL(), 0); sl@0: sl@0: // Incoming sl@0: TBuf incoming; sl@0: aClient.GetString(incoming, R_LOG_DIR_IN); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(incoming); sl@0: event->SetRemoteParty(KTestRemoteParty); sl@0: event->SetContact(KTestContact); sl@0: event->SetNumber(KTestNumber); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), 1); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), event->Id()); sl@0: sl@0: TEST2(dView->CountL(), 0); sl@0: sl@0: event->SetRemoteParty(KTestRemoteParty); sl@0: event->SetContact(KTestContact); sl@0: event->SetNumber(KNullDesC); sl@0: sl@0: //Add event with Number field set to NULL sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), 2); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), event->Id()); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(!res); sl@0: sl@0: TEST2(dView->CountL(), 0); sl@0: sl@0: event->SetRemoteParty(KTestRemoteParty); sl@0: event->SetContact(KLogNullContactId); sl@0: event->SetNumber(KNullDesC); sl@0: sl@0: //Add event with Number field set to NULL & Contact set to -1 sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), 3); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), event->Id()); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(!res); sl@0: sl@0: TEST2(dView->CountL(), 0); sl@0: sl@0: event->SetRemoteParty(KNullDesC); sl@0: event->SetContact(KLogNullContactId); sl@0: event->SetNumber(KNullDesC); sl@0: sl@0: //Add event with Number, Remote Party field set to NULL & Contact set to -1 sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), 4); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(!res); sl@0: sl@0: TEST2(dView->CountL(), 0); sl@0: sl@0: TLogId lastId = event->Id(); sl@0: sl@0: //Add event with Number, Remote Party field set to NULL & Contact set to -1 sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), 4); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(dView->CountL(), 1); sl@0: TEST2(dView->Event().Id(), lastId); sl@0: sl@0: CleanupStack::PopAndDestroy(4); // event, dView, view, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0860 sl@0: @SYMTestCaseDesc Tests for CLogViewDuplicate::RemoveL() functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for removing the events and test for the count sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDuplicateRemoveL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0860 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewRecent* view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient); sl@0: CleanupStack::PushL(dView); sl@0: sl@0: TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: //The incoming call list should have count as 4. These calls were added in sl@0: //...the previous function named TestDuplicateViewL() sl@0: TEST2(view->CountL(), 4); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TLogId id = dView->Event().Id(); sl@0: TEST2(dView->CountL(), 1); sl@0: sl@0: res = dView->RemoveL(active->iStatus); sl@0: TEST(!res); sl@0: sl@0: TEST2(dView->CountL(), 0); sl@0: sl@0: res = dView->RemoveL(active->iStatus); sl@0: TEST(!res); sl@0: TEST2(dView->CountL(), 0); sl@0: sl@0: TEST2(view->CountL(), 4); sl@0: sl@0: CleanupStack::PopAndDestroy(3); // dView, view, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0861 sl@0: @SYMTestCaseDesc Tests for purging on log engine sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for changing the log engine configuration,add event and test for retrieving them back. sl@0: Set up a purge which clears the log and reset the log configuration sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestPurgeOnSetup1L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0861 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: User::After(0x100000); sl@0: sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: sl@0: // Clear all the events sl@0: active->StartL(); sl@0: aClient.ClearLog(now, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: TLogConfig config; sl@0: sl@0: // Get log configuration sl@0: active->StartL(); sl@0: aClient.GetConfig(config, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Set the maximum log age sl@0: TInt oldAge = config.iMaxEventAge; sl@0: config.iMaxEventAge = 10; // 10 seconds! sl@0: sl@0: // Change the log engine config sl@0: active->StartL(); sl@0: aClient.ChangeConfig(config, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that the event can be retrieved sl@0: active->StartL(); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Wait for 15 seconds (just to be safe) sl@0: User::After(15000000); sl@0: sl@0: // Check that the event can be retrieved sl@0: active->StartL(); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that the event can still be retrieved sl@0: active->StartL(); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that the event can still be retrieved sl@0: active->StartL(); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: // Setup a view which should purge the event - hence no events in view! sl@0: TBool res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(!res); sl@0: sl@0: // Reset the config sl@0: config.iMaxEventAge = oldAge; sl@0: sl@0: // Change the log engine config sl@0: active->StartL(); sl@0: aClient.ChangeConfig(config, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(4); // filter, view, active, event sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0862 sl@0: @SYMTestCaseDesc Tests for purging on log engine sl@0: @SYMTestPriority High sl@0: @SYMTestActions Clear the events from the log,set the log engine age to maximum.Change the configuration,and test adding and retrieving the events. sl@0: Set up a purge which clears the log and reset the log configuration sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestPurgeOnSetup2L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0862 ")); sl@0: CTestActive* active1 = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active1); sl@0: sl@0: CTestActive* active2 = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active2); sl@0: sl@0: User::After(0x100000); sl@0: sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: sl@0: // Clear all the events sl@0: active1->StartL(); sl@0: aClient.ClearLog(now, active1->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active1->iStatus.Int(), KErrNone); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: TLogConfig config; sl@0: sl@0: // Get log configuration sl@0: active1->StartL(); sl@0: aClient.GetConfig(config, active1->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active1->iStatus.Int(), KErrNone); sl@0: sl@0: // Set the maximum log age sl@0: TInt oldAge = config.iMaxEventAge; sl@0: config.iMaxEventAge = 10; // 10 seconds! sl@0: sl@0: // Change the log engine config sl@0: active1->StartL(); sl@0: aClient.ChangeConfig(config, active1->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active1->iStatus.Int(), KErrNone); sl@0: sl@0: active1->StartL(); sl@0: aClient.AddEvent(*event, active1->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active1->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that the event can be retrieved sl@0: active1->StartL(); sl@0: aClient.GetEvent(*event, active1->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active1->iStatus.Int(), KErrNone); sl@0: sl@0: // Wait for 15 seconds (just to be safe) sl@0: User::After(15000000); sl@0: sl@0: // Check that the event can be retrieved sl@0: active1->StartL(); sl@0: aClient.GetEvent(*event, active1->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active1->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that the event can still be retrieved sl@0: active1->StartL(); sl@0: aClient.GetEvent(*event, active1->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active1->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that the event can still be retrieved sl@0: active1->StartL(); sl@0: aClient.GetEvent(*event, active1->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active1->iStatus.Int(), KErrNone); sl@0: sl@0: CLogViewEvent* view1 = CLogViewEvent::NewL(aClient); sl@0: CleanupStack::PushL(view1); sl@0: sl@0: CLogViewEvent* view2 = CLogViewEvent::NewL(aClient); sl@0: CleanupStack::PushL(view2); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: // Setup a view which should purge the event - hence no events in view! sl@0: TBool res = view1->SetFilterL(*filter, active1->iStatus); sl@0: TEST(!res); sl@0: res = view2->SetFilterL(*filter, active2->iStatus); sl@0: TEST(!res); sl@0: sl@0: // Reset the config sl@0: config.iMaxEventAge = oldAge; sl@0: sl@0: // Change the log engine config sl@0: active1->StartL(); sl@0: aClient.ChangeConfig(config, active1->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active1->iStatus.Int(), KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(6); // filter, view1, view2, active1, active2, event sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0863 sl@0: @SYMTestCaseDesc Tests for purge on CLogViewRecent sl@0: @SYMTestPriority High sl@0: @SYMTestActions Set the log engine maximum log size and recent log size.Change the configuration and add events to the log sl@0: Tests the count to be less than or equal to recent logsize. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestViewPurgeL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0863 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: TLogConfig config; sl@0: sl@0: aClient.GetConfig(config, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(config.iMaxLogSize, 1000); sl@0: sl@0: config.iMaxLogSize = 2000; sl@0: config.iMaxRecentLogSize = 20; sl@0: sl@0: aClient.ChangeConfig(config, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CLogViewRecent* view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: // Incoming sl@0: TBuf buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: sl@0: for(TInt count = 0; count < config.iMaxRecentLogSize * 2; count++) sl@0: { sl@0: event->SetContact(count); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TBool res = view->SetRecentListL(KLogNullRecentList, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST(view->CountL() <= config.iMaxRecentLogSize); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(3); // active, event, view sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0864 sl@0: @SYMTestCaseDesc Tests for the functionality of CLogViewDuplicate class sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for clearing the duplicate events sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestClearDuplicatesL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0864 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: aClient.ClearLog(KLogNullRecentList, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CLogViewRecent* view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient); sl@0: CleanupStack::PushL(dView); sl@0: sl@0: TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(!res); sl@0: sl@0: TBuf incoming; sl@0: aClient.GetString(incoming, R_LOG_DIR_IN); sl@0: sl@0: TBuf outgoing; sl@0: aClient.GetString(outgoing, R_LOG_DIR_OUT); sl@0: sl@0: TBuf missed; sl@0: aClient.GetString(missed, R_LOG_DIR_MISSED); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: // Add 5 recent events to each list - with 5 duplicates each sl@0: sl@0: // Incoming sl@0: event->SetDirection(incoming); sl@0: TInt recent; sl@0: for(recent = 1; recent <= 5; recent++) sl@0: { sl@0: event->SetContact(recent); sl@0: for(TInt duplicate = 1; duplicate <= 6; duplicate++) sl@0: { sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: } sl@0: sl@0: // Outgoing sl@0: event->SetDirection(outgoing); sl@0: for(recent = 1; recent <= 5; recent++) sl@0: { sl@0: event->SetContact(recent); sl@0: for(TInt duplicate = 1; duplicate <= 6; duplicate++) sl@0: { sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: } sl@0: sl@0: // Missed sl@0: event->SetDirection(missed); sl@0: for(recent = 1; recent <= 5; recent++) sl@0: { sl@0: event->SetContact(recent); sl@0: for(TInt duplicate = 1; duplicate <= 6; duplicate++) sl@0: { sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: } sl@0: sl@0: // Check outgoing sl@0: res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(res); sl@0: TEST2(dView->CountL(), 5); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Check missed sl@0: res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(res); sl@0: TEST2(dView->CountL(), 5); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Check incoming sl@0: res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(res); sl@0: TEST2(dView->CountL(), 5); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Clear duplicates for incoming sl@0: view->ClearDuplicatesL(); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: // Recent list should be unchanged sl@0: res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // No duplicates should exist for this view now sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(!res); sl@0: TEST2(dView->CountL(), 0); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Check outgoing is unchanged sl@0: res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(res); sl@0: TEST2(dView->CountL(), 5); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Check missed is unchanged sl@0: res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(res); sl@0: TEST2(dView->CountL(), 5); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Clear duplicates for missed sl@0: view->ClearDuplicatesL(); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: // Recent list should be unchanged sl@0: res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // No duplicates should exist for this view now sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(!res); sl@0: TEST2(dView->CountL(), 0); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Missed recent list should be unchanged sl@0: res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // No duplicates should exist for this view now sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(!res); sl@0: TEST2(dView->CountL(), 0); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Check outgoing is unchanged sl@0: res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(res); sl@0: TEST2(dView->CountL(), 5); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Clear duplicates for outgoing sl@0: view->ClearDuplicatesL(); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: // Recent list should be unchanged sl@0: res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // No duplicates should exist for this view now sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(!res); sl@0: TEST2(dView->CountL(), 0); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Missed recent list should be unchanged sl@0: res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // No duplicates should exist for this view now sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(!res); sl@0: TEST2(dView->CountL(), 0); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Check outgoing is unchanged sl@0: res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus); sl@0: TEST(res); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // No duplicates should exist for this view now sl@0: res = view->DuplicatesL(*dView, active->iStatus); sl@0: TEST(!res); sl@0: TEST2(dView->CountL(), 0); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: CleanupStack::PopAndDestroy(4); // event, dView, view, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0865 sl@0: @SYMTestCaseDesc Test for the functionality of CLogViewEvent class sl@0: @SYMTestPriority High sl@0: @SYMTestActions Set an event with a number,add the event to the client.Tests for matching a number from the view sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestPhoneNumberMatchingL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0865 ")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: TBuf missed; sl@0: aClient.GetString(missed, R_LOG_DIR_MISSED); sl@0: event->SetDirection(missed); sl@0: sl@0: TLogString number; sl@0: TInt i; sl@0: for(i = 0; i < 10; i++) sl@0: { sl@0: TBuf<1> digit; sl@0: digit.Num(i); sl@0: number.Insert(0, digit); sl@0: event->SetNumber(number); sl@0: sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: TBool res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->CountL(), 10); sl@0: sl@0: number.Zero(); sl@0: for(i = 0; i < 10; i++) sl@0: { sl@0: TBuf<1> digit; sl@0: digit.Num(i); sl@0: number.Insert(0, digit); sl@0: filter->SetNumber(number); sl@0: sl@0: // This is testing phone number matching sl@0: res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Phone numbers with KTestLogNumberCharsToMatch characters or above can match with each other sl@0: TEST2(view->CountL(), (number.Length() < KTestLogNumberCharsToMatch) ? 1 : 11-KTestLogNumberCharsToMatch); sl@0: } sl@0: sl@0: CLogViewRecent* recent = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(recent); sl@0: sl@0: CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient); sl@0: CleanupStack::PushL(duplicate); sl@0: sl@0: res = recent->SetRecentListL(KLogRecentMissedCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(recent->CountL(), KTestLogNumberCharsToMatch); sl@0: sl@0: res = recent->DuplicatesL(*duplicate, active->iStatus); sl@0: TEST(res); sl@0: TEST2(duplicate->CountL(), 10-KTestLogNumberCharsToMatch); sl@0: sl@0: // Check the first recent event has duplicates sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TPtrC number1(recent->Event().Number().Right(KTestLogNumberCharsToMatch)); sl@0: TPtrC number2(duplicate->Event().Number().Right(KTestLogNumberCharsToMatch)); sl@0: TEST(number1 == number2); sl@0: } sl@0: while(duplicate->NextL(active->iStatus)); sl@0: sl@0: // Check none of the others have duplicates sl@0: while(recent->NextL(active->iStatus)) sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: res = recent->DuplicatesL(*duplicate, active->iStatus); sl@0: TEST(!res); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(6); // duplicate, recent, view, filter, event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-3472 sl@0: @SYMTestCaseDesc Tests duplicate number matching correctly compares and matches the last 9 digits sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create and add several numbers to client, check that duplicates are correctly removed sl@0: @SYMTestExpectedResults Number with the same last 9 digits should get matched as duplicates sl@0: @SYMDEF INC105010 sl@0: */ sl@0: LOCAL_C void INC105010L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-3472 ")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: TBuf missed; sl@0: aClient.GetString(missed, R_LOG_DIR_MISSED); sl@0: event->SetDirection(missed); sl@0: sl@0: _LIT(KTestNumber1, "0401234567"); // unique sl@0: _LIT(KTestNumber2, "0421234567"); // unique sl@0: _LIT(KTestNumber3, "0521234567"); // unique sl@0: _LIT(KTestNumber4, "9521234567"); // duplicate sl@0: _LIT(KTestNumber5, "9521234567"); // duplicate sl@0: sl@0: TLogString number; sl@0: sl@0: // add events for the above numbers sl@0: event->SetNumber(KTestNumber1); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: event->SetNumber(KTestNumber2); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: event->SetNumber(KTestNumber3); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: event->SetNumber(KTestNumber4); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: event->SetNumber(KTestNumber5); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: // check 5 entries in log sl@0: TBool res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->CountL(), 5); sl@0: sl@0: CLogViewRecent* recent = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(recent); sl@0: sl@0: CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient); sl@0: CleanupStack::PushL(duplicate); sl@0: sl@0: // check only 3 entries in recent calls view sl@0: res = recent->SetRecentListL(KLogRecentMissedCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TInt rrr = recent->CountL(); sl@0: TEST2(recent->CountL(), 3); sl@0: sl@0: // and that there are 2 duplicates sl@0: res = recent->DuplicatesL(*duplicate, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TInt ddd = duplicate->CountL(); sl@0: TEST2(duplicate->CountL(), 2); sl@0: sl@0: CleanupStack::PopAndDestroy(6); sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0866 sl@0: @SYMTestCaseDesc Tests for CLogViewEvent::SetFlagsL() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Add events to the log and set the flags.Check if all the flags are set. sl@0: Clear all the flags and set half view of the flags.Check if only all view of the flags are set. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestRecentFlagsL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0866 ")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewRecent* view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: // Incoming sl@0: TBuf buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: sl@0: TInt count; sl@0: for(count = 0; count < KTestEventNum; count++) sl@0: { sl@0: event->SetContact(count); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: sl@0: TEST2(view->CountL(), 0); sl@0: TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: // Set all flags in view sl@0: const TLogFlags KAllFlagsSet = 15; // (BIN) 1,1,1,1 sl@0: view->SetFlagsL(KAllFlagsSet); sl@0: sl@0: // Check we can move to the first record sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: sl@0: // Check all flags are now set sl@0: count = KTestEventNum; sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: TEST2(view->RecentList(), KLogRecentIncomingCalls); sl@0: // sl@0: const TLogFlags flags = view->Event().Flags(); sl@0: TEST2(flags, KAllFlagsSet); sl@0: count--; sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: TEST2(count, 0); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: // Clear all flags in view sl@0: const TLogFlags KAllFlagsCleared = 0; // (BIN) 0,0,0,0 sl@0: view->SetFlagsL(KAllFlagsCleared); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: // Check we can move to the first record sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: sl@0: // Check all flags are now set sl@0: count = KTestEventNum; sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: TEST2(view->RecentList(), KLogRecentIncomingCalls); sl@0: // sl@0: const TLogFlags flags = view->Event().Flags(); sl@0: TEST2(flags, KAllFlagsCleared); sl@0: count--; sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: TEST2(count, 0); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: // Set lower half flags in view sl@0: const TLogFlags KLowerHalfFlagsSet = 3; // (BIN) 1,1,0,0 sl@0: view->SetFlagsL(KLowerHalfFlagsSet); sl@0: sl@0: // Check we can move to the first record sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: sl@0: // Check all flags are now set sl@0: count = KTestEventNum; sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: TEST2(view->RecentList(), KLogRecentIncomingCalls); sl@0: // sl@0: const TLogFlags flags = view->Event().Flags(); sl@0: TEST2(flags, KLowerHalfFlagsSet); sl@0: count--; sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: TEST2(count, 0); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: CleanupStack::PopAndDestroy(3, event); // view, active, event sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0867 sl@0: @SYMTestCaseDesc Tests for CLogViewEvent::SetFlagsL() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Add events to the log and set the flags.Check if flags for only the events in view are set. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestViewFlagsL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0867 ")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: // Incoming sl@0: TBuf buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: sl@0: event->SetNumber(_L("123")); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TLogId testId = event->Id(); sl@0: event->SetNumber(KNullDesC); sl@0: TheTest.Printf(_L(" Event flags: 0x%X\r\n"), event->Flags()); sl@0: sl@0: TInt count; sl@0: for(count = 0; count < KTestEventNum; count++) sl@0: { sl@0: event->SetContact(count + 1); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: sl@0: TEST2(view->CountL(), 0); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetNullFields(ELogNumberField); sl@0: sl@0: TEST2(view->CountL(), 0); sl@0: TBool res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: // Set all flags in view sl@0: const TLogFlags KAllFlagsSet = 15; // (BIN) 1,1,1,1 sl@0: view->SetFlagsL(KAllFlagsSet); sl@0: sl@0: // Check flags only set for events in the view sl@0: active->StartL(); sl@0: event->SetId(testId); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: if( TheMatchingIsEnabled) sl@0: {//This check will fail if the first AddEvent() call in this function didn't perform contact matching sl@0: TEST2(event->Flags(), KLogEventContactSearched); sl@0: } sl@0: else sl@0: { sl@0: TEST2(event->Flags(), 0); sl@0: } sl@0: sl@0: // Check we can move to the first record sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: sl@0: // Check all flags are now set sl@0: count = KTestEventNum; sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: // sl@0: const TLogFlags flags = view->Event().Flags(); sl@0: TEST2(flags, KAllFlagsSet); sl@0: count--; sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: TEST2(count, 0); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: // Clear all flags in view sl@0: const TLogFlags KAllFlagsCleared = 0; // (BIN) 0,0,0,0 sl@0: view->SetFlagsL(KAllFlagsCleared); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: // Check flags only set for events in the view sl@0: active->StartL(); sl@0: event->SetId(testId); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: if( TheMatchingIsEnabled) sl@0: { sl@0: TEST2(event->Flags(), KLogEventContactSearched); sl@0: } sl@0: else sl@0: { sl@0: TEST2(event->Flags(), 0); sl@0: } sl@0: sl@0: // Check we can move to the first record sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: sl@0: // Check all flags are now set sl@0: count = KTestEventNum; sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: // sl@0: const TLogFlags flags = view->Event().Flags(); sl@0: TEST2(flags, KAllFlagsCleared); sl@0: count--; sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: TEST2(count, 0); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: // Set lower half flags in view sl@0: const TLogFlags KLowerHalfFlagsSet = 3; // (BIN) 1,1,0,0 sl@0: view->SetFlagsL(KLowerHalfFlagsSet); sl@0: sl@0: // Check flags only set for events in the view sl@0: active->StartL(); sl@0: event->SetId(testId); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: if( TheMatchingIsEnabled) sl@0: { sl@0: TEST2(event->Flags(), KLogEventContactSearched); sl@0: } sl@0: else sl@0: { sl@0: TEST2(event->Flags(), 0); sl@0: } sl@0: sl@0: // Check we can move to the first record sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: sl@0: // Check all flags are now set sl@0: count = KTestEventNum; sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: // sl@0: const TLogFlags flags = view->Event().Flags(); sl@0: TEST2(flags, KLowerHalfFlagsSet); sl@0: count--; sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: TEST2(count, 0); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: sl@0: CleanupStack::PopAndDestroy(4, event); // filter, view, active, event sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0868 sl@0: @SYMTestCaseDesc Tests for CLogViewChangeObserver::HaveChanges(),Changes() functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Check for observing changes while adding and deleting events sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestViewChangeEvents1L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0868 ")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetContact(KTestContact); sl@0: filter->SetEventType(KLogPacketDataEventTypeUid); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); sl@0: changeObs->SetActive(); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); sl@0: CleanupStack::PushL(view); sl@0: sl@0: // Incoming sl@0: TBuf buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogPacketDataEventTypeUid); sl@0: event->SetDirection(buf); sl@0: event->SetContact(KTestContact); sl@0: sl@0: TInt i; sl@0: TInt count; sl@0: for(count = 0; count < KTestEventNum; count++) sl@0: { sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: User::After(1 * 1000000); sl@0: } sl@0: // sl@0: TEST2(view->CountL(), 0); sl@0: active->StartL(); sl@0: TBool res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: // sl@0: count = KTestEventNum; sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: const TLogId eventId = view->Event().Id(); sl@0: TLogId id = --count; sl@0: TEST2(eventId, id); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Transients sl@0: TInt changeCount; sl@0: TLogId logId; sl@0: TInt viewIndex; sl@0: TLogDatabaseChangeType type; sl@0: CLogChangeDefinition* changes; sl@0: sl@0: // Add an event and check for changes sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: changes = changeObs->WaitForChangesLC(); sl@0: if (active->IsActive()) sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum+1); sl@0: sl@0: changeCount = changes->Count(); sl@0: for(i=0; iAt(i, logId, viewIndex); sl@0: TheTest.Printf(_L("Change Type: %d, logId: %d, viewIndex: %d\n"), type, logId, viewIndex); sl@0: } sl@0: sl@0: // Check the change was as expected sl@0: TEST2(changes->Count(), 1); sl@0: type = changes->At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(viewIndex, 0); // first (newest) event in the view sl@0: { sl@0: const TLogId expectedLogId = ((TLogId) KTestEventNum); sl@0: TEST2(logId, expectedLogId); sl@0: } sl@0: CleanupStack::PopAndDestroy(changes); sl@0: sl@0: // Check view navigation sl@0: i=0; sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TheTest.Printf(_L("==\n")); sl@0: TEST2(i, count); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Delete some events sl@0: TEST(KTestEventNum >= 10); sl@0: changeObs->StartCollectingChanges(); sl@0: for(i=1; iStartL(); sl@0: aClient.DeleteEvent(TLogId(i), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 5); // 1,3,5,7,9 sl@0: for(i=0; iChanges().At(i, logId, viewIndex), ELogChangeTypeEventDeleted); sl@0: TEST2(logId, TLogId(2*i + 1)); sl@0: TEST2(viewIndex, 10 - ((2*i) + 1)); sl@0: } sl@0: sl@0: // Add a new event that shouldn't appear in the view sl@0: changeObs->StartCollectingChanges(); sl@0: event->SetContact(TLogContactItemId(0)); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 1 - 5); sl@0: TEST2(event->Id(), KTestEventNum + 1); sl@0: sl@0: // Check changes sl@0: TEST(!changeObs->HaveChanges()); sl@0: sl@0: // Check view navigation sl@0: i=0; sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TheTest.Printf(_L("==\n")); sl@0: TEST2(i, count); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Delete event which isn't in view sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(event->Id(), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 1 - 5); sl@0: sl@0: // Check changes sl@0: TEST(!changeObs->HaveChanges()); sl@0: sl@0: // Check view navigation sl@0: i=0; sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TheTest.Printf(_L("==\n")); sl@0: TEST2(i, count); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Add a new event again that shouldn't appear in the view sl@0: changeObs->StartCollectingChanges(); sl@0: event->SetContact(TLogContactItemId(0)); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 1 - 5); sl@0: TEST2(event->Id(), KTestEventNum + 2); sl@0: sl@0: // Check changes sl@0: TEST(!changeObs->HaveChanges()); sl@0: sl@0: // Check view navigation sl@0: i=0; sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TheTest.Printf(_L("==\n")); sl@0: TEST2(i, count); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Change event so that it appears in the view sl@0: changeObs->StartCollectingChanges(); sl@0: event->SetContact(KTestContact); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 2 - 5); sl@0: TEST2(event->Id(), KTestEventNum + 2); // Shouldn't change sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(logId, KTestEventNum + 2); sl@0: TEST2(viewIndex, 0); sl@0: sl@0: // Check view navigation sl@0: i=0; sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TheTest.Printf(_L("==\n")); sl@0: TEST2(i, count); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Simply change an event in the view sl@0: changeObs->StartCollectingChanges(); sl@0: event->SetDescription(_L("Test")); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 2 - 5); // Shouldn't change sl@0: TEST2(event->Id(), KTestEventNum + 2); // Shouldn't change sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventChanged); sl@0: TEST2(logId, KTestEventNum + 2); sl@0: TEST2(viewIndex, 0); sl@0: sl@0: // Change an event in the view so that it is deleted sl@0: changeObs->StartCollectingChanges(); sl@0: event->SetContact(0); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 2 - 5 - 1); // one less now sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, KTestEventNum + 2); sl@0: TEST2(viewIndex, 0); sl@0: sl@0: // Navigate part way through the view so we have sl@0: // a cursor position part way through... sl@0: i=0; sl@0: count = view->CountL(); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TheTest.Printf(_L("==\n")); sl@0: TEST2(i, count); sl@0: TEST2(view->Event().Id(), TLogId(0)); sl@0: sl@0: // Save id sl@0: TLogId savedId = view->Event().Id(); sl@0: sl@0: // Go one back sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Insert something sl@0: changeObs->StartCollectingChanges(); sl@0: event->SetContact(KTestContact); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 2 - 5); // one more now sl@0: TEST2(event->Id(), KTestEventNum + 3); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(logId, KTestEventNum + 3); sl@0: TEST2(viewIndex, 0); sl@0: sl@0: // Check we can still go forward to the last record sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), savedId); sl@0: sl@0: // Go one back sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Delete current record sl@0: savedId = view->Event().Id(); sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(savedId, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 2 - 5 - 1); // one less sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, savedId); sl@0: TEST2(viewIndex, KTestEventNum + 2 - 5 - 2); // last but one event sl@0: sl@0: // Check we're now at the end of the view sl@0: res = view->NextL(active->iStatus); sl@0: TEST(!res); sl@0: sl@0: // Go to the first record sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Delete the first record sl@0: savedId = view->Event().Id(); sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(savedId, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum - 5); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, savedId); sl@0: TEST2(viewIndex, 0); // first item sl@0: sl@0: // Check 'next' navigation can be performed correctly sl@0: count = 0; sl@0: view->NextL(active->iStatus); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: ++count; sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TEST2(count, KTestEventNum - 5 - 1); sl@0: sl@0: // Check last record sl@0: savedId = view->Event().Id(); sl@0: res = view->LastL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(savedId, view->Event().Id()); sl@0: sl@0: // Delete the last record sl@0: savedId = view->Event().Id(); sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(savedId, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum - 6); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, savedId); sl@0: TEST2(viewIndex, count); // There's now one less item, and we deleted the last item of the previous view sl@0: sl@0: // Check we're still at the end of the view sl@0: res = view->NextL(active->iStatus); sl@0: TEST(!res); sl@0: sl@0: CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event sl@0: } sl@0: sl@0: CBaBackupSessionWrapper* theBackup = NULL; sl@0: sl@0: LOCAL_C TBool IsLogOpenL() sl@0: { sl@0: return TestUtils::IsDatabaseOpenL(); sl@0: } sl@0: sl@0: LOCAL_C void TestLogOpenL() sl@0: { sl@0: TEST(IsLogOpenL()); sl@0: } sl@0: sl@0: LOCAL_C void TestLogClosedL() sl@0: { sl@0: TEST(!IsLogOpenL()); sl@0: } sl@0: sl@0: LOCAL_C void StartBackupL() sl@0: { sl@0: User::InfoPrint(_L("Backup")); sl@0: sl@0: TDriveUnit driveUnit(EDriveC); sl@0: TDriveName name = driveUnit.Name(); sl@0: sl@0: TParse parse; sl@0: LEAVE_IF_ERROR(parse.Set(KLogDatabaseName, &name, NULL)); sl@0: sl@0: delete theBackup; sl@0: theBackup = NULL; sl@0: theBackup = CBaBackupSessionWrapper::NewL(); sl@0: sl@0: theBackup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess); sl@0: User::After(1000000); sl@0: } sl@0: sl@0: LOCAL_C void EndBackupL() sl@0: { sl@0: delete theBackup; sl@0: theBackup = NULL; sl@0: User::After(1000000); sl@0: } sl@0: sl@0: LOCAL_C void DelayL(TInt aDelay) sl@0: { sl@0: CTestTimer* timer = CTestTimer::NewL(); sl@0: timer->After(aDelay); sl@0: CActiveScheduler::Start(); sl@0: delete timer; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0869 sl@0: @SYMTestCaseDesc Tests for CLogViewChangeObserver::HaveChanges(),CLogViewChangeObserver::Changes() functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Check for observing changes while adding,deleting events.Check for observing changes after a backup. sl@0: Check for navigating the view.Test for KErrNone condition. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestViewChangeEvents1aL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0869 ")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetContact(KTestContact); sl@0: filter->SetEventType(KLogPacketDataEventTypeUid); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); sl@0: changeObs->SetActive(); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); sl@0: CleanupStack::PushL(view); sl@0: sl@0: // Incoming sl@0: TBuf buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogPacketDataEventTypeUid); sl@0: event->SetDirection(buf); sl@0: event->SetContact(KTestContact); sl@0: sl@0: TInt i; sl@0: TInt count; sl@0: for(count = 0; count < KTestEventNum; count++) sl@0: { sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: User::After(1 * 1000000); sl@0: } sl@0: // sl@0: TEST2(view->CountL(), 0); sl@0: active->StartL(); sl@0: TEST(view->SetFilterL(*filter, active->iStatus)); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: // sl@0: count = KTestEventNum; sl@0: TEST(view->FirstL(active->iStatus)); sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: TEST2(view->CountL(), KTestEventNum); sl@0: const TLogId eventId = view->Event().Id(); sl@0: TEST2(eventId, (TLogId)--count); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Transients sl@0: TInt changeCount; sl@0: TLogId logId; sl@0: TInt viewIndex; sl@0: TLogDatabaseChangeType type; sl@0: CLogChangeDefinition* changes; sl@0: sl@0: // Add an event and check for changes sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: changes = changeObs->WaitForChangesLC(); sl@0: if (active->IsActive()) sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum+1); sl@0: sl@0: changeCount = changes->Count(); sl@0: for(i=0; iAt(i, logId, viewIndex); sl@0: TheTest.Printf(_L("Change Type: %d, logId: %d, viewIndex: %d"), type, logId, viewIndex); sl@0: } sl@0: sl@0: // Check the change was as expected sl@0: TEST2(changes->Count(), 1); sl@0: type = changes->At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(viewIndex, 0); // first (newest) event in the view sl@0: { sl@0: const TLogId expectedLogId = ((TLogId) KTestEventNum); sl@0: TEST2(logId, expectedLogId); sl@0: } sl@0: CleanupStack::PopAndDestroy(changes); sl@0: sl@0: // Check view navigation sl@0: i=0; sl@0: TEST(view->FirstL(active->iStatus)); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TheTest.Printf(_L("==\n")); sl@0: TEST2(i, count); sl@0: TEST(view->FirstL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that changes work after a backup sl@0: DelayL(1000000); sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // Delete some events sl@0: TEST(KTestEventNum >= 10); sl@0: changeObs->StartCollectingChanges(); sl@0: for(i=1; iStartL(); sl@0: aClient.DeleteEvent(TLogId(i), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 5); // 1,3,5,7,9 sl@0: for(i=0; iChanges().At(i, logId, viewIndex), ELogChangeTypeEventDeleted); sl@0: TEST2(logId, TLogId(2*i + 1)); sl@0: TEST2(viewIndex, 10 - ((2*i) + 1)); sl@0: } sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // Add a new event that shouldn't appear in the view sl@0: changeObs->StartCollectingChanges(); sl@0: event->SetContact(TLogContactItemId(0)); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 1 - 5); sl@0: TEST2(event->Id(), KTestEventNum + 1); sl@0: sl@0: // Check changes sl@0: TEST(!changeObs->HaveChanges()); sl@0: sl@0: // Check view navigation sl@0: i=0; sl@0: TEST(view->FirstL(active->iStatus)); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TheTest.Printf(_L("==\n")); sl@0: TEST2(i, count); sl@0: TEST(view->FirstL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // Delete event which isn't in view sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(event->Id(), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 1 - 5); sl@0: sl@0: // Check changes sl@0: TEST(!changeObs->HaveChanges()); sl@0: sl@0: // Check view navigation sl@0: i=0; sl@0: TEST(view->FirstL(active->iStatus)); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TheTest.Printf(_L("==\n")); sl@0: TEST2(i, count); sl@0: TEST(view->FirstL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // Add a new event again that shouldn't appear in the view sl@0: changeObs->StartCollectingChanges(); sl@0: event->SetContact(TLogContactItemId(0)); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 1 - 5); sl@0: TEST2(event->Id(), KTestEventNum + 2); sl@0: sl@0: // Check changes sl@0: TEST(!changeObs->HaveChanges()); sl@0: sl@0: // Check view navigation sl@0: i=0; sl@0: TEST(view->FirstL(active->iStatus)); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TheTest.Printf(_L("==\n")); sl@0: TEST2(i, count); sl@0: TEST(view->FirstL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // Change event so that it appears in the view sl@0: changeObs->StartCollectingChanges(); sl@0: event->SetContact(KTestContact); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 2 - 5); sl@0: TEST2(event->Id(), KTestEventNum + 2); // Shouldn't change sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(logId, KTestEventNum + 2); sl@0: TEST2(viewIndex, 0); sl@0: sl@0: // Check view navigation sl@0: i=0; sl@0: TEST(view->FirstL(active->iStatus)); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TheTest.Printf(_L("==\n")); sl@0: TEST2(i, count); sl@0: TEST(view->FirstL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // Simply change an event in the view sl@0: changeObs->StartCollectingChanges(); sl@0: event->SetDescription(_L("Test")); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 2 - 5); // Shouldn't change sl@0: TEST2(event->Id(), KTestEventNum + 2); // Shouldn't change sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventChanged); sl@0: TEST2(logId, KTestEventNum + 2); sl@0: TEST2(viewIndex, 0); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // Change an event in the view so that it is deleted sl@0: changeObs->StartCollectingChanges(); sl@0: event->SetContact(0); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 2 - 5 - 1); // one less now sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, KTestEventNum + 2); sl@0: TEST2(viewIndex, 0); sl@0: sl@0: // Navigate part way through the view so we have sl@0: // a cursor position part way through... sl@0: i=0; sl@0: count = view->CountL(); sl@0: TEST(view->FirstL(active->iStatus)); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TheTest.Printf(_L("==\n")); sl@0: TEST2(i, count); sl@0: TEST2(view->Event().Id(), TLogId(0)); sl@0: sl@0: // Save id sl@0: TLogId savedId = view->Event().Id(); sl@0: sl@0: // Go one back sl@0: TEST(view->PreviousL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // Insert something sl@0: changeObs->StartCollectingChanges(); sl@0: event->SetContact(KTestContact); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 2 - 5); // one more now sl@0: TEST2(event->Id(), KTestEventNum + 3); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(logId, KTestEventNum + 3); sl@0: TEST2(viewIndex, 0); sl@0: sl@0: // Check we can still go forward to the last record sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), savedId); sl@0: sl@0: // Go one back sl@0: TEST(view->PreviousL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // Delete current record sl@0: savedId = view->Event().Id(); sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(savedId, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum + 2 - 5 - 1); // one less sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, savedId); sl@0: TEST2(viewIndex, KTestEventNum + 2 - 5 - 2); // last but one event sl@0: sl@0: // Check we're now at the end of the view sl@0: TEST(!view->NextL(active->iStatus)); sl@0: sl@0: // Go to the first record sl@0: TEST(view->FirstL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // Delete the first record sl@0: savedId = view->Event().Id(); sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(savedId, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum - 5); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, savedId); sl@0: TEST2(viewIndex, 0); // first item sl@0: sl@0: // Check 'next' navigation can be performed correctly sl@0: count = 0; sl@0: view->NextL(active->iStatus); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: ++count; sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: TEST2(count, KTestEventNum - 5 - 1); sl@0: sl@0: // Check last record sl@0: savedId = view->Event().Id(); sl@0: TEST(view->LastL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(savedId, view->Event().Id()); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // Delete the last record sl@0: savedId = view->Event().Id(); sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(savedId, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KTestEventNum - 6); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, savedId); sl@0: TEST2(viewIndex, count); // There's now one less item, and we deleted the last item of the previous view sl@0: sl@0: // Check we're still at the end of the view sl@0: TEST(!view->NextL(active->iStatus)); sl@0: sl@0: CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0870 sl@0: @SYMTestCaseDesc Tests for CLogViewChangeObserver::HaveChanges(),Changes() functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Check for observing changes while adding,deleting events.Check for observing changes after a backup. sl@0: Check for observing changes while traversing through the events in the view. sl@0: Delete everything in the view and make sure we can't navigate anymore. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestViewChangeEvents2L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0870 ")); sl@0: // Transients sl@0: TInt i=0; sl@0: TInt count; sl@0: TBuf<1> description; description.SetLength(1); sl@0: TInt changeCount; sl@0: TLogId logId; sl@0: TInt viewIndex; sl@0: TLogDatabaseChangeType type; sl@0: TLogId runningNewId = 0; sl@0: // sl@0: const TInt KChangeEventTest2NumberOfEventsInView = 7; sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetContact(KTestContact); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); sl@0: changeObs->SetActive(); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); sl@0: CleanupStack::PushL(view); sl@0: sl@0: // Add seed events sl@0: TBuf buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogPacketDataEventTypeUid); sl@0: event->SetDirection(buf); sl@0: // sl@0: for(count = 0; count < KChangeEventTest2NumberOfEventsInView; count++) sl@0: { sl@0: // Have to create one event which isn't in the view by default, but sl@0: // when it 'appears' will be part way through sl@0: if (count == 3 && description[0] != TUint16('Z')) sl@0: { sl@0: description[0] = TUint16('Z'); sl@0: event->SetContact(0); sl@0: sl@0: // Go back and do this one again but with a real view entry this time, i.e. 'D' sl@0: --count; sl@0: } sl@0: else sl@0: { sl@0: description[0] = TUint16('A' + KChangeEventTest2NumberOfEventsInView - count); sl@0: event->SetContact(KTestContact); sl@0: } sl@0: event->SetDescription(description); sl@0: // sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(event->Id(), runningNewId++); sl@0: User::After(1 * 1000000); sl@0: } sl@0: // sl@0: TEST2(view->CountL(), 0); sl@0: active->StartL(); sl@0: TBool res =view->SetFilterL(*filter, active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView); sl@0: sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Check addition change events sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0 sl@0: TEST2(view->Event().Id(), 7); sl@0: sl@0: // Add a new entry - should appear as the first item in the view sl@0: description[0] = TUint16('X'); sl@0: event->SetDescription(description); sl@0: // sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(event->Id(), runningNewId++); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(logId, runningNewId-1); sl@0: TEST2(viewIndex, 0); // 8, [7], 6, 5, 4, 2, 1, 0 sl@0: sl@0: // Check we can go forward sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(6)); // 8, 7, [6], 5, 4, 2, 1, 0 sl@0: sl@0: // Check we can now go back (new first entry) sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); // 8, [7], 6, 5, 4, 2, 1, 0 sl@0: TEST2(view->Event().Id(), 7); sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); // [8], 7, 6, 5, 4, 2, 1, 0 sl@0: TEST2(view->Event().Id(), TLogId(KChangeEventTest2NumberOfEventsInView+1)); sl@0: sl@0: // Delete added event sl@0: changeObs->ResetChanges(); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 0); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(view->Event().Id(), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0 sl@0: sl@0: // Check deletion changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, runningNewId-1); sl@0: TEST2(viewIndex, 0); sl@0: sl@0: // Go to end of view sl@0: res = view->LastL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0] sl@0: sl@0: // Add new event sl@0: description[0] = TUint16('X'); sl@0: event->SetDescription(description); sl@0: // sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(event->Id(), runningNewId++); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(logId, runningNewId-1); sl@0: TEST2(viewIndex, 0); // 9, 7, 6, 5, 4, 2, 1, [0] sl@0: sl@0: // Check we can't go forward sl@0: res = view->NextL(active->iStatus); sl@0: TEST(!res); sl@0: sl@0: // Go back to the first record sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(runningNewId-1)); // 9, 7, 6, 5, 4, 2, 1, [0] sl@0: sl@0: // Delete added event sl@0: changeObs->ResetChanges(); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(view->Event().Id(), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0 sl@0: sl@0: // Check deletion changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, runningNewId-1); sl@0: TEST2(viewIndex, 0); sl@0: sl@0: // Go part way through view sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0 sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 2, 1, 0 sl@0: sl@0: // Add new event sl@0: description[0] = TUint16('X'); sl@0: event->SetDescription(description); sl@0: // sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(event->Id(), runningNewId++); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(logId, runningNewId-1); sl@0: TEST2(viewIndex, 0); // 10, 7, 6, [5], 4, 2, 1, 0 sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Work back to beginning sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(6)); // 10, 7, [6], 5, 4, 2, 1, 0 sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(7)); // 10, [7], 6, 5, 4, 2, 1, 0 sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), runningNewId-1); // [10], 7, 6, 5, 4, 2, 1, 0 sl@0: sl@0: // Delete added event sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 0); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(view->Event().Id(), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0 sl@0: sl@0: // Check deletion changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, runningNewId-1); sl@0: TEST2(viewIndex, 0); sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Go back to the first record sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(7)); // [7], 6, 5, 4, 2, 1, 0 sl@0: sl@0: // Move one record forward sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0 sl@0: sl@0: // Change 'Z' event so that it now appears in the view sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 0); sl@0: active->StartL(); sl@0: event->SetId(TLogId(3)); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: event->SetContact(KTestContact); sl@0: active->StartL(); sl@0: changeObs->StartCollectingChanges(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView+1); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view sl@0: TEST2(logId, TLogId(3)); sl@0: TEST2(viewIndex, 4); // 7, [6], 5, 4, 3, 2, 1, 0 sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Move forwards and check sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 3, 2, 1, 0 sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0 sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0 sl@0: sl@0: // Change 'Z' event so that its now missing from the view again sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 0); sl@0: active->StartL(); sl@0: event->SetId(TLogId(3)); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: event->SetContact(0); sl@0: active->StartL(); sl@0: changeObs->StartCollectingChanges(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(3)); sl@0: TEST2(viewIndex, 4); // 7, 6, 5, 4, [2], 1, 0 sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Move forwards and check sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0 sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0] sl@0: sl@0: // Move back one sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0 sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 0); sl@0: sl@0: // Change 'Z' event so that it now appears in the view sl@0: active->StartL(); sl@0: event->SetId(TLogId(3)); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: event->SetContact(KTestContact); sl@0: active->StartL(); sl@0: changeObs->StartCollectingChanges(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView+1); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view sl@0: TEST2(logId, TLogId(3)); sl@0: TEST2(viewIndex, 4); // 7, 6, 5, 4, 3, 2, [1], 0 sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Check can only move forward one more record sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 3, 2, 1, [0] sl@0: sl@0: // Move back until we are before the inserted record sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 3, 2, [1], 0 sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, 3, [2], 1, 0 sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0 sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0 sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 0); sl@0: sl@0: // Change 'Z' event so that its now missing from the view again sl@0: active->StartL(); sl@0: event->SetId(TLogId(3)); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: event->SetContact(0); sl@0: active->StartL(); sl@0: changeObs->StartCollectingChanges(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(3)); sl@0: TEST2(viewIndex, 4); // 7, 6, 5, [4], 2, 1, 0 sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Check navigating to the end of the view sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, [2], 1, 0 sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0 sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0] sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 0); sl@0: res = view->NextL(active->iStatus); sl@0: TEST(!res); sl@0: sl@0: // Delete everything in the view and make sure we can't navigate anymore. sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(4), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 1); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(4)); sl@0: TEST2(viewIndex, 3); // 7, 6, 5, 2, 1, [0] sl@0: changeObs->ResetChanges(); sl@0: // sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(7), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 2); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(7)); sl@0: TEST2(viewIndex, 0); // 6, 5, 2, 1, [0] sl@0: changeObs->ResetChanges(); sl@0: // sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(0), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 3); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(0)); sl@0: TEST2(viewIndex, 4); // 6, 5, 2, [1] sl@0: changeObs->ResetChanges(); sl@0: // sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(5), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 4); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(5)); sl@0: TEST2(viewIndex, 1); // 6, 2, [1] sl@0: changeObs->ResetChanges(); sl@0: // sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(2), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 5); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(2)); sl@0: TEST2(viewIndex, 1); // 6, [1] sl@0: changeObs->ResetChanges(); sl@0: // sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(6), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 6); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(6)); sl@0: TEST2(viewIndex, 0); // [1] sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Check we can't go backwards or forwards sl@0: res = view->NextL(active->iStatus); sl@0: TEST(!res); sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(!res); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(1)); // [1] sl@0: res = view->LastL(active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(1)); // [1] sl@0: sl@0: // Delete last event in view sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(1), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 7); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(1)); sl@0: TEST2(viewIndex, 0); // *Empty* sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Check we can't navigate sl@0: res = view->NextL(active->iStatus); sl@0: TEST(!res); sl@0: res = view->PreviousL(active->iStatus); sl@0: TEST(!res); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(!res); sl@0: res = view->LastL(active->iStatus); sl@0: TEST(!res); sl@0: sl@0: CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0871 sl@0: @SYMTestCaseDesc Tests for CLogViewChangeObserver::HaveChanges(),Changes() functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Check for observing changes while adding,deleting events.Check for observing changes after a backup. sl@0: Check for observing changes while traversing through the events in the view. sl@0: Delete everything in the view and make sure we can't navigate anymore. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestViewChangeEvents2aL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0871 ")); sl@0: // Transients sl@0: TInt i=0; sl@0: TInt count; sl@0: TBuf<1> description; description.SetLength(1); sl@0: TInt changeCount; sl@0: TLogId logId; sl@0: TInt viewIndex; sl@0: TLogDatabaseChangeType type; sl@0: TLogId runningNewId = 0; sl@0: // sl@0: const TInt KChangeEventTest2NumberOfEventsInView = 7; sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetContact(KTestContact); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); sl@0: changeObs->SetActive(); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); sl@0: CleanupStack::PushL(view); sl@0: sl@0: // Add seed events sl@0: TBuf buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogPacketDataEventTypeUid); sl@0: event->SetDirection(buf); sl@0: // sl@0: for(count = 0; count < KChangeEventTest2NumberOfEventsInView; count++) sl@0: { sl@0: // Have to create one event which isn't in the view by default, but sl@0: // when it 'appears' will be part way through sl@0: if (count == 3 && description[0] != TUint16('Z')) sl@0: { sl@0: description[0] = TUint16('Z'); sl@0: event->SetContact(0); sl@0: sl@0: // Go back and do this one again but with a real view entry this time, i.e. 'D' sl@0: --count; sl@0: } sl@0: else sl@0: { sl@0: description[0] = TUint16('A' + KChangeEventTest2NumberOfEventsInView - count); sl@0: event->SetContact(KTestContact); sl@0: } sl@0: event->SetDescription(description); sl@0: // sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(event->Id(), runningNewId++); sl@0: User::After(1 * 1000000); sl@0: } sl@0: // sl@0: TEST2(view->CountL(), 0); sl@0: active->StartL(); sl@0: TEST(view->SetFilterL(*filter, active->iStatus)); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView); sl@0: sl@0: sl@0: TEST(view->FirstL(active->iStatus)); sl@0: do sl@0: { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id()); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: // Check addition change events sl@0: TEST(view->FirstL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0 sl@0: TEST2(view->Event().Id(), 7); sl@0: sl@0: // Add a new entry - should appear as the first item in the view sl@0: description[0] = TUint16('X'); sl@0: event->SetDescription(description); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(event->Id(), runningNewId++); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(logId, runningNewId-1); sl@0: TEST2(viewIndex, 0); // 8, [7], 6, 5, 4, 2, 1, 0 sl@0: sl@0: // Check we can go forward sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(6)); // 8, 7, [6], 5, 4, 2, 1, 0 sl@0: sl@0: // Check we can now go back (new first entry) sl@0: TEST(view->PreviousL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); // 8, [7], 6, 5, 4, 2, 1, 0 sl@0: TEST2(view->Event().Id(), 7); sl@0: TEST(view->PreviousL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); // [8], 7, 6, 5, 4, 2, 1, 0 sl@0: TEST2(view->Event().Id(), TLogId(KChangeEventTest2NumberOfEventsInView+1)); sl@0: sl@0: // Delete added event sl@0: changeObs->ResetChanges(); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 0); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(view->Event().Id(), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0 sl@0: sl@0: // Check deletion changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, runningNewId-1); sl@0: TEST2(viewIndex, 0); sl@0: sl@0: // Go to end of view sl@0: TEST(view->LastL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0] sl@0: sl@0: // Add new event sl@0: description[0] = TUint16('X'); sl@0: event->SetDescription(description); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(event->Id(), runningNewId++); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(logId, runningNewId-1); sl@0: TEST2(viewIndex, 0); // 9, 7, 6, 5, 4, 2, 1, [0] sl@0: sl@0: // Check we can't go forward sl@0: TEST(!view->NextL(active->iStatus)); sl@0: sl@0: // Go back to the first record sl@0: TEST(view->FirstL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(runningNewId-1)); // 9, 7, 6, 5, 4, 2, 1, [0] sl@0: sl@0: // Delete added event sl@0: changeObs->ResetChanges(); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(view->Event().Id(), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0 sl@0: sl@0: // Check deletion changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, runningNewId-1); sl@0: TEST2(viewIndex, 0); sl@0: sl@0: // Go part way through view sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0 sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 2, 1, 0 sl@0: sl@0: // Add new event sl@0: description[0] = TUint16('X'); sl@0: event->SetDescription(description); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: // sl@0: changeObs->StartCollectingChanges(); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(event->Id(), runningNewId++); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(logId, runningNewId-1); sl@0: TEST2(viewIndex, 0); // 10, 7, 6, [5], 4, 2, 1, 0 sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Work back to beginning sl@0: TEST(view->PreviousL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(6)); // 10, 7, [6], 5, 4, 2, 1, 0 sl@0: TEST(view->PreviousL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(7)); // 10, [7], 6, 5, 4, 2, 1, 0 sl@0: TEST(view->PreviousL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), runningNewId-1); // [10], 7, 6, 5, 4, 2, 1, 0 sl@0: sl@0: // Delete added event sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 0); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(view->Event().Id(), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0 sl@0: sl@0: // Check deletion changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); sl@0: TEST2(logId, runningNewId-1); sl@0: TEST2(viewIndex, 0); sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Go back to the first record sl@0: TEST(view->FirstL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(7)); // [7], 6, 5, 4, 2, 1, 0 sl@0: sl@0: // Move one record forward sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0 sl@0: sl@0: // Change 'Z' event so that it now appears in the view sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount ,0); sl@0: active->StartL(); sl@0: event->SetId(TLogId(3)); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: event->SetContact(KTestContact); sl@0: active->StartL(); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: changeObs->StartCollectingChanges(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView+1); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view sl@0: TEST2(logId, TLogId(3)); sl@0: TEST2(viewIndex, 4); // 7, [6], 5, 4, 3, 2, 1, 0 sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Move forwards and check sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 3, 2, 1, 0 sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0 sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0 sl@0: sl@0: // Change 'Z' event so that its now missing from the view again sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount ,0); sl@0: active->StartL(); sl@0: event->SetId(TLogId(3)); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: event->SetContact(0); sl@0: active->StartL(); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: changeObs->StartCollectingChanges(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(3)); sl@0: TEST2(viewIndex, 4); // 7, 6, 5, 4, [2], 1, 0 sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Move forwards and check sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0 sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0] sl@0: sl@0: // Move back one sl@0: TEST(view->PreviousL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0 sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount ,0); sl@0: sl@0: // Change 'Z' event so that it now appears in the view sl@0: active->StartL(); sl@0: event->SetId(TLogId(3)); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: event->SetContact(KTestContact); sl@0: active->StartL(); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: changeObs->StartCollectingChanges(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView+1); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view sl@0: TEST2(logId, TLogId(3)); sl@0: TEST2(viewIndex, 4); // 7, 6, 5, 4, 3, 2, [1], 0 sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Check can only move forward one more record sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 3, 2, 1, [0] sl@0: sl@0: // Move back until we are before the inserted record sl@0: TEST(view->PreviousL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 3, 2, [1], 0 sl@0: TEST(view->PreviousL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, 3, [2], 1, 0 sl@0: TEST(view->PreviousL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0 sl@0: TEST(view->PreviousL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0 sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount ,0); sl@0: sl@0: // Change 'Z' event so that its now missing from the view again sl@0: active->StartL(); sl@0: event->SetId(TLogId(3)); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: event->SetContact(0); sl@0: active->StartL(); sl@0: sl@0: // Check that changes work after a backup sl@0: StartBackupL(); sl@0: DelayL(1000000); sl@0: TestLogClosedL(); sl@0: EndBackupL(); sl@0: TestLogOpenL(); sl@0: sl@0: changeObs->StartCollectingChanges(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView); sl@0: sl@0: // Check changes sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(3)); sl@0: TEST2(viewIndex, 4); // 7, 6, 5, [4], 2, 1, 0 sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Check navigating to the end of the view sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, [2], 1, 0 sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0 sl@0: TEST(view->NextL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0] sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount ,0); sl@0: TEST(!view->NextL(active->iStatus)); sl@0: sl@0: // Delete everything in the view and make sure we can't navigate anymore. sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(4), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 1); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(4)); sl@0: TEST2(viewIndex, 3); // 7, 6, 5, 2, 1, [0] sl@0: changeObs->ResetChanges(); sl@0: // sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(7), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 2); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(7)); sl@0: TEST2(viewIndex, 0); // 6, 5, 2, 1, [0] sl@0: changeObs->ResetChanges(); sl@0: // sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(0), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 3); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(0)); sl@0: TEST2(viewIndex, 4); // 6, 5, 2, [1] sl@0: changeObs->ResetChanges(); sl@0: // sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(5), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 4); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(5)); sl@0: TEST2(viewIndex, 1); // 6, 2, [1] sl@0: changeObs->ResetChanges(); sl@0: // sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(2), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 5); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(2)); sl@0: TEST2(viewIndex, 1); // 6, [1] sl@0: changeObs->ResetChanges(); sl@0: // sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(6), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 6); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(6)); sl@0: TEST2(viewIndex, 0); // [1] sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Check we can't go backwards or forwards sl@0: TEST(!view->NextL(active->iStatus)); sl@0: TEST(!view->PreviousL(active->iStatus)); sl@0: TEST(view->FirstL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(1)); // [1] sl@0: TEST(view->LastL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->Event().Id(), TLogId(1)); // [1] sl@0: sl@0: // Delete last event in view sl@0: active->StartL(); sl@0: aClient.DeleteEvent(TLogId(1), active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, KChangeEventTest2NumberOfEventsInView - 7); sl@0: changeCount = changeObs->Changes().Count(); sl@0: TEST2(changeCount, 1); sl@0: type = changeObs->Changes().At(0, logId, viewIndex); sl@0: TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view sl@0: TEST2(logId, TLogId(1)); sl@0: TEST2(viewIndex, 0); // *Empty* sl@0: changeObs->ResetChanges(); sl@0: sl@0: // Check we can't navigate sl@0: TEST(!view->NextL(active->iStatus)); sl@0: TEST(!view->PreviousL(active->iStatus)); sl@0: TEST(!view->FirstL(active->iStatus)); sl@0: TEST(!view->LastL(active->iStatus)); sl@0: sl@0: CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0872 sl@0: @SYMTestCaseDesc Filtering log view test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Add the Voice call,FAX,SMS event types to the log client. sl@0: Set all the event types to filter list.Check for the correct event types and no errors sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestViewFilteringDefect1L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0872 ")); sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CTestActive* active = new(ELeave) CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: // VOICE CALL sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: const TLogId event1 = event->Id(); sl@0: sl@0: // FAX sl@0: event->SetEventType(KLogFaxEventTypeUid); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: const TLogId event2 = event->Id(); sl@0: (void) event2; sl@0: sl@0: // SMS, CONTACT SEARCHED sl@0: event->SetEventType(KLogShortMessageEventTypeUid); sl@0: event->SetFlags(KLogEventContactSearched); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: const TLogId event3 = event->Id(); sl@0: sl@0: CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); sl@0: changeObs->SetActive(); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogFilterList* filterList = new(ELeave) CLogFilterList(); sl@0: CleanupStack::PushL(filterList); sl@0: sl@0: CLogFilter* filter1 = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter1); sl@0: filter1->SetEventType(KLogCallEventTypeUid); // ALL VOICE CALL EVENTS sl@0: filterList->AppendL(filter1); sl@0: sl@0: CLogFilter* filter2 = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter2); sl@0: filter2->SetEventType(KLogShortMessageEventTypeUid); // ALL SMS's WHERE CONTACTS SEARCH FLAG IS SET sl@0: filter2->SetFlags(KLogEventContactSearched); sl@0: filterList->AppendL(filter2); sl@0: sl@0: TInt count = view->CountL(); sl@0: TEST2(count, 0); sl@0: TBool res = view->SetFilterParseFilterByFilterL(*filterList, active->iStatus); sl@0: TEST(res); sl@0: CleanupStack::PopAndDestroy(3, filterList); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: count = view->CountL(); sl@0: TEST2(count, 2); sl@0: sl@0: // Check correct events sl@0: TLogId eventId; sl@0: // sl@0: active->StartL(); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: eventId = view->Event().Id(); sl@0: TEST2(eventId, event3); sl@0: // sl@0: active->StartL(); sl@0: res = view->NextL(active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: eventId = view->Event().Id(); sl@0: TEST2(eventId, event1); sl@0: sl@0: CleanupStack::PopAndDestroy(4, event); sl@0: } sl@0: sl@0: // sl@0: // sl@0: // sl@0: static TInt TestDeletingViewWithinObserverCallbackL_CallbackFn(TAny* aView) sl@0: { sl@0: CLogViewEvent* view = reinterpret_cast(aView); sl@0: delete view; sl@0: return KErrNone; sl@0: } sl@0: sl@0: // sl@0: // sl@0: // sl@0: static void TestDeletingViewWithinObserverCallbackL_ThreadFunctionL() sl@0: { sl@0: RFs fsSession; sl@0: LEAVE_IF_ERROR(fsSession.Connect()); sl@0: CleanupClosePushL(fsSession); sl@0: // sl@0: CLogClient* client = CLogClient::NewL(fsSession); sl@0: CleanupStack::PushL(client); sl@0: // sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: // sl@0: CTestActive* active = new(ELeave) CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: // Wait for main test code thread sl@0: RSemaphore semaphore; sl@0: const TInt error = semaphore.OpenGlobal(KThreadSemaphoreName); sl@0: LEAVE_IF_ERROR(error); sl@0: sl@0: // Add 5 recent events to the list sl@0: TBuf incoming; sl@0: client->GetString(incoming, R_LOG_DIR_IN); sl@0: event->SetDirection(incoming); sl@0: sl@0: // Incoming sl@0: for(TInt recent = 1; recent <= 5; recent++) sl@0: { sl@0: event->SetContact(recent); sl@0: for(TInt duplicate = 1; duplicate <= 6; duplicate++) sl@0: { sl@0: active->StartL(); sl@0: client->AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 1)); sl@0: } sl@0: } sl@0: sl@0: // Wait now until the main thread says we can delete all events sl@0: semaphore.Signal(); sl@0: User::After(5 * 1000000); sl@0: semaphore.Wait(); sl@0: sl@0: // Clear the duplicates which should result in a batch of changes sl@0: // in the other thread sl@0: CLogViewRecent* view = CLogViewRecent::NewL(*client); sl@0: CleanupStack::PushL(view); sl@0: // sl@0: __ASSERT_ALWAYS(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus), User::Panic(_L("ThreadPanic"), 2)); sl@0: __ASSERT_ALWAYS(view->CountL() == 5, User::Panic(_L("ThreadPanic"), 3)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 4)); sl@0: sl@0: // Now do the clear sl@0: view->ClearDuplicatesL(); sl@0: __ASSERT_ALWAYS(view->CountL() == 5, User::Panic(_L("ThreadPanic"), 5)); sl@0: sl@0: // Cleanup sl@0: CleanupStack::PopAndDestroy(view); sl@0: semaphore.Close(); sl@0: CleanupStack::PopAndDestroy(4, &fsSession); // active, event, client, fsSession sl@0: } sl@0: sl@0: // sl@0: // sl@0: // sl@0: static TInt TestDeletingViewWithinObserverCallbackL_ThreadFunction(TAny* /*aData*/) sl@0: { sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: if (!cleanup) sl@0: return KErrNoMemory; sl@0: CActiveScheduler* scheduler = new CActiveScheduler(); sl@0: if (!scheduler) sl@0: return KErrNoMemory; sl@0: CActiveScheduler::Install(scheduler); sl@0: // sl@0: TRAPD(err, TestDeletingViewWithinObserverCallbackL_ThreadFunctionL()); sl@0: UNUSED_VAR(err); sl@0: // sl@0: delete scheduler; sl@0: delete cleanup; sl@0: // sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0873 sl@0: @SYMTestCaseDesc Tests for observing changes within a callback sl@0: @SYMTestPriority High sl@0: @SYMTestActions Check for observing changes within a callback sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDeletingViewWithinObserverCallbackL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0873 ")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: TInt error = 0; sl@0: // sl@0: CTestActive* active = new(ELeave) CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetEventType(KLogCallEventTypeUid); sl@0: TBool res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(!res); sl@0: CleanupStack::PopAndDestroy(filter); sl@0: sl@0: // Create semaphore so we can control other thread sl@0: RSemaphore semaphore; sl@0: error = semaphore.CreateGlobal(KThreadSemaphoreName, 0); sl@0: LEAVE_IF_ERROR(error); sl@0: CleanupClosePushL(semaphore); sl@0: sl@0: // Create thread which adds two events sl@0: RThread thread; sl@0: error = thread.Create(_L("T_VIEW1_OBS_EVENT_CREATION_THREAD"), TestDeletingViewWithinObserverCallbackL_ThreadFunction, 10 * 1024, 5 * 1024, 20 * 1024, NULL); sl@0: LEAVE_IF_ERROR(error); sl@0: CleanupClosePushL(thread); sl@0: sl@0: // Start the worker thread going sl@0: thread.Resume(); sl@0: User::After(1 * 100000); sl@0: semaphore.Wait(); sl@0: sl@0: // Wait for changes sl@0: CLogChangeDefinition* changes = changeObs->WaitForChangesLC(TCallBack(TestDeletingViewWithinObserverCallbackL_CallbackFn, view), CLogViewChangeObserver::EStopOnChanges); sl@0: sl@0: // Check the changes sl@0: TEST2(changes->Count(), 1); sl@0: TEST2(changes->At(0), ELogChangeTypeEventAdded); sl@0: sl@0: TLogId logId = -1; sl@0: TLogDatabaseChangeType dbChangeType = changes->At(0, logId); sl@0: TEST2(dbChangeType, ELogChangeTypeEventAdded); sl@0: TEST2(logId, 0); sl@0: TInt viewIndex = -1; sl@0: dbChangeType = changes->At(0, logId, viewIndex); sl@0: TEST2(logId, 0); sl@0: TEST2(viewIndex, 0); sl@0: //Find a change position by the log id sl@0: TInt pos = changes->Find(logId); sl@0: TEST2(pos, 0); sl@0: pos = changes->Find(8125347); sl@0: TEST2(pos, KErrNotFound); sl@0: //Find a change position by the log id and the change type sl@0: pos = changes->Find(logId, dbChangeType); sl@0: TEST2(pos, 0); sl@0: pos = changes->Find(432837, ELogChangeTypeEventChanged); sl@0: TEST2(pos, KErrNotFound); sl@0: //Find a view position by the view index sl@0: pos = changes->FindByViewIndex(viewIndex); sl@0: TEST2(pos, 0); sl@0: pos = changes->FindByViewIndex(33939); sl@0: TEST2(pos, KErrNotFound); sl@0: //Stream out the changes to a buffer sl@0: TBuf8<100> strmBuf; sl@0: RDesWriteStream strmOut(strmBuf); sl@0: changes->ExternalizeL(strmOut); sl@0: strmOut.CommitL(); sl@0: sl@0: CleanupStack::PopAndDestroy(changes); sl@0: sl@0: //Re-create changes from the buffer sl@0: RDesReadStream strmIn(strmBuf); sl@0: changes = CLogChangeDefinition::NewL(strmIn); sl@0: dbChangeType = changes->At(0, logId); sl@0: TEST2(dbChangeType, ELogChangeTypeEventAdded); sl@0: TEST2(logId, 0); sl@0: delete changes; sl@0: sl@0: // The view should be deleted... sl@0: CleanupStack::PopAndDestroy(&thread); sl@0: CleanupStack::PopAndDestroy(&semaphore); sl@0: sl@0: CleanupStack::Pop(); // view sl@0: CleanupStack::PopAndDestroy(2, active); // changeObs, active sl@0: } sl@0: sl@0: sl@0: sl@0: // sl@0: // sl@0: // sl@0: struct TThreadData sl@0: { sl@0: inline TThreadData() : iArray(NULL), iStopThread(EFalse) { } sl@0: // sl@0: RArray* iArray; sl@0: TBool iStopThread; sl@0: }; sl@0: sl@0: // Slave Thread for the TestNavigationWhilstBusyL() test. sl@0: // This runs continuously while aThreadData.iStopThread is False. sl@0: static void TestNavigationWhilstBusyL_ThreadFunctionL(TThreadData& aThreadData) sl@0: { sl@0: enum TNextOp sl@0: { sl@0: EAdd = 0, sl@0: EDelete, sl@0: EClear, sl@0: }; sl@0: sl@0: const static TNextOp KOpTable[] = sl@0: { sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EDelete, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EDelete, EDelete, EDelete, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EDelete, EDelete, EDelete, EAdd, EAdd, EAdd, EAdd, sl@0: EDelete, EDelete, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EDelete, EDelete, EDelete, EAdd, EAdd, EAdd, EAdd, sl@0: EDelete, EDelete, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EDelete, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, EAdd, EDelete, sl@0: EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, EAdd, sl@0: }; sl@0: const static TInt KIndexTable[] = sl@0: { sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, sl@0: -1, -1, -1, 0, 4, 20, -1, -1, -1, -1, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, -1, -1, 0, 1, 0, -1, -1, -1, -1, sl@0: 25, 8, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, -1, -1, 2, 4, 15, -1, -1, -1, -1, sl@0: 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, 0, -1, 30, -1, 0, -1, 31, -1, 14, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, 10, -1, 2, -1, 0, -1, 24, -1, 11, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, 0, -1, 10, -1, 0, -1, 12, -1, 5, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, 15, -1, 9, -1, 0, -1, 19, -1, 25, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: -1, 0, -1, 1, -1, 0, -1, 7, -1, 31, sl@0: -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, sl@0: }; sl@0: const static TInt KDelayTable[] = sl@0: { sl@0: 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, sl@0: 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, sl@0: 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, 0001, sl@0: 0001, 0001, 0001, 0001, 0001, 0001, 0002, 0002, 0002, 0002, sl@0: 0002, 0002, 0002, 0001, 0001, 0001, 0002, 0002, 0002, 0002, sl@0: 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, sl@0: 0002, 0002, 0002, 0001, 0002, 0001, 0002, 0002, 0002, 0002, sl@0: 2500, 8000, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, sl@0: 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, sl@0: 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, sl@0: 0002, 0002, 0002, 2000, 4000000, 1500, 0002, 0002, 0002, 0002, sl@0: 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, sl@0: 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, sl@0: 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, 0002, sl@0: 0002, 0002, 0002, 0002, 0002, 0001, 0002, 0002, 0002, 0002, sl@0: 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, sl@0: 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, sl@0: 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, sl@0: 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, sl@0: 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, sl@0: 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, sl@0: 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, sl@0: 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, sl@0: 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, sl@0: 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, sl@0: 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, sl@0: }; sl@0: const TInt KOpCount = sizeof(KOpTable) / sizeof(TNextOp); sl@0: sl@0: TInt TotalAdds = 0; sl@0: TInt TotalDeletes = 0; sl@0: sl@0: RFs fsSession; sl@0: LEAVE_IF_ERROR(fsSession.Connect()); sl@0: CleanupClosePushL(fsSession); sl@0: // sl@0: CLogClient* client = CLogClient::NewL(fsSession); sl@0: CleanupStack::PushL(client); sl@0: // sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: event->SetEventType(TEST_LOG_UID); sl@0: // sl@0: CTestActive* active = new(ELeave) CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: // Add 5 recent events to the list sl@0: TBuf incoming; sl@0: client->GetString(incoming, R_LOG_DIR_IN); sl@0: event->SetDirection(incoming); sl@0: sl@0: CLogSchedulerTimer* timer = CLogSchedulerTimer::NewLC(); sl@0: TInt count = 0; sl@0: TInt i=0; sl@0: TInt Repeat =0; sl@0: // sl@0: while(!(aThreadData.iStopThread)) sl@0: { sl@0: const TInt op = KOpTable[i]; sl@0: // sl@0: switch(op) sl@0: { sl@0: case EAdd: sl@0: { sl@0: event->SetContact(i); sl@0: active->StartL(); sl@0: client->AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 1)); sl@0: ++count; sl@0: LEAVE_IF_ERROR(aThreadData.iArray->Append(event->Id())); sl@0: // TheTest.Printf(_L("EAdd: i:%d count:%d, id:%d\n"), i, aThreadData.iArray->Count(), event->Id()); sl@0: sl@0: // Have to wait for a minimum of 1 ms here because otherwise DMBS sorts records (by time) sl@0: // in an arbitrary manor sl@0: // If this occurs this test will fail the logId == arrayId test below, as the order sl@0: // will be different between the logeng and arrayOfIds[]. sl@0: const TInt timeToWait = KDelayTable[i]; sl@0: if (timeToWait) sl@0: timer->Wait(timeToWait); sl@0: sl@0: timer->Wait(500000); sl@0: sl@0: TotalAdds++; sl@0: break; sl@0: } sl@0: case EDelete: sl@0: { sl@0: const TInt index = KIndexTable[i]; sl@0: const TLogId logId = (*aThreadData.iArray)[index]; sl@0: RDebug::Print(_L("EDelete index[%i]=%d id:%d\n"),i, index, logId); sl@0: active->StartL(); sl@0: client->DeleteEvent(logId, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: if (active->iStatus != KErrNone) sl@0: { sl@0: /* This happens if the LogID is not present in the log, sl@0: so the LogEngine cannot find the event to delete. sl@0: This can happen if the log is full, as it will start sl@0: deleting the old events itself */ sl@0: RDebug::Print(_L("Delete failed error:%d\n"), active->iStatus.Int()); sl@0: __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 2)); sl@0: } sl@0: aThreadData.iArray->Remove(index); sl@0: --count; sl@0: TotalDeletes++; sl@0: break; sl@0: } sl@0: case EClear: sl@0: { sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: now += TTimeIntervalDays(1); sl@0: sl@0: // Clear log sl@0: active->StartL(); sl@0: client->ClearLog(now, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: __ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 3)); sl@0: aThreadData.iArray->Reset(); sl@0: count = 0; sl@0: RDebug::Print(_L("TEST CODE: Log cleared\n")); sl@0: break; sl@0: } sl@0: } sl@0: sl@0: if (++i >= KOpCount) sl@0: { sl@0: i = 0; sl@0: Repeat++; sl@0: } sl@0: } sl@0: sl@0: RDebug::Print(_L("Repeats:%d TotalAdds:%d TotalDeletes:%d = %d\n"),Repeat,TotalAdds, TotalDeletes, count); sl@0: sl@0: CleanupStack::PopAndDestroy(timer); sl@0: sl@0: // Tidy up sl@0: CleanupStack::PopAndDestroy(4, &fsSession); sl@0: } sl@0: sl@0: // Slave Thread for the TestNavigationWhilstBusyL() test. sl@0: // sl@0: static TInt TestNavigationWhilstBusyL_ThreadFunction(TAny* aData) sl@0: { sl@0: TThreadData* threadData = reinterpret_cast(aData); sl@0: // sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: if (!cleanup) sl@0: return KErrNoMemory; sl@0: CActiveScheduler* scheduler = new CActiveScheduler(); sl@0: if (!scheduler) sl@0: return KErrNoMemory; sl@0: CActiveScheduler::Install(scheduler); sl@0: // sl@0: TRAPD(err, TestNavigationWhilstBusyL_ThreadFunctionL(*threadData)); sl@0: UNUSED_VAR(err); sl@0: // sl@0: delete scheduler; sl@0: delete cleanup; sl@0: // sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** sl@0: This tests using the Logeng while it is busy. It starts a new thread which adds and deletes events sl@0: using the data in KOpTable[] and KIndexTable[]. It then checks the database while the new thread is sl@0: running. sl@0: sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0874 sl@0: @SYMTestCaseDesc Tests for navigation while Log engine is busy. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Start a new thread which adds and deletes events sl@0: using the data in defined tables.It then checks the database while the new thread is running. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestNavigationWhilstBusyL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0874 ")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: TInt error = 0; sl@0: TInt count = 0; sl@0: // sl@0: CTestActive* active = new(ELeave) CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); sl@0: sl@0: // Create a test event type - TEST_LOG_UID sl@0: CLogEventType* type = CLogEventType::NewL(); sl@0: CleanupStack::PushL(type); sl@0: sl@0: type->SetUid(TEST_LOG_UID); sl@0: type->SetDescription(KTestEventDesc); sl@0: type->SetLoggingEnabled(ETrue); sl@0: TheTest.Printf(_L("\nTest event type added %x\n"),TEST_LOG_UID ); sl@0: sl@0: // Register the event type sl@0: active->StartL(); sl@0: aClient.AddEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(); // type sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetEventType(TEST_LOG_UID); sl@0: TBool res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(!res); sl@0: sl@0: // increase the default log size sl@0: TLogConfig Config; sl@0: const TInt kMaxLogSize = 2000; sl@0: Config.iMaxLogSize = kMaxLogSize; sl@0: aClient.ChangeConfig( Config, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Shared data between this and the worker thread sl@0: RArray arrayOfIds(100); sl@0: CleanupClosePushL(arrayOfIds); sl@0: TThreadData threadData; sl@0: threadData.iArray = &arrayOfIds; sl@0: sl@0: // Create thread which adds two events sl@0: RThread thread; sl@0: RHeap& heap = User::Heap(); sl@0: error = thread.Create(_L("T_VIEW1_OBS_EVENT_CREATION_THREAD2"), TestNavigationWhilstBusyL_ThreadFunction, 10 * 1024, &heap, &threadData); sl@0: LEAVE_IF_ERROR(error); sl@0: CleanupClosePushL(thread); sl@0: sl@0: // Start the worker thread going sl@0: thread.Resume(); sl@0: sl@0: // Suspend this thread sl@0: TheTest.Printf(_L("TEST CODE: Suspending thread for 2 seconds\n")); sl@0: CLogSchedulerTimer* timer = CLogSchedulerTimer::NewLC(); sl@0: timer->Wait(10 * 1000000); sl@0: sl@0: // Apply the filter now there are some records sl@0: TheTest.Printf(_L("TEST CODE: Setting filter again - should be some records now\n")); sl@0: res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(res); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: 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 sl@0: count = view->CountL(); sl@0: TEST(count > 0); sl@0: sl@0: // Navigate around (up and down) whilst events are being created sl@0: count = view->CountL(); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel); sl@0: count--; sl@0: if (active->iStatus == KErrNone) sl@0: TEST(view->Event().Id() != KLogNullId); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: timer->Wait(5 * 1000000); sl@0: count = view->CountL(); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel); sl@0: count--; sl@0: if (active->iStatus == KErrNone) sl@0: TEST(view->Event().Id() != KLogNullId); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: timer->Wait(5 * 1000000); sl@0: count = view->CountL(); sl@0: res = view->LastL(active->iStatus); sl@0: TEST(res); sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel); sl@0: count--; sl@0: if (active->iStatus == KErrNone) sl@0: TEST(view->Event().Id() != KLogNullId); sl@0: } sl@0: while(view->PreviousL(active->iStatus)); sl@0: sl@0: timer->Wait(5 * 1000000); sl@0: count = view->CountL(); sl@0: res = view->FirstL(active->iStatus); sl@0: TEST(res); sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel); sl@0: count--; sl@0: if (active->iStatus == KErrNone) sl@0: TEST(view->Event().Id() != KLogNullId); sl@0: } sl@0: while(view->NextL(active->iStatus)); sl@0: sl@0: timer->Wait(5 * 1000000); sl@0: count = view->CountL(); sl@0: res = view->LastL(active->iStatus); sl@0: TEST(res); sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel); sl@0: count--; sl@0: if (active->iStatus == KErrNone) sl@0: TEST(view->Event().Id() != KLogNullId); sl@0: } sl@0: while(view->PreviousL(active->iStatus)); sl@0: sl@0: timer->Wait(5 * 1000000); sl@0: count = view->CountL(); sl@0: res = view->LastL(active->iStatus); sl@0: TEST(res); sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel); sl@0: count--; sl@0: if (active->iStatus == KErrNone) sl@0: TEST(view->Event().Id() != KLogNullId); sl@0: } sl@0: while(view->PreviousL(active->iStatus)); sl@0: sl@0: // STOP THE WORKER THREAD sl@0: threadData.iStopThread = ETrue; sl@0: TheTest.Printf(_L("Stopping worker thread\n")); sl@0: timer->Wait(30 * 1000000); sl@0: sl@0: // do some checks on the log sl@0: TLogConfig logConfig; sl@0: aClient.GetConfig( logConfig, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TheTest.Printf(_L("MaxLogSize:%ld MaxRecentLogSize:%d\n"), sl@0: logConfig.iMaxLogSize, logConfig.iMaxRecentLogSize ); sl@0: TEST(logConfig.iMaxLogSize > logConfig.iMaxRecentLogSize); sl@0: sl@0: /* Check the log has not overflowed. sl@0: If this fails either increase the log size or reduce the time the sl@0: worker thread has been running sl@0: */ sl@0: TEST(arrayOfIds.Count() < kMaxLogSize); sl@0: sl@0: // Loop though the logevents created by the worker thread and compare against the sl@0: // data stored in arrayOfIds. sl@0: res = view->LastL(active->iStatus); sl@0: TEST(res); sl@0: count = 0; sl@0: do { sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: const TLogId logId = view->Event().Id(); sl@0: const TLogId arrayId = arrayOfIds[count]; sl@0: if (logId != arrayId) sl@0: TheTest.Printf(_L("Events[%d] - array:%5d, id:%5d ****\n"), count, arrayId, logId); sl@0: // Note: If this test fails the fist thing to check is the time delay after EAdd. sl@0: // If several events get the same time stamp, the order is arbitrary and the test fails here. sl@0: TEST2(logId, arrayId); sl@0: count++; sl@0: } sl@0: while(view->PreviousL(active->iStatus)); sl@0: sl@0: CleanupStack::PopAndDestroy(timer); sl@0: CleanupStack::PopAndDestroy(&thread); sl@0: CleanupStack::PopAndDestroy(&arrayOfIds); sl@0: CleanupStack::PopAndDestroy(filter); sl@0: CleanupStack::PopAndDestroy(view); sl@0: CleanupStack::PopAndDestroy(2, active); // changeObs, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-4014 sl@0: @SYMTestCaseDesc Tests CLogView::CountL works correctly after SetFilterL returns no event. sl@0: @SYMTestPriority High sl@0: @SYMTestActions 1. ClearLog. sl@0: 2. SetFilterL. sl@0: 3. Add events and check count. sl@0: 4. Step through the added events. sl@0: @SYMTestExpectedResults 2 - SetFilterL indicates no event in view. sl@0: 3. CountL method returns correct number of events. sl@0: 4. Can step through the added events. sl@0: sl@0: @SYMDEF INC123066 sl@0: */ sl@0: LOCAL_C void INC123066L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-4014 ")); sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: // deliberately not using CLogViewChangeObserver sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: // Clear all the events sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: now += TTimeIntervalDays(1); sl@0: active->StartL(); sl@0: aClient.ClearLog(now, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TBool res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST2(res, 0); sl@0: sl@0: TInt count; sl@0: for(count = 0; count < KTestEventNum; count++) sl@0: { sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST2(view->CountL(), count+1); sl@0: } sl@0: sl@0: // save the most recent logId for checking. sl@0: TLogId lastLogId = event->Id(); sl@0: sl@0: // Can iterate over the added events sl@0: for (count = 0; count < KTestEventNum; count++) sl@0: { sl@0: active->StartL(); sl@0: TEST( view->NextL(active->iStatus) ); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TLogId id = view->Event().Id(); sl@0: // Most recent event is first. Oldest event is last. sl@0: TEST2((lastLogId - count), id); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(4, event); // filter, view, active, event sl@0: sl@0: // See same test using CLogViewRecent in TestRecentView1L. sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID PDS-LOGENG-CT-4017 sl@0: @SYMTestCaseDesc Tests Handling of CLogViewRecent::SetRecentListL when sl@0: Remote Party string contains single quote character sl@0: @SYMTestPriority High sl@0: @SYMTestActions 1. Create 10 Incoming call events from 3 different sl@0: Remote Parties using single quotes in strings sl@0: 2. Call CLogViewRecent::SetRecentListL. sl@0: 3. Check that duplicate entries have been deleted and only sl@0: 3 events are showm sl@0: sl@0: @SYMTestExpectedResults SetRecentListL indicates 3 events in view sl@0: @SYMDEF INC136334 sl@0: */ sl@0: LOCAL_C void INC136334L(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-CT-4017 ")); sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewRecent* view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: // Incoming sl@0: TBuf buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: sl@0: TInt count; sl@0: //Add 10 missed calls from 3 different contacts sl@0: //These should result in only 3 entries int he log as sl@0: //duplicates should be deleted. sl@0: for(count = 0; count < KTestEventNum; count++) sl@0: { sl@0: //Use a string with a single quote sl@0: event->SetRemoteParty(_L("Sam's Wife")); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: //Use a string with multiple single quotes sl@0: event->SetRemoteParty(_L("'Sam's W'i'f'e'''''''")); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: //Use a string with no single quotes sl@0: event->SetRemoteParty(_L("Sams Wife")); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: } sl@0: sl@0: TEST2(view->CountL(), 0); sl@0: TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus); sl@0: TEST(res); sl@0: sl@0: //All of the duplicate entries should be deleted and there should sl@0: //only be 3 events in the log sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->CountL(), 3); sl@0: sl@0: //Clear the log for he next test sl@0: aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: count = view->CountL(); sl@0: TEST2(count, 0); sl@0: sl@0: CleanupStack::PopAndDestroy(3); // view, active, event sl@0: sl@0: } sl@0: // sl@0: // sl@0: // sl@0: void doTestsL() sl@0: { sl@0: TheMatchingIsEnabled = TestUtils::MatchingEnabledL(); sl@0: sl@0: TestUtils::Initialize(_L("t_logview1")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: CLogClient* client = CLogClient::NewL(theFs); sl@0: CleanupStack::PushL(client); sl@0: sl@0: CLogChangeNotifier* notifier = CLogChangeNotifier::NewL(); sl@0: CleanupStack::PushL(notifier); sl@0: sl@0: TheTest.Start(_L("Event View With No Filter")); sl@0: sl@0: TestEventViewL(*client); sl@0: theLog.Write(_L8("Test 1 OK\n")); sl@0: sl@0: TheTest.Next(_L("Event View Filter alternative")); sl@0: TestViewFilteringDefect1L(*client); sl@0: theLog.Write(_L8("Test 2 OK\n")); sl@0: TheTest.Next(_L("Event View With Filter")); sl@0: TestEventViewFilter1L(*client); sl@0: TestEventViewFilter2L(*client); sl@0: TheTest.Next(_L("INC123066 - LogView not updated if SetFilterL found no event")); sl@0: INC123066L(*client); sl@0: theLog.Write(_L8("Test 3 OK\n")); sl@0: sl@0: TheTest.Next(_L("Recent View")); sl@0: TestRecentView1L(*client); sl@0: TestRecentView2L(*client); sl@0: theLog.Write(_L8("Test 4 OK\n")); sl@0: sl@0: TheTest.Next(_L("Removing recent events")); sl@0: TestRecentRemove1L(*client); sl@0: TestRecentRemove2L(*client); sl@0: theLog.Write(_L8("Test 5 OK\n")); sl@0: sl@0: TheTest.Next(_L("Duplicate View")); sl@0: TestDuplicateViewL(*client); sl@0: theLog.Write(_L8("Test 6 OK\n")); sl@0: sl@0: TheTest.Next(_L("Removing duplicate events")); sl@0: TestDuplicateRemoveL(*client); sl@0: theLog.Write(_L8("Test 7 OK\n")); sl@0: sl@0: TheTest.Next(_L("Check purge performed on view setup")); sl@0: TestPurgeOnSetup1L(*client); sl@0: TestPurgeOnSetup2L(*client); sl@0: theLog.Write(_L8("Test 8 OK\n")); sl@0: sl@0: TheTest.Next(_L("View Purging")); sl@0: TestViewPurgeL(*client); sl@0: theLog.Write(_L8("Test 9 OK\n")); sl@0: sl@0: TheTest.Next(_L("Clearing duplicate lists")); sl@0: TestClearDuplicatesL(*client); sl@0: theLog.Write(_L8("Test 10 OK\n")); sl@0: sl@0: TheTest.Next(_L("Phone number matching")); sl@0: TestPhoneNumberMatchingL(*client); sl@0: theLog.Write(_L8("Test 11 OK\n")); sl@0: sl@0: TheTest.Next(_L("view flags setting/clearing")); sl@0: TestViewFlagsL(*client); sl@0: theLog.Write(_L8("Test 12 OK\n")); sl@0: sl@0: TheTest.Next(_L("Recent view flags setting/clearing")); sl@0: TestRecentFlagsL(*client); sl@0: theLog.Write(_L8("Test 13 OK\n")); sl@0: sl@0: TheTest.Next(_L("View change tests 1")); sl@0: TestViewChangeEvents1L(*client); sl@0: TestViewChangeEvents1aL(*client); sl@0: theLog.Write(_L8("Test 14 OK\n")); sl@0: sl@0: TheTest.Next(_L("View change tests 2")); sl@0: TestViewChangeEvents2L(*client); sl@0: TestViewChangeEvents2aL(*client); sl@0: theLog.Write(_L8("Test 15 OK\n")); sl@0: sl@0: TheTest.Next(_L("View deletion from within callback")); sl@0: TestDeletingViewWithinObserverCallbackL(*client); sl@0: theLog.Write(_L8("Test 16 OK\n")); sl@0: sl@0: TheTest.Next(_L("Test navigation whilst events are added")); sl@0: TestNavigationWhilstBusyL(*client); sl@0: theLog.Write(_L8("Test 17 OK\n")); sl@0: sl@0: TheTest.Next(_L("Defect INC105010 - phone number matching")); sl@0: INC105010L(*client); sl@0: theLog.Write(_L8("Test 18 OK\n")); sl@0: sl@0: TheTest.Next(_L("INC136334 - The miss call log won't show if you have ' in your contact")); sl@0: INC136334L(*client); sl@0: theLog.Write(_L8("Test 19 OK\n")); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // notifier, client; sl@0: }