os/persistentdata/loggingservices/eventlogger/test/src/t_logviewfail3.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <s32file.h>
    17 #include "t_logutil2.h"
    18 #include <logview.h>
    19 
    20 RTest TheTest(_L("t_logviewfail3"));
    21 
    22 const TLogContactItemId KTestContact = 0x123;
    23 _LIT(KTestStatus, "Test Status Text");
    24 
    25 /**
    26 @SYMTestCaseID          SYSLIB-LOGENG-CT-0978
    27 @SYMTestCaseDesc	    Tests for CLogViewEvent::NewL() function
    28 @SYMTestPriority 	    High
    29 @SYMTestActions  	    Add an event to the client,Create a new CLogViewEvent on heap,if no error check if the view works
    30                         Check for log server failure error
    31 @SYMTestExpectedResults Test must not fail
    32 @SYMREQ                 REQ0000
    33 */
    34 LOCAL_C void TestEventViewConstructWithLogServFailL(CLogClient& aClient)
    35 	{
    36 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0978 "));
    37 	CTestActive* active = new(ELeave)CTestActive;
    38 	CleanupStack::PushL(active);
    39 
    40 	CLogEvent* event = CLogEvent::NewL();
    41 	CleanupStack::PushL(event);
    42 	event->SetEventType(KLogCallEventTypeUid);
    43 
    44 	// Add an event
    45 	aClient.AddEvent(*event, active->iStatus);
    46 	active->StartL();
    47 	CActiveScheduler::Start();
    48 	TEST2(active->iStatus.Int(), KErrNone);
    49 
    50 	CLogViewEvent* view = NULL;
    51 
    52 	TInt failCount = 0;
    53 	TBool finished = EFalse;
    54 	TInt error;
    55 
    56 	while(!finished)
    57 		{
    58 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
    59 
    60 		TRAP(error, view = CLogViewEvent::NewL(aClient));
    61 
    62 		__LOGSERV_UHEAP_RESET;
    63 		
    64 		if (!error)
    65 			{
    66 			finished = ETrue;
    67 			CleanupStack::PushL(view);
    68 		
    69 			// Check the view works
    70 			CLogFilter* filter = CLogFilter::NewL();
    71 			CleanupStack::PushL(filter);
    72 			
    73 			TEST(view->SetFilterL(*filter, active->iStatus));
    74 			active->StartL();
    75 			CActiveScheduler::Start();
    76 			TEST2(active->iStatus.Int(), KErrNone);
    77 			TEST(view->CountL() >= 1);
    78 			TEST(TestUtils::EventsEqual(*event, view->Event()));
    79 
    80 			CleanupStack::PopAndDestroy(2); // filter, view
    81 			}
    82 		else
    83 			{
    84 			TEST2(error, KErrNoMemory);
    85 			}
    86 		}
    87 
    88 	CleanupStack::PopAndDestroy(2); // event, active
    89 	}
    90 
    91 /**
    92 @SYMTestCaseID          SYSLIB-LOGENG-CT-0979
    93 @SYMTestCaseDesc	    Tests for CLogViewRecent::NewL(),SetRecentListL() functions
    94 @SYMTestPriority 	    High
    95 @SYMTestActions  	    Create a new view object,if no errors and test of initialising of the view for the specified recent event list. 
    96                         Check for log server failure error
    97 @SYMTestExpectedResults Test must not fail
    98 @SYMREQ                 REQ0000
    99 */
   100 LOCAL_C void TestRecentViewConstructWithLogServFailL(CLogClient& aClient)
   101 	{
   102 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0979 "));
   103 	CTestActive* active = new(ELeave)CTestActive;
   104 	CleanupStack::PushL(active);
   105 
   106 	CLogEvent* event = CLogEvent::NewL();
   107 	CleanupStack::PushL(event);
   108 
   109 	// Incoming
   110 	TLogString buf;
   111 	aClient.GetString(buf, R_LOG_DIR_IN);
   112 
   113 	event->SetEventType(KLogCallEventTypeUid);
   114 	event->SetDirection(buf);
   115 
   116 	// Add an event
   117 	aClient.AddEvent(*event, active->iStatus);
   118 	active->StartL();
   119 	CActiveScheduler::Start();
   120 	TEST2(active->iStatus.Int(), KErrNone);
   121 
   122 	CLogViewRecent* view = NULL;
   123 
   124 	TInt failCount = 0;
   125 	TBool finished = EFalse;
   126 	TInt error;
   127 
   128 	while(!finished)
   129 		{
   130 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   131 
   132 		TRAP(error, view = CLogViewRecent::NewL(aClient));
   133 
   134 		__LOGSERV_UHEAP_RESET;
   135 		
   136 		if (!error)
   137 			{
   138 			finished = ETrue;
   139 			CleanupStack::PushL(view);
   140 					
   141 			TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
   142 			active->StartL();
   143 			CActiveScheduler::Start();
   144 			TEST2(active->iStatus.Int(), KErrNone);
   145 			TEST(view->CountL() >= 1);
   146 			TEST(TestUtils::EventsEqual(*event, view->Event()));
   147 
   148 			CleanupStack::PopAndDestroy(); // view
   149 			}
   150 		else
   151 			{
   152 			TEST2(error, KErrNoMemory);
   153 			}
   154 		}
   155 
   156 	CleanupStack::PopAndDestroy(2); // event, active
   157 	}
   158 
   159 /**
   160 @SYMTestCaseID          SYSLIB-LOGENG-CT-0980
   161 @SYMTestCaseDesc	    Tests for CLogViewDuplicate::NewL() functions
   162 @SYMTestPriority 	    High
   163 @SYMTestActions  	    Create a new logviewrecent object,set the recent log view,list out the duplicates of the current event in the recent event list view
   164                         Check for log server failure error
   165 @SYMTestExpectedResults Test must not fail
   166 @SYMREQ                 REQ0000
   167 */
   168 LOCAL_C void TestDuplicateViewConstructWithLogServFailL(CLogClient& aClient)
   169 	{
   170 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0980 "));
   171 	CTestActive* active = new(ELeave)CTestActive;
   172 	CleanupStack::PushL(active);
   173 
   174 	CLogEvent* event = CLogEvent::NewL();
   175 	CleanupStack::PushL(event);
   176 
   177 	// Incoming
   178 	TLogString buf;
   179 	aClient.GetString(buf, R_LOG_DIR_IN);
   180 
   181 	event->SetEventType(KLogCallEventTypeUid);
   182 	event->SetDirection(buf);
   183 	event->SetContact(KTestContact);
   184 
   185 	// Add events
   186 	aClient.AddEvent(*event, active->iStatus);
   187 	active->StartL();
   188 	CActiveScheduler::Start();
   189 	TEST2(active->iStatus.Int(), KErrNone);
   190 
   191 	aClient.AddEvent(*event, active->iStatus);
   192 	active->StartL();
   193 	CActiveScheduler::Start();
   194 	TEST2(active->iStatus.Int(), KErrNone);
   195 
   196 	CLogViewDuplicate* view = NULL;
   197 
   198 	TInt failCount = 0;
   199 	TBool finished = EFalse;
   200 	TInt error;
   201 
   202 	while(!finished)
   203 		{
   204 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   205 
   206 		TRAP(error, view = CLogViewDuplicate::NewL(aClient));
   207 
   208 		__LOGSERV_UHEAP_RESET;
   209 		
   210 		if (!error)
   211 			{
   212 			finished = ETrue;
   213 			CleanupStack::PushL(view);
   214 			
   215 			CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
   216 			CleanupStack::PushL(recent);
   217 			TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
   218 			active->StartL();
   219 			CActiveScheduler::Start();
   220 			TEST2(active->iStatus.Int(), KErrNone);
   221 			TEST(recent->CountL() >= 1);
   222 
   223 			TEST(recent->DuplicatesL(*view, active->iStatus));
   224 			active->StartL();
   225 			CActiveScheduler::Start();
   226 			TEST2(active->iStatus.Int(), KErrNone);
   227 			TEST(view->CountL() >= 1);
   228 
   229 			CleanupStack::PopAndDestroy(2); // recent, view
   230 			}
   231 		else
   232 			{
   233 			TEST2(error, KErrNoMemory);
   234 			}
   235 		}
   236 
   237 	CleanupStack::PopAndDestroy(2); // event, active
   238 	}
   239 
   240 /**
   241 @SYMTestCaseID          SYSLIB-LOGENG-CT-0981
   242 @SYMTestCaseDesc	    Tests for CLogViewEvent::SetFilterL() function 
   243 @SYMTestPriority 	    High
   244 @SYMTestActions  	    Create a log filter and set the filter on logview.Check for equality of events on the view and events
   245 						added.Check for log server failure error
   246 @SYMTestExpectedResults Test must not fail
   247 @SYMREQ                 REQ0000
   248 */
   249 LOCAL_C void TestEventViewSetupWithLogServFailL(CLogClient& aClient)
   250 	{
   251 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0981 "));
   252 	CTestActive* active = new(ELeave)CTestActive;
   253 	CleanupStack::PushL(active);
   254 
   255 	CLogEvent* event = CLogEvent::NewL();
   256 	CleanupStack::PushL(event);
   257 	event->SetEventType(KLogCallEventTypeUid);
   258 	event->SetStatus(KTestStatus);
   259 
   260 	// Add an event
   261 	aClient.AddEvent(*event, active->iStatus);
   262 	active->StartL();
   263 	CActiveScheduler::Start();
   264 	TEST2(active->iStatus.Int(), KErrNone);
   265 
   266 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
   267 	CleanupStack::PushL(view);
   268 
   269 	CLogFilterList* list = new(ELeave)CLogFilterList;
   270 	CleanupStack::PushL(list);
   271 
   272 	CLogFilter* filter = CLogFilter::NewL();
   273 	CleanupStack::PushL(filter);
   274 	filter->SetStatus(KTestStatus);
   275 
   276 	TInt failCount = 0;
   277 	TBool finished = EFalse;
   278 	TInt error;
   279 
   280 	while(!finished)
   281 		{
   282 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   283 
   284 		TBool result = EFalse;
   285 		TRAP(error, result = view->SetFilterL(*filter, active->iStatus));
   286 		
   287 		if (!error)
   288 			{
   289 			TEST(result);
   290 
   291 			active->StartL();
   292 			CActiveScheduler::Start();
   293 
   294 			if (active->iStatus.Int() == KErrNone)
   295 				{
   296 				finished = ETrue;		
   297 				
   298 				TEST(view->CountL() >= 1);
   299 				TEST(TestUtils::EventsEqual(*event, view->Event()));
   300 				}
   301 			else
   302 				{
   303 				TEST2(active->iStatus.Int(), KErrNoMemory);
   304 				}
   305 			}
   306 		else
   307 			{
   308 			TEST2(error, KErrNoMemory);
   309 			}
   310 
   311 		__LOGSERV_UHEAP_RESET;
   312 		}
   313 
   314 	list->AppendL(filter);
   315 	CleanupStack::Pop(); // filter
   316 	
   317 	filter = CLogFilter::NewL();
   318 	CleanupStack::PushL(filter);
   319 	filter->SetEventType(KLogCallEventTypeUid);
   320 	list->AppendL(filter);
   321 	CleanupStack::Pop(); // filter
   322 
   323 	failCount = 0;
   324 	finished = EFalse;
   325 
   326 	while(!finished)
   327 		{
   328 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   329 
   330 		TBool result = EFalse;
   331 		TRAP(error, result = view->SetFilterL(*list, active->iStatus));
   332 		
   333 		if (!error)
   334 			{
   335 			TEST(result);
   336 
   337 			active->StartL();
   338 			CActiveScheduler::Start();
   339 
   340 			if (active->iStatus.Int() == KErrNone)
   341 				{
   342 				finished = ETrue;		
   343 				
   344 				TEST(view->CountL() >= 1);
   345 				TEST(TestUtils::EventsEqual(*event, view->Event()));
   346 				}
   347 			else
   348 				{
   349 				TEST2(active->iStatus.Int(), KErrNoMemory);
   350 				}
   351 			}
   352 		else
   353 			{
   354 			TEST2(error, KErrNoMemory);
   355 			}
   356 
   357 		__LOGSERV_UHEAP_RESET;
   358 		}
   359 
   360 	list->ResetAndDestroy();
   361 	CleanupStack::PopAndDestroy(4); // list, view, event, active
   362 	}
   363 
   364 /**
   365 @SYMTestCaseID          SYSLIB-LOGENG-CT-0982
   366 @SYMTestCaseDesc	    Tests for CLogViewRecent::SetRecentListL() function 
   367 @SYMTestPriority 	    High
   368 @SYMTestActions  	    Set recent view list first without a filter and later with log filter,Check for log server failure error
   369 @SYMTestExpectedResults Test must not fail
   370 @SYMREQ                 REQ0000
   371 */
   372 LOCAL_C void TestRecentViewSetupWithLogServFailL(CLogClient& aClient)
   373 	{
   374 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0982 "));
   375 	CTestActive* active = new(ELeave)CTestActive;
   376 	CleanupStack::PushL(active);
   377 
   378 	CLogEvent* event = CLogEvent::NewL();
   379 	CleanupStack::PushL(event);
   380 
   381 	// Incoming
   382 	TLogString buf;
   383 	aClient.GetString(buf, R_LOG_DIR_IN);
   384 
   385 	event->SetEventType(KLogCallEventTypeUid);
   386 	event->SetDirection(buf);
   387 	event->SetStatus(KTestStatus);
   388 
   389 	// Add an event
   390 	aClient.AddEvent(*event, active->iStatus);
   391 	active->StartL();
   392 	CActiveScheduler::Start();
   393 	TEST2(active->iStatus.Int(), KErrNone);
   394 
   395 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
   396 	CleanupStack::PushL(view);
   397 
   398 	TInt failCount = 0;
   399 	TBool finished = EFalse;
   400 	TInt error;
   401 
   402 	while(!finished)
   403 		{
   404 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   405 
   406 		TBool result = EFalse;
   407 		TRAP(error, result = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
   408 		
   409 		if (!error)
   410 			{
   411 			TEST(result);
   412 
   413 			active->StartL();
   414 			CActiveScheduler::Start();
   415 
   416 			if (active->iStatus.Int() == KErrNone)
   417 				{
   418 				finished = ETrue;		
   419 				TEST(view->CountL() >= 1);
   420 				}
   421 			else
   422 				{
   423 				TEST2(active->iStatus.Int(), KErrNoMemory);
   424 				}
   425 			}
   426 		else
   427 			{
   428 			TEST2(error, KErrNoMemory);
   429 			}
   430 
   431 		__LOGSERV_UHEAP_RESET;
   432 		}
   433 
   434 	CLogFilterList* list = new(ELeave)CLogFilterList;
   435 	CleanupStack::PushL(list);
   436 
   437 	CLogFilter* filter = CLogFilter::NewL();
   438 	CleanupStack::PushL(filter);
   439 	filter->SetStatus(KTestStatus);
   440 
   441 	failCount = 0;
   442 	finished = EFalse;
   443 
   444 	while(!finished)
   445 		{
   446 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   447 
   448 		TBool result = EFalse;
   449 		TRAP(error, result = view->SetRecentListL(KLogRecentIncomingCalls, *filter, active->iStatus));
   450 		
   451 		if (!error)
   452 			{
   453 			TEST(result);
   454 
   455 			active->StartL();
   456 			CActiveScheduler::Start();
   457 
   458 			if (active->iStatus.Int() == KErrNone)
   459 				{
   460 				finished = ETrue;		
   461 				TEST(view->CountL() >= 1);
   462 				}
   463 			else
   464 				TEST2(active->iStatus.Int(), KErrNoMemory);
   465 			}
   466 		else
   467 			TEST2(error, KErrNoMemory);
   468 
   469 		__LOGSERV_UHEAP_RESET;
   470 		}
   471 
   472 	list->AppendL(filter);
   473 	CleanupStack::Pop(); // filter
   474 
   475 	filter = CLogFilter::NewL();
   476 	CleanupStack::PushL(filter);
   477 	filter->SetEventType(KLogCallEventTypeUid);
   478 	list->AppendL(filter);
   479 	CleanupStack::Pop(); // filter
   480 
   481 	failCount = 0;
   482 	finished = EFalse;
   483 
   484 	while(!finished)
   485 		{
   486 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   487 
   488 		TBool result = EFalse;
   489 		TRAP(error, result = view->SetRecentListL(KLogRecentIncomingCalls, *list, active->iStatus));
   490 		
   491 		if (!error)
   492 			{
   493 			TEST(result);
   494 
   495 			active->StartL();
   496 			CActiveScheduler::Start();
   497 
   498 			if (active->iStatus.Int() == KErrNone)
   499 				{
   500 				finished = ETrue;		
   501 				TEST(view->CountL() >= 1);
   502 				}
   503 			else
   504 				TEST2(active->iStatus.Int(), KErrNoMemory);
   505 			}
   506 		else
   507 			TEST2(error, KErrNoMemory);
   508 
   509 		__LOGSERV_UHEAP_RESET;
   510 		}
   511 
   512 	list->ResetAndDestroy();
   513 	CleanupStack::PopAndDestroy(4); // list, view, event, active
   514 	}
   515 
   516 /**
   517 @SYMTestCaseID          SYSLIB-LOGENG-CT-0983
   518 @SYMTestCaseDesc	    Tests for CLogViewRecent::DuplicatesL() function
   519 @SYMTestPriority 	    High
   520 @SYMTestActions  	    Set the specified duplicate event view with logview duplicates.
   521                         Check for log server failure error
   522 @SYMTestExpectedResults Test must not fail
   523 @SYMREQ                 REQ0000
   524 */
   525 LOCAL_C void TestDuplicateViewSetupWithLogServFailL(CLogClient& aClient)
   526 	{
   527 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0983 "));
   528 	CTestActive* active = new(ELeave)CTestActive;
   529 	CleanupStack::PushL(active);
   530 
   531 	CLogEvent* event = CLogEvent::NewL();
   532 	CleanupStack::PushL(event);
   533 
   534 	// Incoming
   535 	TLogString buf;
   536 	aClient.GetString(buf, R_LOG_DIR_IN);
   537 
   538 	event->SetEventType(KLogCallEventTypeUid);
   539 	event->SetDirection(buf);
   540 	event->SetContact(KTestContact);
   541 	event->SetStatus(KTestStatus);
   542 
   543 	// Add events
   544 	aClient.AddEvent(*event, active->iStatus);
   545 	active->StartL();
   546 	CActiveScheduler::Start();
   547 	TEST2(active->iStatus.Int(), KErrNone);
   548 
   549 	aClient.AddEvent(*event, active->iStatus);
   550 	active->StartL();
   551 	CActiveScheduler::Start();
   552 	TEST2(active->iStatus.Int(), KErrNone);
   553 
   554 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
   555 	CleanupStack::PushL(view);
   556 
   557 	TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
   558 	active->StartL();
   559 	CActiveScheduler::Start();
   560 	TEST2(active->iStatus.Int(), KErrNone);
   561 	
   562 	CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient);
   563 	CleanupStack::PushL(duplicate);
   564 
   565 	TInt failCount = 0;
   566 	TBool finished = EFalse;
   567 	TInt error;
   568 
   569 	while(!finished)
   570 		{
   571 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   572 
   573 		TBool result = EFalse;
   574 		TRAP(error, result = view->DuplicatesL(*duplicate, active->iStatus));
   575 		
   576 		if (!error)
   577 			{
   578 			TEST(result);
   579 
   580 			active->StartL();
   581 			CActiveScheduler::Start();
   582 
   583 			if (active->iStatus.Int() == KErrNone)
   584 				{
   585 				finished = ETrue;		
   586 				TEST(duplicate->CountL() >= 1);
   587 				}
   588 			else
   589 				TEST2(active->iStatus.Int(), KErrNoMemory);
   590 			}
   591 		else
   592 			TEST2(error, KErrNoMemory);
   593 
   594 		__LOGSERV_UHEAP_RESET;
   595 		}
   596 
   597 	CLogFilterList* list = new(ELeave)CLogFilterList;
   598 	CleanupStack::PushL(list);
   599 
   600 	CLogFilter* filter = CLogFilter::NewL();
   601 	CleanupStack::PushL(filter);
   602 	filter->SetStatus(KTestStatus);
   603 
   604 	failCount = 0;
   605 	finished = EFalse;
   606 
   607 	while(!finished)
   608 		{
   609 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   610 
   611 		TBool result = EFalse;
   612 		TRAP(error, result = view->DuplicatesL(*duplicate, *filter, active->iStatus));
   613 		
   614 		if (!error)
   615 			{
   616 			TEST(result);
   617 
   618 			active->StartL();
   619 			CActiveScheduler::Start();
   620 
   621 			if (active->iStatus.Int() == KErrNone)
   622 				{
   623 				finished = ETrue;		
   624 				TEST(duplicate->CountL() >= 1);
   625 				}
   626 			else
   627 				TEST2(active->iStatus.Int(), KErrNoMemory);
   628 			}
   629 		else
   630 			TEST2(error, KErrNoMemory);
   631 
   632 		__LOGSERV_UHEAP_RESET;
   633 		}
   634 
   635 	list->AppendL(filter);
   636 	CleanupStack::Pop(); // filter
   637 
   638 	filter = CLogFilter::NewL();
   639 	CleanupStack::PushL(filter);
   640 	filter->SetEventType(KLogCallEventTypeUid);
   641 	list->AppendL(filter);
   642 	CleanupStack::Pop(); // filter
   643 
   644 	failCount = 0;
   645 	finished = EFalse;
   646 
   647 	while(!finished)
   648 		{
   649 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   650 
   651 		TBool result = EFalse;
   652 		TRAP(error, result = view->DuplicatesL(*duplicate, *list, active->iStatus));
   653 		
   654 		if (!error)
   655 			{
   656 			TEST(result);
   657 
   658 			active->StartL();
   659 			CActiveScheduler::Start();
   660 
   661 			if (active->iStatus.Int() == KErrNone)
   662 				{
   663 				finished = ETrue;		
   664 				TEST(duplicate->CountL() >= 1);
   665 				}
   666 			else
   667 				TEST2(active->iStatus.Int(), KErrNoMemory);
   668 			}
   669 		else
   670 			TEST2(error, KErrNoMemory);
   671 
   672 		__LOGSERV_UHEAP_RESET;
   673 		}
   674 
   675 	list->ResetAndDestroy();
   676 	CleanupStack::PopAndDestroy(5); // list, duplicate, view, event, active
   677 	}
   678 
   679 /**
   680 @SYMTestCaseID          SYSLIB-LOGENG-CT-0984
   681 @SYMTestCaseDesc	    Tests for CLogViewEvent::NextL(),LastL(),PreviousL(),FirstL() functions
   682 @SYMTestPriority 	    High
   683 @SYMTestActions  	    Tests for all the navigation functions in the view.Check for log server failure error 
   684 @SYMTestExpectedResults Test must not fail
   685 @SYMREQ                 REQ0000
   686 */
   687 LOCAL_C void TestNavigationWithLogServFailL(CLogClient& aClient)
   688 	{
   689 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0984 "));
   690 	CTestActive* active = new(ELeave)CTestActive;
   691 	CleanupStack::PushL(active);
   692 
   693 	CLogEvent* event = CLogEvent::NewL();
   694 	CleanupStack::PushL(event);
   695 	event->SetEventType(KLogCallEventTypeUid);
   696 
   697 	// Add an event
   698 	aClient.AddEvent(*event, active->iStatus);
   699 	active->StartL();
   700 	CActiveScheduler::Start();
   701 	TEST2(active->iStatus.Int(), KErrNone);
   702 
   703 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
   704 	CleanupStack::PushL(view);
   705 
   706 	CLogFilter* filter = CLogFilter::NewL();
   707 	CleanupStack::PushL(filter);
   708 
   709 	TInt failCount = 0;
   710 	TBool finished = EFalse;
   711 	TInt error;
   712 
   713 	while(!finished)
   714 		{
   715 		TEST(view->SetFilterL(*filter, active->iStatus));
   716 		active->StartL();
   717 		CActiveScheduler::Start();
   718 		TEST2(active->iStatus.Int(), KErrNone);
   719 		TEST(view->CountL() > 1);
   720 		event->CopyL(view->Event());
   721 
   722 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   723 
   724 		TBool result = EFalse;
   725 		TRAP(error, result = view->NextL(active->iStatus));
   726 		
   727 		if (!error)
   728 			{
   729 			TEST(result);
   730 
   731 			active->StartL();
   732 			CActiveScheduler::Start();
   733 
   734 			if (active->iStatus.Int() == KErrNone)
   735 				{
   736 				finished = ETrue;
   737 				TEST(!TestUtils::EventsEqual(*event, view->Event()));
   738 				}
   739 			else
   740 				TEST2(active->iStatus.Int(), KErrNoMemory);
   741 			}
   742 		else
   743 			TEST2(error, KErrNoMemory);
   744 
   745 		__LOGSERV_UHEAP_RESET;
   746 		}
   747 
   748 	failCount = 0;
   749 	finished = EFalse;
   750 
   751 	while(!finished)
   752 		{
   753 		TEST(view->SetFilterL(*filter, active->iStatus));
   754 		active->StartL();
   755 		CActiveScheduler::Start();
   756 		TEST2(active->iStatus.Int(), KErrNone);
   757 		TEST(view->CountL() > 1);
   758 
   759 		TEST(view->LastL(active->iStatus));
   760 		active->StartL();
   761 		CActiveScheduler::Start();
   762 		TEST2(active->iStatus.Int(), KErrNone);
   763 
   764 		event->CopyL(view->Event());
   765 
   766 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   767 
   768 		TBool result = EFalse;
   769 		TRAP(error, result = view->PreviousL(active->iStatus));
   770 		
   771 		if (!error)
   772 			{
   773 			TEST(result);
   774 
   775 			active->StartL();
   776 			CActiveScheduler::Start();
   777 
   778 			if (active->iStatus.Int() == KErrNone)
   779 				{
   780 				finished = ETrue;
   781 				TEST(!TestUtils::EventsEqual(*event, view->Event()));
   782 				}
   783 			else
   784 				TEST2(active->iStatus.Int(), KErrNoMemory);
   785 			}
   786 		else
   787 			TEST2(error, KErrNoMemory);
   788 
   789 		__LOGSERV_UHEAP_RESET;
   790 		}
   791 
   792 	failCount = 0;
   793 	finished = EFalse;
   794 
   795 	while(!finished)
   796 		{
   797 		TEST(view->SetFilterL(*filter, active->iStatus));
   798 		active->StartL();
   799 		CActiveScheduler::Start();
   800 		TEST2(active->iStatus.Int(), KErrNone);
   801 		TEST(view->CountL() > 1);
   802 
   803 		TEST(view->LastL(active->iStatus));
   804 		active->StartL();
   805 		CActiveScheduler::Start();
   806 		TEST2(active->iStatus.Int(), KErrNone);
   807 
   808 		event->CopyL(view->Event());
   809 
   810 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   811 
   812 		TBool result = EFalse;
   813 		TRAP(error, result = view->FirstL(active->iStatus));
   814 		
   815 		if (!error)
   816 			{
   817 			TEST(result);
   818 
   819 			active->StartL();
   820 			CActiveScheduler::Start();
   821 
   822 			if (active->iStatus.Int() == KErrNone)
   823 				{
   824 				finished = ETrue;
   825 				TEST(!TestUtils::EventsEqual(*event, view->Event()));
   826 				}
   827 			else
   828 				TEST2(active->iStatus.Int(), KErrNoMemory);
   829 			}
   830 		else
   831 			TEST2(error, KErrNoMemory);
   832 
   833 		__LOGSERV_UHEAP_RESET;
   834 		}
   835 
   836 	failCount = 0;
   837 	finished = EFalse;
   838 
   839 	while(!finished)
   840 		{
   841 		TEST(view->SetFilterL(*filter, active->iStatus));
   842 		active->StartL();
   843 		CActiveScheduler::Start();
   844 		TEST2(active->iStatus.Int(), KErrNone);
   845 		TEST(view->CountL() > 1);
   846 
   847 		TEST(view->FirstL(active->iStatus));
   848 		active->StartL();
   849 		CActiveScheduler::Start();
   850 		TEST2(active->iStatus.Int(), KErrNone);
   851 
   852 		event->CopyL(view->Event());
   853 
   854 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   855 
   856 		TBool result = EFalse;
   857 		TRAP(error, result = view->LastL(active->iStatus));
   858 		
   859 		if (!error)
   860 			{
   861 			TEST(result);
   862 
   863 			active->StartL();
   864 			CActiveScheduler::Start();
   865 
   866 			if (active->iStatus.Int() == KErrNone)
   867 				{
   868 				finished = ETrue;
   869 				TEST(!TestUtils::EventsEqual(*event, view->Event()));
   870 				}
   871 			else
   872 				TEST2(active->iStatus.Int(), KErrNoMemory);
   873 			}
   874 		else
   875 			TEST2(error, KErrNoMemory);
   876 
   877 		__LOGSERV_UHEAP_RESET;
   878 		}
   879 
   880 	CleanupStack::PopAndDestroy(4); // filter, view, event, active
   881 	}
   882 
   883 /**
   884 @SYMTestCaseID          SYSLIB-LOGENG-CT-0985
   885 @SYMTestCaseDesc	    Tests for CLogViewEvent::CountL() functions
   886 @SYMTestPriority 	    High
   887 @SYMTestActions  	    Test for getting the number of events in the view.Check for log server failure error 
   888 @SYMTestExpectedResults Test must not fail
   889 @SYMREQ                 REQ0000
   890 */
   891 LOCAL_C void TestViewCountWithLogServFailL(CLogClient& aClient)
   892 	{
   893 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0985 "));
   894 	CTestActive* active = new(ELeave)CTestActive;
   895 	CleanupStack::PushL(active);
   896 
   897 	CLogEvent* event = CLogEvent::NewL();
   898 	CleanupStack::PushL(event);
   899 	event->SetEventType(KLogCallEventTypeUid);
   900 
   901 	// Add an event
   902 	aClient.AddEvent(*event, active->iStatus);
   903 	active->StartL();
   904 	CActiveScheduler::Start();
   905 	TEST2(active->iStatus.Int(), KErrNone);
   906 
   907 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
   908 	CleanupStack::PushL(view);
   909 
   910 	CLogFilter* filter = CLogFilter::NewL();
   911 	CleanupStack::PushL(filter);
   912 
   913 	TEST(view->SetFilterL(*filter, active->iStatus));
   914 	active->StartL();
   915 	CActiveScheduler::Start();
   916 	TEST2(active->iStatus.Int(), KErrNone);
   917 
   918 	TInt failCount = 0;
   919 	TBool finished = EFalse;
   920 	TInt error;
   921 
   922 	while(!finished)
   923 		{
   924 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
   925 
   926 		TInt result = 0;
   927 		TRAP(error, result = view->CountL());
   928 		
   929 		if (!error)
   930 			{
   931 			finished = ETrue;
   932 			TEST(result > 0);
   933 			}
   934 		else
   935 			TEST2(error, KErrNoMemory);
   936 
   937 		__LOGSERV_UHEAP_RESET;
   938 		}
   939 
   940 	CleanupStack::PopAndDestroy(4); // filter, view, event, active
   941 	}
   942 
   943 /**
   944 @SYMTestCaseID          SYSLIB-LOGENG-CT-0986
   945 @SYMTestCaseDesc	    Tests for CLogViewRecent::RemoveL() function
   946 @SYMTestPriority 	    High
   947 @SYMTestActions  	    Test for removing the event with the specified unique event ID from the view
   948 						Check for log server failure error
   949 @SYMTestExpectedResults Test must not fail
   950 @SYMREQ                 REQ0000
   951 */
   952 LOCAL_C void TestRecentViewRemoveWithLogServFailL(CLogClient& aClient)
   953 	{
   954 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0986 "));
   955 	CTestActive* active = new(ELeave)CTestActive;
   956 	CleanupStack::PushL(active);
   957 
   958 	CLogEvent* event = CLogEvent::NewL();
   959 	CleanupStack::PushL(event);
   960 
   961 	// Incoming
   962 	TLogString buf;
   963 	aClient.GetString(buf, R_LOG_DIR_IN);
   964 
   965 	event->SetEventType(KLogCallEventTypeUid);
   966 	event->SetDirection(buf);
   967 	event->SetContact(1);
   968 
   969 	// Add events
   970 	aClient.AddEvent(*event, active->iStatus);
   971 	active->StartL();
   972 	CActiveScheduler::Start();
   973 	TEST2(active->iStatus.Int(), KErrNone);
   974 
   975 	event->SetContact(2);
   976 
   977 	aClient.AddEvent(*event, active->iStatus);
   978 	active->StartL();
   979 	CActiveScheduler::Start();
   980 	TEST2(active->iStatus.Int(), KErrNone);
   981 
   982 	event->SetContact(3);
   983 
   984 	aClient.AddEvent(*event, active->iStatus);
   985 	active->StartL();
   986 	CActiveScheduler::Start();
   987 	TEST2(active->iStatus.Int(), KErrNone);
   988 
   989 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
   990 	CleanupStack::PushL(view);
   991 
   992 	TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
   993 	active->StartL();
   994 	CActiveScheduler::Start();
   995 	TEST2(active->iStatus.Int(), KErrNone);
   996 
   997 	TInt count = view->CountL();
   998 	TEST(count > 1);
   999 
  1000 	TInt failCount = 0;
  1001 	TBool finished = EFalse;
  1002 	TInt error;
  1003 
  1004 	while(!finished)
  1005 		{
  1006 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
  1007 
  1008 		TRAP(error, view->RemoveL(view->Event().Id()));
  1009 
  1010 		__LOGSERV_UHEAP_RESET;
  1011 
  1012 		if (!error)
  1013 			{
  1014 			finished = ETrue;
  1015 
  1016 			TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
  1017 			active->StartL();
  1018 			CActiveScheduler::Start();
  1019 			TEST2(active->iStatus.Int(), KErrNone);
  1020 
  1021 			TEST(count == view->CountL() + 1);
  1022 			}
  1023 		else
  1024 			TEST2(error, KErrNoMemory);
  1025 		}
  1026 
  1027 	failCount = 0;
  1028 	finished = EFalse;
  1029 
  1030 	while(!finished)
  1031 		{
  1032 		TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
  1033 		active->StartL();
  1034 		CActiveScheduler::Start();
  1035 		TEST2(active->iStatus.Int(), KErrNone);
  1036 
  1037 		count = view->CountL();
  1038 		TEST(count > 1);
  1039 
  1040 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
  1041 
  1042 		TBool ret = EFalse;
  1043 		TRAP(error, ret = view->RemoveL(active->iStatus));
  1044 
  1045 		__LOGSERV_UHEAP_RESET;
  1046 
  1047 		if (!error)
  1048 			{
  1049 			TEST(ret);
  1050 
  1051 			active->StartL();
  1052 			CActiveScheduler::Start();
  1053 
  1054 			if (active->iStatus == KErrNone)
  1055 				{
  1056 				TEST(count == view->CountL() + 1);
  1057 				finished = ETrue;
  1058 				}
  1059 			else
  1060 				TEST2(active->iStatus.Int(), KErrNoMemory);
  1061 			}
  1062 		else
  1063 			TEST2(error, KErrNoMemory);
  1064 		}
  1065 
  1066 	CleanupStack::PopAndDestroy(3); // view, event, active
  1067 	}
  1068 
  1069 /**
  1070 @SYMTestCaseID          SYSLIB-LOGENG-CT-0987
  1071 @SYMTestCaseDesc	    Tests for CLogViewDuplicate::RemoveL() function
  1072 @SYMTestPriority 	    High
  1073 @SYMTestActions  	    Test for removing the event with the specified unique event ID from the view.Check for memory error
  1074 @SYMTestExpectedResults Test must not fail
  1075 @SYMREQ                 REQ0000
  1076 */
  1077 LOCAL_C void TestDuplicateViewRemoveWithLogServFailL(CLogClient& aClient)
  1078 	{
  1079 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0987 "));
  1080 	CTestActive* active = new(ELeave)CTestActive;
  1081 	CleanupStack::PushL(active);
  1082 
  1083 	CLogEvent* event = CLogEvent::NewL();
  1084 	CleanupStack::PushL(event);
  1085 
  1086 	// Incoming
  1087 	TLogString buf;
  1088 	aClient.GetString(buf, R_LOG_DIR_IN);
  1089 
  1090 	event->SetEventType(KLogCallEventTypeUid);
  1091 	event->SetDirection(buf);
  1092 	event->SetContact(KTestContact);
  1093 
  1094 	// Add events
  1095 	aClient.AddEvent(*event, active->iStatus);
  1096 	active->StartL();
  1097 	CActiveScheduler::Start();
  1098 	TEST2(active->iStatus.Int(), KErrNone);
  1099 
  1100 	aClient.AddEvent(*event, active->iStatus);
  1101 	active->StartL();
  1102 	CActiveScheduler::Start();
  1103 	TEST2(active->iStatus.Int(), KErrNone);
  1104 
  1105 	aClient.AddEvent(*event, active->iStatus);
  1106 	active->StartL();
  1107 	CActiveScheduler::Start();
  1108 	TEST2(active->iStatus.Int(), KErrNone);
  1109 
  1110 	aClient.AddEvent(*event, active->iStatus);
  1111 	active->StartL();
  1112 	CActiveScheduler::Start();
  1113 	TEST2(active->iStatus.Int(), KErrNone);
  1114 
  1115 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
  1116 	CleanupStack::PushL(view);
  1117 
  1118 	TEST(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
  1119 	active->StartL();
  1120 	CActiveScheduler::Start();
  1121 	TEST2(active->iStatus.Int(), KErrNone);
  1122 
  1123 	CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient);
  1124 	CleanupStack::PushL(duplicate);
  1125 
  1126 	TEST(view->DuplicatesL(*duplicate, active->iStatus));
  1127 	active->StartL();
  1128 	CActiveScheduler::Start();
  1129 	TEST2(active->iStatus.Int(), KErrNone);
  1130 	
  1131 	TInt count = duplicate->CountL();
  1132 	TEST(count > 0);
  1133 
  1134 	TInt failCount = 0;
  1135 	TBool finished = EFalse;
  1136 	TInt error;
  1137 
  1138 	while(!finished)
  1139 		{
  1140 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
  1141 
  1142 		TRAP(error, duplicate->RemoveL(duplicate->Event().Id()));
  1143 
  1144 		__LOGSERV_UHEAP_RESET;
  1145 
  1146 		if (!error)
  1147 			{
  1148 			finished = ETrue;
  1149 
  1150 			TEST(view->DuplicatesL(*duplicate, active->iStatus));
  1151 			active->StartL();
  1152 			CActiveScheduler::Start();
  1153 			TEST2(active->iStatus.Int(), KErrNone);
  1154 
  1155 			TEST(count == duplicate->CountL() + 1);
  1156 			}
  1157 		else
  1158 			TEST2(error, KErrNoMemory);
  1159 		}
  1160 
  1161 	failCount = 0;
  1162 	finished = EFalse;
  1163 
  1164 	while(!finished)
  1165 		{
  1166 		TEST(view->DuplicatesL(*duplicate, active->iStatus));
  1167 		active->StartL();
  1168 		CActiveScheduler::Start();
  1169 		TEST2(active->iStatus.Int(), KErrNone);
  1170 
  1171 		count = duplicate->CountL();
  1172 
  1173 		__LOGSERV_UHEAP_FAILNEXT(failCount++);
  1174 
  1175 		TBool ret = EFalse;
  1176 		TRAP(error, ret = duplicate->RemoveL(active->iStatus));
  1177 
  1178 		__LOGSERV_UHEAP_RESET;
  1179 
  1180 		if (!error)
  1181 			{
  1182 			if (ret)
  1183 				{
  1184 				active->StartL();
  1185 				CActiveScheduler::Start();
  1186 				}
  1187 
  1188 			if (!ret || active->iStatus == KErrNone)
  1189 				{
  1190 				finished = ETrue;
  1191 				TEST(count == duplicate->CountL() + 1);
  1192 				}
  1193 			else
  1194 				TEST2(active->iStatus.Int(), KErrNoMemory);
  1195 			}
  1196 		else
  1197 			TEST2(error, KErrNoMemory);
  1198 		}
  1199 
  1200 	CleanupStack::PopAndDestroy(4); // duplicate, view, event, active
  1201 	}
  1202 
  1203 void doTestsL()
  1204 	{
  1205 	TestUtils::Initialize(_L("t_logviewfail3"));
  1206 	TestUtils::DeleteDatabaseL();
  1207 
  1208 	CLogClient* client = CLogClient::NewL(theFs);
  1209 	CleanupStack::PushL(client);
  1210 
  1211 	TheTest.Start(_L("Heap Failure in Log Server"));
  1212 
  1213 	TheTest.Next(_L("View Construction"));
  1214 	TestEventViewConstructWithLogServFailL(*client);
  1215 	TestRecentViewConstructWithLogServFailL(*client);
  1216 	TestDuplicateViewConstructWithLogServFailL(*client);
  1217 	theLog.Write(_L8("Test 1 OK\n"));
  1218 
  1219 	TheTest.Next(_L("View Setup"));
  1220 	TestEventViewSetupWithLogServFailL(*client);
  1221 	TestRecentViewSetupWithLogServFailL(*client);
  1222 	TestDuplicateViewSetupWithLogServFailL(*client);
  1223 	theLog.Write(_L8("Test 2 OK\n"));
  1224 
  1225 	TheTest.Next(_L("View Navigation"));
  1226 	TestNavigationWithLogServFailL(*client);
  1227 	theLog.Write(_L8("Test 3 OK\n"));
  1228 
  1229 	TheTest.Next(_L("Other"));
  1230 	TestViewCountWithLogServFailL(*client);
  1231 	TestRecentViewRemoveWithLogServFailL(*client);
  1232 	TestDuplicateViewRemoveWithLogServFailL(*client);
  1233 	theLog.Write(_L8("Test 4 OK\n"));
  1234 
  1235 	CleanupStack::PopAndDestroy(); // client;
  1236 	}