os/persistentdata/loggingservices/eventlogger/test/src/t_logapi.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <s32file.h>
sl@0
    17
#include <e32math.h>
sl@0
    18
#include <logview.h>
sl@0
    19
#include <s32mem.h> 
sl@0
    20
#include "t_logutil2.h"
sl@0
    21
#include "t_logutil3.h"
sl@0
    22
sl@0
    23
#define UNUSED_VAR(a) a = a
sl@0
    24
sl@0
    25
const TLogContactItemId KTestContact = 0x1234;
sl@0
    26
const TInt KTestEventNum = 10;
sl@0
    27
sl@0
    28
RTest TheTest(_L("t_logapi"));
sl@0
    29
sl@0
    30
const TUid KTestEventUid = {0x10005393};
sl@0
    31
_LIT(KTestEventDesc1, "Event Type Description");
sl@0
    32
_LIT(KTestEventDesc2, "Changed Event Description");
sl@0
    33
_LIT(KTestRemoteParty1, "Remote Party");
sl@0
    34
_LIT(KTestRemoteParty2, "Changed Remote Party");
sl@0
    35
_LIT(KTestDirection1, "Direction");
sl@0
    36
_LIT(KTestDirection2, "Changed Direction");
sl@0
    37
const TLogDurationType KTestDurationType1 = 1;
sl@0
    38
const TLogDurationType KTestDurationType2 = 2;
sl@0
    39
const TLogDuration KTestDuration1 = 0x1234;
sl@0
    40
const TLogDuration KTestDuration2 = 0x1234567;
sl@0
    41
_LIT(KTestStatus1, "Status");
sl@0
    42
_LIT(KTestStatus2, "Changed Status");
sl@0
    43
_LIT(KTestSubject1, "Subject");
sl@0
    44
_LIT(KTestSubject2, "Changed Subject");
sl@0
    45
_LIT(KTestNumber1, "TheNumber");
sl@0
    46
_LIT(KTestNumber2, "Changed Number");
sl@0
    47
const TLogContactItemId KTestContact1 = 0x1234;
sl@0
    48
const TLogContactItemId KTestContact2 = 0x1234567;
sl@0
    49
const TLogLink KTestLink1 = 0x1234;
sl@0
    50
const TLogLink KTestLink2 = 0x1234567;
sl@0
    51
_LIT8(KTestData1, "ABCDEFGH");
sl@0
    52
_LIT8(KTestData2, "IJKLMNOPQRSTUVWXYZ");
sl@0
    53
const TLogFlags KTestFlags1 = 0x5;
sl@0
    54
const TLogFlags KTestFlags2 = 0xA;
sl@0
    55
const TLogSize KTestMaxLogSize = 0xFFF;
sl@0
    56
const TLogRecentSize KTestMaxRecentLogSize = 0xF;
sl@0
    57
const TLogAge KTestMaxEventAge = 0xFFFFFFF;
sl@0
    58
sl@0
    59
TInt gTheId;
sl@0
    60
sl@0
    61
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
sl@0
    62
sl@0
    63
class TClientObserverTestReceiver : public MLogClientChangeObserver
sl@0
    64
	{
sl@0
    65
public:
sl@0
    66
	TClientObserverTestReceiver(TBool& aFlag) : iCallCount(0), iFlag(aFlag) { }
sl@0
    67
sl@0
    68
public:
sl@0
    69
	void HandleLogClientChangeEventL(TUid aChangeType, TInt /*aChangeParam1*/, TInt /*aChangeParam2*/, TInt /*aChangeParam3*/)
sl@0
    70
		{
sl@0
    71
		++iCallCount;
sl@0
    72
		iFlag = (aChangeType == KLogClientChangeEventLogCleared);
sl@0
    73
		}
sl@0
    74
	inline TInt CallCount() const { return iCallCount; }
sl@0
    75
	inline void Reset() { iCallCount = 0; iFlag = EFalse; }
sl@0
    76
sl@0
    77
private:
sl@0
    78
	TInt iCallCount;
sl@0
    79
	TBool& iFlag;
sl@0
    80
	};
sl@0
    81
sl@0
    82
/**
sl@0
    83
@SYMTestCaseID          SYSLIB-LOGENG-CT-0833
sl@0
    84
@SYMTestCaseDesc	    Client observer mechanism test
sl@0
    85
@SYMTestPriority 	    High
sl@0
    86
@SYMTestActions  	    Set the change observer,add an event type,clear the log and test for the status.
sl@0
    87
@SYMTestExpectedResults Test must not fail
sl@0
    88
@SYMREQ                 REQ0000
sl@0
    89
*/
sl@0
    90
LOCAL_C void TestClientObserverMechanismL(CLogClient& aClient)
sl@0
    91
	{	
sl@0
    92
	//
sl@0
    93
	TBool logClearedFlag = EFalse;
sl@0
    94
	TClientObserverTestReceiver testReceiver(logClearedFlag);
sl@0
    95
	//
sl@0
    96
	aClient.SetGlobalChangeObserverL(&testReceiver);
sl@0
    97
sl@0
    98
	TTime now;
sl@0
    99
	now.UniversalTime();
sl@0
   100
	TTime clearLogThreshold(now);
sl@0
   101
	clearLogThreshold -= TTimeIntervalDays(1);
sl@0
   102
	TTime past(now);
sl@0
   103
	past -= TTimeIntervalDays(2);
sl@0
   104
sl@0
   105
	// Make some events
sl@0
   106
	CLogEvent* event = CLogEvent::NewL();
sl@0
   107
	CleanupStack::PushL(event);
sl@0
   108
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   109
	CleanupStack::PushL(active);
sl@0
   110
	for(TInt i=0; i<10; i++)
sl@0
   111
		{
sl@0
   112
		event->SetEventType(KLogCallEventTypeUid);
sl@0
   113
		event->SetRemoteParty(KTestRemoteParty1);
sl@0
   114
		event->SetDirection(KTestDirection1);
sl@0
   115
		event->SetDurationType(KTestDurationType1);
sl@0
   116
		event->SetDuration(KTestDuration1);
sl@0
   117
		event->SetStatus(KTestStatus1);
sl@0
   118
		event->SetSubject(KTestSubject1);
sl@0
   119
		event->SetNumber(KTestNumber1);
sl@0
   120
		event->SetContact((TLogContactItemId) i+1);
sl@0
   121
		event->SetLink(KTestLink1);
sl@0
   122
		event->SetDataL(KTestData1);
sl@0
   123
		event->SetFlags(KTestFlags1);
sl@0
   124
sl@0
   125
		// Add event
sl@0
   126
		active->StartL();
sl@0
   127
		aClient.AddEvent(*event, active->iStatus);
sl@0
   128
		CActiveScheduler::Start();
sl@0
   129
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   130
sl@0
   131
		// Make it in the past
sl@0
   132
		event->SetTime(past);
sl@0
   133
		active->StartL();
sl@0
   134
		aClient.ChangeEvent(*event, active->iStatus);
sl@0
   135
		CActiveScheduler::Start();
sl@0
   136
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   137
		}
sl@0
   138
	TEST2(testReceiver.CallCount(), 0);
sl@0
   139
sl@0
   140
	// Clear the log
sl@0
   141
	active->StartL();
sl@0
   142
	aClient.ClearLog(clearLogThreshold, active->iStatus);
sl@0
   143
	CActiveScheduler::Start();
sl@0
   144
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   145
sl@0
   146
	// Have to wait a while, since the change observer active object
sl@0
   147
	// won't run until shortly after completing the 'clear log' operation
sl@0
   148
	// request status.
sl@0
   149
	CTestTimer* timer = CTestTimer::NewL();
sl@0
   150
	CleanupStack::PushL(timer);
sl@0
   151
	timer->After(5 * 1000000);
sl@0
   152
	CActiveScheduler::Start();
sl@0
   153
	CleanupStack::PopAndDestroy(timer);
sl@0
   154
	//
sl@0
   155
	TEST2(testReceiver.CallCount(), 1);
sl@0
   156
	TEST(logClearedFlag);
sl@0
   157
sl@0
   158
	// Start again
sl@0
   159
	testReceiver.Reset();
sl@0
   160
sl@0
   161
	// Test removing observer
sl@0
   162
	aClient.SetGlobalChangeObserverL(NULL);
sl@0
   163
sl@0
   164
	// Add an event again
sl@0
   165
	active->StartL();
sl@0
   166
	aClient.AddEvent(*event, active->iStatus);
sl@0
   167
	CActiveScheduler::Start();
sl@0
   168
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   169
	TEST2(testReceiver.CallCount(), 0);
sl@0
   170
sl@0
   171
	// Make it in the past
sl@0
   172
	event->SetTime(past);
sl@0
   173
	active->StartL(); 
sl@0
   174
	aClient.ChangeEvent(*event, active->iStatus);
sl@0
   175
	CActiveScheduler::Start();
sl@0
   176
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   177
sl@0
   178
	// Clear the log again
sl@0
   179
	active->StartL();
sl@0
   180
	aClient.ClearLog(clearLogThreshold, active->iStatus);
sl@0
   181
	CActiveScheduler::Start();
sl@0
   182
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   183
	TEST2(testReceiver.CallCount(), 0);
sl@0
   184
	TEST(logClearedFlag == EFalse);
sl@0
   185
sl@0
   186
	aClient.SetGlobalChangeObserverL(&testReceiver);
sl@0
   187
sl@0
   188
	// Tidy up
sl@0
   189
	CleanupStack::PopAndDestroy(2, event); // active, event
sl@0
   190
	}
sl@0
   191
sl@0
   192
/**
sl@0
   193
@SYMTestCaseID          SYSLIB-LOGENG-CT-0834
sl@0
   194
@SYMTestCaseDesc	    Adding an event to the log engine test.
sl@0
   195
@SYMTestPriority 	    High
sl@0
   196
@SYMTestActions  	    Create a new event type and add that to the log engine.
sl@0
   197
                        Start an active scheduler and check for the  error status.
sl@0
   198
                        Add the event once again and check for the already exits condition.
sl@0
   199
@SYMTestExpectedResults Test must not fail
sl@0
   200
@SYMREQ                 REQ0000
sl@0
   201
*/
sl@0
   202
LOCAL_C void TestAddEventTypeL(CLogClient& aClient)
sl@0
   203
//
sl@0
   204
//
sl@0
   205
//
sl@0
   206
	{
sl@0
   207
	LOGTEXT("TestAddEventTypeL()");	
sl@0
   208
	CLogEventType* type = CLogEventType::NewL();
sl@0
   209
	CleanupStack::PushL(type);
sl@0
   210
sl@0
   211
	type->SetUid(KTestEventUid);
sl@0
   212
	type->SetDescription(KTestEventDesc1);
sl@0
   213
	type->SetLoggingEnabled(ETrue);
sl@0
   214
sl@0
   215
	CTestActive* active = new(ELeave) CTestActive();
sl@0
   216
	CleanupStack::PushL(active);
sl@0
   217
sl@0
   218
	active->StartL();
sl@0
   219
	aClient.AddEventType(*type, active->iStatus);
sl@0
   220
	aClient.Cancel();
sl@0
   221
	CActiveScheduler::Start();
sl@0
   222
	TEST2(active->iStatus.Int(), KErrCancel);
sl@0
   223
sl@0
   224
	active->StartL();
sl@0
   225
	aClient.AddEventType(*type, active->iStatus);
sl@0
   226
	CActiveScheduler::Start();
sl@0
   227
	aClient.Cancel();
sl@0
   228
	TEST((active->iStatus == KErrNone)||(active->iStatus == KErrAlreadyExists));
sl@0
   229
sl@0
   230
	active->StartL();
sl@0
   231
	aClient.AddEventType(*type, active->iStatus);
sl@0
   232
	CActiveScheduler::Start();
sl@0
   233
	TEST2(active->iStatus.Int(), KErrAlreadyExists);
sl@0
   234
sl@0
   235
	CleanupStack::PopAndDestroy(2); // active, type
sl@0
   236
	LOGTEXT("TestAddEventTypeL() - end");
sl@0
   237
	}
sl@0
   238
/**
sl@0
   239
@SYMTestCaseID          SYSLIB-LOGENG-CT-0835
sl@0
   240
@SYMTestCaseDesc	    Retrieving the event type information test.
sl@0
   241
                        Tests for CLogClient::GetEventType() function.
sl@0
   242
@SYMTestPriority 	    High
sl@0
   243
@SYMTestActions  	    Tests for the retrieved information of event type. 
sl@0
   244
@SYMTestExpectedResults Test must not fail
sl@0
   245
@SYMREQ                 REQ0000
sl@0
   246
*/
sl@0
   247
LOCAL_C void TestGetEventTypeL(CLogClient& aClient)
sl@0
   248
//
sl@0
   249
//
sl@0
   250
//
sl@0
   251
	{
sl@0
   252
	LOGTEXT("TestGetEventTypeL()");	
sl@0
   253
	CLogEventType* type = CLogEventType::NewL();
sl@0
   254
	CleanupStack::PushL(type);
sl@0
   255
sl@0
   256
	type->SetUid(KTestEventUid);
sl@0
   257
sl@0
   258
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   259
	CleanupStack::PushL(active);
sl@0
   260
sl@0
   261
	active->StartL();
sl@0
   262
	aClient.GetEventType(*type, active->iStatus);
sl@0
   263
	aClient.Cancel();
sl@0
   264
	CActiveScheduler::Start();
sl@0
   265
	TEST2(active->iStatus.Int(), KErrCancel);
sl@0
   266
sl@0
   267
	active->StartL();
sl@0
   268
	aClient.GetEventType(*type, active->iStatus);
sl@0
   269
	CActiveScheduler::Start();
sl@0
   270
	aClient.Cancel();
sl@0
   271
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   272
sl@0
   273
	TEST(type->Uid() == KTestEventUid);
sl@0
   274
	TEST(type->Description() == KTestEventDesc1);
sl@0
   275
	TEST(type->LoggingEnabled());
sl@0
   276
sl@0
   277
	CleanupStack::PopAndDestroy(2); // active, type
sl@0
   278
	LOGTEXT("TestGetEventTypeL() - end");
sl@0
   279
	}
sl@0
   280
sl@0
   281
/**
sl@0
   282
@SYMTestCaseID          SYSLIB-LOGENG-CT-0836
sl@0
   283
@SYMTestCaseDesc	    Changing the event type test.
sl@0
   284
                        Tests for CLogClient::ChangeEventType test
sl@0
   285
@SYMTestPriority 	    High
sl@0
   286
@SYMTestActions  	    Create a new event type,change the event type and check for any errors
sl@0
   287
@SYMTestExpectedResults Test must not fail
sl@0
   288
@SYMREQ                 REQ0000
sl@0
   289
*/
sl@0
   290
LOCAL_C void TestChangeEventTypeL(CLogClient& aClient)
sl@0
   291
//
sl@0
   292
//
sl@0
   293
//
sl@0
   294
	{
sl@0
   295
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0836 "));
sl@0
   296
	LOGTEXT("TestChangeEventTypeL()");	
sl@0
   297
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   298
	CleanupStack::PushL(active);
sl@0
   299
sl@0
   300
	CLogEventType* type = CLogEventType::NewL();
sl@0
   301
	CleanupStack::PushL(type);
sl@0
   302
sl@0
   303
	type->SetUid(KTestEventUid);
sl@0
   304
	type->SetDescription(KTestEventDesc2);
sl@0
   305
	type->SetLoggingEnabled(EFalse);
sl@0
   306
sl@0
   307
	active->StartL();
sl@0
   308
	aClient.ChangeEventType(*type, active->iStatus);
sl@0
   309
	aClient.Cancel();
sl@0
   310
	CActiveScheduler::Start();
sl@0
   311
	TEST2(active->iStatus.Int(), KErrCancel);
sl@0
   312
sl@0
   313
	active->StartL();
sl@0
   314
	aClient.ChangeEventType(*type, active->iStatus);
sl@0
   315
	CActiveScheduler::Start();
sl@0
   316
	aClient.Cancel();
sl@0
   317
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   318
sl@0
   319
	CleanupStack::PopAndDestroy(); // type
sl@0
   320
sl@0
   321
	type = CLogEventType::NewL();
sl@0
   322
	CleanupStack::PushL(type);
sl@0
   323
sl@0
   324
	type->SetUid(KTestEventUid);
sl@0
   325
sl@0
   326
	active->StartL();
sl@0
   327
	aClient.GetEventType(*type, active->iStatus);
sl@0
   328
	CActiveScheduler::Start();
sl@0
   329
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   330
sl@0
   331
	TEST(type->Uid() == KTestEventUid);
sl@0
   332
	TEST(type->Description() == KTestEventDesc2);
sl@0
   333
	TEST(type->LoggingEnabled() == EFalse);
sl@0
   334
sl@0
   335
	CleanupStack::PopAndDestroy(2); // type, active
sl@0
   336
	LOGTEXT("TestChangeEventTypeL() - end");
sl@0
   337
	}
sl@0
   338
sl@0
   339
/**
sl@0
   340
@SYMTestCaseID          SYSLIB-LOGENG-CT-0837
sl@0
   341
@SYMTestCaseDesc	    Deleting an event type test.
sl@0
   342
                        Tests for CLogClient::DeleteEventType() test
sl@0
   343
@SYMTestPriority 	    High
sl@0
   344
@SYMTestActions  	    Delete an event type from log database and test for no errors found
sl@0
   345
@SYMTestExpectedResults Test must not fail
sl@0
   346
@SYMREQ                 REQ0000
sl@0
   347
*/
sl@0
   348
LOCAL_C void TestDeleteEventTypeL(CLogClient& aClient)
sl@0
   349
//
sl@0
   350
//
sl@0
   351
//
sl@0
   352
	{
sl@0
   353
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0837 "));
sl@0
   354
	LOGTEXT("TestChangeEventTypeL()");	
sl@0
   355
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   356
	CleanupStack::PushL(active);
sl@0
   357
sl@0
   358
	active->StartL();
sl@0
   359
	aClient.DeleteEventType(KTestEventUid, active->iStatus);
sl@0
   360
	aClient.Cancel();
sl@0
   361
	CActiveScheduler::Start();
sl@0
   362
	TEST2(active->iStatus.Int(), KErrCancel);
sl@0
   363
sl@0
   364
	active->StartL();
sl@0
   365
	aClient.DeleteEventType(KTestEventUid, active->iStatus);
sl@0
   366
	CActiveScheduler::Start();
sl@0
   367
	aClient.Cancel();
sl@0
   368
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   369
sl@0
   370
	CLogEventType* type = CLogEventType::NewL();
sl@0
   371
	CleanupStack::PushL(type);
sl@0
   372
sl@0
   373
	type->SetUid(KTestEventUid);
sl@0
   374
sl@0
   375
	active->StartL();
sl@0
   376
	aClient.GetEventType(*type, active->iStatus);
sl@0
   377
	CActiveScheduler::Start();
sl@0
   378
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
   379
sl@0
   380
	CleanupStack::PopAndDestroy(2); // type, active
sl@0
   381
	LOGTEXT("TestChangeEventTypeL() - end");
sl@0
   382
	}
sl@0
   383
sl@0
   384
/**
sl@0
   385
@SYMTestCaseID          SYSLIB-LOGENG-CT-1329
sl@0
   386
@SYMTestCaseDesc	    Adding an event type test.
sl@0
   387
                        Tests for CLogClient::AddEventType() function
sl@0
   388
@SYMTestPriority 	    High
sl@0
   389
@SYMTestActions  	    Add an event type to the log database and test for no errors found
sl@0
   390
@SYMTestExpectedResults Test must not fail
sl@0
   391
@SYMREQ                 REQ0000
sl@0
   392
*/
sl@0
   393
LOCAL_C void TestAddEventL(CLogClient& aClient)
sl@0
   394
//
sl@0
   395
//
sl@0
   396
//
sl@0
   397
	{
sl@0
   398
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1329 "));	
sl@0
   399
	CLogEventType* type = CLogEventType::NewL();
sl@0
   400
	CleanupStack::PushL(type);
sl@0
   401
sl@0
   402
	type->SetUid(KTestEventUid);
sl@0
   403
	type->SetDescription(KTestEventDesc1);
sl@0
   404
	type->SetLoggingEnabled(ETrue);
sl@0
   405
sl@0
   406
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   407
	CleanupStack::PushL(active);
sl@0
   408
sl@0
   409
	active->StartL();
sl@0
   410
	aClient.AddEventType(*type, active->iStatus);
sl@0
   411
	CActiveScheduler::Start();
sl@0
   412
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   413
sl@0
   414
	CLogEvent* event = CLogEvent::NewL();
sl@0
   415
	CleanupStack::PushL(event);
sl@0
   416
sl@0
   417
	// Reset
sl@0
   418
	gTheId = KLogNullId;
sl@0
   419
	//
sl@0
   420
	TTime now;
sl@0
   421
	now.UniversalTime();
sl@0
   422
sl@0
   423
	event->SetEventType(KTestEventUid);
sl@0
   424
	event->SetRemoteParty(KTestRemoteParty1);
sl@0
   425
	event->SetDirection(KTestDirection1);
sl@0
   426
	event->SetDurationType(KTestDurationType1);
sl@0
   427
	event->SetDuration(KTestDuration1);
sl@0
   428
	event->SetStatus(KTestStatus1);
sl@0
   429
	event->SetSubject(KTestSubject1);
sl@0
   430
	event->SetNumber(KTestNumber1);
sl@0
   431
	event->SetContact(KTestContact1);
sl@0
   432
	event->SetLink(KTestLink1);
sl@0
   433
	event->SetDataL(KTestData1);
sl@0
   434
	event->SetFlags(KTestFlags1);
sl@0
   435
	//
sl@0
   436
	active->StartL();
sl@0
   437
	aClient.AddEvent(*event, active->iStatus);
sl@0
   438
	aClient.Cancel();
sl@0
   439
	CActiveScheduler::Start();
sl@0
   440
	TEST2(active->iStatus.Int(), KErrCancel);
sl@0
   441
	//
sl@0
   442
	active->StartL();
sl@0
   443
	aClient.AddEvent(*event, active->iStatus);
sl@0
   444
	CActiveScheduler::Start();
sl@0
   445
	TEST(!active->IsActive());
sl@0
   446
	aClient.Cancel();
sl@0
   447
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   448
	//
sl@0
   449
	gTheId=event->Id();
sl@0
   450
	//
sl@0
   451
	TEST(gTheId != KLogNullId);
sl@0
   452
	TEST(event->Time() >= now);
sl@0
   453
	TEST(event->Description() == KTestEventDesc1);
sl@0
   454
	//
sl@0
   455
	CleanupStack::PopAndDestroy(3); // event, active, type
sl@0
   456
	}
sl@0
   457
sl@0
   458
/**
sl@0
   459
@SYMTestCaseID          SYSLIB-LOGENG-CT-0838
sl@0
   460
@SYMTestCaseDesc	    Client failure test
sl@0
   461
@SYMTestPriority 	    High
sl@0
   462
@SYMTestActions  	    Checks for status after client is deleted,checks for Cancel error flag
sl@0
   463
@SYMTestExpectedResults Test must not fail
sl@0
   464
@SYMREQ                 REQ0000
sl@0
   465
*/
sl@0
   466
LOCAL_C void TestClientFailL()
sl@0
   467
	{
sl@0
   468
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0838 "));	
sl@0
   469
	CLogEvent* event = CLogEvent::NewL();
sl@0
   470
	CleanupStack::PushL(event);
sl@0
   471
sl@0
   472
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   473
	CleanupStack::PushL(active);
sl@0
   474
sl@0
   475
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
   476
	CleanupStack::PushL(client);
sl@0
   477
sl@0
   478
	event->SetId(gTheId);
sl@0
   479
sl@0
   480
	active->StartL();
sl@0
   481
	client->GetEvent(*event, active->iStatus);
sl@0
   482
	CleanupStack::Pop(); // client
sl@0
   483
	delete client;	
sl@0
   484
	
sl@0
   485
	CActiveScheduler::Start();
sl@0
   486
	TEST2(active->iStatus.Int(), KErrCancel);
sl@0
   487
sl@0
   488
	CleanupStack::PopAndDestroy(2); // event, active
sl@0
   489
	}
sl@0
   490
sl@0
   491
/**
sl@0
   492
@SYMTestCaseID          SYSLIB-LOGENG-CT-0839
sl@0
   493
@SYMTestCaseDesc	    Tests for CLogClient::GetEvent() function
sl@0
   494
@SYMTestPriority 	    High
sl@0
   495
@SYMTestActions  	    Retrieve the event type and test for the integrity of the event type information
sl@0
   496
                        Check for no errors
sl@0
   497
@SYMTestExpectedResults Test must not fail
sl@0
   498
@SYMREQ                 REQ0000
sl@0
   499
*/
sl@0
   500
sl@0
   501
LOCAL_C void TestGetEventL(CLogClient& aClient)
sl@0
   502
//
sl@0
   503
//
sl@0
   504
//
sl@0
   505
	{
sl@0
   506
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0839 "));
sl@0
   507
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   508
	CleanupStack::PushL(active);
sl@0
   509
sl@0
   510
	CLogEvent* event = CLogEvent::NewL();
sl@0
   511
	CleanupStack::PushL(event);
sl@0
   512
sl@0
   513
	event->SetId(gTheId);
sl@0
   514
sl@0
   515
	active->StartL();
sl@0
   516
	aClient.GetEvent(*event, active->iStatus);
sl@0
   517
	aClient.Cancel();
sl@0
   518
	CActiveScheduler::Start();
sl@0
   519
	TEST2(active->iStatus.Int(), KErrCancel);
sl@0
   520
sl@0
   521
	active->StartL();
sl@0
   522
	aClient.GetEvent(*event, active->iStatus);
sl@0
   523
	CActiveScheduler::Start();
sl@0
   524
	aClient.Cancel();
sl@0
   525
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   526
sl@0
   527
	TEST(event->Id() == gTheId);
sl@0
   528
	TEST(event->Time() > TTime(0));
sl@0
   529
	TEST(event->Description() == KTestEventDesc1);
sl@0
   530
	TEST(event->EventType() == KTestEventUid);
sl@0
   531
	TEST(event->RemoteParty() == KTestRemoteParty1);
sl@0
   532
	TEST(event->Direction() == KTestDirection1);
sl@0
   533
	TEST(event->DurationType() == KTestDurationType1);
sl@0
   534
	TEST(event->Duration() == KTestDuration1);
sl@0
   535
	TEST(event->Status() == KTestStatus1);
sl@0
   536
	TEST(event->Subject() == KTestSubject1);
sl@0
   537
	TEST(event->Number() == KTestNumber1);
sl@0
   538
	TEST(event->Contact() == KTestContact1);
sl@0
   539
	TEST(event->Link() == KTestLink1);
sl@0
   540
	TEST(event->Data() == KTestData1);
sl@0
   541
	TEST(event->Flags() == KTestFlags1);
sl@0
   542
sl@0
   543
	TBuf<500> subject;
sl@0
   544
	TInt i=450;
sl@0
   545
	while(i--)
sl@0
   546
		subject.Append(_L("a"));
sl@0
   547
	event->SetSubject(subject);
sl@0
   548
sl@0
   549
	active->StartL();
sl@0
   550
	aClient.AddEvent(*event, active->iStatus);
sl@0
   551
	CActiveScheduler::Start();
sl@0
   552
	if	(aClient.IsActive() && active->iStatus == KRequestPending)
sl@0
   553
		{
sl@0
   554
		aClient.Cancel();
sl@0
   555
		CActiveScheduler::Start();
sl@0
   556
		TEST2(active->iStatus.Int(), KErrCancel);
sl@0
   557
		}
sl@0
   558
	else
sl@0
   559
		{
sl@0
   560
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
   561
		}
sl@0
   562
sl@0
   563
	// See TestAddEventL on why this might still allow the active object
sl@0
   564
	// to be cancelled.
sl@0
   565
//	TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel);
sl@0
   566
sl@0
   567
	i=450;
sl@0
   568
	while(i--)
sl@0
   569
		subject[i]='b';
sl@0
   570
	event->SetSubject(subject);
sl@0
   571
sl@0
   572
	active->StartL();
sl@0
   573
	aClient.GetEvent(*event, active->iStatus);
sl@0
   574
	CActiveScheduler::Start();
sl@0
   575
	aClient.Cancel();
sl@0
   576
 	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   577
sl@0
   578
sl@0
   579
	CleanupStack::PopAndDestroy(2); // event, active
sl@0
   580
	}
sl@0
   581
sl@0
   582
/**
sl@0
   583
@SYMTestCaseID          SYSLIB-LOGENG-CT-0840
sl@0
   584
@SYMTestCaseDesc	    Tests for CLogClient::ChangeEvent() function 
sl@0
   585
@SYMTestPriority 	    High
sl@0
   586
@SYMTestActions  	    Change the event,get the event information and test for the integrity.
sl@0
   587
                        Check for any errors.
sl@0
   588
@SYMTestExpectedResults Test must not fail
sl@0
   589
@SYMREQ                 REQ0000
sl@0
   590
*/
sl@0
   591
LOCAL_C void TestChangeEventL(CLogClient& aClient)
sl@0
   592
//
sl@0
   593
//
sl@0
   594
//
sl@0
   595
	{
sl@0
   596
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0840 "));
sl@0
   597
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   598
	CleanupStack::PushL(active);
sl@0
   599
sl@0
   600
	CLogEvent* event = CLogEvent::NewL();
sl@0
   601
	CleanupStack::PushL(event);
sl@0
   602
sl@0
   603
	TTime now;
sl@0
   604
	now.UniversalTime();
sl@0
   605
sl@0
   606
	event->SetId(gTheId);
sl@0
   607
	event->SetTime(now);
sl@0
   608
	event->SetRemoteParty(KTestRemoteParty2);
sl@0
   609
	event->SetDirection(KTestDirection2);
sl@0
   610
	event->SetDurationType(KTestDurationType2);
sl@0
   611
	event->SetDuration(KTestDuration2);
sl@0
   612
	event->SetStatus(KTestStatus2);
sl@0
   613
	event->SetSubject(KTestSubject2);
sl@0
   614
	event->SetNumber(KTestNumber2);
sl@0
   615
	event->SetContact(KTestContact2);
sl@0
   616
	event->SetLink(KTestLink2);
sl@0
   617
	event->SetDataL(KTestData2);
sl@0
   618
	event->SetFlags(KTestFlags2);
sl@0
   619
sl@0
   620
	active->StartL();
sl@0
   621
	aClient.ChangeEvent(*event, active->iStatus);
sl@0
   622
	aClient.Cancel();
sl@0
   623
	CActiveScheduler::Start();
sl@0
   624
	TEST2(active->iStatus.Int(), KErrCancel);
sl@0
   625
sl@0
   626
	active->StartL();
sl@0
   627
	aClient.ChangeEvent(*event, active->iStatus);
sl@0
   628
	CActiveScheduler::Start();
sl@0
   629
	aClient.Cancel();
sl@0
   630
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   631
sl@0
   632
	CleanupStack::PopAndDestroy(); // event
sl@0
   633
sl@0
   634
	event = CLogEvent::NewL();
sl@0
   635
	CleanupStack::PushL(event);
sl@0
   636
sl@0
   637
	event->SetId(gTheId);
sl@0
   638
sl@0
   639
	active->StartL();
sl@0
   640
	aClient.GetEvent(*event, active->iStatus);
sl@0
   641
	CActiveScheduler::Start();
sl@0
   642
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   643
sl@0
   644
	TEST(event->Id() == gTheId);
sl@0
   645
	TEST(event->Time() == now);
sl@0
   646
	TEST(event->Description() == KTestEventDesc1);
sl@0
   647
	TEST(event->EventType() == KTestEventUid);
sl@0
   648
	TEST(event->RemoteParty() == KTestRemoteParty2);
sl@0
   649
	TEST(event->Direction() == KTestDirection2);
sl@0
   650
	TEST(event->DurationType() == KTestDurationType2);
sl@0
   651
	TEST(event->Duration() == KTestDuration2);
sl@0
   652
	TEST(event->Status() == KTestStatus2);
sl@0
   653
	TEST(event->Subject() == KTestSubject2);
sl@0
   654
	TEST(event->Number() == KTestNumber2);
sl@0
   655
	TEST(event->Contact() == KTestContact2);
sl@0
   656
	TEST(event->Link() == KTestLink2);
sl@0
   657
	TEST(event->Data() == KTestData2);
sl@0
   658
	TEST(event->Flags() == KTestFlags2);
sl@0
   659
sl@0
   660
	CleanupStack::PopAndDestroy(2); // event, active
sl@0
   661
	}
sl@0
   662
sl@0
   663
/**
sl@0
   664
@SYMTestCaseID          SYSLIB-LOGENG-CT-0841
sl@0
   665
@SYMTestCaseDesc	    Tests for CLogClient::DeleteEvent() function 
sl@0
   666
@SYMTestPriority 	    High
sl@0
   667
@SYMTestActions  	    Delete the event and test for no errors found.
sl@0
   668
@SYMTestExpectedResults Test must not fail
sl@0
   669
@SYMREQ                 REQ0000
sl@0
   670
*/
sl@0
   671
LOCAL_C void TestDeleteEventL(CLogClient& aClient)
sl@0
   672
//
sl@0
   673
//
sl@0
   674
//
sl@0
   675
	{
sl@0
   676
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0841 "));
sl@0
   677
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   678
	CleanupStack::PushL(active);
sl@0
   679
sl@0
   680
	active->StartL();
sl@0
   681
	aClient.DeleteEvent(0, active->iStatus);
sl@0
   682
	aClient.Cancel();
sl@0
   683
	CActiveScheduler::Start();
sl@0
   684
	TEST2(active->iStatus.Int(), KErrCancel);
sl@0
   685
sl@0
   686
	active->StartL();
sl@0
   687
	aClient.DeleteEvent(0, active->iStatus);
sl@0
   688
	CActiveScheduler::Start();
sl@0
   689
	aClient.Cancel();
sl@0
   690
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   691
sl@0
   692
	CLogEvent* event = CLogEvent::NewL();
sl@0
   693
	CleanupStack::PushL(event);
sl@0
   694
sl@0
   695
	event->SetId(0);
sl@0
   696
sl@0
   697
	active->StartL();
sl@0
   698
	aClient.GetEvent(*event, active->iStatus);
sl@0
   699
	CActiveScheduler::Start();
sl@0
   700
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
   701
sl@0
   702
	CleanupStack::PopAndDestroy(2); // event, active
sl@0
   703
	}
sl@0
   704
sl@0
   705
sl@0
   706
#ifdef SYSLIBS_TEST
sl@0
   707
sl@0
   708
/**
sl@0
   709
@SYMTestCaseID          SYSLIB-LOGENG-UT-4015
sl@0
   710
@SYMTestCaseDesc	    Test the behaviour implemented by PREQ2103
sl@0
   711
@SYMTestPriority 	    Medium
sl@0
   712
@SYMTestActions  	    Get the settings from logeng repository file / resource file.
sl@0
   713
@SYMTestExpectedResults Test must not fail
sl@0
   714
@SYMREQ                 REQ11125
sl@0
   715
                        REQ11126
sl@0
   716
                        REQ11127
sl@0
   717
                        REQ11128
sl@0
   718
*/
sl@0
   719
LOCAL_C void TestGetConfigSettingsFromRepositoryFileL(CLogClient& aClient)
sl@0
   720
	{
sl@0
   721
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-UT-4015 "));
sl@0
   722
sl@0
   723
	TInt contactMatchCount1;
sl@0
   724
	TLogContactNameFormat contactNameFormat1;
sl@0
   725
	LogGetContactmatchCountAndNameFormatL(contactMatchCount1, contactNameFormat1);
sl@0
   726
	TheTest.Printf(_L("Contact match count = %d, contact name format = %d\r\n"), contactMatchCount1, (TInt)contactNameFormat1);
sl@0
   727
	//contactMatchCount1 and contactNameFormat1 are loaded directly from the repository, if exists.
sl@0
   728
	//Otherwise they are initialzied with their default values.
sl@0
   729
	//The LogEng server should load these resource values in a similar way.
sl@0
   730
	//They will be stored in contactMatchCount2 and contactNameFormat2.  
sl@0
   731
	TInt16 contactMatchCount2;
sl@0
   732
	TInt16 contactNameFormat2;
sl@0
   733
	RFs fs;
sl@0
   734
	
sl@0
   735
	LEAVE_IF_ERROR(fs.Connect());
sl@0
   736
	CleanupClosePushL(fs);
sl@0
   737
	
sl@0
   738
	//Creating a new CLogClient Object make the server getting the contact match settings. 
sl@0
   739
	//As the database is deleted it gets them from the LogEng repository.
sl@0
   740
	CLogClient* client2 = CLogClient::NewL(fs);
sl@0
   741
	CleanupStack::PushL(client2);
sl@0
   742
	CleanupStack::PopAndDestroy(client2);
sl@0
   743
		
sl@0
   744
	//Read these settings via "reader" object.
sl@0
   745
	RFileReadStream resFileCount_reader;
sl@0
   746
	CleanupClosePushL(resFileCount_reader);
sl@0
   747
	RFileReadStream resFileFormat_reader;
sl@0
   748
	CleanupClosePushL(resFileFormat_reader);
sl@0
   749
	_LIT(KLogengTestFileNameCount, "c:\\test\\test_logengconfig_count.ini");
sl@0
   750
	_LIT(KLogengTestFileNameFormat, "c:\\test\\test_logengconfig_format.ini");
sl@0
   751
	LEAVE_IF_ERROR(resFileCount_reader.Open(fs, KLogengTestFileNameCount, EFileRead));
sl@0
   752
	LEAVE_IF_ERROR(resFileFormat_reader.Open(fs, KLogengTestFileNameFormat, EFileRead));		
sl@0
   753
	contactMatchCount2 = resFileCount_reader.ReadInt32L();
sl@0
   754
	contactNameFormat2 = resFileFormat_reader.ReadInt32L();
sl@0
   755
		
sl@0
   756
	//The settings should match the ones from resource file.
sl@0
   757
	TEST2(contactMatchCount1, contactMatchCount2);
sl@0
   758
	TEST2(contactNameFormat1, contactNameFormat2);
sl@0
   759
		
sl@0
   760
	CleanupStack::PopAndDestroy(&resFileFormat_reader);
sl@0
   761
	CleanupStack::PopAndDestroy(&resFileCount_reader);
sl@0
   762
	
sl@0
   763
	//Get the config settings (Three config settings). 
sl@0
   764
	
sl@0
   765
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   766
	CleanupStack::PushL(active);
sl@0
   767
		
sl@0
   768
	TLogConfig config;
sl@0
   769
	TEST(config.iMaxEventAge == 0);
sl@0
   770
	TEST(config.iMaxLogSize == 0);
sl@0
   771
	TEST(config.iMaxRecentLogSize == 0);
sl@0
   772
	active->StartL();
sl@0
   773
	aClient.GetConfig(config, active->iStatus);	
sl@0
   774
	CActiveScheduler::Start();
sl@0
   775
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   776
	
sl@0
   777
	//The config settings should match the ones from the repository.
sl@0
   778
	TEST(config.iMaxEventAge == 2592000);
sl@0
   779
	TEST(config.iMaxLogSize == 1000);
sl@0
   780
	TEST(config.iMaxRecentLogSize == 20);
sl@0
   781
	
sl@0
   782
	
sl@0
   783
	//Now let's provide the repository file, so the server will find it and will get the settings
sl@0
   784
	//from it.
sl@0
   785
	
sl@0
   786
	//Create the directory c:\private\10202be9\ if it does not exist.
sl@0
   787
	_LIT(KExecutableFileName,		"t_logapi_helper.exe");
sl@0
   788
	_LIT(KCommandParameters,		"c:\\private\\10202be9\\;c:\\private\\10202be9\\101f401d.txt;3");
sl@0
   789
	RProcess process;
sl@0
   790
	TRequestStatus processWaitStatus;
sl@0
   791
	TInt r = process.Create(KExecutableFileName, KCommandParameters); 
sl@0
   792
	TEST(r == KErrNone);
sl@0
   793
	process.Logon(processWaitStatus);
sl@0
   794
	process.Resume();
sl@0
   795
	User::WaitForRequest(processWaitStatus);
sl@0
   796
	TEST(processWaitStatus.Int() == KErrNone);
sl@0
   797
	process.Close();
sl@0
   798
	
sl@0
   799
	 //copy the repository file to the folder 10202be9
sl@0
   800
	_LIT(KCommandParameters1,		"z:\\test\\101f401d_TEST.txt;c:\\private\\10202be9\\101f401d.txt;0");
sl@0
   801
	r = process.Create(KExecutableFileName, KCommandParameters1); 
sl@0
   802
	TEST(r == KErrNone);
sl@0
   803
	process.Logon(processWaitStatus);
sl@0
   804
	process.Resume();
sl@0
   805
	User::WaitForRequest(processWaitStatus);
sl@0
   806
	TEST(processWaitStatus.Int() == KErrNone);
sl@0
   807
	process.Close();
sl@0
   808
	
sl@0
   809
	TestUtils::DeleteDatabaseL();
sl@0
   810
	
sl@0
   811
	//Get the config settings.
sl@0
   812
	config.iMaxEventAge = 0;
sl@0
   813
	config.iMaxLogSize = 0;
sl@0
   814
	config.iMaxRecentLogSize = 0;	
sl@0
   815
	active->StartL();
sl@0
   816
	aClient.GetConfig(config, active->iStatus);
sl@0
   817
	CActiveScheduler::Start();
sl@0
   818
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   819
sl@0
   820
	//They should match the ones from the repository file.
sl@0
   821
	TEST(config.iMaxEventAge == 2592001);
sl@0
   822
	TEST(config.iMaxLogSize == 1001);
sl@0
   823
	TEST(config.iMaxRecentLogSize == 21);
sl@0
   824
	
sl@0
   825
	CleanupStack::PopAndDestroy(active);
sl@0
   826
	
sl@0
   827
	//Get the contact match count and the contact name format.
sl@0
   828
	RFileReadStream repFileCount_reader;
sl@0
   829
	CleanupClosePushL(repFileCount_reader);
sl@0
   830
	RFileReadStream repFileFormat_reader;
sl@0
   831
	CleanupClosePushL(repFileFormat_reader);
sl@0
   832
	LEAVE_IF_ERROR(repFileCount_reader.Open(fs, KLogengTestFileNameCount, EFileRead));
sl@0
   833
	LEAVE_IF_ERROR(repFileFormat_reader.Open(fs, KLogengTestFileNameFormat, EFileRead));		
sl@0
   834
	contactMatchCount2 = repFileCount_reader.ReadInt32L();
sl@0
   835
	contactNameFormat2 = repFileFormat_reader.ReadInt32L();
sl@0
   836
	CleanupStack::PopAndDestroy(&repFileFormat_reader);
sl@0
   837
	CleanupStack::PopAndDestroy(&repFileCount_reader);
sl@0
   838
	CleanupStack::PopAndDestroy(&fs);
sl@0
   839
	
sl@0
   840
	//The values should match the ones from the repository file.
sl@0
   841
	TEST(contactMatchCount2 == 6);
sl@0
   842
	TEST(contactNameFormat2 == 1);
sl@0
   843
	
sl@0
   844
	//delete the repository file c:\\private\\10202be9\\101f401d.txt.
sl@0
   845
	_LIT(KCommandParameters2,		"c:\\private\\10202be9\\101f401d.txt;private\\10202be9\101f401d.txt;2");
sl@0
   846
	r = process.Create(KExecutableFileName, KCommandParameters2); 
sl@0
   847
	TEST(r == KErrNone);
sl@0
   848
	process.Logon(processWaitStatus);
sl@0
   849
	process.Resume();
sl@0
   850
	User::WaitForRequest(processWaitStatus);
sl@0
   851
	TEST(processWaitStatus.Int() == KErrNone);
sl@0
   852
	process.Close();
sl@0
   853
sl@0
   854
	theLog.Write(_L8("Deleting the Log engine database... \n"));	
sl@0
   855
	TestUtils::DeleteDatabaseL();
sl@0
   856
	TheTest.Next(_L("Delay of 2 min, the necessary time to central repository to unload its cache... "));	
sl@0
   857
	User::After(125000000); // Delay to time to cenrep to unload its cache.
sl@0
   858
	}
sl@0
   859
#endif
sl@0
   860
sl@0
   861
sl@0
   862
/**
sl@0
   863
@SYMTestCaseID          SYSLIB-LOGENG-CT-0842
sl@0
   864
@SYMTestCaseDesc	    Tests for retrieving the log engine configuration data
sl@0
   865
@SYMTestPriority 	    High
sl@0
   866
@SYMTestActions  	    Tests for CLogClient::GetConfig() function,check for the integrity of the data
sl@0
   867
@SYMTestExpectedResults Test must not fail
sl@0
   868
@SYMREQ                 REQ0000
sl@0
   869
*/
sl@0
   870
LOCAL_C void TestGetConfigL(CLogClient& aClient)
sl@0
   871
//
sl@0
   872
//
sl@0
   873
//
sl@0
   874
	{
sl@0
   875
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0842 "));
sl@0
   876
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   877
	CleanupStack::PushL(active);
sl@0
   878
sl@0
   879
	TLogConfig config;
sl@0
   880
sl@0
   881
	TEST(config.iMaxEventAge == 0);
sl@0
   882
	TEST(config.iMaxLogSize == 0);
sl@0
   883
	TEST(config.iMaxRecentLogSize == 0);
sl@0
   884
sl@0
   885
	active->StartL();
sl@0
   886
	aClient.GetConfig(config, active->iStatus);
sl@0
   887
	aClient.Cancel();
sl@0
   888
	CActiveScheduler::Start();
sl@0
   889
	TEST2(active->iStatus.Int(), KErrCancel);
sl@0
   890
sl@0
   891
	active->StartL();
sl@0
   892
	aClient.GetConfig(config, active->iStatus);
sl@0
   893
	CActiveScheduler::Start();
sl@0
   894
	aClient.Cancel();
sl@0
   895
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   896
sl@0
   897
	TEST(config.iMaxEventAge > 0);
sl@0
   898
	TEST(config.iMaxLogSize > 0);
sl@0
   899
	TEST(config.iMaxRecentLogSize > 0);
sl@0
   900
sl@0
   901
	CleanupStack::PopAndDestroy(); // active
sl@0
   902
	}
sl@0
   903
sl@0
   904
/**
sl@0
   905
@SYMTestCaseID          SYSLIB-LOGENG-CT-0843
sl@0
   906
@SYMTestCaseDesc	    Tests for CLogClient::ChangeConfig() function 
sl@0
   907
@SYMTestPriority 	    High
sl@0
   908
@SYMTestActions  	    Change the configuration data and test for the integrity.
sl@0
   909
@SYMTestExpectedResults Test must not fail
sl@0
   910
@SYMREQ                 REQ0000
sl@0
   911
*/
sl@0
   912
LOCAL_C void TestChangeConfigL(CLogClient& aClient)
sl@0
   913
//
sl@0
   914
//
sl@0
   915
//
sl@0
   916
	{
sl@0
   917
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0843 "));
sl@0
   918
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   919
	CleanupStack::PushL(active);
sl@0
   920
sl@0
   921
	TLogConfig config;
sl@0
   922
sl@0
   923
	config.iMaxLogSize = KTestMaxLogSize;
sl@0
   924
	config.iMaxRecentLogSize = KTestMaxRecentLogSize;
sl@0
   925
	config.iMaxEventAge = KTestMaxEventAge;
sl@0
   926
sl@0
   927
	active->StartL();
sl@0
   928
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   929
	aClient.Cancel();
sl@0
   930
	CActiveScheduler::Start();
sl@0
   931
	TEST2(active->iStatus.Int(), KErrCancel);
sl@0
   932
sl@0
   933
	active->StartL();
sl@0
   934
	aClient.ChangeConfig(config, active->iStatus);
sl@0
   935
	CActiveScheduler::Start();
sl@0
   936
	aClient.Cancel();
sl@0
   937
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   938
sl@0
   939
	TEST(config.iMaxLogSize == KTestMaxLogSize);
sl@0
   940
	TEST(config.iMaxRecentLogSize == KTestMaxRecentLogSize);
sl@0
   941
	TEST(config.iMaxEventAge == KTestMaxEventAge);
sl@0
   942
sl@0
   943
	CleanupStack::PopAndDestroy(); // active
sl@0
   944
	}
sl@0
   945
sl@0
   946
/**
sl@0
   947
@SYMTestCaseID          SYSLIB-LOGENG-CT-0844
sl@0
   948
@SYMTestCaseDesc	    Tests for CLogClient::GetString() function
sl@0
   949
@SYMTestPriority 	    High
sl@0
   950
@SYMTestActions  	    Get the string from the resource file and check for no errors and the zero string length
sl@0
   951
@SYMTestExpectedResults Test must not fail
sl@0
   952
@SYMREQ                 REQ0000
sl@0
   953
*/
sl@0
   954
LOCAL_C void TestGetStringL(CLogClient& aClient)
sl@0
   955
//
sl@0
   956
//
sl@0
   957
//
sl@0
   958
	{
sl@0
   959
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0844 "));
sl@0
   960
	TBuf<KLogMaxSharedStringLength> str;
sl@0
   961
	
sl@0
   962
	TInt err = aClient.GetString(str, R_LOG_DIR_IN);
sl@0
   963
	TEST2(err, KErrNone);
sl@0
   964
	TEST(str.Length() > 0);
sl@0
   965
	str.Zero();
sl@0
   966
sl@0
   967
	err = aClient.GetString(str, R_LOG_DIR_OUT);
sl@0
   968
	TEST2(err, KErrNone);
sl@0
   969
	TEST(str.Length() > 0);
sl@0
   970
	str.Zero();
sl@0
   971
sl@0
   972
	err = aClient.GetString(str, R_LOG_DIR_IN_ALT);
sl@0
   973
	TEST2(err, KErrNone);
sl@0
   974
	TEST(str.Length() > 0);
sl@0
   975
	str.Zero();
sl@0
   976
sl@0
   977
	err = aClient.GetString(str, R_LOG_DIR_OUT_ALT);
sl@0
   978
	TEST2(err, KErrNone);
sl@0
   979
	TEST(str.Length() > 0);
sl@0
   980
	str.Zero();
sl@0
   981
sl@0
   982
	err = aClient.GetString(str, R_LOG_DIR_FETCHED);
sl@0
   983
	TEST2(err, KErrNone);
sl@0
   984
	TEST(str.Length() > 0);
sl@0
   985
	str.Zero();
sl@0
   986
sl@0
   987
	err = aClient.GetString(str, R_LOG_DIR_MISSED);
sl@0
   988
	TEST2(err, KErrNone);
sl@0
   989
	TEST(str.Length() > 0);
sl@0
   990
	str.Zero();
sl@0
   991
sl@0
   992
	err = aClient.GetString(str, R_LOG_DEL_PENDING);
sl@0
   993
	TEST2(err, KErrNone);
sl@0
   994
	TEST(str.Length() > 0);
sl@0
   995
	str.Zero();
sl@0
   996
sl@0
   997
	err = aClient.GetString(str, R_LOG_DEL_SENT);
sl@0
   998
	TEST2(err, KErrNone);
sl@0
   999
	TEST(str.Length() > 0);
sl@0
  1000
	str.Zero();
sl@0
  1001
sl@0
  1002
	err = aClient.GetString(str, R_LOG_DEL_FAILED);
sl@0
  1003
	TEST2(err, KErrNone);
sl@0
  1004
	TEST(str.Length() > 0);
sl@0
  1005
	str.Zero();
sl@0
  1006
sl@0
  1007
	err = aClient.GetString(str, R_LOG_DEL_NONE);
sl@0
  1008
	TEST2(err, KErrNone);
sl@0
  1009
	TEST(str.Length() > 0);
sl@0
  1010
	str.Zero();
sl@0
  1011
sl@0
  1012
	err = aClient.GetString(str, R_LOG_DEL_DONE);
sl@0
  1013
	TEST2(err, KErrNone);
sl@0
  1014
	TEST(str.Length() > 0);
sl@0
  1015
	str.Zero();
sl@0
  1016
sl@0
  1017
	err = aClient.GetString(str, R_LOG_DEL_NOT_SENT);
sl@0
  1018
	TEST2(err, KErrNone);
sl@0
  1019
	TEST(str.Length() > 0);
sl@0
  1020
	str.Zero();
sl@0
  1021
sl@0
  1022
	err = aClient.GetString(str, R_LOG_DEL_NOTIFIED);
sl@0
  1023
	TEST2(err, KErrNone);
sl@0
  1024
	TEST(str.Length() > 0);
sl@0
  1025
	str.Zero();
sl@0
  1026
sl@0
  1027
	err = aClient.GetString(str, R_LOG_DEL_EXPIRED);
sl@0
  1028
	TEST2(err, KErrNone);
sl@0
  1029
	TEST(str.Length() > 0);
sl@0
  1030
	str.Zero();
sl@0
  1031
sl@0
  1032
	err = aClient.GetString(str, R_LOG_REMOTE_UNKNOWN);
sl@0
  1033
	TEST2(err, KErrNone);
sl@0
  1034
	TEST(str.Length() > 0);
sl@0
  1035
	str.Zero();
sl@0
  1036
sl@0
  1037
	err = aClient.GetString(str, R_LOG_REMOTE_MULTIPLE);
sl@0
  1038
	TEST2(err, KErrNone);
sl@0
  1039
	TEST(str.Length() > 0);
sl@0
  1040
	str.Zero();
sl@0
  1041
sl@0
  1042
	err = aClient.GetString(str, R_LOG_SUBJECT_NONE);
sl@0
  1043
	TEST2(err, KErrNone);
sl@0
  1044
	TEST(str.Length() > 0);
sl@0
  1045
	str.Zero();
sl@0
  1046
	}
sl@0
  1047
sl@0
  1048
/**
sl@0
  1049
@SYMTestCaseID          SYSLIB-LOGENG-CT-0845
sl@0
  1050
@SYMTestCaseDesc	    Tests for clearing the event types from the log
sl@0
  1051
@SYMTestPriority 	    High
sl@0
  1052
@SYMTestActions  	    Clear the event types from the log and check for event not found error.
sl@0
  1053
@SYMTestExpectedResults Test must not fail
sl@0
  1054
@SYMREQ                 REQ0000
sl@0
  1055
*/
sl@0
  1056
LOCAL_C void TestClearEventLogL(CLogClient& aClient)
sl@0
  1057
	{
sl@0
  1058
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0845 "));
sl@0
  1059
	TTime now;
sl@0
  1060
	now.UniversalTime();
sl@0
  1061
	TDateTime d = now.DateTime();
sl@0
  1062
	TheTest.Printf(_L("TimeNow: Y=%d, M=%d, D=%d, H=%d, M=%d, S=%d\n"), d.Year(), d.Month() + 1, d.Day() + 1, d.Hour(), d.Minute(), d.Second());
sl@0
  1063
sl@0
  1064
	TTime date1(now);
sl@0
  1065
	date1 -= TTimeIntervalDays(1);
sl@0
  1066
sl@0
  1067
	TTime date2(date1);
sl@0
  1068
	date2 -= TTimeIntervalDays(1);
sl@0
  1069
sl@0
  1070
	CTestActive* active = new(ELeave)CTestActive();
sl@0
  1071
	CleanupStack::PushL(active);
sl@0
  1072
sl@0
  1073
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1074
	//Clear all events before (current date). Actually - all events!
sl@0
  1075
	active->StartL();
sl@0
  1076
	aClient.ClearLog(now, active->iStatus);
sl@0
  1077
	CActiveScheduler::Start();
sl@0
  1078
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1079
sl@0
  1080
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1081
	//The next part of the test will create 4 events:
sl@0
  1082
	//-event1 and event2 will have time = current date - 1 day + 10 seconds;
sl@0
  1083
	//-event3 and event4 will have time = current date - 2 days;
sl@0
  1084
	//The test is:
sl@0
  1085
	//ClearLog - Delete all events, which time is less or equal to current date - 1 day.
sl@0
  1086
	//Check - event3 and event4 should disappear, event1 and event2 should stay.
sl@0
  1087
	//ClearLog - Delete all events, which time is less or equal to current date.
sl@0
  1088
	//Check - event1 and event2 should disappear too.
sl@0
  1089
	//
sl@0
  1090
	//The "10 seconds" addition is very important. The creation of the 4 events is 
sl@0
  1091
	//an operation, which is performed very quickly. It is possible that the 
sl@0
  1092
	//first ClearLog operation will be executed at the same second at which the events
sl@0
  1093
	//were created. Which means, that all events will be deleted and the next check 
sl@0
  1094
	//for the presence of event1 and event2 will fail.
sl@0
  1095
sl@0
  1096
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1097
	//Create and add new event - event1. 
sl@0
  1098
	//Set event1 date to be (current date - 1 day + 10 seconds).
sl@0
  1099
	CLogEvent* event1 = CLogEvent::NewL();
sl@0
  1100
	CleanupStack::PushL(event1);
sl@0
  1101
	
sl@0
  1102
	event1->SetEventType(KTestEventUid);
sl@0
  1103
	active->StartL();
sl@0
  1104
	aClient.AddEvent(*event1, active->iStatus);
sl@0
  1105
	CActiveScheduler::Start();
sl@0
  1106
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1107
sl@0
  1108
	TTimeIntervalSeconds tenSeconds(10);
sl@0
  1109
	event1->SetTime(date1 + tenSeconds);
sl@0
  1110
	active->StartL();
sl@0
  1111
	aClient.ChangeEvent(*event1, active->iStatus);
sl@0
  1112
	CActiveScheduler::Start();
sl@0
  1113
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1114
sl@0
  1115
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1116
	//Create and add new event - event2. 
sl@0
  1117
	//Set event2 date to be (current date - 1 day + 10 seconds).
sl@0
  1118
	CLogEvent* event2 = CLogEvent::NewL();
sl@0
  1119
	CleanupStack::PushL(event2);
sl@0
  1120
	
sl@0
  1121
	event2->SetEventType(KTestEventUid);
sl@0
  1122
	active->StartL();
sl@0
  1123
	aClient.AddEvent(*event2, active->iStatus);
sl@0
  1124
	CActiveScheduler::Start();
sl@0
  1125
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1126
sl@0
  1127
	event2->SetTime(date1 + tenSeconds);
sl@0
  1128
	active->StartL();
sl@0
  1129
	aClient.ChangeEvent(*event2, active->iStatus);
sl@0
  1130
	CActiveScheduler::Start();
sl@0
  1131
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1132
sl@0
  1133
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1134
	//Create and add new event - event3. 
sl@0
  1135
	//Set event3 date to be (current date - 2 days).
sl@0
  1136
	CLogEvent* event3 = CLogEvent::NewL();
sl@0
  1137
	CleanupStack::PushL(event3);
sl@0
  1138
	event3->SetEventType(KTestEventUid);
sl@0
  1139
sl@0
  1140
	active->StartL();
sl@0
  1141
	aClient.AddEvent(*event3, active->iStatus);
sl@0
  1142
	CActiveScheduler::Start();
sl@0
  1143
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1144
sl@0
  1145
	event3->SetTime(date2);
sl@0
  1146
	active->StartL();
sl@0
  1147
	aClient.ChangeEvent(*event3, active->iStatus);
sl@0
  1148
	CActiveScheduler::Start();
sl@0
  1149
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1150
sl@0
  1151
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1152
	//Create and add new event - event4. 
sl@0
  1153
	//Set event4 date to be (current date - 2 days).
sl@0
  1154
	CLogEvent* event4 = CLogEvent::NewL();
sl@0
  1155
	CleanupStack::PushL(event4);
sl@0
  1156
	event4->SetEventType(KTestEventUid);
sl@0
  1157
sl@0
  1158
	active->StartL();
sl@0
  1159
	aClient.AddEvent(*event4, active->iStatus);
sl@0
  1160
	CActiveScheduler::Start();
sl@0
  1161
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1162
sl@0
  1163
	event4->SetTime(date2);
sl@0
  1164
	active->StartL();
sl@0
  1165
	aClient.ChangeEvent(*event4, active->iStatus);
sl@0
  1166
	CActiveScheduler::Start();
sl@0
  1167
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1168
sl@0
  1169
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1170
	//Clear all events before (current date - 1 day).
sl@0
  1171
	//Then cancel the operation.
sl@0
  1172
	TheTest.Printf(_L("=.= ClearLog 1\n"));
sl@0
  1173
	active->StartL();
sl@0
  1174
	aClient.ClearLog(date1, active->iStatus);
sl@0
  1175
	aClient.Cancel();
sl@0
  1176
	CActiveScheduler::Start();
sl@0
  1177
	TEST2(active->iStatus.Int(), KErrCancel);
sl@0
  1178
sl@0
  1179
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1180
	//Clear all events before (current date - 1 day).
sl@0
  1181
	//event3 and event4 should be removed.
sl@0
  1182
	TheTest.Printf(_L("=.= ClearLog 2\n"));
sl@0
  1183
	active->StartL();
sl@0
  1184
	aClient.ClearLog(date1, active->iStatus);
sl@0
  1185
	CActiveScheduler::Start();
sl@0
  1186
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1187
sl@0
  1188
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1189
	//Get event1. It should be there - its time is (current date - 1 day + 10 seconds).
sl@0
  1190
	TheTest.Printf(_L("=.= GetEvent 1\n"));
sl@0
  1191
	active->StartL();
sl@0
  1192
	aClient.GetEvent(*event1, active->iStatus);
sl@0
  1193
	CActiveScheduler::Start();
sl@0
  1194
	if(active->iStatus != KErrNone) 
sl@0
  1195
		{
sl@0
  1196
		TheTest.Printf(_L("=1= error code:%d\n"),active->iStatus.Int());
sl@0
  1197
		}
sl@0
  1198
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1199
sl@0
  1200
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1201
	//Get event2. It should be there - its time is (current date - 1 day + 10 seconds).
sl@0
  1202
	TheTest.Printf(_L("=.= GetEvent 2\n"));
sl@0
  1203
	active->StartL();
sl@0
  1204
	aClient.GetEvent(*event2, active->iStatus);
sl@0
  1205
	CActiveScheduler::Start();
sl@0
  1206
	if(active->iStatus != KErrNone) 
sl@0
  1207
		{
sl@0
  1208
		TheTest.Printf(_L("=2= error code:%d\n"),active->iStatus.Int());
sl@0
  1209
		}
sl@0
  1210
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1211
sl@0
  1212
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1213
	//Get event3. It should not be there - its time is (current date - 2 days).
sl@0
  1214
	TheTest.Printf(_L("=.= GetEvent 3\n"));
sl@0
  1215
	active->StartL();
sl@0
  1216
	aClient.GetEvent(*event3, active->iStatus);
sl@0
  1217
	CActiveScheduler::Start();
sl@0
  1218
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1219
sl@0
  1220
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1221
	//Get event4. It should not be there - its time is (current date - 2 days).
sl@0
  1222
	TheTest.Printf(_L("=.= GetEvent 4\n"));
sl@0
  1223
	active->StartL();
sl@0
  1224
	aClient.GetEvent(*event4, active->iStatus);
sl@0
  1225
	CActiveScheduler::Start();
sl@0
  1226
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1227
sl@0
  1228
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1229
	//Clear all events happened before (current date).
sl@0
  1230
	//event1 and event2 should be removed.
sl@0
  1231
	TheTest.Printf(_L("=#= ClearLog 1\n"));
sl@0
  1232
	active->StartL();
sl@0
  1233
	aClient.ClearLog(now, active->iStatus);
sl@0
  1234
	CActiveScheduler::Start();
sl@0
  1235
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1236
sl@0
  1237
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1238
	//Get event1. It should not be there - its time is (current date - 1 day + 10 seconds).
sl@0
  1239
	TheTest.Printf(_L("=#= GetEvent 1\n"));
sl@0
  1240
	active->StartL();
sl@0
  1241
	aClient.GetEvent(*event1, active->iStatus);
sl@0
  1242
	CActiveScheduler::Start();
sl@0
  1243
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1244
sl@0
  1245
	//////////////////////////////////////////////////////////////////////////////	
sl@0
  1246
	//Get event2. It should not be there - its time is (current date - 1 day + 10 seconds).
sl@0
  1247
	TheTest.Printf(_L("=#= GetEvent 2\n"));
sl@0
  1248
	active->StartL();
sl@0
  1249
	aClient.GetEvent(*event2, active->iStatus);
sl@0
  1250
	CActiveScheduler::Start();
sl@0
  1251
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1252
sl@0
  1253
	CleanupStack::PopAndDestroy(5); // event4, event3, event2, event1, active
sl@0
  1254
	}
sl@0
  1255
sl@0
  1256
LOCAL_C void DoTestLogL(CLogBase& aClient)
sl@0
  1257
	{
sl@0
  1258
	CTestActive* active = new(ELeave)CTestActive();
sl@0
  1259
	CleanupStack::PushL(active);
sl@0
  1260
sl@0
  1261
	CLogEvent* event = CLogEvent::NewL();
sl@0
  1262
	CleanupStack::PushL(event);
sl@0
  1263
sl@0
  1264
	TTime now;
sl@0
  1265
	now.UniversalTime();
sl@0
  1266
sl@0
  1267
	event->SetEventType(KLogCallEventTypeUid);
sl@0
  1268
sl@0
  1269
	User::After((Math::Random() % 4) * 100000);
sl@0
  1270
	active->StartL();
sl@0
  1271
	aClient.AddEvent(*event, active->iStatus);
sl@0
  1272
	CActiveScheduler::Start();
sl@0
  1273
	TTEST2(active->iStatus.Int(), KErrNone);
sl@0
  1274
sl@0
  1275
	TTEST(event->EventType() == KLogCallEventTypeUid);
sl@0
  1276
	TTEST(event->Description().Length() > 0);
sl@0
  1277
	TTEST(event->Time() >= now);
sl@0
  1278
	now = event->Time();
sl@0
  1279
sl@0
  1280
	TLogId id = event->Id();
sl@0
  1281
sl@0
  1282
	event->SetRemoteParty(KTestRemoteParty1);
sl@0
  1283
	event->SetDirection(KTestDirection1);
sl@0
  1284
	event->SetDurationType(KTestDurationType1);
sl@0
  1285
	event->SetDuration(KTestDuration1);
sl@0
  1286
	event->SetStatus(KTestStatus1);
sl@0
  1287
	event->SetSubject(KTestSubject1);
sl@0
  1288
	event->SetNumber(KTestNumber1);
sl@0
  1289
	event->SetContact(KTestContact1);
sl@0
  1290
	event->SetLink(KTestLink1);
sl@0
  1291
	event->SetDataL(KTestData1);
sl@0
  1292
sl@0
  1293
	User::After((Math::Random() % 4) * 100000);
sl@0
  1294
	active->StartL();
sl@0
  1295
	aClient.ChangeEvent(*event, active->iStatus);
sl@0
  1296
	CActiveScheduler::Start();
sl@0
  1297
	TTEST2(active->iStatus.Int(), KErrNone);
sl@0
  1298
sl@0
  1299
	TTEST(event->Id() == id);
sl@0
  1300
	TTEST(event->EventType() == KLogCallEventTypeUid);
sl@0
  1301
	TTEST(event->Description().Length() > 0);
sl@0
  1302
	TTEST(event->Time() == now);
sl@0
  1303
	TTEST(event->RemoteParty() == KTestRemoteParty1);
sl@0
  1304
	TTEST(event->Direction() == KTestDirection1);
sl@0
  1305
	TTEST(event->DurationType() == KTestDurationType1);
sl@0
  1306
	TTEST(event->Duration() == KTestDuration1);
sl@0
  1307
	TTEST(event->Status() == KTestStatus1);
sl@0
  1308
	TTEST(event->Subject() == KTestSubject1);
sl@0
  1309
	TTEST(event->Number() == KTestNumber1);
sl@0
  1310
	TTEST(event->Contact() == KTestContact1);
sl@0
  1311
	TTEST(event->Link() == KTestLink1);
sl@0
  1312
	TTEST(event->Data() == KTestData1);
sl@0
  1313
sl@0
  1314
	CleanupStack::PopAndDestroy(); // event;
sl@0
  1315
sl@0
  1316
	event = CLogEvent::NewL();
sl@0
  1317
	CleanupStack::PushL(event);
sl@0
  1318
sl@0
  1319
	event->SetId(id);
sl@0
  1320
sl@0
  1321
	active->StartL();
sl@0
  1322
	aClient.GetEvent(*event, active->iStatus);
sl@0
  1323
	CActiveScheduler::Start();
sl@0
  1324
	TTEST2(active->iStatus.Int(), KErrNone);
sl@0
  1325
sl@0
  1326
	TTEST(event->Id() == id);
sl@0
  1327
	TTEST(event->EventType() == KLogCallEventTypeUid);
sl@0
  1328
	TTEST(event->Description().Length() > 0);
sl@0
  1329
	TTEST(event->Time() == now);
sl@0
  1330
	TTEST(event->RemoteParty() == KTestRemoteParty1);
sl@0
  1331
	TTEST(event->Direction() == KTestDirection1);
sl@0
  1332
	TTEST(event->DurationType() == KTestDurationType1);
sl@0
  1333
	TTEST(event->Duration() == KTestDuration1);
sl@0
  1334
	TTEST(event->Status() == KTestStatus1);
sl@0
  1335
	TTEST(event->Subject() == KTestSubject1);
sl@0
  1336
	TTEST(event->Number() == KTestNumber1);
sl@0
  1337
	TTEST(event->Contact() == KTestContact1);
sl@0
  1338
	TTEST(event->Link() == KTestLink1);
sl@0
  1339
	TTEST(event->Data() == KTestData1);
sl@0
  1340
sl@0
  1341
	User::After((Math::Random() % 4) * 100000);
sl@0
  1342
	active->StartL();
sl@0
  1343
	aClient.DeleteEvent(id, active->iStatus);
sl@0
  1344
	CActiveScheduler::Start();
sl@0
  1345
	TTEST2(active->iStatus.Int(), KErrNone);
sl@0
  1346
sl@0
  1347
	active->StartL();
sl@0
  1348
	aClient.GetEvent(*event, active->iStatus);
sl@0
  1349
	CActiveScheduler::Start();
sl@0
  1350
	TTEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1351
sl@0
  1352
	CleanupStack::PopAndDestroy(2); // event, active
sl@0
  1353
	}
sl@0
  1354
sl@0
  1355
void DoTestMultipleClientAccessL()
sl@0
  1356
	{
sl@0
  1357
	CActiveScheduler::Install(new(ELeave)CActiveScheduler);
sl@0
  1358
	CleanupStack::PushL(CActiveScheduler::Current());
sl@0
  1359
sl@0
  1360
	RFs fs;
sl@0
  1361
	TTEST2(fs.Connect(), KErrNone);
sl@0
  1362
	CleanupClosePushL(fs);
sl@0
  1363
	
sl@0
  1364
	CLogClient* client = CLogClient::NewL(fs);
sl@0
  1365
	CleanupStack::PushL(client);
sl@0
  1366
sl@0
  1367
	TBuf8<500> buf;
sl@0
  1368
sl@0
  1369
	TInt count = 10;
sl@0
  1370
	while(count--)
sl@0
  1371
		{
sl@0
  1372
		DoTestLogL(*client);
sl@0
  1373
		}
sl@0
  1374
sl@0
  1375
	CleanupStack::PopAndDestroy(3); // fs, client, CActiveScheduler
sl@0
  1376
	}
sl@0
  1377
sl@0
  1378
void DoThreadDieL()
sl@0
  1379
	{
sl@0
  1380
	CActiveScheduler::Install(new(ELeave)CActiveScheduler);
sl@0
  1381
	CleanupStack::PushL(CActiveScheduler::Current());
sl@0
  1382
sl@0
  1383
	RFs fs;
sl@0
  1384
	TTEST2(fs.Connect(), KErrNone);
sl@0
  1385
	CleanupClosePushL(fs);
sl@0
  1386
sl@0
  1387
	CLogEvent* event = CLogEvent::NewL();
sl@0
  1388
	CleanupStack::PushL(event);
sl@0
  1389
sl@0
  1390
	const TInt KLogClientCnt = 10;
sl@0
  1391
	for(TInt i=0;i<KLogClientCnt;i++)
sl@0
  1392
		{
sl@0
  1393
		CLogClient* client = CLogClient::NewL(fs);
sl@0
  1394
		event->SetId(i);
sl@0
  1395
		TRequestStatus status;
sl@0
  1396
		client->GetEvent(*event, status);
sl@0
  1397
		}
sl@0
  1398
	
sl@0
  1399
	User::After(100000);
sl@0
  1400
sl@0
  1401
	RThread thread;
sl@0
  1402
	thread.Kill(KErrGeneral);
sl@0
  1403
	}
sl@0
  1404
sl@0
  1405
static TInt DoDyingThreadStart(TAny*)
sl@0
  1406
	{
sl@0
  1407
	CTrapCleanup* cleanup = CTrapCleanup::New();
sl@0
  1408
	TTEST(cleanup != NULL);
sl@0
  1409
	TRAPD(err, DoThreadDieL());		
sl@0
  1410
	delete cleanup;
sl@0
  1411
	if(err != KErrNone)
sl@0
  1412
		{
sl@0
  1413
		RDebug::Print(_L("*** DoThreadDieL() failed with err %d\r\n"), err);
sl@0
  1414
		User::Panic(_L("ThrChk4"), 4);
sl@0
  1415
		}
sl@0
  1416
	return err;
sl@0
  1417
	}
sl@0
  1418
sl@0
  1419
static TInt DoThreadStart(TAny* aThreadNumber)
sl@0
  1420
	{
sl@0
  1421
	TInt thrNum = (TInt)aThreadNumber;
sl@0
  1422
	CTrapCleanup* cleanup = CTrapCleanup::New();
sl@0
  1423
	TTEST(cleanup != NULL);
sl@0
  1424
	TRAPD(err, DoTestMultipleClientAccessL());		
sl@0
  1425
	delete cleanup;
sl@0
  1426
	if(err != KErrNone)
sl@0
  1427
		{
sl@0
  1428
		RDebug::Print(_L("*** Thread %d failed with err %d\r\n"), thrNum, err);
sl@0
  1429
		User::Panic(_L("ThrChk3"), 3);
sl@0
  1430
		}
sl@0
  1431
	return err;
sl@0
  1432
	}
sl@0
  1433
sl@0
  1434
const TInt KTestThreadCount = 20;
sl@0
  1435
const TInt KMinTestHeapSize = 0x10000;
sl@0
  1436
const TInt KMaxTestHeapSize = 0x100000;
sl@0
  1437
sl@0
  1438
/**
sl@0
  1439
@SYMTestCaseID          SYSLIB-LOGENG-CT-0846
sl@0
  1440
@SYMTestCaseDesc	    Thread invoking test
sl@0
  1441
@SYMTestPriority 	    High
sl@0
  1442
@SYMTestActions  	    Create a new thread,check for no errors,register for notification of status when the thread dies
sl@0
  1443
@SYMTestExpectedResults Test must not fail
sl@0
  1444
@SYMREQ                 REQ0000
sl@0
  1445
*/
sl@0
  1446
LOCAL_C void TestThreadDieL()
sl@0
  1447
	{
sl@0
  1448
	RThread thread;
sl@0
  1449
	TRequestStatus status;
sl@0
  1450
sl@0
  1451
	TName name;
sl@0
  1452
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0846 "));
sl@0
  1453
	_LIT(KThreadName, "Test thread");
sl@0
  1454
	name.Format(KThreadName);
sl@0
  1455
sl@0
  1456
	TInt err = thread.Create(name, DoDyingThreadStart, KDefaultStackSize, KMinTestHeapSize, KMaxTestHeapSize, NULL, EOwnerThread);
sl@0
  1457
	// Create the thread
sl@0
  1458
	TEST2(err, KErrNone);
sl@0
  1459
	thread.Logon(status);
sl@0
  1460
sl@0
  1461
	// Let the thread run
sl@0
  1462
	thread.Resume();
sl@0
  1463
sl@0
  1464
	User::WaitForRequest(status);
sl@0
  1465
	TEST2(thread.ExitType(), EExitKill);
sl@0
  1466
	thread.Close();
sl@0
  1467
	TEST2(status.Int(), KErrGeneral);
sl@0
  1468
	}
sl@0
  1469
sl@0
  1470
/**
sl@0
  1471
@SYMTestCaseID          SYSLIB-LOGENG-CT-0847
sl@0
  1472
@SYMTestCaseDesc	    Multiple client access test
sl@0
  1473
@SYMTestPriority 	    High
sl@0
  1474
@SYMTestActions  	    Create threads,request for notification of thread death.
sl@0
  1475
                        Resume and stop all the threads executions.Check for no errors.
sl@0
  1476
@SYMTestExpectedResults Test must not fail
sl@0
  1477
@SYMREQ                 REQ0000
sl@0
  1478
*/
sl@0
  1479
LOCAL_C void TestMultipleClientAccessL()
sl@0
  1480
	{
sl@0
  1481
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0847 "));
sl@0
  1482
	RThread threadArray[KTestThreadCount];
sl@0
  1483
	TRequestStatus statusArray[KTestThreadCount];
sl@0
  1484
sl@0
  1485
	// Create the threads
sl@0
  1486
	TInt count = KTestThreadCount;
sl@0
  1487
	while(count--)
sl@0
  1488
		{
sl@0
  1489
		TName name;
sl@0
  1490
		_LIT(KThreadName, "TmcaTh%d");
sl@0
  1491
		name.Format(KThreadName, count);
sl@0
  1492
sl@0
  1493
		// Create the thread
sl@0
  1494
		TInt err = threadArray[count].Create(name, DoThreadStart, KDefaultStackSize, KMinTestHeapSize, KMaxTestHeapSize, (TAny*) count, EOwnerThread);
sl@0
  1495
		TEST2(err, KErrNone);
sl@0
  1496
		threadArray[count].Logon(statusArray[count]);
sl@0
  1497
		}
sl@0
  1498
sl@0
  1499
	// Let the thread run
sl@0
  1500
	count = KTestThreadCount;
sl@0
  1501
	while(count--)
sl@0
  1502
		{
sl@0
  1503
		TheTest.Printf(_L("   ** Resume thread %d\r\n"), count);
sl@0
  1504
		threadArray[count].Resume();
sl@0
  1505
		}
sl@0
  1506
sl@0
  1507
	TheTest.Printf(_L("   ** Waiting threads to complete....\r\n"));
sl@0
  1508
	
sl@0
  1509
	// Wait for all the threads to complete
sl@0
  1510
	count = KTestThreadCount;
sl@0
  1511
	while(count--)
sl@0
  1512
		{
sl@0
  1513
		User::WaitForRequest(statusArray[count]);
sl@0
  1514
		TheTest.Printf(_L("   ** Thread %d completed\r\n"), count);
sl@0
  1515
		TEST(threadArray[count].ExitType() != EExitPanic);
sl@0
  1516
		threadArray[count].Close();
sl@0
  1517
		}
sl@0
  1518
	}
sl@0
  1519
sl@0
  1520
/**
sl@0
  1521
@SYMTestCaseID          SYSLIB-LOGENG-CT-0848
sl@0
  1522
@SYMTestCaseDesc	    Test for checking notification of status
sl@0
  1523
@SYMTestPriority 	    High
sl@0
  1524
@SYMTestActions  	    Call up add - get - change - delete event type.
sl@0
  1525
@SYMTestExpectedResults Test must not fail
sl@0
  1526
@SYMREQ                 REQ0000
sl@0
  1527
*/
sl@0
  1528
LOCAL_C void TestNoNotifierL()
sl@0
  1529
	{
sl@0
  1530
	TestUtils::DeleteDatabaseL();
sl@0
  1531
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0848 "));
sl@0
  1532
	TheTest.Printf(_L("TestNoNotifierL - begin\n"));
sl@0
  1533
sl@0
  1534
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
  1535
	CleanupStack::PushL(client);
sl@0
  1536
sl@0
  1537
	CTestActive* active = new(ELeave)CTestActive;
sl@0
  1538
	CleanupStack::PushL(active);
sl@0
  1539
	
sl@0
  1540
	TheTest.Printf(_L("TestAddEventTypeL\n"));
sl@0
  1541
	TestAddEventTypeL(*client);
sl@0
  1542
sl@0
  1543
	TheTest.Printf(_L("TestGetEventTypeL\n"));
sl@0
  1544
	TestGetEventTypeL(*client);
sl@0
  1545
sl@0
  1546
	TheTest.Printf(_L("TestChangeEventTypeL\n"));
sl@0
  1547
	TestChangeEventTypeL(*client);
sl@0
  1548
sl@0
  1549
	TheTest.Printf(_L("TestDeleteEventTypeL\n"));
sl@0
  1550
	TestDeleteEventTypeL(*client);
sl@0
  1551
sl@0
  1552
	TheTest.Printf(_L("TestAddEventL\n"));
sl@0
  1553
	TestAddEventL(*client);
sl@0
  1554
sl@0
  1555
	TheTest.Printf(_L("TestGetEventL\n"));
sl@0
  1556
	TestGetEventL(*client);
sl@0
  1557
sl@0
  1558
	TheTest.Printf(_L("TestChangeEventL\n"));
sl@0
  1559
	TestChangeEventL(*client);
sl@0
  1560
sl@0
  1561
	TheTest.Printf(_L("TestDeleteEventL\n"));
sl@0
  1562
	TestDeleteEventL(*client);
sl@0
  1563
sl@0
  1564
	TheTest.Printf(_L("TestGetConfigL\n"));
sl@0
  1565
	TestGetConfigL(*client);
sl@0
  1566
sl@0
  1567
	TheTest.Printf(_L("TestChangeConfigL\n"));
sl@0
  1568
	TestChangeConfigL(*client);
sl@0
  1569
sl@0
  1570
	TheTest.Printf(_L("TestGetStringL\n"));
sl@0
  1571
	TestGetStringL(*client);
sl@0
  1572
sl@0
  1573
	TheTest.Printf(_L("TestClearEventLogL\n"));
sl@0
  1574
	TestClearEventLogL(*client);
sl@0
  1575
sl@0
  1576
	CleanupStack::PopAndDestroy(2); // active, client
sl@0
  1577
	TheTest.Printf(_L("TestNoNotifierL - end\n"));
sl@0
  1578
	}
sl@0
  1579
sl@0
  1580
/**
sl@0
  1581
@SYMTestCaseID          PDS-LOGENG-CT-4016
sl@0
  1582
@SYMTestCaseDesc	    Tests for CLogChangeDefinition public APIs
sl@0
  1583
@SYMTestPriority 	    High
sl@0
  1584
@SYMTestActions  	    Tests for CLogChangeDefinition::Find() functions, and different NewL() functions.
sl@0
  1585
@SYMTestExpectedResults CLogChangeDefinition object need to be created propertly. Find() functions
sl@0
  1586
						need to return proper items from list.
sl@0
  1587
@SYMDEF                 DEF135499
sl@0
  1588
*/
sl@0
  1589
LOCAL_C void TestLogChangeDefinitionL(CLogClient& aClient)
sl@0
  1590
	{
sl@0
  1591
	TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-CT-4016"));
sl@0
  1592
	TestUtils::DeleteDatabaseL();
sl@0
  1593
sl@0
  1594
	CLogEvent* event = CLogEvent::NewL();
sl@0
  1595
	CleanupStack::PushL(event);
sl@0
  1596
sl@0
  1597
	CLogFilter* filter = CLogFilter::NewL();
sl@0
  1598
	CleanupStack::PushL(filter);
sl@0
  1599
	filter->SetContact(KTestContact);
sl@0
  1600
	filter->SetEventType(KLogPacketDataEventTypeUid);
sl@0
  1601
sl@0
  1602
	CTestActive* active = new(ELeave)CTestActive();
sl@0
  1603
	CleanupStack::PushL(active);
sl@0
  1604
sl@0
  1605
	CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC();
sl@0
  1606
	changeObs->SetActive();
sl@0
  1607
sl@0
  1608
	CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs);
sl@0
  1609
	CleanupStack::PushL(view);
sl@0
  1610
sl@0
  1611
	// Incoming
sl@0
  1612
	TBuf<KLogMaxDirectionLength> buf;
sl@0
  1613
	aClient.GetString(buf, R_LOG_DIR_IN);
sl@0
  1614
sl@0
  1615
	event->SetEventType(KLogPacketDataEventTypeUid);
sl@0
  1616
	event->SetDirection(buf);
sl@0
  1617
	event->SetContact(KTestContact);
sl@0
  1618
	
sl@0
  1619
	active->StartL();
sl@0
  1620
	aClient.AddEvent(*event, active->iStatus);
sl@0
  1621
	CActiveScheduler::Start();
sl@0
  1622
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1623
	User::After(1 * 1000000);
sl@0
  1624
	
sl@0
  1625
	TEST2(view->CountL(), 0);
sl@0
  1626
	active->StartL();
sl@0
  1627
	TBool res = view->SetFilterL(*filter, active->iStatus);
sl@0
  1628
	TEST(res);
sl@0
  1629
	CActiveScheduler::Start();
sl@0
  1630
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1631
	TEST2(view->CountL(), 1);
sl@0
  1632
	
sl@0
  1633
	// Transients
sl@0
  1634
	TInt changeCount;
sl@0
  1635
	TLogId logId;
sl@0
  1636
	TInt viewIndex;
sl@0
  1637
	TLogDatabaseChangeType type;
sl@0
  1638
	
sl@0
  1639
	for(TInt count = 0; count < KTestEventNum; count++)
sl@0
  1640
		{
sl@0
  1641
		active->StartL();
sl@0
  1642
		aClient.AddEvent(*event, active->iStatus);
sl@0
  1643
		CActiveScheduler::Start();
sl@0
  1644
		TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1645
		User::After(1 * 1000000);
sl@0
  1646
		}
sl@0
  1647
sl@0
  1648
	const CLogChangeDefinition& changes = changeObs->Changes();
sl@0
  1649
sl@0
  1650
	changeCount = changes.Count();
sl@0
  1651
	TheTest.Printf(_L("Change Count: %d\n"), changeCount);
sl@0
  1652
	TEST2(changeCount, KTestEventNum);
sl@0
  1653
	for(TInt i=0; i<changeCount; i++)
sl@0
  1654
		{
sl@0
  1655
		type = changes.At(i, logId, viewIndex);
sl@0
  1656
		TheTest.Printf(_L("Change Type: %d, logId: %d, viewIndex: %d\n"), type, logId, viewIndex);
sl@0
  1657
		TEST(changes.Find(logId)==i);
sl@0
  1658
		TEST(changes.Find(logId, ELogChangeTypeEventAdded)>=0);
sl@0
  1659
		TEST(changes.Find(TLogId(100000000), ELogChangeTypeEventAdded)==KErrNotFound);
sl@0
  1660
		TEST(changes.Find(logId, ELogChangeTypeLogCleared)==KErrNotFound);
sl@0
  1661
		TEST(changes.FindByViewIndex(viewIndex)>=0);
sl@0
  1662
		TEST(changes.Find(TLogId(100000000))==KErrNotFound);
sl@0
  1663
		}
sl@0
  1664
	
sl@0
  1665
	CBufFlat* buffer = CBufFlat::NewL(10*1024);
sl@0
  1666
	CleanupStack::PushL(buffer);
sl@0
  1667
	RBufWriteStream wstr(*buffer,0);
sl@0
  1668
	wstr << changes;
sl@0
  1669
	wstr.CommitL();
sl@0
  1670
	wstr.Close();
sl@0
  1671
	RBufReadStream rstr(*buffer,0);
sl@0
  1672
	CLogChangeDefinition* changes2 = CLogChangeDefinition::NewL(rstr);
sl@0
  1673
	CleanupStack::PushL(changes2);
sl@0
  1674
	rstr.Close();
sl@0
  1675
	
sl@0
  1676
	TEST(changes.Count()==changes2->Count());
sl@0
  1677
sl@0
  1678
	CleanupStack::PopAndDestroy(3); // changes2, buffer, view
sl@0
  1679
	
sl@0
  1680
	// Check the change was as expected
sl@0
  1681
	TEST2(changes.Count(), 10);
sl@0
  1682
	type = changes.At(0, logId, viewIndex);
sl@0
  1683
sl@0
  1684
	CleanupStack::PopAndDestroy(4, event); // changeObs, active, filter, event
sl@0
  1685
	
sl@0
  1686
	TEST2(type, ELogChangeTypeEventAdded);
sl@0
  1687
	TEST2(viewIndex, 0); // first (newest) events in the view
sl@0
  1688
sl@0
  1689
	const TLogId expectedLogId = ((TLogId) 1);
sl@0
  1690
	TEST2(logId, expectedLogId);
sl@0
  1691
	}
sl@0
  1692
sl@0
  1693
void DoStartL()
sl@0
  1694
	{
sl@0
  1695
	CActiveScheduler::Install(new(ELeave)CActiveScheduler);
sl@0
  1696
	RFs fs;
sl@0
  1697
	LEAVE_IF_ERROR(fs.Connect());
sl@0
  1698
	CleanupClosePushL(fs);
sl@0
  1699
	CLogClient* client = CLogClient::NewL(fs);
sl@0
  1700
	delete client;
sl@0
  1701
	CleanupStack::PopAndDestroy(&fs);
sl@0
  1702
	delete CActiveScheduler::Current();
sl@0
  1703
	}
sl@0
  1704
sl@0
  1705
static TInt LaunchThread(TAny* /*aAny*/)
sl@0
  1706
	{
sl@0
  1707
	__UHEAP_MARK;
sl@0
  1708
	CTrapCleanup* cleanup = CTrapCleanup::New();
sl@0
  1709
	TRAPD(err, DoStartL());		
sl@0
  1710
	delete cleanup;	
sl@0
  1711
	__UHEAP_MARKEND;
sl@0
  1712
	if(err != KErrNone)
sl@0
  1713
		{
sl@0
  1714
		RDebug::Print(_L("*** DoStartL() failed with err %d\r\n"), err);
sl@0
  1715
		User::Panic(_L("ThrChk5"), 5);
sl@0
  1716
		}
sl@0
  1717
	return KErrNone;
sl@0
  1718
	}
sl@0
  1719
sl@0
  1720
/**
sl@0
  1721
@SYMTestCaseID          SYSLIB-LOGENG-CT-0849
sl@0
  1722
@SYMTestCaseDesc	    Tests for creation of two simultaneous threads
sl@0
  1723
@SYMTestPriority 	    High
sl@0
  1724
@SYMTestActions  	    Create two threads,start and close the threads 
sl@0
  1725
@SYMTestExpectedResults Test must not fail
sl@0
  1726
@SYMREQ                 REQ0000
sl@0
  1727
*/
sl@0
  1728
LOCAL_C void TestStartupL()
sl@0
  1729
	{
sl@0
  1730
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0849 "));
sl@0
  1731
	RThread thread1;
sl@0
  1732
	RThread thread2;
sl@0
  1733
sl@0
  1734
	// Create the threads
sl@0
  1735
	LEAVE_IF_ERROR(thread1.Create(_L("Thread1"), LaunchThread, KDefaultStackSize, KMinHeapSize , KMinHeapSize , NULL));
sl@0
  1736
	LEAVE_IF_ERROR(thread2.Create(_L("Thread2"), LaunchThread, KDefaultStackSize, KMinHeapSize , KMinHeapSize, NULL));
sl@0
  1737
sl@0
  1738
	// Let them run
sl@0
  1739
	TRequestStatus s1;
sl@0
  1740
	thread1.Logon(s1);
sl@0
  1741
	thread1.Resume();
sl@0
  1742
	
sl@0
  1743
	TRequestStatus s2;
sl@0
  1744
	thread2.Logon(s2);
sl@0
  1745
	thread2.Resume();
sl@0
  1746
sl@0
  1747
	User::WaitForRequest(s1);
sl@0
  1748
	TEST(thread1.ExitType() != EExitPanic);
sl@0
  1749
	thread1.Close();
sl@0
  1750
	
sl@0
  1751
	User::WaitForRequest(s2);
sl@0
  1752
	TEST(thread2.ExitType() != EExitPanic);
sl@0
  1753
	thread2.Close();
sl@0
  1754
	
sl@0
  1755
	TEST2(s1.Int(), KErrNone);
sl@0
  1756
	TEST2(s2.Int(), KErrNone);
sl@0
  1757
	}
sl@0
  1758
sl@0
  1759
/**
sl@0
  1760
@SYMTestCaseID          SYSLIB-LOGENG-CT-0850
sl@0
  1761
@SYMTestCaseDesc	    Tests for invalid database scheme 
sl@0
  1762
@SYMTestPriority 	    High
sl@0
  1763
@SYMTestActions  	    Create a log event implementation,should leave if there is a problem
sl@0
  1764
@SYMTestExpectedResults Test must not fail
sl@0
  1765
@SYMREQ                 REQ0000
sl@0
  1766
*/
sl@0
  1767
LOCAL_C void TestInvalidSchemaL()
sl@0
  1768
	{
sl@0
  1769
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0850 "));
sl@0
  1770
	TestUtils::TestInvalidSchemaL();
sl@0
  1771
	}
sl@0
  1772
sl@0
  1773
void doTestsL()
sl@0
  1774
	{
sl@0
  1775
	TestUtils::Initialize(_L("t_logapi"));
sl@0
  1776
	
sl@0
  1777
	// This test should be first to ensure no clients kicking around
sl@0
  1778
	TheTest.Next(_L("Invalid database scheme"));
sl@0
  1779
	TestInvalidSchemaL();
sl@0
  1780
	theLog.Write(_L8("Test 0 OK\n"));
sl@0
  1781
sl@0
  1782
	TheTest.Start(_L("Simultaneous Startup"));
sl@0
  1783
	TestStartupL();
sl@0
  1784
	theLog.Write(_L8("Test 1 OK\n"));
sl@0
  1785
sl@0
  1786
	CLogChangeNotifier* notifier = CLogChangeNotifier::NewL();
sl@0
  1787
	CleanupStack::PushL(notifier);
sl@0
  1788
sl@0
  1789
	TheTest.Next(_L("Dying thread test"));
sl@0
  1790
	TestThreadDieL();
sl@0
  1791
	theLog.Write(_L8("Test 2 OK\n"));
sl@0
  1792
	
sl@0
  1793
	TestUtils::DeleteDatabaseL();
sl@0
  1794
sl@0
  1795
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
  1796
	CleanupStack::PushL(client);
sl@0
  1797
sl@0
  1798
	CTestActive* active = new(ELeave) CTestActive(CActive::EPriorityIdle - 500);
sl@0
  1799
	CleanupStack::PushL(active);
sl@0
  1800
	
sl@0
  1801
	TheTest.Next(_L("Additional tests on CLogChangeDefinition."));
sl@0
  1802
	TestLogChangeDefinitionL(*client);
sl@0
  1803
	theLog.Write(_L8("Test 2.1 OK\n"));
sl@0
  1804
	TestUtils::DeleteDatabaseL();
sl@0
  1805
	
sl@0
  1806
	TheTest.Next(_L("Client death"));
sl@0
  1807
	TestClientFailL();
sl@0
  1808
	theLog.Write(_L8("Test 3 OK\n"));
sl@0
  1809
sl@0
  1810
	TheTest.Next(_L("Testing client API"));
sl@0
  1811
	TestNoNotifierL();
sl@0
  1812
	theLog.Write(_L8("Test 4 OK\n"));
sl@0
  1813
sl@0
  1814
	// Delay for testing change notification
sl@0
  1815
	TInt delay = 5000000;	
sl@0
  1816
	User::After(delay);	
sl@0
  1817
sl@0
  1818
sl@0
  1819
	active->StartL();
sl@0
  1820
	client->NotifyChange(delay, active->iStatus);
sl@0
  1821
sl@0
  1822
	TheTest.Next(_L("Delete Event Type"));
sl@0
  1823
	TestDeleteEventTypeL(*client);
sl@0
  1824
	theLog.Write(_L8("Test 5 OK\n"));
sl@0
  1825
sl@0
  1826
	CActiveScheduler::Start();
sl@0
  1827
	TEST(active->iStatus.Int() >= 0);
sl@0
  1828
sl@0
  1829
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0834 Add Event Type "));
sl@0
  1830
	TestAddEventTypeL(*client);
sl@0
  1831
	theLog.Write(_L8("Test 6 OK\n"));
sl@0
  1832
sl@0
  1833
	// Must delete the database before testing
sl@0
  1834
	// the notification API, since we just created the
sl@0
  1835
	// entry in the previous test (6) and therefore
sl@0
  1836
	// attempting to add the entry again just results in
sl@0
  1837
	// KErrAlreadyExists and does not cause a change to the
sl@0
  1838
	// database.
sl@0
  1839
	TestUtils::DeleteDatabaseL();
sl@0
  1840
sl@0
  1841
	active->StartL();
sl@0
  1842
	client->NotifyChange(delay, active->iStatus);
sl@0
  1843
sl@0
  1844
	TestAddEventTypeL(*client);
sl@0
  1845
sl@0
  1846
	CActiveScheduler::Start();
sl@0
  1847
	TEST(active->iStatus.Int() >= 0);
sl@0
  1848
	active->StartL();
sl@0
  1849
	client->NotifyChange(delay, active->iStatus);
sl@0
  1850
sl@0
  1851
	// The following doesn't make any changes
sl@0
  1852
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0835 Get Event Type "));
sl@0
  1853
	TestGetEventTypeL(*client);
sl@0
  1854
	theLog.Write(_L8("Test 7 OK\n"));
sl@0
  1855
sl@0
  1856
	TheTest.Next(_L("Change Event Type"));
sl@0
  1857
	TestChangeEventTypeL(*client);
sl@0
  1858
	theLog.Write(_L8("Test 8 OK\n"));
sl@0
  1859
sl@0
  1860
	CActiveScheduler::Start();
sl@0
  1861
	TEST(active->iStatus.Int() >= 0);
sl@0
  1862
	active->StartL();
sl@0
  1863
	client->NotifyChange(delay, active->iStatus);
sl@0
  1864
sl@0
  1865
	TheTest.Next(_L("Delete Event Type"));
sl@0
  1866
	TestDeleteEventTypeL(*client);
sl@0
  1867
	theLog.Write(_L8("Test 9 OK\n"));
sl@0
  1868
sl@0
  1869
	CActiveScheduler::Start();
sl@0
  1870
	TEST(active->iStatus.Int() >= 0);
sl@0
  1871
	active->StartL();
sl@0
  1872
	client->NotifyChange(delay, active->iStatus);
sl@0
  1873
sl@0
  1874
	TheTest.Next(_L("Add Event"));
sl@0
  1875
	TestAddEventL(*client);
sl@0
  1876
	theLog.Write(_L8("Test 10 OK\n"));
sl@0
  1877
sl@0
  1878
	CActiveScheduler::Start();
sl@0
  1879
	TEST(active->iStatus.Int() >= 0);
sl@0
  1880
	active->StartL();
sl@0
  1881
	client->NotifyChange(delay, active->iStatus);
sl@0
  1882
sl@0
  1883
	// The following doesn't make any changes
sl@0
  1884
	TheTest.Next(_L("Get Event"));
sl@0
  1885
	TestGetEventL(*client);
sl@0
  1886
	theLog.Write(_L8("Test 11 OK\n"));
sl@0
  1887
sl@0
  1888
	TheTest.Next(_L("Change Event"));
sl@0
  1889
	TestChangeEventL(*client);
sl@0
  1890
	theLog.Write(_L8("Test 12 OK\n"));
sl@0
  1891
sl@0
  1892
	CActiveScheduler::Start();
sl@0
  1893
	TEST(active->iStatus.Int() >= 0);
sl@0
  1894
	active->StartL();
sl@0
  1895
	client->NotifyChange(delay, active->iStatus);
sl@0
  1896
sl@0
  1897
	TheTest.Next(_L("Delete Event"));
sl@0
  1898
	TestDeleteEventL(*client);
sl@0
  1899
	theLog.Write(_L8("Test 13 OK\n"));
sl@0
  1900
sl@0
  1901
	CActiveScheduler::Start();
sl@0
  1902
	TEST(active->iStatus.Int() >= 0);
sl@0
  1903
	active->StartL();
sl@0
  1904
	client->NotifyChange(delay, active->iStatus);
sl@0
  1905
sl@0
  1906
	// The following doesn't make any changes
sl@0
  1907
	TheTest.Next(_L("Get Config"));
sl@0
  1908
	TestGetConfigL(*client);
sl@0
  1909
	theLog.Write(_L8("Test 14 OK\n"));
sl@0
  1910
sl@0
  1911
	TheTest.Next(_L("Change Config"));
sl@0
  1912
	TestChangeConfigL(*client);
sl@0
  1913
	theLog.Write(_L8("Test 15 OK\n"));
sl@0
  1914
sl@0
  1915
	CActiveScheduler::Start();
sl@0
  1916
	TEST(active->iStatus.Int() >= 0);
sl@0
  1917
	active->StartL();
sl@0
  1918
	client->NotifyChange(delay*3, active->iStatus);
sl@0
  1919
sl@0
  1920
	// The following doesn't make any changes
sl@0
  1921
	TheTest.Next(_L("Get String"));
sl@0
  1922
	TestGetStringL(*client);
sl@0
  1923
	theLog.Write(_L8("Test 16 OK\n"));
sl@0
  1924
sl@0
  1925
	TheTest.Next(_L("Clear Event Log"));
sl@0
  1926
	TestClearEventLogL(*client);
sl@0
  1927
	theLog.Write(_L8("Test 17 OK\n"));
sl@0
  1928
sl@0
  1929
	CActiveScheduler::Start();
sl@0
  1930
	TEST(active->iStatus.Int() >= 0);
sl@0
  1931
	active->StartL();
sl@0
  1932
	client->NotifyChange(delay, active->iStatus);
sl@0
  1933
sl@0
  1934
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0833 Test global change API "));
sl@0
  1935
	TestClientObserverMechanismL(*client);
sl@0
  1936
	theLog.Write(_L8("Test 18 OK\n"));
sl@0
  1937
sl@0
  1938
	TheTest.Next(_L("Multiple client access"));
sl@0
  1939
	TestMultipleClientAccessL();
sl@0
  1940
	theLog.Write(_L8("Test 19 OK\n"));
sl@0
  1941
	
sl@0
  1942
	theLog.Write(_L8("Destroying: active\n"));
sl@0
  1943
	CleanupStack::PopAndDestroy(active);
sl@0
  1944
	theLog.Write(_L8("Destroyed ok\n"));
sl@0
  1945
	theLog.Write(_L8("Destroying: client\n"));
sl@0
  1946
	CleanupStack::PopAndDestroy(client);
sl@0
  1947
	theLog.Write(_L8("Destroyed ok\n"));
sl@0
  1948
	theLog.Write(_L8("Destroying: notifier\n"));
sl@0
  1949
	CleanupStack::PopAndDestroy(notifier);
sl@0
  1950
	theLog.Write(_L8("Destroyed ok\n"));
sl@0
  1951
sl@0
  1952
sl@0
  1953
#ifdef SYSLIBS_TEST		
sl@0
  1954
	theLog.Write(_L8("Preparing the context for the test : @SYMTestCaseID:SYSLIB-LOGENG-UT-4015... \n"));
sl@0
  1955
	theLog.Write(_L8("Deleting the Log engine database... \n"));	
sl@0
  1956
	TestUtils::DeleteDatabaseL();
sl@0
  1957
	theLog.Write(_L8("Allocating a new CLogClient object... \n"));
sl@0
  1958
	CLogClient* theClient = CLogClient::NewL(theFs);
sl@0
  1959
	CleanupStack::PushL(theClient);	
sl@0
  1960
	TheTest.Next(_L("TestGetConfigSettingsFromRepositoryFileL () "));
sl@0
  1961
	TestGetConfigSettingsFromRepositoryFileL(*theClient);
sl@0
  1962
	theLog.Write(_L8("TestGetConfigSettingsFromRepositoryFileL () OK\n"));
sl@0
  1963
	theLog.Write(_L8("Destroying the CLogClient object... \n"));	
sl@0
  1964
	CleanupStack::PopAndDestroy(theClient);
sl@0
  1965
	theLog.Write(_L8("Destroyed ok\n"));
sl@0
  1966
#else
sl@0
  1967
	theLog.Write(_L8("The Test PREQ2103 works only when SYSLIBS_TEST macro is defined"));
sl@0
  1968
#endif
sl@0
  1969
	}