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