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