os/persistentdata/loggingservices/eventlogger/test/src/t_logapi2.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2009-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
// t_logapi2.cpp - LogEng API tests 
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
#include <s32file.h>
sl@0
    18
#include <s32mem.h>
sl@0
    19
#include <e32math.h>
sl@0
    20
#include <bautils.h>
sl@0
    21
#include <logview.h>
sl@0
    22
#include "t_logutil2.h"
sl@0
    23
#include "LogServSqlStrings.h"
sl@0
    24
sl@0
    25
RTest TheTest(_L("t_logapi2"));
sl@0
    26
sl@0
    27
_LIT(KTestRemoteParty1, "Remote Party");
sl@0
    28
_LIT(KTestDirection1, "Direction");
sl@0
    29
_LIT(KTestStatus1, "Status");
sl@0
    30
_LIT(KTestSubject1, "Subject");
sl@0
    31
const TUid KTestEventUid = {0x10005393};
sl@0
    32
const TLogDurationType KTestDurationType1 = 1;
sl@0
    33
const TLogDuration KTestDuration1 = 0x1234;
sl@0
    34
const TLogContactItemId KTestContact1 = 0x1234;
sl@0
    35
const TLogLink KTestLink1 = 0x1234;
sl@0
    36
_LIT8(KTestData1, "ABCDEFGH");
sl@0
    37
const TLogFlags KTestFlags1 = 0x5;
sl@0
    38
_LIT(KEvNumber1, "11119999");
sl@0
    39
_LIT(KEvNumber2, "22226666");
sl@0
    40
const TLogDurationType KEvDurationType1 = 1;
sl@0
    41
const TLogDurationType KEvDurationType2 = 2;
sl@0
    42
const TLogContactItemId KEvContact1 = 1010;
sl@0
    43
const TLogLink KEvLink1 = 2000;
sl@0
    44
_LIT(KEvDesc1, "Event Type Description 1");
sl@0
    45
sl@0
    46
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
    47
const TSimId KEvSimId1 = 3000000910U;//Bigger than KMaxTInt, to check that SQL statement formatting works as expected
sl@0
    48
const TSimId KEvSimId2 = 2911;
sl@0
    49
#endif
sl@0
    50
sl@0
    51
const TInt KDiffEvCount = 10;
sl@0
    52
sl@0
    53
//KEvDirection2 used together with KEvTypeUid guarantees that the properties of the event being changed
sl@0
    54
//match the conditions of one the LogEng server recent lists and thus the "recent list" related functionality 
sl@0
    55
//on the server side will be used.
sl@0
    56
_LIT(KEvDirection2, "Incoming");
sl@0
    57
sl@0
    58
const TUid KEvTypeUid = {KLogCallEventType};
sl@0
    59
const TUid KEvTypeUidLoggingDisabled = {0x447422};
sl@0
    60
sl@0
    61
enum TLogAddEventOps {ELogOpAddEvent, ELogOpAddEventInvalidType, ELogOpAddEventLoggingDisabled};
sl@0
    62
enum TLogGetEventOps {ELogOpGetEvent, ELogOpGetEventZeroId, ELogOpGetEventNotExists};
sl@0
    63
sl@0
    64
TLogId TheEvId = -1;
sl@0
    65
TInt TheAddedEventCount = -1;
sl@0
    66
TInt TheMaxLogSize = -1;
sl@0
    67
sl@0
    68
//The default max log size is 1000. But the test timeouts on hardware with max log size of 1000.
sl@0
    69
const TInt KMaxLogSize = 200;
sl@0
    70
const TInt KMaxRecentLogSize = 10; // Default recent log size is 20
sl@0
    71
const TInt KMaxPlusEvCount = 100; //Added events count on top of the max log size
sl@0
    72
sl@0
    73
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
    74
sl@0
    75
//Add a new event type with "logging disabled"
sl@0
    76
void DoAddEventTypeL(CLogClient& aClient, CTestActive& aActive)
sl@0
    77
	{
sl@0
    78
	CLogEventType* type = CLogEventType::NewL();
sl@0
    79
	CleanupStack::PushL(type);
sl@0
    80
sl@0
    81
	type->SetUid(KEvTypeUidLoggingDisabled);
sl@0
    82
	type->SetDescription(_L("110111011011"));
sl@0
    83
	type->SetLoggingEnabled(EFalse);
sl@0
    84
sl@0
    85
	aClient.AddEventType(*type, aActive.iStatus);
sl@0
    86
	aActive.StartL();
sl@0
    87
	CActiveScheduler::Start();
sl@0
    88
	TEST2(aActive.iStatus.Int(), KErrNone);
sl@0
    89
sl@0
    90
	CleanupStack::PopAndDestroy(type);
sl@0
    91
	}
sl@0
    92
sl@0
    93
void DoSetNewMaxLogSizeL(CLogClient& aClient, CTestActive& aActive)
sl@0
    94
	{
sl@0
    95
	//Check what is the max log size.
sl@0
    96
	TLogConfig config;
sl@0
    97
	aActive.StartL();
sl@0
    98
	aClient.GetConfig(config, aActive.iStatus);
sl@0
    99
	CActiveScheduler::Start();
sl@0
   100
	TEST2(aActive.iStatus.Int(), KErrNone);
sl@0
   101
	//Set new max log size
sl@0
   102
	config.iMaxLogSize = KMaxLogSize;
sl@0
   103
	aActive.StartL();
sl@0
   104
	aClient.ChangeConfig(config, aActive.iStatus);
sl@0
   105
	CActiveScheduler::Start();
sl@0
   106
	TEST2(aActive.iStatus.Int(), KErrNone);
sl@0
   107
	//Test the new max log size
sl@0
   108
	aActive.StartL();
sl@0
   109
	aClient.GetConfig(config, aActive.iStatus);
sl@0
   110
	CActiveScheduler::Start();
sl@0
   111
	TEST2(aActive.iStatus.Int(), KErrNone);
sl@0
   112
	TEST2(config.iMaxLogSize, KMaxLogSize);
sl@0
   113
	//
sl@0
   114
	TheMaxLogSize = config.iMaxLogSize;
sl@0
   115
	TheAddedEventCount = config.iMaxLogSize + KMaxPlusEvCount;
sl@0
   116
	}
sl@0
   117
sl@0
   118
void DoAddEventsL()
sl@0
   119
	{
sl@0
   120
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
   121
	CleanupStack::PushL(client);
sl@0
   122
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   123
	CleanupStack::PushL(active);
sl@0
   124
	
sl@0
   125
	//Set new max log size
sl@0
   126
	DoSetNewMaxLogSizeL(*client, *active);
sl@0
   127
sl@0
   128
	//Add TheAddedEventCount events. Some of them with SimId, some - not.
sl@0
   129
	//This certainly will involve some log purging operations when the log size reaches the max.
sl@0
   130
	CLogEvent* event = CLogEvent::NewL();
sl@0
   131
	CleanupStack::PushL(event);
sl@0
   132
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   133
	event->SetRemoteParty(KTestRemoteParty1);
sl@0
   134
	event->SetDirection(KTestDirection1);
sl@0
   135
	event->SetDurationType(KEvDurationType1);
sl@0
   136
	event->SetDuration(KTestDuration1);
sl@0
   137
	event->SetStatus(KTestStatus1);
sl@0
   138
	event->SetSubject(KTestSubject1);
sl@0
   139
	event->SetNumber(KEvNumber1);
sl@0
   140
	event->SetContact(KEvContact1);
sl@0
   141
	event->SetLink(KEvLink1);
sl@0
   142
	event->SetDescription(KEvDesc1);
sl@0
   143
	event->SetFlags(KTestFlags1);
sl@0
   144
	event->SetDataL(KTestData1);
sl@0
   145
	
sl@0
   146
	TTime st_time;
sl@0
   147
	st_time.UniversalTime();
sl@0
   148
	
sl@0
   149
	TheTest.Printf(_L("Added events:\n"));
sl@0
   150
	TInt diffEvCount = KDiffEvCount;
sl@0
   151
	for(TInt i=0;i<TheAddedEventCount;++i)
sl@0
   152
		{
sl@0
   153
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
   154
		event->SetSimId(KLogNullSimId);
sl@0
   155
#endif		
sl@0
   156
		event->SetDurationType(KEvDurationType1);
sl@0
   157
		event->SetNumber(KEvNumber1);
sl@0
   158
		if((i %2) == 0)
sl@0
   159
			{
sl@0
   160
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
   161
			event->SetSimId(KEvSimId1);
sl@0
   162
#endif			
sl@0
   163
			if((i > TheMaxLogSize / 2 + 1) && (i % 10) == 0 && --diffEvCount >= 0)
sl@0
   164
				{//Add after the second half because when the log grows above the max log size, the first events will be deleted
sl@0
   165
				event->SetDurationType(KEvDurationType2);
sl@0
   166
				event->SetNumber(KEvNumber2);
sl@0
   167
				}
sl@0
   168
			}
sl@0
   169
		active->StartL();
sl@0
   170
		client->AddEvent(*event, active->iStatus);
sl@0
   171
		CActiveScheduler::Start();
sl@0
   172
		TEST(!active->IsActive());
sl@0
   173
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   174
		if((i % 50) == 0 && i > 0)
sl@0
   175
			{
sl@0
   176
			TheTest.Printf(_L("%d\r"), i);
sl@0
   177
			}
sl@0
   178
		}
sl@0
   179
	TheTest.Printf(_L("%d\n"), TheAddedEventCount);
sl@0
   180
	
sl@0
   181
	TTime end_time;
sl@0
   182
	end_time.UniversalTime();
sl@0
   183
	
sl@0
   184
	CleanupStack::PopAndDestroy(event);
sl@0
   185
	
sl@0
   186
	CleanupStack::PopAndDestroy(active);
sl@0
   187
	CleanupStack::PopAndDestroy(client);
sl@0
   188
	
sl@0
   189
	TTimeIntervalMicroSeconds us = end_time.MicroSecondsFrom(st_time);
sl@0
   190
	TheTest.Printf(_L("%d events added. Time: %ld milliseconds\n"), TheAddedEventCount, us.Int64() / 1000);
sl@0
   191
	}
sl@0
   192
sl@0
   193
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   194
sl@0
   195
/**
sl@0
   196
@SYMTestCaseID			PDS-LOGENG-UT-4042
sl@0
   197
@SYMTestCaseDesc		"Cancel operation" test.
sl@0
   198
						The test uses RLogTestSession to establish a connection with the EventViewer server.
sl@0
   199
						The the test initializes an "Add Event" opertaion.
sl@0
   200
						But instead of completing the operation the test cancels it. 
sl@0
   201
@SYMTestActions			"Cancel operation" test.
sl@0
   202
@SYMTestExpectedResults Test must not fail
sl@0
   203
@SYMTestPriority		Medium
sl@0
   204
@SYMREQ					REQ12747
sl@0
   205
*/
sl@0
   206
void CancelOperationTest()
sl@0
   207
	{
sl@0
   208
	RLogTestSession sess;
sl@0
   209
	TInt err = sess.Connect();
sl@0
   210
	TEST2(err, KErrNone);
sl@0
   211
	
sl@0
   212
	CLogEvent* event = NULL;
sl@0
   213
	TRAP(err, event = CLogEvent::NewL());
sl@0
   214
	TEST2(err, KErrNone);
sl@0
   215
	event->SetEventType(KTestEventUid);
sl@0
   216
	event->SetRemoteParty(KTestRemoteParty1);
sl@0
   217
	event->SetDirection(KTestDirection1);
sl@0
   218
	event->SetDurationType(KTestDurationType1);
sl@0
   219
	event->SetDuration(KTestDuration1);
sl@0
   220
	event->SetStatus(KTestStatus1);
sl@0
   221
	event->SetSubject(KTestSubject1);
sl@0
   222
	event->SetContact(KTestContact1);
sl@0
   223
	event->SetLink(KTestLink1);
sl@0
   224
	TRAP(err, event->SetDataL(KTestData1));
sl@0
   225
	TEST2(err, KErrNone);
sl@0
   226
	event->SetFlags(KTestFlags1);
sl@0
   227
	
sl@0
   228
	TBuf8<1024> buf;
sl@0
   229
	RDesWriteStream strm(buf);
sl@0
   230
	TRAP(err, event->ExternalizeL(strm));
sl@0
   231
	TEST2(err, KErrNone);
sl@0
   232
	TRAP(err, strm.CommitL());
sl@0
   233
	TEST2(err, KErrNone);
sl@0
   234
	
sl@0
   235
	TPckgBuf<TLogClientServerData> data;
sl@0
   236
	data().iOperationType = ELogOperationEventAdd;
sl@0
   237
	data().iOperationId = KLogNullOperationId;
sl@0
   238
	
sl@0
   239
	TRequestStatus stat;
sl@0
   240
	TIpcArgs args1(&data, &buf);
sl@0
   241
	sess.Send(ELogOperationInitiate, args1, stat);
sl@0
   242
	TEST2(stat.Int(), KRequestPending);
sl@0
   243
	TIpcArgs args2(&data);
sl@0
   244
	err = sess.Send(ELogOperationCancel, args2);
sl@0
   245
	TEST2(err, KErrCancel);
sl@0
   246
	User::WaitForRequest(stat);
sl@0
   247
	err = stat.Int();
sl@0
   248
	TEST2(err, KErrCancel);
sl@0
   249
	
sl@0
   250
	strm.Close();
sl@0
   251
	delete event;
sl@0
   252
	sess.Close();
sl@0
   253
	}
sl@0
   254
sl@0
   255
/**
sl@0
   256
@SYMTestCaseID			PDS-LOGENG-UT-4029
sl@0
   257
@SYMTestCaseDesc		AddEvent() server side OOM test.
sl@0
   258
						This test uses the results from the previous test cases that
sl@0
   259
						the LogEng database contains TheMaxLogSize events.
sl@0
   260
						This ensures that the "purge main" functionality on the server side 
sl@0
   261
						will be used.
sl@0
   262
						The properties of the event being added are such (KEvDirection1 and KEvTypeUid) that 
sl@0
   263
						one of the LogServ recent lists will be used. This ensures that the "purge recent"
sl@0
   264
						LogEng server functionality will be used.
sl@0
   265
						The test, as any other of the LogEng server OOM tests, does not fully cover the used on the
sl@0
   266
						server side functions, because:
sl@0
   267
						1) CLogAddEvent will set the iEventAdded flag right after adding the event to the database.
sl@0
   268
						   After that, any OOM failure that occurs for example in "purge recent" related calls, will be
sl@0
   269
						   ignored.
sl@0
   270
						2) CLogEvent will use the CLogDuplicate active object for the "purge recent" action.
sl@0
   271
						   When CLogDuplicate fails with KErrNoMemory in DoRunL(), the error is ignored and not reported
sl@0
   272
						   back.
sl@0
   273
@SYMTestActions			AddEvent() server side OOM test.
sl@0
   274
@SYMTestExpectedResults Test must not fail
sl@0
   275
@SYMTestPriority		Medium
sl@0
   276
@SYMREQ					REQ12746
sl@0
   277
*/
sl@0
   278
void AddEventOomTestL(TLogAddEventOps aLogAddEventOp, TInt aExpectedError)
sl@0
   279
	{
sl@0
   280
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
   281
	CleanupStack::PushL(client);
sl@0
   282
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   283
	CleanupStack::PushL(active);
sl@0
   284
	CLogEvent* event = CLogEvent::NewL();
sl@0
   285
	CleanupStack::PushL(event);
sl@0
   286
sl@0
   287
	if(aLogAddEventOp == ELogOpAddEventLoggingDisabled)
sl@0
   288
		{
sl@0
   289
		DoAddEventTypeL(*client, *active);
sl@0
   290
		}
sl@0
   291
	
sl@0
   292
	TTime now;
sl@0
   293
	now.UniversalTime();
sl@0
   294
sl@0
   295
	TUid eventType = KEvTypeUid;
sl@0
   296
	if(aLogAddEventOp == ELogOpAddEventInvalidType)
sl@0
   297
		{
sl@0
   298
		eventType = TUid::Uid(0x445972);
sl@0
   299
		}
sl@0
   300
	else if(aLogAddEventOp == ELogOpAddEventLoggingDisabled)
sl@0
   301
		{
sl@0
   302
		eventType = KEvTypeUidLoggingDisabled;
sl@0
   303
		}
sl@0
   304
sl@0
   305
	event->SetEventType(eventType);
sl@0
   306
	event->SetRemoteParty(KTestRemoteParty1);
sl@0
   307
	event->SetDirection(KTestDirection1);
sl@0
   308
	event->SetDurationType(KEvDurationType1);
sl@0
   309
	event->SetDuration(KTestDuration1);
sl@0
   310
	event->SetStatus(KTestStatus1);
sl@0
   311
	event->SetSubject(KTestSubject1);
sl@0
   312
	event->SetNumber(KEvNumber1);
sl@0
   313
	event->SetContact(KEvContact1);
sl@0
   314
	event->SetLink(KEvLink1);
sl@0
   315
	event->SetDescription(KEvDesc1);
sl@0
   316
	event->SetFlags(KTestFlags1);
sl@0
   317
	event->SetDataL(KTestData1);
sl@0
   318
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
   319
	event->SetSimId(KEvSimId1);
sl@0
   320
#endif	
sl@0
   321
	
sl@0
   322
	TInt failCount = 0;
sl@0
   323
	TBool finished = EFalse;
sl@0
   324
sl@0
   325
	while(!finished)
sl@0
   326
		{
sl@0
   327
		__LOGSERV_UHEAP_FAILNEXT(++failCount);
sl@0
   328
		client->AddEvent(*event, active->iStatus);
sl@0
   329
		active->StartL();
sl@0
   330
		CActiveScheduler::Start();
sl@0
   331
sl@0
   332
		if(active->iStatus.Int() == aExpectedError)
sl@0
   333
			{
sl@0
   334
			finished = ETrue;
sl@0
   335
			}
sl@0
   336
		
sl@0
   337
		__LOGSERV_UHEAP_RESET;
sl@0
   338
sl@0
   339
		if(active->iStatus.Int() != aExpectedError)
sl@0
   340
			{
sl@0
   341
			TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   342
			}
sl@0
   343
		}
sl@0
   344
sl@0
   345
	TEST2(active->iStatus.Int(), aExpectedError);
sl@0
   346
	if(aLogAddEventOp == ELogOpAddEvent)
sl@0
   347
		{
sl@0
   348
		TEST(event->Time() >= now);
sl@0
   349
		active->StartL();
sl@0
   350
		client->GetEvent(*event, active->iStatus);
sl@0
   351
		CActiveScheduler::Start();
sl@0
   352
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   353
		TheEvId = event->Id();
sl@0
   354
		TEST(TheEvId > 0);
sl@0
   355
		}
sl@0
   356
sl@0
   357
	CleanupStack::PopAndDestroy(event);
sl@0
   358
	CleanupStack::PopAndDestroy(active);
sl@0
   359
	CleanupStack::PopAndDestroy(client);
sl@0
   360
	
sl@0
   361
	TheTest.Printf(_L("===CLogClient::AddEvent() server side OOM test succeeded at iteration %d\n"), failCount);
sl@0
   362
	}
sl@0
   363
sl@0
   364
/**
sl@0
   365
@SYMTestCaseID			PDS-LOGENG-UT-4030
sl@0
   366
@SYMTestCaseDesc		ChangeEvent() server side OOM test.
sl@0
   367
						This test uses the results from the previous test cases that
sl@0
   368
						the LogEng database contains TheMaxLogSize events.
sl@0
   369
						This ensures that the "purge main" functionality on the server side 
sl@0
   370
						will be used.
sl@0
   371
						The properties of the event being changed are such (KEvDirection2 and KEvTypeUid) that 
sl@0
   372
						one of the LogServ recent lists will be used. This ensures that the "purge recent"
sl@0
   373
						LogEng server functionality will be used.
sl@0
   374
@SYMTestActions			ChangeEvent() server side OOM test.
sl@0
   375
@SYMTestExpectedResults Test must not fail
sl@0
   376
@SYMTestPriority		Medium
sl@0
   377
@SYMREQ					REQ12746
sl@0
   378
*/
sl@0
   379
void ChangeEventOomTestL(TBool aEventExists)
sl@0
   380
	{
sl@0
   381
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
   382
	CleanupStack::PushL(client);
sl@0
   383
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   384
	CleanupStack::PushL(active);
sl@0
   385
	CLogEvent* event = CLogEvent::NewL();
sl@0
   386
	CleanupStack::PushL(event);
sl@0
   387
	
sl@0
   388
	event->SetId(TheEvId);
sl@0
   389
	active->StartL();
sl@0
   390
	client->GetEvent(*event, active->iStatus);
sl@0
   391
	CActiveScheduler::Start();
sl@0
   392
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   393
	TEST2(TheEvId, event->Id());
sl@0
   394
	event->SetDirection(KEvDirection2);
sl@0
   395
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
   396
	event->SetSimId(KEvSimId2);
sl@0
   397
#endif	
sl@0
   398
	
sl@0
   399
	TInt failCount = 0;
sl@0
   400
	TBool finished = EFalse;
sl@0
   401
sl@0
   402
	if(!aEventExists)
sl@0
   403
		{//Search for a non-existing event in the OOM loop
sl@0
   404
		event->SetId(TheEvId + 5678);
sl@0
   405
		}
sl@0
   406
	
sl@0
   407
	while(!finished)
sl@0
   408
		{
sl@0
   409
		__LOGSERV_UHEAP_FAILNEXT(++failCount);
sl@0
   410
		client->ChangeEvent(*event, active->iStatus);
sl@0
   411
		active->StartL();
sl@0
   412
		CActiveScheduler::Start();
sl@0
   413
sl@0
   414
		TInt err = active->iStatus.Int();
sl@0
   415
		if(err == (aEventExists ? KErrNone : KErrNotFound))
sl@0
   416
			{
sl@0
   417
			finished = ETrue;
sl@0
   418
			}
sl@0
   419
		
sl@0
   420
		__LOGSERV_UHEAP_RESET;
sl@0
   421
sl@0
   422
		if(err != (aEventExists ? KErrNone : KErrNotFound))
sl@0
   423
			{
sl@0
   424
			TEST2(err, KErrNoMemory);
sl@0
   425
			}
sl@0
   426
		}
sl@0
   427
sl@0
   428
	active->StartL();
sl@0
   429
	client->GetEvent(*event, active->iStatus);
sl@0
   430
	CActiveScheduler::Start();
sl@0
   431
	if(aEventExists)
sl@0
   432
		{
sl@0
   433
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   434
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
   435
		TEST2(event->SimId(), KEvSimId2);
sl@0
   436
#endif		
sl@0
   437
		}
sl@0
   438
	else
sl@0
   439
		{
sl@0
   440
		TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
   441
		}
sl@0
   442
sl@0
   443
	CleanupStack::PopAndDestroy(event);
sl@0
   444
	CleanupStack::PopAndDestroy(active);
sl@0
   445
	CleanupStack::PopAndDestroy(client);
sl@0
   446
	
sl@0
   447
	TheTest.Printf(_L("===CLogClient::ChangeEvent() server side OOM test succeeded at iteration %d\n"), failCount);
sl@0
   448
	}
sl@0
   449
sl@0
   450
/**
sl@0
   451
@SYMTestCaseID			PDS-LOGENG-UT-4031
sl@0
   452
@SYMTestCaseDesc		DeleteEvent() server side OOM test.
sl@0
   453
						This test uses the results from the previous test cases that
sl@0
   454
						the LogEng database contains TheMaxLogSize events.
sl@0
   455
						This ensures that the "purge main" functionality on the server side 
sl@0
   456
						will be used.
sl@0
   457
@SYMTestActions			DeleteEvent() server side OOM test.
sl@0
   458
@SYMTestExpectedResults Test must not fail
sl@0
   459
@SYMTestPriority		Medium
sl@0
   460
@SYMREQ					REQ12746
sl@0
   461
*/
sl@0
   462
void DeleteEventOomTestL(TBool aEventExists)
sl@0
   463
	{
sl@0
   464
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
   465
	CleanupStack::PushL(client);
sl@0
   466
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   467
	CleanupStack::PushL(active);
sl@0
   468
	
sl@0
   469
	TInt failCount = 0;
sl@0
   470
	TBool finished = EFalse;
sl@0
   471
sl@0
   472
	while(!finished)
sl@0
   473
		{
sl@0
   474
		__LOGSERV_UHEAP_FAILNEXT(++failCount);
sl@0
   475
		client->DeleteEvent(TheEvId, active->iStatus);
sl@0
   476
		active->StartL();
sl@0
   477
		CActiveScheduler::Start();
sl@0
   478
sl@0
   479
		TInt err = active->iStatus.Int();
sl@0
   480
		if(err == (aEventExists ? KErrNone : KErrNotFound))
sl@0
   481
			{
sl@0
   482
			finished = ETrue;
sl@0
   483
			}
sl@0
   484
		
sl@0
   485
		__LOGSERV_UHEAP_RESET;
sl@0
   486
sl@0
   487
		if(err != (aEventExists ? KErrNone : KErrNotFound))
sl@0
   488
			{
sl@0
   489
			TEST2(err, KErrNoMemory);
sl@0
   490
			}
sl@0
   491
		}
sl@0
   492
sl@0
   493
	CLogEvent* event = CLogEvent::NewL();
sl@0
   494
	CleanupStack::PushL(event);
sl@0
   495
	event->SetId(TheEvId);
sl@0
   496
	active->StartL();
sl@0
   497
	client->GetEvent(*event, active->iStatus);
sl@0
   498
	CActiveScheduler::Start();
sl@0
   499
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
   500
	CleanupStack::PopAndDestroy(event);
sl@0
   501
	
sl@0
   502
	CleanupStack::PopAndDestroy(active);
sl@0
   503
	CleanupStack::PopAndDestroy(client);
sl@0
   504
	
sl@0
   505
	TheTest.Printf(_L("===CLogClient::DeleteEvent() server side OOM test succeeded at iteration %d\n"), failCount);
sl@0
   506
	}
sl@0
   507
sl@0
   508
/**
sl@0
   509
@SYMTestCaseID			PDS-LOGENG-UT-4032
sl@0
   510
@SYMTestCaseDesc		GetEvent() server side OOM test.
sl@0
   511
						This test uses the results from the previous test cases that
sl@0
   512
						the LogEng database contains TheMaxLogSize events.
sl@0
   513
						GetEvent() is executed in OOM loop.
sl@0
   514
@SYMTestActions			GetEvent() server side OOM test.
sl@0
   515
@SYMTestExpectedResults Test must not fail
sl@0
   516
@SYMTestPriority		Medium
sl@0
   517
@SYMREQ					REQ12746
sl@0
   518
*/
sl@0
   519
void GetEventOomTestL(TLogGetEventOps aGetEventOp, TInt aExpectedError)
sl@0
   520
	{
sl@0
   521
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
   522
	CleanupStack::PushL(client);
sl@0
   523
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   524
	CleanupStack::PushL(active);
sl@0
   525
	CLogEvent* event = CLogEvent::NewL();
sl@0
   526
	CleanupStack::PushL(event);
sl@0
   527
	
sl@0
   528
	event->SetId(aGetEventOp == ELogOpGetEvent ? TheEvId : (aGetEventOp == ELogOpGetEventNotExists ? 0x932271F : 0x0));
sl@0
   529
	
sl@0
   530
	TInt failCount = 0;
sl@0
   531
	TBool finished = EFalse;
sl@0
   532
sl@0
   533
	while(!finished)
sl@0
   534
		{
sl@0
   535
		__LOGSERV_UHEAP_FAILNEXT(++failCount);
sl@0
   536
		client->GetEvent(*event, active->iStatus);
sl@0
   537
		active->StartL();
sl@0
   538
		CActiveScheduler::Start();
sl@0
   539
sl@0
   540
		if(active->iStatus.Int() == aExpectedError)
sl@0
   541
			{
sl@0
   542
			finished = ETrue;
sl@0
   543
			}
sl@0
   544
		
sl@0
   545
		__LOGSERV_UHEAP_RESET;
sl@0
   546
sl@0
   547
		if(active->iStatus.Int() != aExpectedError)
sl@0
   548
			{
sl@0
   549
			TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   550
			}
sl@0
   551
		}
sl@0
   552
	
sl@0
   553
	TEST2(active->iStatus.Int(), aExpectedError);
sl@0
   554
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
   555
	if(aGetEventOp == ELogOpGetEvent)
sl@0
   556
		{
sl@0
   557
		TEST2(event->SimId(), KEvSimId2);
sl@0
   558
		}
sl@0
   559
#endif
sl@0
   560
	
sl@0
   561
	CleanupStack::PopAndDestroy(event);
sl@0
   562
	CleanupStack::PopAndDestroy(active);
sl@0
   563
	CleanupStack::PopAndDestroy(client);
sl@0
   564
	
sl@0
   565
	TheTest.Printf(_L("===CLogClient::GetEvent() server side OOM test succeeded at iteration %d\n"), failCount);
sl@0
   566
	}
sl@0
   567
sl@0
   568
/**
sl@0
   569
@SYMTestCaseID			PDS-LOGENG-UT-4033
sl@0
   570
@SYMTestCaseDesc		Change Event Type test.
sl@0
   571
						The test attempts to change the type of an existing event.
sl@0
   572
						The attempt must fails with KErrPermissionDenied error. 
sl@0
   573
@SYMTestActions			Change Event Type test.
sl@0
   574
@SYMTestExpectedResults Test must not fail
sl@0
   575
@SYMTestPriority		Medium
sl@0
   576
@SYMREQ					REQ12746
sl@0
   577
*/
sl@0
   578
void ChangeStandardEventTypeTestL()
sl@0
   579
	{
sl@0
   580
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
   581
	CleanupStack::PushL(client);
sl@0
   582
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   583
	CleanupStack::PushL(active);
sl@0
   584
	
sl@0
   585
	CLogEventType* evType = CLogEventType::NewL(); 
sl@0
   586
	CleanupStack::PushL(evType);
sl@0
   587
	TUid uid = {KLogCallEventType};
sl@0
   588
	evType->SetUid(uid);
sl@0
   589
	evType->SetDescription(_L("aaaaaaaa"));
sl@0
   590
sl@0
   591
	active->StartL();
sl@0
   592
	client->ChangeEventType(*evType, active->iStatus);
sl@0
   593
	CActiveScheduler::Start();
sl@0
   594
	TEST2(active->iStatus.Int(), KErrPermissionDenied);
sl@0
   595
	
sl@0
   596
	CleanupStack::PopAndDestroy(evType);
sl@0
   597
	
sl@0
   598
	CleanupStack::PopAndDestroy(active);
sl@0
   599
	CleanupStack::PopAndDestroy(client);
sl@0
   600
	}
sl@0
   601
sl@0
   602
CLogFilter* DoCreateFilter1LC()
sl@0
   603
	{
sl@0
   604
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   605
	CleanupStack::PushL(filter);
sl@0
   606
	
sl@0
   607
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
   608
	filter->SetSimId(KEvSimId2);
sl@0
   609
#endif	
sl@0
   610
	filter->SetDurationType(KEvDurationType2);
sl@0
   611
	filter->SetNumber(KEvNumber2);
sl@0
   612
	filter->SetStatus(KTestStatus1);
sl@0
   613
	filter->SetDirection(KTestDirection1);
sl@0
   614
	
sl@0
   615
	return filter;
sl@0
   616
	}
sl@0
   617
sl@0
   618
CLogFilter* DoCreateFilter2LC()
sl@0
   619
	{
sl@0
   620
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   621
	CleanupStack::PushL(filter);
sl@0
   622
sl@0
   623
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
   624
	filter->SetSimId(KEvSimId1);
sl@0
   625
#endif	
sl@0
   626
	filter->SetDurationType(KEvDurationType1);
sl@0
   627
	filter->SetNumber(KEvNumber1);
sl@0
   628
	filter->SetStatus(KTestStatus1);
sl@0
   629
	filter->SetDirection(KTestDirection1);
sl@0
   630
	filter->SetEventType(KEvTypeUid);
sl@0
   631
	filter->SetRemoteParty(KTestRemoteParty1);
sl@0
   632
	filter->SetNullFields(ELogFlagsField);
sl@0
   633
sl@0
   634
	return filter;
sl@0
   635
	}
sl@0
   636
sl@0
   637
CLogFilter* DoCreateFilter3LC()
sl@0
   638
	{
sl@0
   639
	CLogFilter* filter = CLogFilter::NewL();
sl@0
   640
	CleanupStack::PushL(filter);
sl@0
   641
sl@0
   642
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
   643
	filter->SetSimId(KEvSimId1);
sl@0
   644
#endif	
sl@0
   645
	filter->SetDurationType(KEvDurationType1);
sl@0
   646
	filter->SetNumber(KEvNumber1);
sl@0
   647
	filter->SetStatus(KTestStatus1);
sl@0
   648
	filter->SetDirection(KTestDirection1);
sl@0
   649
	filter->SetEventType(KEvTypeUid);
sl@0
   650
	filter->SetRemoteParty(KTestRemoteParty1);
sl@0
   651
	filter->SetContact(KEvContact1);
sl@0
   652
	filter->SetNullFields(ELogFlagsField);
sl@0
   653
sl@0
   654
	return filter;
sl@0
   655
	}
sl@0
   656
sl@0
   657
/**
sl@0
   658
@SYMTestCaseID			PDS-LOGENG-UT-4034
sl@0
   659
@SYMTestCaseDesc		Complex view filter set test.
sl@0
   660
						The test creates a set of filters using all event properties and duplicating some of them
sl@0
   661
						in the filters. Then sets the set of filters to a view and iterates over the view's events.
sl@0
   662
						The idea is to test as much as possible the server side filter processing in TLogFilterExprBuilder
sl@0
   663
						class implementation.
sl@0
   664
@SYMTestActions			Complex view filter set test.
sl@0
   665
@SYMTestExpectedResults Test must not fail
sl@0
   666
@SYMTestPriority		Medium
sl@0
   667
@SYMREQ					REQ12746
sl@0
   668
*/
sl@0
   669
void ComplexFilterSetTestL()
sl@0
   670
	{
sl@0
   671
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
   672
	CleanupStack::PushL(client);
sl@0
   673
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   674
	CleanupStack::PushL(active);
sl@0
   675
	CLogViewEvent* view = CLogViewEvent::NewL(*client);
sl@0
   676
	CleanupStack::PushL(view);
sl@0
   677
	CLogFilter* filter1 = DoCreateFilter1LC();
sl@0
   678
	CLogFilter* filter2 = DoCreateFilter2LC();
sl@0
   679
	CLogFilter* filter3 = DoCreateFilter3LC();
sl@0
   680
	CLogFilterList* filterList = new(ELeave)CLogFilterList;
sl@0
   681
	CleanupStack::PushL(filterList);
sl@0
   682
	filterList->AppendL(filter1);
sl@0
   683
	filterList->AppendL(filter2);
sl@0
   684
	filterList->AppendL(filter3);
sl@0
   685
	
sl@0
   686
	//Check the "copy filter list" operations
sl@0
   687
	CLogFilterList* filterList2 = filterList->CopyL();
sl@0
   688
	TEST2(filterList2->Count(), filterList->Count());
sl@0
   689
	delete filterList2;
sl@0
   690
	CLogFilterList* filterList3 = filterList->CopyLC();
sl@0
   691
	TEST2(filterList3->Count(), filterList->Count());
sl@0
   692
	CleanupStack::PopAndDestroy(filterList3);
sl@0
   693
	
sl@0
   694
	TTime st_time;
sl@0
   695
	st_time.UniversalTime();
sl@0
   696
	TBool res = view->SetFilterL(*filterList, active->iStatus);
sl@0
   697
	TEST(res);
sl@0
   698
	active->StartL();
sl@0
   699
	CActiveScheduler::Start();
sl@0
   700
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   701
	TInt count = view->CountL();
sl@0
   702
	TheTest.Printf(_L("===Events count: %d\n"), count);
sl@0
   703
	TTime end_time;
sl@0
   704
	end_time.UniversalTime();
sl@0
   705
	TTimeIntervalMicroSeconds us = end_time.MicroSecondsFrom(st_time);
sl@0
   706
	TheTest.Printf(_L("SetFilter(). Time: %ld milliseconds\n"), us.Int64() / 1000);
sl@0
   707
sl@0
   708
	st_time.UniversalTime();
sl@0
   709
	if(view->FirstL(active->iStatus))
sl@0
   710
		{
sl@0
   711
		count = 0; 
sl@0
   712
		do
sl@0
   713
			{
sl@0
   714
			active->StartL();
sl@0
   715
			CActiveScheduler::Start();
sl@0
   716
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
   717
			++count;
sl@0
   718
			}
sl@0
   719
		while(view->NextL(active->iStatus));
sl@0
   720
		}
sl@0
   721
	end_time.UniversalTime();
sl@0
   722
	us = end_time.MicroSecondsFrom(st_time);
sl@0
   723
	TheTest.Printf(_L("Event view walk completed. Events count: %d. Time: %ld milliseconds\n"), count, us.Int64() / 1000);
sl@0
   724
		
sl@0
   725
	CleanupStack::PopAndDestroy(filterList);
sl@0
   726
	CleanupStack::PopAndDestroy(filter3);
sl@0
   727
	CleanupStack::PopAndDestroy(filter2);
sl@0
   728
	CleanupStack::PopAndDestroy(filter1);
sl@0
   729
	CleanupStack::PopAndDestroy(view);
sl@0
   730
	CleanupStack::PopAndDestroy(active);
sl@0
   731
	CleanupStack::PopAndDestroy(client);
sl@0
   732
	}
sl@0
   733
sl@0
   734
#ifdef _DEBUG
sl@0
   735
static void StopLogServerL()
sl@0
   736
    {
sl@0
   737
    static RLogTestSession logServSession;
sl@0
   738
    //this function doesn't have any effect on UREL builds as LogEng server doesn't 
sl@0
   739
    //support the transient mode in UREL builds 
sl@0
   740
    //Used for LogEng server side heap failure testing.
sl@0
   741
    TInt error = KErrNone;
sl@0
   742
      
sl@0
   743
    if(!logServSession.Handle())
sl@0
   744
        {
sl@0
   745
        error = logServSession.Connect();
sl@0
   746
        }
sl@0
   747
      
sl@0
   748
    // Is the server running?
sl@0
   749
    if(error == KErrNotFound)
sl@0
   750
        {
sl@0
   751
        return;
sl@0
   752
        }
sl@0
   753
    LEAVE_IF_ERROR(error);
sl@0
   754
      
sl@0
   755
    // Make the server transient
sl@0
   756
    TInt p0 = 1;
sl@0
   757
    TIpcArgs  ipcArgs(p0);
sl@0
   758
    LEAVE_IF_ERROR(logServSession.Send(ELogMakeTransient, ipcArgs));
sl@0
   759
      
sl@0
   760
    logServSession.Close();
sl@0
   761
      
sl@0
   762
    User::After(6 * 1000000); // Enough time for the server to exit
sl@0
   763
    }
sl@0
   764
#else//_DEBUG
sl@0
   765
static void StopLogServerL()
sl@0
   766
    {
sl@0
   767
    TheTest.Printf(_L("StopLogServerL(): the LogEng server cannot be stopped in release mode. ELogMakeTransient is a debug message.\n"));
sl@0
   768
    }
sl@0
   769
#endif//_DEBUG
sl@0
   770
sl@0
   771
/**
sl@0
   772
@SYMTestCaseID          PDS-LOGENG-UT-4047
sl@0
   773
@SYMTestCaseDesc        Configuration value update test.
sl@0
   774
                        The test changes the configuration values & thne stops the log server. Start the 
sl@0
   775
                        server again & check if the configuration values are updated. 
sl@0
   776
                        Again restores the original value back. 
sl@0
   777
@SYMTestActions         Configuration value update test.
sl@0
   778
@SYMTestExpectedResults Test must not fail
sl@0
   779
@SYMTestPriority        Medium
sl@0
   780
@SYMREQ                 DEF142142
sl@0
   781
*/
sl@0
   782
void DoCheckUpdateConfigL()
sl@0
   783
    {
sl@0
   784
 
sl@0
   785
    CLogClient* client = CLogClient::NewL(theFs);
sl@0
   786
    CleanupStack::PushL(client);
sl@0
   787
    CTestActive* active = new(ELeave)CTestActive();
sl@0
   788
    CleanupStack::PushL(active);
sl@0
   789
sl@0
   790
    //Check for updated configurations.
sl@0
   791
    TLogConfig config;
sl@0
   792
    active->StartL();
sl@0
   793
    client->GetConfig(config, active->iStatus);
sl@0
   794
    CActiveScheduler::Start();
sl@0
   795
    TEST2(active->iStatus.Int(), KErrNone);
sl@0
   796
    
sl@0
   797
    //Set new max log size
sl@0
   798
    TLogSize tmpMaxLogSize = config.iMaxLogSize;
sl@0
   799
    config.iMaxLogSize = KMaxLogSize;
sl@0
   800
    config.iMaxRecentLogSize = KMaxRecentLogSize;
sl@0
   801
    active->StartL();
sl@0
   802
    client->ChangeConfig(config, active->iStatus);
sl@0
   803
    CActiveScheduler::Start();
sl@0
   804
    TEST2(active->iStatus.Int(), KErrNone);
sl@0
   805
    
sl@0
   806
    //Stop the Server
sl@0
   807
    StopLogServerL();
sl@0
   808
    
sl@0
   809
    //Test the new max log size
sl@0
   810
    active->StartL();
sl@0
   811
    client->GetConfig(config, active->iStatus);
sl@0
   812
    CActiveScheduler::Start();
sl@0
   813
    TEST2(active->iStatus.Int(), KErrNone);
sl@0
   814
    TEST2(config.iMaxLogSize, KMaxLogSize);
sl@0
   815
    
sl@0
   816
    //Set original max log size
sl@0
   817
    config.iMaxLogSize = tmpMaxLogSize;
sl@0
   818
    active->StartL();
sl@0
   819
    client->ChangeConfig(config, active->iStatus);
sl@0
   820
    CActiveScheduler::Start();
sl@0
   821
    TEST2(active->iStatus.Int(), KErrNone);
sl@0
   822
    
sl@0
   823
    CleanupStack::PopAndDestroy(active);
sl@0
   824
    CleanupStack::PopAndDestroy(client);
sl@0
   825
    }
sl@0
   826
sl@0
   827
//////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
   828
#ifdef SYSLIBS_TEST
sl@0
   829
sl@0
   830
TLogId DoAddEvent2TestRecentListL(CLogClient& aClient, CTestActive& aActive)
sl@0
   831
	{
sl@0
   832
	CLogEvent* event = CLogEvent::NewL();
sl@0
   833
	CleanupStack::PushL(event);
sl@0
   834
	
sl@0
   835
	event->SetEventType(KLogCallEventTypeUid);
sl@0
   836
	event->SetRemoteParty(KLogRctTListRemoteParty);
sl@0
   837
	event->SetDirection(KLogRctTListDirection);
sl@0
   838
	event->SetDurationType(KLogRctTListDurationType);
sl@0
   839
	event->SetDuration(KTestDuration1);
sl@0
   840
	event->SetStatus(KLogRctTListStatus);
sl@0
   841
	event->SetSubject(KTestSubject1);
sl@0
   842
	event->SetNumber(KLogRctTListNumber);
sl@0
   843
	event->SetContact(KEvContact1);
sl@0
   844
	event->SetLink(KEvLink1);
sl@0
   845
	event->SetDescription(KEvDesc1);
sl@0
   846
	event->SetFlags(KLogRctTListFlags);
sl@0
   847
	event->SetDataL(KTestData1);
sl@0
   848
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
   849
	event->SetSimId(KLogRctTListSimId);
sl@0
   850
#endif	
sl@0
   851
	
sl@0
   852
	aActive.StartL();
sl@0
   853
	aClient.AddEvent(*event, aActive.iStatus);
sl@0
   854
	CActiveScheduler::Start();
sl@0
   855
	TEST(!aActive.IsActive());
sl@0
   856
	TEST2(aActive.iStatus.Int(), KErrNone);
sl@0
   857
	TLogId logId = event->Id();
sl@0
   858
	
sl@0
   859
	//Get the just added event
sl@0
   860
	aActive.StartL();
sl@0
   861
	aClient.GetEvent(*event, aActive.iStatus);
sl@0
   862
	CActiveScheduler::Start();
sl@0
   863
	TEST2(aActive.iStatus.Int(), KErrNone);
sl@0
   864
	
sl@0
   865
	CleanupStack::PopAndDestroy(event);
sl@0
   866
	
sl@0
   867
	return logId;
sl@0
   868
	}
sl@0
   869
sl@0
   870
TLogId DoAddEvent2TestRecentListL()
sl@0
   871
	{
sl@0
   872
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
   873
	CleanupStack::PushL(client);
sl@0
   874
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   875
	CleanupStack::PushL(active);
sl@0
   876
sl@0
   877
	TLogId logId = DoAddEvent2TestRecentListL(*client, *active);
sl@0
   878
sl@0
   879
	CleanupStack::PopAndDestroy(active);
sl@0
   880
	CleanupStack::PopAndDestroy(client);
sl@0
   881
	
sl@0
   882
	return logId;
sl@0
   883
	}
sl@0
   884
sl@0
   885
struct TLogViewTestObserver : public MLogViewChangeObserver
sl@0
   886
	{
sl@0
   887
	TLogViewTestObserver() : 
sl@0
   888
		iIdAdded(-1),
sl@0
   889
		iIdChanged(-1),
sl@0
   890
		iIdDeleted(-1)
sl@0
   891
		{
sl@0
   892
		}
sl@0
   893
	virtual void HandleLogViewChangeEventAddedL(TLogId aId, TInt, TInt, TInt)
sl@0
   894
		{
sl@0
   895
		iIdAdded = aId;
sl@0
   896
		}
sl@0
   897
	virtual void HandleLogViewChangeEventChangedL(TLogId aId, TInt, TInt, TInt)
sl@0
   898
		{
sl@0
   899
		iIdChanged = aId;
sl@0
   900
		}
sl@0
   901
	virtual void HandleLogViewChangeEventDeletedL(TLogId aId, TInt, TInt, TInt)
sl@0
   902
		{
sl@0
   903
		iIdDeleted = aId;
sl@0
   904
		}
sl@0
   905
	TLogId iIdAdded;
sl@0
   906
	TLogId iIdChanged;
sl@0
   907
	TLogId iIdDeleted;
sl@0
   908
	};
sl@0
   909
	
sl@0
   910
void DoViewEventFromTestRecentListL(TLogId aId1, TLogId aId2)
sl@0
   911
	{
sl@0
   912
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
   913
	CleanupStack::PushL(client);
sl@0
   914
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   915
	CleanupStack::PushL(active);
sl@0
   916
	CLogViewRecent* view = CLogViewRecent::NewL(*client);
sl@0
   917
	CleanupStack::PushL(view);
sl@0
   918
	TLogViewTestObserver observer;
sl@0
   919
	CLogViewDuplicate* duplicate = CLogViewDuplicate::NewL(*client, observer);
sl@0
   920
	CleanupStack::PushL(duplicate);
sl@0
   921
	
sl@0
   922
	TBool rc = view->SetRecentListL(KLogRctTListId, active->iStatus);
sl@0
   923
	active->StartL();
sl@0
   924
	CActiveScheduler::Start();
sl@0
   925
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   926
	
sl@0
   927
	TInt count = 0; 
sl@0
   928
	if(view->FirstL(active->iStatus))
sl@0
   929
		{
sl@0
   930
		do
sl@0
   931
			{
sl@0
   932
			active->StartL();
sl@0
   933
			CActiveScheduler::Start();
sl@0
   934
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
   935
			const CLogEvent& e = view->Event();
sl@0
   936
			TEST2(aId2, e.Id());
sl@0
   937
			++count;
sl@0
   938
			}
sl@0
   939
		while(view->NextL(active->iStatus));
sl@0
   940
		}
sl@0
   941
	TEST2(count, 1);//The second event is a duplicate => not in the list
sl@0
   942
		
sl@0
   943
	//Check duplicates 
sl@0
   944
	active->StartL();
sl@0
   945
	rc = view->DuplicatesL(*duplicate, active->iStatus);
sl@0
   946
	TEST(rc);
sl@0
   947
	CActiveScheduler::Start();
sl@0
   948
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   949
	TEST2(duplicate->CountL(), 1);
sl@0
   950
	
sl@0
   951
	//Test the duplicated event
sl@0
   952
	rc = duplicate->FirstL(active->iStatus);
sl@0
   953
	TEST(rc);
sl@0
   954
	active->StartL();
sl@0
   955
	CActiveScheduler::Start();
sl@0
   956
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   957
	const CLogEvent& e2 = duplicate->Event();
sl@0
   958
	TEST2(aId1, e2.Id());
sl@0
   959
sl@0
   960
	//Get the event
sl@0
   961
	CLogEvent* event = CLogEvent::NewL();
sl@0
   962
	CleanupStack::PushL(event);
sl@0
   963
	event->SetId(aId1);
sl@0
   964
	active->StartL();
sl@0
   965
	client->GetEvent(*event, active->iStatus);
sl@0
   966
	CActiveScheduler::Start();
sl@0
   967
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   968
	
sl@0
   969
	//Change the event. The observer should register the change. 
sl@0
   970
	event->SetDataL(_L8("123444555"));
sl@0
   971
	client->ChangeEvent(*event, active->iStatus);
sl@0
   972
	active->StartL();
sl@0
   973
	CActiveScheduler::Start();
sl@0
   974
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   975
	TEST2(observer.iIdChanged, event->Id());
sl@0
   976
sl@0
   977
	//Add  a new event to the recent list. This operation should be detected as a "delete" one by the observer 
sl@0
   978
	//and the existing event should be cleared from the recent list.
sl@0
   979
	TLogId logId = DoAddEvent2TestRecentListL(*client, *active);
sl@0
   980
	TEST2(observer.iIdDeleted, aId1);
sl@0
   981
	TEST(logId != observer.iIdDeleted);
sl@0
   982
	//No added events detected by the observer
sl@0
   983
	TEST2(observer.iIdAdded, -1);
sl@0
   984
	
sl@0
   985
	//Cleanup
sl@0
   986
	CleanupStack::PopAndDestroy(event);
sl@0
   987
	CleanupStack::PopAndDestroy(duplicate);
sl@0
   988
	CleanupStack::PopAndDestroy(view);
sl@0
   989
	CleanupStack::PopAndDestroy(active);
sl@0
   990
	CleanupStack::PopAndDestroy(client);
sl@0
   991
	}
sl@0
   992
sl@0
   993
/**
sl@0
   994
@SYMTestCaseID			PDS-LOGENG-UT-4035
sl@0
   995
@SYMTestCaseDesc		Complex recent list test.
sl@0
   996
						The test works only if SYSLIBS_TEST macro is defined, in which case the server side will
sl@0
   997
						create a recent list with a lot of fields.
sl@0
   998
						The test case will add 2 events with the same properties, such that both will be added
sl@0
   999
						to that test recent list. Because the second event is a match of the first one and matches 
sl@0
  1000
						the recent list "duplicates" mask, the second event will be marked as a duplicate of the
sl@0
  1001
						first one. After adding the events a view is used to check for their presence.
sl@0
  1002
@SYMTestActions			Complex recent list test.
sl@0
  1003
@SYMTestExpectedResults Test must not fail
sl@0
  1004
@SYMTestPriority		Medium
sl@0
  1005
@SYMREQ					REQ12747
sl@0
  1006
*/
sl@0
  1007
void ComplexRecentListTestL()
sl@0
  1008
	{
sl@0
  1009
	TLogId logId1 = DoAddEvent2TestRecentListL();
sl@0
  1010
	TLogId logId2 = DoAddEvent2TestRecentListL();
sl@0
  1011
	DoViewEventFromTestRecentListL(logId1, logId2);
sl@0
  1012
	}
sl@0
  1013
sl@0
  1014
#endif//SYSLIBS_TEST
sl@0
  1015
//////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
  1016
sl@0
  1017
void doTestsL()
sl@0
  1018
	{
sl@0
  1019
    TestUtils::Initialize(_L("t_logapi2"));
sl@0
  1020
	TestUtils::DeleteDatabaseL();
sl@0
  1021
	//
sl@0
  1022
	TheTest.Start(_L("Preparation. Adding 200 events..."));
sl@0
  1023
	DoAddEventsL();
sl@0
  1024
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4029: AddEvent() server side OOM test when logged events count is max (200)"));
sl@0
  1025
	AddEventOomTestL(ELogOpAddEvent, KErrNone);
sl@0
  1026
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4029: AddEvent() server side OOM test when logged events count is max (200). Invalid event type."));
sl@0
  1027
	AddEventOomTestL(ELogOpAddEventInvalidType, KErrNotFound);
sl@0
  1028
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4030: AddEvent() server side OOM test when logged events count is max (200). Logging disabled."));
sl@0
  1029
	AddEventOomTestL(ELogOpAddEventLoggingDisabled, KErrNotSupported);
sl@0
  1030
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4030: ChangeEvent() server side OOM test when logged events count is max (200). The event does exist."));
sl@0
  1031
	ChangeEventOomTestL(ETrue);
sl@0
  1032
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4030: ChangeEvent() server side OOM test when logged events count is max (200). The event does not exist."));
sl@0
  1033
	ChangeEventOomTestL(EFalse);
sl@0
  1034
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4032: GetEvent() server side OOM test when logged events count is max (200)."));
sl@0
  1035
	GetEventOomTestL(ELogOpGetEvent, KErrNone);
sl@0
  1036
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4032: GetEvent() server side OOM test when logged events count is max (200). The event does not exist."));
sl@0
  1037
	GetEventOomTestL(ELogOpGetEventNotExists, KErrNotFound);
sl@0
  1038
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4032: GetEvent() server side OOM test when logged events count is max (200). The event id is 0."));
sl@0
  1039
	GetEventOomTestL(ELogOpGetEventZeroId, KErrNotFound);
sl@0
  1040
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4031: DeleteEvent() server side OOM test when logged events count is max (200). The event does exist."));
sl@0
  1041
	DeleteEventOomTestL(ETrue);
sl@0
  1042
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4031: DeleteEvent() server side OOM test when logged events count is max (200). The event does not exist."));
sl@0
  1043
	DeleteEventOomTestL(EFalse);
sl@0
  1044
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4033: Attempt to change one of the standard event types."));
sl@0
  1045
	ChangeStandardEventTypeTestL();
sl@0
  1046
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4042: \"Cancel Operation\" test"));
sl@0
  1047
	CancelOperationTest();
sl@0
  1048
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4034: Complex filter set test."));
sl@0
  1049
	ComplexFilterSetTestL();
sl@0
  1050
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4047: Check for updated configuration values"));
sl@0
  1051
	DoCheckUpdateConfigL();
sl@0
  1052
#ifdef SYSLIBS_TEST
sl@0
  1053
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4035: Complex recent list test."));
sl@0
  1054
	ComplexRecentListTestL();
sl@0
  1055
#endif
sl@0
  1056
	//
sl@0
  1057
	TestUtils::DeleteDatabaseL();
sl@0
  1058
	}