os/persistentdata/loggingservices/eventlogger/test/src/t_logviewfail.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/loggingservices/eventlogger/test/src/t_logviewfail.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1268 @@
     1.4 +// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +#include <s32file.h>
    1.20 +#include "t_logutil2.h"
    1.21 +#include <logview.h>
    1.22 +
    1.23 +RTest TheTest(_L("t_logviewfail"));
    1.24 +
    1.25 +const TLogContactItemId KTestContact = 0x123;
    1.26 +_LIT(KTestStatus, "Test Status Text");
    1.27 +
    1.28 +
    1.29 +/**
    1.30 +@SYMTestCaseID          SYSLIB-LOGENG-CT-0961-0001
    1.31 +@SYMTestCaseDesc	    Tests for CLogViewEvent::NewL() function
    1.32 +@SYMTestPriority 	    High
    1.33 +@SYMTestActions  	    Add an event to the client,Create a new CLogViewEvent on heap,if no error check if the view works
    1.34 +                        Check for memory errors
    1.35 +@SYMTestExpectedResults Test must not fail
    1.36 +@SYMREQ                 REQ0000
    1.37 +*/
    1.38 +LOCAL_C void TestEventViewConstructWithHeapFailL(CLogClient& aClient)
    1.39 +	{
    1.40 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0961-0001 "));
    1.41 +	CTestActive* active = new(ELeave)CTestActive;
    1.42 +	CleanupStack::PushL(active);
    1.43 +
    1.44 +	CLogEvent* event = CLogEvent::NewL();
    1.45 +	CleanupStack::PushL(event);
    1.46 +	event->SetEventType(KLogCallEventTypeUid);
    1.47 +
    1.48 +	// Add an event
    1.49 +	aClient.AddEvent(*event, active->iStatus);
    1.50 +	active->StartL();
    1.51 +	CActiveScheduler::Start();
    1.52 +	TEST2(active->iStatus.Int(), KErrNone);
    1.53 +
    1.54 +	CLogViewEvent* view = NULL;
    1.55 +
    1.56 +#ifdef _DEBUG
    1.57 +	TInt failCount = 0;
    1.58 +#endif
    1.59 +	TBool finished = EFalse;
    1.60 +	TInt error;
    1.61 +
    1.62 +	while(!finished)
    1.63 +		{
    1.64 +		__UHEAP_FAILNEXT(failCount++);
    1.65 +
    1.66 +		TRAP(error, view = CLogViewEvent::NewL(aClient));
    1.67 +
    1.68 +		__UHEAP_RESET;
    1.69 +		
    1.70 +		if (!error)
    1.71 +			{
    1.72 +			finished = ETrue;
    1.73 +			CleanupStack::PushL(view);
    1.74 +		
    1.75 +			// Check the view works
    1.76 +			CLogFilter* filter = CLogFilter::NewL();
    1.77 +			CleanupStack::PushL(filter);
    1.78 +			
    1.79 +			TEST(view->SetFilterL(*filter, active->iStatus));
    1.80 +			active->StartL();
    1.81 +			CActiveScheduler::Start();
    1.82 +			TEST2(active->iStatus.Int(), KErrNone);
    1.83 +			TEST(view->CountL() >= 1);
    1.84 +			TEST(TestUtils::EventsEqual(*event, view->Event()));
    1.85 +
    1.86 +			CleanupStack::PopAndDestroy(2); // filter, view
    1.87 +			}
    1.88 +		else
    1.89 +			TEST2(error, KErrNoMemory);
    1.90 +		}
    1.91 +
    1.92 +	CleanupStack::PopAndDestroy(2); // event, active
    1.93 +	}
    1.94 +
    1.95 +/**
    1.96 +@SYMTestCaseID          SYSLIB-LOGENG-CT-0962-0001
    1.97 +@SYMTestCaseDesc	    Tests for CLogViewRecent::NewL(),CLogViewRecent::SetRecentListL() functions
    1.98 +@SYMTestPriority 	    High
    1.99 +@SYMTestActions  	    Create a new view object,if no errors and test of initialising of the view for the specified recent event list. 
   1.100 +                        Check for no memory errors.                         
   1.101 +@SYMTestExpectedResults Test must not fail
   1.102 +@SYMREQ                 REQ0000
   1.103 +*/
   1.104 +LOCAL_C void TestRecentViewConstructWithHeapFailL(CLogClient& aClient)
   1.105 +	{
   1.106 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0962-0001 "));
   1.107 +	CTestActive* active = new(ELeave)CTestActive;
   1.108 +	CleanupStack::PushL(active);
   1.109 +
   1.110 +	CLogEvent* event = CLogEvent::NewL();
   1.111 +	CleanupStack::PushL(event);
   1.112 +
   1.113 +	// Incoming
   1.114 +	TLogString buf;
   1.115 +	aClient.GetString(buf, R_LOG_DIR_IN);
   1.116 +
   1.117 +	event->SetEventType(KLogCallEventTypeUid);
   1.118 +	event->SetDirection(buf);
   1.119 +
   1.120 +	// Add an event
   1.121 +	aClient.AddEvent(*event, active->iStatus);
   1.122 +	active->StartL();
   1.123 +	CActiveScheduler::Start();
   1.124 +	TEST2(active->iStatus.Int(), KErrNone);
   1.125 +
   1.126 +	CLogViewRecent* view = NULL;
   1.127 +
   1.128 +#ifdef _DEBUG
   1.129 +	TInt failCount = 0;
   1.130 +#endif
   1.131 +
   1.132 +	TBool finished = EFalse;
   1.133 +	TInt error;
   1.134 +
   1.135 +	while(!finished)
   1.136 +		{
   1.137 +		__UHEAP_FAILNEXT(failCount++);
   1.138 +
   1.139 +		TRAP(error, view = CLogViewRecent::NewL(aClient));
   1.140 +
   1.141 +		__UHEAP_RESET;
   1.142 +		
   1.143 +		if (!error)
   1.144 +			{
   1.145 +			finished = ETrue;
   1.146 +			CleanupStack::PushL(view);
   1.147 +					
   1.148 +			TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
   1.149 +			active->StartL();
   1.150 +			CActiveScheduler::Start();
   1.151 +			TEST2(active->iStatus.Int(), KErrNone);
   1.152 +			TEST(view->CountL() >= 1);
   1.153 +			TEST(TestUtils::EventsEqual(*event, view->Event()));
   1.154 +
   1.155 +			CleanupStack::PopAndDestroy(); // view
   1.156 +			}
   1.157 +		else
   1.158 +			TEST2(error, KErrNoMemory);
   1.159 +		}
   1.160 +
   1.161 +	CleanupStack::PopAndDestroy(2); // event, active
   1.162 +	}
   1.163 +
   1.164 +/**
   1.165 +@SYMTestCaseID          SYSLIB-LOGENG-CT-0963-0001
   1.166 +@SYMTestCaseDesc	    Tests for CLogViewDuplicate::NewL() functions
   1.167 +@SYMTestPriority 	    High
   1.168 +@SYMTestActions  	    Create a new logviewrecent object,set the recent log view,
   1.169 +                        List out the duplicates of the current event in the recent event list view,
   1.170 +                        Check for no memory errors.
   1.171 +@SYMTestExpectedResults Test must not fail
   1.172 +@SYMREQ                 REQ0000
   1.173 +*/
   1.174 +LOCAL_C void TestDuplicateViewConstructWithHeapFailL(CLogClient& aClient)
   1.175 +	{
   1.176 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0963-0001 "));
   1.177 +	CTestActive* active = new(ELeave)CTestActive;
   1.178 +	CleanupStack::PushL(active);
   1.179 +
   1.180 +	CLogEvent* event = CLogEvent::NewL();
   1.181 +	CleanupStack::PushL(event);
   1.182 +
   1.183 +	// Incoming
   1.184 +	TLogString buf;
   1.185 +	aClient.GetString(buf, R_LOG_DIR_IN);
   1.186 +
   1.187 +	event->SetEventType(KLogCallEventTypeUid);
   1.188 +	event->SetDirection(buf);
   1.189 +	event->SetContact(KTestContact);
   1.190 +
   1.191 +	// Add events
   1.192 +	aClient.AddEvent(*event, active->iStatus);
   1.193 +	active->StartL();
   1.194 +	CActiveScheduler::Start();
   1.195 +	TEST2(active->iStatus.Int(), KErrNone);
   1.196 +
   1.197 +	aClient.AddEvent(*event, active->iStatus);
   1.198 +	active->StartL();
   1.199 +	CActiveScheduler::Start();
   1.200 +	TEST2(active->iStatus.Int(), KErrNone);
   1.201 +
   1.202 +	CLogViewDuplicate* view = NULL;
   1.203 +
   1.204 +#ifdef _DEBUG
   1.205 +	TInt failCount = 0;
   1.206 +#endif
   1.207 +
   1.208 +	TBool finished = EFalse;
   1.209 +	TInt error;
   1.210 +
   1.211 +	while(!finished)
   1.212 +		{
   1.213 +		__UHEAP_FAILNEXT(failCount++);
   1.214 +
   1.215 +		TRAP(error, view = CLogViewDuplicate::NewL(aClient));
   1.216 +
   1.217 +		__UHEAP_RESET;
   1.218 +		
   1.219 +		if (!error)
   1.220 +			{
   1.221 +			finished = ETrue;
   1.222 +			CleanupStack::PushL(view);
   1.223 +			
   1.224 +			CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
   1.225 +			CleanupStack::PushL(recent);
   1.226 +			TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
   1.227 +			active->StartL();
   1.228 +			CActiveScheduler::Start();
   1.229 +			TEST2(active->iStatus.Int(), KErrNone);
   1.230 +			TEST(recent->CountL() >= 1);
   1.231 +
   1.232 +			TEST(recent->DuplicatesL(*view, active->iStatus));
   1.233 +			active->StartL();
   1.234 +			CActiveScheduler::Start();
   1.235 +			TEST2(active->iStatus.Int(), KErrNone);
   1.236 +			TEST(view->CountL() >= 1);
   1.237 +
   1.238 +			CleanupStack::PopAndDestroy(2); // recent, view
   1.239 +			}
   1.240 +		else
   1.241 +			TEST2(error, KErrNoMemory);
   1.242 +		}
   1.243 +
   1.244 +	CleanupStack::PopAndDestroy(2); // event, active
   1.245 +	}
   1.246 +
   1.247 +/**
   1.248 +@SYMTestCaseID          SYSLIB-LOGENG-CT-0964-0001
   1.249 +@SYMTestCaseDesc	    Tests for CLogViewEvent::SetFilterL() function 
   1.250 +@SYMTestPriority 	    High
   1.251 +@SYMTestActions  	    Create a log filter and set the filter on logview.Check for equality of events on the view and events
   1.252 +						added.Check for memory errors.
   1.253 +@SYMTestExpectedResults Test must not fail
   1.254 +@SYMREQ                 REQ0000
   1.255 +*/
   1.256 +LOCAL_C void TestEventViewSetupWithHeapFailL(CLogClient& aClient)
   1.257 +	{
   1.258 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0964-0001 "));
   1.259 +	CTestActive* active = new(ELeave)CTestActive;
   1.260 +	CleanupStack::PushL(active);
   1.261 +
   1.262 +	CLogEvent* event = CLogEvent::NewL();
   1.263 +	CleanupStack::PushL(event);
   1.264 +	event->SetEventType(KLogCallEventTypeUid);
   1.265 +	event->SetStatus(KTestStatus);
   1.266 +
   1.267 +	// Add an event
   1.268 +	aClient.AddEvent(*event, active->iStatus);
   1.269 +	active->StartL();
   1.270 +	CActiveScheduler::Start();
   1.271 +	TEST2(active->iStatus.Int(), KErrNone);
   1.272 +
   1.273 +	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
   1.274 +	CleanupStack::PushL(view);
   1.275 +
   1.276 +	CLogFilterList* list = new(ELeave)CLogFilterList;
   1.277 +	CleanupStack::PushL(list);
   1.278 +
   1.279 +	CLogFilter* filter = CLogFilter::NewL();
   1.280 +	CleanupStack::PushL(filter);
   1.281 +	filter->SetStatus(KTestStatus);
   1.282 +
   1.283 +#ifdef _DEBUG
   1.284 +	TInt failCount = 0;
   1.285 +#endif
   1.286 +
   1.287 +	TBool finished = EFalse;
   1.288 +	TInt error;
   1.289 +
   1.290 +	while(!finished)
   1.291 +		{
   1.292 +		__UHEAP_FAILNEXT(failCount++);
   1.293 +
   1.294 +		TBool result = EFalse;
   1.295 +		TRAP(error, result = view->SetFilterL(*filter, active->iStatus));
   1.296 +		
   1.297 +		if (!error)
   1.298 +			{
   1.299 +			TEST(result);
   1.300 +
   1.301 +			active->StartL();
   1.302 +			CActiveScheduler::Start();
   1.303 +
   1.304 +			if (active->iStatus.Int() == KErrNone)
   1.305 +				{
   1.306 +				finished = ETrue;		
   1.307 +				
   1.308 +				TEST(view->CountL() >= 1);
   1.309 +				TEST(TestUtils::EventsEqual(*event, view->Event()));
   1.310 +				}
   1.311 +			else
   1.312 +				TEST2(active->iStatus.Int(), KErrNoMemory);
   1.313 +			}
   1.314 +		else
   1.315 +			TEST2(error, KErrNoMemory);
   1.316 +
   1.317 +		__UHEAP_RESET;
   1.318 +		}
   1.319 +
   1.320 +	list->AppendL(filter);
   1.321 +	CleanupStack::Pop(); // filter
   1.322 +	
   1.323 +	filter = CLogFilter::NewL();
   1.324 +	CleanupStack::PushL(filter);
   1.325 +	filter->SetEventType(KLogCallEventTypeUid);
   1.326 +	list->AppendL(filter);
   1.327 +	CleanupStack::Pop(); // filter
   1.328 +
   1.329 +#ifdef _DEBUG
   1.330 +	failCount = 0;
   1.331 +#endif
   1.332 +
   1.333 +	while(!finished)
   1.334 +		{
   1.335 +		__UHEAP_FAILNEXT(failCount++);
   1.336 +
   1.337 +		TBool result = EFalse;
   1.338 +		TRAP(error, result = view->SetFilterL(*list, active->iStatus));
   1.339 +		
   1.340 +		if (!error)
   1.341 +			{
   1.342 +			TEST(result);
   1.343 +
   1.344 +			active->StartL();
   1.345 +			CActiveScheduler::Start();
   1.346 +
   1.347 +			if (active->iStatus.Int() == KErrNone)
   1.348 +				{
   1.349 +				finished = ETrue;		
   1.350 +				
   1.351 +				TEST(view->CountL() >= 1);
   1.352 +				TEST(TestUtils::EventsEqual(*event, view->Event()));
   1.353 +				}
   1.354 +			else
   1.355 +				TEST2(active->iStatus.Int(), KErrNoMemory);
   1.356 +			}
   1.357 +		else
   1.358 +			TEST2(error, KErrNoMemory);
   1.359 +
   1.360 +		__UHEAP_RESET;
   1.361 +		}
   1.362 +
   1.363 +	list->ResetAndDestroy();
   1.364 +	CleanupStack::PopAndDestroy(4); // list, view, event, active
   1.365 +	}
   1.366 +
   1.367 +/**
   1.368 +@SYMTestCaseID          SYSLIB-LOGENG-CT-0965-0001
   1.369 +@SYMTestCaseDesc	    Tests for CLogViewRecent::SetRecentListL() function 
   1.370 +@SYMTestPriority 	    High
   1.371 +@SYMTestActions  	    Set recent view list first without a filter and later with log filter,check for memory errors
   1.372 +@SYMTestExpectedResults Test must not fail
   1.373 +@SYMREQ                 REQ0000
   1.374 +*/
   1.375 +LOCAL_C void TestRecentViewSetupWithHeapFailL(CLogClient& aClient)
   1.376 +	{
   1.377 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0965-0001 "));
   1.378 +	CTestActive* active = new(ELeave)CTestActive;
   1.379 +	CleanupStack::PushL(active);
   1.380 +
   1.381 +	CLogEvent* event = CLogEvent::NewL();
   1.382 +	CleanupStack::PushL(event);
   1.383 +
   1.384 +	// Incoming
   1.385 +	TLogString buf;
   1.386 +	aClient.GetString(buf, R_LOG_DIR_IN);
   1.387 +
   1.388 +	event->SetEventType(KLogCallEventTypeUid);
   1.389 +	event->SetDirection(buf);
   1.390 +	event->SetStatus(KTestStatus);
   1.391 +
   1.392 +	// Add an event
   1.393 +	aClient.AddEvent(*event, active->iStatus);
   1.394 +	active->StartL();
   1.395 +	CActiveScheduler::Start();
   1.396 +	TEST2(active->iStatus.Int(), KErrNone);
   1.397 +
   1.398 +	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
   1.399 +	CleanupStack::PushL(view);
   1.400 +
   1.401 +#ifdef _DEBUG
   1.402 +	TInt failCount = 0;
   1.403 +#endif
   1.404 +
   1.405 +	TBool finished = EFalse;
   1.406 +	TInt error;
   1.407 +
   1.408 +	while(!finished)
   1.409 +		{
   1.410 +		__UHEAP_FAILNEXT(failCount++);
   1.411 +
   1.412 +		TBool result = EFalse;
   1.413 +		TRAP(error, result = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
   1.414 +		
   1.415 +		if (!error)
   1.416 +			{
   1.417 +			TEST(result);
   1.418 +
   1.419 +			active->StartL();
   1.420 +			CActiveScheduler::Start();
   1.421 +
   1.422 +			if (active->iStatus.Int() == KErrNone)
   1.423 +				{
   1.424 +				finished = ETrue;		
   1.425 +				TEST(view->CountL() >= 1);
   1.426 +				}
   1.427 +			else
   1.428 +				TEST2(active->iStatus.Int(), KErrNoMemory);
   1.429 +			}
   1.430 +		else
   1.431 +			TEST2(error, KErrNoMemory);
   1.432 +
   1.433 +		__UHEAP_RESET;
   1.434 +		}
   1.435 +
   1.436 +	CLogFilterList* list = new(ELeave)CLogFilterList;
   1.437 +	CleanupStack::PushL(list);
   1.438 +
   1.439 +	CLogFilter* filter = CLogFilter::NewL();
   1.440 +	CleanupStack::PushL(filter);
   1.441 +	filter->SetStatus(KTestStatus);
   1.442 +
   1.443 +#ifdef _DEBUG
   1.444 +	failCount = 0;
   1.445 +#endif
   1.446 +	finished = EFalse;
   1.447 +
   1.448 +	while(!finished)
   1.449 +		{
   1.450 +		__UHEAP_FAILNEXT(failCount++);
   1.451 +
   1.452 +		TBool result = EFalse;
   1.453 +		TRAP(error, result = view->SetRecentListL(KLogRecentIncomingCalls, *filter, active->iStatus));
   1.454 +		
   1.455 +		if (!error)
   1.456 +			{
   1.457 +			TEST(result);
   1.458 +
   1.459 +			active->StartL();
   1.460 +			CActiveScheduler::Start();
   1.461 +
   1.462 +			if (active->iStatus.Int() == KErrNone)
   1.463 +				{
   1.464 +				finished = ETrue;		
   1.465 +				TEST(view->CountL() >= 1);
   1.466 +				}
   1.467 +			else
   1.468 +				TEST2(active->iStatus.Int(), KErrNoMemory);
   1.469 +			}
   1.470 +		else
   1.471 +			TEST2(error, KErrNoMemory);
   1.472 +
   1.473 +		__UHEAP_RESET;
   1.474 +		}
   1.475 +
   1.476 +	list->AppendL(filter);
   1.477 +	CleanupStack::Pop(); // filter
   1.478 +
   1.479 +	filter = CLogFilter::NewL();
   1.480 +	CleanupStack::PushL(filter);
   1.481 +	filter->SetEventType(KLogCallEventTypeUid);
   1.482 +	list->AppendL(filter);
   1.483 +	CleanupStack::Pop(); // filter
   1.484 +
   1.485 +#ifdef _DEBUG
   1.486 +	failCount = 0;
   1.487 +#endif
   1.488 +	finished = EFalse;
   1.489 +
   1.490 +	while(!finished)
   1.491 +		{
   1.492 +		__UHEAP_FAILNEXT(failCount++);
   1.493 +
   1.494 +		TBool result = EFalse;
   1.495 +		TRAP(error, result = view->SetRecentListL(KLogRecentIncomingCalls, *list, active->iStatus));
   1.496 +		
   1.497 +		if (!error)
   1.498 +			{
   1.499 +			TEST(result);
   1.500 +
   1.501 +			active->StartL();
   1.502 +			CActiveScheduler::Start();
   1.503 +
   1.504 +			if (active->iStatus.Int() == KErrNone)
   1.505 +				{
   1.506 +				finished = ETrue;		
   1.507 +				TEST(view->CountL() >= 1);
   1.508 +				}
   1.509 +			else
   1.510 +				TEST2(active->iStatus.Int(), KErrNoMemory);
   1.511 +			}
   1.512 +		else
   1.513 +			TEST2(error, KErrNoMemory);
   1.514 +
   1.515 +		__UHEAP_RESET;
   1.516 +		}
   1.517 +
   1.518 +	list->ResetAndDestroy();
   1.519 +	CleanupStack::PopAndDestroy(4); // list, view, event, active
   1.520 +	}
   1.521 +
   1.522 +/**
   1.523 +@SYMTestCaseID          SYSLIB-LOGENG-CT-0966
   1.524 +@SYMTestCaseDesc	    Tests for CLogViewRecent::DuplicatesL() function
   1.525 +@SYMTestPriority 	    High
   1.526 +@SYMTestActions  	    Set the specified duplicate event view with logview duplicates.
   1.527 +                        Check for memory errors 
   1.528 +@SYMTestExpectedResults Test must not fail
   1.529 +@SYMREQ                 REQ0000
   1.530 +*/
   1.531 +LOCAL_C void TestDuplicateViewSetupWithHeapFailL(CLogClient& aClient)
   1.532 +	{
   1.533 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0966 "));
   1.534 +	CTestActive* active = new(ELeave)CTestActive;
   1.535 +	CleanupStack::PushL(active);
   1.536 +
   1.537 +	CLogEvent* event = CLogEvent::NewL();
   1.538 +	CleanupStack::PushL(event);
   1.539 +
   1.540 +	// Incoming
   1.541 +	TLogString buf;
   1.542 +	aClient.GetString(buf, R_LOG_DIR_IN);
   1.543 +
   1.544 +	event->SetEventType(KLogCallEventTypeUid);
   1.545 +	event->SetDirection(buf);
   1.546 +	event->SetContact(KTestContact);
   1.547 +	event->SetStatus(KTestStatus);
   1.548 +
   1.549 +	// Add events
   1.550 +	aClient.AddEvent(*event, active->iStatus);
   1.551 +	active->StartL();
   1.552 +	CActiveScheduler::Start();
   1.553 +	TEST2(active->iStatus.Int(), KErrNone);
   1.554 +
   1.555 +	aClient.AddEvent(*event, active->iStatus);
   1.556 +	active->StartL();
   1.557 +	CActiveScheduler::Start();
   1.558 +	TEST2(active->iStatus.Int(), KErrNone);
   1.559 +
   1.560 +	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
   1.561 +	CleanupStack::PushL(view);
   1.562 +
   1.563 +	TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
   1.564 +	active->StartL();
   1.565 +	CActiveScheduler::Start();
   1.566 +	TEST2(active->iStatus.Int(), KErrNone);
   1.567 +	
   1.568 +	CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient);
   1.569 +	CleanupStack::PushL(duplicate);
   1.570 +
   1.571 +#ifdef _DEBUG
   1.572 +	TInt failCount = 0;
   1.573 +#endif
   1.574 +
   1.575 +	TBool finished = EFalse;
   1.576 +	TInt error;
   1.577 +
   1.578 +	while(!finished)
   1.579 +		{
   1.580 +		__UHEAP_FAILNEXT(failCount++);
   1.581 +
   1.582 +		TBool result = EFalse;
   1.583 +		TRAP(error, result = view->DuplicatesL(*duplicate, active->iStatus));
   1.584 +		
   1.585 +		if (!error)
   1.586 +			{
   1.587 +			TEST(result);
   1.588 +
   1.589 +			active->StartL();
   1.590 +			CActiveScheduler::Start();
   1.591 +
   1.592 +			if (active->iStatus.Int() == KErrNone)
   1.593 +				{
   1.594 +				finished = ETrue;		
   1.595 +				TEST(duplicate->CountL() >= 1);
   1.596 +				}
   1.597 +			else
   1.598 +				TEST2(active->iStatus.Int(), KErrNoMemory);
   1.599 +			}
   1.600 +		else
   1.601 +			TEST2(error, KErrNoMemory);
   1.602 +
   1.603 +		__UHEAP_RESET;
   1.604 +		}
   1.605 +
   1.606 +	CLogFilterList* list = new(ELeave)CLogFilterList;
   1.607 +	CleanupStack::PushL(list);
   1.608 +
   1.609 +	CLogFilter* filter = CLogFilter::NewL();
   1.610 +	CleanupStack::PushL(filter);
   1.611 +	filter->SetStatus(KTestStatus);
   1.612 +
   1.613 +#ifdef _DEBUG
   1.614 +	failCount = 0;
   1.615 +#endif
   1.616 +	finished = EFalse;
   1.617 +
   1.618 +	while(!finished)
   1.619 +		{
   1.620 +		__UHEAP_FAILNEXT(failCount++);
   1.621 +
   1.622 +		TBool result = EFalse;
   1.623 +		TRAP(error, result = view->DuplicatesL(*duplicate, *filter, active->iStatus));
   1.624 +		
   1.625 +		if (!error)
   1.626 +			{
   1.627 +			TEST(result);
   1.628 +
   1.629 +			active->StartL();
   1.630 +			CActiveScheduler::Start();
   1.631 +
   1.632 +			if (active->iStatus.Int() == KErrNone)
   1.633 +				{
   1.634 +				finished = ETrue;		
   1.635 +				TEST(duplicate->CountL() >= 1);
   1.636 +				}
   1.637 +			else
   1.638 +				TEST2(active->iStatus.Int(), KErrNoMemory);
   1.639 +			}
   1.640 +		else
   1.641 +			TEST2(error, KErrNoMemory);
   1.642 +
   1.643 +		__UHEAP_RESET;
   1.644 +		}
   1.645 +
   1.646 +	list->AppendL(filter);
   1.647 +	CleanupStack::Pop(); // filter
   1.648 +
   1.649 +	filter = CLogFilter::NewL();
   1.650 +	CleanupStack::PushL(filter);
   1.651 +	filter->SetEventType(KLogCallEventTypeUid);
   1.652 +	list->AppendL(filter);
   1.653 +	CleanupStack::Pop(); // filter
   1.654 +
   1.655 +#ifdef _DEBUG
   1.656 +	failCount = 0;
   1.657 +#endif
   1.658 +	finished = EFalse;
   1.659 +
   1.660 +	while(!finished)
   1.661 +		{
   1.662 +		__UHEAP_FAILNEXT(failCount++);
   1.663 +
   1.664 +		TBool result = EFalse;
   1.665 +		TRAP(error, result = view->DuplicatesL(*duplicate, *list, active->iStatus));
   1.666 +		
   1.667 +		if (!error)
   1.668 +			{
   1.669 +			TEST(result);
   1.670 +
   1.671 +			active->StartL();
   1.672 +			CActiveScheduler::Start();
   1.673 +
   1.674 +			if (active->iStatus.Int() == KErrNone)
   1.675 +				{
   1.676 +				finished = ETrue;		
   1.677 +				TEST(duplicate->CountL() >= 1);
   1.678 +				}
   1.679 +			else
   1.680 +				TEST2(active->iStatus.Int(), KErrNoMemory);
   1.681 +			}
   1.682 +		else
   1.683 +			TEST2(error, KErrNoMemory);
   1.684 +
   1.685 +		__UHEAP_RESET;
   1.686 +		}
   1.687 +
   1.688 +	list->ResetAndDestroy();
   1.689 +	CleanupStack::PopAndDestroy(5); // list, duplicate, view, event, active
   1.690 +	}
   1.691 +
   1.692 +/**
   1.693 +@SYMTestCaseID          SYSLIB-LOGENG-CT-0967
   1.694 +@SYMTestCaseDesc	    Tests for CLogViewEvent::NextL(),CLogViewEvent::LastL(),CLogViewEvent::PreviousL(),
   1.695 +                        CLogViewEvent::FirstL() functions
   1.696 +@SYMTestPriority 	    High
   1.697 +@SYMTestActions  	    Tests for all the navigation functions in the view. 
   1.698 +@SYMTestExpectedResults Test must not fail
   1.699 +@SYMREQ                 REQ0000
   1.700 +*/
   1.701 +LOCAL_C void TestNavigationWithHeapFailL(CLogClient& aClient)
   1.702 +	{
   1.703 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0967 "));
   1.704 +	CTestActive* active = new(ELeave)CTestActive;
   1.705 +	CleanupStack::PushL(active);
   1.706 +
   1.707 +	CLogEvent* event = CLogEvent::NewL();
   1.708 +	CleanupStack::PushL(event);
   1.709 +	event->SetEventType(KLogCallEventTypeUid);
   1.710 +
   1.711 +	// Add an event
   1.712 +	aClient.AddEvent(*event, active->iStatus);
   1.713 +	active->StartL();
   1.714 +	CActiveScheduler::Start();
   1.715 +	TEST2(active->iStatus.Int(), KErrNone);
   1.716 +
   1.717 +	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
   1.718 +	CleanupStack::PushL(view);
   1.719 +
   1.720 +	CLogFilter* filter = CLogFilter::NewL();
   1.721 +	CleanupStack::PushL(filter);
   1.722 +
   1.723 +#ifdef _DEBUG
   1.724 +	TInt failCount = 0;
   1.725 +#endif
   1.726 +
   1.727 +	TBool finished = EFalse;
   1.728 +	TInt error;
   1.729 +
   1.730 +	while(!finished)
   1.731 +		{
   1.732 +		TEST(view->SetFilterL(*filter, active->iStatus));
   1.733 +		active->StartL();
   1.734 +		CActiveScheduler::Start();
   1.735 +		TEST2(active->iStatus.Int(), KErrNone);
   1.736 +		TEST(view->CountL() > 1);
   1.737 +		event->CopyL(view->Event());
   1.738 +
   1.739 +		__UHEAP_FAILNEXT(failCount++);
   1.740 +
   1.741 +		TBool result = EFalse;
   1.742 +		TRAP(error, result = view->NextL(active->iStatus));
   1.743 +		
   1.744 +		if (!error)
   1.745 +			{
   1.746 +			TEST(result);
   1.747 +
   1.748 +			active->StartL();
   1.749 +			CActiveScheduler::Start();
   1.750 +
   1.751 +			if (active->iStatus.Int() == KErrNone)
   1.752 +				{
   1.753 +				finished = ETrue;
   1.754 +				TEST(!TestUtils::EventsEqual(*event, view->Event()));
   1.755 +				}
   1.756 +			else
   1.757 +				TEST2(active->iStatus.Int(), KErrNoMemory);
   1.758 +			}
   1.759 +		else
   1.760 +			TEST2(error, KErrNoMemory);
   1.761 +
   1.762 +		__UHEAP_RESET;
   1.763 +		}
   1.764 +
   1.765 +#ifdef _DEBUG
   1.766 +	failCount = 0;
   1.767 +#endif
   1.768 +	finished = EFalse;
   1.769 +
   1.770 +	while(!finished)
   1.771 +		{
   1.772 +		TEST(view->SetFilterL(*filter, active->iStatus));
   1.773 +		active->StartL();
   1.774 +		CActiveScheduler::Start();
   1.775 +		TEST2(active->iStatus.Int(), KErrNone);
   1.776 +		TEST(view->CountL() > 1);
   1.777 +
   1.778 +		TEST(view->LastL(active->iStatus));
   1.779 +		active->StartL();
   1.780 +		CActiveScheduler::Start();
   1.781 +		TEST2(active->iStatus.Int(), KErrNone);
   1.782 +
   1.783 +		event->CopyL(view->Event());
   1.784 +
   1.785 +		__UHEAP_FAILNEXT(failCount++);
   1.786 +
   1.787 +		TBool result = EFalse;
   1.788 +		TRAP(error, result = view->PreviousL(active->iStatus));
   1.789 +		
   1.790 +		if (!error)
   1.791 +			{
   1.792 +			TEST(result);
   1.793 +
   1.794 +			active->StartL();
   1.795 +			CActiveScheduler::Start();
   1.796 +
   1.797 +			if (active->iStatus.Int() == KErrNone)
   1.798 +				{
   1.799 +				finished = ETrue;
   1.800 +				TEST(!TestUtils::EventsEqual(*event, view->Event()));
   1.801 +				}
   1.802 +			else
   1.803 +				TEST2(active->iStatus.Int(), KErrNoMemory);
   1.804 +			}
   1.805 +		else
   1.806 +			TEST2(error, KErrNoMemory);
   1.807 +
   1.808 +		__UHEAP_RESET;
   1.809 +		}
   1.810 +
   1.811 +#ifdef _DEBUG
   1.812 +	failCount = 0;
   1.813 +#endif
   1.814 +	finished = EFalse;
   1.815 +
   1.816 +	while(!finished)
   1.817 +		{
   1.818 +		TEST(view->SetFilterL(*filter, active->iStatus));
   1.819 +		active->StartL();
   1.820 +		CActiveScheduler::Start();
   1.821 +		TEST2(active->iStatus.Int(), KErrNone);
   1.822 +		TEST(view->CountL() > 1);
   1.823 +
   1.824 +		TEST(view->LastL(active->iStatus));
   1.825 +		active->StartL();
   1.826 +		CActiveScheduler::Start();
   1.827 +		TEST2(active->iStatus.Int(), KErrNone);
   1.828 +
   1.829 +		event->CopyL(view->Event());
   1.830 +
   1.831 +		__UHEAP_FAILNEXT(failCount++);
   1.832 +
   1.833 +		TBool result = EFalse;
   1.834 +		TRAP(error, result = view->FirstL(active->iStatus));
   1.835 +		
   1.836 +		if (!error)
   1.837 +			{
   1.838 +			TEST(result);
   1.839 +
   1.840 +			active->StartL();
   1.841 +			CActiveScheduler::Start();
   1.842 +
   1.843 +			if (active->iStatus.Int() == KErrNone)
   1.844 +				{
   1.845 +				finished = ETrue;
   1.846 +				TEST(!TestUtils::EventsEqual(*event, view->Event()));
   1.847 +				}
   1.848 +			else
   1.849 +				TEST2(active->iStatus.Int(), KErrNoMemory);
   1.850 +			}
   1.851 +		else
   1.852 +			TEST2(error, KErrNoMemory);
   1.853 +
   1.854 +		__UHEAP_RESET;
   1.855 +		}
   1.856 +
   1.857 +#ifdef _DEBUG
   1.858 +	failCount = 0;
   1.859 +#endif
   1.860 +	finished = EFalse;
   1.861 +
   1.862 +	while(!finished)
   1.863 +		{
   1.864 +		TEST(view->SetFilterL(*filter, active->iStatus));
   1.865 +		active->StartL();
   1.866 +		CActiveScheduler::Start();
   1.867 +		TEST2(active->iStatus.Int(), KErrNone);
   1.868 +		TEST(view->CountL() > 1);
   1.869 +
   1.870 +		TEST(view->FirstL(active->iStatus));
   1.871 +		active->StartL();
   1.872 +		CActiveScheduler::Start();
   1.873 +		TEST2(active->iStatus.Int(), KErrNone);
   1.874 +
   1.875 +		event->CopyL(view->Event());
   1.876 +
   1.877 +		__UHEAP_FAILNEXT(failCount++);
   1.878 +
   1.879 +		TBool result = EFalse;
   1.880 +		TRAP(error, result = view->LastL(active->iStatus));
   1.881 +		
   1.882 +		if (!error)
   1.883 +			{
   1.884 +			TEST(result);
   1.885 +
   1.886 +			active->StartL();
   1.887 +			CActiveScheduler::Start();
   1.888 +
   1.889 +			if (active->iStatus.Int() == KErrNone)
   1.890 +				{
   1.891 +				finished = ETrue;
   1.892 +				TEST(!TestUtils::EventsEqual(*event, view->Event()));
   1.893 +				}
   1.894 +			else
   1.895 +				TEST2(active->iStatus.Int(), KErrNoMemory);
   1.896 +			}
   1.897 +		else
   1.898 +			TEST2(error, KErrNoMemory);
   1.899 +
   1.900 +		__UHEAP_RESET;
   1.901 +		}
   1.902 +
   1.903 +	CleanupStack::PopAndDestroy(4); // filter, view, event, active
   1.904 +	}
   1.905 +
   1.906 +/**
   1.907 +@SYMTestCaseID          SYSLIB-LOGENG-CT-0968
   1.908 +@SYMTestCaseDesc	    Tests for CLogViewEvent::CountL() function
   1.909 +@SYMTestPriority 	    High
   1.910 +@SYMTestActions  	    Test for getting the number of events in the view.Check for memory errors
   1.911 +@SYMTestExpectedResults Test must not fail
   1.912 +@SYMREQ                 REQ0000
   1.913 +*/
   1.914 +LOCAL_C void TestViewCountWithHeapFailL(CLogClient& aClient)
   1.915 +	{
   1.916 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0968 "));
   1.917 +	CTestActive* active = new(ELeave)CTestActive;
   1.918 +	CleanupStack::PushL(active);
   1.919 +
   1.920 +	CLogEvent* event = CLogEvent::NewL();
   1.921 +	CleanupStack::PushL(event);
   1.922 +	event->SetEventType(KLogCallEventTypeUid);
   1.923 +
   1.924 +	// Add an event
   1.925 +	aClient.AddEvent(*event, active->iStatus);
   1.926 +	active->StartL();
   1.927 +	CActiveScheduler::Start();
   1.928 +	TEST2(active->iStatus.Int(), KErrNone);
   1.929 +
   1.930 +	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
   1.931 +	CleanupStack::PushL(view);
   1.932 +
   1.933 +	CLogFilter* filter = CLogFilter::NewL();
   1.934 +	CleanupStack::PushL(filter);
   1.935 +
   1.936 +	TEST(view->SetFilterL(*filter, active->iStatus));
   1.937 +	active->StartL();
   1.938 +	CActiveScheduler::Start();
   1.939 +	TEST2(active->iStatus.Int(), KErrNone);
   1.940 +
   1.941 +#ifdef _DEBUG
   1.942 +	TInt failCount = 0;
   1.943 +#endif
   1.944 +
   1.945 +	TBool finished = EFalse;
   1.946 +	TInt error;
   1.947 +
   1.948 +	while(!finished)
   1.949 +		{
   1.950 +		__UHEAP_FAILNEXT(failCount++);
   1.951 +
   1.952 +		TInt result = 0;
   1.953 +		TRAP(error, result = view->CountL());
   1.954 +		
   1.955 +		if (!error)
   1.956 +			{
   1.957 +			finished = ETrue;
   1.958 +			TEST(result > 0);
   1.959 +			}
   1.960 +		else
   1.961 +			TEST2(error, KErrNoMemory);
   1.962 +
   1.963 +		__UHEAP_RESET;
   1.964 +		}
   1.965 +
   1.966 +	CleanupStack::PopAndDestroy(4); // filter, view, event, active
   1.967 +	}
   1.968 +
   1.969 +/**
   1.970 +@SYMTestCaseID          SYSLIB-LOGENG-CT-0969
   1.971 +@SYMTestCaseDesc	    Tests for CLogViewRecent::RemoveL() function
   1.972 +@SYMTestPriority 	    High
   1.973 +@SYMTestActions  	    Test for removing the event with the specified unique event ID from the view.Check for memory error
   1.974 +@SYMTestExpectedResults Test must not fail
   1.975 +@SYMREQ                 REQ0000
   1.976 +*/
   1.977 +LOCAL_C void TestRecentViewRemoveWithHeapFailL(CLogClient& aClient)
   1.978 +	{
   1.979 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0969 "));
   1.980 +	CTestActive* active = new(ELeave)CTestActive;
   1.981 +	CleanupStack::PushL(active);
   1.982 +
   1.983 +	CLogEvent* event = CLogEvent::NewL();
   1.984 +	CleanupStack::PushL(event);
   1.985 +
   1.986 +	// Incoming
   1.987 +	TLogString buf;
   1.988 +	aClient.GetString(buf, R_LOG_DIR_IN);
   1.989 +
   1.990 +	event->SetEventType(KLogCallEventTypeUid);
   1.991 +	event->SetDirection(buf);
   1.992 +	event->SetContact(1);
   1.993 +
   1.994 +	// Add events
   1.995 +	aClient.AddEvent(*event, active->iStatus);
   1.996 +	active->StartL();
   1.997 +	CActiveScheduler::Start();
   1.998 +	TEST2(active->iStatus.Int(), KErrNone);
   1.999 +
  1.1000 +	event->SetContact(2);
  1.1001 +
  1.1002 +	aClient.AddEvent(*event, active->iStatus);
  1.1003 +	active->StartL();
  1.1004 +	CActiveScheduler::Start();
  1.1005 +	TEST2(active->iStatus.Int(), KErrNone);
  1.1006 +
  1.1007 +	event->SetContact(3);
  1.1008 +
  1.1009 +	aClient.AddEvent(*event, active->iStatus);
  1.1010 +	active->StartL();
  1.1011 +	CActiveScheduler::Start();
  1.1012 +	TEST2(active->iStatus.Int(), KErrNone);
  1.1013 +
  1.1014 +	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
  1.1015 +	CleanupStack::PushL(view);
  1.1016 +
  1.1017 +	TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
  1.1018 +	active->StartL();
  1.1019 +	CActiveScheduler::Start();
  1.1020 +	TEST2(active->iStatus.Int(), KErrNone);
  1.1021 +
  1.1022 +	TInt count = view->CountL();
  1.1023 +	TEST(count > 1);
  1.1024 +
  1.1025 +#ifdef _DEBUG
  1.1026 +	TInt failCount = 0;
  1.1027 +#endif
  1.1028 +
  1.1029 +	TBool finished = EFalse;
  1.1030 +	TInt error;
  1.1031 +
  1.1032 +	while(!finished)
  1.1033 +		{
  1.1034 +		__UHEAP_FAILNEXT(failCount++);
  1.1035 +
  1.1036 +		TRAP(error, view->RemoveL(view->Event().Id()));
  1.1037 +
  1.1038 +		__UHEAP_RESET;
  1.1039 +
  1.1040 +		if (!error)
  1.1041 +			{
  1.1042 +			finished = ETrue;
  1.1043 +
  1.1044 +			TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
  1.1045 +			active->StartL();
  1.1046 +			CActiveScheduler::Start();
  1.1047 +			TEST2(active->iStatus.Int(), KErrNone);
  1.1048 +
  1.1049 +			TEST(count == view->CountL() + 1);
  1.1050 +			}
  1.1051 +		else
  1.1052 +			TEST2(error, KErrNoMemory);
  1.1053 +		}
  1.1054 +
  1.1055 +#ifdef _DEBUG
  1.1056 +	failCount = 0;
  1.1057 +#endif
  1.1058 +	finished = EFalse;
  1.1059 +
  1.1060 +	while(!finished)
  1.1061 +		{
  1.1062 +		TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
  1.1063 +		active->StartL();
  1.1064 +		CActiveScheduler::Start();
  1.1065 +		TEST2(active->iStatus.Int(), KErrNone);
  1.1066 +
  1.1067 +		count = view->CountL();
  1.1068 +		TEST(count > 1);
  1.1069 +
  1.1070 +		__UHEAP_FAILNEXT(failCount++);
  1.1071 +
  1.1072 +		TBool ret = EFalse;
  1.1073 +		TRAP(error, ret = view->RemoveL(active->iStatus));
  1.1074 +
  1.1075 +		__UHEAP_RESET;
  1.1076 +
  1.1077 +		if (!error)
  1.1078 +			{
  1.1079 +			TEST(ret);
  1.1080 +
  1.1081 +			active->StartL();
  1.1082 +			CActiveScheduler::Start();
  1.1083 +
  1.1084 +			if (active->iStatus == KErrNone)
  1.1085 +				{
  1.1086 +				TEST(count == view->CountL() + 1);
  1.1087 +				finished = ETrue;
  1.1088 +				}
  1.1089 +			else
  1.1090 +				TEST2(active->iStatus.Int(), KErrNoMemory);
  1.1091 +			}
  1.1092 +		else
  1.1093 +			TEST2(error, KErrNoMemory);
  1.1094 +		}
  1.1095 +
  1.1096 +	CleanupStack::PopAndDestroy(3); // view, event, active
  1.1097 +	}
  1.1098 +
  1.1099 +/**
  1.1100 +@SYMTestCaseID          SYSLIB-LOGENG-CT-0970
  1.1101 +@SYMTestCaseDesc	    Tests for CLogViewDuplicate::RemoveL() function
  1.1102 +@SYMTestPriority 	    High
  1.1103 +@SYMTestActions  	    Test for removing the event with the specified unique event ID from the view.Check for memory error
  1.1104 +@SYMTestExpectedResults Test must not fail
  1.1105 +@SYMREQ                 REQ0000
  1.1106 +*/
  1.1107 +LOCAL_C void TestDuplicateViewRemoveWithHeapFailL(CLogClient& aClient)
  1.1108 +	{
  1.1109 +	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0970 "));
  1.1110 +	CTestActive* active = new(ELeave)CTestActive;
  1.1111 +	CleanupStack::PushL(active);
  1.1112 +
  1.1113 +	CLogEvent* event = CLogEvent::NewL();
  1.1114 +	CleanupStack::PushL(event);
  1.1115 +
  1.1116 +	// Incoming
  1.1117 +	TLogString buf;
  1.1118 +	aClient.GetString(buf, R_LOG_DIR_IN);
  1.1119 +
  1.1120 +	event->SetEventType(KLogCallEventTypeUid);
  1.1121 +	event->SetDirection(buf);
  1.1122 +	event->SetContact(KTestContact);
  1.1123 +
  1.1124 +	// Add events
  1.1125 +	aClient.AddEvent(*event, active->iStatus);
  1.1126 +	active->StartL();
  1.1127 +	CActiveScheduler::Start();
  1.1128 +	TEST2(active->iStatus.Int(), KErrNone);
  1.1129 +
  1.1130 +	aClient.AddEvent(*event, active->iStatus);
  1.1131 +	active->StartL();
  1.1132 +	CActiveScheduler::Start();
  1.1133 +	TEST2(active->iStatus.Int(), KErrNone);
  1.1134 +
  1.1135 +	aClient.AddEvent(*event, active->iStatus);
  1.1136 +	active->StartL();
  1.1137 +	CActiveScheduler::Start();
  1.1138 +	TEST2(active->iStatus.Int(), KErrNone);
  1.1139 +
  1.1140 +	aClient.AddEvent(*event, active->iStatus);
  1.1141 +	active->StartL();
  1.1142 +	CActiveScheduler::Start();
  1.1143 +	TEST2(active->iStatus.Int(), KErrNone);
  1.1144 +
  1.1145 +	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
  1.1146 +	CleanupStack::PushL(view);
  1.1147 +
  1.1148 +	TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
  1.1149 +	active->StartL();
  1.1150 +	CActiveScheduler::Start();
  1.1151 +	TEST2(active->iStatus.Int(), KErrNone);
  1.1152 +
  1.1153 +	CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient);
  1.1154 +	CleanupStack::PushL(duplicate);
  1.1155 +
  1.1156 +	TEST(view->DuplicatesL(*duplicate, active->iStatus));
  1.1157 +	active->StartL();
  1.1158 +	CActiveScheduler::Start();
  1.1159 +	TEST2(active->iStatus.Int(), KErrNone);
  1.1160 +	
  1.1161 +	TInt count = duplicate->CountL();
  1.1162 +	TEST(count > 0);
  1.1163 +
  1.1164 +#ifdef _DEBUG
  1.1165 +	TInt failCount = 0;
  1.1166 +#endif
  1.1167 +
  1.1168 +	TBool finished = EFalse;
  1.1169 +	TInt error;
  1.1170 +
  1.1171 +	while(!finished)
  1.1172 +		{
  1.1173 +		__UHEAP_FAILNEXT(failCount++);
  1.1174 +
  1.1175 +		TRAP(error, duplicate->RemoveL(duplicate->Event().Id()));
  1.1176 +
  1.1177 +		__UHEAP_RESET;
  1.1178 +
  1.1179 +		if (!error)
  1.1180 +			{
  1.1181 +			finished = ETrue;
  1.1182 +
  1.1183 +			TEST(view->DuplicatesL(*duplicate, active->iStatus));
  1.1184 +			active->StartL();
  1.1185 +			CActiveScheduler::Start();
  1.1186 +			TEST2(active->iStatus.Int(), KErrNone);
  1.1187 +
  1.1188 +			TEST(count == duplicate->CountL() + 1);
  1.1189 +			}
  1.1190 +		else
  1.1191 +			TEST2(error, KErrNoMemory);
  1.1192 +		}
  1.1193 +
  1.1194 +#ifdef _DEBUG
  1.1195 +	failCount = 0;
  1.1196 +#endif
  1.1197 +	finished = EFalse;
  1.1198 +
  1.1199 +	while(!finished)
  1.1200 +		{
  1.1201 +		TEST(view->DuplicatesL(*duplicate, active->iStatus));
  1.1202 +		active->StartL();
  1.1203 +		CActiveScheduler::Start();
  1.1204 +		TEST2(active->iStatus.Int(), KErrNone);
  1.1205 +
  1.1206 +		count = duplicate->CountL();
  1.1207 +		TEST(count > 1);
  1.1208 +
  1.1209 +		__UHEAP_FAILNEXT(failCount++);
  1.1210 +
  1.1211 +		TBool ret = EFalse;
  1.1212 +		TRAP(error, ret = duplicate->RemoveL(active->iStatus));
  1.1213 +
  1.1214 +		__UHEAP_RESET;
  1.1215 +
  1.1216 +		if (!error)
  1.1217 +			{
  1.1218 +			TEST(ret);
  1.1219 +
  1.1220 +			active->StartL();
  1.1221 +			CActiveScheduler::Start();
  1.1222 +
  1.1223 +			if (active->iStatus == KErrNone)
  1.1224 +				{
  1.1225 +				finished = ETrue;
  1.1226 +				TEST(count == duplicate->CountL() + 1);
  1.1227 +				}
  1.1228 +			else
  1.1229 +				TEST2(active->iStatus.Int(), KErrNoMemory);
  1.1230 +			}
  1.1231 +		else
  1.1232 +			TEST2(error, KErrNoMemory);
  1.1233 +		}
  1.1234 +
  1.1235 +	CleanupStack::PopAndDestroy(4); // duplicate, view, event, active
  1.1236 +	}
  1.1237 +
  1.1238 +void doTestsL()
  1.1239 +	{
  1.1240 +	TestUtils::Initialize(_L("t_logviewfail"));
  1.1241 +	TestUtils::DeleteDatabaseL();
  1.1242 +
  1.1243 +	CLogClient* client = CLogClient::NewL(theFs);
  1.1244 +	CleanupStack::PushL(client);
  1.1245 +
  1.1246 +	TheTest.Start(_L("Heap Failure in Client"));
  1.1247 +
  1.1248 +	TheTest.Next(_L("View Construction"));
  1.1249 +	TestEventViewConstructWithHeapFailL(*client);
  1.1250 +	TestRecentViewConstructWithHeapFailL(*client);
  1.1251 +	TestDuplicateViewConstructWithHeapFailL(*client);
  1.1252 +	theLog.Write(_L8("Test 1 OK\n"));
  1.1253 +
  1.1254 +	TheTest.Next(_L("View Setup"));
  1.1255 +	TestEventViewSetupWithHeapFailL(*client);
  1.1256 +	TestRecentViewSetupWithHeapFailL(*client);
  1.1257 +	TestDuplicateViewSetupWithHeapFailL(*client);
  1.1258 +	theLog.Write(_L8("Test 2 OK\n"));
  1.1259 +
  1.1260 +	TheTest.Next(_L("View Navigation"));
  1.1261 +	TestNavigationWithHeapFailL(*client);
  1.1262 +	theLog.Write(_L8("Test 3 OK\n"));
  1.1263 +
  1.1264 +	TheTest.Next(_L("Other"));
  1.1265 +	TestViewCountWithHeapFailL(*client);
  1.1266 +	TestRecentViewRemoveWithHeapFailL(*client);
  1.1267 +	TestDuplicateViewRemoveWithHeapFailL(*client);
  1.1268 +	theLog.Write(_L8("Test 4 OK\n"));
  1.1269 +
  1.1270 +	CleanupStack::PopAndDestroy(); // client;
  1.1271 +	}