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