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