os/persistentdata/loggingservices/eventlogger/test/src/t_logpurge.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) 2003-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
sl@0
    16
#include <s32file.h>
sl@0
    17
#include "t_logutil2.h"
sl@0
    18
#include <logview.h>
sl@0
    19
sl@0
    20
RTest TheTest(_L("t_logpurge"));
sl@0
    21
sl@0
    22
const TInt KTestEventNum = 10;
sl@0
    23
const TInt KTestEventAge = 5;
sl@0
    24
const TInt KTestRecentNum = 10;
sl@0
    25
const TInt KTestDuplicateNum = 10;
sl@0
    26
sl@0
    27
_LIT(KTestRemoteParty, "Test Remote Party %d");
sl@0
    28
sl@0
    29
/**
sl@0
    30
@SYMTestCaseID          SYSLIB-LOGENG-CT-0875
sl@0
    31
@SYMTestCaseDesc	    Tests for maximum logging of configuration data 
sl@0
    32
@SYMTestPriority 	    High
sl@0
    33
@SYMTestActions  	    Get the event type configuration data.Set the log size to maximum.
sl@0
    34
                        Change the log engine configuration data with the new one.Add events to the log
sl@0
    35
                        Set the filter on the view and check for KErrNone flag.
sl@0
    36
						Add a new event and disable logging by setting the maximum logging size to zero
sl@0
    37
						Clear all the events and test for KErrNone and the total count of events.
sl@0
    38
@SYMTestExpectedResults Test must not fail
sl@0
    39
@SYMREQ                 REQ0000
sl@0
    40
*/
sl@0
    41
LOCAL_C void TestMaxLogSizeL(CLogClient& aClient)
sl@0
    42
	{
sl@0
    43
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0875 "));
sl@0
    44
	CLogEvent* event = CLogEvent::NewL();
sl@0
    45
	CleanupStack::PushL(event);
sl@0
    46
	event->SetEventType(KLogCallEventTypeUid);
sl@0
    47
sl@0
    48
	CTestActive* active = new(ELeave)CTestActive();
sl@0
    49
	CleanupStack::PushL(active);
sl@0
    50
sl@0
    51
	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
sl@0
    52
	CleanupStack::PushL(view);
sl@0
    53
sl@0
    54
	CLogFilter* filter = CLogFilter::NewL();
sl@0
    55
	CleanupStack::PushL(filter);
sl@0
    56
sl@0
    57
	TLogConfig config;
sl@0
    58
sl@0
    59
	// Get log configuration
sl@0
    60
	active->StartL();
sl@0
    61
	aClient.GetConfig(config, active->iStatus);
sl@0
    62
	CActiveScheduler::Start();
sl@0
    63
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
    64
sl@0
    65
	// Set the maximum log size
sl@0
    66
	config.iMaxLogSize = KTestEventNum;
sl@0
    67
sl@0
    68
	// Change the log engine config
sl@0
    69
	active->StartL();
sl@0
    70
	aClient.ChangeConfig(config, active->iStatus);
sl@0
    71
	CActiveScheduler::Start();
sl@0
    72
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
    73
sl@0
    74
	// Initialise the view - There should be no events
sl@0
    75
	TEST(!view->SetFilterL(*filter, active->iStatus));
sl@0
    76
sl@0
    77
	// Add the number of allowed events
sl@0
    78
	TInt count;
sl@0
    79
	for(count = 0; count < KTestEventNum; count++)
sl@0
    80
		{
sl@0
    81
		active->StartL();
sl@0
    82
		aClient.AddEvent(*event, active->iStatus);
sl@0
    83
		CActiveScheduler::Start();
sl@0
    84
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
    85
		}
sl@0
    86
sl@0
    87
	TEST(view->SetFilterL(*filter, active->iStatus));
sl@0
    88
	active->StartL();
sl@0
    89
	CActiveScheduler::Start();
sl@0
    90
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
    91
sl@0
    92
	// The view should now have the correct number of events
sl@0
    93
	TEST(view->CountL() == KTestEventNum);
sl@0
    94
sl@0
    95
	// Add the same number of events again - the old ones should be deleted
sl@0
    96
	for(count = 0; count < KTestEventNum; count++)
sl@0
    97
		{
sl@0
    98
		TEST(view->SetFilterL(*filter, active->iStatus));
sl@0
    99
		active->StartL();
sl@0
   100
		CActiveScheduler::Start();
sl@0
   101
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   102
sl@0
   103
		// Get the last (oldest) event
sl@0
   104
		active->StartL();
sl@0
   105
		view->LastL(active->iStatus);
sl@0
   106
		CActiveScheduler::Start();
sl@0
   107
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   108
sl@0
   109
		// Remember the Id
sl@0
   110
		TLogId id = view->Event().Id();
sl@0
   111
sl@0
   112
		// Add another event - the oldest should be removed
sl@0
   113
		active->StartL();
sl@0
   114
		aClient.AddEvent(*event, active->iStatus);
sl@0
   115
		CActiveScheduler::Start();
sl@0
   116
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   117
sl@0
   118
		// There should be the same number of events in view
sl@0
   119
		TEST(view->CountL() == KTestEventNum);
sl@0
   120
		
sl@0
   121
		event->SetId(id);
sl@0
   122
sl@0
   123
		// Try and get the old event
sl@0
   124
		active->StartL();
sl@0
   125
		aClient.GetEvent(*event, active->iStatus);
sl@0
   126
		CActiveScheduler::Start();
sl@0
   127
		TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
   128
		}
sl@0
   129
sl@0
   130
	// Add an event
sl@0
   131
	active->StartL();
sl@0
   132
	aClient.AddEvent(*event, active->iStatus);
sl@0
   133
	CActiveScheduler::Start();
sl@0
   134
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   135
sl@0
   136
	// Check it's there
sl@0
   137
	active->StartL();
sl@0
   138
	aClient.GetEvent(*event, active->iStatus);
sl@0
   139
	CActiveScheduler::Start();
sl@0
   140
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   141
sl@0
   142
	// Set the maximum log size to zero, i.e. disable logging
sl@0
   143
	config.iMaxLogSize = 0;
sl@0
   144
sl@0
   145
	// Change the log engine config
sl@0
   146
	active->StartL();
sl@0
   147
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   148
	CActiveScheduler::Start();
sl@0
   149
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   150
sl@0
   151
	// Check the event has gone
sl@0
   152
	active->StartL();
sl@0
   153
	aClient.GetEvent(*event, active->iStatus);
sl@0
   154
	CActiveScheduler::Start();
sl@0
   155
	TEST2(active->iStatus.Int(), KErrNotFound);;
sl@0
   156
sl@0
   157
	// Add an event
sl@0
   158
	active->StartL();
sl@0
   159
	aClient.AddEvent(*event, active->iStatus);
sl@0
   160
	CActiveScheduler::Start();
sl@0
   161
	TEST2(active->iStatus.Int(), KErrNotSupported);
sl@0
   162
sl@0
   163
	// Check that event doesn't exist
sl@0
   164
	active->StartL();
sl@0
   165
	aClient.GetEvent(*event, active->iStatus);
sl@0
   166
	CActiveScheduler::Start();
sl@0
   167
	TEST2(active->iStatus.Int(), KErrNotFound);;
sl@0
   168
sl@0
   169
	User::After(1000000);
sl@0
   170
sl@0
   171
	TTime now;
sl@0
   172
	now.UniversalTime();
sl@0
   173
	now+=(TTimeIntervalDays) 1;
sl@0
   174
	// Clear all the events
sl@0
   175
	active->StartL();
sl@0
   176
	aClient.ClearLog(now, active->iStatus);
sl@0
   177
	CActiveScheduler::Start();
sl@0
   178
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   179
sl@0
   180
	TEST(!view->SetFilterL(*filter, active->iStatus));
sl@0
   181
	TEST(view->CountL() == 0);
sl@0
   182
sl@0
   183
	CleanupStack::PopAndDestroy(4); // filter, view, active, event
sl@0
   184
	}
sl@0
   185
sl@0
   186
/**
sl@0
   187
@SYMTestCaseID          SYSLIB-LOGENG-CT-0876
sl@0
   188
@SYMTestCaseDesc	    Tests for maximum logging of configuration data 
sl@0
   189
@SYMTestPriority 	    High
sl@0
   190
@SYMTestActions  	    Get the event type configuration data.Set the log size to maximum.
sl@0
   191
                        Change the log engine configuration data and add the number of allowed events
sl@0
   192
                        Reduce the number of allowed events.The old ones should be purged
sl@0
   193
						Change the log engine config and check for the event count.
sl@0
   194
@SYMTestExpectedResults Test must not fail
sl@0
   195
@SYMREQ                 REQ0000
sl@0
   196
*/
sl@0
   197
LOCAL_C void TestMaxLogSizeConfigL(CLogClient& aClient)
sl@0
   198
	{
sl@0
   199
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0876 "));
sl@0
   200
	CLogEvent* event = CLogEvent::NewL();
sl@0
   201
	CleanupStack::PushL(event);
sl@0
   202
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   203
sl@0
   204
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   205
	CleanupStack::PushL(active);
sl@0
   206
sl@0
   207
	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
sl@0
   208
	CleanupStack::PushL(view);
sl@0
   209
sl@0
   210
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   211
	CleanupStack::PushL(filter);
sl@0
   212
sl@0
   213
	TLogConfig config;
sl@0
   214
sl@0
   215
	// Get log configuration
sl@0
   216
	active->StartL();
sl@0
   217
	aClient.GetConfig(config, active->iStatus);
sl@0
   218
	CActiveScheduler::Start();
sl@0
   219
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   220
sl@0
   221
	// Set the maximum log size
sl@0
   222
	config.iMaxLogSize = KTestEventNum;
sl@0
   223
sl@0
   224
	// Change the log engine config
sl@0
   225
	active->StartL();
sl@0
   226
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   227
	CActiveScheduler::Start();
sl@0
   228
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   229
sl@0
   230
	// Initialise the view - There should be no events
sl@0
   231
	TEST(!view->SetFilterL(*filter, active->iStatus));
sl@0
   232
sl@0
   233
	// Add the number of allowed events
sl@0
   234
	TInt count;
sl@0
   235
	for(count = 0; count < KTestEventNum; count++)
sl@0
   236
		{
sl@0
   237
		active->StartL();
sl@0
   238
		aClient.AddEvent(*event, active->iStatus);
sl@0
   239
		CActiveScheduler::Start();
sl@0
   240
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   241
		}
sl@0
   242
sl@0
   243
	TEST(view->SetFilterL(*filter, active->iStatus));
sl@0
   244
	active->StartL();
sl@0
   245
	CActiveScheduler::Start();
sl@0
   246
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   247
sl@0
   248
	// The view should now have the correct number of events
sl@0
   249
	TEST(view->CountL() == KTestEventNum);
sl@0
   250
sl@0
   251
	// Reduce the number of allowed events
sl@0
   252
	// The old ones should be purged
sl@0
   253
	config.iMaxLogSize = KTestEventNum / 2;
sl@0
   254
sl@0
   255
	// Change the log engine config
sl@0
   256
	active->StartL();
sl@0
   257
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   258
	CActiveScheduler::Start();
sl@0
   259
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   260
sl@0
   261
	// Check the event count
sl@0
   262
	TEST(view->SetFilterL(*filter, active->iStatus));
sl@0
   263
	active->StartL();
sl@0
   264
	CActiveScheduler::Start();
sl@0
   265
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   266
	TEST(view->CountL() == KTestEventNum / 2);
sl@0
   267
		
sl@0
   268
	User::After(0x1000000);
sl@0
   269
sl@0
   270
	TTime now;
sl@0
   271
	now.UniversalTime();
sl@0
   272
	now+=(TTimeIntervalDays )1;
sl@0
   273
	// Clear all the events
sl@0
   274
	active->StartL();
sl@0
   275
	aClient.ClearLog(now, active->iStatus);
sl@0
   276
	CActiveScheduler::Start();
sl@0
   277
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   278
sl@0
   279
	TEST(!view->SetFilterL(*filter, active->iStatus));
sl@0
   280
	TEST(view->CountL() == 0);
sl@0
   281
sl@0
   282
	CleanupStack::PopAndDestroy(4); // filter, view, active, event
sl@0
   283
	}
sl@0
   284
sl@0
   285
/**
sl@0
   286
@SYMTestCaseID          SYSLIB-LOGENG-CT-0877
sl@0
   287
@SYMTestCaseDesc	    Tests for maximum time for which events can be retained in the log
sl@0
   288
@SYMTestPriority 	    High
sl@0
   289
@SYMTestActions  	    Get the event type configuration data.Set maximum log age.
sl@0
   290
                        Change the log engine configuration data with the new one.Add events to the log
sl@0
   291
                        Set the date and time of events clear the log and check for errors
sl@0
   292
@SYMTestExpectedResults Test must not fail
sl@0
   293
@SYMREQ                 REQ0000
sl@0
   294
*/
sl@0
   295
LOCAL_C void TestMaxLogAgeL(CLogClient& aClient, TLogAge aMaxLogAge)
sl@0
   296
	{
sl@0
   297
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0877 "));
sl@0
   298
	CLogEvent* event = CLogEvent::NewL();
sl@0
   299
	CleanupStack::PushL(event);
sl@0
   300
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   301
sl@0
   302
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   303
	CleanupStack::PushL(active);
sl@0
   304
sl@0
   305
	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
sl@0
   306
	CleanupStack::PushL(view);
sl@0
   307
sl@0
   308
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   309
	CleanupStack::PushL(filter);
sl@0
   310
sl@0
   311
	TLogConfig config;
sl@0
   312
sl@0
   313
	// Get log configuration
sl@0
   314
	active->StartL();
sl@0
   315
	aClient.GetConfig(config, active->iStatus);
sl@0
   316
	CActiveScheduler::Start();
sl@0
   317
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   318
sl@0
   319
	// Set the maximum log age
sl@0
   320
	config.iMaxLogSize = KTestEventAge * 2;
sl@0
   321
	config.iMaxEventAge = aMaxLogAge;
sl@0
   322
sl@0
   323
	// Change the log engine config
sl@0
   324
	active->StartL();
sl@0
   325
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   326
	CActiveScheduler::Start();
sl@0
   327
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   328
sl@0
   329
	// Initialise the view - There should be no events
sl@0
   330
	TEST(!view->SetFilterL(*filter, active->iStatus));
sl@0
   331
sl@0
   332
	TTime date;
sl@0
   333
	date.UniversalTime();
sl@0
   334
sl@0
   335
	// Wait a second
sl@0
   336
	User::After(0x1000000);
sl@0
   337
sl@0
   338
	// Add events
sl@0
   339
	TInt count;
sl@0
   340
	for(count = 0; count < KTestEventAge * 2; count++)
sl@0
   341
		{
sl@0
   342
		active->StartL();
sl@0
   343
		aClient.AddEvent(*event, active->iStatus);
sl@0
   344
		CActiveScheduler::Start();
sl@0
   345
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   346
sl@0
   347
		// Set the time and date of the event
sl@0
   348
		event->SetTime(date);
sl@0
   349
		date -= TTimeIntervalDays(1);
sl@0
   350
sl@0
   351
		active->StartL();
sl@0
   352
		aClient.ChangeEvent(*event, active->iStatus);
sl@0
   353
		CActiveScheduler::Start();
sl@0
   354
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   355
		User::After(1000000);
sl@0
   356
sl@0
   357
		TEST(view->SetFilterL(*filter, active->iStatus));
sl@0
   358
		active->StartL();
sl@0
   359
		CActiveScheduler::Start();
sl@0
   360
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   361
sl@0
   362
		// Check the old events have been removed
sl@0
   363
		if ((count < KTestEventAge) || !aMaxLogAge)
sl@0
   364
			TEST(view->CountL() == count + 1);
sl@0
   365
		else
sl@0
   366
			TEST(view->CountL() == KTestEventAge);
sl@0
   367
		}
sl@0
   368
sl@0
   369
	User::After(0x1000000);
sl@0
   370
	date.UniversalTime();
sl@0
   371
sl@0
   372
	date+=(TTimeIntervalYears )1;
sl@0
   373
sl@0
   374
	// Clear all the events
sl@0
   375
	active->StartL();
sl@0
   376
	aClient.ClearLog(date, active->iStatus);
sl@0
   377
	CActiveScheduler::Start();
sl@0
   378
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   379
sl@0
   380
	TEST(!view->SetFilterL(*filter, active->iStatus));
sl@0
   381
	TEST(view->CountL() == 0);
sl@0
   382
sl@0
   383
	CleanupStack::PopAndDestroy(4); // filter, view, active, event
sl@0
   384
	}
sl@0
   385
sl@0
   386
/**
sl@0
   387
@SYMTestCaseID          SYSLIB-LOGENG-CT-0878
sl@0
   388
@SYMTestCaseDesc	    Tests for maximum number of events that a recent event list holds
sl@0
   389
@SYMTestPriority 	    High
sl@0
   390
@SYMTestActions  	    Set the event configuration data of recent log size(10) to maximum and 
sl@0
   391
						Add events to the log.Set the filter on the view and check for NO error.
sl@0
   392
						Add a new event and disable logging by setting the maximum logging size to zero
sl@0
   393
						Clear all the events and test for no errors and the total count of events and the logviewrecent should be zero.
sl@0
   394
@SYMTestExpectedResults Test must not fail
sl@0
   395
@SYMREQ                 REQ0000
sl@0
   396
*/
sl@0
   397
LOCAL_C void TestMaxRecentSize1L(CLogClient& aClient)
sl@0
   398
	{
sl@0
   399
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0878 "));
sl@0
   400
	CLogEvent* event = CLogEvent::NewL();
sl@0
   401
	CleanupStack::PushL(event);
sl@0
   402
sl@0
   403
	// Incoming
sl@0
   404
	TBuf<KLogMaxDirectionLength> buf;
sl@0
   405
	aClient.GetString(buf, R_LOG_DIR_IN);
sl@0
   406
sl@0
   407
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   408
	event->SetDirection(buf);
sl@0
   409
sl@0
   410
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   411
	CleanupStack::PushL(active);
sl@0
   412
sl@0
   413
	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
sl@0
   414
	CleanupStack::PushL(view);
sl@0
   415
sl@0
   416
	CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
sl@0
   417
	CleanupStack::PushL(recent);
sl@0
   418
sl@0
   419
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   420
	CleanupStack::PushL(filter);
sl@0
   421
sl@0
   422
	TLogConfig config;
sl@0
   423
sl@0
   424
	// Get log configuration
sl@0
   425
	active->StartL();
sl@0
   426
	aClient.GetConfig(config, active->iStatus);
sl@0
   427
	CActiveScheduler::Start();
sl@0
   428
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   429
sl@0
   430
	// Set the maximum log size
sl@0
   431
	config.iMaxLogSize = KTestRecentNum * 2;
sl@0
   432
	config.iMaxRecentLogSize = KTestRecentNum;
sl@0
   433
sl@0
   434
	// Change the log engine config
sl@0
   435
	active->StartL();
sl@0
   436
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   437
	CActiveScheduler::Start();
sl@0
   438
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   439
sl@0
   440
	// Initialise the views - There should be no events
sl@0
   441
	TEST(!view->SetFilterL(*filter, active->iStatus));
sl@0
   442
	TEST(!recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   443
sl@0
   444
	// Add a number of events
sl@0
   445
	TInt count;
sl@0
   446
	for(count = 0; count < KTestRecentNum; count++)
sl@0
   447
		{
sl@0
   448
		event->SetContact(count);
sl@0
   449
sl@0
   450
		active->StartL();
sl@0
   451
		aClient.AddEvent(*event, active->iStatus);
sl@0
   452
		CActiveScheduler::Start();
sl@0
   453
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   454
		}
sl@0
   455
sl@0
   456
	TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   457
	active->StartL();
sl@0
   458
	CActiveScheduler::Start();
sl@0
   459
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   460
sl@0
   461
	TEST(recent->CountL() == KTestRecentNum);
sl@0
   462
sl@0
   463
	// Add the same number of events again - the old ones should be removed
sl@0
   464
	for(count = 0; count < KTestRecentNum; count++)
sl@0
   465
		{
sl@0
   466
		// Add another event - the oldest should be removed from recent list
sl@0
   467
		active->StartL();
sl@0
   468
		aClient.AddEvent(*event, active->iStatus);
sl@0
   469
		CActiveScheduler::Start();
sl@0
   470
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   471
sl@0
   472
		TEST(view->SetFilterL(*filter, active->iStatus));
sl@0
   473
		active->StartL();
sl@0
   474
		CActiveScheduler::Start();
sl@0
   475
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   476
sl@0
   477
		TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   478
		active->StartL();
sl@0
   479
		CActiveScheduler::Start();
sl@0
   480
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   481
sl@0
   482
		// Check an event has been removed from recent view
sl@0
   483
		TEST(recent->CountL() == KTestRecentNum);
sl@0
   484
		TEST(view->CountL() == count + KTestRecentNum + 1);
sl@0
   485
		}
sl@0
   486
sl@0
   487
	User::After(0x1000000);
sl@0
   488
sl@0
   489
	TTime now;
sl@0
   490
	now.UniversalTime();
sl@0
   491
	now+=(TTimeIntervalDays )1;
sl@0
   492
sl@0
   493
	// Clear all the events
sl@0
   494
	active->StartL();
sl@0
   495
	aClient.ClearLog(now, active->iStatus);
sl@0
   496
	CActiveScheduler::Start();
sl@0
   497
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   498
sl@0
   499
	TEST(!view->SetFilterL(*filter, active->iStatus));
sl@0
   500
	TEST(!recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   501
	TEST(view->CountL() == 0 && recent->CountL() == 0);
sl@0
   502
sl@0
   503
	CleanupStack::PopAndDestroy(5); // filter, recent, view, active, event
sl@0
   504
	}
sl@0
   505
sl@0
   506
/**
sl@0
   507
@SYMTestCaseID          SYSLIB-LOGENG-CT-0879
sl@0
   508
@SYMTestCaseDesc	    Tests for maximum number of events that a recent event list holds
sl@0
   509
@SYMTestPriority 	    High
sl@0
   510
@SYMTestActions  	    Set the event configuration data of recent log size(10) to maximum and 
sl@0
   511
						Add events to the log.Set the filter on the view and check for NO error.
sl@0
   512
	                    Reduce the recent log size(5)  and set the new configuration.
sl@0
   513
						Clear all the events and test for no errors and the total count of events and the logviewrecent should be zero.
sl@0
   514
						Tests for CLogViewRecent::SetRecentListL
sl@0
   515
@SYMTestExpectedResults Test must not fail
sl@0
   516
@SYMREQ                 REQ0000
sl@0
   517
*/
sl@0
   518
LOCAL_C void TestMaxRecentSizeConfigL(CLogClient& aClient)
sl@0
   519
	{
sl@0
   520
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0879 "));
sl@0
   521
	CLogEvent* event = CLogEvent::NewL();
sl@0
   522
	CleanupStack::PushL(event);
sl@0
   523
sl@0
   524
	// Incoming
sl@0
   525
	TBuf<KLogMaxDirectionLength> buf;
sl@0
   526
	aClient.GetString(buf, R_LOG_DIR_IN);
sl@0
   527
sl@0
   528
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   529
	event->SetDirection(buf);
sl@0
   530
sl@0
   531
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   532
	CleanupStack::PushL(active);
sl@0
   533
sl@0
   534
	CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
sl@0
   535
	CleanupStack::PushL(recent);
sl@0
   536
sl@0
   537
	TLogConfig config;
sl@0
   538
sl@0
   539
	// Get log configuration
sl@0
   540
	active->StartL();
sl@0
   541
	aClient.GetConfig(config, active->iStatus);
sl@0
   542
	CActiveScheduler::Start();
sl@0
   543
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   544
sl@0
   545
	// Set the maximum log size
sl@0
   546
	config.iMaxLogSize = KTestRecentNum * 2;
sl@0
   547
	config.iMaxRecentLogSize = KTestRecentNum;
sl@0
   548
sl@0
   549
	// Change the log engine config
sl@0
   550
	active->StartL();
sl@0
   551
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   552
	CActiveScheduler::Start();
sl@0
   553
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   554
sl@0
   555
	// Initialise the views - There should be no events
sl@0
   556
	TEST(!recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   557
sl@0
   558
	// Add a number of events
sl@0
   559
	TInt count;
sl@0
   560
	for(count = 0; count < KTestRecentNum; count++)
sl@0
   561
		{
sl@0
   562
		event->SetContact(count);
sl@0
   563
sl@0
   564
		active->StartL();
sl@0
   565
		aClient.AddEvent(*event, active->iStatus);
sl@0
   566
		CActiveScheduler::Start();
sl@0
   567
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   568
		}
sl@0
   569
sl@0
   570
	TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   571
	active->StartL();
sl@0
   572
	CActiveScheduler::Start();
sl@0
   573
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   574
sl@0
   575
	TEST(recent->CountL() == KTestRecentNum);
sl@0
   576
sl@0
   577
	// Reduce the maximum allowed recent list size
sl@0
   578
	// The oldest ones should be removed
sl@0
   579
	config.iMaxRecentLogSize = KTestRecentNum / 2;
sl@0
   580
sl@0
   581
	active->StartL();
sl@0
   582
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   583
	CActiveScheduler::Start();
sl@0
   584
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   585
sl@0
   586
	TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   587
	active->StartL();
sl@0
   588
	CActiveScheduler::Start();
sl@0
   589
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   590
sl@0
   591
	TEST(recent->CountL() == KTestRecentNum / 2);
sl@0
   592
	User::After(0x1000000);
sl@0
   593
sl@0
   594
	TTime now;
sl@0
   595
	now.UniversalTime();
sl@0
   596
	now+=(TTimeIntervalDays )1;
sl@0
   597
sl@0
   598
	// Clear all the events
sl@0
   599
	active->StartL();
sl@0
   600
	aClient.ClearLog(now, active->iStatus);
sl@0
   601
	CActiveScheduler::Start();
sl@0
   602
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   603
sl@0
   604
	TEST(!recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   605
	TEST(recent->CountL() == 0);
sl@0
   606
sl@0
   607
	CleanupStack::PopAndDestroy(3); // recent, active, event
sl@0
   608
	}
sl@0
   609
sl@0
   610
/**
sl@0
   611
@SYMTestCaseID          SYSLIB-LOGENG-CT-0880
sl@0
   612
@SYMTestCaseDesc	    Tests for CLogViewRecent::SetRecentListL(),CLogViewRecent::DuplicatesL() functions
sl@0
   613
@SYMTestPriority 	    High
sl@0
   614
@SYMTestActions  	    Set the event configuration data of recent log size(10) to maximum and 
sl@0
   615
						Add events to the log.Set the filter on the view and check for NO error.
sl@0
   616
	                    Reduce the recent log size(5)  and set the new configuration.
sl@0
   617
						Clear all the events and test for no errors and the total count of events and the logviewrecent should be zero.
sl@0
   618
						Tests for CLogViewRecent::SetRecentListL()
sl@0
   619
@SYMTestExpectedResults Test must not fail
sl@0
   620
@SYMREQ                 REQ0000
sl@0
   621
*/
sl@0
   622
LOCAL_C void TestMaxRecentSize2L(CLogClient& aClient)
sl@0
   623
	{
sl@0
   624
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0880 "));
sl@0
   625
	CLogEvent* event = CLogEvent::NewL();
sl@0
   626
	CleanupStack::PushL(event);
sl@0
   627
sl@0
   628
	// Incoming
sl@0
   629
	TBuf<KLogMaxDirectionLength> buf;
sl@0
   630
	aClient.GetString(buf, R_LOG_DIR_IN);
sl@0
   631
sl@0
   632
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   633
	event->SetDirection(buf);
sl@0
   634
sl@0
   635
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   636
	CleanupStack::PushL(active);
sl@0
   637
sl@0
   638
	CLogViewRecent* recent = CLogViewRecent::NewL(aClient);
sl@0
   639
	CleanupStack::PushL(recent);
sl@0
   640
sl@0
   641
	CLogViewDuplicate* dup = CLogViewDuplicate::NewL(aClient);
sl@0
   642
	CleanupStack::PushL(dup);
sl@0
   643
sl@0
   644
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   645
	CleanupStack::PushL(filter);
sl@0
   646
sl@0
   647
	TLogConfig config;
sl@0
   648
sl@0
   649
	// Get log configuration
sl@0
   650
	active->StartL();
sl@0
   651
	aClient.GetConfig(config, active->iStatus);
sl@0
   652
	CActiveScheduler::Start();
sl@0
   653
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   654
sl@0
   655
	// Set the maximum log size
sl@0
   656
	config.iMaxLogSize = (KTestRecentNum * KTestDuplicateNum) * 2;
sl@0
   657
	config.iMaxRecentLogSize = KTestRecentNum;
sl@0
   658
sl@0
   659
	// Change the log engine config
sl@0
   660
	active->StartL();
sl@0
   661
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   662
	CActiveScheduler::Start();
sl@0
   663
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   664
sl@0
   665
	// Initialise the view - There should be no events
sl@0
   666
	TEST(!recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   667
sl@0
   668
	// Add a number of events
sl@0
   669
	TInt count;
sl@0
   670
	for(count = 0; count < KTestRecentNum; count++)
sl@0
   671
		{
sl@0
   672
		TBuf<KLogMaxRemotePartyLength> buf;
sl@0
   673
		buf.Format(KTestRemoteParty, count);
sl@0
   674
		event->SetRemoteParty(buf);
sl@0
   675
sl@0
   676
		active->StartL();
sl@0
   677
		aClient.AddEvent(*event, active->iStatus);
sl@0
   678
		CActiveScheduler::Start();
sl@0
   679
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   680
sl@0
   681
		// Add some duplicates
sl@0
   682
		TInt duplicate;
sl@0
   683
		for(duplicate = 0; duplicate < KTestDuplicateNum; duplicate++)
sl@0
   684
			{
sl@0
   685
			active->StartL();
sl@0
   686
			aClient.AddEvent(*event, active->iStatus);
sl@0
   687
			CActiveScheduler::Start();
sl@0
   688
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
   689
			}
sl@0
   690
sl@0
   691
		// The views should now have the correct number of events
sl@0
   692
		TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   693
		active->StartL();
sl@0
   694
		CActiveScheduler::Start();
sl@0
   695
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   696
sl@0
   697
		TEST(recent->CountL() == count + 1);
sl@0
   698
sl@0
   699
		TEST(recent->DuplicatesL(*dup, active->iStatus));
sl@0
   700
		active->StartL();
sl@0
   701
		CActiveScheduler::Start();
sl@0
   702
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   703
sl@0
   704
		TEST(dup->CountL() == KTestDuplicateNum);
sl@0
   705
		}
sl@0
   706
sl@0
   707
	event->SetRemoteParty(KNullDesC);
sl@0
   708
sl@0
   709
	// Add the more events - the old ones should be removed
sl@0
   710
	for(count = 0; count < KTestRecentNum; count++)
sl@0
   711
		{
sl@0
   712
		// Add another event - the oldest should be removed from recent list
sl@0
   713
		active->StartL();
sl@0
   714
		aClient.AddEvent(*event, active->iStatus);
sl@0
   715
		CActiveScheduler::Start();
sl@0
   716
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   717
sl@0
   718
		TEST(recent->SetRecentListL(KLogRecentIncomingCalls, active->iStatus));
sl@0
   719
		active->StartL();
sl@0
   720
		CActiveScheduler::Start();
sl@0
   721
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   722
sl@0
   723
		// Check an event has been removed from recent view
sl@0
   724
		TEST(recent->CountL() == KTestRecentNum);
sl@0
   725
		}
sl@0
   726
sl@0
   727
	User::After(0x1000000);
sl@0
   728
sl@0
   729
	TTime now;
sl@0
   730
	now.UniversalTime();
sl@0
   731
	now+=(TTimeIntervalDays )1;
sl@0
   732
sl@0
   733
	// Clear all the events
sl@0
   734
	active->StartL();
sl@0
   735
	aClient.ClearLog(now, active->iStatus);
sl@0
   736
	CActiveScheduler::Start();
sl@0
   737
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   738
sl@0
   739
	TEST(!recent->DuplicatesL(*dup, active->iStatus));
sl@0
   740
sl@0
   741
	CleanupStack::PopAndDestroy(5); // filter, dup, recent, active, event
sl@0
   742
	}
sl@0
   743
sl@0
   744
/**
sl@0
   745
@SYMTestCaseID          SYSLIB-LOGENG-CT-0881
sl@0
   746
@SYMTestCaseDesc	    Tests for purge
sl@0
   747
@SYMTestPriority 	    High
sl@0
   748
@SYMTestActions  	    Get the event type data 
sl@0
   749
@SYMTestExpectedResults Test must not fail
sl@0
   750
@SYMREQ                 REQ0000
sl@0
   751
*/
sl@0
   752
LOCAL_C void TestNoPurgeWithGetL(CLogClient& aClient)
sl@0
   753
	{
sl@0
   754
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0881 "));
sl@0
   755
	CLogEvent* event = CLogEvent::NewL();
sl@0
   756
	CleanupStack::PushL(event);
sl@0
   757
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   758
sl@0
   759
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   760
	CleanupStack::PushL(active);
sl@0
   761
sl@0
   762
	TLogConfig config;
sl@0
   763
sl@0
   764
	// Get log configuration
sl@0
   765
	active->StartL();
sl@0
   766
	aClient.GetConfig(config, active->iStatus);
sl@0
   767
	CActiveScheduler::Start();
sl@0
   768
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   769
sl@0
   770
	// Set the maximum log age
sl@0
   771
	TInt oldAge = config.iMaxEventAge;
sl@0
   772
	config.iMaxEventAge = 24 * 60 * 60;
sl@0
   773
sl@0
   774
	// Change the log engine config
sl@0
   775
	active->StartL();
sl@0
   776
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   777
	CActiveScheduler::Start();
sl@0
   778
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   779
sl@0
   780
	active->StartL();
sl@0
   781
	aClient.AddEvent(*event, active->iStatus);
sl@0
   782
	CActiveScheduler::Start();
sl@0
   783
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   784
sl@0
   785
	// Check that the event can be retrieved
sl@0
   786
	active->StartL();
sl@0
   787
	aClient.GetEvent(*event, active->iStatus);
sl@0
   788
	CActiveScheduler::Start();
sl@0
   789
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   790
sl@0
   791
	// Wait for 15 seconds (just to be safe)
sl@0
   792
	User::After(15000000);
sl@0
   793
sl@0
   794
	// Check that the event can still be retrieved
sl@0
   795
	active->StartL();
sl@0
   796
	aClient.GetEvent(*event, active->iStatus);
sl@0
   797
	CActiveScheduler::Start();
sl@0
   798
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   799
sl@0
   800
	// Perform a dummy change
sl@0
   801
	event->SetTime(event->Time() - TTimeIntervalDays(2));
sl@0
   802
	active->StartL();
sl@0
   803
	aClient.ChangeEvent(*event, active->iStatus);
sl@0
   804
	CActiveScheduler::Start();
sl@0
   805
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   806
sl@0
   807
	// Check the event has been removed
sl@0
   808
	active->StartL();
sl@0
   809
	aClient.GetEvent(*event, active->iStatus);
sl@0
   810
	CActiveScheduler::Start();
sl@0
   811
	TEST2(active->iStatus.Int(), KErrNotFound);;
sl@0
   812
sl@0
   813
	// Reset the config
sl@0
   814
	config.iMaxEventAge = oldAge;
sl@0
   815
sl@0
   816
	// Change the log engine config
sl@0
   817
	active->StartL();
sl@0
   818
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   819
	CActiveScheduler::Start();
sl@0
   820
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   821
sl@0
   822
	CleanupStack::PopAndDestroy(2); // active, event	
sl@0
   823
	}
sl@0
   824
sl@0
   825
/**
sl@0
   826
@SYMTestCaseID          SYSLIB-LOGENG-CT-0882
sl@0
   827
@SYMTestCaseDesc	    Tests for CLogClient::ClearLog() function
sl@0
   828
@SYMTestPriority 	    High
sl@0
   829
@SYMTestActions  	    Change locale settings and log duration to 1 day and test for number of event types in log 
sl@0
   830
@SYMTestExpectedResults Test must not fail
sl@0
   831
@SYMREQ                 REQ0000
sl@0
   832
*/
sl@0
   833
LOCAL_C void TestClearLog1L(CLogClient& aClient)
sl@0
   834
	{
sl@0
   835
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0882 "));
sl@0
   836
	CLogEvent* event = CLogEvent::NewL();
sl@0
   837
	CleanupStack::PushL(event);
sl@0
   838
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   839
sl@0
   840
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   841
	CleanupStack::PushL(active);
sl@0
   842
sl@0
   843
	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
sl@0
   844
	CleanupStack::PushL(view);
sl@0
   845
sl@0
   846
	// change Locale
sl@0
   847
	TLocale locale;
sl@0
   848
	locale.SetCountryCode(47);//Norway
sl@0
   849
	locale.SetDateFormat(EDateEuropean);
sl@0
   850
	locale.SetTimeFormat(ETime12);
sl@0
   851
	for (int i=0; i<4; i++)
sl@0
   852
         {
sl@0
   853
         locale.SetTimeSeparator(TChar('.'),i);
sl@0
   854
         locale.SetDateSeparator(TChar(':'),i);
sl@0
   855
         }
sl@0
   856
	locale.Set();
sl@0
   857
sl@0
   858
	// change the log duration settings to 1 day  
sl@0
   859
	TLogConfig config;
sl@0
   860
	active->StartL();
sl@0
   861
	aClient.GetConfig(config, active->iStatus);
sl@0
   862
	CActiveScheduler::Start();
sl@0
   863
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   864
sl@0
   865
	config.iMaxLogSize = KTestEventAge * 2;
sl@0
   866
	config.iMaxEventAge = 86400;
sl@0
   867
	active->StartL();
sl@0
   868
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   869
	CActiveScheduler::Start();
sl@0
   870
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   871
sl@0
   872
	// add a call event
sl@0
   873
	active->StartL();
sl@0
   874
	aClient.AddEvent(*event, active->iStatus);
sl@0
   875
	CActiveScheduler::Start();
sl@0
   876
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   877
	User::After(1000000);
sl@0
   878
	TTime now;
sl@0
   879
	now.HomeTime();	
sl@0
   880
	event->SetTime(now);
sl@0
   881
	active->StartL();
sl@0
   882
	aClient.ChangeEvent(*event, active->iStatus);
sl@0
   883
	CActiveScheduler::Start();
sl@0
   884
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   885
sl@0
   886
	// forward two days
sl@0
   887
	now+=(TTimeIntervalDays )2;
sl@0
   888
	User::SetHomeTime(now);
sl@0
   889
		
sl@0
   890
	// dummy call ensures ClearLog() is called
sl@0
   891
	active->StartL();
sl@0
   892
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   893
	CActiveScheduler::Start();
sl@0
   894
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   895
sl@0
   896
	// try to retrieve event
sl@0
   897
	active->StartL();
sl@0
   898
	aClient.GetEvent(*event, active->iStatus);
sl@0
   899
	CActiveScheduler::Start();
sl@0
   900
	TEST2(active->iStatus.Int(), KErrNotFound);;
sl@0
   901
sl@0
   902
	TEST(view->CountL() == 0);
sl@0
   903
sl@0
   904
	CleanupStack::PopAndDestroy(3); // view, active, event
sl@0
   905
	}
sl@0
   906
sl@0
   907
/**
sl@0
   908
@SYMTestCaseID          SYSLIB-LOGENG-CT-0883
sl@0
   909
@SYMTestCaseDesc	    Tests for CLogClient::ClearLog() function
sl@0
   910
@SYMTestPriority 	    High
sl@0
   911
@SYMTestActions  	    Change locale settings,call up ClearLog and try to retrieve event,test for count of number of events in the view.
sl@0
   912
@SYMTestExpectedResults Test must not fail
sl@0
   913
@SYMREQ                 REQ0000
sl@0
   914
*/
sl@0
   915
LOCAL_C void TestClearLog2L(CLogClient& aClient)
sl@0
   916
	{
sl@0
   917
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0883 "));
sl@0
   918
	CLogEvent* event = CLogEvent::NewL();
sl@0
   919
	CleanupStack::PushL(event);
sl@0
   920
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   921
sl@0
   922
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   923
	CleanupStack::PushL(active);
sl@0
   924
sl@0
   925
	CLogViewEvent* view = CLogViewEvent::NewL(aClient);
sl@0
   926
	CleanupStack::PushL(view);
sl@0
   927
sl@0
   928
	// change Locale
sl@0
   929
	TLocale locale;
sl@0
   930
	locale.SetCountryCode(47);//Norway
sl@0
   931
	locale.SetDateFormat(EDateEuropean);
sl@0
   932
	locale.SetTimeFormat(ETime12);
sl@0
   933
	for (int i=0; i<4; i++)
sl@0
   934
         {
sl@0
   935
         locale.SetTimeSeparator(TChar('.'),i);
sl@0
   936
         locale.SetDateSeparator(TChar(':'),i);
sl@0
   937
         }
sl@0
   938
	locale.Set();
sl@0
   939
sl@0
   940
	// change the log duration settings to 1 day  
sl@0
   941
	TLogConfig config;
sl@0
   942
	active->StartL();
sl@0
   943
	aClient.GetConfig(config, active->iStatus);
sl@0
   944
	CActiveScheduler::Start();
sl@0
   945
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   946
sl@0
   947
	config.iMaxLogSize = KTestEventAge * 2;
sl@0
   948
	config.iMaxEventAge = 86400;
sl@0
   949
	active->StartL();
sl@0
   950
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   951
	CActiveScheduler::Start();
sl@0
   952
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   953
sl@0
   954
	// add a call event
sl@0
   955
	active->StartL();
sl@0
   956
	aClient.AddEvent(*event, active->iStatus);
sl@0
   957
	CActiveScheduler::Start();
sl@0
   958
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   959
	User::After(1000000);
sl@0
   960
	TTime now;
sl@0
   961
	now.HomeTime();	
sl@0
   962
	event->SetTime(now);
sl@0
   963
	active->StartL();
sl@0
   964
	aClient.ChangeEvent(*event, active->iStatus);
sl@0
   965
	CActiveScheduler::Start();
sl@0
   966
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   967
sl@0
   968
	// forward two days
sl@0
   969
	now+=(TTimeIntervalDays )2;
sl@0
   970
	User::SetHomeTime(now);
sl@0
   971
		
sl@0
   972
	active->StartL();
sl@0
   973
	aClient.ClearLog(now, active->iStatus);
sl@0
   974
	CActiveScheduler::Start();
sl@0
   975
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   976
sl@0
   977
	// try to retrieve event
sl@0
   978
	active->StartL();
sl@0
   979
	aClient.GetEvent(*event, active->iStatus);
sl@0
   980
	CActiveScheduler::Start();
sl@0
   981
	TEST2(active->iStatus.Int(), KErrNotFound);;
sl@0
   982
sl@0
   983
	TEST(view->CountL() == 0);
sl@0
   984
sl@0
   985
	CleanupStack::PopAndDestroy(3); // view, active, event
sl@0
   986
	}
sl@0
   987
sl@0
   988
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
   989
sl@0
   990
/**
sl@0
   991
@SYMTestCaseID			PDS-LOGENG-UT-4036
sl@0
   992
@SYMTestCaseDesc		Clear log events with specific SimId test.
sl@0
   993
						The test adds 3 events with different SimIds and then checks that
sl@0
   994
						CLogEvent::ClearLog() deletes only the event with the specified id.
sl@0
   995
@SYMTestActions			Clear log events with specific SimId test.
sl@0
   996
@SYMTestExpectedResults Test must not fail
sl@0
   997
@SYMTestPriority		High
sl@0
   998
@SYMREQ					REQ12748
sl@0
   999
*/
sl@0
  1000
void ClearLogSimIdL(CLogClient& aClient)
sl@0
  1001
	{//This test case is compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined.
sl@0
  1002
	const TSimId KSimId1 = 4100000000U;
sl@0
  1003
	const TSimId KSimId2 = 100;
sl@0
  1004
	const TSimId KSimId3 = 1678;
sl@0
  1005
	
sl@0
  1006
	TTime now;
sl@0
  1007
	now.UniversalTime();
sl@0
  1008
	
sl@0
  1009
	TDateTime dt(now.DateTime());
sl@0
  1010
	dt.SetHour(dt.Hour() - 1);
sl@0
  1011
	TTime date(dt);
sl@0
  1012
	
sl@0
  1013
	TTime threshold(date);
sl@0
  1014
	threshold += TTimeIntervalSeconds(10);
sl@0
  1015
	
sl@0
  1016
	CTestActive* active = new(ELeave)CTestActive();
sl@0
  1017
	CleanupStack::PushL(active);
sl@0
  1018
sl@0
  1019
	//////// Event1 ///////////////////////////
sl@0
  1020
	CLogEvent* event1 = CLogEvent::NewL();
sl@0
  1021
	CleanupStack::PushL(event1);
sl@0
  1022
	event1->SetEventType(KLogCallEventTypeUid);
sl@0
  1023
	event1->SetSimId(KSimId1);
sl@0
  1024
sl@0
  1025
	active->StartL();
sl@0
  1026
	aClient.AddEvent(*event1, active->iStatus);
sl@0
  1027
	CActiveScheduler::Start();
sl@0
  1028
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1029
sl@0
  1030
	event1->SetTime(date);
sl@0
  1031
sl@0
  1032
	active->StartL();
sl@0
  1033
	aClient.ChangeEvent(*event1, active->iStatus);
sl@0
  1034
	CActiveScheduler::Start();
sl@0
  1035
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1036
sl@0
  1037
	//////// Event2 ///////////////////////////
sl@0
  1038
	CLogEvent* event2 = CLogEvent::NewL();
sl@0
  1039
	CleanupStack::PushL(event2);
sl@0
  1040
	event2->SetEventType(KLogCallEventTypeUid);
sl@0
  1041
	event2->SetSimId(KSimId2);
sl@0
  1042
sl@0
  1043
	active->StartL();
sl@0
  1044
	aClient.AddEvent(*event2, active->iStatus);
sl@0
  1045
	CActiveScheduler::Start();
sl@0
  1046
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1047
sl@0
  1048
	event2->SetTime(date);
sl@0
  1049
sl@0
  1050
	active->StartL();
sl@0
  1051
	aClient.ChangeEvent(*event2, active->iStatus);
sl@0
  1052
	CActiveScheduler::Start();
sl@0
  1053
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1054
sl@0
  1055
	//////// Event3 ///////////////////////////
sl@0
  1056
	CLogEvent* event3 = CLogEvent::NewL();
sl@0
  1057
	CleanupStack::PushL(event3);
sl@0
  1058
	event3->SetEventType(KLogCallEventTypeUid);
sl@0
  1059
	event3->SetSimId(KSimId3);
sl@0
  1060
sl@0
  1061
	active->StartL();
sl@0
  1062
	aClient.AddEvent(*event3, active->iStatus);
sl@0
  1063
	CActiveScheduler::Start();
sl@0
  1064
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1065
sl@0
  1066
	event3->SetTime(date);
sl@0
  1067
sl@0
  1068
	active->StartL();
sl@0
  1069
	aClient.ChangeEvent(*event3, active->iStatus);
sl@0
  1070
	CActiveScheduler::Start();
sl@0
  1071
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1072
	
sl@0
  1073
	//////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
  1074
	
sl@0
  1075
	//Delete event3 /////////////////////////
sl@0
  1076
	aClient.ClearLog(threshold, KSimId3, active->iStatus);
sl@0
  1077
	active->StartL();	
sl@0
  1078
	CActiveScheduler::Start();
sl@0
  1079
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1080
	//Event1 and event2 should be there
sl@0
  1081
	active->StartL();
sl@0
  1082
	aClient.GetEvent(*event1, active->iStatus);
sl@0
  1083
	CActiveScheduler::Start();
sl@0
  1084
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1085
	active->StartL();
sl@0
  1086
	aClient.GetEvent(*event2, active->iStatus);
sl@0
  1087
	CActiveScheduler::Start();
sl@0
  1088
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1089
	active->StartL();
sl@0
  1090
	aClient.GetEvent(*event3, active->iStatus);
sl@0
  1091
	CActiveScheduler::Start();
sl@0
  1092
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1093
	
sl@0
  1094
	//Delete event2 /////////////////////////
sl@0
  1095
	aClient.ClearLog(threshold, KSimId2, active->iStatus);
sl@0
  1096
	active->StartL();	
sl@0
  1097
	CActiveScheduler::Start();
sl@0
  1098
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1099
	//Event1 should be there
sl@0
  1100
	active->StartL();
sl@0
  1101
	aClient.GetEvent(*event1, active->iStatus);
sl@0
  1102
	CActiveScheduler::Start();
sl@0
  1103
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1104
	active->StartL();
sl@0
  1105
	aClient.GetEvent(*event2, active->iStatus);
sl@0
  1106
	CActiveScheduler::Start();
sl@0
  1107
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1108
	active->StartL();
sl@0
  1109
	aClient.GetEvent(*event3, active->iStatus);
sl@0
  1110
	CActiveScheduler::Start();
sl@0
  1111
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1112
	
sl@0
  1113
	//Delete event1 /////////////////////////
sl@0
  1114
	aClient.ClearLog(threshold, KSimId1, active->iStatus);
sl@0
  1115
	active->StartL();	
sl@0
  1116
	CActiveScheduler::Start();
sl@0
  1117
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1118
	//All events deleted
sl@0
  1119
	active->StartL();
sl@0
  1120
	aClient.GetEvent(*event1, active->iStatus);
sl@0
  1121
	CActiveScheduler::Start();
sl@0
  1122
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1123
	active->StartL();
sl@0
  1124
	aClient.GetEvent(*event2, active->iStatus);
sl@0
  1125
	CActiveScheduler::Start();
sl@0
  1126
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1127
	active->StartL();
sl@0
  1128
	aClient.GetEvent(*event3, active->iStatus);
sl@0
  1129
	CActiveScheduler::Start();
sl@0
  1130
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1131
sl@0
  1132
	CleanupStack::PopAndDestroy(4); //event3, event2, event1, active
sl@0
  1133
	}
sl@0
  1134
sl@0
  1135
/**
sl@0
  1136
@SYMTestCaseID			PDS-LOGENG-UT-4037
sl@0
  1137
@SYMTestCaseDesc		Clear log events from a recent list with specific SimId test.
sl@0
  1138
						The test adds 3 events to a recent list with different SimIds and then checks that
sl@0
  1139
						CLogEvent::ClearLog() deletes only the event with the specified id.
sl@0
  1140
@SYMTestActions			Clear log events from a recent list with specific SimId test.
sl@0
  1141
@SYMTestExpectedResults Test must not fail
sl@0
  1142
@SYMTestPriority 	    High
sl@0
  1143
@SYMREQ					REQ12748
sl@0
  1144
*/
sl@0
  1145
void ClearLogRecentSimIdL(CLogClient& aClient)
sl@0
  1146
	{//This test case is compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined.
sl@0
  1147
	const TSimId KSimId1 = 4200110000U;
sl@0
  1148
	const TSimId KSimId2 = 38223;
sl@0
  1149
	const TSimId KSimId3 = 239816;
sl@0
  1150
	
sl@0
  1151
	const TUid KEvTypeUid = {KLogCallEventType};
sl@0
  1152
	_LIT(KEvDirection, "Missed call");
sl@0
  1153
	
sl@0
  1154
	CTestActive* active = new(ELeave)CTestActive();
sl@0
  1155
	CleanupStack::PushL(active);
sl@0
  1156
sl@0
  1157
	//////// Event1 ///////////////////////////
sl@0
  1158
	CLogEvent* event1 = CLogEvent::NewL();
sl@0
  1159
	CleanupStack::PushL(event1);
sl@0
  1160
	event1->SetEventType(KEvTypeUid);
sl@0
  1161
	event1->SetDirection(KEvDirection);
sl@0
  1162
	event1->SetNumber(_L("12345678"));
sl@0
  1163
	event1->SetSimId(KSimId1);
sl@0
  1164
	active->StartL();
sl@0
  1165
	aClient.AddEvent(*event1, active->iStatus);
sl@0
  1166
	CActiveScheduler::Start();
sl@0
  1167
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1168
	//////// Event2 ///////////////////////////
sl@0
  1169
	CLogEvent* event2 = CLogEvent::NewL();
sl@0
  1170
	CleanupStack::PushL(event2);
sl@0
  1171
	event2->SetEventType(KEvTypeUid);
sl@0
  1172
	event2->SetDirection(KEvDirection);
sl@0
  1173
	event2->SetNumber(_L("87654321"));
sl@0
  1174
	event2->SetSimId(KSimId2);
sl@0
  1175
	active->StartL();
sl@0
  1176
	aClient.AddEvent(*event2, active->iStatus);
sl@0
  1177
	CActiveScheduler::Start();
sl@0
  1178
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1179
	//////// Event3 ///////////////////////////
sl@0
  1180
	CLogEvent* event3 = CLogEvent::NewL();
sl@0
  1181
	CleanupStack::PushL(event3);
sl@0
  1182
	event3->SetEventType(KEvTypeUid);
sl@0
  1183
	event3->SetDirection(KEvDirection);
sl@0
  1184
	event3->SetNumber(_L("99229922"));
sl@0
  1185
	event3->SetSimId(KSimId3);
sl@0
  1186
	active->StartL();
sl@0
  1187
	aClient.AddEvent(*event3, active->iStatus);
sl@0
  1188
	CActiveScheduler::Start();
sl@0
  1189
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1190
	//////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
  1191
	
sl@0
  1192
	//Delete event3 /////////////////////////
sl@0
  1193
	aClient.ClearLog(KLogRecentMissedCalls, KSimId3, active->iStatus);
sl@0
  1194
	active->StartL();	
sl@0
  1195
	CActiveScheduler::Start();
sl@0
  1196
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1197
	//Event1 and event2 should be there
sl@0
  1198
	CLogViewRecent* view = CLogViewRecent::NewL(aClient);
sl@0
  1199
	CleanupStack::PushL(view);
sl@0
  1200
	TBool rc = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
sl@0
  1201
	TEST(rc);
sl@0
  1202
	active->StartL();
sl@0
  1203
	CActiveScheduler::Start();
sl@0
  1204
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1205
sl@0
  1206
	TInt count = view->CountL();
sl@0
  1207
	TEST2(count, 2);
sl@0
  1208
	rc = view->FirstL(active->iStatus);
sl@0
  1209
	TEST(rc);
sl@0
  1210
	active->StartL();
sl@0
  1211
	CActiveScheduler::Start();
sl@0
  1212
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1213
	const CLogEvent& e1 = view->Event();
sl@0
  1214
	TEST(e1.SimId() == KSimId2 || e1.SimId() == KSimId1);
sl@0
  1215
	rc = view->NextL(active->iStatus);
sl@0
  1216
	TEST(rc);
sl@0
  1217
	active->StartL();
sl@0
  1218
	CActiveScheduler::Start();
sl@0
  1219
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1220
	const CLogEvent& e2 = view->Event();
sl@0
  1221
	TEST(e2.SimId() == KSimId2 || e2.SimId() == KSimId1);
sl@0
  1222
	TEST(e1.Id() != e2.Id());
sl@0
  1223
sl@0
  1224
	CleanupStack::PopAndDestroy(view);
sl@0
  1225
	
sl@0
  1226
	//Delete event1 /////////////////////////
sl@0
  1227
	aClient.ClearLog(KLogRecentMissedCalls, KSimId1, active->iStatus);
sl@0
  1228
	active->StartL();	
sl@0
  1229
	CActiveScheduler::Start();
sl@0
  1230
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1231
	//Only event2 should be there
sl@0
  1232
	view = CLogViewRecent::NewL(aClient);
sl@0
  1233
	CleanupStack::PushL(view);
sl@0
  1234
	rc = view->SetRecentListL(KLogRecentMissedCalls, active->iStatus);
sl@0
  1235
	TEST(rc);
sl@0
  1236
	active->StartL();
sl@0
  1237
	CActiveScheduler::Start();
sl@0
  1238
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1239
	count = view->CountL();
sl@0
  1240
	TEST2(count, 1);
sl@0
  1241
	rc = view->FirstL(active->iStatus);
sl@0
  1242
	TEST(rc);
sl@0
  1243
	active->StartL();
sl@0
  1244
	CActiveScheduler::Start();
sl@0
  1245
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1246
	const CLogEvent& e3 = view->Event();
sl@0
  1247
	TEST(e3.SimId() == KSimId2);
sl@0
  1248
sl@0
  1249
	CleanupStack::PopAndDestroy(5); //view, event3, event2, event1, active
sl@0
  1250
	}
sl@0
  1251
sl@0
  1252
#endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
  1253
sl@0
  1254
void doTestsL()
sl@0
  1255
	{
sl@0
  1256
	TestUtils::Initialize(_L("t_logpurge"));
sl@0
  1257
	TestUtils::DeleteDatabaseL();
sl@0
  1258
sl@0
  1259
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
  1260
	CleanupStack::PushL(client);
sl@0
  1261
sl@0
  1262
	TheTest.Start(_L("Maximum Log Size"));
sl@0
  1263
	TestMaxLogSizeL(*client);
sl@0
  1264
	theLog.Write(_L8("Test 1 OK\n"));
sl@0
  1265
sl@0
  1266
	TheTest.Next(_L("Purge Log When Config Changed"));
sl@0
  1267
	TestMaxLogSizeConfigL(*client);
sl@0
  1268
	theLog.Write(_L8("Test 2 OK\n"));
sl@0
  1269
sl@0
  1270
	TheTest.Next(_L("Test purge by Maximum Log Age enabled/disabled"));
sl@0
  1271
	TestMaxLogAgeL(*client, 0);	// disable purging by age
sl@0
  1272
	TestMaxLogAgeL(*client, KTestEventAge * 60 * 60 * 24);  
sl@0
  1273
	theLog.Write(_L8("Test 3 OK\n"));
sl@0
  1274
sl@0
  1275
	TheTest.Next(_L("Maximum Recent List Size"));
sl@0
  1276
	TestMaxRecentSize1L(*client);
sl@0
  1277
	theLog.Write(_L8("Test 4 OK\n"));
sl@0
  1278
sl@0
  1279
	TheTest.Next(_L("Purge Recent Lists When Config Changed"));
sl@0
  1280
	TestMaxRecentSizeConfigL(*client);
sl@0
  1281
	theLog.Write(_L8("Test 5 OK\n"));
sl@0
  1282
sl@0
  1283
	TheTest.Next(_L("Maximum Recent List Size With Duplicates"));
sl@0
  1284
	TestMaxRecentSize2L(*client);
sl@0
  1285
	theLog.Write(_L8("Test 6 OK\n"));
sl@0
  1286
sl@0
  1287
	TheTest.Next(_L("Check no purge when retrieving event"));
sl@0
  1288
	TestNoPurgeWithGetL(*client);
sl@0
  1289
	theLog.Write(_L8("Test 7 OK\n"));
sl@0
  1290
sl@0
  1291
	TheTest.Next(_L("Check ClearLog works for different locales"));
sl@0
  1292
	TestClearLog1L(*client);
sl@0
  1293
	TestClearLog2L(*client);
sl@0
  1294
 	theLog.Write(_L8("Test 8 OK\n"));
sl@0
  1295
sl@0
  1296
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
  1297
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4036 CLogClient::ClearLog() + SimId test"));
sl@0
  1298
 	ClearLogSimIdL(*client);
sl@0
  1299
 	theLog.Write(_L8("Test 9 OK\n"));
sl@0
  1300
sl@0
  1301
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4037 CLogClient::ClearLog()/recent + SimId test"));
sl@0
  1302
 	ClearLogRecentSimIdL(*client);
sl@0
  1303
 	theLog.Write(_L8("Test 10 OK\n"));
sl@0
  1304
#endif 	
sl@0
  1305
 	
sl@0
  1306
	CleanupStack::PopAndDestroy(); // client;
sl@0
  1307
	}