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: sl@0: #include sl@0: #include "t_logutil2.h" sl@0: #include sl@0: sl@0: RTest TheTest(_L("t_logviewfail")); sl@0: sl@0: const TLogContactItemId KTestContact = 0x123; sl@0: _LIT(KTestStatus, "Test Status Text"); sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0961-0001 sl@0: @SYMTestCaseDesc Tests for CLogViewEvent::NewL() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Add an event to the client,Create a new CLogViewEvent on heap,if no error check if the view works sl@0: Check for memory errors sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestEventViewConstructWithHeapFailL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0961-0001 ")); 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: event->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: // Add an event 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: CLogViewEvent* view = NULL; sl@0: sl@0: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TRAP(error, view = CLogViewEvent::NewL(aClient)); sl@0: sl@0: __UHEAP_RESET; sl@0: sl@0: if (!error) sl@0: { sl@0: finished = ETrue; sl@0: CleanupStack::PushL(view); sl@0: sl@0: // Check the view works sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: TEST(view->SetFilterL(*filter, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST(view->CountL() >= 1); sl@0: TEST(TestUtils::EventsEqual(*event, view->Event())); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // filter, view sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2); // event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0962-0001 sl@0: @SYMTestCaseDesc Tests for CLogViewRecent::NewL(),CLogViewRecent::SetRecentListL() functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create a new view object,if no errors and test of initialising of the view for the specified recent event list. sl@0: Check for no memory errors. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestRecentViewConstructWithHeapFailL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0962-0001 ")); 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: // Incoming sl@0: TLogString 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: // Add an event 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: CLogViewRecent* view = NULL; sl@0: sl@0: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TRAP(error, view = CLogViewRecent::NewL(aClient)); sl@0: sl@0: __UHEAP_RESET; sl@0: sl@0: if (!error) sl@0: { sl@0: finished = ETrue; sl@0: CleanupStack::PushL(view); sl@0: sl@0: TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST(view->CountL() >= 1); sl@0: TEST(TestUtils::EventsEqual(*event, view->Event())); sl@0: sl@0: CleanupStack::PopAndDestroy(); // view sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2); // event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0963-0001 sl@0: @SYMTestCaseDesc Tests for CLogViewDuplicate::NewL() functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create a new logviewrecent object,set the recent log view, sl@0: List out the duplicates of the current event in the recent event list view, sl@0: Check for no memory errors. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDuplicateViewConstructWithHeapFailL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0963-0001 ")); 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: // Incoming sl@0: TLogString buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: event->SetContact(KTestContact); sl@0: sl@0: // Add events 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: aClient.AddEvent(*event, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CLogViewDuplicate* view = NULL; sl@0: sl@0: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TRAP(error, view = CLogViewDuplicate::NewL(aClient)); sl@0: sl@0: __UHEAP_RESET; sl@0: sl@0: if (!error) sl@0: { sl@0: finished = ETrue; sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogViewRecent* recent = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(recent); sl@0: TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST(recent->CountL() >= 1); sl@0: sl@0: TEST(recent->DuplicatesL(*view, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST(view->CountL() >= 1); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // recent, view sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2); // event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0964-0001 sl@0: @SYMTestCaseDesc Tests for CLogViewEvent::SetFilterL() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create a log filter and set the filter on logview.Check for equality of events on the view and events sl@0: added.Check for memory errors. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestEventViewSetupWithHeapFailL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0964-0001 ")); 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: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetStatus(KTestStatus); sl@0: sl@0: // Add an event 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: CLogViewEvent* view = CLogViewEvent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogFilterList* list = new(ELeave)CLogFilterList; sl@0: CleanupStack::PushL(list); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetStatus(KTestStatus); sl@0: sl@0: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool result = EFalse; sl@0: TRAP(error, result = view->SetFilterL(*filter, active->iStatus)); sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(result); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus.Int() == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: sl@0: TEST(view->CountL() >= 1); sl@0: TEST(TestUtils::EventsEqual(*event, view->Event())); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: list->AppendL(filter); sl@0: CleanupStack::Pop(); // filter sl@0: sl@0: filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetEventType(KLogCallEventTypeUid); sl@0: list->AppendL(filter); sl@0: CleanupStack::Pop(); // filter sl@0: sl@0: #ifdef _DEBUG sl@0: failCount = 0; sl@0: #endif sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool result = EFalse; sl@0: TRAP(error, result = view->SetFilterL(*list, active->iStatus)); sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(result); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus.Int() == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: sl@0: TEST(view->CountL() >= 1); sl@0: TEST(TestUtils::EventsEqual(*event, view->Event())); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: list->ResetAndDestroy(); sl@0: CleanupStack::PopAndDestroy(4); // list, view, event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0965-0001 sl@0: @SYMTestCaseDesc Tests for CLogViewRecent::SetRecentListL() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Set recent view list first without a filter and later with log filter,check for memory errors sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestRecentViewSetupWithHeapFailL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0965-0001 ")); 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: // Incoming sl@0: TLogString buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: event->SetStatus(KTestStatus); sl@0: sl@0: // Add an event 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: CLogViewRecent* view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool result = EFalse; sl@0: TRAP(error, result = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus)); sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(result); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus.Int() == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: TEST(view->CountL() >= 1); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: CLogFilterList* list = new(ELeave)CLogFilterList; sl@0: CleanupStack::PushL(list); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetStatus(KTestStatus); sl@0: sl@0: #ifdef _DEBUG sl@0: failCount = 0; sl@0: #endif sl@0: finished = EFalse; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool result = EFalse; sl@0: TRAP(error, result = view->SetRecentListL(KLogRecentIncomingCalls, *filter, active->iStatus)); sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(result); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus.Int() == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: TEST(view->CountL() >= 1); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: list->AppendL(filter); sl@0: CleanupStack::Pop(); // filter sl@0: sl@0: filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetEventType(KLogCallEventTypeUid); sl@0: list->AppendL(filter); sl@0: CleanupStack::Pop(); // filter sl@0: sl@0: #ifdef _DEBUG sl@0: failCount = 0; sl@0: #endif sl@0: finished = EFalse; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool result = EFalse; sl@0: TRAP(error, result = view->SetRecentListL(KLogRecentIncomingCalls, *list, active->iStatus)); sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(result); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus.Int() == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: TEST(view->CountL() >= 1); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: list->ResetAndDestroy(); sl@0: CleanupStack::PopAndDestroy(4); // list, view, event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0966 sl@0: @SYMTestCaseDesc Tests for CLogViewRecent::DuplicatesL() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Set the specified duplicate event view with logview duplicates. sl@0: Check for memory errors sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDuplicateViewSetupWithHeapFailL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0966 ")); 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: // Incoming sl@0: TLogString buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: event->SetContact(KTestContact); sl@0: event->SetStatus(KTestStatus); sl@0: sl@0: // Add events 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: aClient.AddEvent(*event, 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: TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient); sl@0: CleanupStack::PushL(duplicate); sl@0: sl@0: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool result = EFalse; sl@0: TRAP(error, result = view->DuplicatesL(*duplicate, active->iStatus)); sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(result); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus.Int() == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: TEST(duplicate->CountL() >= 1); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: CLogFilterList* list = new(ELeave)CLogFilterList; sl@0: CleanupStack::PushL(list); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetStatus(KTestStatus); sl@0: sl@0: #ifdef _DEBUG sl@0: failCount = 0; sl@0: #endif sl@0: finished = EFalse; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool result = EFalse; sl@0: TRAP(error, result = view->DuplicatesL(*duplicate, *filter, active->iStatus)); sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(result); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus.Int() == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: TEST(duplicate->CountL() >= 1); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: list->AppendL(filter); sl@0: CleanupStack::Pop(); // filter sl@0: sl@0: filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetEventType(KLogCallEventTypeUid); sl@0: list->AppendL(filter); sl@0: CleanupStack::Pop(); // filter sl@0: sl@0: #ifdef _DEBUG sl@0: failCount = 0; sl@0: #endif sl@0: finished = EFalse; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool result = EFalse; sl@0: TRAP(error, result = view->DuplicatesL(*duplicate, *list, active->iStatus)); sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(result); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus.Int() == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: TEST(duplicate->CountL() >= 1); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: list->ResetAndDestroy(); sl@0: CleanupStack::PopAndDestroy(5); // list, duplicate, view, event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0967 sl@0: @SYMTestCaseDesc Tests for CLogViewEvent::NextL(),CLogViewEvent::LastL(),CLogViewEvent::PreviousL(), sl@0: CLogViewEvent::FirstL() functions sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for all the navigation functions in the view. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestNavigationWithHeapFailL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0967 ")); 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: event->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: // Add an event 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: 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: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: TEST(view->SetFilterL(*filter, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST(view->CountL() > 1); sl@0: event->CopyL(view->Event()); sl@0: sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool result = EFalse; sl@0: TRAP(error, result = view->NextL(active->iStatus)); sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(result); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus.Int() == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: TEST(!TestUtils::EventsEqual(*event, view->Event())); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: #ifdef _DEBUG sl@0: failCount = 0; sl@0: #endif sl@0: finished = EFalse; sl@0: sl@0: while(!finished) sl@0: { sl@0: TEST(view->SetFilterL(*filter, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST(view->CountL() > 1); sl@0: sl@0: TEST(view->LastL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: event->CopyL(view->Event()); sl@0: sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool result = EFalse; sl@0: TRAP(error, result = view->PreviousL(active->iStatus)); sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(result); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus.Int() == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: TEST(!TestUtils::EventsEqual(*event, view->Event())); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: #ifdef _DEBUG sl@0: failCount = 0; sl@0: #endif sl@0: finished = EFalse; sl@0: sl@0: while(!finished) sl@0: { sl@0: TEST(view->SetFilterL(*filter, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST(view->CountL() > 1); sl@0: sl@0: TEST(view->LastL(active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: event->CopyL(view->Event()); sl@0: sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool result = EFalse; sl@0: TRAP(error, result = view->FirstL(active->iStatus)); sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(result); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus.Int() == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: TEST(!TestUtils::EventsEqual(*event, view->Event())); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: #ifdef _DEBUG sl@0: failCount = 0; sl@0: #endif sl@0: finished = EFalse; sl@0: sl@0: while(!finished) sl@0: { sl@0: TEST(view->SetFilterL(*filter, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST(view->CountL() > 1); sl@0: 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: event->CopyL(view->Event()); sl@0: sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool result = EFalse; sl@0: TRAP(error, result = view->LastL(active->iStatus)); sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(result); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus.Int() == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: TEST(!TestUtils::EventsEqual(*event, view->Event())); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(4); // filter, view, event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0968 sl@0: @SYMTestCaseDesc Tests for CLogViewEvent::CountL() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for getting the number of events in the view.Check for memory errors sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestViewCountWithHeapFailL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0968 ")); 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: event->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: // Add an event 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: 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: TEST(view->SetFilterL(*filter, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TInt result = 0; sl@0: TRAP(error, result = view->CountL()); sl@0: sl@0: if (!error) sl@0: { sl@0: finished = ETrue; sl@0: TEST(result > 0); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(4); // filter, view, event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0969 sl@0: @SYMTestCaseDesc Tests for CLogViewRecent::RemoveL() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for removing the event with the specified unique event ID from the view.Check for memory error sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestRecentViewRemoveWithHeapFailL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0969 ")); 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: // Incoming sl@0: TLogString buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: event->SetContact(1); sl@0: sl@0: // Add events 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->SetContact(2); 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: event->SetContact(3); 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: CLogViewRecent* view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus)); 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: TEST(count > 1); sl@0: sl@0: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TRAP(error, view->RemoveL(view->Event().Id())); sl@0: sl@0: __UHEAP_RESET; sl@0: sl@0: if (!error) sl@0: { sl@0: finished = ETrue; sl@0: sl@0: TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST(count == view->CountL() + 1); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: } sl@0: sl@0: #ifdef _DEBUG sl@0: failCount = 0; sl@0: #endif sl@0: finished = EFalse; sl@0: sl@0: while(!finished) sl@0: { sl@0: TEST(view->SetRecentListL(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: TEST(count > 1); sl@0: sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool ret = EFalse; sl@0: TRAP(error, ret = view->RemoveL(active->iStatus)); sl@0: sl@0: __UHEAP_RESET; sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(ret); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus == KErrNone) sl@0: { sl@0: TEST(count == view->CountL() + 1); sl@0: finished = ETrue; sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(3); // view, event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0970 sl@0: @SYMTestCaseDesc Tests for CLogViewDuplicate::RemoveL() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Test for removing the event with the specified unique event ID from the view.Check for memory error sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDuplicateViewRemoveWithHeapFailL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0970 ")); 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: // Incoming sl@0: TLogString buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetDirection(buf); sl@0: event->SetContact(KTestContact); sl@0: sl@0: // Add events 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: aClient.AddEvent(*event, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); 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: aClient.AddEvent(*event, 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: TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient); sl@0: CleanupStack::PushL(duplicate); sl@0: sl@0: TEST(view->DuplicatesL(*duplicate, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TInt count = duplicate->CountL(); sl@0: TEST(count > 0); sl@0: sl@0: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TRAP(error, duplicate->RemoveL(duplicate->Event().Id())); sl@0: sl@0: __UHEAP_RESET; sl@0: sl@0: if (!error) sl@0: { sl@0: finished = ETrue; sl@0: sl@0: TEST(view->DuplicatesL(*duplicate, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST(count == duplicate->CountL() + 1); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: } sl@0: sl@0: #ifdef _DEBUG sl@0: failCount = 0; sl@0: #endif sl@0: finished = EFalse; sl@0: sl@0: while(!finished) sl@0: { sl@0: TEST(view->DuplicatesL(*duplicate, active->iStatus)); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: count = duplicate->CountL(); sl@0: TEST(count > 1); sl@0: sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: TBool ret = EFalse; sl@0: TRAP(error, ret = duplicate->RemoveL(active->iStatus)); sl@0: sl@0: __UHEAP_RESET; sl@0: sl@0: if (!error) sl@0: { sl@0: TEST(ret); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus == KErrNone) sl@0: { sl@0: finished = ETrue; sl@0: TEST(count == duplicate->CountL() + 1); sl@0: } sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: } sl@0: else sl@0: TEST2(error, KErrNoMemory); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(4); // duplicate, view, event, active sl@0: } sl@0: sl@0: void doTestsL() sl@0: { sl@0: TestUtils::Initialize(_L("t_logviewfail")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: CLogClient* client = CLogClient::NewL(theFs); sl@0: CleanupStack::PushL(client); sl@0: sl@0: TheTest.Start(_L("Heap Failure in Client")); sl@0: sl@0: TheTest.Next(_L("View Construction")); sl@0: TestEventViewConstructWithHeapFailL(*client); sl@0: TestRecentViewConstructWithHeapFailL(*client); sl@0: TestDuplicateViewConstructWithHeapFailL(*client); sl@0: theLog.Write(_L8("Test 1 OK\n")); sl@0: sl@0: TheTest.Next(_L("View Setup")); sl@0: TestEventViewSetupWithHeapFailL(*client); sl@0: TestRecentViewSetupWithHeapFailL(*client); sl@0: TestDuplicateViewSetupWithHeapFailL(*client); sl@0: theLog.Write(_L8("Test 2 OK\n")); sl@0: sl@0: TheTest.Next(_L("View Navigation")); sl@0: TestNavigationWithHeapFailL(*client); sl@0: theLog.Write(_L8("Test 3 OK\n")); sl@0: sl@0: TheTest.Next(_L("Other")); sl@0: TestViewCountWithHeapFailL(*client); sl@0: TestRecentViewRemoveWithHeapFailL(*client); sl@0: TestDuplicateViewRemoveWithHeapFailL(*client); sl@0: theLog.Write(_L8("Test 4 OK\n")); sl@0: sl@0: CleanupStack::PopAndDestroy(); // client; sl@0: }