os/persistentdata/loggingservices/eventlogger/test/src/t_logfile.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) 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 "t_logutil2.h"
sl@0
    18
sl@0
    19
/*
sl@0
    20
This test may fail occasionally, especially after changing the LogEng server code. The reported error is KErrCorrupt.
sl@0
    21
The typical scenario when the test fails is:
sl@0
    22
1) Some of the test functions calls "__FILE_FAILNEXT(failCount++)"
sl@0
    23
2) The test calls some CLogClient method, typically "aClient.GetEventType()".
sl@0
    24
3) The statement "test(active->iStatus == KErrNone)" fails.
sl@0
    25
This behaviour might be related to INC044553 "DBMS does not handle OOD error 
sl@0
    26
scenarios correctly when committing a transaction".
sl@0
    27
"__FILE_FAILNEXT" is a macro, which calls theFs.SetErrorCondition(KErrGeneral, X).
sl@0
    28
If you perform a search with "SetErrorCondition" keyword in "Programming" database, you will find
sl@0
    29
some explanations that the programmer has to be careful when using SetErrorCondition() method,
sl@0
    30
because:
sl@0
    31
sl@0
    32
"You have to be careful if you use this in the same way as you do for heap testing, because you 
sl@0
    33
can get the file system in a state where it think the file you're working on is corrupted."
sl@0
    34
sl@0
    35
Anyway, LOGENG server internally uses DBMS component. Calling SetErrorCondition() we test DBMS 
sl@0
    36
component actually not LOGENG component!
sl@0
    37
There is one addidtional thing in the test, which makes me believing that the problem is not 
sl@0
    38
in LOGENG but in SetErrorCondition()/DBMS interaction - in many if the test functions a statement
sl@0
    39
like:
sl@0
    40
sl@0
    41
  		if (failCount == 5)
sl@0
    42
			failCount++;
sl@0
    43
sl@0
    44
may be found. I think that it is there to prevent exactly the problem with 
sl@0
    45
SetErrorCondition()/DBMS interaction.
sl@0
    46
*/
sl@0
    47
sl@0
    48
RTest TheTest(_L("t_logfile"));
sl@0
    49
sl@0
    50
const TUid KTestEventUid = {0x10005393};
sl@0
    51
_LIT(KTestEventDesc1, "Event Type Description");
sl@0
    52
_LIT(KTestEventDesc2, "Changed Event Description");
sl@0
    53
_LIT(KTestRemoteParty1, "Remote Party");
sl@0
    54
_LIT(KTestRemoteParty2, "Changed Remote Party");
sl@0
    55
_LIT(KTestDirection1, "Direction");
sl@0
    56
_LIT(KTestDirection2, "Changed Direction");
sl@0
    57
const TLogDurationType KTestDurationType1 = 1;
sl@0
    58
const TLogDurationType KTestDurationType2 = 2;
sl@0
    59
const TLogDuration KTestDuration1 = 0x1234;
sl@0
    60
const TLogDuration KTestDuration2 = 0x1234567;
sl@0
    61
_LIT(KTestStatus1, "Status");
sl@0
    62
_LIT(KTestStatus2, "Changed Status");
sl@0
    63
_LIT(KTestSubject1, "Subject");
sl@0
    64
_LIT(KTestSubject2, "Changed Subject");
sl@0
    65
_LIT(KTestNumber1, "Number");
sl@0
    66
_LIT(KTestNumber2, "Changed Number");
sl@0
    67
const TLogContactItemId KTestContact1 = 0x1234;
sl@0
    68
const TLogContactItemId KTestContact2 = 0x1234567;
sl@0
    69
const TLogLink KTestLink1 = 0x1234;
sl@0
    70
const TLogLink KTestLink2 = 0x1234567;
sl@0
    71
_LIT8(KTestData1, "ABCDEFGH");
sl@0
    72
_LIT8(KTestData2, "IJKLMNOPQRSTUVWXYZ");
sl@0
    73
const TLogSize KTestMaxLogSize = 0xFFF;
sl@0
    74
const TLogRecentSize KTestMaxRecentLogSize = 0xF;
sl@0
    75
const TLogAge KTestMaxEventAge = 0xFFFFFFF;
sl@0
    76
sl@0
    77
/**
sl@0
    78
@SYMTestCaseID          SYSLIB-LOGENG-CT-1334
sl@0
    79
@SYMTestCaseDesc	    Basic test to add events
sl@0
    80
@SYMTestPriority 	    High
sl@0
    81
@SYMTestActions  	    Tests for CLogClient::AddEvent() function
sl@0
    82
@SYMTestExpectedResults Test must not fail
sl@0
    83
@SYMREQ                 REQ0000
sl@0
    84
*/
sl@0
    85
LOCAL_C void TestBasicL(CLogClient& aClient)
sl@0
    86
	{
sl@0
    87
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1334 "));
sl@0
    88
	CTestActive* active = new(ELeave)CTestActive();
sl@0
    89
	CleanupStack::PushL(active);
sl@0
    90
sl@0
    91
	CLogEvent* event = CLogEvent::NewL();
sl@0
    92
	CleanupStack::PushL(event);
sl@0
    93
sl@0
    94
	TTime now;
sl@0
    95
	now.UniversalTime();
sl@0
    96
sl@0
    97
	event->SetEventType(KLogCallEventTypeUid);
sl@0
    98
sl@0
    99
	active->StartL();
sl@0
   100
	aClient.AddEvent(*event, active->iStatus);
sl@0
   101
	CActiveScheduler::Start();
sl@0
   102
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   103
sl@0
   104
	TEST(event->EventType() == KLogCallEventTypeUid);
sl@0
   105
	TEST(event->Description().Length() > 0);
sl@0
   106
	TEST(event->Time() >= now);
sl@0
   107
	now = event->Time();
sl@0
   108
sl@0
   109
	TLogId id = event->Id();
sl@0
   110
sl@0
   111
	event->SetRemoteParty(KTestRemoteParty1);
sl@0
   112
	event->SetDirection(KTestDirection1);
sl@0
   113
	event->SetDurationType(KTestDurationType1);
sl@0
   114
	event->SetDuration(KTestDuration1);
sl@0
   115
	event->SetStatus(KTestStatus1);
sl@0
   116
	event->SetSubject(KTestSubject1);
sl@0
   117
	event->SetNumber(KTestNumber1);
sl@0
   118
	event->SetContact(KTestContact1);
sl@0
   119
	event->SetLink(KTestLink1);
sl@0
   120
	event->SetDataL(KTestData1);
sl@0
   121
sl@0
   122
	active->StartL();
sl@0
   123
	aClient.ChangeEvent(*event, active->iStatus);
sl@0
   124
	CActiveScheduler::Start();
sl@0
   125
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   126
sl@0
   127
	TEST(event->Id() == id);
sl@0
   128
	TEST(event->EventType() == KLogCallEventTypeUid);
sl@0
   129
	TEST(event->Description().Length() > 0);
sl@0
   130
	TEST(event->Time() == now);
sl@0
   131
	TEST(event->RemoteParty() == KTestRemoteParty1);
sl@0
   132
	TEST(event->Direction() == KTestDirection1);
sl@0
   133
	TEST(event->DurationType() == KTestDurationType1);
sl@0
   134
	TEST(event->Duration() == KTestDuration1);
sl@0
   135
	TEST(event->Status() == KTestStatus1);
sl@0
   136
	TEST(event->Subject() == KTestSubject1);
sl@0
   137
	TEST(event->Number() == KTestNumber1);
sl@0
   138
	TEST(event->Contact() == KTestContact1);
sl@0
   139
	TEST(event->Link() == KTestLink1);
sl@0
   140
	TEST(event->Data() == KTestData1);
sl@0
   141
sl@0
   142
	CleanupStack::PopAndDestroy(); // event;
sl@0
   143
sl@0
   144
	event = CLogEvent::NewL();
sl@0
   145
	CleanupStack::PushL(event);
sl@0
   146
sl@0
   147
	event->SetId(id);
sl@0
   148
sl@0
   149
	active->StartL();
sl@0
   150
	aClient.GetEvent(*event, active->iStatus);
sl@0
   151
	CActiveScheduler::Start();
sl@0
   152
	TEST2(active->iStatus.Int(),KErrNone);
sl@0
   153
sl@0
   154
	TEST(event->Id() == id);
sl@0
   155
	TEST(event->EventType() == KLogCallEventTypeUid);
sl@0
   156
	TEST(event->Description().Length() > 0);
sl@0
   157
	TEST(event->Time() == now);
sl@0
   158
	TEST(event->RemoteParty() == KTestRemoteParty1);
sl@0
   159
	TEST(event->Direction() == KTestDirection1);
sl@0
   160
	TEST(event->DurationType() == KTestDurationType1);
sl@0
   161
	TEST(event->Duration() == KTestDuration1);
sl@0
   162
	TEST(event->Status() == KTestStatus1);
sl@0
   163
	TEST(event->Subject() == KTestSubject1);
sl@0
   164
	TEST(event->Number() == KTestNumber1);
sl@0
   165
	TEST(event->Contact() == KTestContact1);
sl@0
   166
	TEST(event->Link() == KTestLink1);
sl@0
   167
	TEST(event->Data() == KTestData1);
sl@0
   168
sl@0
   169
	active->StartL();
sl@0
   170
	aClient.DeleteEvent(id, active->iStatus);
sl@0
   171
	CActiveScheduler::Start();
sl@0
   172
	TEST2(active->iStatus.Int(),KErrNone);
sl@0
   173
sl@0
   174
	active->StartL();
sl@0
   175
	aClient.GetEvent(*event, active->iStatus);
sl@0
   176
	CActiveScheduler::Start();
sl@0
   177
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
   178
sl@0
   179
	CleanupStack::PopAndDestroy(2); // event, active
sl@0
   180
	}
sl@0
   181
sl@0
   182
/**
sl@0
   183
@SYMTestCaseID          SYSLIB-LOGENG-CT-0911
sl@0
   184
@SYMTestCaseDesc	    Tests for new CLogClient object creation
sl@0
   185
@SYMTestPriority 	    High
sl@0
   186
@SYMTestActions  	    Create a new CLogClient check for memory errors
sl@0
   187
@SYMTestExpectedResults Test must not fail
sl@0
   188
@SYMREQ                 REQ0000
sl@0
   189
*/
sl@0
   190
LOCAL_C void TestConstructionL()
sl@0
   191
	{
sl@0
   192
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0911 "));
sl@0
   193
	CLogClient* client = NULL;
sl@0
   194
sl@0
   195
	TInt failCount = 0;
sl@0
   196
	TBool finished = EFalse;
sl@0
   197
	TInt error;
sl@0
   198
sl@0
   199
	while(!finished)
sl@0
   200
		{
sl@0
   201
		TheTest.Printf(_L("%d\r\n"), failCount);
sl@0
   202
sl@0
   203
        if(failCount > 8)
sl@0
   204
            {
sl@0
   205
            TRAP(error, client = CLogClient::NewL(theFs));
sl@0
   206
            TEST2(error, KErrNone);
sl@0
   207
            TestBasicL(*client);
sl@0
   208
            finished = ETrue;
sl@0
   209
            continue;
sl@0
   210
            }
sl@0
   211
		
sl@0
   212
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
   213
sl@0
   214
		TRAP(error, client = CLogClient::NewL(theFs));
sl@0
   215
sl@0
   216
		__FILE_RESET;
sl@0
   217
sl@0
   218
		if (error == KErrNone)
sl@0
   219
			{
sl@0
   220
			finished = ETrue;
sl@0
   221
			TestBasicL(*client);
sl@0
   222
			}
sl@0
   223
		else
sl@0
   224
			{
sl@0
   225
			TEST2(error, KErrNoMemory);
sl@0
   226
			TestUtils::DeleteDatabaseL();
sl@0
   227
			}
sl@0
   228
		}
sl@0
   229
sl@0
   230
	delete client;
sl@0
   231
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
   232
	}
sl@0
   233
sl@0
   234
/**
sl@0
   235
@SYMTestCaseID          SYSLIB-LOGENG-CT-0912
sl@0
   236
@SYMTestCaseDesc	    Adding an event type test,
sl@0
   237
                        Tests for CLogClient::AddEventType() function
sl@0
   238
@SYMTestPriority 	    High
sl@0
   239
@SYMTestActions  	    Check for file failure errors while adding event types
sl@0
   240
@SYMTestExpectedResults Test must not fail
sl@0
   241
@SYMREQ                 REQ0000
sl@0
   242
*/
sl@0
   243
LOCAL_C void TestAddEventTypeL(CLogClient& aClient)
sl@0
   244
	{
sl@0
   245
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0912 "));
sl@0
   246
	CLogEventType* type = CLogEventType::NewL();
sl@0
   247
	CleanupStack::PushL(type);
sl@0
   248
sl@0
   249
	type->SetUid(KTestEventUid);
sl@0
   250
	type->SetDescription(KTestEventDesc1);
sl@0
   251
	type->SetLoggingEnabled(ETrue);
sl@0
   252
sl@0
   253
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   254
	CleanupStack::PushL(active);
sl@0
   255
sl@0
   256
	TInt failCount = 0;
sl@0
   257
	TBool finished = EFalse;
sl@0
   258
	TInt error;
sl@0
   259
sl@0
   260
	while(!finished)
sl@0
   261
		{
sl@0
   262
		error = KErrNone;
sl@0
   263
        if(failCount == 8)
sl@0
   264
            {
sl@0
   265
            aClient.AddEventType(*type, active->iStatus);
sl@0
   266
            active->StartL();
sl@0
   267
            CActiveScheduler::Start();
sl@0
   268
            TEST2(active->iStatus.Int(), KErrNone);
sl@0
   269
            finished = ETrue;
sl@0
   270
            continue;
sl@0
   271
            }
sl@0
   272
sl@0
   273
		TheTest.Printf(_L("%d  \r"), failCount);
sl@0
   274
        
sl@0
   275
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
   276
		
sl@0
   277
		aClient.AddEventType(*type, active->iStatus);
sl@0
   278
	
sl@0
   279
		active->StartL();
sl@0
   280
		CActiveScheduler::Start();
sl@0
   281
		
sl@0
   282
		if (active->iStatus == KErrNone)
sl@0
   283
			finished = ETrue;
sl@0
   284
		else
sl@0
   285
			error = active->iStatus.Int();
sl@0
   286
sl@0
   287
		__FILE_RESET;
sl@0
   288
sl@0
   289
		if (error == KErrNoMemory)
sl@0
   290
			{
sl@0
   291
			active->StartL();
sl@0
   292
			aClient.GetEventType(*type, active->iStatus);
sl@0
   293
			CActiveScheduler::Start();
sl@0
   294
			TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
   295
			}
sl@0
   296
		else
sl@0
   297
			TEST2(error, KErrNone);
sl@0
   298
sl@0
   299
		}
sl@0
   300
sl@0
   301
	active->StartL();
sl@0
   302
	aClient.AddEventType(*type, active->iStatus);
sl@0
   303
	CActiveScheduler::Start();
sl@0
   304
	TEST2(active->iStatus.Int(), KErrAlreadyExists);
sl@0
   305
sl@0
   306
	CleanupStack::PopAndDestroy(2); // active, type
sl@0
   307
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
   308
	}
sl@0
   309
sl@0
   310
/**
sl@0
   311
@SYMTestCaseID          SYSLIB-LOGENG-CT-0913
sl@0
   312
@SYMTestCaseDesc	    Getting an event type test.
sl@0
   313
                        Tests for CLogClient::GetEventType() function
sl@0
   314
@SYMTestPriority 	    High
sl@0
   315
@SYMTestActions  	    Check for file failure errors while getting event types
sl@0
   316
@SYMTestExpectedResults Test must not fail
sl@0
   317
@SYMREQ                 REQ0000
sl@0
   318
*/
sl@0
   319
LOCAL_C void TestGetEventTypeL(CLogClient& aClient)
sl@0
   320
	{
sl@0
   321
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0913 "));
sl@0
   322
	CLogEventType* type = CLogEventType::NewL();
sl@0
   323
	CleanupStack::PushL(type);
sl@0
   324
sl@0
   325
	type->SetUid(KTestEventUid);
sl@0
   326
sl@0
   327
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   328
	CleanupStack::PushL(active);
sl@0
   329
sl@0
   330
	TInt failCount = 0;
sl@0
   331
	TBool finished = EFalse;
sl@0
   332
sl@0
   333
	while(!finished)
sl@0
   334
		{
sl@0
   335
		TheTest.Printf(_L("%d  \r"), failCount);
sl@0
   336
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
   337
sl@0
   338
		aClient.GetEventType(*type, active->iStatus);
sl@0
   339
sl@0
   340
		active->StartL();
sl@0
   341
		CActiveScheduler::Start();
sl@0
   342
		
sl@0
   343
		if (active->iStatus == KErrNone)
sl@0
   344
			finished = ETrue;
sl@0
   345
		else
sl@0
   346
			{
sl@0
   347
			TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   348
			TEST(type->Description() == KNullDesC);
sl@0
   349
			}
sl@0
   350
sl@0
   351
		__FILE_RESET;
sl@0
   352
		}
sl@0
   353
sl@0
   354
	TEST(type->Uid() == KTestEventUid);
sl@0
   355
	TEST(type->Description() == KTestEventDesc1);
sl@0
   356
	TEST(type->LoggingEnabled());
sl@0
   357
sl@0
   358
	CleanupStack::PopAndDestroy(2); // active, type
sl@0
   359
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
   360
	}
sl@0
   361
sl@0
   362
/**
sl@0
   363
@SYMTestCaseID          SYSLIB-LOGENG-CT-0914
sl@0
   364
@SYMTestCaseDesc	    Changing an event type test,
sl@0
   365
                        Tests for CLogClient::ChangeEventType() function
sl@0
   366
@SYMTestPriority 	    High
sl@0
   367
@SYMTestActions  	    Check for file failure errors while changing event types
sl@0
   368
@SYMTestExpectedResults Test must not fail
sl@0
   369
@SYMREQ                 REQ0000
sl@0
   370
*/
sl@0
   371
LOCAL_C void TestChangeEventTypeL(CLogClient& aClient)
sl@0
   372
	{
sl@0
   373
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0914 "));
sl@0
   374
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   375
	CleanupStack::PushL(active);
sl@0
   376
sl@0
   377
	CLogEventType* type = CLogEventType::NewL();
sl@0
   378
	CleanupStack::PushL(type);
sl@0
   379
sl@0
   380
	type->SetUid(KTestEventUid);
sl@0
   381
sl@0
   382
	TInt failCount = 0;
sl@0
   383
	TBool finished = EFalse;
sl@0
   384
	TInt error;
sl@0
   385
sl@0
   386
	while(!finished)
sl@0
   387
		{
sl@0
   388
		error = KErrNone;
sl@0
   389
sl@0
   390
		type->SetDescription(KTestEventDesc2);
sl@0
   391
		type->SetLoggingEnabled(EFalse);
sl@0
   392
sl@0
   393
        if(failCount == 8)
sl@0
   394
            {
sl@0
   395
            aClient.ChangeEventType(*type, active->iStatus);
sl@0
   396
            active->StartL();
sl@0
   397
            CActiveScheduler::Start();
sl@0
   398
            TEST2(active->iStatus.Int(), KErrNone);
sl@0
   399
            finished = ETrue;
sl@0
   400
            continue;
sl@0
   401
            }
sl@0
   402
		
sl@0
   403
		TheTest.Printf(_L("%d  \r"), failCount);
sl@0
   404
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
   405
sl@0
   406
		aClient.ChangeEventType(*type, active->iStatus);
sl@0
   407
sl@0
   408
		active->StartL();
sl@0
   409
		CActiveScheduler::Start();
sl@0
   410
sl@0
   411
		if (active->iStatus == KErrNone)
sl@0
   412
			finished = ETrue;
sl@0
   413
		else
sl@0
   414
			error = active->iStatus.Int();
sl@0
   415
sl@0
   416
		__FILE_RESET;
sl@0
   417
sl@0
   418
		if (error == KErrNoMemory)
sl@0
   419
			{
sl@0
   420
			active->StartL();
sl@0
   421
			aClient.GetEventType(*type, active->iStatus);
sl@0
   422
			CActiveScheduler::Start();
sl@0
   423
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
   424
sl@0
   425
			TEST(type->Description() == KTestEventDesc1);
sl@0
   426
			TEST(type->LoggingEnabled());
sl@0
   427
			}
sl@0
   428
		else
sl@0
   429
			TEST2(error, KErrNone);
sl@0
   430
		}
sl@0
   431
sl@0
   432
	type->SetUid(KTestEventUid);
sl@0
   433
sl@0
   434
	active->StartL();
sl@0
   435
	aClient.GetEventType(*type, active->iStatus);
sl@0
   436
	CActiveScheduler::Start();
sl@0
   437
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   438
sl@0
   439
	TEST(type->Uid() == KTestEventUid);
sl@0
   440
	TEST(type->Description() == KTestEventDesc2);
sl@0
   441
	TEST(type->LoggingEnabled() == EFalse);
sl@0
   442
sl@0
   443
	CleanupStack::PopAndDestroy(2); // type, active
sl@0
   444
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
   445
	}
sl@0
   446
sl@0
   447
/**
sl@0
   448
@SYMTestCaseID          SYSLIB-LOGENG-CT-0915
sl@0
   449
@SYMTestCaseDesc	    Deleting an event type test
sl@0
   450
                        Tests for CLogClient::DeleteEventType() function
sl@0
   451
@SYMTestPriority 	    High
sl@0
   452
@SYMTestActions  	    Check for file failure errors while deleting event types
sl@0
   453
@SYMTestExpectedResults Test must not fail
sl@0
   454
@SYMREQ                 REQ0000
sl@0
   455
*/
sl@0
   456
LOCAL_C void TestDeleteEventTypeL(CLogClient& aClient)
sl@0
   457
	{
sl@0
   458
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0915 "));
sl@0
   459
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   460
	CleanupStack::PushL(active);
sl@0
   461
sl@0
   462
	CLogEventType* type = CLogEventType::NewL();
sl@0
   463
	CleanupStack::PushL(type);
sl@0
   464
sl@0
   465
	type->SetUid(KTestEventUid);
sl@0
   466
sl@0
   467
	TInt failCount = 0;
sl@0
   468
	TBool finished = EFalse;
sl@0
   469
	TInt error;
sl@0
   470
sl@0
   471
	while(!finished)
sl@0
   472
		{
sl@0
   473
		error = KErrNone;
sl@0
   474
sl@0
   475
        if(failCount == 8)
sl@0
   476
            {
sl@0
   477
            aClient.DeleteEventType(KTestEventUid, active->iStatus);
sl@0
   478
            active->StartL();
sl@0
   479
            CActiveScheduler::Start();
sl@0
   480
            TEST2(active->iStatus.Int(), KErrNone);
sl@0
   481
            finished = ETrue;
sl@0
   482
            continue;
sl@0
   483
            }
sl@0
   484
		
sl@0
   485
		TheTest.Printf(_L("%d  \r"), failCount);
sl@0
   486
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
   487
sl@0
   488
		aClient.DeleteEventType(KTestEventUid, active->iStatus);
sl@0
   489
sl@0
   490
		active->StartL();
sl@0
   491
		CActiveScheduler::Start();
sl@0
   492
sl@0
   493
		if (active->iStatus == KErrNone)
sl@0
   494
			finished = ETrue;
sl@0
   495
		else
sl@0
   496
			error = active->iStatus.Int();
sl@0
   497
sl@0
   498
		__FILE_RESET;
sl@0
   499
sl@0
   500
		if (error == KErrNoMemory)
sl@0
   501
			{
sl@0
   502
			active->StartL();
sl@0
   503
			aClient.GetEventType(*type, active->iStatus);
sl@0
   504
			CActiveScheduler::Start();
sl@0
   505
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
   506
			}
sl@0
   507
		else
sl@0
   508
			TEST2(error, KErrNone);
sl@0
   509
		}
sl@0
   510
sl@0
   511
	active->StartL();
sl@0
   512
	aClient.GetEventType(*type, active->iStatus);
sl@0
   513
	CActiveScheduler::Start();
sl@0
   514
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
   515
sl@0
   516
	CleanupStack::PopAndDestroy(2); // type, active
sl@0
   517
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
   518
	}
sl@0
   519
sl@0
   520
/**
sl@0
   521
@SYMTestCaseID          SYSLIB-LOGENG-CT-0916
sl@0
   522
@SYMTestCaseDesc	    Adding an event test,
sl@0
   523
                        Tests for CLogClient::AddEvent() function
sl@0
   524
@SYMTestPriority 	    High
sl@0
   525
@SYMTestActions  	    Check for file failure errors while adding event
sl@0
   526
                        Tests for no error conditons,and the event information 
sl@0
   527
@SYMTestExpectedResults Test must not fail
sl@0
   528
@SYMREQ                 REQ0000
sl@0
   529
*/
sl@0
   530
LOCAL_C void TestAddEventL(CLogClient& aClient)
sl@0
   531
	{
sl@0
   532
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0916 "));
sl@0
   533
	// Ensure we always start from the same state
sl@0
   534
    TestUtils::DeleteDatabaseL();
sl@0
   535
sl@0
   536
	CLogEventType* type = CLogEventType::NewL();
sl@0
   537
	CleanupStack::PushL(type);
sl@0
   538
sl@0
   539
	type->SetUid(KTestEventUid);
sl@0
   540
	type->SetDescription(KTestEventDesc1);
sl@0
   541
	type->SetLoggingEnabled(ETrue);
sl@0
   542
sl@0
   543
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   544
	CleanupStack::PushL(active);
sl@0
   545
sl@0
   546
	active->StartL();
sl@0
   547
	aClient.AddEventType(*type, active->iStatus);
sl@0
   548
	CActiveScheduler::Start();
sl@0
   549
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   550
sl@0
   551
	CLogEvent* event = CLogEvent::NewL();
sl@0
   552
	CleanupStack::PushL(event);
sl@0
   553
sl@0
   554
	TTime now;
sl@0
   555
	now.UniversalTime();
sl@0
   556
sl@0
   557
	event->SetEventType(KTestEventUid);
sl@0
   558
	event->SetRemoteParty(KTestRemoteParty1);
sl@0
   559
	event->SetDirection(KTestDirection1);
sl@0
   560
	event->SetDurationType(KTestDurationType1);
sl@0
   561
	event->SetDuration(KTestDuration1);
sl@0
   562
	event->SetStatus(KTestStatus1);
sl@0
   563
	event->SetSubject(KTestSubject1);
sl@0
   564
	event->SetNumber(KTestNumber1);
sl@0
   565
	event->SetContact(KTestContact1);
sl@0
   566
	event->SetLink(KTestLink1);
sl@0
   567
	event->SetDataL(KTestData1);
sl@0
   568
sl@0
   569
	TInt failCount = 0;
sl@0
   570
	TBool finished = EFalse;
sl@0
   571
	TInt error;
sl@0
   572
sl@0
   573
	while(!finished)
sl@0
   574
		{
sl@0
   575
		error = KErrNone;
sl@0
   576
sl@0
   577
        if(failCount == 8)
sl@0
   578
            {
sl@0
   579
            aClient.AddEvent(*event, active->iStatus);
sl@0
   580
            active->StartL();
sl@0
   581
            CActiveScheduler::Start();
sl@0
   582
            TEST2(active->iStatus.Int(), KErrNone);
sl@0
   583
            finished = ETrue;
sl@0
   584
            continue;
sl@0
   585
            }
sl@0
   586
sl@0
   587
		TheTest.Printf(_L("%d  \r"), failCount);
sl@0
   588
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
   589
		aClient.AddEvent(*event, active->iStatus);
sl@0
   590
sl@0
   591
		active->StartL();
sl@0
   592
		CActiveScheduler::Start();
sl@0
   593
sl@0
   594
		if (active->iStatus == KErrNone)
sl@0
   595
			finished = ETrue;
sl@0
   596
		else
sl@0
   597
			error = active->iStatus.Int();
sl@0
   598
sl@0
   599
		__FILE_RESET;
sl@0
   600
sl@0
   601
		if (error == KErrNoMemory)
sl@0
   602
			{
sl@0
   603
			event->SetId(0);
sl@0
   604
sl@0
   605
			active->StartL();
sl@0
   606
			aClient.GetEvent(*event, active->iStatus);
sl@0
   607
			CActiveScheduler::Start();
sl@0
   608
			TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
   609
sl@0
   610
			event->SetId(KLogNullId);
sl@0
   611
			}
sl@0
   612
		else
sl@0
   613
			TEST2(error, KErrNone);
sl@0
   614
		}
sl@0
   615
sl@0
   616
	TEST(event->Id() == 0);
sl@0
   617
	TEST(event->Time() >= now);
sl@0
   618
	TEST(event->Description() == KTestEventDesc1);
sl@0
   619
sl@0
   620
	active->StartL();
sl@0
   621
	aClient.GetEvent(*event, active->iStatus);
sl@0
   622
	CActiveScheduler::Start();
sl@0
   623
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   624
sl@0
   625
	CleanupStack::PopAndDestroy(3); // event, active, type
sl@0
   626
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
   627
	}
sl@0
   628
sl@0
   629
/**
sl@0
   630
@SYMTestCaseID          SYSLIB-LOGENG-CT-0917
sl@0
   631
@SYMTestCaseDesc	    Get an events' information test
sl@0
   632
                        Tests for CLogClient::GetEvent() function
sl@0
   633
@SYMTestPriority 	    High
sl@0
   634
@SYMTestActions  	    Check for file failure errors while getting an event
sl@0
   635
                        Tests for no error conditons,and the event information. 
sl@0
   636
@SYMTestExpectedResults Test must not fail
sl@0
   637
@SYMREQ                 REQ0000
sl@0
   638
*/
sl@0
   639
LOCAL_C void TestGetEventL(CLogClient& aClient)
sl@0
   640
	{
sl@0
   641
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0917 "));
sl@0
   642
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   643
	CleanupStack::PushL(active);
sl@0
   644
sl@0
   645
	CLogEvent* event = CLogEvent::NewL();
sl@0
   646
	CleanupStack::PushL(event);
sl@0
   647
sl@0
   648
	event->SetId(0);
sl@0
   649
sl@0
   650
	TInt failCount = 0;
sl@0
   651
	TBool finished = EFalse;
sl@0
   652
sl@0
   653
	while(!finished)
sl@0
   654
		{
sl@0
   655
		TheTest.Printf(_L("%d  \r"), failCount);
sl@0
   656
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
   657
		aClient.GetEvent(*event, active->iStatus);
sl@0
   658
sl@0
   659
		active->StartL();
sl@0
   660
		CActiveScheduler::Start();
sl@0
   661
sl@0
   662
		if (active->iStatus == KErrNone)
sl@0
   663
			finished = ETrue;
sl@0
   664
		else
sl@0
   665
			TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   666
sl@0
   667
		__FILE_RESET;
sl@0
   668
		}
sl@0
   669
sl@0
   670
	TEST(event->Id() == 0);
sl@0
   671
	TEST(event->Time() > TTime(0));
sl@0
   672
	TEST(event->Description() == KTestEventDesc1);
sl@0
   673
	TEST(event->EventType() == KTestEventUid);
sl@0
   674
	TEST(event->RemoteParty() == KTestRemoteParty1);
sl@0
   675
	TEST(event->Direction() == KTestDirection1);
sl@0
   676
	TEST(event->DurationType() == KTestDurationType1);
sl@0
   677
	TEST(event->Duration() == KTestDuration1);
sl@0
   678
	TEST(event->Status() == KTestStatus1);
sl@0
   679
	TEST(event->Subject() == KTestSubject1);
sl@0
   680
	TEST(event->Number() == KTestNumber1);
sl@0
   681
	TEST(event->Contact() == KTestContact1);
sl@0
   682
	TEST(event->Link() == KTestLink1);
sl@0
   683
	TEST(event->Data() == KTestData1);
sl@0
   684
sl@0
   685
	CleanupStack::PopAndDestroy(2); // event, active
sl@0
   686
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
   687
	}
sl@0
   688
sl@0
   689
/**
sl@0
   690
@SYMTestCaseID          SYSLIB-LOGENG-CT-0918
sl@0
   691
@SYMTestCaseDesc	    Changing an event type test
sl@0
   692
                        Tests for CLogClient::ChangeEvent() function
sl@0
   693
@SYMTestPriority 	    High
sl@0
   694
@SYMTestActions  	    Check for file failure errors while changing an event
sl@0
   695
                        Tests for no error conditons,and the event information for the changed event
sl@0
   696
@SYMTestExpectedResults Test must not fail
sl@0
   697
@SYMREQ                 REQ0000
sl@0
   698
*/
sl@0
   699
LOCAL_C void TestChangeEventL(CLogClient& aClient)
sl@0
   700
	{
sl@0
   701
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0918 "));
sl@0
   702
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   703
	CleanupStack::PushL(active);
sl@0
   704
sl@0
   705
	CLogEvent* event = CLogEvent::NewL();
sl@0
   706
	CleanupStack::PushL(event);
sl@0
   707
sl@0
   708
	TTime now;
sl@0
   709
	now.UniversalTime();
sl@0
   710
sl@0
   711
	TInt failCount = 0;
sl@0
   712
	TBool finished = EFalse;
sl@0
   713
	TInt error;
sl@0
   714
sl@0
   715
	while(!finished)
sl@0
   716
		{
sl@0
   717
		error = KErrNone;
sl@0
   718
sl@0
   719
		event->SetId(0);
sl@0
   720
		event->SetTime(now);
sl@0
   721
		event->SetRemoteParty(KTestRemoteParty2);
sl@0
   722
		event->SetDirection(KTestDirection2);
sl@0
   723
		event->SetDurationType(KTestDurationType2);
sl@0
   724
		event->SetDuration(KTestDuration2);
sl@0
   725
		event->SetStatus(KTestStatus2);
sl@0
   726
		event->SetSubject(KTestSubject2);
sl@0
   727
		event->SetNumber(KTestNumber2);
sl@0
   728
		event->SetContact(KTestContact2);
sl@0
   729
		event->SetLink(KTestLink2);
sl@0
   730
		event->SetDataL(KTestData2);
sl@0
   731
sl@0
   732
        if(failCount == 14)
sl@0
   733
            {
sl@0
   734
            aClient.ChangeEvent(*event, active->iStatus);
sl@0
   735
            active->StartL();
sl@0
   736
            CActiveScheduler::Start();
sl@0
   737
            TEST2(active->iStatus.Int(), KErrNone);
sl@0
   738
            finished = ETrue;
sl@0
   739
            continue;
sl@0
   740
            }
sl@0
   741
		
sl@0
   742
		TheTest.Printf(_L("%d  \r"), failCount);
sl@0
   743
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
   744
sl@0
   745
		aClient.ChangeEvent(*event, active->iStatus);
sl@0
   746
sl@0
   747
		active->StartL();
sl@0
   748
		CActiveScheduler::Start();
sl@0
   749
		if (active->iStatus == KErrNone)
sl@0
   750
			finished = ETrue;
sl@0
   751
		else
sl@0
   752
			error = active->iStatus.Int();
sl@0
   753
sl@0
   754
		__FILE_RESET;
sl@0
   755
sl@0
   756
		if (error == KErrNoMemory)
sl@0
   757
			{
sl@0
   758
			active->StartL();
sl@0
   759
			aClient.GetEvent(*event, active->iStatus);
sl@0
   760
			CActiveScheduler::Start();
sl@0
   761
			if (active->iStatus != KErrNone) 
sl@0
   762
			    TheTest.Printf(_L("\nerror code:%d failcount:%d\n"),active->iStatus.Int(),failCount);
sl@0
   763
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
   764
sl@0
   765
			TEST(event->Id() == 0);
sl@0
   766
			TEST(event->Time() > TTime(0));
sl@0
   767
			TEST(event->Description() == KTestEventDesc1);
sl@0
   768
			TEST(event->EventType() == KTestEventUid);
sl@0
   769
			TEST(event->RemoteParty() == KTestRemoteParty1);
sl@0
   770
			TEST(event->Direction() == KTestDirection1);
sl@0
   771
			TEST(event->DurationType() == KTestDurationType1);
sl@0
   772
			TEST(event->Duration() == KTestDuration1);
sl@0
   773
			TEST(event->Status() == KTestStatus1);
sl@0
   774
			TEST(event->Subject() == KTestSubject1);
sl@0
   775
			TEST(event->Number() == KTestNumber1);
sl@0
   776
			TEST(event->Contact() == KTestContact1);
sl@0
   777
			TEST(event->Link() == KTestLink1);
sl@0
   778
			TEST(event->Data() == KTestData1);
sl@0
   779
			}
sl@0
   780
		else
sl@0
   781
			TEST2(error, KErrNone);
sl@0
   782
		}
sl@0
   783
sl@0
   784
	active->StartL();
sl@0
   785
	aClient.GetEvent(*event, active->iStatus);
sl@0
   786
	CActiveScheduler::Start();
sl@0
   787
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   788
sl@0
   789
	TEST(event->Id() == 0);
sl@0
   790
	TEST(event->Time() == now);
sl@0
   791
	TEST(event->Description() == KTestEventDesc1);
sl@0
   792
	TEST(event->EventType() == KTestEventUid);
sl@0
   793
	TEST(event->RemoteParty() == KTestRemoteParty2);
sl@0
   794
	TEST(event->Direction() == KTestDirection2);
sl@0
   795
	TEST(event->DurationType() == KTestDurationType2);
sl@0
   796
	TEST(event->Duration() == KTestDuration2);
sl@0
   797
	TEST(event->Status() == KTestStatus2);
sl@0
   798
	TEST(event->Subject() == KTestSubject2);
sl@0
   799
	TEST(event->Number() == KTestNumber2);
sl@0
   800
	TEST(event->Contact() == KTestContact2);
sl@0
   801
	TEST(event->Link() == KTestLink2);
sl@0
   802
	TEST(event->Data() == KTestData2);
sl@0
   803
sl@0
   804
	CleanupStack::PopAndDestroy(2); // event, active
sl@0
   805
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
   806
	}
sl@0
   807
sl@0
   808
/**
sl@0
   809
@SYMTestCaseID          SYSLIB-LOGENG-CT-0919
sl@0
   810
@SYMTestCaseDesc	    Deleting an event test,
sl@0
   811
                        Tests for CLogClient::DeleteEvent() function
sl@0
   812
@SYMTestPriority 	    High
sl@0
   813
@SYMTestActions  	    Check for file failure errors while deleting an event
sl@0
   814
                        Tests for ErrNone flag.
sl@0
   815
@SYMTestExpectedResults Test must not fail
sl@0
   816
@SYMREQ                 REQ0000
sl@0
   817
*/
sl@0
   818
LOCAL_C void TestDeleteEventL(CLogClient& aClient)
sl@0
   819
	{
sl@0
   820
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0919 "));
sl@0
   821
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   822
	CleanupStack::PushL(active);
sl@0
   823
sl@0
   824
	CLogEvent* event = CLogEvent::NewL();
sl@0
   825
	CleanupStack::PushL(event);
sl@0
   826
sl@0
   827
	event->SetId(0);
sl@0
   828
sl@0
   829
	TInt failCount = 0;
sl@0
   830
	TBool finished = EFalse;
sl@0
   831
	TInt error;
sl@0
   832
sl@0
   833
	while(!finished)
sl@0
   834
		{
sl@0
   835
		error = KErrNone;
sl@0
   836
sl@0
   837
        if(failCount == 10)
sl@0
   838
            {
sl@0
   839
            aClient.DeleteEvent(0, active->iStatus);
sl@0
   840
            active->StartL();
sl@0
   841
            CActiveScheduler::Start();
sl@0
   842
            TEST2(active->iStatus.Int(), KErrNone);
sl@0
   843
            finished = ETrue;
sl@0
   844
            continue;
sl@0
   845
            }
sl@0
   846
		
sl@0
   847
		TheTest.Printf(_L("%d  \r"), failCount);
sl@0
   848
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
   849
sl@0
   850
		aClient.DeleteEvent(0, active->iStatus);
sl@0
   851
sl@0
   852
		active->StartL();
sl@0
   853
		CActiveScheduler::Start();
sl@0
   854
sl@0
   855
		if (active->iStatus == KErrNone)
sl@0
   856
			finished = ETrue;
sl@0
   857
		else
sl@0
   858
			error = active->iStatus.Int();
sl@0
   859
sl@0
   860
		__FILE_RESET;
sl@0
   861
sl@0
   862
		if (error == KErrNoMemory)
sl@0
   863
			{
sl@0
   864
			active->StartL();
sl@0
   865
			aClient.GetEvent(*event, active->iStatus);
sl@0
   866
			CActiveScheduler::Start();
sl@0
   867
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
   868
			}
sl@0
   869
		else
sl@0
   870
			TEST2(error, KErrNone);
sl@0
   871
		}
sl@0
   872
sl@0
   873
	active->StartL();
sl@0
   874
	aClient.GetEvent(*event, active->iStatus);
sl@0
   875
	CActiveScheduler::Start();
sl@0
   876
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
   877
sl@0
   878
	CleanupStack::PopAndDestroy(2); // event, active
sl@0
   879
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
   880
	}
sl@0
   881
sl@0
   882
/**
sl@0
   883
@SYMTestCaseID          SYSLIB-LOGENG-CT-0920
sl@0
   884
@SYMTestCaseDesc	    Getting the Log Engine configuration information test
sl@0
   885
                        Tests for CLogClient::GetConfig() function
sl@0
   886
@SYMTestPriority 	    High
sl@0
   887
@SYMTestActions  	    Check for file failure errors while getting the configuration data
sl@0
   888
                        Tests for ErrNone flag.Tests for the retrieved information
sl@0
   889
@SYMTestExpectedResults Test must not fail
sl@0
   890
@SYMREQ                 REQ0000
sl@0
   891
*/
sl@0
   892
LOCAL_C void TestGetConfigL(CLogClient& aClient)
sl@0
   893
	{
sl@0
   894
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0920 "));
sl@0
   895
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   896
	CleanupStack::PushL(active);
sl@0
   897
sl@0
   898
	TLogConfig config;
sl@0
   899
sl@0
   900
	TEST(config.iMaxEventAge == 0);
sl@0
   901
	TEST(config.iMaxLogSize == 0);
sl@0
   902
	TEST(config.iMaxRecentLogSize == 0);
sl@0
   903
sl@0
   904
	TInt failCount = 0;
sl@0
   905
	TBool finished = EFalse;
sl@0
   906
sl@0
   907
	while(!finished)
sl@0
   908
		{
sl@0
   909
		TheTest.Printf(_L("%d  \r"), failCount);
sl@0
   910
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
   911
		aClient.GetConfig(config, active->iStatus);
sl@0
   912
sl@0
   913
		active->StartL();
sl@0
   914
		CActiveScheduler::Start();
sl@0
   915
sl@0
   916
		if (active->iStatus == KErrNone)
sl@0
   917
			finished = ETrue;
sl@0
   918
		else
sl@0
   919
			TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
   920
sl@0
   921
		__FILE_RESET;
sl@0
   922
		}
sl@0
   923
sl@0
   924
	TEST(config.iMaxEventAge > 0);
sl@0
   925
	TEST(config.iMaxLogSize > 0);
sl@0
   926
	TEST(config.iMaxRecentLogSize > 0);
sl@0
   927
sl@0
   928
	CleanupStack::PopAndDestroy(); // active
sl@0
   929
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
   930
	}
sl@0
   931
sl@0
   932
/**
sl@0
   933
@SYMTestCaseID          SYSLIB-LOGENG-CT-0921
sl@0
   934
@SYMTestCaseDesc	    Changing the configuration of Log Engine test,
sl@0
   935
                        Tests for CLogClient::ChangeConfig() function
sl@0
   936
@SYMTestPriority 	    High
sl@0
   937
@SYMTestActions  	    Check for file failure errors while changing the log engine configuration data
sl@0
   938
                        Tests for ErrNone error conditons.Tests for the changed configuration data
sl@0
   939
@SYMTestExpectedResults Test must not fail
sl@0
   940
@SYMREQ                 REQ0000
sl@0
   941
*/
sl@0
   942
LOCAL_C void TestChangeConfigL(CLogClient& aClient)
sl@0
   943
	{
sl@0
   944
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0921 "));
sl@0
   945
	CTestActive* active = new(ELeave)CTestActive();
sl@0
   946
	CleanupStack::PushL(active);
sl@0
   947
sl@0
   948
	TLogConfig configOld;
sl@0
   949
sl@0
   950
	active->StartL();
sl@0
   951
	aClient.GetConfig(configOld, active->iStatus);
sl@0
   952
	CActiveScheduler::Start();
sl@0
   953
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
   954
sl@0
   955
	TLogConfig config;
sl@0
   956
sl@0
   957
	TInt failCount = 0;
sl@0
   958
	TBool finished = EFalse;
sl@0
   959
	TInt error;
sl@0
   960
sl@0
   961
	while(!finished)
sl@0
   962
		{
sl@0
   963
		error = KErrNone;
sl@0
   964
sl@0
   965
		config.iMaxLogSize = KTestMaxLogSize;
sl@0
   966
		config.iMaxRecentLogSize = KTestMaxRecentLogSize;
sl@0
   967
		config.iMaxEventAge = KTestMaxEventAge;
sl@0
   968
sl@0
   969
        if(failCount == 11)
sl@0
   970
            {
sl@0
   971
            aClient.ChangeConfig(config, active->iStatus);
sl@0
   972
            active->StartL();
sl@0
   973
            CActiveScheduler::Start();
sl@0
   974
            TEST2(active->iStatus.Int(), KErrNone);
sl@0
   975
            finished = ETrue;
sl@0
   976
            continue;
sl@0
   977
            }
sl@0
   978
		
sl@0
   979
		TheTest.Printf(_L("%d  \r"), failCount);
sl@0
   980
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
   981
sl@0
   982
		aClient.ChangeConfig(config, active->iStatus);
sl@0
   983
sl@0
   984
		active->StartL();
sl@0
   985
		CActiveScheduler::Start();
sl@0
   986
sl@0
   987
		if (active->iStatus == KErrNone)
sl@0
   988
			finished = ETrue;
sl@0
   989
		else
sl@0
   990
			error = active->iStatus.Int();
sl@0
   991
		
sl@0
   992
		__FILE_RESET;
sl@0
   993
sl@0
   994
		if (error == KErrNoMemory)
sl@0
   995
			{
sl@0
   996
			active->StartL();
sl@0
   997
			aClient.GetConfig(config, active->iStatus);
sl@0
   998
			CActiveScheduler::Start();
sl@0
   999
			TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1000
sl@0
  1001
			TEST(config.iMaxLogSize == configOld.iMaxLogSize);
sl@0
  1002
			TEST(config.iMaxRecentLogSize == configOld.iMaxRecentLogSize);
sl@0
  1003
			TEST(config.iMaxEventAge == configOld.iMaxEventAge);
sl@0
  1004
			}
sl@0
  1005
		else
sl@0
  1006
			TEST2(error, KErrNone);		
sl@0
  1007
		}
sl@0
  1008
sl@0
  1009
	TEST(config.iMaxLogSize == KTestMaxLogSize);
sl@0
  1010
	TEST(config.iMaxRecentLogSize == KTestMaxRecentLogSize);
sl@0
  1011
	TEST(config.iMaxEventAge == KTestMaxEventAge);
sl@0
  1012
sl@0
  1013
	CleanupStack::PopAndDestroy(); // active
sl@0
  1014
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
  1015
	}
sl@0
  1016
sl@0
  1017
/**
sl@0
  1018
@SYMTestCaseID          SYSLIB-LOGENG-CT-0922
sl@0
  1019
@SYMTestCaseDesc	    Getting a standard string from the specified resource file test
sl@0
  1020
                        Tests for CLogClient::GetString() function
sl@0
  1021
@SYMTestPriority 	    High
sl@0
  1022
@SYMTestActions  	    Check for file failure errors while changing the log engine configuration data
sl@0
  1023
                        Check for ErrNone flag.Tests for general errors,and retrieved string length. 
sl@0
  1024
@SYMTestExpectedResults Test must not fail
sl@0
  1025
@SYMREQ                 REQ0000
sl@0
  1026
*/
sl@0
  1027
LOCAL_C void TestGetStringL(CLogClient& aClient)
sl@0
  1028
	{
sl@0
  1029
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0922 "));
sl@0
  1030
	TBuf<KLogMaxSharedStringLength> str;
sl@0
  1031
	
sl@0
  1032
	TInt failCount = 0;
sl@0
  1033
	TBool finished = EFalse;
sl@0
  1034
	TInt error;
sl@0
  1035
sl@0
  1036
	while(!finished)
sl@0
  1037
		{
sl@0
  1038
		TheTest.Printf(_L("%d  \r"), failCount);
sl@0
  1039
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
  1040
sl@0
  1041
		error = aClient.GetString(str, R_LOG_DIR_IN);
sl@0
  1042
sl@0
  1043
		__FILE_RESET;
sl@0
  1044
sl@0
  1045
		if (error == KErrNone)
sl@0
  1046
			{
sl@0
  1047
			finished = ETrue;
sl@0
  1048
			TEST(str.Length() > 0);
sl@0
  1049
			}
sl@0
  1050
		else
sl@0
  1051
			{
sl@0
  1052
			TEST2(error, KErrNoMemory);
sl@0
  1053
			TEST(str.Length() == 0);
sl@0
  1054
			}
sl@0
  1055
		}
sl@0
  1056
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
  1057
	}
sl@0
  1058
sl@0
  1059
/**
sl@0
  1060
@SYMTestCaseID          SYSLIB-LOGENG-CT-0923
sl@0
  1061
@SYMTestCaseDesc	    Clearing the Log Event test.
sl@0
  1062
                        Tests for CLogClient::ClearLog() function
sl@0
  1063
@SYMTestPriority 	    High
sl@0
  1064
@SYMTestActions  	    Add 4 events to the event log,check for ErrNone flag
sl@0
  1065
                        Clear the log by calling CLogClient::ClearLog() function.
sl@0
  1066
						Try for getting the added 4 events.Check for not found error.
sl@0
  1067
@SYMTestExpectedResults Test must not fail
sl@0
  1068
@SYMREQ                 REQ12748
sl@0
  1069
*/
sl@0
  1070
LOCAL_C void TestClearEventLogL(CLogClient& aClient
sl@0
  1071
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
  1072
		, TBool aUseSimId = EFalse
sl@0
  1073
#endif		
sl@0
  1074
		)
sl@0
  1075
	{
sl@0
  1076
	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0923 "));
sl@0
  1077
	TTime now;
sl@0
  1078
	now.UniversalTime();
sl@0
  1079
	
sl@0
  1080
	TDateTime dt(now.DateTime());
sl@0
  1081
	dt.SetYear(dt.Year() - 1);
sl@0
  1082
	TTime date1(dt);
sl@0
  1083
sl@0
  1084
	dt.SetYear(dt.Year() - 1);
sl@0
  1085
	TTime date2(dt);
sl@0
  1086
sl@0
  1087
	CTestActive* active = new(ELeave)CTestActive();
sl@0
  1088
	CleanupStack::PushL(active);
sl@0
  1089
sl@0
  1090
	CLogEvent* event1 = CLogEvent::NewL();
sl@0
  1091
	CleanupStack::PushL(event1);
sl@0
  1092
	event1->SetEventType(KTestEventUid);
sl@0
  1093
sl@0
  1094
	active->StartL();
sl@0
  1095
	aClient.AddEvent(*event1, active->iStatus);
sl@0
  1096
	CActiveScheduler::Start();
sl@0
  1097
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1098
sl@0
  1099
	event1->SetTime(date1);
sl@0
  1100
sl@0
  1101
	active->StartL();
sl@0
  1102
	aClient.ChangeEvent(*event1, active->iStatus);
sl@0
  1103
	CActiveScheduler::Start();
sl@0
  1104
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1105
sl@0
  1106
	CLogEvent* event2 = CLogEvent::NewL();
sl@0
  1107
	CleanupStack::PushL(event2);
sl@0
  1108
	event2->SetEventType(KTestEventUid);
sl@0
  1109
sl@0
  1110
	active->StartL();
sl@0
  1111
	aClient.AddEvent(*event2, active->iStatus);
sl@0
  1112
	CActiveScheduler::Start();
sl@0
  1113
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1114
sl@0
  1115
	event2->SetTime(date1);
sl@0
  1116
sl@0
  1117
	active->StartL();
sl@0
  1118
	aClient.ChangeEvent(*event2, active->iStatus);
sl@0
  1119
	CActiveScheduler::Start();
sl@0
  1120
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1121
sl@0
  1122
	CLogEvent* event3 = CLogEvent::NewL();
sl@0
  1123
	CleanupStack::PushL(event3);
sl@0
  1124
	event3->SetEventType(KTestEventUid);
sl@0
  1125
sl@0
  1126
	active->StartL();
sl@0
  1127
	aClient.AddEvent(*event3, active->iStatus);
sl@0
  1128
	CActiveScheduler::Start();
sl@0
  1129
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1130
sl@0
  1131
	event3->SetTime(date2);
sl@0
  1132
sl@0
  1133
	active->StartL();
sl@0
  1134
	aClient.ChangeEvent(*event3, active->iStatus);
sl@0
  1135
	CActiveScheduler::Start();
sl@0
  1136
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1137
sl@0
  1138
	CLogEvent* event4 = CLogEvent::NewL();
sl@0
  1139
	CleanupStack::PushL(event4);
sl@0
  1140
	event4->SetEventType(KTestEventUid);
sl@0
  1141
sl@0
  1142
	active->StartL();
sl@0
  1143
	aClient.AddEvent(*event4, active->iStatus);
sl@0
  1144
	CActiveScheduler::Start();
sl@0
  1145
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1146
sl@0
  1147
	event4->SetTime(date2);
sl@0
  1148
sl@0
  1149
	active->StartL();
sl@0
  1150
	aClient.ChangeEvent(*event4, active->iStatus);
sl@0
  1151
	CActiveScheduler::Start();
sl@0
  1152
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1153
sl@0
  1154
	TInt failCount = 0;
sl@0
  1155
	TBool finished = EFalse;
sl@0
  1156
sl@0
  1157
	while(!finished)
sl@0
  1158
		{
sl@0
  1159
		TheTest.Printf(_L("%d  \r"), failCount);
sl@0
  1160
		__FILE_FAILNEXT(KErrNoMemory, failCount++);
sl@0
  1161
sl@0
  1162
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
  1163
		if(aUseSimId)
sl@0
  1164
			{
sl@0
  1165
			aClient.ClearLog(date1, KLogNullSimId, active->iStatus);
sl@0
  1166
			}
sl@0
  1167
		else
sl@0
  1168
#endif			
sl@0
  1169
			{
sl@0
  1170
			aClient.ClearLog(date1, active->iStatus);
sl@0
  1171
			}
sl@0
  1172
sl@0
  1173
		__FILE_RESET;
sl@0
  1174
sl@0
  1175
		active->StartL();	
sl@0
  1176
		CActiveScheduler::Start();
sl@0
  1177
sl@0
  1178
		if (active->iStatus == KErrNone)
sl@0
  1179
			finished = ETrue;
sl@0
  1180
		else
sl@0
  1181
			TEST2(active->iStatus.Int(), KErrNoMemory);
sl@0
  1182
		}
sl@0
  1183
sl@0
  1184
	active->StartL();
sl@0
  1185
	aClient.GetEvent(*event1, active->iStatus);
sl@0
  1186
	CActiveScheduler::Start();
sl@0
  1187
	if (active->iStatus != KErrNone) 
sl@0
  1188
	    TheTest.Printf(_L("error code:%d\n"),active->iStatus.Int());
sl@0
  1189
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1190
sl@0
  1191
	active->StartL();
sl@0
  1192
	aClient.GetEvent(*event2, active->iStatus);
sl@0
  1193
	CActiveScheduler::Start();
sl@0
  1194
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1195
sl@0
  1196
	active->StartL();
sl@0
  1197
	aClient.GetEvent(*event3, active->iStatus);
sl@0
  1198
	CActiveScheduler::Start();
sl@0
  1199
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1200
sl@0
  1201
	active->StartL();
sl@0
  1202
	aClient.GetEvent(*event4, active->iStatus);
sl@0
  1203
	CActiveScheduler::Start();
sl@0
  1204
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1205
sl@0
  1206
	active->StartL();
sl@0
  1207
	aClient.ClearLog(now, active->iStatus);
sl@0
  1208
	CActiveScheduler::Start();
sl@0
  1209
	TEST2(active->iStatus.Int(), KErrNone);
sl@0
  1210
sl@0
  1211
	active->StartL();
sl@0
  1212
	aClient.GetEvent(*event1, active->iStatus);
sl@0
  1213
	CActiveScheduler::Start();
sl@0
  1214
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1215
sl@0
  1216
	active->StartL();
sl@0
  1217
	aClient.GetEvent(*event2, active->iStatus);
sl@0
  1218
	CActiveScheduler::Start();
sl@0
  1219
	TEST2(active->iStatus.Int(), KErrNotFound);
sl@0
  1220
sl@0
  1221
	CleanupStack::PopAndDestroy(5); // event4, event3, event2, event1, active
sl@0
  1222
	TheTest.Printf(_L("\r\nThe test has succeeded at iteration %d\n"), failCount);
sl@0
  1223
	}
sl@0
  1224
sl@0
  1225
void doTestsL()
sl@0
  1226
	{
sl@0
  1227
	TestUtils::Initialize(_L("t_logfile"));
sl@0
  1228
sl@0
  1229
    TheTest.Start(_L("Construction + create db"));
sl@0
  1230
	TestUtils::DeleteDatabaseL();
sl@0
  1231
	TestConstructionL(); // Creates database
sl@0
  1232
	TheTest.Next(_L("Construction + open db"));
sl@0
  1233
	TestConstructionL(); // Opens existing database
sl@0
  1234
	TestUtils::DeleteDatabaseL();
sl@0
  1235
	theLog.Write(_L8("Test 1 OK\n"));
sl@0
  1236
sl@0
  1237
	CLogClient* client = CLogClient::NewL(theFs);
sl@0
  1238
	CleanupStack::PushL(client);
sl@0
  1239
sl@0
  1240
	TheTest.Next(_L("Add Event Type"));
sl@0
  1241
	TestAddEventTypeL(*client);
sl@0
  1242
	theLog.Write(_L8("Test 2 OK\n"));
sl@0
  1243
sl@0
  1244
	TheTest.Next(_L("Get Event Type"));
sl@0
  1245
	TestGetEventTypeL(*client);
sl@0
  1246
	theLog.Write(_L8("Test 3 OK\n"));
sl@0
  1247
sl@0
  1248
	TheTest.Next(_L("Change Event Type"));
sl@0
  1249
	TestChangeEventTypeL(*client);
sl@0
  1250
	theLog.Write(_L8("Test 4 OK\n"));
sl@0
  1251
sl@0
  1252
	TheTest.Next(_L("Delete Event Type"));
sl@0
  1253
	TestDeleteEventTypeL(*client);
sl@0
  1254
	theLog.Write(_L8("Test 5 OK\n"));
sl@0
  1255
sl@0
  1256
	TestUtils::DeleteDatabaseL();
sl@0
  1257
sl@0
  1258
	TheTest.Next(_L("Add Event"));
sl@0
  1259
	TestAddEventL(*client);
sl@0
  1260
	theLog.Write(_L8("Test 6 OK\n"));
sl@0
  1261
sl@0
  1262
	TheTest.Next(_L("Get Event"));
sl@0
  1263
	TestGetEventL(*client);
sl@0
  1264
	theLog.Write(_L8("Test 7 OK\n"));
sl@0
  1265
sl@0
  1266
	TheTest.Next(_L("Change Event"));
sl@0
  1267
	TestChangeEventL(*client);
sl@0
  1268
	theLog.Write(_L8("Test 8 OK\n"));
sl@0
  1269
sl@0
  1270
	TheTest.Next(_L("Delete Event"));
sl@0
  1271
	TestDeleteEventL(*client);
sl@0
  1272
	theLog.Write(_L8("Test 9 OK\n"));
sl@0
  1273
sl@0
  1274
	TheTest.Next(_L("Get Config"));
sl@0
  1275
	TestGetConfigL(*client);
sl@0
  1276
	theLog.Write(_L8("Test 10 OK\n"));
sl@0
  1277
sl@0
  1278
	TheTest.Next(_L("Change Config"));
sl@0
  1279
	TestChangeConfigL(*client);
sl@0
  1280
	theLog.Write(_L8("Test 11 OK\n"));
sl@0
  1281
sl@0
  1282
	TheTest.Next(_L("Get String"));
sl@0
  1283
	TestGetStringL(*client);
sl@0
  1284
	theLog.Write(_L8("Test 12 OK\n"));
sl@0
  1285
sl@0
  1286
	TheTest.Next(_L("Clear Event Log"));
sl@0
  1287
	TestClearEventLogL(*client);
sl@0
  1288
	theLog.Write(_L8("Test 13 OK\n"));
sl@0
  1289
sl@0
  1290
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
  1291
	TheTest.Next(_L("Clear Event Log + SimId"));
sl@0
  1292
	TestClearEventLogL(*client, ETrue);
sl@0
  1293
	theLog.Write(_L8("Test 14 OK\n"));
sl@0
  1294
#endif	
sl@0
  1295
sl@0
  1296
	CleanupStack::PopAndDestroy(); // client
sl@0
  1297
	}