os/persistentdata/loggingservices/eventlogger/test/src/t_logview1.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 #include <s32file.h>
    16 #include <s32mem.h>
    17 #include <e32math.h>
    18 #include "t_logutil2.h"
    19 #include <logview.h>
    20 
    21 #define UNUSED_VAR(a) a = a
    22 
    23 RTest TheTest(_L("t_logview1"));
    24 
    25 const TInt KTestLogNumberCharsToMatch = 9; // should be the same as KLogNumberCharsToMatch defined in LogServ\src\LOGFILTQ.CPP
    26 const TInt KTestEventNum = 10;
    27 const TUid KTestEventUid = {0x10005393};
    28 const TLogDurationType KTestDurationType = 0x12;
    29 const TLogContactItemId KTestContact = 0x1234;
    30 _LIT(KTestEventDesc, "Test Event");
    31 _LIT(KTestRemoteParty, "Test Remote Party");
    32 _LIT(KTestDirection, "Test Direction");
    33 _LIT(KTestStatus, "Test Status");
    34 _LIT(KTestNumber, "Test Number");
    35 _LIT(KThreadSemaphoreName, "T_VIEW1_TEST_CODE");
    36 
    37 
    38 TBool TheMatchingIsEnabled = EFalse;
    39 
    40 #define TEST_LOG_UID KTestEventUid
    41 
    42 //View's DoCancel() test
    43 void DoViewCancelTestL(CTestActive& aActive, CLogViewEvent& aView)
    44 	{
    45 	//Call FirstL() and cancel the operation
    46 	aActive.StartL();
    47 	(void)aView.FirstL(aActive.iStatus);
    48 	aView.Cancel();
    49 	TEST(!aView.IsActive());
    50 	CActiveScheduler::Start();
    51 	TEST2(aActive.iStatus.Int(), KErrCancel);
    52 	
    53 	//Call FirstL(). View cursor positioned on the first record.
    54 	aActive.StartL();
    55 	(void)aView.FirstL(aActive.iStatus);
    56 	CActiveScheduler::Start();
    57 	TEST2(aActive.iStatus.Int(), KErrNone);
    58 
    59 	//Call NextL() and cancel the operation
    60 	aActive.StartL();
    61 	(void)aView.NextL(aActive.iStatus);
    62 	aView.Cancel();
    63 	TEST(!aView.IsActive());
    64 	CActiveScheduler::Start();
    65 	TEST2(aActive.iStatus.Int(), KErrCancel);
    66 
    67 	//Call LastL() and cancel the operation
    68 	aActive.StartL();
    69 	(void)aView.LastL(aActive.iStatus);
    70 	aView.Cancel();
    71 	TEST(!aView.IsActive());
    72 	CActiveScheduler::Start();
    73 	TEST2(aActive.iStatus.Int(), KErrCancel);
    74 
    75 	//Call LastL(). View cursor positioned on the last record.
    76 	aActive.StartL();
    77 	(void)aView.LastL(aActive.iStatus);
    78 	CActiveScheduler::Start();
    79 	TEST2(aActive.iStatus.Int(), KErrNone);
    80 
    81 	//Call PreviousL() and cancel the operation
    82 	aActive.StartL();
    83 	(void)aView.PreviousL(aActive.iStatus);
    84 	aView.Cancel();
    85 	TEST(!aView.IsActive());
    86 	CActiveScheduler::Start();
    87 	TEST2(aActive.iStatus.Int(), KErrCancel);
    88 	}
    89 
    90 /**
    91 @SYMTestCaseID          SYSLIB-LOGENG-CT-0851
    92 @SYMTestCaseDesc	    Tests for adding event types to the log 
    93 @SYMTestPriority 	    High
    94 @SYMTestActions  	    Tests for adding events,check event count,clearing all the events
    95 @SYMTestExpectedResults Test must not fail
    96 @SYMREQ                 REQ0000
    97 */
    98 LOCAL_C void TestEventViewL(CLogClient& aClient)
    99 	{
   100 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0851 "));
   101 	CLogEvent* event = CLogEvent::NewL();
   102 	CleanupStack::PushL(event);
   103 	event->SetEventType(KLogCallEventTypeUid);
   104 
   105 	CTestActive* active = new(ELeave)CTestActive();
   106 	CleanupStack::PushL(active);
   107 
   108 	TInt count;
   109 	for(count = 0; count < KTestEventNum; count++)
   110 		{
   111 		active->StartL();
   112 		aClient.AddEvent(*event, active->iStatus);
   113 		CActiveScheduler::Start();
   114 		TEST2(active->iStatus.Int(), KErrNone);
   115 		}
   116 
   117 	CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
   118 	changeObs->SetActive();
   119 
   120 	CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
   121 	CleanupStack::PushL(view);
   122 
   123 	CLogFilter* filter = CLogFilter::NewL();
   124 	CleanupStack::PushL(filter);
   125 
   126 	count = view->CountL();
   127 	TEST2(count, 0);
   128 	TBool res = view->SetFilterL(*filter, active->iStatus);
   129 	TEST(res);
   130 
   131 	// Move forward
   132 	count = KTestEventNum;
   133 	do	{
   134 		active->StartL();
   135 		CActiveScheduler::Start();
   136 		TEST2(active->iStatus.Int(), KErrNone);
   137 
   138 		const TInt viewCount = view->CountL();
   139 		TEST2(viewCount, KTestEventNum);
   140 		const TLogId eventId = view->Event().Id();
   141 		TLogId id = --count;
   142 		TEST2(eventId, id);
   143 		}
   144 	while(view->NextL(active->iStatus));
   145 	TEST2(count, 0);
   146 
   147 	// Move back
   148 	while(view->PreviousL(active->iStatus))
   149 		{
   150 		active->StartL();
   151 		CActiveScheduler::Start();
   152 		TEST2(active->iStatus.Int(), KErrNone);
   153 
   154 		TEST2(view->CountL(), KTestEventNum);
   155 		TLogId id = ++count;
   156 		TEST2(view->Event().Id(), id);
   157 		}
   158 	TEST2(count, KTestEventNum - 1);
   159 
   160 	active->StartL();
   161 	res = view->FirstL(active->iStatus);
   162 	TEST(res);
   163 	CActiveScheduler::Start();
   164 	TEST2(active->iStatus.Int(), KErrNone);
   165 
   166 	active->StartL();
   167 	res = view->LastL(active->iStatus);
   168 	TEST(res);
   169 	CActiveScheduler::Start();
   170 	TEST2(active->iStatus.Int(), KErrNone);
   171 
   172 	// Nothing has changed in the view yet
   173 	TEST(!changeObs->HaveChanges());
   174 
   175 	DoViewCancelTestL(*active, *view);
   176 	
   177 	TTime now;
   178 	now.UniversalTime();
   179 	now+=(TTimeIntervalDays) 1;
   180 
   181 	// Clear all the events
   182 	active->StartL();
   183 	aClient.ClearLog(now, active->iStatus);
   184 	CActiveScheduler::Start();
   185 	TEST2(active->iStatus.Int(), KErrNone);
   186 
   187 	res = view->SetFilterL(*filter, active->iStatus);
   188 	TEST(!res);
   189 	TEST2(view->CountL(), 0);
   190 	res = view->FirstL(active->iStatus);
   191 	TEST(!res);
   192 	res = view->LastL(active->iStatus);
   193 	TEST(!res);
   194 	res = view->NextL(active->iStatus);
   195 	TEST(!res);
   196 	res = view->PreviousL(active->iStatus);
   197 	TEST(!res);
   198 	
   199 	CleanupStack::PopAndDestroy(5, event); // filter, view, changeObs, active, event
   200 
   201 	CLogSchedulerTimer* timer = CLogSchedulerTimer::NewLC();
   202 	timer->Wait(10 * 1000000);
   203 	CleanupStack::PopAndDestroy(timer);
   204 	}
   205 
   206 /**
   207 @SYMTestCaseID          SYSLIB-LOGENG-CT-0852
   208 @SYMTestCaseDesc	    Tests for adding event types to the filter list
   209 @SYMTestPriority 	    High
   210 @SYMTestActions  	    Set the configuration data of event type.Add the event type to the filter and 
   211                         compare the configuration data of event type and from filter view.
   212 @SYMTestExpectedResults Test must not fail
   213 @SYMREQ                 REQ0000
   214 */
   215 LOCAL_C void TestViewFilterL(CLogClient& aClient, CLogFilter& aFilter)
   216 	{
   217 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0852 "));
   218 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
   219 	CleanupStack::PushL(view);
   220 
   221 	CLogEvent* event = CLogEvent::NewL();
   222 	CleanupStack::PushL(event);
   223 
   224 	event->SetEventType(KTestEventUid);
   225 	event->SetRemoteParty(aFilter.RemoteParty());
   226 	event->SetDirection(aFilter.Direction());
   227 	event->SetDurationType(aFilter.DurationType());
   228 	event->SetStatus(aFilter.Status());
   229 	event->SetContact(aFilter.Contact());
   230 	event->SetNumber(aFilter.Number());
   231 
   232 	CTestActive* active = new(ELeave)CTestActive();
   233 	CleanupStack::PushL(active);
   234 
   235 	if (view->SetFilterL(aFilter, active->iStatus))
   236 		{
   237 		active->StartL();
   238 		CActiveScheduler::Start();
   239 		TEST2(active->iStatus.Int(), KErrNone);
   240 		}
   241 
   242 	TInt total = view->CountL();
   243 
   244 	active->StartL();
   245 	aClient.AddEvent(*event, active->iStatus);
   246 	CActiveScheduler::Start();
   247 	TEST2(active->iStatus.Int(), KErrNone);
   248 
   249 	TBool res = view->SetFilterL(aFilter, active->iStatus);
   250 	TEST(res);
   251 	active->StartL();
   252 	CActiveScheduler::Start();
   253 	TEST2(active->iStatus.Int(), KErrNone);
   254 
   255 	TEST2(view->CountL(), total + 1);
   256 
   257 	TEST2(event->EventType().iUid, KTestEventUid.iUid);
   258 	TEST(event->RemoteParty() == aFilter.RemoteParty());
   259 	TEST(event->Direction() == aFilter.Direction());
   260 	TEST2(event->DurationType(), aFilter.DurationType());
   261 	TEST(event->Status() == aFilter.Status());
   262 	TEST2(event->Contact(), aFilter.Contact());
   263 	TEST(event->Number() == aFilter.Number());
   264 
   265 	TTime now;
   266 	now.UniversalTime();
   267 
   268 	TInt count = 1;
   269 
   270 	while(view->NextL(active->iStatus))
   271 		{
   272 		count++;
   273 		TEST(count <= total + 1);
   274 
   275 		active->StartL();
   276 		CActiveScheduler::Start();
   277 		TEST2(active->iStatus.Int(), KErrNone);
   278 
   279 		TEST(now >= event->Time());
   280 
   281 		if (aFilter.EventType() != KNullUid)
   282 			TEST2(event->EventType().iUid, aFilter.EventType().iUid);
   283 
   284 		if (aFilter.RemoteParty().Length() > 0)
   285 			TEST(event->RemoteParty() == aFilter.RemoteParty());
   286 
   287 		if (aFilter.Direction().Length() > 0)
   288 			TEST(event->Direction() == aFilter.Direction());
   289 
   290 		if (aFilter.DurationType() != KLogNullDurationType)
   291 			TEST2(event->DurationType(), aFilter.DurationType());
   292 
   293 		if (aFilter.Status().Length() > 0)
   294 			TEST(event->Status() == aFilter.Status());
   295 
   296 		if (aFilter.Contact() > KLogNullContactId)
   297 			TEST2(event->Contact(), aFilter.Contact());
   298 
   299 		if (aFilter.Number().Length() > 0)
   300 			TEST(event->Number() == aFilter.Number());
   301 		}
   302 
   303 	TEST2(count, total + 1);
   304 
   305 	CleanupStack::PopAndDestroy(3); // active, event, view;
   306 	}
   307 
   308 /**
   309 @SYMTestCaseID          SYSLIB-LOGENG-CT-0853
   310 @SYMTestCaseDesc	    Tests for filtering the log view
   311 @SYMTestPriority 	    High
   312 @SYMTestActions  	    Tests for the log view filter,which is set with different configuration data
   313 @SYMTestExpectedResults Test must not fail
   314 @SYMREQ                 REQ0000
   315 */
   316 LOCAL_C void TestEventViewFilter1L(CLogClient& aClient)
   317 	{
   318 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0853 "));
   319 	CTestActive* active = new(ELeave)CTestActive();
   320 	CleanupStack::PushL(active);
   321 
   322 	// Create a test event type
   323 	CLogEventType* type = CLogEventType::NewL();
   324 	CleanupStack::PushL(type);
   325 
   326 	type->SetUid(KTestEventUid);
   327 	type->SetDescription(KTestEventDesc);
   328 	type->SetLoggingEnabled(ETrue);
   329 
   330 	// Register the event type
   331 	active->StartL();
   332 	aClient.AddEventType(*type, active->iStatus);
   333 	CActiveScheduler::Start();
   334 	TEST2(active->iStatus.Int(), KErrNone);
   335 
   336 	CleanupStack::PopAndDestroy(); // type
   337 
   338 	CLogFilter* filter = CLogFilter::NewL();
   339 	CleanupStack::PushL(filter);
   340 
   341 	filter->SetEventType(KTestEventUid);
   342 	TestViewFilterL(aClient, *filter);
   343 
   344 	filter->SetEventType(KTestEventUid);
   345 	filter->SetRemoteParty(KTestRemoteParty);
   346 	TestViewFilterL(aClient, *filter);
   347 
   348 	filter->SetEventType(KTestEventUid);
   349 	filter->SetRemoteParty(KTestRemoteParty);
   350 	filter->SetDirection(KTestDirection);
   351 	TestViewFilterL(aClient, *filter);
   352 
   353 	filter->SetEventType(KTestEventUid);
   354 	filter->SetRemoteParty(KTestRemoteParty);
   355 	filter->SetDirection(KTestDirection);
   356 	filter->SetDurationType(KTestDurationType);
   357 	TestViewFilterL(aClient, *filter);
   358 
   359 	filter->SetEventType(KTestEventUid);
   360 	filter->SetRemoteParty(KTestRemoteParty);
   361 	filter->SetDirection(KTestDirection);
   362 	filter->SetDurationType(KTestDurationType);
   363 	filter->SetStatus(KTestStatus);
   364 	TestViewFilterL(aClient, *filter);
   365 
   366 	filter->SetEventType(KTestEventUid);
   367 	filter->SetRemoteParty(KTestRemoteParty);
   368 	filter->SetDirection(KTestDirection);
   369 	filter->SetDurationType(KTestDurationType);
   370 	filter->SetStatus(KTestStatus);
   371 	filter->SetContact(KTestContact);
   372 	TestViewFilterL(aClient, *filter);
   373 
   374 	filter->SetEventType(KTestEventUid);
   375 	filter->SetRemoteParty(KTestRemoteParty);
   376 	filter->SetDirection(KTestDirection);
   377 	filter->SetDurationType(KTestDurationType);
   378 	filter->SetStatus(KTestStatus);
   379 	filter->SetContact(KTestContact);
   380 	filter->SetNumber(KTestNumber);
   381 	TestViewFilterL(aClient, *filter);
   382 
   383 	CleanupStack::PopAndDestroy(); // filter
   384 
   385 	filter = CLogFilter::NewL();
   386 	CleanupStack::PushL(filter);
   387 
   388 	filter->SetRemoteParty(KTestRemoteParty);
   389 	TestViewFilterL(aClient, *filter);
   390 
   391 	filter->SetRemoteParty(KTestRemoteParty);
   392 	filter->SetDirection(KTestDirection);
   393 	TestViewFilterL(aClient, *filter);
   394 
   395 	filter->SetRemoteParty(KTestRemoteParty);
   396 	filter->SetDirection(KTestDirection);
   397 	filter->SetDurationType(KTestDurationType);
   398 	TestViewFilterL(aClient, *filter);
   399 
   400 	filter->SetRemoteParty(KTestRemoteParty);
   401 	filter->SetDirection(KTestDirection);
   402 	filter->SetDurationType(KTestDurationType);
   403 	filter->SetStatus(KTestStatus);
   404 	TestViewFilterL(aClient, *filter);
   405 
   406 	filter->SetRemoteParty(KTestRemoteParty);
   407 	filter->SetDirection(KTestDirection);
   408 	filter->SetDurationType(KTestDurationType);
   409 	filter->SetStatus(KTestStatus);
   410 	filter->SetContact(KTestContact);
   411 	TestViewFilterL(aClient, *filter);
   412 
   413 	filter->SetRemoteParty(KTestRemoteParty);
   414 	filter->SetDirection(KTestDirection);
   415 	filter->SetDurationType(KTestDurationType);
   416 	filter->SetStatus(KTestStatus);
   417 	filter->SetContact(KTestContact);
   418 	filter->SetNumber(KTestNumber);
   419 	TestViewFilterL(aClient, *filter);
   420 
   421 	CleanupStack::PopAndDestroy(); // filter
   422 
   423 	filter = CLogFilter::NewL();
   424 	CleanupStack::PushL(filter);
   425 
   426 	filter->SetDirection(KTestDirection);
   427 	TestViewFilterL(aClient, *filter);
   428 
   429 	filter->SetDirection(KTestDirection);
   430 	filter->SetDurationType(KTestDurationType);
   431 	TestViewFilterL(aClient, *filter);
   432 
   433 	filter->SetDirection(KTestDirection);
   434 	filter->SetDurationType(KTestDurationType);
   435 	filter->SetStatus(KTestStatus);
   436 	TestViewFilterL(aClient, *filter);
   437 
   438 	filter->SetDirection(KTestDirection);
   439 	filter->SetDurationType(KTestDurationType);
   440 	filter->SetStatus(KTestStatus);
   441 	filter->SetContact(KTestContact);
   442 	TestViewFilterL(aClient, *filter);
   443 
   444 	filter->SetDirection(KTestDirection);
   445 	filter->SetDurationType(KTestDurationType);
   446 	filter->SetStatus(KTestStatus);
   447 	filter->SetContact(KTestContact);
   448 	filter->SetNumber(KTestNumber);
   449 	TestViewFilterL(aClient, *filter);
   450 
   451 	CleanupStack::PopAndDestroy(); // filter
   452 
   453 	filter = CLogFilter::NewL();
   454 	CleanupStack::PushL(filter);
   455 
   456 	filter->SetDurationType(KTestDurationType);
   457 	TestViewFilterL(aClient, *filter);
   458 
   459 	filter->SetDurationType(KTestDurationType);
   460 	filter->SetStatus(KTestStatus);
   461 	TestViewFilterL(aClient, *filter);
   462 
   463 	filter->SetDurationType(KTestDurationType);
   464 	filter->SetStatus(KTestStatus);
   465 	filter->SetContact(KTestContact);
   466 	TestViewFilterL(aClient, *filter);
   467 
   468 	filter->SetDurationType(KTestDurationType);
   469 	filter->SetStatus(KTestStatus);
   470 	filter->SetContact(KTestContact);
   471 	filter->SetNumber(KTestNumber);
   472 	TestViewFilterL(aClient, *filter);
   473 
   474 	CleanupStack::PopAndDestroy(); // filter
   475 
   476 	filter = CLogFilter::NewL();
   477 	CleanupStack::PushL(filter);
   478 
   479 	filter->SetStatus(KTestStatus);
   480 	TestViewFilterL(aClient, *filter);
   481 
   482 	filter->SetStatus(KTestStatus);
   483 	filter->SetContact(KTestContact);
   484 	TestViewFilterL(aClient, *filter);
   485 
   486 	filter->SetStatus(KTestStatus);
   487 	filter->SetContact(KTestContact);
   488 	filter->SetNumber(KTestNumber);
   489 	TestViewFilterL(aClient, *filter);
   490 
   491 	CleanupStack::PopAndDestroy(); // filter
   492 
   493 	filter = CLogFilter::NewL();
   494 	CleanupStack::PushL(filter);
   495 
   496 	filter->SetContact(KTestContact);
   497 	TestViewFilterL(aClient, *filter);
   498 
   499 	filter->SetContact(KTestContact);
   500 	filter->SetNumber(KTestNumber);
   501 	TestViewFilterL(aClient, *filter);
   502 
   503 	CleanupStack::PopAndDestroy(); // filter
   504 
   505 	filter = CLogFilter::NewL();
   506 	CleanupStack::PushL(filter);
   507 
   508 	filter->SetNumber(KTestNumber);
   509 	TestViewFilterL(aClient, *filter);
   510 
   511 	CleanupStack::PopAndDestroy(2); // filter, active
   512 	}
   513 
   514 /**
   515 @SYMTestCaseID          SYSLIB-LOGENG-CT-0854
   516 @SYMTestCaseDesc	    Tests for filtering list event types
   517 @SYMTestPriority 	    High
   518 @SYMTestActions  	    Get the count of all event types,call,data,fax events.
   519                         Add some event types to the filter,test for the new count
   520 						Check for non existing event type.
   521 @SYMTestExpectedResults Test must not fail
   522 @SYMREQ                 REQ0000
   523 */
   524 LOCAL_C void TestEventViewFilter2L(CLogClient& aClient)
   525 	{
   526 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0854 "));
   527 	CTestActive* active = new(ELeave)CTestActive();
   528 	CleanupStack::PushL(active);
   529 
   530 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
   531 	CleanupStack::PushL(view);
   532 
   533 	CLogFilter* filter = CLogFilter::NewL();
   534 	CleanupStack::PushL(filter);
   535 
   536 	// Get total count of all events
   537 	if (view->SetFilterL(*filter, active->iStatus))
   538 		{
   539 		active->StartL();
   540 		CActiveScheduler::Start();
   541 		TEST2(active->iStatus.Int(), KErrNone);
   542 		}
   543 	TInt total = view->CountL();
   544 
   545 	filter->SetEventType(KLogCallEventTypeUid);
   546 
   547 	// Get number of call events
   548 	if (view->SetFilterL(*filter, active->iStatus))
   549 		{
   550 		active->StartL();
   551 		CActiveScheduler::Start();
   552 		TEST2(active->iStatus.Int(), KErrNone);
   553 		}
   554 	TInt calls = view->CountL();
   555 
   556 	filter->SetEventType(KLogDataEventTypeUid);
   557 
   558 	// Get number of data events
   559 	if (view->SetFilterL(*filter, active->iStatus))
   560 		{
   561 		active->StartL();
   562 		CActiveScheduler::Start();
   563 		TEST2(active->iStatus.Int(), KErrNone);
   564 		}
   565 	TInt data = view->CountL();
   566 
   567 	filter->SetEventType(KLogFaxEventTypeUid);
   568 
   569 	// Get number of fax events
   570 	if (view->SetFilterL(*filter, active->iStatus))
   571 		{
   572 		active->StartL();
   573 		CActiveScheduler::Start();
   574 		TEST2(active->iStatus.Int(), KErrNone);
   575 		}
   576 	TInt fax = view->CountL();
   577 
   578 	filter->SetEventType(KLogLbsSelfLocateEventTypeUid);
   579 
   580 	// Get number of Lbs self locate events
   581 	if (view->SetFilterL(*filter, active->iStatus))
   582 		{
   583 		active->StartL();
   584 		CActiveScheduler::Start();
   585 		TEST2(active->iStatus.Int(), KErrNone);
   586 		}
   587 	TInt lbsSelf = view->CountL();
   588 
   589 	filter->SetEventType(KLogLbsExternalLocateEventTypeUid);
   590 
   591 	// Get number of Lbs self locate events
   592 	if (view->SetFilterL(*filter, active->iStatus))
   593 		{
   594 		active->StartL();
   595 		CActiveScheduler::Start();
   596 		TEST2(active->iStatus.Int(), KErrNone);
   597 		}
   598 	TInt lbsExternal = view->CountL();
   599 
   600 	filter->SetEventType(KLogLbsTransmitLocationEventTypeUid);
   601 
   602 	// Get number of Lbs transmit location events
   603 	if (view->SetFilterL(*filter, active->iStatus))
   604 		{
   605 		active->StartL();
   606 		CActiveScheduler::Start();
   607 		TEST2(active->iStatus.Int(), KErrNone);
   608 		}
   609 	TInt lbsXmitLoc = view->CountL();
   610 
   611 	filter->SetEventType(KLogLbsNetworkLocateEventTypeUid);
   612 
   613 	// Get number of Lbs network locate events
   614 	if (view->SetFilterL(*filter, active->iStatus))
   615 		{
   616 		active->StartL();
   617 		CActiveScheduler::Start();
   618 		TEST2(active->iStatus.Int(), KErrNone);
   619 		}
   620 	TInt lbsNetwork = view->CountL();
   621 
   622 	filter->SetEventType(KLogLbsAssistanceDataEventTypeUid);
   623 
   624 	// Get number of Lbs assistance data events
   625 	if (view->SetFilterL(*filter, active->iStatus))
   626 		{
   627 		active->StartL();
   628 		CActiveScheduler::Start();
   629 		TEST2(active->iStatus.Int(), KErrNone);
   630 		}
   631 	TInt lbsAssistance = view->CountL();
   632 
   633 	CLogEvent* event = CLogEvent::NewL();
   634 	CleanupStack::PushL(event);
   635 
   636 	event->SetEventType(KLogCallEventTypeUid);
   637 
   638 	// Add two call events
   639 	active->StartL();
   640 	aClient.AddEvent(*event, active->iStatus);
   641 	CActiveScheduler::Start();
   642 	TEST2(active->iStatus.Int(), KErrNone);
   643 
   644 	active->StartL();
   645 	aClient.AddEvent(*event, active->iStatus);
   646 	CActiveScheduler::Start();
   647 	TEST2(active->iStatus.Int(), KErrNone);
   648 
   649 	event->SetEventType(KLogDataEventTypeUid);
   650 
   651 	// Add two data events
   652 	active->StartL();
   653 	aClient.AddEvent(*event, active->iStatus);
   654 	CActiveScheduler::Start();
   655 	TEST2(active->iStatus.Int(), KErrNone);
   656 
   657 	active->StartL();
   658 	aClient.AddEvent(*event, active->iStatus);
   659 	CActiveScheduler::Start();
   660 	TEST2(active->iStatus.Int(), KErrNone);
   661 
   662 	// Filter all event types
   663 	filter->SetEventType(KNullUid);
   664 
   665 	// Get view of all events
   666 	active->StartL();
   667 	TBool res = view->SetFilterL(*filter, active->iStatus);
   668 	TEST(res);
   669 	CActiveScheduler::Start();
   670 	TEST2(active->iStatus.Int(), KErrNone);
   671 
   672 	// Check the count is correct
   673 	TEST2(view->CountL(), total + 4);
   674 
   675 	filter->SetEventType(KLogCallEventTypeUid);
   676 
   677 	// Get view of call events
   678 	active->StartL();
   679 	res = view->SetFilterL(*filter, active->iStatus);
   680 	TEST(res);
   681 	CActiveScheduler::Start();
   682 	TEST2(active->iStatus.Int(), KErrNone);
   683 
   684 	TEST2(view->CountL(), calls + 2);
   685 
   686 	filter->SetEventType(KLogDataEventTypeUid);
   687 
   688 	// Get view of data events
   689 	active->StartL();
   690 	res = view->SetFilterL(*filter, active->iStatus);
   691 	TEST(res);
   692 	CActiveScheduler::Start();
   693 	TEST2(active->iStatus.Int(), KErrNone);
   694 
   695 	TEST2(view->CountL(), data + 2);
   696 
   697 	filter->SetEventType(KLogFaxEventTypeUid);
   698 
   699 	// Get view of fax events
   700 	if (view->SetFilterL(*filter, active->iStatus))
   701 		{
   702 		active->StartL();
   703 		CActiveScheduler::Start();
   704 		TEST2(active->iStatus.Int(), KErrNone);
   705 		}
   706 	TEST2(view->CountL(), fax);
   707 
   708 	filter->SetEventType(KLogLbsSelfLocateEventTypeUid);
   709 
   710 	// Get number of Lbs self locate events
   711 	if (view->SetFilterL(*filter, active->iStatus))
   712 		{
   713 		active->StartL();
   714 		CActiveScheduler::Start();
   715 		TEST2(active->iStatus.Int(), KErrNone);
   716 		}
   717 	TEST2(view->CountL(), lbsSelf);
   718 
   719 	filter->SetEventType(KLogLbsExternalLocateEventTypeUid);
   720 
   721 	// Get number of Lbs self locate events	
   722 	if (view->SetFilterL(*filter, active->iStatus))
   723 		{
   724 		active->StartL();
   725 		CActiveScheduler::Start();
   726 		TEST2(active->iStatus.Int(), KErrNone);
   727 		}
   728 	TEST2(view->CountL(), lbsExternal);
   729 
   730 	filter->SetEventType(KLogLbsTransmitLocationEventTypeUid);
   731 
   732 	// Get number of Lbs transmit location events
   733 	if (view->SetFilterL(*filter, active->iStatus))
   734 		{
   735 		active->StartL();
   736 		CActiveScheduler::Start();
   737 		TEST2(active->iStatus.Int(), KErrNone);
   738 		}
   739 	TEST2(view->CountL(), lbsXmitLoc);
   740 
   741 	filter->SetEventType(KLogLbsNetworkLocateEventTypeUid);
   742 
   743 	// Get number of Lbs network locate events
   744 	if (view->SetFilterL(*filter, active->iStatus))
   745 		{
   746 		active->StartL();
   747 		CActiveScheduler::Start();
   748 		TEST2(active->iStatus.Int(), KErrNone);
   749 		}
   750 	TEST2(view->CountL(), lbsNetwork);
   751 
   752 	filter->SetEventType(KLogLbsAssistanceDataEventTypeUid);
   753 
   754 	// Get number of Lbs assistance data events
   755 	if (view->SetFilterL(*filter, active->iStatus))
   756 		{
   757 		active->StartL();
   758 		CActiveScheduler::Start();
   759 		TEST2(active->iStatus.Int(), KErrNone);
   760 		}
   761 	TEST2(view->CountL(), lbsAssistance);
   762 
   763 	// Test a non existing event type
   764 	filter->SetEventType(TUid::Uid(0x12345678));
   765 	res = view->SetFilterL(*filter, active->iStatus);
   766 	TEST(!res);
   767 	TEST2(view->CountL(), 0);
   768 
   769 	CleanupStack::PopAndDestroy(4); // view, filter, event, active
   770 	}
   771 
   772 /**
   773 @SYMTestCaseID          SYSLIB-LOGENG-CT-0855
   774 @SYMTestCaseDesc	    Tests for CLogViewRecent::SetRecentListL() function 
   775 @SYMTestPriority 	    High
   776 @SYMTestActions  	    Tests for the count of events,outgoing calls.
   777 @SYMTestExpectedResults Test must not fail
   778 @SYMREQ                 REQ0000
   779 */
   780 LOCAL_C void TestRecentView1L(CLogClient& aClient)
   781 	{
   782 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0855 "));
   783 	CLogEvent* event = CLogEvent::NewL();
   784 	CleanupStack::PushL(event);
   785 
   786 	CTestActive* active = new(ELeave)CTestActive();
   787 	CleanupStack::PushL(active);
   788 
   789 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
   790 	CleanupStack::PushL(view);
   791 
   792 	// Incoming
   793 	TBuf<KLogMaxDirectionLength> buf;
   794 	aClient.GetString(buf, R_LOG_DIR_IN);
   795 
   796 	event->SetEventType(KLogCallEventTypeUid);
   797 	event->SetDirection(buf);
   798 
   799 	TInt count;
   800 	for(count = 0; count < KTestEventNum; count++)
   801 		{
   802 		event->SetContact(count);
   803 
   804 		active->StartL();
   805 		aClient.AddEvent(*event, active->iStatus);
   806 		CActiveScheduler::Start();
   807 		TEST2(active->iStatus.Int(), KErrNone);
   808 		}
   809 
   810 	TEST2(view->CountL(), 0);
   811 	TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
   812 	TEST(res);
   813 
   814 	// Move forward
   815 	count = KTestEventNum;
   816 	do	{
   817 		active->StartL();
   818 		CActiveScheduler::Start();
   819 		TEST2(active->iStatus.Int(), KErrNone);
   820 
   821 		TEST2(view->CountL(), KTestEventNum);
   822 		TEST2(view->RecentList(), KLogRecentIncomingCalls);
   823 		count--;
   824 		}
   825 	while(view->NextL(active->iStatus));
   826 	TEST2(count, 0);
   827 	TEST2(view->CountL(), KTestEventNum);
   828 
   829 	// Move back
   830 	while(view->PreviousL(active->iStatus))
   831 		{
   832 		active->StartL();
   833 		CActiveScheduler::Start();
   834 		TEST2(active->iStatus.Int(), KErrNone);
   835 
   836 		TEST2(view->CountL(), KTestEventNum);
   837 		TEST2(view->RecentList(), KLogRecentIncomingCalls);
   838 		count++;
   839 		}
   840 	TEST2(count, KTestEventNum - 1);
   841 
   842 	active->StartL();
   843 	res = view->FirstL(active->iStatus);
   844 	TEST(res);
   845 	CActiveScheduler::Start();
   846 	TEST2(active->iStatus.Int(), KErrNone);
   847 
   848 	active->StartL();
   849 	res = view->LastL(active->iStatus);
   850 	TEST(res);
   851 	CActiveScheduler::Start();
   852 	TEST2(active->iStatus.Int(), KErrNone);
   853 
   854 	TEST2(view->CountL(), KTestEventNum);
   855 
   856 	// Outgoing
   857 	res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
   858 	TEST(!res);
   859 	count = view->CountL();
   860 	TEST2(count, 0);
   861 	CleanupStack::PopAndDestroy(view);
   862 	//
   863 	view = CLogViewRecent::NewL(aClient);
   864 	CleanupStack::PushL(view);
   865 	res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
   866 	TEST(res);
   867 	TEST2(view->CountL(), KTestEventNum);
   868 	active->StartL();
   869 	CActiveScheduler::Start();
   870 	TEST2(active->iStatus.Int(), KErrNone);
   871 
   872 	aClient.GetString(buf, R_LOG_DIR_OUT);
   873 
   874 	event->SetEventType(KLogCallEventTypeUid);
   875 	event->SetDirection(buf);
   876 
   877 	for(count = 0; count < KTestEventNum; count++)
   878 		{
   879 		event->SetContact(count);
   880 
   881 		active->StartL();
   882 		aClient.AddEvent(*event, active->iStatus);
   883 		CActiveScheduler::Start();
   884 		TEST2(active->iStatus.Int(), KErrNone);
   885 		}
   886 
   887 	count = view->CountL();
   888 	TEST2(count, KTestEventNum);
   889 	res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
   890 	TEST(res);
   891 
   892 	// Move forward
   893 	count = KTestEventNum;
   894 	do	{
   895 		active->StartL();
   896 		CActiveScheduler::Start();
   897 		TEST2(active->iStatus.Int(), KErrNone);
   898 
   899 		TEST2(view->CountL(), KTestEventNum);
   900 		TEST2(view->RecentList(), KLogRecentOutgoingCalls);
   901 		count--;
   902 		}
   903 	while(view->NextL(active->iStatus));
   904 	TEST2(count, 0);
   905 	TEST2(view->CountL(), KTestEventNum);
   906 
   907 	// Move back
   908 	while(view->PreviousL(active->iStatus))
   909 		{
   910 		active->StartL();
   911 		CActiveScheduler::Start();
   912 		TEST2(active->iStatus.Int(), KErrNone);
   913 
   914 		TEST2(view->CountL(), KTestEventNum);
   915 		TEST2(view->RecentList(), KLogRecentOutgoingCalls);
   916 		count++;
   917 		}
   918 	TEST2(count, KTestEventNum - 1);
   919 
   920 	active->StartL();
   921 	res = view->FirstL(active->iStatus);
   922 	TEST(res);
   923 	CActiveScheduler::Start();
   924 	TEST2(active->iStatus.Int(), KErrNone);
   925 
   926 	active->StartL();
   927 	res = view->LastL(active->iStatus);
   928 	TEST(res);
   929 	CActiveScheduler::Start();
   930 	TEST2(active->iStatus.Int(), KErrNone);
   931 
   932 	// Missed
   933 	aClient.GetString(buf, R_LOG_DIR_MISSED);
   934 
   935 	event->SetEventType(KLogCallEventTypeUid);
   936 	event->SetDirection(buf);
   937 
   938 	TEST2(view->CountL(), KTestEventNum);
   939 	res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
   940 	TEST(!res);
   941 	TEST2(view->CountL(), 0);
   942 
   943 	for(count = 0; count < KTestEventNum; count++)
   944 		{
   945 		event->SetContact(count);
   946 
   947 		active->StartL();
   948 		aClient.AddEvent(*event, active->iStatus);
   949 		CActiveScheduler::Start();
   950 		TEST2(active->iStatus.Int(), KErrNone);
   951 
   952 		// Test INC123066 - LogView not updated if log count is zero at
   953 		// time of SetFilterL.
   954 		TEST2(view->CountL(), count+1);
   955 		}
   956 
   957 
   958 	// Move forward
   959 	count = KTestEventNum;
   960 	while(view->NextL(active->iStatus))
   961 		{
   962 		active->StartL();
   963 		CActiveScheduler::Start();
   964 		TEST2(active->iStatus.Int(), KErrNone);
   965 
   966 		TEST2(view->CountL(), KTestEventNum);
   967 		TEST2(view->RecentList(), KLogRecentMissedCalls);
   968 		count--;
   969 		}
   970 	TEST2(count, 0);
   971 
   972 	// Move back
   973 	while(view->PreviousL(active->iStatus))
   974 		{
   975 		active->StartL();
   976 		CActiveScheduler::Start();
   977 		TEST2(active->iStatus.Int(), KErrNone);
   978 
   979 		TEST2(view->CountL(), KTestEventNum);
   980 		TEST2(view->RecentList(), KLogRecentMissedCalls);
   981 		count++;
   982 		}
   983 	TEST2(count, KTestEventNum - 1);
   984 
   985 	active->StartL();
   986 	res = view->FirstL(active->iStatus);
   987 	TEST(res);
   988 	CActiveScheduler::Start();
   989 	TEST2(active->iStatus.Int(), KErrNone);
   990 
   991 	active->StartL();
   992 	res = view->LastL(active->iStatus);
   993 	TEST(res);
   994 	CActiveScheduler::Start();
   995 	TEST2(active->iStatus.Int(), KErrNone);
   996 
   997 	// All
   998 	TEST2(view->CountL(), KTestEventNum);
   999 	res = view->SetRecentListL(KLogNullRecentList, active->iStatus);
  1000 	TEST(res);
  1001 
  1002 	// Move forward
  1003 	count = KTestEventNum * 3;
  1004 	TEST2(view->CountL(), count);
  1005 	do	{
  1006 		active->StartL();
  1007 		CActiveScheduler::Start();
  1008 		TEST2(active->iStatus.Int(), KErrNone);
  1009 
  1010 		TEST2(view->CountL(), KTestEventNum * 3);
  1011 		count--;
  1012 		}
  1013 	while(view->NextL(active->iStatus));
  1014 	TEST2(count, 0);
  1015 
  1016 	// Move back
  1017 	while(view->PreviousL(active->iStatus))
  1018 		{
  1019 		active->StartL();
  1020 		CActiveScheduler::Start();
  1021 		TEST2(active->iStatus.Int(), KErrNone);
  1022 
  1023 		TEST2(view->CountL(), KTestEventNum * 3);
  1024 		count++;
  1025 		}
  1026 	TEST2(count, KTestEventNum * 3 - 1);
  1027 
  1028 	active->StartL();
  1029 	res = view->FirstL(active->iStatus);
  1030 	TEST(res);
  1031 	CActiveScheduler::Start();
  1032 	TEST2(active->iStatus.Int(), KErrNone);
  1033 
  1034 	active->StartL();
  1035 	res = view->LastL(active->iStatus);
  1036 	TEST(res);
  1037 	CActiveScheduler::Start();
  1038 	TEST2(active->iStatus.Int(), KErrNone);
  1039 
  1040 	CleanupStack::PopAndDestroy(3); // view, active, event
  1041 	theLog.Write(_L8("Test 3.1 OK\n"));
  1042 	}
  1043 
  1044 /**
  1045 @SYMTestCaseID          SYSLIB-LOGENG-CT-0856
  1046 @SYMTestCaseDesc	    Tests for CLogViewRecent::SetRecentListL(),DuplicatesL() functions
  1047 @SYMTestPriority 	    High
  1048 @SYMTestActions  	    Tests for the count of events in the log
  1049 @SYMTestExpectedResults Test must not fail
  1050 @SYMREQ                 REQ0000
  1051 */
  1052 LOCAL_C void TestRecentView2L(CLogClient& aClient)
  1053 	{
  1054 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0856 "));
  1055 	TInt count;
  1056 
  1057 	CLogEvent* event = CLogEvent::NewL();
  1058 	CleanupStack::PushL(event);
  1059 
  1060 	CTestActive* active = new(ELeave)CTestActive();
  1061 	CleanupStack::PushL(active);
  1062 
  1063 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
  1064 	CleanupStack::PushL(view);
  1065 
  1066 	TEST2(view->CountL(), 0);
  1067 	TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1068 	TEST(res);
  1069 	active->StartL();
  1070 	CActiveScheduler::Start();
  1071 	TEST2(active->iStatus.Int(), KErrNone);
  1072 	count = view->CountL();
  1073 	TEST2(count, KTestEventNum);
  1074 
  1075 	aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus);
  1076 	active->StartL();
  1077 	CActiveScheduler::Start();
  1078 	TEST2(active->iStatus.Int(), KErrNone);
  1079 
  1080 	count = view->CountL();
  1081 	TEST2(count, 0);
  1082 
  1083 	CleanupStack::PopAndDestroy(view);
  1084 	view = CLogViewRecent::NewL(aClient);
  1085 	CleanupStack::PushL(view);
  1086 
  1087 
  1088 	// Incoming
  1089 	TBuf<KLogMaxDirectionLength> buf;
  1090 	aClient.GetString(buf, R_LOG_DIR_IN);
  1091 
  1092 	event->SetEventType(KLogCallEventTypeUid);
  1093 	event->SetDirection(buf);
  1094 
  1095 	// All fields are null, they should all be duplicates
  1096 	for(count = 0; count < KTestEventNum; count++)
  1097 		{
  1098 		active->StartL();
  1099 		aClient.AddEvent(*event, active->iStatus);
  1100 		CActiveScheduler::Start();
  1101 		TEST2(active->iStatus.Int(), KErrNone);
  1102 		}
  1103 
  1104 	TEST2(view->CountL(), 0);
  1105 
  1106 	// Move forward
  1107 	res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1108 	TEST(res);
  1109 	active->StartL();
  1110 	CActiveScheduler::Start();
  1111 	TEST2(active->iStatus.Int(), KErrNone);
  1112 	TEST2(view->CountL(), 1);
  1113 
  1114 	CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient);
  1115 	CleanupStack::PushL(dView);
  1116 
  1117 	res = view->DuplicatesL(*dView, active->iStatus);
  1118 	TEST(res);
  1119 	active->StartL();
  1120 	CActiveScheduler::Start();
  1121 	TEST2(active->iStatus.Int(), KErrNone);
  1122 	TEST2(dView->CountL(), KTestEventNum - 1);
  1123 
  1124 	CleanupStack::PopAndDestroy(4); // view, active, event, dView
  1125 	}
  1126 
  1127 /**
  1128 @SYMTestCaseID          SYSLIB-LOGENG-CT-0857
  1129 @SYMTestCaseDesc	    Tests for CLogViewRecent::RemoveL() functions
  1130 @SYMTestPriority 	    High
  1131 @SYMTestActions  	    Add the recently view events to the view.Remove the items and check for the count.
  1132 @SYMTestExpectedResults Test must not fail
  1133 @SYMREQ                 REQ0000
  1134 */
  1135 LOCAL_C void TestRecentRemove1L(CLogClient& aClient)
  1136 	{
  1137 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0857 "));
  1138 	CTestActive* active = new(ELeave)CTestActive();
  1139 	CleanupStack::PushL(active);
  1140 
  1141 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
  1142 	CleanupStack::PushL(view);
  1143 
  1144 	TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1145 	TEST(res);
  1146 	active->StartL();
  1147 	CActiveScheduler::Start();
  1148 	TEST2(active->iStatus.Int(), KErrNone);
  1149 
  1150 	TInt count = view->CountL();
  1151 
  1152 	while(view->RemoveL(active->iStatus))
  1153 		{
  1154 		TEST2(view->CountL(), count - 1);
  1155 		count = view->CountL();
  1156 
  1157 		active->StartL();
  1158 		CActiveScheduler::Start();
  1159 		TEST2(active->iStatus.Int(), KErrNone);
  1160 		}
  1161 	TEST2(view->CountL(), 0);
  1162 
  1163 	res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
  1164 	TEST(res);
  1165 	active->StartL();
  1166 	CActiveScheduler::Start();
  1167 	TEST2(active->iStatus.Int(), KErrNone);
  1168 	TEST2(view->CountL(), KTestEventNum);
  1169 
  1170 	aClient.ClearLog(KLogRecentOutgoingCalls, active->iStatus);
  1171 	active->StartL();
  1172 	CActiveScheduler::Start();
  1173 	TEST2(active->iStatus.Int(), KErrNone);
  1174 	TEST2(view->CountL(), 0);
  1175 
  1176 	res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
  1177 	TEST(!res);
  1178 
  1179 	res = view->SetRecentListL(KLogNullRecentList, active->iStatus);
  1180 	TEST(res);
  1181 	active->StartL();
  1182 	CActiveScheduler::Start();
  1183 	TEST2(active->iStatus.Int(), KErrNone);
  1184 	TEST2(view->CountL(), KTestEventNum);
  1185 
  1186 	aClient.ClearLog(KLogNullRecentList, active->iStatus);
  1187 	active->StartL();
  1188 	CActiveScheduler::Start();
  1189 	TEST2(active->iStatus.Int(), KErrNone);
  1190 
  1191 	res = view->SetRecentListL(KLogNullRecentList, active->iStatus);
  1192 	TEST(!res);
  1193 	TEST2(view->CountL(), 0);
  1194 
  1195 	CleanupStack::PopAndDestroy(2); // view, active
  1196 	}
  1197 
  1198 /**
  1199 @SYMTestCaseID          SYSLIB-LOGENG-CT-0858
  1200 @SYMTestCaseDesc	    Tests for CLogViewRecent::RemoveL() functions
  1201 @SYMTestPriority 	    High
  1202 @SYMTestActions  	    Add the recently view events to the two logviewrecents.Remove the items and check for the count of the first logview.
  1203 @SYMTestExpectedResults Test must not fail
  1204 @SYMREQ                 REQ0000
  1205 */
  1206 LOCAL_C void TestRecentRemove2L(CLogClient& aClient)
  1207 	{
  1208 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0858 "));
  1209 	CLogEvent* event = CLogEvent::NewL();
  1210 	CleanupStack::PushL(event);
  1211 
  1212 	CTestActive* active = new(ELeave)CTestActive();
  1213 	CleanupStack::PushL(active);
  1214 
  1215 	CLogViewRecent* view1 = CLogViewRecent::NewL(aClient);
  1216 	CleanupStack::PushL(view1);
  1217 
  1218 	// Incoming
  1219 	TBuf<KLogMaxDirectionLength> buf;
  1220 	aClient.GetString(buf, R_LOG_DIR_IN);
  1221 
  1222 	event->SetEventType(KLogCallEventTypeUid);
  1223 	event->SetDirection(buf);
  1224 
  1225 	TInt count;
  1226 	for(count = 0; count < KTestEventNum; count++)
  1227 		{
  1228 		event->SetContact(count);
  1229 
  1230 		active->StartL();
  1231 		aClient.AddEvent(*event, active->iStatus);
  1232 		CActiveScheduler::Start();
  1233 		TEST2(active->iStatus.Int(), KErrNone);
  1234 		}
  1235 
  1236 	// Create another invalid view and remove an event using it
  1237 	CLogViewRecent* view2 = CLogViewRecent::NewL(aClient);
  1238 	CleanupStack::PushL(view2);
  1239 
  1240 	TEST2(view1->CountL(), 0);
  1241 	TBool res = view1->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1242 	TEST(res);
  1243 	TEST2(view1->CountL(), KTestEventNum);
  1244 
  1245 	do
  1246 		{
  1247 		active->StartL();
  1248 		CActiveScheduler::Start();
  1249 		TEST2(active->iStatus.Int(), KErrNone);
  1250 		view2->RemoveL(view1->Event().Id());
  1251 		}
  1252 	while(view1->NextL(active->iStatus));
  1253 
  1254 	aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus);
  1255 	active->StartL();
  1256 	CActiveScheduler::Start();
  1257 	TEST2(active->iStatus.Int(), KErrNone);
  1258 	TEST2(view1->CountL(), 0);
  1259 
  1260 	CleanupStack::PopAndDestroy(4); // view2, view1, active, event
  1261 	}
  1262 
  1263 /**
  1264 @SYMTestCaseID          SYSLIB-LOGENG-CT-0859
  1265 @SYMTestCaseDesc	    Tests for CLogViewDuplicate::SetRecentListL(),DuplicatesL() functions
  1266 @SYMTestPriority 	    High
  1267 @SYMTestActions  	    Tests for the count of events and the event ID
  1268 @SYMTestExpectedResults Test must not fail
  1269 @SYMREQ                 REQ0000
  1270 */
  1271 LOCAL_C void TestDuplicateViewL(CLogClient& aClient)
  1272 	{
  1273 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0859 "));
  1274 	CTestActive* active = new(ELeave)CTestActive();
  1275 	CleanupStack::PushL(active);
  1276 
  1277 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
  1278 	CleanupStack::PushL(view);
  1279 
  1280 	CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient);
  1281 	CleanupStack::PushL(dView);
  1282 
  1283 	TEST2(dView->CountL(), 0);
  1284 
  1285 	TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1286 	TEST(!res);
  1287 	TEST2(view->CountL(), 0);
  1288 
  1289 	res = view->DuplicatesL(*dView, active->iStatus);
  1290 	TEST(!res);
  1291 	TEST2(dView->CountL(), 0);
  1292 
  1293 	// Incoming
  1294 	TBuf<KLogMaxDirectionLength> incoming;
  1295 	aClient.GetString(incoming, R_LOG_DIR_IN);
  1296 
  1297 	CLogEvent* event = CLogEvent::NewL();
  1298 	CleanupStack::PushL(event);
  1299 
  1300 	event->SetEventType(KLogCallEventTypeUid);
  1301 	event->SetDirection(incoming);
  1302 	event->SetRemoteParty(KTestRemoteParty);
  1303 	event->SetContact(KTestContact);
  1304 	event->SetNumber(KTestNumber);
  1305 
  1306 	active->StartL();
  1307 	aClient.AddEvent(*event, active->iStatus);
  1308 	CActiveScheduler::Start();
  1309 	TEST2(active->iStatus.Int(), KErrNone);
  1310 
  1311 	res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1312 	TEST(res);
  1313 	active->StartL();
  1314 	CActiveScheduler::Start();
  1315 	TEST2(active->iStatus.Int(), KErrNone);
  1316 
  1317 	TEST2(view->CountL(), 1);
  1318 	res = view->FirstL(active->iStatus);
  1319 	TEST(res);
  1320 	active->StartL();
  1321 	CActiveScheduler::Start();
  1322 	TEST2(active->iStatus.Int(), KErrNone);
  1323 	TEST2(view->Event().Id(), event->Id());
  1324 
  1325 	TEST2(dView->CountL(), 0);
  1326 
  1327 	event->SetRemoteParty(KTestRemoteParty);
  1328 	event->SetContact(KTestContact);
  1329 	event->SetNumber(KNullDesC);
  1330 
  1331 	//Add event with Number field set to NULL
  1332 	active->StartL();
  1333 	aClient.AddEvent(*event, active->iStatus);
  1334 	CActiveScheduler::Start();
  1335 	TEST2(active->iStatus.Int(), KErrNone);
  1336 
  1337 	res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1338 	TEST(res);
  1339 	active->StartL();
  1340 	CActiveScheduler::Start();
  1341 	TEST2(active->iStatus.Int(), KErrNone);
  1342 
  1343 	TEST2(view->CountL(), 2);
  1344 	res = view->FirstL(active->iStatus);
  1345 	TEST(res);
  1346 	active->StartL();
  1347 	CActiveScheduler::Start();
  1348 	TEST2(active->iStatus.Int(), KErrNone);
  1349 	TEST2(view->Event().Id(), event->Id());
  1350 
  1351 	res = view->DuplicatesL(*dView, active->iStatus);
  1352 	TEST(!res);
  1353 
  1354 	TEST2(dView->CountL(), 0);
  1355 
  1356 	event->SetRemoteParty(KTestRemoteParty);
  1357 	event->SetContact(KLogNullContactId);
  1358 	event->SetNumber(KNullDesC);
  1359 
  1360 	//Add event with Number field set to NULL & Contact set to -1
  1361 	active->StartL();
  1362 	aClient.AddEvent(*event, active->iStatus);
  1363 	CActiveScheduler::Start();
  1364 	TEST2(active->iStatus.Int(), KErrNone);
  1365 
  1366 	res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1367 	TEST(res);
  1368 	active->StartL();
  1369 	CActiveScheduler::Start();
  1370 	TEST2(active->iStatus.Int(), KErrNone);
  1371 
  1372 	TEST2(view->CountL(), 3);
  1373 	res = view->FirstL(active->iStatus);
  1374 	TEST(res);
  1375 	active->StartL();
  1376 	CActiveScheduler::Start();
  1377 	TEST2(active->iStatus.Int(), KErrNone);
  1378 	TEST2(view->Event().Id(), event->Id());
  1379 
  1380 	res = view->DuplicatesL(*dView, active->iStatus);
  1381 	TEST(!res);
  1382 
  1383 	TEST2(dView->CountL(), 0);
  1384 
  1385 	event->SetRemoteParty(KNullDesC);
  1386 	event->SetContact(KLogNullContactId);
  1387 	event->SetNumber(KNullDesC);
  1388 
  1389 	//Add event with Number, Remote Party field set to NULL & Contact set to -1
  1390 	active->StartL();
  1391 	aClient.AddEvent(*event, active->iStatus);
  1392 	CActiveScheduler::Start();
  1393 	TEST2(active->iStatus.Int(), KErrNone);
  1394 
  1395 	res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1396 	TEST(res);
  1397 	active->StartL();
  1398 	CActiveScheduler::Start();
  1399 	TEST2(active->iStatus.Int(), KErrNone);
  1400 
  1401 	TEST2(view->CountL(), 4);
  1402 
  1403 	res = view->DuplicatesL(*dView, active->iStatus);
  1404 	TEST(!res);
  1405 
  1406 	TEST2(dView->CountL(), 0);
  1407 
  1408 	TLogId lastId = event->Id();
  1409 	
  1410 	//Add event with Number, Remote Party field set to NULL & Contact set to -1
  1411 	active->StartL();
  1412 	aClient.AddEvent(*event, active->iStatus);
  1413 	CActiveScheduler::Start();
  1414 	TEST2(active->iStatus.Int(), KErrNone);
  1415 	
  1416 	res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1417 	TEST(res);
  1418 	active->StartL();
  1419 	CActiveScheduler::Start();
  1420 	TEST2(active->iStatus.Int(), KErrNone);
  1421 
  1422 	TEST2(view->CountL(), 4);
  1423 
  1424 	res = view->DuplicatesL(*dView, active->iStatus);
  1425 	TEST(res);
  1426 	active->StartL();
  1427 	CActiveScheduler::Start();
  1428 	TEST2(active->iStatus.Int(), KErrNone);
  1429 
  1430 	TEST2(dView->CountL(), 1);
  1431 	TEST2(dView->Event().Id(), lastId);
  1432 	
  1433 	CleanupStack::PopAndDestroy(4); // event, dView, view, active
  1434 	}
  1435 
  1436 /**
  1437 @SYMTestCaseID          SYSLIB-LOGENG-CT-0860
  1438 @SYMTestCaseDesc	    Tests for CLogViewDuplicate::RemoveL() functions
  1439 @SYMTestPriority 	    High
  1440 @SYMTestActions  	    Tests for removing the events and test for the count
  1441 @SYMTestExpectedResults Test must not fail
  1442 @SYMREQ                 REQ0000
  1443 */
  1444 LOCAL_C void TestDuplicateRemoveL(CLogClient& aClient)
  1445 	{
  1446 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0860 "));
  1447 	CTestActive* active = new(ELeave)CTestActive();
  1448 	CleanupStack::PushL(active);
  1449 
  1450 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
  1451 	CleanupStack::PushL(view);
  1452 
  1453 	CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient);
  1454 	CleanupStack::PushL(dView);
  1455 
  1456 	TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1457 	TEST(res);
  1458 	active->StartL();
  1459 	CActiveScheduler::Start();
  1460 	TEST2(active->iStatus.Int(), KErrNone);
  1461 
  1462 	//The incoming call list should have count as 4. These calls were added in 
  1463 	//...the previous function named TestDuplicateViewL() 
  1464 	TEST2(view->CountL(), 4);
  1465 
  1466 	res = view->DuplicatesL(*dView, active->iStatus);
  1467 	TEST(res);
  1468 	active->StartL();
  1469 	CActiveScheduler::Start();
  1470 	TEST2(active->iStatus.Int(), KErrNone);
  1471 
  1472 	TLogId id = dView->Event().Id();
  1473 	TEST2(dView->CountL(), 1);
  1474 	
  1475 	res = dView->RemoveL(active->iStatus);
  1476 	TEST(!res);
  1477 
  1478 	TEST2(dView->CountL(), 0);
  1479 
  1480 	res = dView->RemoveL(active->iStatus);
  1481 	TEST(!res);
  1482 	TEST2(dView->CountL(), 0);
  1483 
  1484 	TEST2(view->CountL(), 4);
  1485 
  1486 	CleanupStack::PopAndDestroy(3); // dView, view, active
  1487 	}
  1488 
  1489 /**
  1490 @SYMTestCaseID          SYSLIB-LOGENG-CT-0861
  1491 @SYMTestCaseDesc	    Tests for purging on log engine
  1492 @SYMTestPriority 	    High
  1493 @SYMTestActions  	    Tests for changing the log engine configuration,add event and test for retrieving them back.
  1494 						Set up a purge which clears the log and reset the log configuration 
  1495 @SYMTestExpectedResults Test must not fail
  1496 @SYMREQ                 REQ0000
  1497 */
  1498 LOCAL_C void TestPurgeOnSetup1L(CLogClient& aClient)
  1499 	{
  1500 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0861 "));
  1501 	CTestActive* active = new(ELeave)CTestActive();
  1502 	CleanupStack::PushL(active);
  1503 
  1504 	User::After(0x100000);
  1505 
  1506 	TTime now;
  1507 	now.UniversalTime();
  1508 
  1509 	// Clear all the events
  1510 	active->StartL();
  1511 	aClient.ClearLog(now, active->iStatus);
  1512 	CActiveScheduler::Start();
  1513 	TEST2(active->iStatus.Int(), KErrNone);
  1514 
  1515 	CLogEvent* event = CLogEvent::NewL();
  1516 	CleanupStack::PushL(event);
  1517 	event->SetEventType(KLogCallEventTypeUid);
  1518 
  1519 	TLogConfig config;
  1520 
  1521 	// Get log configuration
  1522 	active->StartL();
  1523 	aClient.GetConfig(config, active->iStatus);
  1524 	CActiveScheduler::Start();
  1525 	TEST2(active->iStatus.Int(), KErrNone);
  1526 
  1527 	// Set the maximum log age
  1528 	TInt oldAge = config.iMaxEventAge;
  1529 	config.iMaxEventAge = 10; // 10 seconds!
  1530 
  1531 	// Change the log engine config
  1532 	active->StartL();
  1533 	aClient.ChangeConfig(config, active->iStatus);
  1534 	CActiveScheduler::Start();
  1535 	TEST2(active->iStatus.Int(), KErrNone);
  1536 
  1537 	active->StartL();
  1538 	aClient.AddEvent(*event, active->iStatus);
  1539 	CActiveScheduler::Start();
  1540 	TEST2(active->iStatus.Int(), KErrNone);
  1541 
  1542 	// Check that the event can be retrieved
  1543 	active->StartL();
  1544 	aClient.GetEvent(*event, active->iStatus);
  1545 	CActiveScheduler::Start();
  1546 	TEST2(active->iStatus.Int(), KErrNone);
  1547 
  1548 	// Wait for 15 seconds (just to be safe)
  1549 	User::After(15000000);
  1550 
  1551 	// Check that the event can be retrieved
  1552 	active->StartL();
  1553 	aClient.GetEvent(*event, active->iStatus);
  1554 	CActiveScheduler::Start();
  1555 	TEST2(active->iStatus.Int(), KErrNone);
  1556 
  1557 	// Check that the event can still be retrieved
  1558 	active->StartL();
  1559 	aClient.GetEvent(*event, active->iStatus);
  1560 	CActiveScheduler::Start();
  1561 	TEST2(active->iStatus.Int(), KErrNone);
  1562 
  1563 	// Check that the event can still be retrieved
  1564 	active->StartL();
  1565 	aClient.GetEvent(*event, active->iStatus);
  1566 	CActiveScheduler::Start();
  1567 	TEST2(active->iStatus.Int(), KErrNone);
  1568 
  1569 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
  1570 	CleanupStack::PushL(view);
  1571 
  1572 	CLogFilter* filter = CLogFilter::NewL();
  1573 	CleanupStack::PushL(filter);
  1574 
  1575 	// Setup a view which should purge the event - hence no events in view!
  1576 	TBool res = view->SetFilterL(*filter, active->iStatus);
  1577 	TEST(!res);
  1578 
  1579 	// Reset the config
  1580 	config.iMaxEventAge = oldAge;
  1581 
  1582 	// Change the log engine config
  1583 	active->StartL();
  1584 	aClient.ChangeConfig(config, active->iStatus);
  1585 	CActiveScheduler::Start();
  1586 	TEST2(active->iStatus.Int(), KErrNone);
  1587 
  1588 	CleanupStack::PopAndDestroy(4); // filter, view, active, event
  1589 	}
  1590 
  1591 /**
  1592 @SYMTestCaseID          SYSLIB-LOGENG-CT-0862
  1593 @SYMTestCaseDesc	    Tests for purging on log engine
  1594 @SYMTestPriority 	    High
  1595 @SYMTestActions  	    Clear the events from the log,set the log engine age to maximum.Change the configuration,and test adding and retrieving the events.
  1596                         Set up a purge which clears the log and reset the log configuration 
  1597 @SYMTestExpectedResults Test must not fail
  1598 @SYMREQ                 REQ0000
  1599 */
  1600 LOCAL_C void TestPurgeOnSetup2L(CLogClient& aClient)
  1601 	{
  1602 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0862 "));
  1603 	CTestActive* active1 = new(ELeave)CTestActive();
  1604 	CleanupStack::PushL(active1);
  1605 
  1606 	CTestActive* active2 = new(ELeave)CTestActive();
  1607 	CleanupStack::PushL(active2);
  1608 
  1609 	User::After(0x100000);
  1610 
  1611 	TTime now;
  1612 	now.UniversalTime();
  1613 
  1614 	// Clear all the events
  1615 	active1->StartL();
  1616 	aClient.ClearLog(now, active1->iStatus);
  1617 	CActiveScheduler::Start();
  1618 	TEST2(active1->iStatus.Int(), KErrNone);
  1619 
  1620 	CLogEvent* event = CLogEvent::NewL();
  1621 	CleanupStack::PushL(event);
  1622 	event->SetEventType(KLogCallEventTypeUid);
  1623 
  1624 	TLogConfig config;
  1625 
  1626 	// Get log configuration
  1627 	active1->StartL();
  1628 	aClient.GetConfig(config, active1->iStatus);
  1629 	CActiveScheduler::Start();
  1630 	TEST2(active1->iStatus.Int(), KErrNone);
  1631 
  1632 	// Set the maximum log age
  1633 	TInt oldAge = config.iMaxEventAge;
  1634 	config.iMaxEventAge = 10; // 10 seconds!
  1635 
  1636 	// Change the log engine config
  1637 	active1->StartL();
  1638 	aClient.ChangeConfig(config, active1->iStatus);
  1639 	CActiveScheduler::Start();
  1640 	TEST2(active1->iStatus.Int(), KErrNone);
  1641 
  1642 	active1->StartL();
  1643 	aClient.AddEvent(*event, active1->iStatus);
  1644 	CActiveScheduler::Start();
  1645 	TEST2(active1->iStatus.Int(), KErrNone);
  1646 
  1647 	// Check that the event can be retrieved
  1648 	active1->StartL();
  1649 	aClient.GetEvent(*event, active1->iStatus);
  1650 	CActiveScheduler::Start();
  1651 	TEST2(active1->iStatus.Int(), KErrNone);
  1652 
  1653 	// Wait for 15 seconds (just to be safe)
  1654 	User::After(15000000);
  1655 
  1656 	// Check that the event can be retrieved
  1657 	active1->StartL();
  1658 	aClient.GetEvent(*event, active1->iStatus);
  1659 	CActiveScheduler::Start();
  1660 	TEST2(active1->iStatus.Int(), KErrNone);
  1661 
  1662 	// Check that the event can still be retrieved
  1663 	active1->StartL();
  1664 	aClient.GetEvent(*event, active1->iStatus);
  1665 	CActiveScheduler::Start();
  1666 	TEST2(active1->iStatus.Int(), KErrNone);
  1667 
  1668 	// Check that the event can still be retrieved
  1669 	active1->StartL();
  1670 	aClient.GetEvent(*event, active1->iStatus);
  1671 	CActiveScheduler::Start();
  1672 	TEST2(active1->iStatus.Int(), KErrNone);
  1673 
  1674 	CLogViewEvent* view1 = CLogViewEvent::NewL(aClient);
  1675 	CleanupStack::PushL(view1);
  1676 
  1677 	CLogViewEvent* view2 = CLogViewEvent::NewL(aClient);
  1678 	CleanupStack::PushL(view2);
  1679 
  1680 	CLogFilter* filter = CLogFilter::NewL();
  1681 	CleanupStack::PushL(filter);
  1682 
  1683 	// Setup a view which should purge the event - hence no events in view!
  1684 	TBool res = view1->SetFilterL(*filter, active1->iStatus);
  1685 	TEST(!res);
  1686 	res = view2->SetFilterL(*filter, active2->iStatus);
  1687 	TEST(!res);
  1688 
  1689 	// Reset the config
  1690 	config.iMaxEventAge = oldAge;
  1691 
  1692 	// Change the log engine config
  1693 	active1->StartL();
  1694 	aClient.ChangeConfig(config, active1->iStatus);
  1695 	CActiveScheduler::Start();
  1696 	TEST2(active1->iStatus.Int(), KErrNone);
  1697 
  1698 	CleanupStack::PopAndDestroy(6); // filter, view1, view2, active1, active2, event
  1699 	}
  1700 
  1701 /**
  1702 @SYMTestCaseID          SYSLIB-LOGENG-CT-0863
  1703 @SYMTestCaseDesc	    Tests for purge on CLogViewRecent
  1704 @SYMTestPriority 	    High
  1705 @SYMTestActions  	    Set the log engine maximum log size and recent log size.Change the configuration and add events to the log
  1706                         Tests the count to be less than or equal to recent logsize.
  1707 @SYMTestExpectedResults Test must not fail
  1708 @SYMREQ                 REQ0000
  1709 */
  1710 LOCAL_C void TestViewPurgeL(CLogClient& aClient)
  1711 	{
  1712 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0863 "));
  1713 	CTestActive* active = new(ELeave)CTestActive();
  1714 	CleanupStack::PushL(active);
  1715 
  1716 	TLogConfig config;
  1717 
  1718 	aClient.GetConfig(config, active->iStatus);
  1719 	active->StartL();
  1720 	CActiveScheduler::Start();
  1721 	TEST2(active->iStatus.Int(), KErrNone);
  1722 	TEST2(config.iMaxLogSize, 1000);
  1723 
  1724 	config.iMaxLogSize = 2000;
  1725 	config.iMaxRecentLogSize = 20;
  1726 
  1727 	aClient.ChangeConfig(config, active->iStatus);
  1728 	active->StartL();
  1729 	CActiveScheduler::Start();
  1730 	TEST2(active->iStatus.Int(), KErrNone);
  1731 
  1732 	CLogEvent* event = CLogEvent::NewL();
  1733 	CleanupStack::PushL(event);
  1734 
  1735 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
  1736 	CleanupStack::PushL(view);
  1737 
  1738 	// Incoming
  1739 	TBuf<KLogMaxDirectionLength> buf;
  1740 	aClient.GetString(buf, R_LOG_DIR_IN);
  1741 
  1742 	event->SetEventType(KLogCallEventTypeUid);
  1743 	event->SetDirection(buf);
  1744 
  1745 	for(TInt count = 0; count < config.iMaxRecentLogSize * 2; count++)
  1746 		{
  1747 		event->SetContact(count);
  1748 
  1749 		active->StartL();
  1750 		aClient.AddEvent(*event, active->iStatus);
  1751 		CActiveScheduler::Start();
  1752 		TEST2(active->iStatus.Int(), KErrNone);
  1753 
  1754 		TBool res = view->SetRecentListL(KLogNullRecentList, active->iStatus);
  1755 		TEST(res);
  1756 		active->StartL();
  1757 		CActiveScheduler::Start();
  1758 		TEST2(active->iStatus.Int(), KErrNone);
  1759 		TEST(view->CountL() <= config.iMaxRecentLogSize);
  1760 		}
  1761 
  1762 	CleanupStack::PopAndDestroy(3); // active, event, view
  1763 	}
  1764 
  1765 /**
  1766 @SYMTestCaseID          SYSLIB-LOGENG-CT-0864
  1767 @SYMTestCaseDesc	    Tests for the functionality of CLogViewDuplicate class
  1768 @SYMTestPriority 	    High
  1769 @SYMTestActions  	    Tests for clearing the duplicate events
  1770 @SYMTestExpectedResults Test must not fail
  1771 @SYMREQ                 REQ0000
  1772 */
  1773 LOCAL_C void TestClearDuplicatesL(CLogClient& aClient)
  1774 	{
  1775 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0864 "));
  1776 	CTestActive* active = new(ELeave)CTestActive();
  1777 	CleanupStack::PushL(active);
  1778 
  1779 	aClient.ClearLog(KLogNullRecentList, active->iStatus);
  1780 	active->StartL();
  1781 	CActiveScheduler::Start();
  1782 	TEST2(active->iStatus.Int(), KErrNone);
  1783 
  1784 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
  1785 	CleanupStack::PushL(view);
  1786 
  1787 	CLogViewDuplicate* dView = CLogViewDuplicate::NewL(aClient);
  1788 	CleanupStack::PushL(dView);
  1789 
  1790 	TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1791 	TEST(!res);
  1792 
  1793 	TBuf<KLogMaxDirectionLength> incoming;
  1794 	aClient.GetString(incoming, R_LOG_DIR_IN);
  1795 
  1796 	TBuf<KLogMaxDirectionLength> outgoing;
  1797 	aClient.GetString(outgoing, R_LOG_DIR_OUT);
  1798 
  1799 	TBuf<KLogMaxDirectionLength> missed;
  1800 	aClient.GetString(missed, R_LOG_DIR_MISSED);
  1801 
  1802 	CLogEvent* event = CLogEvent::NewL();
  1803 	CleanupStack::PushL(event);
  1804 
  1805 	event->SetEventType(KLogCallEventTypeUid);
  1806 
  1807 	// Add 5 recent events to each list - with 5 duplicates each
  1808 
  1809 	// Incoming
  1810 	event->SetDirection(incoming);
  1811 	TInt recent;
  1812 	for(recent = 1; recent <= 5; recent++)
  1813 		{
  1814 		event->SetContact(recent);
  1815 		for(TInt duplicate = 1; duplicate <= 6; duplicate++)
  1816 			{
  1817 			active->StartL();
  1818 			aClient.AddEvent(*event, active->iStatus);
  1819 			CActiveScheduler::Start();
  1820 			TEST2(active->iStatus.Int(), KErrNone);
  1821 			}
  1822 		}
  1823 
  1824 	// Outgoing
  1825 	event->SetDirection(outgoing);
  1826 	for(recent = 1; recent <= 5; recent++)
  1827 		{
  1828 		event->SetContact(recent);
  1829 		for(TInt duplicate = 1; duplicate <= 6; duplicate++)
  1830 			{
  1831 			active->StartL();
  1832 			aClient.AddEvent(*event, active->iStatus);
  1833 			CActiveScheduler::Start();
  1834 			TEST2(active->iStatus.Int(), KErrNone);
  1835 			}
  1836 		}
  1837 
  1838 	// Missed
  1839 	event->SetDirection(missed);
  1840 	for(recent = 1; recent <= 5; recent++)
  1841 		{
  1842 		event->SetContact(recent);
  1843 		for(TInt duplicate = 1; duplicate <= 6; duplicate++)
  1844 			{
  1845 			active->StartL();
  1846 			aClient.AddEvent(*event, active->iStatus);
  1847 			CActiveScheduler::Start();
  1848 			TEST2(active->iStatus.Int(), KErrNone);
  1849 			}
  1850 		}
  1851 
  1852 	// Check outgoing
  1853 	res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
  1854 	TEST(res);
  1855 	TEST2(view->CountL(), 5);
  1856 
  1857 	do
  1858 		{
  1859 		active->StartL();
  1860 		CActiveScheduler::Start();
  1861 		TEST2(active->iStatus.Int(), KErrNone);
  1862 
  1863 		res = view->DuplicatesL(*dView, active->iStatus);
  1864 		TEST(res);
  1865 		TEST2(dView->CountL(), 5);
  1866 		active->StartL();
  1867 		CActiveScheduler::Start();
  1868 		TEST2(active->iStatus.Int(), KErrNone);
  1869 		}
  1870 	while(view->NextL(active->iStatus));
  1871 
  1872 	// Check missed
  1873 	res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
  1874 	TEST(res);
  1875 	TEST2(view->CountL(), 5);
  1876 
  1877 	do
  1878 		{
  1879 		active->StartL();
  1880 		CActiveScheduler::Start();
  1881 		TEST2(active->iStatus.Int(), KErrNone);
  1882 
  1883 		res = view->DuplicatesL(*dView, active->iStatus);
  1884 		TEST(res);
  1885 		TEST2(dView->CountL(), 5);
  1886 		active->StartL();
  1887 		CActiveScheduler::Start();
  1888 		TEST2(active->iStatus.Int(), KErrNone);
  1889 		}
  1890 	while(view->NextL(active->iStatus));
  1891 
  1892 	// Check incoming
  1893 	res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1894 	TEST(res);
  1895 	TEST2(view->CountL(), 5);
  1896 
  1897 	do
  1898 		{
  1899 		active->StartL();
  1900 		CActiveScheduler::Start();
  1901 		TEST2(active->iStatus.Int(), KErrNone);
  1902 
  1903 		res = view->DuplicatesL(*dView, active->iStatus);
  1904 		TEST(res);
  1905 		TEST2(dView->CountL(), 5);
  1906 		active->StartL();
  1907 		CActiveScheduler::Start();
  1908 		TEST2(active->iStatus.Int(), KErrNone);
  1909 		}
  1910 	while(view->NextL(active->iStatus));
  1911 
  1912 	// Clear duplicates for incoming
  1913 	view->ClearDuplicatesL();
  1914 	TEST2(view->CountL(), 5);
  1915 	
  1916 	// Recent list should be unchanged
  1917 	res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1918 	TEST(res);
  1919 	TEST2(view->CountL(), 5);
  1920 
  1921 	do
  1922 		{
  1923 		active->StartL();
  1924 		CActiveScheduler::Start();
  1925 		TEST2(active->iStatus.Int(), KErrNone);
  1926 
  1927 		// No duplicates should exist for this view now
  1928 		res = view->DuplicatesL(*dView, active->iStatus);
  1929 		TEST(!res);
  1930 		TEST2(dView->CountL(), 0);
  1931 		}
  1932 	while(view->NextL(active->iStatus));
  1933 
  1934 	// Check outgoing is unchanged
  1935 	res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
  1936 	TEST(res);
  1937 	TEST2(view->CountL(), 5);
  1938 
  1939 	do
  1940 		{
  1941 		active->StartL();
  1942 		CActiveScheduler::Start();
  1943 		TEST2(active->iStatus.Int(), KErrNone);
  1944 
  1945 		res = view->DuplicatesL(*dView, active->iStatus);
  1946 		TEST(res);
  1947 		TEST2(dView->CountL(), 5);
  1948 		active->StartL();
  1949 		CActiveScheduler::Start();
  1950 		TEST2(active->iStatus.Int(), KErrNone);
  1951 		}
  1952 	while(view->NextL(active->iStatus));
  1953 
  1954 	// Check missed is unchanged
  1955 	res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
  1956 	TEST(res);
  1957 	TEST2(view->CountL(), 5);
  1958 
  1959 	do
  1960 		{
  1961 		active->StartL();
  1962 		CActiveScheduler::Start();
  1963 		TEST2(active->iStatus.Int(), KErrNone);
  1964 
  1965 		res = view->DuplicatesL(*dView, active->iStatus);
  1966 		TEST(res);
  1967 		TEST2(dView->CountL(), 5);
  1968 		active->StartL();
  1969 		CActiveScheduler::Start();
  1970 		TEST2(active->iStatus.Int(), KErrNone);
  1971 		}
  1972 	while(view->NextL(active->iStatus));
  1973 
  1974 	// Clear duplicates for missed
  1975 	view->ClearDuplicatesL();
  1976 	TEST2(view->CountL(), 5);
  1977 	
  1978 	// Recent list should be unchanged
  1979 	res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  1980 	TEST(res);
  1981 	TEST2(view->CountL(), 5);
  1982 
  1983 	do
  1984 		{
  1985 		active->StartL();
  1986 		CActiveScheduler::Start();
  1987 		TEST2(active->iStatus.Int(), KErrNone);
  1988 
  1989 		// No duplicates should exist for this view now
  1990 		res = view->DuplicatesL(*dView, active->iStatus);
  1991 		TEST(!res);
  1992 		TEST2(dView->CountL(), 0);
  1993 		}
  1994 	while(view->NextL(active->iStatus));
  1995 
  1996 	// Missed recent list should be unchanged
  1997 	res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
  1998 	TEST(res);
  1999 	TEST2(view->CountL(), 5);
  2000 
  2001 	do
  2002 		{
  2003 		active->StartL();
  2004 		CActiveScheduler::Start();
  2005 		TEST2(active->iStatus.Int(), KErrNone);
  2006 
  2007 		// No duplicates should exist for this view now
  2008 		res = view->DuplicatesL(*dView, active->iStatus);
  2009 		TEST(!res);
  2010 		TEST2(dView->CountL(), 0);
  2011 		}
  2012 	while(view->NextL(active->iStatus));
  2013 
  2014 	// Check outgoing is unchanged
  2015 	res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
  2016 	TEST(res);
  2017 	TEST2(view->CountL(), 5);
  2018 
  2019 	do
  2020 		{
  2021 		active->StartL();
  2022 		CActiveScheduler::Start();
  2023 		TEST2(active->iStatus.Int(), KErrNone);
  2024 
  2025 		res = view->DuplicatesL(*dView, active->iStatus);
  2026 		TEST(res);
  2027 		TEST2(dView->CountL(), 5);
  2028 		active->StartL();
  2029 		CActiveScheduler::Start();
  2030 		TEST2(active->iStatus.Int(), KErrNone);
  2031 		}
  2032 	while(view->NextL(active->iStatus));
  2033 
  2034 	// Clear duplicates for outgoing
  2035 	view->ClearDuplicatesL();
  2036 	TEST2(view->CountL(), 5);
  2037 	
  2038 	// Recent list should be unchanged
  2039 	res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  2040 	TEST(res);
  2041 	TEST2(view->CountL(), 5);
  2042 
  2043 	do
  2044 		{
  2045 		active->StartL();
  2046 		CActiveScheduler::Start();
  2047 		TEST2(active->iStatus.Int(), KErrNone);
  2048 
  2049 		// No duplicates should exist for this view now
  2050 		res = view->DuplicatesL(*dView, active->iStatus);
  2051 		TEST(!res);
  2052 		TEST2(dView->CountL(), 0);
  2053 		}
  2054 	while(view->NextL(active->iStatus));
  2055 
  2056 	// Missed recent list should be unchanged
  2057 	res = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
  2058 	TEST(res);
  2059 	TEST2(view->CountL(), 5);
  2060 
  2061 	do
  2062 		{
  2063 		active->StartL();
  2064 		CActiveScheduler::Start();
  2065 		TEST2(active->iStatus.Int(), KErrNone);
  2066 
  2067 		// No duplicates should exist for this view now
  2068 		res = view->DuplicatesL(*dView, active->iStatus);
  2069 		TEST(!res);
  2070 		TEST2(dView->CountL(), 0);
  2071 		}
  2072 	while(view->NextL(active->iStatus));
  2073 
  2074 	// Check outgoing is unchanged
  2075 	res = view->SetRecentListL(KLogRecentOutgoingCalls, active->iStatus);
  2076 	TEST(res);
  2077 	TEST2(view->CountL(), 5);
  2078 
  2079 	do
  2080 		{
  2081 		active->StartL();
  2082 		CActiveScheduler::Start();
  2083 		TEST2(active->iStatus.Int(), KErrNone);
  2084 
  2085 		// No duplicates should exist for this view now
  2086 		res = view->DuplicatesL(*dView, active->iStatus);
  2087 		TEST(!res);
  2088 		TEST2(dView->CountL(), 0);
  2089 		}
  2090 	while(view->NextL(active->iStatus));
  2091 
  2092 	CleanupStack::PopAndDestroy(4); // event, dView, view, active
  2093 	}
  2094 
  2095 /**
  2096 @SYMTestCaseID          SYSLIB-LOGENG-CT-0865
  2097 @SYMTestCaseDesc	    Test for the functionality of CLogViewEvent class
  2098 @SYMTestPriority 	    High
  2099 @SYMTestActions  	    Set an event with a number,add the event to the client.Tests for matching a number from the view
  2100 @SYMTestExpectedResults Test must not fail
  2101 @SYMREQ                 REQ0000
  2102 */
  2103 LOCAL_C void TestPhoneNumberMatchingL(CLogClient& aClient)
  2104 	{
  2105 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0865 "));
  2106 	TestUtils::DeleteDatabaseL();
  2107 
  2108 	CTestActive* active = new(ELeave)CTestActive();
  2109 	CleanupStack::PushL(active);
  2110 
  2111 	CLogEvent* event = CLogEvent::NewL();
  2112 	CleanupStack::PushL(event);
  2113 
  2114 	event->SetEventType(KLogCallEventTypeUid);
  2115 	TBuf<KLogMaxDirectionLength> missed;
  2116 	aClient.GetString(missed, R_LOG_DIR_MISSED);
  2117 	event->SetDirection(missed);
  2118 
  2119 	TLogString number;
  2120 	TInt i;
  2121 	for(i = 0; i < 10; i++)
  2122 		{
  2123 		TBuf<1> digit;
  2124 		digit.Num(i);
  2125 		number.Insert(0, digit);
  2126 		event->SetNumber(number);
  2127 
  2128 		aClient.AddEvent(*event, active->iStatus);
  2129 		active->StartL();
  2130 		CActiveScheduler::Start();
  2131 		TEST2(active->iStatus.Int(), KErrNone);
  2132 		}
  2133 
  2134 	CLogFilter* filter = CLogFilter::NewL();
  2135 	CleanupStack::PushL(filter);
  2136 
  2137 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
  2138 	CleanupStack::PushL(view);
  2139 
  2140 	TBool res = view->SetFilterL(*filter, active->iStatus);
  2141 	TEST(res);
  2142 	active->StartL();
  2143 	CActiveScheduler::Start();
  2144 	TEST2(active->iStatus.Int(), KErrNone);
  2145 	TEST2(view->CountL(), 10);
  2146 
  2147 	number.Zero();
  2148 	for(i = 0; i < 10; i++)
  2149 		{
  2150 		TBuf<1> digit;
  2151 		digit.Num(i);
  2152 		number.Insert(0, digit);
  2153 		filter->SetNumber(number);
  2154 
  2155 		// This is testing phone number matching
  2156 		res = view->SetFilterL(*filter, active->iStatus);
  2157 		TEST(res);
  2158 		active->StartL();
  2159 		CActiveScheduler::Start();
  2160 		TEST2(active->iStatus.Int(), KErrNone);
  2161 
  2162 		// Phone numbers with KTestLogNumberCharsToMatch characters or above can match with each other
  2163 		TEST2(view->CountL(), (number.Length() < KTestLogNumberCharsToMatch) ? 1 : 11-KTestLogNumberCharsToMatch);		
  2164 		}
  2165 
  2166 	CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
  2167 	CleanupStack::PushL(recent);
  2168 
  2169 	CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient);
  2170 	CleanupStack::PushL(duplicate);
  2171 
  2172 	res = recent->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
  2173 	TEST(res);
  2174 	active->StartL();
  2175 	CActiveScheduler::Start();
  2176 	TEST2(active->iStatus.Int(), KErrNone);
  2177 	TEST2(recent->CountL(), KTestLogNumberCharsToMatch);
  2178 
  2179 	res = recent->DuplicatesL(*duplicate, active->iStatus);
  2180 	TEST(res);
  2181 	TEST2(duplicate->CountL(), 10-KTestLogNumberCharsToMatch);
  2182 
  2183 	// Check the first recent event has duplicates
  2184 	do
  2185 		{
  2186 		active->StartL();
  2187 		CActiveScheduler::Start();
  2188 		TEST2(active->iStatus.Int(), KErrNone);
  2189 
  2190 		TPtrC number1(recent->Event().Number().Right(KTestLogNumberCharsToMatch));
  2191 		TPtrC number2(duplicate->Event().Number().Right(KTestLogNumberCharsToMatch));
  2192 		TEST(number1 == number2);
  2193 		}
  2194 	while(duplicate->NextL(active->iStatus));
  2195 
  2196 	// Check none of the others have duplicates
  2197 	while(recent->NextL(active->iStatus))
  2198 		{
  2199 		active->StartL();
  2200 		CActiveScheduler::Start();
  2201 		TEST2(active->iStatus.Int(), KErrNone);
  2202 		res = recent->DuplicatesL(*duplicate, active->iStatus);
  2203 		TEST(!res);
  2204 		}
  2205 
  2206 	CleanupStack::PopAndDestroy(6); // duplicate, recent, view, filter, event, active
  2207 	}
  2208 
  2209 /**
  2210 @SYMTestCaseID          SYSLIB-LOGENG-CT-3472
  2211 @SYMTestCaseDesc	    Tests duplicate number matching correctly compares and matches the last 9 digits
  2212 @SYMTestPriority 	    High
  2213 @SYMTestActions  	    Create and add several numbers to client, check that duplicates are correctly removed
  2214 @SYMTestExpectedResults Number with the same last 9 digits should get matched as duplicates
  2215 @SYMDEF                 INC105010
  2216 */	
  2217 LOCAL_C void INC105010L(CLogClient& aClient)
  2218 {
  2219 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-3472 "));
  2220 	TestUtils::DeleteDatabaseL();
  2221 
  2222 	CTestActive* active = new(ELeave)CTestActive();
  2223 	CleanupStack::PushL(active);
  2224 
  2225 	CLogEvent* event = CLogEvent::NewL();
  2226 	CleanupStack::PushL(event);
  2227 
  2228 	event->SetEventType(KLogCallEventTypeUid);
  2229 	TBuf<KLogMaxDirectionLength> missed;
  2230 	aClient.GetString(missed, R_LOG_DIR_MISSED);
  2231 	event->SetDirection(missed);
  2232 
  2233 	_LIT(KTestNumber1, "0401234567"); // unique
  2234 	_LIT(KTestNumber2, "0421234567"); // unique
  2235 	_LIT(KTestNumber3, "0521234567"); // unique
  2236 	_LIT(KTestNumber4, "9521234567"); // duplicate
  2237 	_LIT(KTestNumber5, "9521234567"); // duplicate
  2238 	
  2239 	TLogString number;
  2240 
  2241  	// add events for the above numbers
  2242 	event->SetNumber(KTestNumber1);
  2243 	aClient.AddEvent(*event, active->iStatus);
  2244 	active->StartL();
  2245 	CActiveScheduler::Start();
  2246 	TEST2(active->iStatus.Int(), KErrNone);
  2247 	
  2248 	event->SetNumber(KTestNumber2);
  2249 	aClient.AddEvent(*event, active->iStatus);
  2250 	active->StartL();
  2251 	CActiveScheduler::Start();
  2252 	TEST2(active->iStatus.Int(), KErrNone);
  2253 	
  2254 	event->SetNumber(KTestNumber3);
  2255 	aClient.AddEvent(*event, active->iStatus);
  2256 	active->StartL();
  2257 	CActiveScheduler::Start();
  2258 	TEST2(active->iStatus.Int(), KErrNone);
  2259 	
  2260 	event->SetNumber(KTestNumber4);
  2261 	aClient.AddEvent(*event, active->iStatus);
  2262 	active->StartL();
  2263 	CActiveScheduler::Start();
  2264 	TEST2(active->iStatus.Int(), KErrNone);
  2265 	
  2266 	event->SetNumber(KTestNumber5);
  2267 	aClient.AddEvent(*event, active->iStatus);
  2268 	active->StartL();
  2269 	CActiveScheduler::Start();
  2270 	TEST2(active->iStatus.Int(), KErrNone);
  2271 	
  2272 	CLogFilter* filter = CLogFilter::NewL();
  2273 	CleanupStack::PushL(filter);
  2274 
  2275 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
  2276 	CleanupStack::PushL(view);
  2277 
  2278 	// check 5 entries in log
  2279 	TBool res = view->SetFilterL(*filter, active->iStatus);
  2280 	TEST(res);
  2281 	active->StartL();
  2282 	CActiveScheduler::Start();
  2283 	TEST2(active->iStatus.Int(), KErrNone);	
  2284 	TEST2(view->CountL(), 5);
  2285 
  2286 	CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
  2287 	CleanupStack::PushL(recent);
  2288 
  2289 	CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(aClient);
  2290 	CleanupStack::PushL(duplicate);
  2291 
  2292 	// check only 3 entries in recent calls view
  2293 	res = recent->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
  2294 	TEST(res);
  2295 	active->StartL();
  2296 	CActiveScheduler::Start();
  2297 	TEST2(active->iStatus.Int(), KErrNone);
  2298 	TInt rrr = recent->CountL();
  2299 	TEST2(recent->CountL(), 3);
  2300 
  2301 	// and that there are 2 duplicates
  2302 	res = recent->DuplicatesL(*duplicate, active->iStatus);
  2303 	TEST(res);
  2304 	active->StartL();
  2305 	CActiveScheduler::Start();
  2306 	TEST2(active->iStatus.Int(), KErrNone);	
  2307 	
  2308 	TInt ddd = duplicate->CountL();
  2309 	TEST2(duplicate->CountL(), 2);
  2310 
  2311 	CleanupStack::PopAndDestroy(6); 
  2312 }
  2313 	
  2314 	
  2315 	
  2316 /**
  2317 @SYMTestCaseID          SYSLIB-LOGENG-CT-0866
  2318 @SYMTestCaseDesc	    Tests for CLogViewEvent::SetFlagsL() function
  2319 @SYMTestPriority 	    High
  2320 @SYMTestActions  	    Add events to the log and set the flags.Check if all the flags are set.
  2321                         Clear all the flags and set half view of the flags.Check if only all view of the flags are set.
  2322 @SYMTestExpectedResults Test must not fail
  2323 @SYMREQ                 REQ0000
  2324 */
  2325 LOCAL_C void TestRecentFlagsL(CLogClient& aClient)
  2326 	{
  2327 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0866 "));
  2328 	TestUtils::DeleteDatabaseL();
  2329 
  2330 	CLogEvent* event = CLogEvent::NewL();
  2331 	CleanupStack::PushL(event);
  2332 
  2333 	CTestActive* active = new(ELeave)CTestActive();
  2334 	CleanupStack::PushL(active);
  2335 
  2336 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
  2337 	CleanupStack::PushL(view);
  2338 
  2339 	// Incoming
  2340 	TBuf<KLogMaxDirectionLength> buf;
  2341 	aClient.GetString(buf, R_LOG_DIR_IN);
  2342 
  2343 	event->SetEventType(KLogCallEventTypeUid);
  2344 	event->SetDirection(buf);
  2345 	
  2346 	TInt count;
  2347 	for(count = 0; count < KTestEventNum; count++)
  2348 		{
  2349 		event->SetContact(count);
  2350 
  2351 		active->StartL();
  2352 		aClient.AddEvent(*event, active->iStatus);
  2353 		CActiveScheduler::Start();
  2354 		TEST2(active->iStatus.Int(), KErrNone);
  2355 		}
  2356 
  2357 	TEST2(view->CountL(), 0);
  2358 	TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  2359 	TEST(res);
  2360 	active->StartL();
  2361 	CActiveScheduler::Start();
  2362 	TEST2(active->iStatus.Int(), KErrNone);
  2363 	TEST2(view->CountL(), KTestEventNum);
  2364 
  2365 	// Set all flags in view
  2366 	const TLogFlags KAllFlagsSet = 15; // (BIN) 1,1,1,1 
  2367 	view->SetFlagsL(KAllFlagsSet);
  2368 
  2369 	// Check we can move to the first record
  2370 	res = view->FirstL(active->iStatus);
  2371 	TEST(res);
  2372 
  2373 	// Check all flags are now set
  2374 	count = KTestEventNum;
  2375 	do	{
  2376 		active->StartL();
  2377 		CActiveScheduler::Start();
  2378 		TEST2(active->iStatus.Int(), KErrNone);
  2379 		//
  2380 		TEST2(view->CountL(), KTestEventNum);
  2381 		TEST2(view->RecentList(), KLogRecentIncomingCalls);
  2382 		//
  2383 		const TLogFlags flags = view->Event().Flags();
  2384 		TEST2(flags, KAllFlagsSet);
  2385 		count--;
  2386 		}
  2387 	while(view->NextL(active->iStatus));
  2388 
  2389 	TEST2(count, 0);
  2390 	TEST2(view->CountL(), KTestEventNum);
  2391 
  2392 	// Clear all flags in view
  2393 	const TLogFlags KAllFlagsCleared = 0; // (BIN) 0,0,0,0 
  2394 	view->SetFlagsL(KAllFlagsCleared);
  2395 	TEST2(view->CountL(), KTestEventNum);
  2396 
  2397 	// Check we can move to the first record
  2398 	res = view->FirstL(active->iStatus);
  2399 	TEST(res);
  2400 
  2401 	// Check all flags are now set
  2402 	count = KTestEventNum;
  2403 	do	{
  2404 		active->StartL();
  2405 		CActiveScheduler::Start();
  2406 		TEST2(active->iStatus.Int(), KErrNone);
  2407 		//
  2408 		TEST2(view->CountL(), KTestEventNum);
  2409 		TEST2(view->RecentList(), KLogRecentIncomingCalls);
  2410 		//
  2411 		const TLogFlags flags = view->Event().Flags();
  2412 		TEST2(flags, KAllFlagsCleared);
  2413 		count--;
  2414 		}
  2415 	while(view->NextL(active->iStatus));
  2416 	
  2417 	TEST2(count, 0);
  2418 	TEST2(view->CountL(), KTestEventNum);
  2419 
  2420 	// Set lower half flags in view
  2421 	const TLogFlags KLowerHalfFlagsSet = 3; // (BIN) 1,1,0,0 
  2422 	view->SetFlagsL(KLowerHalfFlagsSet);
  2423 
  2424 	// Check we can move to the first record
  2425 	res = view->FirstL(active->iStatus);
  2426 	TEST(res);
  2427 
  2428 	// Check all flags are now set
  2429 	count = KTestEventNum;
  2430 	do	{
  2431 		active->StartL();
  2432 		CActiveScheduler::Start();
  2433 		TEST2(active->iStatus.Int(), KErrNone);
  2434 		//
  2435 		TEST2(view->CountL(), KTestEventNum);
  2436 		TEST2(view->RecentList(), KLogRecentIncomingCalls);
  2437 		//
  2438 		const TLogFlags flags = view->Event().Flags();
  2439 		TEST2(flags, KLowerHalfFlagsSet);
  2440 		count--;
  2441 		}
  2442 	while(view->NextL(active->iStatus));
  2443 
  2444 	TEST2(count, 0);
  2445 	TEST2(view->CountL(), KTestEventNum);
  2446 
  2447 	CleanupStack::PopAndDestroy(3, event); // view, active, event
  2448 	}
  2449 
  2450 /**
  2451 @SYMTestCaseID          SYSLIB-LOGENG-CT-0867
  2452 @SYMTestCaseDesc	    Tests for CLogViewEvent::SetFlagsL() function
  2453 @SYMTestPriority 	    High
  2454 @SYMTestActions  	    Add events to the log and set the flags.Check if flags for only the events in view are set.
  2455 @SYMTestExpectedResults Test must not fail
  2456 @SYMREQ                 REQ0000
  2457 */
  2458 LOCAL_C void TestViewFlagsL(CLogClient& aClient)
  2459 	{
  2460 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0867 "));
  2461 	TestUtils::DeleteDatabaseL();
  2462 
  2463 	CLogEvent* event = CLogEvent::NewL();
  2464 	CleanupStack::PushL(event);
  2465 
  2466 	CTestActive* active = new(ELeave)CTestActive();
  2467 	CleanupStack::PushL(active);
  2468 
  2469 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
  2470 	CleanupStack::PushL(view);
  2471 
  2472 	// Incoming
  2473 	TBuf<KLogMaxDirectionLength> buf;
  2474 	aClient.GetString(buf, R_LOG_DIR_IN);
  2475 
  2476 	event->SetEventType(KLogCallEventTypeUid);
  2477 	event->SetDirection(buf);
  2478 	
  2479 	event->SetNumber(_L("123"));
  2480 	active->StartL();
  2481 	aClient.AddEvent(*event, active->iStatus);
  2482 	CActiveScheduler::Start();
  2483 	TEST2(active->iStatus.Int(), KErrNone);
  2484 	TLogId testId = event->Id();
  2485 	event->SetNumber(KNullDesC);
  2486 	TheTest.Printf(_L("  Event flags: 0x%X\r\n"), event->Flags());
  2487 
  2488 	TInt count;
  2489 	for(count = 0; count < KTestEventNum; count++)
  2490 		{
  2491 		event->SetContact(count + 1);
  2492 
  2493 		active->StartL();
  2494 		aClient.AddEvent(*event, active->iStatus);
  2495 		CActiveScheduler::Start();
  2496 		TEST2(active->iStatus.Int(), KErrNone);
  2497 		}
  2498 
  2499 	TEST2(view->CountL(), 0);
  2500 
  2501 	CLogFilter* filter = CLogFilter::NewL();
  2502 	CleanupStack::PushL(filter);
  2503 	filter->SetNullFields(ELogNumberField);
  2504 
  2505 	TEST2(view->CountL(), 0);
  2506 	TBool res = view->SetFilterL(*filter, active->iStatus);
  2507 	TEST(res);
  2508 	active->StartL();
  2509 	CActiveScheduler::Start();
  2510 	TEST2(active->iStatus.Int(), KErrNone);
  2511 	TEST2(view->CountL(), KTestEventNum);
  2512 
  2513 	// Set all flags in view
  2514 	const TLogFlags KAllFlagsSet = 15; // (BIN) 1,1,1,1 
  2515 	view->SetFlagsL(KAllFlagsSet);
  2516 
  2517 	// Check flags only set for events in the view
  2518 	active->StartL();
  2519 	event->SetId(testId);
  2520 	aClient.GetEvent(*event, active->iStatus);
  2521 	CActiveScheduler::Start();
  2522 	TEST2(active->iStatus.Int(), KErrNone);
  2523 	if( TheMatchingIsEnabled)
  2524 		{//This check will fail if the first AddEvent() call in this function didn't perform contact matching
  2525 		TEST2(event->Flags(), KLogEventContactSearched);
  2526 		}
  2527 	else
  2528 		{
  2529 		TEST2(event->Flags(), 0);
  2530 		}
  2531 
  2532 	// Check we can move to the first record
  2533 	res = view->FirstL(active->iStatus);
  2534 	TEST(res);
  2535 
  2536 	// Check all flags are now set
  2537 	count = KTestEventNum;
  2538 	do	{
  2539 		active->StartL();
  2540 		CActiveScheduler::Start();
  2541 		TEST2(active->iStatus.Int(), KErrNone);
  2542 		//
  2543 		TEST2(view->CountL(), KTestEventNum);
  2544 		//
  2545 		const TLogFlags flags = view->Event().Flags();
  2546 		TEST2(flags, KAllFlagsSet);
  2547 		count--;
  2548 		}
  2549 	while(view->NextL(active->iStatus));
  2550 
  2551 	TEST2(count, 0);
  2552 	TEST2(view->CountL(), KTestEventNum);
  2553 
  2554 	// Clear all flags in view
  2555 	const TLogFlags KAllFlagsCleared = 0; // (BIN) 0,0,0,0 
  2556 	view->SetFlagsL(KAllFlagsCleared);
  2557 	TEST2(view->CountL(), KTestEventNum);
  2558 
  2559 	// Check flags only set for events in the view
  2560 	active->StartL();
  2561 	event->SetId(testId);
  2562 	aClient.GetEvent(*event, active->iStatus);
  2563 	CActiveScheduler::Start();
  2564 	TEST2(active->iStatus.Int(), KErrNone);
  2565 	if( TheMatchingIsEnabled)
  2566 		{
  2567 		TEST2(event->Flags(), KLogEventContactSearched);
  2568 		}
  2569 	else
  2570 		{
  2571 		TEST2(event->Flags(), 0);
  2572 		}
  2573 
  2574 	// Check we can move to the first record
  2575 	res = view->FirstL(active->iStatus);
  2576 	TEST(res);
  2577 
  2578 	// Check all flags are now set
  2579 	count = KTestEventNum;
  2580 	do	{
  2581 		active->StartL();
  2582 		CActiveScheduler::Start();
  2583 		TEST2(active->iStatus.Int(), KErrNone);
  2584 		//
  2585 		TEST2(view->CountL(), KTestEventNum);
  2586 		//
  2587 		const TLogFlags flags = view->Event().Flags();
  2588 		TEST2(flags, KAllFlagsCleared);
  2589 		count--;
  2590 		}
  2591 	while(view->NextL(active->iStatus));
  2592 	
  2593 	TEST2(count, 0);
  2594 	TEST2(view->CountL(), KTestEventNum);
  2595 
  2596 	// Set lower half flags in view
  2597 	const TLogFlags KLowerHalfFlagsSet = 3; // (BIN) 1,1,0,0 
  2598 	view->SetFlagsL(KLowerHalfFlagsSet);
  2599 
  2600 	// Check flags only set for events in the view
  2601 	active->StartL();
  2602 	event->SetId(testId);
  2603 	aClient.GetEvent(*event, active->iStatus);
  2604 	CActiveScheduler::Start();
  2605 	TEST2(active->iStatus.Int(), KErrNone);
  2606 	if( TheMatchingIsEnabled)
  2607 		{
  2608 		TEST2(event->Flags(), KLogEventContactSearched);
  2609 		}
  2610 	else
  2611 		{
  2612 		TEST2(event->Flags(), 0);
  2613 		}
  2614 
  2615 	// Check we can move to the first record
  2616 	res = view->FirstL(active->iStatus);
  2617 	TEST(res);
  2618 
  2619 	// Check all flags are now set
  2620 	count = KTestEventNum;
  2621 	do	{
  2622 		active->StartL();
  2623 		CActiveScheduler::Start();
  2624 		TEST2(active->iStatus.Int(), KErrNone);
  2625 		//
  2626 		TEST2(view->CountL(), KTestEventNum);
  2627 		//
  2628 		const TLogFlags flags = view->Event().Flags();
  2629 		TEST2(flags, KLowerHalfFlagsSet);
  2630 		count--;
  2631 		}
  2632 	while(view->NextL(active->iStatus));
  2633 
  2634 	TEST2(count, 0);
  2635 	TEST2(view->CountL(), KTestEventNum);
  2636 
  2637 	CleanupStack::PopAndDestroy(4, event); // filter, view, active, event
  2638 	}
  2639 
  2640 /**
  2641 @SYMTestCaseID          SYSLIB-LOGENG-CT-0868
  2642 @SYMTestCaseDesc	    Tests for CLogViewChangeObserver::HaveChanges(),Changes() functions
  2643 @SYMTestPriority 	    High
  2644 @SYMTestActions  	    Check for observing changes while adding and deleting events
  2645 @SYMTestExpectedResults Test must not fail
  2646 @SYMREQ                 REQ0000
  2647 */
  2648 LOCAL_C void TestViewChangeEvents1L(CLogClient& aClient)
  2649 	{
  2650 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0868 "));
  2651 	TestUtils::DeleteDatabaseL();
  2652 
  2653 	CLogEvent* event = CLogEvent::NewL();
  2654 	CleanupStack::PushL(event);
  2655 
  2656 	CLogFilter* filter = CLogFilter::NewL();
  2657 	CleanupStack::PushL(filter);
  2658 	filter->SetContact(KTestContact);
  2659 	filter->SetEventType(KLogPacketDataEventTypeUid);
  2660 
  2661 	CTestActive* active = new(ELeave)CTestActive();
  2662 	CleanupStack::PushL(active);
  2663 
  2664 	CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
  2665 	changeObs->SetActive();
  2666 
  2667 	CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
  2668 	CleanupStack::PushL(view);
  2669 
  2670 	// Incoming
  2671 	TBuf<KLogMaxDirectionLength> buf;
  2672 	aClient.GetString(buf, R_LOG_DIR_IN);
  2673 
  2674 	event->SetEventType(KLogPacketDataEventTypeUid);
  2675 	event->SetDirection(buf);
  2676 	event->SetContact(KTestContact);
  2677 
  2678 	TInt i;
  2679 	TInt count;
  2680 	for(count = 0; count < KTestEventNum; count++)
  2681 		{
  2682 		active->StartL();
  2683 		aClient.AddEvent(*event, active->iStatus);
  2684 		CActiveScheduler::Start();
  2685 		TEST2(active->iStatus.Int(), KErrNone);
  2686 		User::After(1 * 1000000);
  2687 		}
  2688 	//
  2689 	TEST2(view->CountL(), 0);
  2690 	active->StartL();
  2691 	TBool res = view->SetFilterL(*filter, active->iStatus);
  2692 	TEST(res);
  2693 	CActiveScheduler::Start();
  2694 	TEST2(active->iStatus.Int(), KErrNone);
  2695 	TEST2(view->CountL(), KTestEventNum);
  2696 	//
  2697 	count = KTestEventNum;
  2698 	res = view->FirstL(active->iStatus);
  2699 	TEST(res);
  2700 	do	{
  2701 		active->StartL();
  2702 		CActiveScheduler::Start();
  2703 		TEST2(active->iStatus.Int(), KErrNone);
  2704 		//
  2705 		TEST2(view->CountL(), KTestEventNum);
  2706 		const TLogId eventId = view->Event().Id();
  2707 		TLogId id = --count;
  2708 		TEST2(eventId, id);
  2709 		}
  2710 	while(view->NextL(active->iStatus));
  2711 
  2712 	// Transients
  2713 	TInt changeCount;
  2714 	TLogId logId;
  2715 	TInt viewIndex;
  2716 	TLogDatabaseChangeType type;
  2717 	CLogChangeDefinition* changes;
  2718 	
  2719 	// Add an event and check for changes
  2720 	active->StartL();
  2721 	aClient.AddEvent(*event, active->iStatus);
  2722 	changes = changeObs->WaitForChangesLC();
  2723 	if	(active->IsActive())
  2724 		CActiveScheduler::Start();
  2725 	TEST2(active->iStatus.Int(), KErrNone);
  2726 	count = view->CountL();
  2727 	TEST2(count, KTestEventNum+1);
  2728 
  2729 	changeCount = changes->Count();
  2730 	for(i=0; i<changeCount; i++)
  2731 		{
  2732 		type = changes->At(i, logId, viewIndex);
  2733 		TheTest.Printf(_L("Change Type: %d, logId: %d, viewIndex: %d\n"), type, logId, viewIndex);
  2734 		}
  2735 	
  2736 	// Check the change was as expected
  2737 	TEST2(changes->Count(), 1);
  2738 	type = changes->At(0, logId, viewIndex);
  2739 	TEST2(type, ELogChangeTypeEventAdded);
  2740 	TEST2(viewIndex, 0); // first (newest) event in the view
  2741 	{
  2742 	const TLogId expectedLogId = ((TLogId) KTestEventNum);
  2743 	TEST2(logId, expectedLogId);
  2744 	}
  2745 	CleanupStack::PopAndDestroy(changes);
  2746 
  2747 	// Check view navigation
  2748 	i=0;
  2749 	res = view->FirstL(active->iStatus);
  2750 	TEST(res);
  2751 	do
  2752 		{
  2753 		active->StartL();
  2754 		CActiveScheduler::Start();
  2755 		TEST2(active->iStatus.Int(), KErrNone);
  2756 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  2757 		}
  2758 	while(view->NextL(active->iStatus));
  2759 	TheTest.Printf(_L("==\n"));
  2760 	TEST2(i, count);
  2761 	res = view->FirstL(active->iStatus);
  2762 	TEST(res);
  2763 	active->StartL();
  2764 	CActiveScheduler::Start();
  2765 	TEST2(active->iStatus.Int(), KErrNone);
  2766 
  2767 	// Delete some events
  2768 	TEST(KTestEventNum >= 10);
  2769 	changeObs->StartCollectingChanges();
  2770 	for(i=1; i<KTestEventNum; i+=2)
  2771 		{
  2772 		active->StartL();
  2773 		aClient.DeleteEvent(TLogId(i), active->iStatus);
  2774 		CActiveScheduler::Start();
  2775 		TEST2(active->iStatus.Int(), KErrNone);
  2776 		}
  2777 
  2778 	// Check changes
  2779 	changeCount = changeObs->Changes().Count();
  2780 	TEST2(changeCount, 5); // 1,3,5,7,9
  2781 	for(i=0; i<changeCount; i++)
  2782 		{
  2783 		TEST2(changeObs->Changes().At(i, logId, viewIndex), ELogChangeTypeEventDeleted);
  2784 		TEST2(logId, TLogId(2*i + 1));
  2785 		TEST2(viewIndex, 10 - ((2*i) + 1));
  2786 		}
  2787 	
  2788 	// Add a new event that shouldn't appear in the view
  2789 	changeObs->StartCollectingChanges();
  2790 	event->SetContact(TLogContactItemId(0));
  2791 	active->StartL();
  2792 	aClient.AddEvent(*event, active->iStatus);
  2793 	CActiveScheduler::Start();
  2794 	TEST2(active->iStatus.Int(), KErrNone);
  2795 	count = view->CountL();
  2796 	TEST2(count, KTestEventNum + 1 - 5);
  2797 	TEST2(event->Id(), KTestEventNum + 1);
  2798 
  2799 	// Check changes
  2800 	TEST(!changeObs->HaveChanges());
  2801 
  2802 	// Check view navigation
  2803 	i=0;
  2804 	res = view->FirstL(active->iStatus);
  2805 	TEST(res);
  2806 	do
  2807 		{
  2808 		active->StartL();
  2809 		CActiveScheduler::Start();
  2810 		TEST2(active->iStatus.Int(), KErrNone);
  2811 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  2812 		}
  2813 	while(view->NextL(active->iStatus));
  2814 	TheTest.Printf(_L("==\n"));
  2815 	TEST2(i, count);
  2816 	res = view->FirstL(active->iStatus);
  2817 	TEST(res);
  2818 	active->StartL();
  2819 	CActiveScheduler::Start();
  2820 	TEST2(active->iStatus.Int(), KErrNone);
  2821 
  2822 	// Delete event which isn't in view
  2823 	changeObs->StartCollectingChanges();
  2824 	active->StartL();
  2825 	aClient.DeleteEvent(event->Id(), active->iStatus);
  2826 	CActiveScheduler::Start();
  2827 	TEST2(active->iStatus.Int(), KErrNone);
  2828 	count = view->CountL();
  2829 	TEST2(count, KTestEventNum + 1 - 5);
  2830 
  2831 	// Check changes
  2832 	TEST(!changeObs->HaveChanges());
  2833 
  2834 	// Check view navigation
  2835 	i=0;
  2836 	res = view->FirstL(active->iStatus);
  2837 	TEST(res);
  2838 	do
  2839 		{
  2840 		active->StartL();
  2841 		CActiveScheduler::Start();
  2842 		TEST2(active->iStatus.Int(), KErrNone);
  2843 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  2844 		}
  2845 	while(view->NextL(active->iStatus));
  2846 	TheTest.Printf(_L("==\n"));
  2847 	TEST2(i, count);
  2848 	res = view->FirstL(active->iStatus);
  2849 	TEST(res);
  2850 	active->StartL();
  2851 	CActiveScheduler::Start();
  2852 	TEST2(active->iStatus.Int(), KErrNone);
  2853 
  2854 	// Add a new event again that shouldn't appear in the view
  2855 	changeObs->StartCollectingChanges();
  2856 	event->SetContact(TLogContactItemId(0));
  2857 	active->StartL();
  2858 	aClient.AddEvent(*event, active->iStatus);
  2859 	CActiveScheduler::Start();
  2860 	TEST2(active->iStatus.Int(), KErrNone);
  2861 	count = view->CountL();
  2862 	TEST2(count, KTestEventNum + 1 - 5);
  2863 	TEST2(event->Id(),  KTestEventNum + 2);
  2864 
  2865 	// Check changes
  2866 	TEST(!changeObs->HaveChanges());
  2867 
  2868 	// Check view navigation
  2869 	i=0;
  2870 	res = view->FirstL(active->iStatus);
  2871 	TEST(res);
  2872 	do
  2873 		{
  2874 		active->StartL();
  2875 		CActiveScheduler::Start();
  2876 		TEST2(active->iStatus.Int(), KErrNone);
  2877 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  2878 		}
  2879 	while(view->NextL(active->iStatus));
  2880 	TheTest.Printf(_L("==\n"));
  2881 	TEST2(i, count);
  2882 	res = view->FirstL(active->iStatus);
  2883 	TEST(res);
  2884 	active->StartL();
  2885 	CActiveScheduler::Start();
  2886 	TEST2(active->iStatus.Int(), KErrNone);
  2887 
  2888 	// Change event so that it appears in the view
  2889 	changeObs->StartCollectingChanges();
  2890 	event->SetContact(KTestContact);
  2891 	active->StartL();
  2892 	aClient.ChangeEvent(*event, active->iStatus);
  2893 	CActiveScheduler::Start();
  2894 	TEST2(active->iStatus.Int(), KErrNone);
  2895 	count = view->CountL();
  2896 	TEST2(count, KTestEventNum + 2 - 5);
  2897 	TEST2(event->Id(),  KTestEventNum + 2); // Shouldn't change
  2898 
  2899 	// Check changes
  2900 	changeCount = changeObs->Changes().Count();
  2901 	TEST2(changeCount, 1);
  2902 	type = changeObs->Changes().At(0, logId, viewIndex);
  2903 	TEST2(type, ELogChangeTypeEventAdded);
  2904 	TEST2(logId, KTestEventNum + 2);
  2905 	TEST2(viewIndex, 0);
  2906 
  2907 	// Check view navigation
  2908 	i=0;
  2909 	res = view->FirstL(active->iStatus);
  2910 	TEST(res);
  2911 	do
  2912 		{
  2913 		active->StartL();
  2914 		CActiveScheduler::Start();
  2915 		TEST2(active->iStatus.Int(), KErrNone);
  2916 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  2917 		}
  2918 	while(view->NextL(active->iStatus));
  2919 	TheTest.Printf(_L("==\n"));
  2920 	TEST2(i, count);
  2921 	res = view->FirstL(active->iStatus);
  2922 	TEST(res);
  2923 	active->StartL();
  2924 	CActiveScheduler::Start();
  2925 	TEST2(active->iStatus.Int(), KErrNone);
  2926 
  2927 	// Simply change an event in the view
  2928 	changeObs->StartCollectingChanges();
  2929 	event->SetDescription(_L("Test"));
  2930 	active->StartL();
  2931 	aClient.ChangeEvent(*event, active->iStatus);
  2932 	CActiveScheduler::Start();
  2933 	TEST2(active->iStatus.Int(), KErrNone);
  2934 	count = view->CountL();
  2935 	TEST2(count, KTestEventNum + 2 - 5); // Shouldn't change
  2936 	TEST2(event->Id(),  KTestEventNum + 2); // Shouldn't change
  2937 
  2938 	// Check changes
  2939 	changeCount = changeObs->Changes().Count();
  2940 	TEST2(changeCount, 1);
  2941 	type = changeObs->Changes().At(0, logId, viewIndex);
  2942 	TEST2(type, ELogChangeTypeEventChanged);
  2943 	TEST2(logId, KTestEventNum + 2);
  2944 	TEST2(viewIndex, 0);
  2945 
  2946 	// Change an event in the view so that it is deleted
  2947 	changeObs->StartCollectingChanges();
  2948 	event->SetContact(0);
  2949 	active->StartL();
  2950 	aClient.ChangeEvent(*event, active->iStatus);
  2951 	CActiveScheduler::Start();
  2952 	TEST2(active->iStatus.Int(), KErrNone);
  2953 	count = view->CountL();
  2954 	TEST2(count, KTestEventNum + 2 - 5 - 1); // one less now
  2955 
  2956 	// Check changes
  2957 	changeCount = changeObs->Changes().Count();
  2958 	TEST2(changeCount, 1);
  2959 	type = changeObs->Changes().At(0, logId, viewIndex);
  2960 	TEST2(type, ELogChangeTypeEventDeleted);
  2961 	TEST2(logId, KTestEventNum + 2);
  2962 	TEST2(viewIndex, 0);
  2963 
  2964 	// Navigate part way through the view so we have
  2965 	// a cursor position part way through...
  2966 	i=0;
  2967 	count = view->CountL();
  2968 	res = view->FirstL(active->iStatus);
  2969 	TEST(res);
  2970 	do
  2971 		{
  2972 		active->StartL();
  2973 		CActiveScheduler::Start();
  2974 		TEST2(active->iStatus.Int(), KErrNone);
  2975 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  2976 		}
  2977 	while(view->NextL(active->iStatus));
  2978 	TheTest.Printf(_L("==\n"));
  2979 	TEST2(i, count);
  2980 	TEST2(view->Event().Id(), TLogId(0));
  2981 
  2982 	// Save id
  2983 	TLogId savedId = view->Event().Id();
  2984 
  2985 	// Go one back
  2986 	res = view->PreviousL(active->iStatus);
  2987 	TEST(res);
  2988 	active->StartL();
  2989 	CActiveScheduler::Start();
  2990 	TEST2(active->iStatus.Int(), KErrNone);
  2991 
  2992 	// Insert something
  2993 	changeObs->StartCollectingChanges();
  2994 	event->SetContact(KTestContact);
  2995 	active->StartL();
  2996 	aClient.AddEvent(*event, active->iStatus);
  2997 	CActiveScheduler::Start();
  2998 	TEST2(active->iStatus.Int(), KErrNone);
  2999 	count = view->CountL();
  3000 	TEST2(count, KTestEventNum + 2 - 5); // one more now
  3001 	TEST2(event->Id(),  KTestEventNum + 3);
  3002 
  3003 	// Check changes
  3004 	changeCount = changeObs->Changes().Count();
  3005 	TEST2(changeCount, 1);
  3006 	type = changeObs->Changes().At(0, logId, viewIndex);
  3007 	TEST2(type, ELogChangeTypeEventAdded);
  3008 	TEST2(logId, KTestEventNum + 3);
  3009 	TEST2(viewIndex, 0);
  3010 
  3011 	// Check we can still go forward to the last record
  3012 	res = view->NextL(active->iStatus);
  3013 	TEST(res);
  3014 	active->StartL();
  3015 	CActiveScheduler::Start();
  3016 	TEST2(active->iStatus.Int(), KErrNone);
  3017 	TEST2(view->Event().Id(), savedId);
  3018 
  3019 	// Go one back
  3020 	res = view->PreviousL(active->iStatus);
  3021 	TEST(res);
  3022 	active->StartL();
  3023 	CActiveScheduler::Start();
  3024 	TEST2(active->iStatus.Int(), KErrNone);
  3025 
  3026 	// Delete current record
  3027 	savedId = view->Event().Id();
  3028 	changeObs->StartCollectingChanges();
  3029 	active->StartL();
  3030 	aClient.DeleteEvent(savedId, active->iStatus);
  3031 	CActiveScheduler::Start();
  3032 	TEST2(active->iStatus.Int(), KErrNone);
  3033 	count = view->CountL();
  3034 	TEST2(count, KTestEventNum + 2 - 5 - 1); // one less
  3035 
  3036 	// Check changes
  3037 	changeCount = changeObs->Changes().Count();
  3038 	TEST2(changeCount, 1);
  3039 	type = changeObs->Changes().At(0, logId, viewIndex);
  3040 	TEST2(type, ELogChangeTypeEventDeleted);
  3041 	TEST2(logId, savedId);
  3042 	TEST2(viewIndex, KTestEventNum + 2 - 5 - 2); // last but one event
  3043 
  3044 	// Check we're now at the end of the view
  3045 	res = view->NextL(active->iStatus);
  3046 	TEST(!res);
  3047 
  3048 	// Go to the first record
  3049 	res = view->FirstL(active->iStatus);
  3050 	TEST(res);
  3051 	active->StartL();
  3052 	CActiveScheduler::Start();
  3053 	TEST2(active->iStatus.Int(), KErrNone);
  3054 
  3055 	// Delete the first record
  3056 	savedId = view->Event().Id();
  3057 	changeObs->StartCollectingChanges();
  3058 	active->StartL();
  3059 	aClient.DeleteEvent(savedId, active->iStatus);
  3060 	CActiveScheduler::Start();
  3061 	TEST2(active->iStatus.Int(), KErrNone);
  3062 	count = view->CountL();
  3063 	TEST2(count, KTestEventNum - 5);
  3064 
  3065 	// Check changes
  3066 	changeCount = changeObs->Changes().Count();
  3067 	TEST2(changeCount, 1);
  3068 	type = changeObs->Changes().At(0, logId, viewIndex);
  3069 	TEST2(type, ELogChangeTypeEventDeleted);
  3070 	TEST2(logId, savedId);
  3071 	TEST2(viewIndex, 0); // first item
  3072 
  3073 	// Check 'next' navigation can be performed correctly
  3074 	count = 0;
  3075 	view->NextL(active->iStatus);
  3076 	do
  3077 		{
  3078 		active->StartL();
  3079 		CActiveScheduler::Start();
  3080 		TEST2(active->iStatus.Int(), KErrNone);
  3081 		++count;
  3082 		}
  3083 	while(view->NextL(active->iStatus));
  3084 	TEST2(count, KTestEventNum - 5 - 1);
  3085 
  3086 	// Check last record
  3087 	savedId = view->Event().Id();
  3088 	res = view->LastL(active->iStatus);
  3089 	TEST(res);
  3090 	active->StartL();
  3091 	CActiveScheduler::Start();
  3092 	TEST2(active->iStatus.Int(), KErrNone);
  3093 	TEST2(savedId, view->Event().Id());
  3094 	
  3095 	// Delete the last record
  3096 	savedId = view->Event().Id();
  3097 	changeObs->StartCollectingChanges();
  3098 	active->StartL();
  3099 	aClient.DeleteEvent(savedId, active->iStatus);
  3100 	CActiveScheduler::Start();
  3101 	TEST2(active->iStatus.Int(), KErrNone);
  3102 	count = view->CountL();
  3103 	TEST2(count, KTestEventNum - 6);
  3104 
  3105 	// Check changes
  3106 	changeCount = changeObs->Changes().Count();
  3107 	TEST2(changeCount, 1);
  3108 	type = changeObs->Changes().At(0, logId, viewIndex);
  3109 	TEST2(type, ELogChangeTypeEventDeleted);
  3110 	TEST2(logId, savedId);
  3111 	TEST2(viewIndex, count); // There's now one less item, and we deleted the last item of the previous view
  3112 
  3113 	// Check we're still at the end of the view
  3114 	res = view->NextL(active->iStatus);
  3115 	TEST(!res);
  3116 
  3117 	CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event
  3118 	}
  3119 
  3120 CBaBackupSessionWrapper* theBackup = NULL;
  3121 
  3122 LOCAL_C TBool IsLogOpenL()
  3123 	{
  3124 	return TestUtils::IsDatabaseOpenL();
  3125 	}
  3126 
  3127 LOCAL_C void TestLogOpenL()
  3128 	{
  3129 	TEST(IsLogOpenL());
  3130 	}
  3131 
  3132 LOCAL_C void TestLogClosedL()
  3133 	{
  3134 	TEST(!IsLogOpenL());
  3135 	}
  3136 
  3137 LOCAL_C void StartBackupL()
  3138 	{
  3139 	User::InfoPrint(_L("Backup"));
  3140 
  3141 	TDriveUnit driveUnit(EDriveC);
  3142 	TDriveName name = driveUnit.Name();
  3143 
  3144 	TParse parse;
  3145 	LEAVE_IF_ERROR(parse.Set(KLogDatabaseName, &name, NULL));
  3146 
  3147 	delete theBackup;
  3148 	theBackup = NULL;
  3149 	theBackup = CBaBackupSessionWrapper::NewL();
  3150 
  3151 	theBackup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
  3152 	User::After(1000000);
  3153 	}
  3154 
  3155 LOCAL_C void EndBackupL()
  3156 	{
  3157 	delete theBackup;
  3158 	theBackup = NULL;
  3159 	User::After(1000000);
  3160 	}
  3161 
  3162 LOCAL_C void DelayL(TInt aDelay)
  3163 	{
  3164 	CTestTimer* timer = CTestTimer::NewL();
  3165 	timer->After(aDelay);
  3166 	CActiveScheduler::Start();
  3167 	delete timer;
  3168 	}
  3169 
  3170 /**
  3171 @SYMTestCaseID          SYSLIB-LOGENG-CT-0869
  3172 @SYMTestCaseDesc	    Tests for CLogViewChangeObserver::HaveChanges(),CLogViewChangeObserver::Changes() functions
  3173 @SYMTestPriority 	    High
  3174 @SYMTestActions  	    Check for observing changes while adding,deleting events.Check for observing changes after a backup.
  3175                         Check for navigating the view.Test for KErrNone condition.
  3176 @SYMTestExpectedResults Test must not fail
  3177 @SYMREQ                 REQ0000
  3178 */
  3179 LOCAL_C void TestViewChangeEvents1aL(CLogClient& aClient)
  3180 	{
  3181 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0869 "));
  3182 	TestUtils::DeleteDatabaseL();
  3183 
  3184 	CLogEvent* event = CLogEvent::NewL();
  3185 	CleanupStack::PushL(event);
  3186 
  3187 	CLogFilter* filter = CLogFilter::NewL();
  3188 	CleanupStack::PushL(filter);
  3189 	filter->SetContact(KTestContact);
  3190 	filter->SetEventType(KLogPacketDataEventTypeUid);
  3191 
  3192 	CTestActive* active = new(ELeave)CTestActive();
  3193 	CleanupStack::PushL(active);
  3194 
  3195 	CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
  3196 	changeObs->SetActive();
  3197 
  3198 	CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
  3199 	CleanupStack::PushL(view);
  3200 
  3201 	// Incoming
  3202 	TBuf<KLogMaxDirectionLength> buf;
  3203 	aClient.GetString(buf, R_LOG_DIR_IN);
  3204 
  3205 	event->SetEventType(KLogPacketDataEventTypeUid);
  3206 	event->SetDirection(buf);
  3207 	event->SetContact(KTestContact);
  3208 
  3209 	TInt i;
  3210 	TInt count;
  3211 	for(count = 0; count < KTestEventNum; count++)
  3212 		{
  3213 		active->StartL();
  3214 		aClient.AddEvent(*event, active->iStatus);
  3215 		CActiveScheduler::Start();
  3216 		TEST2(active->iStatus.Int(), KErrNone);
  3217 		User::After(1 * 1000000);
  3218 		}
  3219 	//
  3220 	TEST2(view->CountL(), 0);
  3221 	active->StartL();
  3222 	TEST(view->SetFilterL(*filter, active->iStatus));
  3223 	CActiveScheduler::Start();
  3224 	TEST2(active->iStatus.Int(), KErrNone);
  3225 	TEST2(view->CountL(), KTestEventNum);
  3226 	//
  3227 	count = KTestEventNum;
  3228 	TEST(view->FirstL(active->iStatus));
  3229 	do	{
  3230 		active->StartL();
  3231 		CActiveScheduler::Start();
  3232 		TEST2(active->iStatus.Int(), KErrNone);
  3233 		//
  3234 		TEST2(view->CountL(), KTestEventNum);
  3235 		const TLogId eventId = view->Event().Id();
  3236 		TEST2(eventId, (TLogId)--count);
  3237 		}
  3238 	while(view->NextL(active->iStatus));
  3239 
  3240 	// Transients
  3241 	TInt changeCount;
  3242 	TLogId logId;
  3243 	TInt viewIndex;
  3244 	TLogDatabaseChangeType type;
  3245 	CLogChangeDefinition* changes;
  3246 	
  3247 	// Add an event and check for changes
  3248 	active->StartL();
  3249 	aClient.AddEvent(*event, active->iStatus);
  3250 	changes = changeObs->WaitForChangesLC();
  3251 	if	(active->IsActive())
  3252 		CActiveScheduler::Start();
  3253 	TEST2(active->iStatus.Int(), KErrNone);
  3254 	count = view->CountL();
  3255 	TEST2(count, KTestEventNum+1);
  3256 
  3257 	changeCount = changes->Count();
  3258 	for(i=0; i<changeCount; i++)
  3259 		{
  3260 		type = changes->At(i, logId, viewIndex);
  3261 		TheTest.Printf(_L("Change Type: %d, logId: %d, viewIndex: %d"), type, logId, viewIndex);
  3262 		}
  3263 	
  3264 	// Check the change was as expected
  3265 	TEST2(changes->Count(), 1);
  3266 	type = changes->At(0, logId, viewIndex);
  3267 	TEST2(type, ELogChangeTypeEventAdded);
  3268 	TEST2(viewIndex, 0); // first (newest) event in the view
  3269 	{
  3270 	const TLogId expectedLogId = ((TLogId) KTestEventNum);
  3271 	TEST2(logId, expectedLogId);
  3272 	}
  3273 	CleanupStack::PopAndDestroy(changes);
  3274 
  3275 	// Check view navigation
  3276 	i=0;
  3277 	TEST(view->FirstL(active->iStatus));
  3278 	do
  3279 		{
  3280 		active->StartL();
  3281 		CActiveScheduler::Start();
  3282 		TEST2(active->iStatus.Int(), KErrNone);
  3283 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  3284 		}
  3285 	while(view->NextL(active->iStatus));
  3286 	TheTest.Printf(_L("==\n"));
  3287 	TEST2(i, count);
  3288 	TEST(view->FirstL(active->iStatus));
  3289 	active->StartL();
  3290 	CActiveScheduler::Start();
  3291 	TEST2(active->iStatus.Int(), KErrNone);
  3292 
  3293 	// Check that changes work after a backup
  3294 	DelayL(1000000);
  3295 	StartBackupL();
  3296 	DelayL(1000000);
  3297 	TestLogClosedL();
  3298 	EndBackupL();
  3299 	TestLogOpenL();
  3300 
  3301 	// Delete some events
  3302 	TEST(KTestEventNum >= 10);
  3303 	changeObs->StartCollectingChanges();
  3304 	for(i=1; i<KTestEventNum; i+=2)
  3305 		{
  3306 		active->StartL();
  3307 		aClient.DeleteEvent(TLogId(i), active->iStatus);
  3308 		CActiveScheduler::Start();
  3309 		TEST2(active->iStatus.Int(), KErrNone);
  3310 		}
  3311 
  3312 	// Check changes
  3313 	changeCount = changeObs->Changes().Count();
  3314 	TEST2(changeCount, 5); // 1,3,5,7,9
  3315 	for(i=0; i<changeCount; i++)
  3316 		{
  3317 		TEST2(changeObs->Changes().At(i, logId, viewIndex), ELogChangeTypeEventDeleted);
  3318 		TEST2(logId, TLogId(2*i + 1));
  3319 		TEST2(viewIndex, 10 - ((2*i) + 1));
  3320 		}
  3321 	
  3322 	// Check that changes work after a backup
  3323 	StartBackupL();
  3324 	DelayL(1000000);
  3325 	TestLogClosedL();
  3326 	EndBackupL();
  3327 	TestLogOpenL();
  3328 
  3329 	// Add a new event that shouldn't appear in the view
  3330 	changeObs->StartCollectingChanges();
  3331 	event->SetContact(TLogContactItemId(0));
  3332 	active->StartL();
  3333 	aClient.AddEvent(*event, active->iStatus);
  3334 	CActiveScheduler::Start();
  3335 	TEST2(active->iStatus.Int(), KErrNone);
  3336 	count = view->CountL();
  3337 	TEST2(count, KTestEventNum + 1 - 5);
  3338 	TEST2(event->Id(),  KTestEventNum + 1);
  3339 
  3340 	// Check changes
  3341 	TEST(!changeObs->HaveChanges());
  3342 
  3343 	// Check view navigation
  3344 	i=0;
  3345 	TEST(view->FirstL(active->iStatus));
  3346 	do
  3347 		{
  3348 		active->StartL();
  3349 		CActiveScheduler::Start();
  3350 		TEST2(active->iStatus.Int(), KErrNone);
  3351 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  3352 		}
  3353 	while(view->NextL(active->iStatus));
  3354 	TheTest.Printf(_L("==\n"));
  3355 	TEST2(i, count);
  3356 	TEST(view->FirstL(active->iStatus));
  3357 	active->StartL();
  3358 	CActiveScheduler::Start();
  3359 	TEST2(active->iStatus.Int(), KErrNone);
  3360 
  3361 	// Check that changes work after a backup
  3362 	StartBackupL();
  3363 	DelayL(1000000);
  3364 	TestLogClosedL();
  3365 	EndBackupL();
  3366 	TestLogOpenL();
  3367 
  3368 	// Delete event which isn't in view
  3369 	changeObs->StartCollectingChanges();
  3370 	active->StartL();
  3371 	aClient.DeleteEvent(event->Id(), active->iStatus);
  3372 	CActiveScheduler::Start();
  3373 	TEST2(active->iStatus.Int(), KErrNone);
  3374 	count = view->CountL();
  3375 	TEST2(count, KTestEventNum + 1 - 5);
  3376 
  3377 	// Check changes
  3378 	TEST(!changeObs->HaveChanges());
  3379 
  3380 	// Check view navigation
  3381 	i=0;
  3382 	TEST(view->FirstL(active->iStatus));
  3383 	do
  3384 		{
  3385 		active->StartL();
  3386 		CActiveScheduler::Start();
  3387 		TEST2(active->iStatus.Int(), KErrNone);
  3388 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  3389 		}
  3390 	while(view->NextL(active->iStatus));
  3391 	TheTest.Printf(_L("==\n"));
  3392 	TEST2(i, count);
  3393 	TEST(view->FirstL(active->iStatus));
  3394 	active->StartL();
  3395 	CActiveScheduler::Start();
  3396 	TEST2(active->iStatus.Int(), KErrNone);
  3397 
  3398 	// Check that changes work after a backup
  3399 	StartBackupL();
  3400 	DelayL(1000000);
  3401 	TestLogClosedL();
  3402 	EndBackupL();
  3403 	TestLogOpenL();
  3404 
  3405 	// Add a new event again that shouldn't appear in the view
  3406 	changeObs->StartCollectingChanges();
  3407 	event->SetContact(TLogContactItemId(0));
  3408 	active->StartL();
  3409 	aClient.AddEvent(*event, active->iStatus);
  3410 	CActiveScheduler::Start();
  3411 	TEST2(active->iStatus.Int(), KErrNone);
  3412 	count = view->CountL();
  3413 	TEST2(count, KTestEventNum + 1 - 5);
  3414 	TEST2(event->Id(), KTestEventNum + 2);
  3415 
  3416 	// Check changes
  3417 	TEST(!changeObs->HaveChanges());
  3418 
  3419 	// Check view navigation
  3420 	i=0;
  3421 	TEST(view->FirstL(active->iStatus));
  3422 	do
  3423 		{
  3424 		active->StartL();
  3425 		CActiveScheduler::Start();
  3426 		TEST2(active->iStatus.Int(), KErrNone);
  3427 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  3428 		}
  3429 	while(view->NextL(active->iStatus));
  3430 	TheTest.Printf(_L("==\n"));
  3431 	TEST2(i, count);
  3432 	TEST(view->FirstL(active->iStatus));
  3433 	active->StartL();
  3434 	CActiveScheduler::Start();
  3435 	TEST2(active->iStatus.Int(), KErrNone);
  3436 
  3437 	// Check that changes work after a backup
  3438 	StartBackupL();
  3439 	DelayL(1000000);
  3440 	TestLogClosedL();
  3441 	EndBackupL();
  3442 	TestLogOpenL();
  3443 
  3444 	// Change event so that it appears in the view
  3445 	changeObs->StartCollectingChanges();
  3446 	event->SetContact(KTestContact);
  3447 	active->StartL();
  3448 	aClient.ChangeEvent(*event, active->iStatus);
  3449 	CActiveScheduler::Start();
  3450 	TEST2(active->iStatus.Int(), KErrNone);
  3451 	count = view->CountL();
  3452 	TEST2(count, KTestEventNum + 2 - 5);
  3453 	TEST2(event->Id(), KTestEventNum + 2); // Shouldn't change
  3454 
  3455 	// Check changes
  3456 	changeCount = changeObs->Changes().Count();
  3457 	TEST2(changeCount, 1);
  3458 	type = changeObs->Changes().At(0, logId, viewIndex);
  3459 	TEST2(type, ELogChangeTypeEventAdded);
  3460 	TEST2(logId, KTestEventNum + 2);
  3461 	TEST2(viewIndex, 0);
  3462 
  3463 	// Check view navigation
  3464 	i=0;
  3465 	TEST(view->FirstL(active->iStatus));
  3466 	do
  3467 		{
  3468 		active->StartL();
  3469 		CActiveScheduler::Start();
  3470 		TEST2(active->iStatus.Int(), KErrNone);
  3471 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  3472 		}
  3473 	while(view->NextL(active->iStatus));
  3474 	TheTest.Printf(_L("==\n"));
  3475 	TEST2(i, count);
  3476 	TEST(view->FirstL(active->iStatus));
  3477 	active->StartL();
  3478 	CActiveScheduler::Start();
  3479 	TEST2(active->iStatus.Int(), KErrNone);
  3480 
  3481 	// Check that changes work after a backup
  3482 	StartBackupL();
  3483 	DelayL(1000000);
  3484 	TestLogClosedL();
  3485 	EndBackupL();
  3486 	TestLogOpenL();
  3487 
  3488 	// Simply change an event in the view
  3489 	changeObs->StartCollectingChanges();
  3490 	event->SetDescription(_L("Test"));
  3491 	active->StartL();
  3492 	aClient.ChangeEvent(*event, active->iStatus);
  3493 	CActiveScheduler::Start();
  3494 	TEST2(active->iStatus.Int(), KErrNone);
  3495 	count = view->CountL();
  3496 	TEST2(count, KTestEventNum + 2 - 5); // Shouldn't change
  3497 	TEST2(event->Id(), KTestEventNum + 2); // Shouldn't change
  3498 
  3499 	// Check changes
  3500 	changeCount = changeObs->Changes().Count();
  3501 	TEST2(changeCount, 1);
  3502 	type = changeObs->Changes().At(0, logId, viewIndex);
  3503 	TEST2(type, ELogChangeTypeEventChanged);
  3504 	TEST2(logId, KTestEventNum + 2);
  3505 	TEST2(viewIndex, 0);
  3506 
  3507 	// Check that changes work after a backup
  3508 	StartBackupL();
  3509 	DelayL(1000000);
  3510 	TestLogClosedL();
  3511 	EndBackupL();
  3512 	TestLogOpenL();
  3513 
  3514 	// Change an event in the view so that it is deleted
  3515 	changeObs->StartCollectingChanges();
  3516 	event->SetContact(0);
  3517 	active->StartL();
  3518 	aClient.ChangeEvent(*event, active->iStatus);
  3519 	CActiveScheduler::Start();
  3520 	TEST2(active->iStatus.Int(), KErrNone);
  3521 	count = view->CountL();
  3522 	TEST2(count, KTestEventNum + 2 - 5 - 1); // one less now
  3523 
  3524 	// Check changes
  3525 	changeCount = changeObs->Changes().Count();
  3526 	TEST2(changeCount, 1);
  3527 	type = changeObs->Changes().At(0, logId, viewIndex);
  3528 	TEST2(type, ELogChangeTypeEventDeleted);
  3529 	TEST2(logId, KTestEventNum + 2);
  3530 	TEST2(viewIndex, 0);
  3531 
  3532 	// Navigate part way through the view so we have
  3533 	// a cursor position part way through...
  3534 	i=0;
  3535 	count = view->CountL();
  3536 	TEST(view->FirstL(active->iStatus));
  3537 	do
  3538 		{
  3539 		active->StartL();
  3540 		CActiveScheduler::Start();
  3541 		TEST2(active->iStatus.Int(), KErrNone);
  3542 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  3543 		}
  3544 	while(view->NextL(active->iStatus));
  3545 	TheTest.Printf(_L("==\n"));
  3546 	TEST2(i, count);
  3547 	TEST2(view->Event().Id(), TLogId(0));
  3548 
  3549 	// Save id
  3550 	TLogId savedId = view->Event().Id();
  3551 
  3552 	// Go one back
  3553 	TEST(view->PreviousL(active->iStatus));
  3554 	active->StartL();
  3555 	CActiveScheduler::Start();
  3556 	TEST2(active->iStatus.Int(), KErrNone);
  3557 
  3558 	// Check that changes work after a backup
  3559 	StartBackupL();
  3560 	DelayL(1000000);
  3561 	TestLogClosedL();
  3562 	EndBackupL();
  3563 	TestLogOpenL();
  3564 
  3565 	// Insert something
  3566 	changeObs->StartCollectingChanges();
  3567 	event->SetContact(KTestContact);
  3568 	active->StartL();
  3569 	aClient.AddEvent(*event, active->iStatus);
  3570 	CActiveScheduler::Start();
  3571 	TEST2(active->iStatus.Int(), KErrNone);
  3572 	count = view->CountL();
  3573 	TEST2(count, KTestEventNum + 2 - 5); // one more now
  3574 	TEST2(event->Id(), KTestEventNum + 3);
  3575 
  3576 	// Check changes
  3577 	changeCount = changeObs->Changes().Count();
  3578 	TEST2(changeCount, 1);
  3579 	type = changeObs->Changes().At(0, logId, viewIndex);
  3580 	TEST2(type, ELogChangeTypeEventAdded);
  3581 	TEST2(logId, KTestEventNum + 3);
  3582 	TEST2(viewIndex, 0);
  3583 
  3584 	// Check we can still go forward to the last record
  3585 	TEST(view->NextL(active->iStatus));
  3586 	active->StartL();
  3587 	CActiveScheduler::Start();
  3588 	TEST2(active->iStatus.Int(), KErrNone);
  3589 	TEST2(view->Event().Id(), savedId);
  3590 
  3591 	// Go one back
  3592 	TEST(view->PreviousL(active->iStatus));
  3593 	active->StartL();
  3594 	CActiveScheduler::Start();
  3595 	TEST2(active->iStatus.Int(), KErrNone);
  3596 
  3597 	// Check that changes work after a backup
  3598 	StartBackupL();
  3599 	DelayL(1000000);
  3600 	TestLogClosedL();
  3601 	EndBackupL();
  3602 	TestLogOpenL();
  3603 
  3604 	// Delete current record
  3605 	savedId = view->Event().Id();
  3606 	changeObs->StartCollectingChanges();
  3607 	active->StartL();
  3608 	aClient.DeleteEvent(savedId, active->iStatus);
  3609 	CActiveScheduler::Start();
  3610 	TEST2(active->iStatus.Int(), KErrNone);
  3611 	count = view->CountL();
  3612 	TEST2(count, KTestEventNum + 2 - 5 - 1); // one less
  3613 
  3614 	// Check changes
  3615 	changeCount = changeObs->Changes().Count();
  3616 	TEST2(changeCount, 1);
  3617 	type = changeObs->Changes().At(0, logId, viewIndex);
  3618 	TEST2(type, ELogChangeTypeEventDeleted);
  3619 	TEST2(logId, savedId);
  3620 	TEST2(viewIndex, KTestEventNum + 2 - 5 - 2); // last but one event
  3621 
  3622 	// Check we're now at the end of the view
  3623 	TEST(!view->NextL(active->iStatus));
  3624 
  3625 	// Go to the first record
  3626 	TEST(view->FirstL(active->iStatus));
  3627 	active->StartL();
  3628 	CActiveScheduler::Start();
  3629 	TEST2(active->iStatus.Int(), KErrNone);
  3630 
  3631 	// Check that changes work after a backup
  3632 	StartBackupL();
  3633 	DelayL(1000000);
  3634 	TestLogClosedL();
  3635 	EndBackupL();
  3636 	TestLogOpenL();
  3637 
  3638 	// Delete the first record
  3639 	savedId = view->Event().Id();
  3640 	changeObs->StartCollectingChanges();
  3641 	active->StartL();
  3642 	aClient.DeleteEvent(savedId, active->iStatus);
  3643 	CActiveScheduler::Start();
  3644 	TEST2(active->iStatus.Int(), KErrNone);
  3645 	count = view->CountL();
  3646 	TEST2(count, KTestEventNum - 5);
  3647 
  3648 	// Check changes
  3649 	changeCount = changeObs->Changes().Count();
  3650 	TEST2(changeCount, 1);
  3651 	type = changeObs->Changes().At(0, logId, viewIndex);
  3652 	TEST2(type, ELogChangeTypeEventDeleted);
  3653 	TEST2(logId, savedId);
  3654 	TEST2(viewIndex, 0); // first item
  3655 
  3656 	// Check 'next' navigation can be performed correctly
  3657 	count = 0;
  3658 	view->NextL(active->iStatus);
  3659 	do
  3660 		{
  3661 		active->StartL();
  3662 		CActiveScheduler::Start();
  3663 		TEST2(active->iStatus.Int(), KErrNone);
  3664 		++count;
  3665 		}
  3666 	while(view->NextL(active->iStatus));
  3667 	TEST2(count, KTestEventNum - 5 - 1);
  3668 
  3669 	// Check last record
  3670 	savedId = view->Event().Id();
  3671 	TEST(view->LastL(active->iStatus));
  3672 	active->StartL();
  3673 	CActiveScheduler::Start();
  3674 	TEST2(active->iStatus.Int(), KErrNone);
  3675 	TEST2(savedId, view->Event().Id());
  3676 
  3677 	// Check that changes work after a backup
  3678 	StartBackupL();
  3679 	DelayL(1000000);
  3680 	TestLogClosedL();
  3681 	EndBackupL();
  3682 	TestLogOpenL();
  3683 
  3684 	// Delete the last record
  3685 	savedId = view->Event().Id();
  3686 	changeObs->StartCollectingChanges();
  3687 	active->StartL();
  3688 	aClient.DeleteEvent(savedId, active->iStatus);
  3689 	CActiveScheduler::Start();
  3690 	TEST2(active->iStatus.Int(), KErrNone);
  3691 	count = view->CountL();
  3692 	TEST2(count, KTestEventNum - 6);
  3693 
  3694 	// Check changes
  3695 	changeCount = changeObs->Changes().Count();
  3696 	TEST2(changeCount, 1);
  3697 	type = changeObs->Changes().At(0, logId, viewIndex);
  3698 	TEST2(type, ELogChangeTypeEventDeleted);
  3699 	TEST2(logId, savedId);
  3700 	TEST2(viewIndex, count); // There's now one less item, and we deleted the last item of the previous view
  3701 
  3702 	// Check we're still at the end of the view
  3703 	TEST(!view->NextL(active->iStatus));
  3704 
  3705 	CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event
  3706 	}
  3707 
  3708 /**
  3709 @SYMTestCaseID          SYSLIB-LOGENG-CT-0870
  3710 @SYMTestCaseDesc	    Tests for CLogViewChangeObserver::HaveChanges(),Changes() functions
  3711 @SYMTestPriority 	    High
  3712 @SYMTestActions  	    Check for observing changes while adding,deleting events.Check for observing changes after a backup.
  3713                         Check for observing changes while traversing through the events in the view.
  3714 						Delete everything in the view and make sure we can't navigate anymore.
  3715 @SYMTestExpectedResults Test must not fail
  3716 @SYMREQ                 REQ0000
  3717 */
  3718 LOCAL_C void TestViewChangeEvents2L(CLogClient& aClient)
  3719 	{
  3720 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0870 "));
  3721 	// Transients
  3722 	TInt i=0;
  3723 	TInt count;
  3724 	TBuf<1> description; description.SetLength(1);
  3725 	TInt changeCount;
  3726 	TLogId logId;
  3727 	TInt viewIndex;
  3728 	TLogDatabaseChangeType type;
  3729 	TLogId runningNewId = 0;
  3730 	//
  3731 	const TInt KChangeEventTest2NumberOfEventsInView = 7;
  3732 	TestUtils::DeleteDatabaseL();
  3733 
  3734 	CLogEvent* event = CLogEvent::NewL();
  3735 	CleanupStack::PushL(event);
  3736 
  3737 	CLogFilter* filter = CLogFilter::NewL();
  3738 	CleanupStack::PushL(filter);
  3739 	filter->SetContact(KTestContact);
  3740 
  3741 	CTestActive* active = new(ELeave)CTestActive();
  3742 	CleanupStack::PushL(active);
  3743 
  3744 	CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
  3745 	changeObs->SetActive();
  3746 
  3747 	CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
  3748 	CleanupStack::PushL(view);
  3749 
  3750 	// Add seed events
  3751 	TBuf<KLogMaxDirectionLength> buf;
  3752 	aClient.GetString(buf, R_LOG_DIR_IN);
  3753 
  3754 	event->SetEventType(KLogPacketDataEventTypeUid);
  3755 	event->SetDirection(buf);
  3756 	//
  3757 	for(count = 0; count < KChangeEventTest2NumberOfEventsInView; count++)
  3758 		{
  3759 		// Have to create one event which isn't in the view by default, but
  3760 		// when it 'appears' will be part way through
  3761 		if	(count == 3 && description[0] != TUint16('Z'))
  3762 			{
  3763 			description[0] = TUint16('Z');
  3764 			event->SetContact(0);
  3765 
  3766 			// Go back and do this one again but with a real view entry this time, i.e. 'D'
  3767 			--count;
  3768 			}
  3769 		else
  3770 			{
  3771 			description[0] = TUint16('A' + KChangeEventTest2NumberOfEventsInView - count);
  3772 			event->SetContact(KTestContact);
  3773 			}
  3774 		event->SetDescription(description);
  3775 		//
  3776 		active->StartL();
  3777 		aClient.AddEvent(*event, active->iStatus);
  3778 		CActiveScheduler::Start();
  3779 		TEST2(active->iStatus.Int(), KErrNone);
  3780 		TEST2(event->Id(), runningNewId++);
  3781 	User::After(1 * 1000000);
  3782 		}
  3783 	//
  3784 	TEST2(view->CountL(), 0);
  3785 	active->StartL();
  3786 	TBool res =view->SetFilterL(*filter, active->iStatus);
  3787 	TEST(res);
  3788 	CActiveScheduler::Start();
  3789 	TEST2(active->iStatus.Int(), KErrNone);
  3790 	count = view->CountL();
  3791 	TEST2(count, KChangeEventTest2NumberOfEventsInView);
  3792 
  3793 	res = view->FirstL(active->iStatus);
  3794 	TEST(res);
  3795 	do
  3796 		{
  3797 		active->StartL();
  3798 		CActiveScheduler::Start();
  3799 		TEST2(active->iStatus.Int(), KErrNone);
  3800 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  3801 		}
  3802 	while(view->NextL(active->iStatus));
  3803 	
  3804 	// Check addition change events
  3805 	res = view->FirstL(active->iStatus);
  3806 	TEST(res);
  3807 	active->StartL();
  3808 	CActiveScheduler::Start();
  3809 	TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
  3810 	TEST2(view->Event().Id(), 7);
  3811 
  3812 	// Add a new entry - should appear as the first item in the view
  3813 	description[0] = TUint16('X');
  3814 	event->SetDescription(description);
  3815 	//
  3816 	changeObs->StartCollectingChanges();
  3817 	active->StartL();
  3818 	aClient.AddEvent(*event, active->iStatus);
  3819 	CActiveScheduler::Start();
  3820 	TEST2(active->iStatus.Int(), KErrNone);
  3821 	TEST2(event->Id(), runningNewId++);
  3822 
  3823 	// Check changes
  3824 	changeCount = changeObs->Changes().Count();
  3825 	TEST2(changeCount, 1);
  3826 	type = changeObs->Changes().At(0, logId, viewIndex);
  3827 	TEST2(type, ELogChangeTypeEventAdded);
  3828 	TEST2(logId, runningNewId-1);
  3829 	TEST2(viewIndex, 0); // 8, [7], 6, 5, 4, 2, 1, 0
  3830 
  3831 	// Check we can go forward
  3832 	res = view->NextL(active->iStatus);
  3833 	TEST(res);
  3834 	active->StartL();
  3835 	CActiveScheduler::Start();
  3836 	TEST2(active->iStatus.Int(), KErrNone);
  3837 	TEST2(view->Event().Id(), TLogId(6)); // 8, 7, [6], 5, 4, 2, 1, 0
  3838 
  3839 	// Check we can now go back (new first entry)
  3840 	res = view->PreviousL(active->iStatus);
  3841 	TEST(res);
  3842 	active->StartL();
  3843 	CActiveScheduler::Start();
  3844 	TEST2(active->iStatus.Int(), KErrNone); // 8, [7], 6, 5, 4, 2, 1, 0
  3845 	TEST2(view->Event().Id(), 7);
  3846 	res = view->PreviousL(active->iStatus);
  3847 	TEST(res);
  3848 	active->StartL();
  3849 	CActiveScheduler::Start();
  3850 	TEST2(active->iStatus.Int(), KErrNone); // [8], 7, 6, 5, 4, 2, 1, 0
  3851 	TEST2(view->Event().Id(), TLogId(KChangeEventTest2NumberOfEventsInView+1));
  3852 
  3853 	// Delete added event
  3854 	changeObs->ResetChanges();
  3855 	changeCount = changeObs->Changes().Count();
  3856 	TEST2(changeCount, 0);
  3857 	active->StartL();
  3858 	aClient.DeleteEvent(view->Event().Id(), active->iStatus);
  3859 	CActiveScheduler::Start();
  3860 	TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
  3861 
  3862 	// Check deletion changes
  3863 	changeCount = changeObs->Changes().Count();
  3864 	TEST2(changeCount, 1);
  3865 	type = changeObs->Changes().At(0, logId, viewIndex);
  3866 	TEST2(type, ELogChangeTypeEventDeleted);
  3867 	TEST2(logId, runningNewId-1);
  3868 	TEST2(viewIndex, 0);
  3869 
  3870 	// Go to end of view
  3871 	res = view->LastL(active->iStatus);
  3872 	TEST(res);
  3873 	active->StartL();
  3874 	CActiveScheduler::Start();
  3875 	TEST2(active->iStatus.Int(), KErrNone);
  3876 	TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0]
  3877 
  3878 	// Add new event
  3879 	description[0] = TUint16('X');
  3880 	event->SetDescription(description);
  3881 	//
  3882 	changeObs->StartCollectingChanges();
  3883 	active->StartL();
  3884 	aClient.AddEvent(*event, active->iStatus);
  3885 	CActiveScheduler::Start();
  3886 	TEST2(active->iStatus.Int(), KErrNone);
  3887 	TEST2(event->Id(), runningNewId++);
  3888 
  3889 	// Check changes
  3890 	changeCount = changeObs->Changes().Count();
  3891 	TEST2(changeCount, 1);
  3892 	type = changeObs->Changes().At(0, logId, viewIndex);
  3893 	TEST2(type, ELogChangeTypeEventAdded);
  3894 	TEST2(logId, runningNewId-1);
  3895 	TEST2(viewIndex, 0); // 9, 7, 6, 5, 4, 2, 1, [0]
  3896 
  3897 	// Check we can't go forward
  3898 	res = view->NextL(active->iStatus);
  3899 	TEST(!res);
  3900 
  3901 	// Go back to the first record
  3902 	res = view->FirstL(active->iStatus);
  3903 	TEST(res);
  3904 	active->StartL();
  3905 	CActiveScheduler::Start();
  3906 	TEST2(active->iStatus.Int(), KErrNone);
  3907 	TEST2(view->Event().Id(), TLogId(runningNewId-1)); // 9, 7, 6, 5, 4, 2, 1, [0]
  3908 
  3909 	// Delete added event
  3910 	changeObs->ResetChanges();
  3911 	active->StartL();
  3912 	aClient.DeleteEvent(view->Event().Id(), active->iStatus);
  3913 	CActiveScheduler::Start();
  3914 	TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
  3915 
  3916 	// Check deletion changes
  3917 	changeCount = changeObs->Changes().Count();
  3918 	TEST2(changeCount, 1);
  3919 	type = changeObs->Changes().At(0, logId, viewIndex);
  3920 	TEST2(type, ELogChangeTypeEventDeleted);
  3921 	TEST2(logId, runningNewId-1);
  3922 	TEST2(viewIndex, 0);
  3923 
  3924 	// Go part way through view
  3925 	res = view->NextL(active->iStatus);
  3926 	TEST(res);
  3927 	active->StartL();
  3928 	CActiveScheduler::Start();
  3929 	TEST2(active->iStatus.Int(), KErrNone);
  3930 	TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0
  3931 	res = view->NextL(active->iStatus);
  3932 	TEST(res);
  3933 	active->StartL();
  3934 	CActiveScheduler::Start();
  3935 	TEST2(active->iStatus.Int(), KErrNone);
  3936 	TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 2, 1, 0
  3937 
  3938 	// Add new event
  3939 	description[0] = TUint16('X');
  3940 	event->SetDescription(description);
  3941 	//
  3942 	changeObs->StartCollectingChanges();
  3943 	active->StartL();
  3944 	aClient.AddEvent(*event, active->iStatus);
  3945 	CActiveScheduler::Start();
  3946 	TEST2(active->iStatus.Int(), KErrNone);
  3947 	TEST2(event->Id(), runningNewId++);
  3948 
  3949 	// Check changes
  3950 	changeCount = changeObs->Changes().Count();
  3951 	TEST2(changeCount, 1);
  3952 	type = changeObs->Changes().At(0, logId, viewIndex);
  3953 	TEST2(type, ELogChangeTypeEventAdded);
  3954 	TEST2(logId, runningNewId-1);
  3955 	TEST2(viewIndex, 0); // 10, 7, 6, [5], 4, 2, 1, 0
  3956 	changeObs->ResetChanges();
  3957 
  3958 	// Work back to beginning
  3959 	res = view->PreviousL(active->iStatus);
  3960 	TEST(res);
  3961 	active->StartL();
  3962 	CActiveScheduler::Start();
  3963 	TEST2(active->iStatus.Int(), KErrNone);
  3964 	TEST2(view->Event().Id(), TLogId(6)); // 10, 7, [6], 5, 4, 2, 1, 0
  3965 	res = view->PreviousL(active->iStatus);
  3966 	TEST(res);
  3967 	active->StartL();
  3968 	CActiveScheduler::Start();
  3969 	TEST2(active->iStatus.Int(), KErrNone);
  3970 	TEST2(view->Event().Id(), TLogId(7)); // 10, [7], 6, 5, 4, 2, 1, 0
  3971 	res = view->PreviousL(active->iStatus);
  3972 	TEST(res);
  3973 	active->StartL();
  3974 	CActiveScheduler::Start();
  3975 	TEST2(active->iStatus.Int(), KErrNone);
  3976 	TEST2(view->Event().Id(), runningNewId-1); // [10], 7, 6, 5, 4, 2, 1, 0
  3977 
  3978 	// Delete added event
  3979 	changeCount = changeObs->Changes().Count();
  3980 	TEST2(changeCount, 0);
  3981 	active->StartL();
  3982 	aClient.DeleteEvent(view->Event().Id(), active->iStatus);
  3983 	CActiveScheduler::Start();
  3984 	TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
  3985 
  3986 	// Check deletion changes
  3987 	changeCount = changeObs->Changes().Count();
  3988 	TEST2(changeCount, 1);
  3989 	type = changeObs->Changes().At(0, logId, viewIndex);
  3990 	TEST2(type, ELogChangeTypeEventDeleted);
  3991 	TEST2(logId, runningNewId-1);
  3992 	TEST2(viewIndex, 0);
  3993 	changeObs->ResetChanges();
  3994 
  3995 	// Go back to the first record
  3996 	res = view->FirstL(active->iStatus);
  3997 	TEST(res);
  3998 	active->StartL();
  3999 	CActiveScheduler::Start();
  4000 	TEST2(active->iStatus.Int(), KErrNone);
  4001 	TEST2(view->Event().Id(), TLogId(7)); // [7], 6, 5, 4, 2, 1, 0
  4002 
  4003 	// Move one record forward
  4004 	res = view->NextL(active->iStatus);
  4005 	TEST(res);
  4006 	active->StartL();
  4007 	CActiveScheduler::Start();
  4008 	TEST2(active->iStatus.Int(), KErrNone);
  4009 	TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0
  4010 
  4011 	// Change 'Z' event so that it now appears in the view
  4012 	changeCount = changeObs->Changes().Count();
  4013 	TEST2(changeCount, 0);
  4014 	active->StartL();
  4015 	event->SetId(TLogId(3));
  4016 	aClient.GetEvent(*event, active->iStatus);
  4017 	CActiveScheduler::Start();
  4018 	TEST2(active->iStatus.Int(), KErrNone);
  4019 	//
  4020 	event->SetContact(KTestContact);
  4021 	active->StartL();
  4022 	changeObs->StartCollectingChanges();
  4023 	aClient.ChangeEvent(*event, active->iStatus);
  4024 	CActiveScheduler::Start();
  4025 	TEST2(active->iStatus.Int(), KErrNone);
  4026 	count = view->CountL();
  4027 	TEST2(count, KChangeEventTest2NumberOfEventsInView+1);
  4028 
  4029 	// Check changes
  4030 	changeCount = changeObs->Changes().Count();
  4031 	TEST2(changeCount, 1);
  4032 	type = changeObs->Changes().At(0, logId, viewIndex);
  4033 	TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view
  4034 	TEST2(logId, TLogId(3));
  4035 	TEST2(viewIndex, 4); // 7, [6], 5, 4, 3, 2, 1, 0
  4036 	changeObs->ResetChanges();
  4037 
  4038 	// Move forwards and check
  4039 	res = view->NextL(active->iStatus);
  4040 	TEST(res);
  4041 	active->StartL();
  4042 	CActiveScheduler::Start();
  4043 	TEST2(active->iStatus.Int(), KErrNone);
  4044 	TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 3, 2, 1, 0
  4045 	res = view->NextL(active->iStatus);
  4046 	TEST(res);
  4047 	active->StartL();
  4048 	CActiveScheduler::Start();
  4049 	TEST2(active->iStatus.Int(), KErrNone);
  4050 	TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0
  4051 	res = view->NextL(active->iStatus);
  4052 	TEST(res);
  4053 	active->StartL();
  4054 	CActiveScheduler::Start();
  4055 	TEST2(active->iStatus.Int(), KErrNone);
  4056 	TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0
  4057 
  4058 	// Change 'Z' event so that its now missing from the view again
  4059 	changeCount = changeObs->Changes().Count();
  4060 	TEST2(changeCount, 0);
  4061 	active->StartL();
  4062 	event->SetId(TLogId(3));
  4063 	aClient.GetEvent(*event, active->iStatus);
  4064 	CActiveScheduler::Start();
  4065 	TEST2(active->iStatus.Int(), KErrNone);
  4066 	//
  4067 	event->SetContact(0);
  4068 	active->StartL();
  4069 	changeObs->StartCollectingChanges();
  4070 	aClient.ChangeEvent(*event, active->iStatus);
  4071 	CActiveScheduler::Start();
  4072 	TEST2(active->iStatus.Int(), KErrNone);
  4073 	count = view->CountL();
  4074 	TEST2(count, KChangeEventTest2NumberOfEventsInView);
  4075 
  4076 	// Check changes
  4077 	changeCount = changeObs->Changes().Count();
  4078 	TEST2(changeCount, 1);
  4079 	type = changeObs->Changes().At(0, logId, viewIndex);
  4080 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4081 	TEST2(logId, TLogId(3));
  4082 	TEST2(viewIndex, 4); // 7, 6, 5, 4, [2], 1, 0
  4083 	changeObs->ResetChanges();
  4084 
  4085 	// Move forwards and check
  4086 	res = view->NextL(active->iStatus);
  4087 	TEST(res);
  4088 	active->StartL();
  4089 	CActiveScheduler::Start();
  4090 	TEST2(active->iStatus.Int(), KErrNone);
  4091 	TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0
  4092 	res = view->NextL(active->iStatus);
  4093 	TEST(res);
  4094 	active->StartL();
  4095 	CActiveScheduler::Start();
  4096 	TEST2(active->iStatus.Int(), KErrNone);
  4097 	TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0]
  4098 
  4099 	// Move back one
  4100 	res = view->PreviousL(active->iStatus);
  4101 	TEST(res);
  4102 	active->StartL();
  4103 	CActiveScheduler::Start();
  4104 	TEST2(active->iStatus.Int(), KErrNone);
  4105 	TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0
  4106 	changeCount = changeObs->Changes().Count();
  4107 	TEST2(changeCount, 0);
  4108 
  4109 	// Change 'Z' event so that it now appears in the view
  4110 	active->StartL();
  4111 	event->SetId(TLogId(3));
  4112 	aClient.GetEvent(*event, active->iStatus);
  4113 	CActiveScheduler::Start();
  4114 	TEST2(active->iStatus.Int(), KErrNone);
  4115 	//
  4116 	event->SetContact(KTestContact);
  4117 	active->StartL();
  4118 	changeObs->StartCollectingChanges();
  4119 	aClient.ChangeEvent(*event, active->iStatus);
  4120 	CActiveScheduler::Start();
  4121 	TEST2(active->iStatus.Int(), KErrNone);
  4122 	count = view->CountL();
  4123 	TEST2(count, KChangeEventTest2NumberOfEventsInView+1);
  4124 
  4125 	// Check changes
  4126 	changeCount = changeObs->Changes().Count();
  4127 	TEST2(changeCount, 1);
  4128 	type = changeObs->Changes().At(0, logId, viewIndex);
  4129 	TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view
  4130 	TEST2(logId, TLogId(3));
  4131 	TEST2(viewIndex, 4); // 7, 6, 5, 4, 3, 2, [1], 0
  4132 	changeObs->ResetChanges();
  4133 
  4134 	// Check can only move forward one more record
  4135 	res = view->NextL(active->iStatus);
  4136 	TEST(res);
  4137 	active->StartL();
  4138 	CActiveScheduler::Start();
  4139 	TEST2(active->iStatus.Int(), KErrNone);
  4140 	TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 3, 2, 1, [0]
  4141 
  4142 	// Move back until we are before the inserted record
  4143 	res = view->PreviousL(active->iStatus);
  4144 	TEST(res);
  4145 	active->StartL();
  4146 	CActiveScheduler::Start();
  4147 	TEST2(active->iStatus.Int(), KErrNone);
  4148 	TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 3, 2, [1], 0
  4149 	res = view->PreviousL(active->iStatus);
  4150 	TEST(res);
  4151 	active->StartL();
  4152 	CActiveScheduler::Start();
  4153 	TEST2(active->iStatus.Int(), KErrNone);
  4154 	TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, 3, [2], 1, 0
  4155 	res = view->PreviousL(active->iStatus);
  4156 	TEST(res);
  4157 	active->StartL();
  4158 	CActiveScheduler::Start();
  4159 	TEST2(active->iStatus.Int(), KErrNone);
  4160 	TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0
  4161 	res = view->PreviousL(active->iStatus);
  4162 	TEST(res);
  4163 	active->StartL();
  4164 	CActiveScheduler::Start();
  4165 	TEST2(active->iStatus.Int(), KErrNone);
  4166 	TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0
  4167 	changeCount = changeObs->Changes().Count();
  4168 	TEST2(changeCount, 0);
  4169 
  4170 	// Change 'Z' event so that its now missing from the view again
  4171 	active->StartL();
  4172 	event->SetId(TLogId(3));
  4173 	aClient.GetEvent(*event, active->iStatus);
  4174 	CActiveScheduler::Start();
  4175 	TEST2(active->iStatus.Int(), KErrNone);
  4176 	//
  4177 	event->SetContact(0);
  4178 	active->StartL();
  4179 	changeObs->StartCollectingChanges();
  4180 	aClient.ChangeEvent(*event, active->iStatus);
  4181 	CActiveScheduler::Start();
  4182 	TEST2(active->iStatus.Int(), KErrNone);
  4183 	count = view->CountL();
  4184 	TEST2(count, KChangeEventTest2NumberOfEventsInView);
  4185 
  4186 	// Check changes
  4187 	changeCount = changeObs->Changes().Count();
  4188 	TEST2(changeCount, 1);
  4189 	type = changeObs->Changes().At(0, logId, viewIndex);
  4190 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4191 	TEST2(logId, TLogId(3));
  4192 	TEST2(viewIndex, 4); // 7, 6, 5, [4], 2, 1, 0
  4193 	changeObs->ResetChanges();
  4194 
  4195 	// Check navigating to the end of the view
  4196 	res = view->NextL(active->iStatus);
  4197 	TEST(res);
  4198 	active->StartL();
  4199 	CActiveScheduler::Start();
  4200 	TEST2(active->iStatus.Int(), KErrNone);
  4201 	TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, [2], 1, 0
  4202 	res = view->NextL(active->iStatus);
  4203 	TEST(res);
  4204 	active->StartL();
  4205 	CActiveScheduler::Start();
  4206 	TEST2(active->iStatus.Int(), KErrNone);
  4207 	TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0
  4208 	res = view->NextL(active->iStatus);
  4209 	TEST(res);
  4210 	active->StartL();
  4211 	CActiveScheduler::Start();
  4212 	TEST2(active->iStatus.Int(), KErrNone);
  4213 	TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0]
  4214 	changeCount = changeObs->Changes().Count();
  4215 	TEST2(changeCount, 0);
  4216 	res = view->NextL(active->iStatus);
  4217 	TEST(!res);
  4218 
  4219 	// Delete everything in the view and make sure we can't navigate anymore.
  4220 	active->StartL();
  4221 	aClient.DeleteEvent(TLogId(4), active->iStatus);
  4222 	CActiveScheduler::Start();
  4223 	TEST2(active->iStatus.Int(), KErrNone);
  4224 	count = view->CountL();
  4225 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 1);
  4226 	changeCount = changeObs->Changes().Count();
  4227 	TEST2(changeCount, 1);
  4228 	type = changeObs->Changes().At(0, logId, viewIndex);
  4229 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4230 	TEST2(logId, TLogId(4));
  4231 	TEST2(viewIndex, 3); // 7, 6, 5, 2, 1, [0]
  4232 	changeObs->ResetChanges();
  4233 	//
  4234 	active->StartL();
  4235 	aClient.DeleteEvent(TLogId(7), active->iStatus);
  4236 	CActiveScheduler::Start();
  4237 	TEST2(active->iStatus.Int(), KErrNone);
  4238 	count = view->CountL();
  4239 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 2);
  4240 	changeCount = changeObs->Changes().Count();
  4241 	TEST2(changeCount, 1);
  4242 	type = changeObs->Changes().At(0, logId, viewIndex);
  4243 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4244 	TEST2(logId, TLogId(7));
  4245 	TEST2(viewIndex, 0); // 6, 5, 2, 1, [0]
  4246 	changeObs->ResetChanges();
  4247 	//
  4248 	active->StartL();
  4249 	aClient.DeleteEvent(TLogId(0), active->iStatus);
  4250 	CActiveScheduler::Start();
  4251 	TEST2(active->iStatus.Int(), KErrNone);
  4252 	count = view->CountL();
  4253 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 3);
  4254 	changeCount = changeObs->Changes().Count();
  4255 	TEST2(changeCount, 1);
  4256 	type = changeObs->Changes().At(0, logId, viewIndex);
  4257 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4258 	TEST2(logId, TLogId(0));
  4259 	TEST2(viewIndex, 4); // 6, 5, 2, [1]
  4260 	changeObs->ResetChanges();
  4261 	//
  4262 	active->StartL();
  4263 	aClient.DeleteEvent(TLogId(5), active->iStatus);
  4264 	CActiveScheduler::Start();
  4265 	TEST2(active->iStatus.Int(), KErrNone);
  4266 	count = view->CountL();
  4267 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 4);
  4268 	changeCount = changeObs->Changes().Count();
  4269 	TEST2(changeCount, 1);
  4270 	type = changeObs->Changes().At(0, logId, viewIndex);
  4271 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4272 	TEST2(logId, TLogId(5));
  4273 	TEST2(viewIndex, 1); // 6, 2, [1]
  4274 	changeObs->ResetChanges();
  4275 	//
  4276 	active->StartL();
  4277 	aClient.DeleteEvent(TLogId(2), active->iStatus);
  4278 	CActiveScheduler::Start();
  4279 	TEST2(active->iStatus.Int(), KErrNone);
  4280 	count = view->CountL();
  4281 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 5);
  4282 	changeCount = changeObs->Changes().Count();
  4283 	TEST2(changeCount, 1);
  4284 	type = changeObs->Changes().At(0, logId, viewIndex);
  4285 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4286 	TEST2(logId, TLogId(2));
  4287 	TEST2(viewIndex, 1); // 6, [1]
  4288 	changeObs->ResetChanges();
  4289 	//
  4290 	active->StartL();
  4291 	aClient.DeleteEvent(TLogId(6), active->iStatus);
  4292 	CActiveScheduler::Start();
  4293 	TEST2(active->iStatus.Int(), KErrNone);
  4294 	count = view->CountL();
  4295 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 6);
  4296 	changeCount = changeObs->Changes().Count();
  4297 	TEST2(changeCount, 1);
  4298 	type = changeObs->Changes().At(0, logId, viewIndex);
  4299 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4300 	TEST2(logId, TLogId(6));
  4301 	TEST2(viewIndex, 0); // [1]
  4302 	changeObs->ResetChanges();
  4303 
  4304 	// Check we can't go backwards or forwards
  4305 	res = view->NextL(active->iStatus);
  4306 	TEST(!res);
  4307 	res = view->PreviousL(active->iStatus);
  4308 	TEST(!res);
  4309 	res = view->FirstL(active->iStatus);
  4310 	TEST(res);
  4311 	active->StartL();
  4312 	CActiveScheduler::Start();
  4313 	TEST2(active->iStatus.Int(), KErrNone);
  4314 	TEST2(view->Event().Id(), TLogId(1)); // [1]
  4315 	res = view->LastL(active->iStatus);
  4316 	TEST(res);
  4317 	active->StartL();
  4318 	CActiveScheduler::Start();
  4319 	TEST2(active->iStatus.Int(), KErrNone);
  4320 	TEST2(view->Event().Id(), TLogId(1)); // [1]
  4321 
  4322 	// Delete last event in view
  4323 	active->StartL();
  4324 	aClient.DeleteEvent(TLogId(1), active->iStatus);
  4325 	CActiveScheduler::Start();
  4326 	TEST2(active->iStatus.Int(), KErrNone);
  4327 	count = view->CountL();
  4328 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 7);
  4329 	changeCount = changeObs->Changes().Count();
  4330 	TEST2(changeCount, 1);
  4331 	type = changeObs->Changes().At(0, logId, viewIndex);
  4332 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4333 	TEST2(logId, TLogId(1));
  4334 	TEST2(viewIndex, 0); // *Empty*
  4335 	changeObs->ResetChanges();
  4336 
  4337 	// Check we can't navigate
  4338 	res = view->NextL(active->iStatus);
  4339 	TEST(!res);
  4340 	res = view->PreviousL(active->iStatus);
  4341 	TEST(!res);
  4342 	res = view->FirstL(active->iStatus);
  4343 	TEST(!res);
  4344 	res = view->LastL(active->iStatus);
  4345 	TEST(!res);
  4346 
  4347 	CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event
  4348 	}
  4349 
  4350 /**
  4351 @SYMTestCaseID          SYSLIB-LOGENG-CT-0871
  4352 @SYMTestCaseDesc	    Tests for CLogViewChangeObserver::HaveChanges(),Changes() functions
  4353 @SYMTestPriority 	    High
  4354 @SYMTestActions  	    Check for observing changes while adding,deleting events.Check for observing changes after a backup.
  4355                         Check for observing changes while traversing through the events in the view.
  4356 						Delete everything in the view and make sure we can't navigate anymore.
  4357 @SYMTestExpectedResults Test must not fail
  4358 @SYMREQ                 REQ0000
  4359 */
  4360 LOCAL_C void TestViewChangeEvents2aL(CLogClient& aClient)
  4361 	{
  4362 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0871 "));
  4363 	// Transients
  4364 	TInt i=0;
  4365 	TInt count;
  4366 	TBuf<1> description; description.SetLength(1);
  4367 	TInt changeCount;
  4368 	TLogId logId;
  4369 	TInt viewIndex;
  4370 	TLogDatabaseChangeType type;
  4371 	TLogId runningNewId = 0;
  4372 	//
  4373 	const TInt KChangeEventTest2NumberOfEventsInView = 7;
  4374 	TestUtils::DeleteDatabaseL();
  4375 
  4376 	CLogEvent* event = CLogEvent::NewL();
  4377 	CleanupStack::PushL(event);
  4378 
  4379 	CLogFilter* filter = CLogFilter::NewL();
  4380 	CleanupStack::PushL(filter);
  4381 	filter->SetContact(KTestContact);
  4382 
  4383 	CTestActive* active = new(ELeave)CTestActive();
  4384 	CleanupStack::PushL(active);
  4385 
  4386 	CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
  4387 	changeObs->SetActive();
  4388 
  4389 	CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
  4390 	CleanupStack::PushL(view);
  4391 
  4392 	// Add seed events
  4393 	TBuf<KLogMaxDirectionLength> buf;
  4394 	aClient.GetString(buf, R_LOG_DIR_IN);
  4395 
  4396 	event->SetEventType(KLogPacketDataEventTypeUid);
  4397 	event->SetDirection(buf);
  4398 	//
  4399 	for(count = 0; count < KChangeEventTest2NumberOfEventsInView; count++)
  4400 		{
  4401 		// Have to create one event which isn't in the view by default, but
  4402 		// when it 'appears' will be part way through
  4403 		if	(count == 3 && description[0] != TUint16('Z'))
  4404 			{
  4405 			description[0] = TUint16('Z');
  4406 			event->SetContact(0);
  4407 
  4408 			// Go back and do this one again but with a real view entry this time, i.e. 'D'
  4409 			--count;
  4410 			}
  4411 		else
  4412 			{
  4413 			description[0] = TUint16('A' + KChangeEventTest2NumberOfEventsInView - count);
  4414 			event->SetContact(KTestContact);
  4415 			}
  4416 		event->SetDescription(description);
  4417 		//
  4418 		active->StartL();
  4419 		aClient.AddEvent(*event, active->iStatus);
  4420 		CActiveScheduler::Start();
  4421 		TEST2(active->iStatus.Int(), KErrNone);
  4422 		TEST2(event->Id(), runningNewId++);
  4423 	User::After(1 * 1000000);
  4424 		}
  4425 	//
  4426 	TEST2(view->CountL(), 0);
  4427 	active->StartL();
  4428 	TEST(view->SetFilterL(*filter, active->iStatus));
  4429 	CActiveScheduler::Start();
  4430 	TEST2(active->iStatus.Int(), KErrNone);
  4431 	count = view->CountL();
  4432 	TEST2(count, KChangeEventTest2NumberOfEventsInView);
  4433 
  4434 
  4435 	TEST(view->FirstL(active->iStatus));
  4436 	do
  4437 		{
  4438 		active->StartL();
  4439 		CActiveScheduler::Start();
  4440 		TEST2(active->iStatus.Int(), KErrNone);
  4441 		TheTest.Printf(_L("View Entry[%d]: Id: %d\r\n"), i++, view->Event().Id());
  4442 		}
  4443 	while(view->NextL(active->iStatus));
  4444 	
  4445 	// Check addition change events
  4446 	TEST(view->FirstL(active->iStatus));
  4447 	active->StartL();
  4448 	CActiveScheduler::Start();
  4449 	TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
  4450 	TEST2(view->Event().Id(), 7);
  4451 
  4452 	// Add a new entry - should appear as the first item in the view
  4453 	description[0] = TUint16('X');
  4454 	event->SetDescription(description);
  4455 
  4456 	// Check that changes work after a backup
  4457 	StartBackupL();
  4458 	DelayL(1000000);
  4459 	TestLogClosedL();
  4460 	EndBackupL();
  4461 	TestLogOpenL();
  4462 
  4463 	//
  4464 	changeObs->StartCollectingChanges();
  4465 	active->StartL();
  4466 	aClient.AddEvent(*event, active->iStatus);
  4467 	CActiveScheduler::Start();
  4468 	TEST2(active->iStatus.Int(), KErrNone);
  4469 	TEST2(event->Id(), runningNewId++);
  4470 
  4471 	// Check changes
  4472 	changeCount = changeObs->Changes().Count();
  4473 	TEST2(changeCount, 1);
  4474 	type = changeObs->Changes().At(0, logId, viewIndex);
  4475 	TEST2(type, ELogChangeTypeEventAdded);
  4476 	TEST2(logId, runningNewId-1);
  4477 	TEST2(viewIndex, 0); // 8, [7], 6, 5, 4, 2, 1, 0
  4478 
  4479 	// Check we can go forward
  4480 	TEST(view->NextL(active->iStatus));
  4481 	active->StartL();
  4482 	CActiveScheduler::Start();
  4483 	TEST2(active->iStatus.Int(), KErrNone);
  4484 	TEST2(view->Event().Id(), TLogId(6)); // 8, 7, [6], 5, 4, 2, 1, 0
  4485 
  4486 	// Check we can now go back (new first entry)
  4487 	TEST(view->PreviousL(active->iStatus));
  4488 	active->StartL();
  4489 	CActiveScheduler::Start();
  4490 	TEST2(active->iStatus.Int(), KErrNone); // 8, [7], 6, 5, 4, 2, 1, 0
  4491 	TEST2(view->Event().Id(), 7);
  4492 	TEST(view->PreviousL(active->iStatus));
  4493 	active->StartL();
  4494 	CActiveScheduler::Start();
  4495 	TEST2(active->iStatus.Int(), KErrNone); // [8], 7, 6, 5, 4, 2, 1, 0
  4496 	TEST2(view->Event().Id(), TLogId(KChangeEventTest2NumberOfEventsInView+1));
  4497 
  4498 	// Delete added event
  4499 	changeObs->ResetChanges();
  4500 	changeCount = changeObs->Changes().Count();
  4501 	TEST2(changeCount, 0);
  4502 	active->StartL();
  4503 	aClient.DeleteEvent(view->Event().Id(), active->iStatus);
  4504 	CActiveScheduler::Start();
  4505 	TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
  4506 
  4507 	// Check deletion changes
  4508 	changeCount = changeObs->Changes().Count();
  4509 	TEST2(changeCount, 1);
  4510 	type = changeObs->Changes().At(0, logId, viewIndex);
  4511 	TEST2(type, ELogChangeTypeEventDeleted);
  4512 	TEST2(logId, runningNewId-1);
  4513 	TEST2(viewIndex, 0);
  4514 
  4515 	// Go to end of view
  4516 	TEST(view->LastL(active->iStatus));
  4517 	active->StartL();
  4518 	CActiveScheduler::Start();
  4519 	TEST2(active->iStatus.Int(), KErrNone);
  4520 	TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0]
  4521 
  4522 	// Add new event
  4523 	description[0] = TUint16('X');
  4524 	event->SetDescription(description);
  4525 
  4526 	// Check that changes work after a backup
  4527 	StartBackupL();
  4528 	DelayL(1000000);
  4529 	TestLogClosedL();
  4530 	EndBackupL();
  4531 	TestLogOpenL();
  4532 
  4533 	//
  4534 	changeObs->StartCollectingChanges();
  4535 	active->StartL();
  4536 	aClient.AddEvent(*event, active->iStatus);
  4537 	CActiveScheduler::Start();
  4538 	TEST2(active->iStatus.Int(), KErrNone);
  4539 	TEST2(event->Id(), runningNewId++);
  4540 
  4541 	// Check changes
  4542 	changeCount = changeObs->Changes().Count();
  4543 	TEST2(changeCount, 1);
  4544 	type = changeObs->Changes().At(0, logId, viewIndex);
  4545 	TEST2(type, ELogChangeTypeEventAdded);
  4546 	TEST2(logId, runningNewId-1);
  4547 	TEST2(viewIndex, 0); // 9, 7, 6, 5, 4, 2, 1, [0]
  4548 
  4549 	// Check we can't go forward
  4550 	TEST(!view->NextL(active->iStatus));
  4551 
  4552 	// Go back to the first record
  4553 	TEST(view->FirstL(active->iStatus));
  4554 	active->StartL();
  4555 	CActiveScheduler::Start();
  4556 	TEST2(active->iStatus.Int(), KErrNone);
  4557 	TEST2(view->Event().Id(), TLogId(runningNewId-1)); // 9, 7, 6, 5, 4, 2, 1, [0]
  4558 
  4559 	// Delete added event
  4560 	changeObs->ResetChanges();
  4561 	active->StartL();
  4562 	aClient.DeleteEvent(view->Event().Id(), active->iStatus);
  4563 	CActiveScheduler::Start();
  4564 	TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
  4565 
  4566 	// Check deletion changes
  4567 	changeCount = changeObs->Changes().Count();
  4568 	TEST2(changeCount, 1);
  4569 	type = changeObs->Changes().At(0, logId, viewIndex);
  4570 	TEST2(type, ELogChangeTypeEventDeleted);
  4571 	TEST2(logId, runningNewId-1);
  4572 	TEST2(viewIndex, 0);
  4573 
  4574 	// Go part way through view
  4575 	TEST(view->NextL(active->iStatus));
  4576 	active->StartL();
  4577 	CActiveScheduler::Start();
  4578 	TEST2(active->iStatus.Int(), KErrNone);
  4579 	TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0
  4580 	TEST(view->NextL(active->iStatus));
  4581 	active->StartL();
  4582 	CActiveScheduler::Start();
  4583 	TEST2(active->iStatus.Int(), KErrNone);
  4584 	TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 2, 1, 0
  4585 
  4586 	// Add new event
  4587 	description[0] = TUint16('X');
  4588 	event->SetDescription(description);
  4589 
  4590 	// Check that changes work after a backup
  4591 	StartBackupL();
  4592 	DelayL(1000000);
  4593 	TestLogClosedL();
  4594 	EndBackupL();
  4595 	TestLogOpenL();
  4596 
  4597 	//
  4598 	changeObs->StartCollectingChanges();
  4599 	active->StartL();
  4600 	aClient.AddEvent(*event, active->iStatus);
  4601 	CActiveScheduler::Start();
  4602 	TEST2(active->iStatus.Int(), KErrNone);
  4603 	TEST2(event->Id(), runningNewId++);
  4604 
  4605 	// Check changes
  4606 	changeCount = changeObs->Changes().Count();
  4607 	TEST2(changeCount, 1);
  4608 	type = changeObs->Changes().At(0, logId, viewIndex);
  4609 	TEST2(type, ELogChangeTypeEventAdded);
  4610 	TEST2(logId, runningNewId-1);
  4611 	TEST2(viewIndex, 0); // 10, 7, 6, [5], 4, 2, 1, 0
  4612 	changeObs->ResetChanges();
  4613 
  4614 	// Work back to beginning
  4615 	TEST(view->PreviousL(active->iStatus));
  4616 	active->StartL();
  4617 	CActiveScheduler::Start();
  4618 	TEST2(active->iStatus.Int(), KErrNone);
  4619 	TEST2(view->Event().Id(), TLogId(6)); // 10, 7, [6], 5, 4, 2, 1, 0
  4620 	TEST(view->PreviousL(active->iStatus));
  4621 	active->StartL();
  4622 	CActiveScheduler::Start();
  4623 	TEST2(active->iStatus.Int(), KErrNone);
  4624 	TEST2(view->Event().Id(), TLogId(7)); // 10, [7], 6, 5, 4, 2, 1, 0
  4625 	TEST(view->PreviousL(active->iStatus));
  4626 	active->StartL();
  4627 	CActiveScheduler::Start();
  4628 	TEST2(active->iStatus.Int(), KErrNone);
  4629 	TEST2(view->Event().Id(), runningNewId-1); // [10], 7, 6, 5, 4, 2, 1, 0
  4630 
  4631 	// Delete added event
  4632 	changeCount = changeObs->Changes().Count();
  4633 	TEST2(changeCount, 0);
  4634 	active->StartL();
  4635 	aClient.DeleteEvent(view->Event().Id(), active->iStatus);
  4636 	CActiveScheduler::Start();
  4637 	TEST2(active->iStatus.Int(), KErrNone); // [7], 6, 5, 4, 2, 1, 0
  4638 
  4639 	// Check deletion changes
  4640 	changeCount = changeObs->Changes().Count();
  4641 	TEST2(changeCount, 1);
  4642 	type = changeObs->Changes().At(0, logId, viewIndex);
  4643 	TEST2(type, ELogChangeTypeEventDeleted);
  4644 	TEST2(logId, runningNewId-1);
  4645 	TEST2(viewIndex, 0);
  4646 	changeObs->ResetChanges();
  4647 
  4648 	// Go back to the first record
  4649 	TEST(view->FirstL(active->iStatus));
  4650 	active->StartL();
  4651 	CActiveScheduler::Start();
  4652 	TEST2(active->iStatus.Int(), KErrNone);
  4653 	TEST2(view->Event().Id(), TLogId(7)); // [7], 6, 5, 4, 2, 1, 0
  4654 
  4655 	// Move one record forward
  4656 	TEST(view->NextL(active->iStatus));
  4657 	active->StartL();
  4658 	CActiveScheduler::Start();
  4659 	TEST2(active->iStatus.Int(), KErrNone);
  4660 	TEST2(view->Event().Id(), TLogId(6)); // 7, [6], 5, 4, 2, 1, 0
  4661 
  4662 	// Change 'Z' event so that it now appears in the view
  4663 	changeCount = changeObs->Changes().Count();
  4664 	TEST2(changeCount ,0);
  4665 	active->StartL();
  4666 	event->SetId(TLogId(3));
  4667 	aClient.GetEvent(*event, active->iStatus);
  4668 	CActiveScheduler::Start();
  4669 	TEST2(active->iStatus.Int(), KErrNone);
  4670 	//
  4671 	event->SetContact(KTestContact);
  4672 	active->StartL();
  4673 
  4674 	// Check that changes work after a backup
  4675 	StartBackupL();
  4676 	DelayL(1000000);
  4677 	TestLogClosedL();
  4678 	EndBackupL();
  4679 	TestLogOpenL();
  4680 
  4681 	changeObs->StartCollectingChanges();
  4682 	aClient.ChangeEvent(*event, active->iStatus);
  4683 	CActiveScheduler::Start();
  4684 	TEST2(active->iStatus.Int(), KErrNone);
  4685 	count = view->CountL();
  4686 	TEST2(count, KChangeEventTest2NumberOfEventsInView+1);
  4687 
  4688 	// Check changes
  4689 	changeCount = changeObs->Changes().Count();
  4690 	TEST2(changeCount, 1);
  4691 	type = changeObs->Changes().At(0, logId, viewIndex);
  4692 	TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view
  4693 	TEST2(logId, TLogId(3));
  4694 	TEST2(viewIndex, 4); // 7, [6], 5, 4, 3, 2, 1, 0
  4695 	changeObs->ResetChanges();
  4696 
  4697 	// Move forwards and check
  4698 	TEST(view->NextL(active->iStatus));
  4699 	active->StartL();
  4700 	CActiveScheduler::Start();
  4701 	TEST2(active->iStatus.Int(), KErrNone);
  4702 	TEST2(view->Event().Id(), TLogId(5)); // 7, 6, [5], 4, 3, 2, 1, 0
  4703 	TEST(view->NextL(active->iStatus));
  4704 	active->StartL();
  4705 	CActiveScheduler::Start();
  4706 	TEST2(active->iStatus.Int(), KErrNone);
  4707 	TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0
  4708 	TEST(view->NextL(active->iStatus));
  4709 	active->StartL();
  4710 	CActiveScheduler::Start();
  4711 	TEST2(active->iStatus.Int(), KErrNone);
  4712 	TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0
  4713 
  4714 	// Change 'Z' event so that its now missing from the view again
  4715 	changeCount = changeObs->Changes().Count();
  4716 	TEST2(changeCount ,0);
  4717 	active->StartL();
  4718 	event->SetId(TLogId(3));
  4719 	aClient.GetEvent(*event, active->iStatus);
  4720 	CActiveScheduler::Start();
  4721 	TEST2(active->iStatus.Int(), KErrNone);
  4722 	//
  4723 	event->SetContact(0);
  4724 	active->StartL();
  4725 
  4726 	// Check that changes work after a backup
  4727 	StartBackupL();
  4728 	DelayL(1000000);
  4729 	TestLogClosedL();
  4730 	EndBackupL();
  4731 	TestLogOpenL();
  4732 
  4733 	changeObs->StartCollectingChanges();
  4734 	aClient.ChangeEvent(*event, active->iStatus);
  4735 	CActiveScheduler::Start();
  4736 	TEST2(active->iStatus.Int(), KErrNone);
  4737 	count = view->CountL();
  4738 	TEST2(count, KChangeEventTest2NumberOfEventsInView);
  4739 
  4740 	// Check changes
  4741 	changeCount = changeObs->Changes().Count();
  4742 	TEST2(changeCount, 1);
  4743 	type = changeObs->Changes().At(0, logId, viewIndex);
  4744 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4745 	TEST2(logId, TLogId(3));
  4746 	TEST2(viewIndex, 4); // 7, 6, 5, 4, [2], 1, 0
  4747 	changeObs->ResetChanges();
  4748 
  4749 	// Move forwards and check
  4750 	TEST(view->NextL(active->iStatus));
  4751 	active->StartL();
  4752 	CActiveScheduler::Start();
  4753 	TEST2(active->iStatus.Int(), KErrNone);
  4754 	TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0
  4755 	TEST(view->NextL(active->iStatus));
  4756 	active->StartL();
  4757 	CActiveScheduler::Start();
  4758 	TEST2(active->iStatus.Int(), KErrNone);
  4759 	TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0]
  4760 
  4761 	// Move back one
  4762 	TEST(view->PreviousL(active->iStatus));
  4763 	active->StartL();
  4764 	CActiveScheduler::Start();
  4765 	TEST2(active->iStatus.Int(), KErrNone);
  4766 	TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0
  4767 	changeCount = changeObs->Changes().Count();
  4768 	TEST2(changeCount ,0);
  4769 
  4770 	// Change 'Z' event so that it now appears in the view
  4771 	active->StartL();
  4772 	event->SetId(TLogId(3));
  4773 	aClient.GetEvent(*event, active->iStatus);
  4774 	CActiveScheduler::Start();
  4775 	TEST2(active->iStatus.Int(), KErrNone);
  4776 	//
  4777 	event->SetContact(KTestContact);
  4778 	active->StartL();
  4779 
  4780 	// Check that changes work after a backup
  4781 	StartBackupL();
  4782 	DelayL(1000000);
  4783 	TestLogClosedL();
  4784 	EndBackupL();
  4785 	TestLogOpenL();
  4786 
  4787 	changeObs->StartCollectingChanges();
  4788 	aClient.ChangeEvent(*event, active->iStatus);
  4789 	CActiveScheduler::Start();
  4790 	TEST2(active->iStatus.Int(), KErrNone);
  4791 	count = view->CountL();
  4792 	TEST2(count, KChangeEventTest2NumberOfEventsInView+1);
  4793 
  4794 	// Check changes
  4795 	changeCount = changeObs->Changes().Count();
  4796 	TEST2(changeCount, 1);
  4797 	type = changeObs->Changes().At(0, logId, viewIndex);
  4798 	TEST2(type, ELogChangeTypeEventAdded); // Change resulted in an addition to the view
  4799 	TEST2(logId, TLogId(3));
  4800 	TEST2(viewIndex, 4); // 7, 6, 5, 4, 3, 2, [1], 0
  4801 	changeObs->ResetChanges();
  4802 
  4803 	// Check can only move forward one more record
  4804 	TEST(view->NextL(active->iStatus));
  4805 	active->StartL();
  4806 	CActiveScheduler::Start();
  4807 	TEST2(active->iStatus.Int(), KErrNone);
  4808 	TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 3, 2, 1, [0]
  4809 
  4810 	// Move back until we are before the inserted record
  4811 	TEST(view->PreviousL(active->iStatus));
  4812 	active->StartL();
  4813 	CActiveScheduler::Start();
  4814 	TEST2(active->iStatus.Int(), KErrNone);
  4815 	TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 3, 2, [1], 0
  4816 	TEST(view->PreviousL(active->iStatus));
  4817 	active->StartL();
  4818 	CActiveScheduler::Start();
  4819 	TEST2(active->iStatus.Int(), KErrNone);
  4820 	TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, 3, [2], 1, 0
  4821 	TEST(view->PreviousL(active->iStatus));
  4822 	active->StartL();
  4823 	CActiveScheduler::Start();
  4824 	TEST2(active->iStatus.Int(), KErrNone);
  4825 	TEST2(view->Event().Id(), TLogId(3)); // 7, 6, 5, 4, [3], 2, 1, 0
  4826 	TEST(view->PreviousL(active->iStatus));
  4827 	active->StartL();
  4828 	CActiveScheduler::Start();
  4829 	TEST2(active->iStatus.Int(), KErrNone);
  4830 	TEST2(view->Event().Id(), TLogId(4)); // 7, 6, 5, [4], 3, 2, 1, 0
  4831 	changeCount = changeObs->Changes().Count();
  4832 	TEST2(changeCount ,0);
  4833 
  4834 	// Change 'Z' event so that its now missing from the view again
  4835 	active->StartL();
  4836 	event->SetId(TLogId(3));
  4837 	aClient.GetEvent(*event, active->iStatus);
  4838 	CActiveScheduler::Start();
  4839 	TEST2(active->iStatus.Int(), KErrNone);
  4840 	//
  4841 	event->SetContact(0);
  4842 	active->StartL();
  4843 
  4844 	// Check that changes work after a backup
  4845 	StartBackupL();
  4846 	DelayL(1000000);
  4847 	TestLogClosedL();
  4848 	EndBackupL();
  4849 	TestLogOpenL();
  4850 
  4851 	changeObs->StartCollectingChanges();
  4852 	aClient.ChangeEvent(*event, active->iStatus);
  4853 	CActiveScheduler::Start();
  4854 	TEST2(active->iStatus.Int(), KErrNone);
  4855 	count = view->CountL();
  4856 	TEST2(count, KChangeEventTest2NumberOfEventsInView);
  4857 
  4858 	// Check changes
  4859 	changeCount = changeObs->Changes().Count();
  4860 	TEST2(changeCount, 1);
  4861 	type = changeObs->Changes().At(0, logId, viewIndex);
  4862 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4863 	TEST2(logId, TLogId(3));
  4864 	TEST2(viewIndex, 4); // 7, 6, 5, [4], 2, 1, 0
  4865 	changeObs->ResetChanges();
  4866 
  4867 	// Check navigating to the end of the view
  4868 	TEST(view->NextL(active->iStatus));
  4869 	active->StartL();
  4870 	CActiveScheduler::Start();
  4871 	TEST2(active->iStatus.Int(), KErrNone);
  4872 	TEST2(view->Event().Id(), TLogId(2)); // 7, 6, 5, 4, [2], 1, 0
  4873 	TEST(view->NextL(active->iStatus));
  4874 	active->StartL();
  4875 	CActiveScheduler::Start();
  4876 	TEST2(active->iStatus.Int(), KErrNone);
  4877 	TEST2(view->Event().Id(), TLogId(1)); // 7, 6, 5, 4, 2, [1], 0
  4878 	TEST(view->NextL(active->iStatus));
  4879 	active->StartL();
  4880 	CActiveScheduler::Start();
  4881 	TEST2(active->iStatus.Int(), KErrNone);
  4882 	TEST2(view->Event().Id(), TLogId(0)); // 7, 6, 5, 4, 2, 1, [0]
  4883 	changeCount = changeObs->Changes().Count();
  4884 	TEST2(changeCount ,0);
  4885 	TEST(!view->NextL(active->iStatus));
  4886 
  4887 	// Delete everything in the view and make sure we can't navigate anymore.
  4888 	active->StartL();
  4889 	aClient.DeleteEvent(TLogId(4), active->iStatus);
  4890 	CActiveScheduler::Start();
  4891 	TEST2(active->iStatus.Int(), KErrNone);
  4892 	count = view->CountL();
  4893 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 1);
  4894 	changeCount = changeObs->Changes().Count();
  4895 	TEST2(changeCount, 1);
  4896 	type = changeObs->Changes().At(0, logId, viewIndex);
  4897 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4898 	TEST2(logId, TLogId(4));
  4899 	TEST2(viewIndex, 3); // 7, 6, 5, 2, 1, [0]
  4900 	changeObs->ResetChanges();
  4901 	//
  4902 	active->StartL();
  4903 	aClient.DeleteEvent(TLogId(7), active->iStatus);
  4904 	CActiveScheduler::Start();
  4905 	TEST2(active->iStatus.Int(), KErrNone);
  4906 	count = view->CountL();
  4907 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 2);
  4908 	changeCount = changeObs->Changes().Count();
  4909 	TEST2(changeCount, 1);
  4910 	type = changeObs->Changes().At(0, logId, viewIndex);
  4911 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4912 	TEST2(logId, TLogId(7));
  4913 	TEST2(viewIndex, 0); // 6, 5, 2, 1, [0]
  4914 	changeObs->ResetChanges();
  4915 	//
  4916 	active->StartL();
  4917 	aClient.DeleteEvent(TLogId(0), active->iStatus);
  4918 	CActiveScheduler::Start();
  4919 	TEST2(active->iStatus.Int(), KErrNone);
  4920 	count = view->CountL();
  4921 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 3);
  4922 	changeCount = changeObs->Changes().Count();
  4923 	TEST2(changeCount, 1);
  4924 	type = changeObs->Changes().At(0, logId, viewIndex);
  4925 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4926 	TEST2(logId, TLogId(0));
  4927 	TEST2(viewIndex, 4); // 6, 5, 2, [1]
  4928 	changeObs->ResetChanges();
  4929 	//
  4930 	active->StartL();
  4931 	aClient.DeleteEvent(TLogId(5), active->iStatus);
  4932 	CActiveScheduler::Start();
  4933 	TEST2(active->iStatus.Int(), KErrNone);
  4934 	count = view->CountL();
  4935 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 4);
  4936 	changeCount = changeObs->Changes().Count();
  4937 	TEST2(changeCount, 1);
  4938 	type = changeObs->Changes().At(0, logId, viewIndex);
  4939 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4940 	TEST2(logId, TLogId(5));
  4941 	TEST2(viewIndex, 1); // 6, 2, [1]
  4942 	changeObs->ResetChanges();
  4943 	//
  4944 	active->StartL();
  4945 	aClient.DeleteEvent(TLogId(2), active->iStatus);
  4946 	CActiveScheduler::Start();
  4947 	TEST2(active->iStatus.Int(), KErrNone);
  4948 	count = view->CountL();
  4949 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 5);
  4950 	changeCount = changeObs->Changes().Count();
  4951 	TEST2(changeCount, 1);
  4952 	type = changeObs->Changes().At(0, logId, viewIndex);
  4953 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4954 	TEST2(logId, TLogId(2));
  4955 	TEST2(viewIndex, 1); // 6, [1]
  4956 	changeObs->ResetChanges();
  4957 	//
  4958 	active->StartL();
  4959 	aClient.DeleteEvent(TLogId(6), active->iStatus);
  4960 	CActiveScheduler::Start();
  4961 	TEST2(active->iStatus.Int(), KErrNone);
  4962 	count = view->CountL();
  4963 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 6);
  4964 	changeCount = changeObs->Changes().Count();
  4965 	TEST2(changeCount, 1);
  4966 	type = changeObs->Changes().At(0, logId, viewIndex);
  4967 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4968 	TEST2(logId, TLogId(6));
  4969 	TEST2(viewIndex, 0); // [1]
  4970 	changeObs->ResetChanges();
  4971 
  4972 	// Check we can't go backwards or forwards
  4973 	TEST(!view->NextL(active->iStatus));
  4974 	TEST(!view->PreviousL(active->iStatus));
  4975 	TEST(view->FirstL(active->iStatus));
  4976 	active->StartL();
  4977 	CActiveScheduler::Start();
  4978 	TEST2(active->iStatus.Int(), KErrNone);
  4979 	TEST2(view->Event().Id(), TLogId(1)); // [1]
  4980 	TEST(view->LastL(active->iStatus));
  4981 	active->StartL();
  4982 	CActiveScheduler::Start();
  4983 	TEST2(active->iStatus.Int(), KErrNone);
  4984 	TEST2(view->Event().Id(), TLogId(1)); // [1]
  4985 
  4986 	// Delete last event in view
  4987 	active->StartL();
  4988 	aClient.DeleteEvent(TLogId(1), active->iStatus);
  4989 	CActiveScheduler::Start();
  4990 	TEST2(active->iStatus.Int(), KErrNone);
  4991 	count = view->CountL();
  4992 	TEST2(count, KChangeEventTest2NumberOfEventsInView - 7);
  4993 	changeCount = changeObs->Changes().Count();
  4994 	TEST2(changeCount, 1);
  4995 	type = changeObs->Changes().At(0, logId, viewIndex);
  4996 	TEST2(type, ELogChangeTypeEventDeleted); // Change resulted in a removal from the view
  4997 	TEST2(logId, TLogId(1));
  4998 	TEST2(viewIndex, 0); // *Empty*
  4999 	changeObs->ResetChanges();
  5000 
  5001 	// Check we can't navigate
  5002 	TEST(!view->NextL(active->iStatus));
  5003 	TEST(!view->PreviousL(active->iStatus));
  5004 	TEST(!view->FirstL(active->iStatus));
  5005 	TEST(!view->LastL(active->iStatus));
  5006 
  5007 	CleanupStack::PopAndDestroy(5, event); // view, changeObs, active, filter, event
  5008 	}
  5009 
  5010 /**
  5011 @SYMTestCaseID          SYSLIB-LOGENG-CT-0872
  5012 @SYMTestCaseDesc	    Filtering log view test
  5013 @SYMTestPriority 	    High
  5014 @SYMTestActions  	    Add the Voice call,FAX,SMS event types to the log client.
  5015                         Set all the event types to filter list.Check for the correct event types and no errors
  5016 @SYMTestExpectedResults Test must not fail
  5017 @SYMREQ                 REQ0000
  5018 */
  5019 LOCAL_C void TestViewFilteringDefect1L(CLogClient& aClient)
  5020 	{
  5021 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0872 "));
  5022 	CLogEvent* event = CLogEvent::NewL();
  5023 	CleanupStack::PushL(event);
  5024 
  5025 	CTestActive* active = new(ELeave) CTestActive();
  5026 	CleanupStack::PushL(active);
  5027 
  5028 	// VOICE CALL
  5029 	event->SetEventType(KLogCallEventTypeUid);
  5030 	active->StartL();
  5031 	aClient.AddEvent(*event, active->iStatus);
  5032 	CActiveScheduler::Start();
  5033 	TEST2(active->iStatus.Int(), KErrNone);
  5034 	const TLogId event1 = event->Id();
  5035 
  5036 	// FAX
  5037 	event->SetEventType(KLogFaxEventTypeUid);
  5038 	active->StartL();
  5039 	aClient.AddEvent(*event, active->iStatus);
  5040 	CActiveScheduler::Start();
  5041 	TEST2(active->iStatus.Int(), KErrNone);
  5042 	const TLogId event2 = event->Id();
  5043 	(void) event2;
  5044 
  5045 	// SMS, CONTACT SEARCHED
  5046 	event->SetEventType(KLogShortMessageEventTypeUid);
  5047 	event->SetFlags(KLogEventContactSearched);
  5048 	active->StartL();
  5049 	aClient.AddEvent(*event, active->iStatus);
  5050 	CActiveScheduler::Start();
  5051 	TEST2(active->iStatus.Int(), KErrNone);
  5052 	const TLogId event3 = event->Id();
  5053 
  5054 	CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
  5055 	changeObs->SetActive();
  5056 
  5057 	CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
  5058 	CleanupStack::PushL(view);
  5059 
  5060 	CLogFilterList* filterList = new(ELeave) CLogFilterList();
  5061 	CleanupStack::PushL(filterList);
  5062 
  5063 	CLogFilter* filter1 = CLogFilter::NewL();
  5064 	CleanupStack::PushL(filter1);
  5065 	filter1->SetEventType(KLogCallEventTypeUid); // ALL VOICE CALL EVENTS
  5066 	filterList->AppendL(filter1);
  5067 	
  5068 	CLogFilter* filter2 = CLogFilter::NewL();
  5069 	CleanupStack::PushL(filter2);
  5070 	filter2->SetEventType(KLogShortMessageEventTypeUid); // ALL SMS's WHERE CONTACTS SEARCH FLAG IS SET
  5071 	filter2->SetFlags(KLogEventContactSearched);
  5072 	filterList->AppendL(filter2);
  5073 
  5074 	TInt count = view->CountL();
  5075 	TEST2(count, 0);
  5076 	TBool res = view->SetFilterParseFilterByFilterL(*filterList, active->iStatus);
  5077 	TEST(res);
  5078 	CleanupStack::PopAndDestroy(3, filterList);
  5079 
  5080 	active->StartL();
  5081 	CActiveScheduler::Start();
  5082 	TEST2(active->iStatus.Int(), KErrNone);
  5083 	count = view->CountL();
  5084 	TEST2(count, 2);
  5085 
  5086 	// Check correct events
  5087 	TLogId eventId;
  5088 	//
  5089 	active->StartL();
  5090 	res = view->FirstL(active->iStatus);
  5091 	TEST(res);
  5092 	CActiveScheduler::Start();
  5093 	TEST2(active->iStatus.Int(), KErrNone);
  5094 	eventId = view->Event().Id();
  5095 	TEST2(eventId, event3);
  5096 	//
  5097 	active->StartL();
  5098 	res = view->NextL(active->iStatus);
  5099 	TEST(res);
  5100 	CActiveScheduler::Start();
  5101 	TEST2(active->iStatus.Int(), KErrNone);
  5102 	eventId = view->Event().Id();
  5103 	TEST2(eventId, event1);
  5104 	
  5105 	CleanupStack::PopAndDestroy(4, event);
  5106 	}
  5107 
  5108 //
  5109 //
  5110 //
  5111 static TInt TestDeletingViewWithinObserverCallbackL_CallbackFn(TAny* aView)
  5112 	{
  5113 	CLogViewEvent* view = reinterpret_cast<CLogViewEvent*>(aView);
  5114 	delete view;
  5115 	return KErrNone;
  5116 	}
  5117 
  5118 //
  5119 //
  5120 //
  5121 static void TestDeletingViewWithinObserverCallbackL_ThreadFunctionL()
  5122 	{
  5123 	RFs fsSession;
  5124 	LEAVE_IF_ERROR(fsSession.Connect());
  5125 	CleanupClosePushL(fsSession);
  5126 	//
  5127 	CLogClient* client = CLogClient::NewL(fsSession);
  5128 	CleanupStack::PushL(client);
  5129 	//
  5130 	CLogEvent* event = CLogEvent::NewL();
  5131 	CleanupStack::PushL(event);
  5132 	event->SetEventType(KLogCallEventTypeUid);
  5133 	//
  5134 	CTestActive* active = new(ELeave) CTestActive();
  5135 	CleanupStack::PushL(active);
  5136 
  5137 	// Wait for main test code thread
  5138 	RSemaphore semaphore;
  5139 	const TInt error = semaphore.OpenGlobal(KThreadSemaphoreName);
  5140 	LEAVE_IF_ERROR(error);
  5141 
  5142 	// Add 5 recent events to the list
  5143 	TBuf<KLogMaxDirectionLength> incoming;
  5144 	client->GetString(incoming, R_LOG_DIR_IN);
  5145 	event->SetDirection(incoming);
  5146 
  5147 	// Incoming
  5148 	for(TInt recent = 1; recent <= 5; recent++)
  5149 		{
  5150 		event->SetContact(recent);
  5151 		for(TInt duplicate = 1; duplicate <= 6; duplicate++)
  5152 			{
  5153 			active->StartL();
  5154 			client->AddEvent(*event, active->iStatus);
  5155 			CActiveScheduler::Start();
  5156 			__ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 1));
  5157 			}
  5158 		}
  5159 
  5160 	// Wait now until the main thread says we can delete all events
  5161 	semaphore.Signal();
  5162 	User::After(5 * 1000000);
  5163 	semaphore.Wait();
  5164 
  5165 	// Clear the duplicates which should result in a batch of changes
  5166 	// in the other thread
  5167 	CLogViewRecent* view = CLogViewRecent::NewL(*client);
  5168 	CleanupStack::PushL(view);
  5169 	//
  5170 	__ASSERT_ALWAYS(view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus), User::Panic(_L("ThreadPanic"), 2));
  5171 	__ASSERT_ALWAYS(view->CountL() == 5, User::Panic(_L("ThreadPanic"), 3));
  5172 	active->StartL();
  5173 	CActiveScheduler::Start();
  5174 	__ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 4));
  5175 
  5176 	// Now do the clear
  5177 	view->ClearDuplicatesL();
  5178 	__ASSERT_ALWAYS(view->CountL() == 5, User::Panic(_L("ThreadPanic"), 5));
  5179 
  5180 	// Cleanup
  5181 	CleanupStack::PopAndDestroy(view);
  5182 	semaphore.Close();
  5183 	CleanupStack::PopAndDestroy(4, &fsSession); // active, event, client, fsSession
  5184 	}
  5185 
  5186 //
  5187 //
  5188 //
  5189 static TInt TestDeletingViewWithinObserverCallbackL_ThreadFunction(TAny* /*aData*/)
  5190 	{
  5191 	CTrapCleanup* cleanup = CTrapCleanup::New();
  5192 	if	(!cleanup)
  5193 		return KErrNoMemory;
  5194 	CActiveScheduler* scheduler = new CActiveScheduler();
  5195 	if	(!scheduler)
  5196 		return KErrNoMemory;
  5197 	CActiveScheduler::Install(scheduler);
  5198 	//
  5199 	TRAPD(err, TestDeletingViewWithinObserverCallbackL_ThreadFunctionL());
  5200     UNUSED_VAR(err);
  5201 	//
  5202 	delete scheduler;
  5203 	delete cleanup;
  5204 	//
  5205 	return KErrNone;
  5206 	}
  5207 
  5208 /**
  5209 @SYMTestCaseID          SYSLIB-LOGENG-CT-0873
  5210 @SYMTestCaseDesc	    Tests for observing changes within a callback
  5211 @SYMTestPriority 	    High
  5212 @SYMTestActions  	    Check for observing changes within a callback
  5213 @SYMTestExpectedResults Test must not fail
  5214 @SYMREQ                 REQ0000
  5215 */
  5216 LOCAL_C void TestDeletingViewWithinObserverCallbackL(CLogClient& aClient)
  5217 	{
  5218 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0873 "));
  5219 	TestUtils::DeleteDatabaseL();
  5220 
  5221 	TInt error = 0;
  5222 	//
  5223 	CTestActive* active = new(ELeave) CTestActive();
  5224 	CleanupStack::PushL(active);
  5225 
  5226 	CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
  5227 
  5228 	CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
  5229 	CleanupStack::PushL(view);
  5230 
  5231 	CLogFilter* filter = CLogFilter::NewL();
  5232 	CleanupStack::PushL(filter);
  5233 	filter->SetEventType(KLogCallEventTypeUid); 
  5234 	TBool res = view->SetFilterL(*filter, active->iStatus);
  5235 	TEST(!res);
  5236 	CleanupStack::PopAndDestroy(filter);
  5237 
  5238 	// Create semaphore so we can control other thread
  5239 	RSemaphore semaphore;
  5240 	error = semaphore.CreateGlobal(KThreadSemaphoreName, 0);
  5241 	LEAVE_IF_ERROR(error);
  5242 	CleanupClosePushL(semaphore);
  5243 
  5244 	// Create thread which adds two events
  5245 	RThread thread;
  5246 	error = thread.Create(_L("T_VIEW1_OBS_EVENT_CREATION_THREAD"), TestDeletingViewWithinObserverCallbackL_ThreadFunction, 10 * 1024, 5 * 1024, 20 * 1024, NULL);
  5247 	LEAVE_IF_ERROR(error);
  5248 	CleanupClosePushL(thread);
  5249 
  5250 	// Start the worker thread going
  5251 	thread.Resume();
  5252 	User::After(1 * 100000);
  5253 	semaphore.Wait();
  5254 
  5255 	// Wait for changes
  5256 	CLogChangeDefinition* changes = changeObs->WaitForChangesLC(TCallBack(TestDeletingViewWithinObserverCallbackL_CallbackFn, view), CLogViewChangeObserver::EStopOnChanges);
  5257 
  5258 	// Check the changes
  5259 	TEST2(changes->Count(), 1);
  5260 	TEST2(changes->At(0), ELogChangeTypeEventAdded);
  5261 
  5262 	TLogId logId = -1;
  5263 	TLogDatabaseChangeType dbChangeType = changes->At(0, logId);
  5264 	TEST2(dbChangeType, ELogChangeTypeEventAdded);
  5265 	TEST2(logId, 0);
  5266 	TInt viewIndex = -1;
  5267 	dbChangeType = changes->At(0, logId, viewIndex);
  5268 	TEST2(logId, 0);
  5269 	TEST2(viewIndex, 0);
  5270 	//Find a change position by the log id
  5271 	TInt pos = changes->Find(logId);
  5272 	TEST2(pos, 0);
  5273 	pos = changes->Find(8125347);
  5274 	TEST2(pos, KErrNotFound);
  5275 	//Find a change position by the log id and the change type
  5276 	pos = changes->Find(logId, dbChangeType);
  5277 	TEST2(pos, 0);
  5278 	pos = changes->Find(432837, ELogChangeTypeEventChanged);
  5279 	TEST2(pos, KErrNotFound);
  5280 	//Find a view position by the view index
  5281 	pos = changes->FindByViewIndex(viewIndex);
  5282 	TEST2(pos, 0);
  5283 	pos = changes->FindByViewIndex(33939);
  5284 	TEST2(pos, KErrNotFound);
  5285 	//Stream out the changes to a buffer
  5286 	TBuf8<100> strmBuf;
  5287 	RDesWriteStream strmOut(strmBuf);
  5288 	changes->ExternalizeL(strmOut);
  5289 	strmOut.CommitL();
  5290 	
  5291 	CleanupStack::PopAndDestroy(changes);
  5292 	
  5293 	//Re-create changes from the buffer
  5294 	RDesReadStream strmIn(strmBuf);
  5295 	changes = CLogChangeDefinition::NewL(strmIn);
  5296 	dbChangeType = changes->At(0, logId);
  5297 	TEST2(dbChangeType, ELogChangeTypeEventAdded);
  5298 	TEST2(logId, 0);
  5299 	delete changes;
  5300 
  5301 	// The view should be deleted...
  5302 	CleanupStack::PopAndDestroy(&thread);
  5303 	CleanupStack::PopAndDestroy(&semaphore);
  5304 
  5305 	CleanupStack::Pop(); // view
  5306 	CleanupStack::PopAndDestroy(2, active); // changeObs, active
  5307 	}
  5308 
  5309 
  5310 
  5311 //
  5312 //
  5313 //
  5314 struct TThreadData
  5315 	{
  5316 	inline TThreadData() : iArray(NULL), iStopThread(EFalse) { }
  5317 	//
  5318 	RArray<TLogId>* iArray;
  5319 	TBool iStopThread;
  5320 	};
  5321 
  5322 // Slave Thread for the TestNavigationWhilstBusyL() test.
  5323 // This runs continuously while aThreadData.iStopThread is False.
  5324 static void TestNavigationWhilstBusyL_ThreadFunctionL(TThreadData& aThreadData)
  5325 	{
  5326 	enum TNextOp
  5327 		{
  5328 		EAdd = 0,
  5329 		EDelete,
  5330 		EClear,
  5331 		};
  5332 
  5333 	const static TNextOp KOpTable[] = 
  5334 		{
  5335 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5336 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5337 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5338 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EDelete,	EAdd,		EAdd,		EAdd,		EAdd,
  5339 		EAdd,		EAdd,		EAdd,		EDelete,	EDelete,	EDelete,	EAdd,		EAdd,		EAdd,		EAdd,
  5340 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5341 		EAdd,		EAdd,		EAdd,		EDelete,	EDelete,	EDelete,	EAdd,		EAdd,		EAdd,		EAdd,
  5342 		EDelete,	EDelete,	EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5343 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5344 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5345 		EAdd,		EAdd,		EAdd,		EDelete,	EDelete,	EDelete,	EAdd,		EAdd,		EAdd,		EAdd,
  5346 		EDelete,	EDelete,	EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5347 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5348 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5349 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EDelete,	EAdd,		EAdd,		EAdd,		EAdd,
  5350 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5351 		EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,
  5352 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5353 		EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,
  5354 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5355 		EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,
  5356 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5357 		EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,
  5358 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5359 		EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,	EAdd,		EDelete,
  5360 		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,		EAdd,
  5361 		};
  5362 	const static TInt KIndexTable[] = 
  5363 		{
  5364 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5365 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5366 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5367 		-1,			-1,			-1,			-1,			-1,			0,			-1,			-1,			-1,			-1,
  5368 		-1,			-1,			-1,			0,			4,			20,			-1,			-1,			-1,			-1,
  5369 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5370 		-1,			-1,			-1,			0,			1,			0,			-1,			-1,			-1,			-1,
  5371 		25,			8,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5372 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5373 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5374 		-1,			-1,			-1,			2,			4,			15,			-1,			-1,			-1,			-1,
  5375 		0,			0,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5376 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5377 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5378 		-1,			-1,			-1,			-1,			-1,			0,			-1,			-1,			-1,			-1,
  5379 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5380 		-1,			0,			-1,			30,			-1,			0,			-1,			31,			-1,			14,
  5381 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5382 		-1,			10,			-1,			2,			-1,			0,			-1,			24,			-1,			11,
  5383 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5384 		-1,			0,			-1,			10,			-1,			0,			-1,			12,			-1,			5,
  5385 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5386 		-1,			15,			-1,			9,			-1,			0,			-1,			19,			-1,			25,
  5387 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5388 		-1,			0,			-1,			1,			-1,			0,			-1,			7,			-1,			31,
  5389 		-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,			-1,
  5390 		};
  5391 	const static TInt KDelayTable[] = 
  5392 		{
  5393 		0001,		0001,		0001,		0001,		0001,		0001,		0001,		0001,		0001,		0001,
  5394 		0001,		0001,		0001,		0001,		0001,		0001,		0001,		0001,		0001,		0001,
  5395 		0001,		0001,		0001,		0001,		0001,		0001,		0001,		0001,		0001,		0001,
  5396 		0001,		0001,		0001,		0001,		0001,		0001,		0002,		0002,		0002,		0002,
  5397 		0002,		0002,		0002,		0001,		0001,		0001,		0002,		0002,		0002,		0002,
  5398 		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,
  5399 		0002,		0002,		0002,		0001,		0002,		0001,		0002,		0002,		0002,		0002,
  5400 		2500,		8000,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,
  5401 		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,
  5402 		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,
  5403 		0002,		0002,		0002,		2000,		4000000,	1500,		0002,		0002,		0002,		0002,
  5404 		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,
  5405 		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,
  5406 		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,		0002,
  5407 		0002,		0002,		0002,		0002,		0002,		0001,		0002,		0002,		0002,		0002,
  5408 		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,
  5409 		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,
  5410 		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,
  5411 		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,
  5412 		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,
  5413 		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,
  5414 		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,
  5415 		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,
  5416 		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,
  5417 		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,
  5418 		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,		0000,
  5419 		};
  5420 	const TInt KOpCount = sizeof(KOpTable) / sizeof(TNextOp);
  5421 
  5422 	TInt TotalAdds = 0;
  5423 	TInt TotalDeletes = 0;
  5424 	
  5425 	RFs fsSession;
  5426 	LEAVE_IF_ERROR(fsSession.Connect());
  5427 	CleanupClosePushL(fsSession);
  5428 	//
  5429 	CLogClient* client = CLogClient::NewL(fsSession);
  5430 	CleanupStack::PushL(client);
  5431 	//
  5432 	CLogEvent* event = CLogEvent::NewL();
  5433 	CleanupStack::PushL(event);
  5434 	event->SetEventType(TEST_LOG_UID);
  5435 	//
  5436 	CTestActive* active = new(ELeave) CTestActive();
  5437 	CleanupStack::PushL(active);
  5438 
  5439 	// Add 5 recent events to the list
  5440 	TBuf<KLogMaxDirectionLength> incoming;
  5441 	client->GetString(incoming, R_LOG_DIR_IN);
  5442 	event->SetDirection(incoming);
  5443 
  5444 	CLogSchedulerTimer* timer = CLogSchedulerTimer::NewLC();
  5445 	TInt count = 0;
  5446 	TInt i=0;
  5447 	TInt Repeat =0;
  5448 	//
  5449 	while(!(aThreadData.iStopThread))
  5450 		{
  5451 		const TInt op = KOpTable[i];
  5452 		//
  5453 		switch(op)
  5454 			{
  5455 			case EAdd:
  5456 				{
  5457 				event->SetContact(i);
  5458 				active->StartL();
  5459 				client->AddEvent(*event, active->iStatus);
  5460 				CActiveScheduler::Start();
  5461 				__ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 1));
  5462 				++count;
  5463 				LEAVE_IF_ERROR(aThreadData.iArray->Append(event->Id()));
  5464 				// TheTest.Printf(_L("EAdd: i:%d count:%d, id:%d\n"), i, aThreadData.iArray->Count(), event->Id());
  5465 
  5466 				// Have to wait for a minimum of 1 ms here because otherwise DMBS sorts records (by time)
  5467 				// in an arbitrary manor
  5468 				// If this occurs this test will fail the logId == arrayId test below, as the order
  5469 				// will be different between the logeng and arrayOfIds[].
  5470 				const TInt timeToWait = KDelayTable[i];
  5471 				if	(timeToWait)
  5472 					timer->Wait(timeToWait);
  5473 
  5474 				timer->Wait(500000);
  5475 				
  5476 				TotalAdds++;	
  5477 				break;
  5478 				}
  5479 			case EDelete:
  5480 				{
  5481 				const TInt index = KIndexTable[i];
  5482 				const TLogId logId = (*aThreadData.iArray)[index];
  5483 				RDebug::Print(_L("EDelete index[%i]=%d id:%d\n"),i, index, logId);
  5484 				active->StartL();
  5485 				client->DeleteEvent(logId, active->iStatus);
  5486 				CActiveScheduler::Start();
  5487 				if (active->iStatus != KErrNone)
  5488 					{
  5489 					/* This happens if the LogID is not present in the log,
  5490 					   so the LogEngine cannot find the event to delete.
  5491 					   This can happen if the log is full, as it will start
  5492 					   deleting the old events itself */
  5493 					RDebug::Print(_L("Delete failed error:%d\n"), active->iStatus.Int());
  5494 					__ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 2));
  5495 					}
  5496 				aThreadData.iArray->Remove(index);
  5497 				--count;
  5498 				TotalDeletes++;
  5499 				break;
  5500 				}
  5501 			case EClear:
  5502 				{
  5503 				TTime now;
  5504 				now.UniversalTime();
  5505 				now += TTimeIntervalDays(1);
  5506 
  5507 				// Clear log
  5508 				active->StartL();
  5509 				client->ClearLog(now, active->iStatus);
  5510 				CActiveScheduler::Start();
  5511 				__ASSERT_ALWAYS(active->iStatus == KErrNone, User::Panic(_L("ThreadPanic"), 3));
  5512 				aThreadData.iArray->Reset();
  5513 				count = 0;
  5514 				RDebug::Print(_L("TEST CODE: Log cleared\n"));
  5515 				break;
  5516 				}
  5517 			}
  5518 	
  5519 		if	(++i >= KOpCount)
  5520 			{
  5521 			i = 0;
  5522 			Repeat++;
  5523 			}
  5524 		}
  5525 
  5526 	RDebug::Print(_L("Repeats:%d TotalAdds:%d TotalDeletes:%d = %d\n"),Repeat,TotalAdds, TotalDeletes, count);
  5527 	
  5528 	CleanupStack::PopAndDestroy(timer);
  5529 
  5530 	// Tidy up
  5531 	CleanupStack::PopAndDestroy(4, &fsSession);
  5532 	}
  5533 
  5534 // Slave Thread for the TestNavigationWhilstBusyL() test.
  5535 //
  5536 static TInt TestNavigationWhilstBusyL_ThreadFunction(TAny* aData)
  5537 	{
  5538 	TThreadData* threadData = reinterpret_cast<TThreadData*>(aData);
  5539 	//
  5540 	CTrapCleanup* cleanup = CTrapCleanup::New();
  5541 	if	(!cleanup)
  5542 		return KErrNoMemory;
  5543 	CActiveScheduler* scheduler = new CActiveScheduler();
  5544 	if	(!scheduler)
  5545 		return KErrNoMemory;
  5546 	CActiveScheduler::Install(scheduler);
  5547 	//
  5548 	TRAPD(err, TestNavigationWhilstBusyL_ThreadFunctionL(*threadData));
  5549     UNUSED_VAR(err);
  5550 	//
  5551 	delete scheduler;
  5552 	delete cleanup;
  5553 	//
  5554 	return KErrNone;
  5555 	}
  5556 
  5557 /**
  5558 This tests using the Logeng while it is busy.  It starts a new thread which adds and deletes events
  5559 using the data in KOpTable[] and KIndexTable[]. It then checks the database while the new thread is 
  5560 running.
  5561 
  5562 @SYMTestCaseID          SYSLIB-LOGENG-CT-0874
  5563 @SYMTestCaseDesc	    Tests for navigation while Log engine is busy.
  5564 @SYMTestPriority 	    High
  5565 @SYMTestActions  	    Start a new thread which adds and deletes events
  5566                         using the data in defined tables.It then checks the database while the new thread is running.
  5567 @SYMTestExpectedResults Test must not fail
  5568 @SYMREQ                 REQ0000
  5569 */
  5570 LOCAL_C void TestNavigationWhilstBusyL(CLogClient& aClient)
  5571 	{
  5572 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0874 "));
  5573 	TestUtils::DeleteDatabaseL();
  5574 
  5575 	TInt error = 0;
  5576 	TInt count = 0;
  5577 	//
  5578 	CTestActive* active = new(ELeave) CTestActive();
  5579 	CleanupStack::PushL(active);
  5580 
  5581 	CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
  5582 
  5583 	// Create a test event type - TEST_LOG_UID
  5584 	CLogEventType* type = CLogEventType::NewL();
  5585 	CleanupStack::PushL(type);
  5586 
  5587 	type->SetUid(TEST_LOG_UID);
  5588 	type->SetDescription(KTestEventDesc);
  5589 	type->SetLoggingEnabled(ETrue);
  5590 	TheTest.Printf(_L("\nTest event type added %x\n"),TEST_LOG_UID );
  5591 
  5592 	// Register the event type
  5593 	active->StartL();
  5594 	aClient.AddEventType(*type, active->iStatus);
  5595 	CActiveScheduler::Start();
  5596 	TEST2(active->iStatus.Int(), KErrNone);
  5597 
  5598 	CleanupStack::PopAndDestroy(); // type
  5599 
  5600 	CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
  5601 	CleanupStack::PushL(view);
  5602 
  5603 	CLogFilter* filter = CLogFilter::NewL();
  5604 	CleanupStack::PushL(filter);
  5605 	filter->SetEventType(TEST_LOG_UID);  
  5606 	TBool res = view->SetFilterL(*filter, active->iStatus);
  5607 	TEST(!res);
  5608 
  5609 	// increase the default log size
  5610 	TLogConfig Config;
  5611 	const TInt kMaxLogSize = 2000;
  5612 	Config.iMaxLogSize = kMaxLogSize;
  5613 	aClient.ChangeConfig( Config, active->iStatus);
  5614 	active->StartL();
  5615 	CActiveScheduler::Start();
  5616 	TEST2(active->iStatus.Int(), KErrNone);
  5617 	
  5618 	// Shared data between this and the worker thread
  5619 	RArray<TLogId> arrayOfIds(100);
  5620 	CleanupClosePushL(arrayOfIds);
  5621 	TThreadData threadData;
  5622 	threadData.iArray = &arrayOfIds;
  5623 
  5624 	// Create thread which adds two events
  5625 	RThread thread;
  5626 	RHeap& heap = User::Heap();
  5627 	error = thread.Create(_L("T_VIEW1_OBS_EVENT_CREATION_THREAD2"), TestNavigationWhilstBusyL_ThreadFunction, 10 * 1024, &heap, &threadData);
  5628 	LEAVE_IF_ERROR(error);
  5629 	CleanupClosePushL(thread);
  5630 
  5631 	// Start the worker thread going
  5632 	thread.Resume();
  5633 
  5634 	// Suspend this thread
  5635 	TheTest.Printf(_L("TEST CODE: Suspending thread for 2 seconds\n"));
  5636 	CLogSchedulerTimer* timer = CLogSchedulerTimer::NewLC();
  5637 	timer->Wait(10 * 1000000);
  5638 
  5639 	// Apply the filter now there are some records
  5640 	TheTest.Printf(_L("TEST CODE: Setting filter again - should be some records now\n"));
  5641 	res = view->SetFilterL(*filter, active->iStatus);
  5642 	TEST(res);
  5643 	active->StartL();
  5644 	CActiveScheduler::Start();
  5645 	TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel); // KErrCancel when the worker thread clears the log at the same time as we are navigating to the first record
  5646 	count = view->CountL();
  5647 	TEST(count > 0);
  5648 
  5649 	// Navigate around (up and down) whilst events are being created
  5650 	count = view->CountL();
  5651 	res = view->FirstL(active->iStatus);
  5652 	TEST(res);
  5653 	do	{
  5654 		active->StartL();
  5655 		CActiveScheduler::Start();
  5656 		TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
  5657 		count--;
  5658 		if	(active->iStatus == KErrNone)
  5659 			TEST(view->Event().Id() != KLogNullId);
  5660 		}
  5661 	while(view->NextL(active->iStatus));
  5662 
  5663 	timer->Wait(5 * 1000000);
  5664 	count = view->CountL();
  5665 	res = view->FirstL(active->iStatus);
  5666 	TEST(res);
  5667 	do	{
  5668 		active->StartL();
  5669 		CActiveScheduler::Start();
  5670 		TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
  5671 		count--;
  5672 		if	(active->iStatus == KErrNone)
  5673 			TEST(view->Event().Id() != KLogNullId);
  5674 		}
  5675 	while(view->NextL(active->iStatus));
  5676 
  5677 	timer->Wait(5 * 1000000);
  5678 	count = view->CountL();
  5679 	res = view->LastL(active->iStatus);
  5680 	TEST(res);
  5681 	do	{
  5682 		active->StartL();
  5683 		CActiveScheduler::Start();
  5684 		TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
  5685 		count--;
  5686 		if	(active->iStatus == KErrNone)
  5687 			TEST(view->Event().Id() != KLogNullId);
  5688 		}
  5689 	while(view->PreviousL(active->iStatus));
  5690 
  5691 	timer->Wait(5 * 1000000);
  5692 	count = view->CountL();
  5693 	res = view->FirstL(active->iStatus);
  5694 	TEST(res);
  5695 	do	{
  5696 		active->StartL();
  5697 		CActiveScheduler::Start();
  5698 		TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
  5699 		count--;
  5700 		if	(active->iStatus == KErrNone)
  5701 			TEST(view->Event().Id() != KLogNullId);
  5702 		}
  5703 	while(view->NextL(active->iStatus));
  5704 
  5705 	timer->Wait(5 * 1000000);
  5706 	count = view->CountL();
  5707 	res = view->LastL(active->iStatus);
  5708 	TEST(res);
  5709 	do	{
  5710 		active->StartL();
  5711 		CActiveScheduler::Start();
  5712 		TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
  5713 		count--;
  5714 		if	(active->iStatus == KErrNone)
  5715 			TEST(view->Event().Id() != KLogNullId);
  5716 		}
  5717 	while(view->PreviousL(active->iStatus));
  5718 
  5719 	timer->Wait(5 * 1000000);
  5720 	count = view->CountL();
  5721 	res = view->LastL(active->iStatus);
  5722 	TEST(res);
  5723 	do	{
  5724 		active->StartL();
  5725 		CActiveScheduler::Start();
  5726 		TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
  5727 		count--;
  5728 		if	(active->iStatus == KErrNone)
  5729 			TEST(view->Event().Id() != KLogNullId);
  5730 		}
  5731 	while(view->PreviousL(active->iStatus));
  5732 	
  5733 	// STOP THE WORKER THREAD
  5734 	threadData.iStopThread = ETrue;
  5735 	TheTest.Printf(_L("Stopping worker thread\n"));
  5736 	timer->Wait(30 * 1000000);
  5737 	
  5738 	// do some checks on the log
  5739 	TLogConfig logConfig;
  5740 	aClient.GetConfig( logConfig, active->iStatus);
  5741 	active->StartL();
  5742 	CActiveScheduler::Start();
  5743 	TEST2(active->iStatus.Int(), KErrNone);
  5744 	TheTest.Printf(_L("MaxLogSize:%ld MaxRecentLogSize:%d\n"),
  5745 		logConfig.iMaxLogSize, logConfig.iMaxRecentLogSize );
  5746 	TEST(logConfig.iMaxLogSize > logConfig.iMaxRecentLogSize);
  5747 
  5748 	/*  Check the log has not overflowed.
  5749 	    If this fails either increase the log size or reduce the time the 
  5750 	    worker thread has been running
  5751      */
  5752 	TEST(arrayOfIds.Count() < kMaxLogSize);
  5753 	
  5754 	// Loop though the logevents created by the worker thread and compare against the 
  5755 	// data stored in arrayOfIds. 
  5756 	res = view->LastL(active->iStatus);
  5757 	TEST(res);
  5758 	count = 0;
  5759 	do	{
  5760 		active->StartL();
  5761 		CActiveScheduler::Start();
  5762 		TEST2(active->iStatus.Int(), KErrNone);
  5763 		
  5764 		const TLogId logId = view->Event().Id();
  5765 		const TLogId arrayId = arrayOfIds[count];
  5766 		if	(logId != arrayId)
  5767 			TheTest.Printf(_L("Events[%d] - array:%5d, id:%5d ****\n"), count, arrayId, logId);
  5768 		// Note: If this test fails the fist thing to check is the time delay after EAdd.
  5769 		// If several events get the same time stamp, the order is arbitrary and the test fails here.
  5770 		TEST2(logId, arrayId);
  5771 		count++;
  5772 		}
  5773 	while(view->PreviousL(active->iStatus));
  5774 
  5775 	CleanupStack::PopAndDestroy(timer);
  5776 	CleanupStack::PopAndDestroy(&thread);
  5777 	CleanupStack::PopAndDestroy(&arrayOfIds);
  5778 	CleanupStack::PopAndDestroy(filter);
  5779 	CleanupStack::PopAndDestroy(view);
  5780 	CleanupStack::PopAndDestroy(2, active); // changeObs, active
  5781 	}
  5782 
  5783 /**
  5784 @SYMTestCaseID          SYSLIB-LOGENG-CT-4014
  5785 @SYMTestCaseDesc	    Tests CLogView::CountL works correctly after SetFilterL returns no event.
  5786 @SYMTestPriority 	    High
  5787 @SYMTestActions  	    1. ClearLog. 
  5788 						2. SetFilterL.
  5789 						3. Add events and check count.
  5790 						4. Step through the added events.
  5791 @SYMTestExpectedResults 2 - SetFilterL indicates no event in view.
  5792 						3. CountL method returns correct number of events.
  5793 						4. Can step through the added events.
  5794 						
  5795 @SYMDEF                 INC123066
  5796 */
  5797 LOCAL_C void INC123066L(CLogClient& aClient)
  5798 	{
  5799 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-4014 "));
  5800 	CLogEvent* event = CLogEvent::NewL();
  5801 	CleanupStack::PushL(event);
  5802 	event->SetEventType(KLogCallEventTypeUid);
  5803 
  5804 	CTestActive* active = new(ELeave)CTestActive();
  5805 	CleanupStack::PushL(active);
  5806 
  5807 	// deliberately not using CLogViewChangeObserver
  5808 
  5809 	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
  5810 	CleanupStack::PushL(view);
  5811 
  5812 	CLogFilter* filter = CLogFilter::NewL();
  5813 	CleanupStack::PushL(filter);
  5814 
  5815 	// Clear all the events
  5816 	TTime now;
  5817 	now.UniversalTime();
  5818 	now += TTimeIntervalDays(1);
  5819 	active->StartL();
  5820 	aClient.ClearLog(now, active->iStatus);
  5821 	CActiveScheduler::Start();
  5822 	TEST2(active->iStatus.Int(), KErrNone);
  5823 
  5824 	TBool res = view->SetFilterL(*filter, active->iStatus);
  5825 	TEST2(res, 0);
  5826 
  5827 	TInt count;
  5828 	for(count = 0; count < KTestEventNum; count++)
  5829 		{
  5830 		active->StartL();
  5831 		aClient.AddEvent(*event, active->iStatus);
  5832 		CActiveScheduler::Start();
  5833 		TEST2(active->iStatus.Int(), KErrNone);
  5834 
  5835 		TEST2(view->CountL(), count+1);
  5836 		}
  5837 
  5838 	// save the most recent logId for checking.
  5839 	TLogId lastLogId = event->Id();
  5840 
  5841 	// Can iterate over the added events
  5842 	for (count = 0; count < KTestEventNum; count++)
  5843 		{
  5844 		active->StartL();
  5845 		TEST( view->NextL(active->iStatus) );
  5846 		CActiveScheduler::Start();
  5847 		TEST2(active->iStatus.Int(), KErrNone);
  5848 
  5849 		TLogId id = view->Event().Id();
  5850 		// Most recent event is first. Oldest event is last.
  5851 		TEST2((lastLogId - count), id);
  5852 		}
  5853 
  5854 	CleanupStack::PopAndDestroy(4, event); // filter, view, active, event
  5855 
  5856 	// See same test using CLogViewRecent in TestRecentView1L.
  5857 	}
  5858 
  5859 /**
  5860 @SYMTestCaseID          PDS-LOGENG-CT-4017
  5861 @SYMTestCaseDesc	    Tests Handling of CLogViewRecent::SetRecentListL when
  5862 						Remote Party string contains single quote character
  5863 @SYMTestPriority 	    High
  5864 @SYMTestActions  	    1. Create 10 Incoming call events from 3 different 
  5865 							Remote Parties using single quotes in strings
  5866 						2. Call CLogViewRecent::SetRecentListL.
  5867 						3. Check that duplicate entries have been deleted and only 
  5868 							3 events are showm
  5869 						
  5870 @SYMTestExpectedResults SetRecentListL indicates 3 events in view					
  5871 @SYMDEF                 INC136334
  5872 */
  5873 LOCAL_C void INC136334L(CLogClient& aClient)
  5874 	{
  5875 	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-CT-4017 "));
  5876 	CLogEvent* event = CLogEvent::NewL();
  5877 	CleanupStack::PushL(event);
  5878 
  5879 	CTestActive* active = new(ELeave)CTestActive();
  5880 	CleanupStack::PushL(active);
  5881 
  5882 	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
  5883 	CleanupStack::PushL(view);
  5884 
  5885 	// Incoming
  5886 	TBuf<KLogMaxDirectionLength> buf;
  5887 	aClient.GetString(buf, R_LOG_DIR_IN);
  5888 
  5889 	event->SetEventType(KLogCallEventTypeUid);
  5890 	event->SetDirection(buf);
  5891 
  5892 	TInt count;
  5893 	//Add 10 missed calls from 3 different contacts
  5894 	//These should result in only 3 entries int he log as
  5895 	//duplicates should be deleted.
  5896 	for(count = 0; count < KTestEventNum; count++)
  5897 		{
  5898 		//Use a string with a single quote
  5899 		event->SetRemoteParty(_L("Sam's Wife"));
  5900 
  5901 		active->StartL();
  5902 		aClient.AddEvent(*event, active->iStatus);
  5903 		CActiveScheduler::Start();
  5904 		TEST2(active->iStatus.Int(), KErrNone);
  5905 		
  5906 		//Use a string with multiple single quotes
  5907 		event->SetRemoteParty(_L("'Sam's W'i'f'e'''''''"));
  5908 
  5909 		active->StartL();
  5910 		aClient.AddEvent(*event, active->iStatus);
  5911 		CActiveScheduler::Start();
  5912 		TEST2(active->iStatus.Int(), KErrNone);
  5913 		
  5914 		//Use a string with no single quotes
  5915 		event->SetRemoteParty(_L("Sams Wife"));
  5916 
  5917 		active->StartL();
  5918 		aClient.AddEvent(*event, active->iStatus);
  5919 		CActiveScheduler::Start();
  5920 		TEST2(active->iStatus.Int(), KErrNone);
  5921 		
  5922 		}	
  5923 
  5924 	TEST2(view->CountL(), 0);
  5925 	TBool res = view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus);
  5926 	TEST(res);
  5927 	
  5928 	//All of the duplicate entries should be deleted and there should 
  5929 	//only be 3 events in the log
  5930 	active->StartL();
  5931 	CActiveScheduler::Start();
  5932 	TEST2(active->iStatus.Int(), KErrNone);
  5933 	TEST2(view->CountL(), 3);
  5934 	
  5935 	//Clear the log for he next test
  5936 	aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus);
  5937 	active->StartL();
  5938 	CActiveScheduler::Start();
  5939 	TEST2(active->iStatus.Int(), KErrNone);
  5940 
  5941 	count = view->CountL();
  5942 	TEST2(count, 0);
  5943 	
  5944 	CleanupStack::PopAndDestroy(3); // view, active, event
  5945 
  5946 	}
  5947 //
  5948 //
  5949 //
  5950 void doTestsL()
  5951 	{
  5952 	TheMatchingIsEnabled = TestUtils::MatchingEnabledL();
  5953 	
  5954 	TestUtils::Initialize(_L("t_logview1"));
  5955 	TestUtils::DeleteDatabaseL();
  5956 
  5957 	CLogClient* client = CLogClient::NewL(theFs);
  5958 	CleanupStack::PushL(client);
  5959 
  5960 	CLogChangeNotifier* notifier = CLogChangeNotifier::NewL();
  5961 	CleanupStack::PushL(notifier);
  5962 
  5963 	TheTest.Start(_L("Event View With No Filter"));
  5964 
  5965 	TestEventViewL(*client);
  5966 	theLog.Write(_L8("Test 1 OK\n"));
  5967 
  5968 	TheTest.Next(_L("Event View Filter alternative"));
  5969 	TestViewFilteringDefect1L(*client);
  5970 	theLog.Write(_L8("Test 2 OK\n"));
  5971 	TheTest.Next(_L("Event View With Filter"));
  5972 	TestEventViewFilter1L(*client);
  5973 	TestEventViewFilter2L(*client);
  5974 	TheTest.Next(_L("INC123066 - LogView not updated if SetFilterL found no event"));
  5975 	INC123066L(*client);
  5976 	theLog.Write(_L8("Test 3 OK\n"));
  5977 	
  5978 	TheTest.Next(_L("Recent View"));
  5979 	TestRecentView1L(*client);
  5980 	TestRecentView2L(*client);
  5981 	theLog.Write(_L8("Test 4 OK\n"));
  5982 
  5983 	TheTest.Next(_L("Removing recent events"));
  5984 	TestRecentRemove1L(*client);
  5985 	TestRecentRemove2L(*client);
  5986 	theLog.Write(_L8("Test 5 OK\n"));
  5987 
  5988 	TheTest.Next(_L("Duplicate View"));
  5989 	TestDuplicateViewL(*client);
  5990 	theLog.Write(_L8("Test 6 OK\n"));
  5991 
  5992 	TheTest.Next(_L("Removing duplicate events"));
  5993 	TestDuplicateRemoveL(*client);
  5994 	theLog.Write(_L8("Test 7 OK\n"));
  5995 
  5996 	TheTest.Next(_L("Check purge performed on view setup"));
  5997 	TestPurgeOnSetup1L(*client); 
  5998 	TestPurgeOnSetup2L(*client);
  5999 	theLog.Write(_L8("Test 8 OK\n"));
  6000 
  6001 	TheTest.Next(_L("View Purging"));
  6002 	TestViewPurgeL(*client);
  6003 	theLog.Write(_L8("Test 9 OK\n"));
  6004 
  6005 	TheTest.Next(_L("Clearing duplicate lists"));
  6006 	TestClearDuplicatesL(*client);
  6007 	theLog.Write(_L8("Test 10 OK\n"));
  6008 
  6009 	TheTest.Next(_L("Phone number matching"));
  6010 	TestPhoneNumberMatchingL(*client);
  6011 	theLog.Write(_L8("Test 11 OK\n"));	
  6012 
  6013 	TheTest.Next(_L("view flags setting/clearing"));
  6014 	TestViewFlagsL(*client);
  6015 	theLog.Write(_L8("Test 12 OK\n"));
  6016 
  6017 	TheTest.Next(_L("Recent view flags setting/clearing"));
  6018 	TestRecentFlagsL(*client);
  6019 	theLog.Write(_L8("Test 13 OK\n"));
  6020 
  6021 	TheTest.Next(_L("View change tests 1"));
  6022 	TestViewChangeEvents1L(*client);
  6023 	TestViewChangeEvents1aL(*client);
  6024 	theLog.Write(_L8("Test 14 OK\n"));
  6025 
  6026 	TheTest.Next(_L("View change tests 2"));
  6027 	TestViewChangeEvents2L(*client);
  6028 	TestViewChangeEvents2aL(*client);
  6029 	theLog.Write(_L8("Test 15 OK\n"));
  6030 
  6031 	TheTest.Next(_L("View deletion from within callback"));
  6032 	TestDeletingViewWithinObserverCallbackL(*client);
  6033 	theLog.Write(_L8("Test 16 OK\n"));
  6034 
  6035 	TheTest.Next(_L("Test navigation whilst events are added"));
  6036 	TestNavigationWhilstBusyL(*client);
  6037 	theLog.Write(_L8("Test 17 OK\n"));
  6038 	
  6039 	TheTest.Next(_L("Defect INC105010 - phone number matching"));
  6040 	INC105010L(*client);
  6041 	theLog.Write(_L8("Test 18 OK\n"));
  6042 
  6043 	TheTest.Next(_L("INC136334 - The miss call log won't show if you have  '  in your contact"));
  6044 	INC136334L(*client);
  6045 	theLog.Write(_L8("Test 19 OK\n"));
  6046 
  6047 	CleanupStack::PopAndDestroy(2); // notifier, client;
  6048 	}