sl@0: // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_logutil2.h" sl@0: #include "t_logutil3.h" sl@0: sl@0: #define UNUSED_VAR(a) a = a sl@0: sl@0: const TLogContactItemId KTestContact = 0x1234; sl@0: const TInt KTestEventNum = 10; sl@0: sl@0: RTest TheTest(_L("t_logapi")); sl@0: sl@0: const TUid KTestEventUid = {0x10005393}; sl@0: _LIT(KTestEventDesc1, "Event Type Description"); sl@0: _LIT(KTestEventDesc2, "Changed Event Description"); sl@0: _LIT(KTestRemoteParty1, "Remote Party"); sl@0: _LIT(KTestRemoteParty2, "Changed Remote Party"); sl@0: _LIT(KTestDirection1, "Direction"); sl@0: _LIT(KTestDirection2, "Changed Direction"); sl@0: const TLogDurationType KTestDurationType1 = 1; sl@0: const TLogDurationType KTestDurationType2 = 2; sl@0: const TLogDuration KTestDuration1 = 0x1234; sl@0: const TLogDuration KTestDuration2 = 0x1234567; sl@0: _LIT(KTestStatus1, "Status"); sl@0: _LIT(KTestStatus2, "Changed Status"); sl@0: _LIT(KTestSubject1, "Subject"); sl@0: _LIT(KTestSubject2, "Changed Subject"); sl@0: _LIT(KTestNumber1, "TheNumber"); sl@0: _LIT(KTestNumber2, "Changed Number"); sl@0: const TLogContactItemId KTestContact1 = 0x1234; sl@0: const TLogContactItemId KTestContact2 = 0x1234567; sl@0: const TLogLink KTestLink1 = 0x1234; sl@0: const TLogLink KTestLink2 = 0x1234567; sl@0: _LIT8(KTestData1, "ABCDEFGH"); sl@0: _LIT8(KTestData2, "IJKLMNOPQRSTUVWXYZ"); sl@0: const TLogFlags KTestFlags1 = 0x5; sl@0: const TLogFlags KTestFlags2 = 0xA; sl@0: const TLogSize KTestMaxLogSize = 0xFFF; sl@0: const TLogRecentSize KTestMaxRecentLogSize = 0xF; sl@0: const TLogAge KTestMaxEventAge = 0xFFFFFFF; sl@0: sl@0: TInt gTheId; sl@0: sl@0: //////////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: class TClientObserverTestReceiver : public MLogClientChangeObserver sl@0: { sl@0: public: sl@0: TClientObserverTestReceiver(TBool& aFlag) : iCallCount(0), iFlag(aFlag) { } sl@0: sl@0: public: sl@0: void HandleLogClientChangeEventL(TUid aChangeType, TInt /*aChangeParam1*/, TInt /*aChangeParam2*/, TInt /*aChangeParam3*/) sl@0: { sl@0: ++iCallCount; sl@0: iFlag = (aChangeType == KLogClientChangeEventLogCleared); sl@0: } sl@0: inline TInt CallCount() const { return iCallCount; } sl@0: inline void Reset() { iCallCount = 0; iFlag = EFalse; } sl@0: sl@0: private: sl@0: TInt iCallCount; sl@0: TBool& iFlag; sl@0: }; sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0833 sl@0: @SYMTestCaseDesc Client observer mechanism test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Set the change observer,add an event type,clear the log and test for the status. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestClientObserverMechanismL(CLogClient& aClient) sl@0: { sl@0: // sl@0: TBool logClearedFlag = EFalse; sl@0: TClientObserverTestReceiver testReceiver(logClearedFlag); sl@0: // sl@0: aClient.SetGlobalChangeObserverL(&testReceiver); sl@0: sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: TTime clearLogThreshold(now); sl@0: clearLogThreshold -= TTimeIntervalDays(1); sl@0: TTime past(now); sl@0: past -= TTimeIntervalDays(2); sl@0: sl@0: // Make some events sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: for(TInt i=0; i<10; i++) sl@0: { sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: event->SetRemoteParty(KTestRemoteParty1); sl@0: event->SetDirection(KTestDirection1); sl@0: event->SetDurationType(KTestDurationType1); sl@0: event->SetDuration(KTestDuration1); sl@0: event->SetStatus(KTestStatus1); sl@0: event->SetSubject(KTestSubject1); sl@0: event->SetNumber(KTestNumber1); sl@0: event->SetContact((TLogContactItemId) i+1); sl@0: event->SetLink(KTestLink1); sl@0: event->SetDataL(KTestData1); sl@0: event->SetFlags(KTestFlags1); sl@0: sl@0: // Add event sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Make it in the past sl@0: event->SetTime(past); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: TEST2(testReceiver.CallCount(), 0); sl@0: sl@0: // Clear the log sl@0: active->StartL(); sl@0: aClient.ClearLog(clearLogThreshold, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Have to wait a while, since the change observer active object sl@0: // won't run until shortly after completing the 'clear log' operation sl@0: // request status. sl@0: CTestTimer* timer = CTestTimer::NewL(); sl@0: CleanupStack::PushL(timer); sl@0: timer->After(5 * 1000000); sl@0: CActiveScheduler::Start(); sl@0: CleanupStack::PopAndDestroy(timer); sl@0: // sl@0: TEST2(testReceiver.CallCount(), 1); sl@0: TEST(logClearedFlag); sl@0: sl@0: // Start again sl@0: testReceiver.Reset(); sl@0: sl@0: // Test removing observer sl@0: aClient.SetGlobalChangeObserverL(NULL); sl@0: sl@0: // Add an event again sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(testReceiver.CallCount(), 0); sl@0: sl@0: // Make it in the past sl@0: event->SetTime(past); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Clear the log again sl@0: active->StartL(); sl@0: aClient.ClearLog(clearLogThreshold, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(testReceiver.CallCount(), 0); sl@0: TEST(logClearedFlag == EFalse); sl@0: sl@0: aClient.SetGlobalChangeObserverL(&testReceiver); sl@0: sl@0: // Tidy up sl@0: CleanupStack::PopAndDestroy(2, event); // active, event sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0834 sl@0: @SYMTestCaseDesc Adding an event to the log engine test. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create a new event type and add that to the log engine. sl@0: Start an active scheduler and check for the error status. sl@0: Add the event once again and check for the already exits condition. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestAddEventTypeL(CLogClient& aClient) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: LOGTEXT("TestAddEventTypeL()"); sl@0: CLogEventType* type = CLogEventType::NewL(); sl@0: CleanupStack::PushL(type); sl@0: sl@0: type->SetUid(KTestEventUid); sl@0: type->SetDescription(KTestEventDesc1); sl@0: type->SetLoggingEnabled(ETrue); sl@0: sl@0: CTestActive* active = new(ELeave) CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEventType(*type, active->iStatus); sl@0: aClient.Cancel(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: aClient.Cancel(); sl@0: TEST((active->iStatus == KErrNone)||(active->iStatus == KErrAlreadyExists)); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrAlreadyExists); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // active, type sl@0: LOGTEXT("TestAddEventTypeL() - end"); sl@0: } sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0835 sl@0: @SYMTestCaseDesc Retrieving the event type information test. sl@0: Tests for CLogClient::GetEventType() function. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for the retrieved information of event type. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestGetEventTypeL(CLogClient& aClient) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: LOGTEXT("TestGetEventTypeL()"); sl@0: CLogEventType* type = CLogEventType::NewL(); sl@0: CleanupStack::PushL(type); sl@0: sl@0: type->SetUid(KTestEventUid); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEventType(*type, active->iStatus); sl@0: aClient.Cancel(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: aClient.Cancel(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST(type->Uid() == KTestEventUid); sl@0: TEST(type->Description() == KTestEventDesc1); sl@0: TEST(type->LoggingEnabled()); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // active, type sl@0: LOGTEXT("TestGetEventTypeL() - end"); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0836 sl@0: @SYMTestCaseDesc Changing the event type test. sl@0: Tests for CLogClient::ChangeEventType test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create a new event type,change the event type and check for any errors sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestChangeEventTypeL(CLogClient& aClient) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0836 ")); sl@0: LOGTEXT("TestChangeEventTypeL()"); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogEventType* type = CLogEventType::NewL(); sl@0: CleanupStack::PushL(type); sl@0: sl@0: type->SetUid(KTestEventUid); sl@0: type->SetDescription(KTestEventDesc2); sl@0: type->SetLoggingEnabled(EFalse); sl@0: sl@0: active->StartL(); sl@0: aClient.ChangeEventType(*type, active->iStatus); sl@0: aClient.Cancel(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: sl@0: active->StartL(); sl@0: aClient.ChangeEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: aClient.Cancel(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(); // type sl@0: sl@0: type = CLogEventType::NewL(); sl@0: CleanupStack::PushL(type); sl@0: sl@0: type->SetUid(KTestEventUid); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST(type->Uid() == KTestEventUid); sl@0: TEST(type->Description() == KTestEventDesc2); sl@0: TEST(type->LoggingEnabled() == EFalse); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // type, active sl@0: LOGTEXT("TestChangeEventTypeL() - end"); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0837 sl@0: @SYMTestCaseDesc Deleting an event type test. sl@0: Tests for CLogClient::DeleteEventType() test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Delete an event type from log database and test for no errors found sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDeleteEventTypeL(CLogClient& aClient) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0837 ")); sl@0: LOGTEXT("TestChangeEventTypeL()"); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: active->StartL(); sl@0: aClient.DeleteEventType(KTestEventUid, active->iStatus); sl@0: aClient.Cancel(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: sl@0: active->StartL(); sl@0: aClient.DeleteEventType(KTestEventUid, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: aClient.Cancel(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CLogEventType* type = CLogEventType::NewL(); sl@0: CleanupStack::PushL(type); sl@0: sl@0: type->SetUid(KTestEventUid); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNotFound); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // type, active sl@0: LOGTEXT("TestChangeEventTypeL() - end"); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-1329 sl@0: @SYMTestCaseDesc Adding an event type test. sl@0: Tests for CLogClient::AddEventType() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Add an event type to the log database and test for no errors found sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestAddEventL(CLogClient& aClient) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1329 ")); sl@0: CLogEventType* type = CLogEventType::NewL(); sl@0: CleanupStack::PushL(type); sl@0: sl@0: type->SetUid(KTestEventUid); sl@0: type->SetDescription(KTestEventDesc1); sl@0: type->SetLoggingEnabled(ETrue); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: // Reset sl@0: gTheId = KLogNullId; sl@0: // sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: sl@0: event->SetEventType(KTestEventUid); sl@0: event->SetRemoteParty(KTestRemoteParty1); sl@0: event->SetDirection(KTestDirection1); sl@0: event->SetDurationType(KTestDurationType1); sl@0: event->SetDuration(KTestDuration1); sl@0: event->SetStatus(KTestStatus1); sl@0: event->SetSubject(KTestSubject1); sl@0: event->SetNumber(KTestNumber1); sl@0: event->SetContact(KTestContact1); sl@0: event->SetLink(KTestLink1); sl@0: event->SetDataL(KTestData1); sl@0: event->SetFlags(KTestFlags1); sl@0: // sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: aClient.Cancel(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: // sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST(!active->IsActive()); sl@0: aClient.Cancel(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: // sl@0: gTheId=event->Id(); sl@0: // sl@0: TEST(gTheId != KLogNullId); sl@0: TEST(event->Time() >= now); sl@0: TEST(event->Description() == KTestEventDesc1); sl@0: // sl@0: CleanupStack::PopAndDestroy(3); // event, active, type sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0838 sl@0: @SYMTestCaseDesc Client failure test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Checks for status after client is deleted,checks for Cancel error flag sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestClientFailL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0838 ")); sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogClient* client = CLogClient::NewL(theFs); sl@0: CleanupStack::PushL(client); sl@0: sl@0: event->SetId(gTheId); sl@0: sl@0: active->StartL(); sl@0: client->GetEvent(*event, active->iStatus); sl@0: CleanupStack::Pop(); // client sl@0: delete client; sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0839 sl@0: @SYMTestCaseDesc Tests for CLogClient::GetEvent() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Retrieve the event type and test for the integrity of the event type information sl@0: Check for no errors sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: sl@0: LOCAL_C void TestGetEventL(CLogClient& aClient) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0839 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: event->SetId(gTheId); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: aClient.Cancel(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: aClient.Cancel(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST(event->Id() == gTheId); sl@0: TEST(event->Time() > TTime(0)); sl@0: TEST(event->Description() == KTestEventDesc1); sl@0: TEST(event->EventType() == KTestEventUid); sl@0: TEST(event->RemoteParty() == KTestRemoteParty1); sl@0: TEST(event->Direction() == KTestDirection1); sl@0: TEST(event->DurationType() == KTestDurationType1); sl@0: TEST(event->Duration() == KTestDuration1); sl@0: TEST(event->Status() == KTestStatus1); sl@0: TEST(event->Subject() == KTestSubject1); sl@0: TEST(event->Number() == KTestNumber1); sl@0: TEST(event->Contact() == KTestContact1); sl@0: TEST(event->Link() == KTestLink1); sl@0: TEST(event->Data() == KTestData1); sl@0: TEST(event->Flags() == KTestFlags1); sl@0: sl@0: TBuf<500> subject; sl@0: TInt i=450; sl@0: while(i--) sl@0: subject.Append(_L("a")); sl@0: event->SetSubject(subject); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: if (aClient.IsActive() && active->iStatus == KRequestPending) sl@0: { sl@0: aClient.Cancel(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: } sl@0: else sl@0: { sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: } sl@0: sl@0: // See TestAddEventL on why this might still allow the active object sl@0: // to be cancelled. sl@0: // TEST(active->iStatus == KErrNone || active->iStatus == KErrCancel); sl@0: sl@0: i=450; sl@0: while(i--) sl@0: subject[i]='b'; sl@0: event->SetSubject(subject); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: aClient.Cancel(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: sl@0: CleanupStack::PopAndDestroy(2); // event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0840 sl@0: @SYMTestCaseDesc Tests for CLogClient::ChangeEvent() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Change the event,get the event information and test for the integrity. sl@0: Check for any errors. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestChangeEventL(CLogClient& aClient) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0840 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: sl@0: event->SetId(gTheId); sl@0: event->SetTime(now); sl@0: event->SetRemoteParty(KTestRemoteParty2); sl@0: event->SetDirection(KTestDirection2); sl@0: event->SetDurationType(KTestDurationType2); sl@0: event->SetDuration(KTestDuration2); sl@0: event->SetStatus(KTestStatus2); sl@0: event->SetSubject(KTestSubject2); sl@0: event->SetNumber(KTestNumber2); sl@0: event->SetContact(KTestContact2); sl@0: event->SetLink(KTestLink2); sl@0: event->SetDataL(KTestData2); sl@0: event->SetFlags(KTestFlags2); sl@0: sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: aClient.Cancel(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: aClient.Cancel(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(); // event sl@0: sl@0: event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: event->SetId(gTheId); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST(event->Id() == gTheId); sl@0: TEST(event->Time() == now); sl@0: TEST(event->Description() == KTestEventDesc1); sl@0: TEST(event->EventType() == KTestEventUid); sl@0: TEST(event->RemoteParty() == KTestRemoteParty2); sl@0: TEST(event->Direction() == KTestDirection2); sl@0: TEST(event->DurationType() == KTestDurationType2); sl@0: TEST(event->Duration() == KTestDuration2); sl@0: TEST(event->Status() == KTestStatus2); sl@0: TEST(event->Subject() == KTestSubject2); sl@0: TEST(event->Number() == KTestNumber2); sl@0: TEST(event->Contact() == KTestContact2); sl@0: TEST(event->Link() == KTestLink2); sl@0: TEST(event->Data() == KTestData2); sl@0: TEST(event->Flags() == KTestFlags2); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // event, active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0841 sl@0: @SYMTestCaseDesc Tests for CLogClient::DeleteEvent() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Delete the event and test for no errors found. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDeleteEventL(CLogClient& aClient) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0841 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: active->StartL(); sl@0: aClient.DeleteEvent(0, active->iStatus); sl@0: aClient.Cancel(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: sl@0: active->StartL(); sl@0: aClient.DeleteEvent(0, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: aClient.Cancel(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: event->SetId(0); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNotFound); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // event, active sl@0: } sl@0: sl@0: sl@0: #ifdef SYSLIBS_TEST sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-UT-4015 sl@0: @SYMTestCaseDesc Test the behaviour implemented by PREQ2103 sl@0: @SYMTestPriority Medium sl@0: @SYMTestActions Get the settings from logeng repository file / resource file. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ11125 sl@0: REQ11126 sl@0: REQ11127 sl@0: REQ11128 sl@0: */ sl@0: LOCAL_C void TestGetConfigSettingsFromRepositoryFileL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-UT-4015 ")); sl@0: sl@0: TInt contactMatchCount1; sl@0: TLogContactNameFormat contactNameFormat1; sl@0: LogGetContactmatchCountAndNameFormatL(contactMatchCount1, contactNameFormat1); sl@0: TheTest.Printf(_L("Contact match count = %d, contact name format = %d\r\n"), contactMatchCount1, (TInt)contactNameFormat1); sl@0: //contactMatchCount1 and contactNameFormat1 are loaded directly from the repository, if exists. sl@0: //Otherwise they are initialzied with their default values. sl@0: //The LogEng server should load these resource values in a similar way. sl@0: //They will be stored in contactMatchCount2 and contactNameFormat2. sl@0: TInt16 contactMatchCount2; sl@0: TInt16 contactNameFormat2; sl@0: RFs fs; sl@0: sl@0: LEAVE_IF_ERROR(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: sl@0: //Creating a new CLogClient Object make the server getting the contact match settings. sl@0: //As the database is deleted it gets them from the LogEng repository. sl@0: CLogClient* client2 = CLogClient::NewL(fs); sl@0: CleanupStack::PushL(client2); sl@0: CleanupStack::PopAndDestroy(client2); sl@0: sl@0: //Read these settings via "reader" object. sl@0: RFileReadStream resFileCount_reader; sl@0: CleanupClosePushL(resFileCount_reader); sl@0: RFileReadStream resFileFormat_reader; sl@0: CleanupClosePushL(resFileFormat_reader); sl@0: _LIT(KLogengTestFileNameCount, "c:\\test\\test_logengconfig_count.ini"); sl@0: _LIT(KLogengTestFileNameFormat, "c:\\test\\test_logengconfig_format.ini"); sl@0: LEAVE_IF_ERROR(resFileCount_reader.Open(fs, KLogengTestFileNameCount, EFileRead)); sl@0: LEAVE_IF_ERROR(resFileFormat_reader.Open(fs, KLogengTestFileNameFormat, EFileRead)); sl@0: contactMatchCount2 = resFileCount_reader.ReadInt32L(); sl@0: contactNameFormat2 = resFileFormat_reader.ReadInt32L(); sl@0: sl@0: //The settings should match the ones from resource file. sl@0: TEST2(contactMatchCount1, contactMatchCount2); sl@0: TEST2(contactNameFormat1, contactNameFormat2); sl@0: sl@0: CleanupStack::PopAndDestroy(&resFileFormat_reader); sl@0: CleanupStack::PopAndDestroy(&resFileCount_reader); sl@0: sl@0: //Get the config settings (Three config settings). sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: TLogConfig config; sl@0: TEST(config.iMaxEventAge == 0); sl@0: TEST(config.iMaxLogSize == 0); sl@0: TEST(config.iMaxRecentLogSize == 0); sl@0: active->StartL(); sl@0: aClient.GetConfig(config, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: //The config settings should match the ones from the repository. sl@0: TEST(config.iMaxEventAge == 2592000); sl@0: TEST(config.iMaxLogSize == 1000); sl@0: TEST(config.iMaxRecentLogSize == 20); sl@0: sl@0: sl@0: //Now let's provide the repository file, so the server will find it and will get the settings sl@0: //from it. sl@0: sl@0: //Create the directory c:\private\10202be9\ if it does not exist. sl@0: _LIT(KExecutableFileName, "t_logapi_helper.exe"); sl@0: _LIT(KCommandParameters, "c:\\private\\10202be9\\;c:\\private\\10202be9\\101f401d.txt;3"); sl@0: RProcess process; sl@0: TRequestStatus processWaitStatus; sl@0: TInt r = process.Create(KExecutableFileName, KCommandParameters); sl@0: TEST(r == KErrNone); sl@0: process.Logon(processWaitStatus); sl@0: process.Resume(); sl@0: User::WaitForRequest(processWaitStatus); sl@0: TEST(processWaitStatus.Int() == KErrNone); sl@0: process.Close(); sl@0: sl@0: //copy the repository file to the folder 10202be9 sl@0: _LIT(KCommandParameters1, "z:\\test\\101f401d_TEST.txt;c:\\private\\10202be9\\101f401d.txt;0"); sl@0: r = process.Create(KExecutableFileName, KCommandParameters1); sl@0: TEST(r == KErrNone); sl@0: process.Logon(processWaitStatus); sl@0: process.Resume(); sl@0: User::WaitForRequest(processWaitStatus); sl@0: TEST(processWaitStatus.Int() == KErrNone); sl@0: process.Close(); sl@0: sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: //Get the config settings. sl@0: config.iMaxEventAge = 0; sl@0: config.iMaxLogSize = 0; sl@0: config.iMaxRecentLogSize = 0; sl@0: active->StartL(); sl@0: aClient.GetConfig(config, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: //They should match the ones from the repository file. sl@0: TEST(config.iMaxEventAge == 2592001); sl@0: TEST(config.iMaxLogSize == 1001); sl@0: TEST(config.iMaxRecentLogSize == 21); sl@0: sl@0: CleanupStack::PopAndDestroy(active); sl@0: sl@0: //Get the contact match count and the contact name format. sl@0: RFileReadStream repFileCount_reader; sl@0: CleanupClosePushL(repFileCount_reader); sl@0: RFileReadStream repFileFormat_reader; sl@0: CleanupClosePushL(repFileFormat_reader); sl@0: LEAVE_IF_ERROR(repFileCount_reader.Open(fs, KLogengTestFileNameCount, EFileRead)); sl@0: LEAVE_IF_ERROR(repFileFormat_reader.Open(fs, KLogengTestFileNameFormat, EFileRead)); sl@0: contactMatchCount2 = repFileCount_reader.ReadInt32L(); sl@0: contactNameFormat2 = repFileFormat_reader.ReadInt32L(); sl@0: CleanupStack::PopAndDestroy(&repFileFormat_reader); sl@0: CleanupStack::PopAndDestroy(&repFileCount_reader); sl@0: CleanupStack::PopAndDestroy(&fs); sl@0: sl@0: //The values should match the ones from the repository file. sl@0: TEST(contactMatchCount2 == 6); sl@0: TEST(contactNameFormat2 == 1); sl@0: sl@0: //delete the repository file c:\\private\\10202be9\\101f401d.txt. sl@0: _LIT(KCommandParameters2, "c:\\private\\10202be9\\101f401d.txt;private\\10202be9\101f401d.txt;2"); sl@0: r = process.Create(KExecutableFileName, KCommandParameters2); sl@0: TEST(r == KErrNone); sl@0: process.Logon(processWaitStatus); sl@0: process.Resume(); sl@0: User::WaitForRequest(processWaitStatus); sl@0: TEST(processWaitStatus.Int() == KErrNone); sl@0: process.Close(); sl@0: sl@0: theLog.Write(_L8("Deleting the Log engine database... \n")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: TheTest.Next(_L("Delay of 2 min, the necessary time to central repository to unload its cache... ")); sl@0: User::After(125000000); // Delay to time to cenrep to unload its cache. sl@0: } sl@0: #endif sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0842 sl@0: @SYMTestCaseDesc Tests for retrieving the log engine configuration data sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for CLogClient::GetConfig() function,check for the integrity of the data sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestGetConfigL(CLogClient& aClient) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0842 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: TLogConfig config; sl@0: sl@0: TEST(config.iMaxEventAge == 0); sl@0: TEST(config.iMaxLogSize == 0); sl@0: TEST(config.iMaxRecentLogSize == 0); sl@0: sl@0: active->StartL(); sl@0: aClient.GetConfig(config, active->iStatus); sl@0: aClient.Cancel(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: sl@0: active->StartL(); sl@0: aClient.GetConfig(config, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: aClient.Cancel(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST(config.iMaxEventAge > 0); sl@0: TEST(config.iMaxLogSize > 0); sl@0: TEST(config.iMaxRecentLogSize > 0); sl@0: sl@0: CleanupStack::PopAndDestroy(); // active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0843 sl@0: @SYMTestCaseDesc Tests for CLogClient::ChangeConfig() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Change the configuration data and test for the integrity. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestChangeConfigL(CLogClient& aClient) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0843 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: TLogConfig config; sl@0: sl@0: config.iMaxLogSize = KTestMaxLogSize; sl@0: config.iMaxRecentLogSize = KTestMaxRecentLogSize; sl@0: config.iMaxEventAge = KTestMaxEventAge; sl@0: sl@0: active->StartL(); sl@0: aClient.ChangeConfig(config, active->iStatus); sl@0: aClient.Cancel(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: sl@0: active->StartL(); sl@0: aClient.ChangeConfig(config, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: aClient.Cancel(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TEST(config.iMaxLogSize == KTestMaxLogSize); sl@0: TEST(config.iMaxRecentLogSize == KTestMaxRecentLogSize); sl@0: TEST(config.iMaxEventAge == KTestMaxEventAge); sl@0: sl@0: CleanupStack::PopAndDestroy(); // active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0844 sl@0: @SYMTestCaseDesc Tests for CLogClient::GetString() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Get the string from the resource file and check for no errors and the zero string length sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestGetStringL(CLogClient& aClient) sl@0: // sl@0: // sl@0: // sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0844 ")); sl@0: TBuf str; sl@0: sl@0: TInt err = aClient.GetString(str, R_LOG_DIR_IN); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DIR_OUT); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DIR_IN_ALT); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DIR_OUT_ALT); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DIR_FETCHED); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DIR_MISSED); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DEL_PENDING); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DEL_SENT); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DEL_FAILED); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DEL_NONE); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DEL_DONE); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DEL_NOT_SENT); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DEL_NOTIFIED); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_DEL_EXPIRED); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_REMOTE_UNKNOWN); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_REMOTE_MULTIPLE); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: sl@0: err = aClient.GetString(str, R_LOG_SUBJECT_NONE); sl@0: TEST2(err, KErrNone); sl@0: TEST(str.Length() > 0); sl@0: str.Zero(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0845 sl@0: @SYMTestCaseDesc Tests for clearing the event types from the log sl@0: @SYMTestPriority High sl@0: @SYMTestActions Clear the event types from the log and check for event not found error. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestClearEventLogL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0845 ")); sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: TDateTime d = now.DateTime(); sl@0: TheTest.Printf(_L("TimeNow: Y=%d, M=%d, D=%d, H=%d, M=%d, S=%d\n"), d.Year(), d.Month() + 1, d.Day() + 1, d.Hour(), d.Minute(), d.Second()); sl@0: sl@0: TTime date1(now); sl@0: date1 -= TTimeIntervalDays(1); sl@0: sl@0: TTime date2(date1); sl@0: date2 -= TTimeIntervalDays(1); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Clear all events before (current date). Actually - all events! sl@0: active->StartL(); sl@0: aClient.ClearLog(now, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //The next part of the test will create 4 events: sl@0: //-event1 and event2 will have time = current date - 1 day + 10 seconds; sl@0: //-event3 and event4 will have time = current date - 2 days; sl@0: //The test is: sl@0: //ClearLog - Delete all events, which time is less or equal to current date - 1 day. sl@0: //Check - event3 and event4 should disappear, event1 and event2 should stay. sl@0: //ClearLog - Delete all events, which time is less or equal to current date. sl@0: //Check - event1 and event2 should disappear too. sl@0: // sl@0: //The "10 seconds" addition is very important. The creation of the 4 events is sl@0: //an operation, which is performed very quickly. It is possible that the sl@0: //first ClearLog operation will be executed at the same second at which the events sl@0: //were created. Which means, that all events will be deleted and the next check sl@0: //for the presence of event1 and event2 will fail. sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Create and add new event - event1. sl@0: //Set event1 date to be (current date - 1 day + 10 seconds). sl@0: CLogEvent* event1 = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event1); sl@0: sl@0: event1->SetEventType(KTestEventUid); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event1, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TTimeIntervalSeconds tenSeconds(10); sl@0: event1->SetTime(date1 + tenSeconds); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event1, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Create and add new event - event2. sl@0: //Set event2 date to be (current date - 1 day + 10 seconds). sl@0: CLogEvent* event2 = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event2); sl@0: sl@0: event2->SetEventType(KTestEventUid); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event2, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: event2->SetTime(date1 + tenSeconds); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event2, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Create and add new event - event3. sl@0: //Set event3 date to be (current date - 2 days). sl@0: CLogEvent* event3 = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event3); sl@0: event3->SetEventType(KTestEventUid); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event3, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: event3->SetTime(date2); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event3, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Create and add new event - event4. sl@0: //Set event4 date to be (current date - 2 days). sl@0: CLogEvent* event4 = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event4); sl@0: event4->SetEventType(KTestEventUid); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event4, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: event4->SetTime(date2); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event4, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Clear all events before (current date - 1 day). sl@0: //Then cancel the operation. sl@0: TheTest.Printf(_L("=.= ClearLog 1\n")); sl@0: active->StartL(); sl@0: aClient.ClearLog(date1, active->iStatus); sl@0: aClient.Cancel(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrCancel); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Clear all events before (current date - 1 day). sl@0: //event3 and event4 should be removed. sl@0: TheTest.Printf(_L("=.= ClearLog 2\n")); sl@0: active->StartL(); sl@0: aClient.ClearLog(date1, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Get event1. It should be there - its time is (current date - 1 day + 10 seconds). sl@0: TheTest.Printf(_L("=.= GetEvent 1\n")); sl@0: active->StartL(); sl@0: aClient.GetEvent(*event1, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: if(active->iStatus != KErrNone) sl@0: { sl@0: TheTest.Printf(_L("=1= error code:%d\n"),active->iStatus.Int()); sl@0: } sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Get event2. It should be there - its time is (current date - 1 day + 10 seconds). sl@0: TheTest.Printf(_L("=.= GetEvent 2\n")); sl@0: active->StartL(); sl@0: aClient.GetEvent(*event2, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: if(active->iStatus != KErrNone) sl@0: { sl@0: TheTest.Printf(_L("=2= error code:%d\n"),active->iStatus.Int()); sl@0: } sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Get event3. It should not be there - its time is (current date - 2 days). sl@0: TheTest.Printf(_L("=.= GetEvent 3\n")); sl@0: active->StartL(); sl@0: aClient.GetEvent(*event3, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNotFound); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Get event4. It should not be there - its time is (current date - 2 days). sl@0: TheTest.Printf(_L("=.= GetEvent 4\n")); sl@0: active->StartL(); sl@0: aClient.GetEvent(*event4, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNotFound); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Clear all events happened before (current date). sl@0: //event1 and event2 should be removed. sl@0: TheTest.Printf(_L("=#= ClearLog 1\n")); sl@0: active->StartL(); sl@0: aClient.ClearLog(now, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Get event1. It should not be there - its time is (current date - 1 day + 10 seconds). sl@0: TheTest.Printf(_L("=#= GetEvent 1\n")); sl@0: active->StartL(); sl@0: aClient.GetEvent(*event1, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNotFound); sl@0: sl@0: ////////////////////////////////////////////////////////////////////////////// sl@0: //Get event2. It should not be there - its time is (current date - 1 day + 10 seconds). sl@0: TheTest.Printf(_L("=#= GetEvent 2\n")); sl@0: active->StartL(); sl@0: aClient.GetEvent(*event2, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNotFound); sl@0: sl@0: CleanupStack::PopAndDestroy(5); // event4, event3, event2, event1, active sl@0: } sl@0: sl@0: LOCAL_C void DoTestLogL(CLogBase& aClient) sl@0: { sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: sl@0: event->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: User::After((Math::Random() % 4) * 100000); sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TTEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TTEST(event->EventType() == KLogCallEventTypeUid); sl@0: TTEST(event->Description().Length() > 0); sl@0: TTEST(event->Time() >= now); sl@0: now = event->Time(); sl@0: sl@0: TLogId id = event->Id(); sl@0: sl@0: event->SetRemoteParty(KTestRemoteParty1); sl@0: event->SetDirection(KTestDirection1); sl@0: event->SetDurationType(KTestDurationType1); sl@0: event->SetDuration(KTestDuration1); sl@0: event->SetStatus(KTestStatus1); sl@0: event->SetSubject(KTestSubject1); sl@0: event->SetNumber(KTestNumber1); sl@0: event->SetContact(KTestContact1); sl@0: event->SetLink(KTestLink1); sl@0: event->SetDataL(KTestData1); sl@0: sl@0: User::After((Math::Random() % 4) * 100000); sl@0: active->StartL(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TTEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TTEST(event->Id() == id); sl@0: TTEST(event->EventType() == KLogCallEventTypeUid); sl@0: TTEST(event->Description().Length() > 0); sl@0: TTEST(event->Time() == now); sl@0: TTEST(event->RemoteParty() == KTestRemoteParty1); sl@0: TTEST(event->Direction() == KTestDirection1); sl@0: TTEST(event->DurationType() == KTestDurationType1); sl@0: TTEST(event->Duration() == KTestDuration1); sl@0: TTEST(event->Status() == KTestStatus1); sl@0: TTEST(event->Subject() == KTestSubject1); sl@0: TTEST(event->Number() == KTestNumber1); sl@0: TTEST(event->Contact() == KTestContact1); sl@0: TTEST(event->Link() == KTestLink1); sl@0: TTEST(event->Data() == KTestData1); sl@0: sl@0: CleanupStack::PopAndDestroy(); // event; sl@0: sl@0: event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: event->SetId(id); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TTEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TTEST(event->Id() == id); sl@0: TTEST(event->EventType() == KLogCallEventTypeUid); sl@0: TTEST(event->Description().Length() > 0); sl@0: TTEST(event->Time() == now); sl@0: TTEST(event->RemoteParty() == KTestRemoteParty1); sl@0: TTEST(event->Direction() == KTestDirection1); sl@0: TTEST(event->DurationType() == KTestDurationType1); sl@0: TTEST(event->Duration() == KTestDuration1); sl@0: TTEST(event->Status() == KTestStatus1); sl@0: TTEST(event->Subject() == KTestSubject1); sl@0: TTEST(event->Number() == KTestNumber1); sl@0: TTEST(event->Contact() == KTestContact1); sl@0: TTEST(event->Link() == KTestLink1); sl@0: TTEST(event->Data() == KTestData1); sl@0: sl@0: User::After((Math::Random() % 4) * 100000); sl@0: active->StartL(); sl@0: aClient.DeleteEvent(id, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TTEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TTEST2(active->iStatus.Int(), KErrNotFound); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // event, active sl@0: } sl@0: sl@0: void DoTestMultipleClientAccessL() sl@0: { sl@0: CActiveScheduler::Install(new(ELeave)CActiveScheduler); sl@0: CleanupStack::PushL(CActiveScheduler::Current()); sl@0: sl@0: RFs fs; sl@0: TTEST2(fs.Connect(), KErrNone); sl@0: CleanupClosePushL(fs); sl@0: sl@0: CLogClient* client = CLogClient::NewL(fs); sl@0: CleanupStack::PushL(client); sl@0: sl@0: TBuf8<500> buf; sl@0: sl@0: TInt count = 10; sl@0: while(count--) sl@0: { sl@0: DoTestLogL(*client); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(3); // fs, client, CActiveScheduler sl@0: } sl@0: sl@0: void DoThreadDieL() sl@0: { sl@0: CActiveScheduler::Install(new(ELeave)CActiveScheduler); sl@0: CleanupStack::PushL(CActiveScheduler::Current()); sl@0: sl@0: RFs fs; sl@0: TTEST2(fs.Connect(), KErrNone); sl@0: CleanupClosePushL(fs); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: const TInt KLogClientCnt = 10; sl@0: for(TInt i=0;iSetId(i); sl@0: TRequestStatus status; sl@0: client->GetEvent(*event, status); sl@0: } sl@0: sl@0: User::After(100000); sl@0: sl@0: RThread thread; sl@0: thread.Kill(KErrGeneral); sl@0: } sl@0: sl@0: static TInt DoDyingThreadStart(TAny*) sl@0: { sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: TTEST(cleanup != NULL); sl@0: TRAPD(err, DoThreadDieL()); sl@0: delete cleanup; sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Print(_L("*** DoThreadDieL() failed with err %d\r\n"), err); sl@0: User::Panic(_L("ThrChk4"), 4); sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: static TInt DoThreadStart(TAny* aThreadNumber) sl@0: { sl@0: TInt thrNum = (TInt)aThreadNumber; sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: TTEST(cleanup != NULL); sl@0: TRAPD(err, DoTestMultipleClientAccessL()); sl@0: delete cleanup; sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Print(_L("*** Thread %d failed with err %d\r\n"), thrNum, err); sl@0: User::Panic(_L("ThrChk3"), 3); sl@0: } sl@0: return err; sl@0: } sl@0: sl@0: const TInt KTestThreadCount = 20; sl@0: const TInt KMinTestHeapSize = 0x10000; sl@0: const TInt KMaxTestHeapSize = 0x100000; sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0846 sl@0: @SYMTestCaseDesc Thread invoking test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create a new thread,check for no errors,register for notification of status when the thread dies sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestThreadDieL() sl@0: { sl@0: RThread thread; sl@0: TRequestStatus status; sl@0: sl@0: TName name; sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0846 ")); sl@0: _LIT(KThreadName, "Test thread"); sl@0: name.Format(KThreadName); sl@0: sl@0: TInt err = thread.Create(name, DoDyingThreadStart, KDefaultStackSize, KMinTestHeapSize, KMaxTestHeapSize, NULL, EOwnerThread); sl@0: // Create the thread sl@0: TEST2(err, KErrNone); sl@0: thread.Logon(status); sl@0: sl@0: // Let the thread run sl@0: thread.Resume(); sl@0: sl@0: User::WaitForRequest(status); sl@0: TEST2(thread.ExitType(), EExitKill); sl@0: thread.Close(); sl@0: TEST2(status.Int(), KErrGeneral); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0847 sl@0: @SYMTestCaseDesc Multiple client access test sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create threads,request for notification of thread death. sl@0: Resume and stop all the threads executions.Check for no errors. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestMultipleClientAccessL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0847 ")); sl@0: RThread threadArray[KTestThreadCount]; sl@0: TRequestStatus statusArray[KTestThreadCount]; sl@0: sl@0: // Create the threads sl@0: TInt count = KTestThreadCount; sl@0: while(count--) sl@0: { sl@0: TName name; sl@0: _LIT(KThreadName, "TmcaTh%d"); sl@0: name.Format(KThreadName, count); sl@0: sl@0: // Create the thread sl@0: TInt err = threadArray[count].Create(name, DoThreadStart, KDefaultStackSize, KMinTestHeapSize, KMaxTestHeapSize, (TAny*) count, EOwnerThread); sl@0: TEST2(err, KErrNone); sl@0: threadArray[count].Logon(statusArray[count]); sl@0: } sl@0: sl@0: // Let the thread run sl@0: count = KTestThreadCount; sl@0: while(count--) sl@0: { sl@0: TheTest.Printf(_L(" ** Resume thread %d\r\n"), count); sl@0: threadArray[count].Resume(); sl@0: } sl@0: sl@0: TheTest.Printf(_L(" ** Waiting threads to complete....\r\n")); sl@0: sl@0: // Wait for all the threads to complete sl@0: count = KTestThreadCount; sl@0: while(count--) sl@0: { sl@0: User::WaitForRequest(statusArray[count]); sl@0: TheTest.Printf(_L(" ** Thread %d completed\r\n"), count); sl@0: TEST(threadArray[count].ExitType() != EExitPanic); sl@0: threadArray[count].Close(); sl@0: } sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0848 sl@0: @SYMTestCaseDesc Test for checking notification of status sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call up add - get - change - delete event type. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestNoNotifierL() sl@0: { sl@0: TestUtils::DeleteDatabaseL(); sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0848 ")); sl@0: TheTest.Printf(_L("TestNoNotifierL - begin\n")); sl@0: sl@0: CLogClient* client = CLogClient::NewL(theFs); sl@0: CleanupStack::PushL(client); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive; sl@0: CleanupStack::PushL(active); sl@0: sl@0: TheTest.Printf(_L("TestAddEventTypeL\n")); sl@0: TestAddEventTypeL(*client); sl@0: sl@0: TheTest.Printf(_L("TestGetEventTypeL\n")); sl@0: TestGetEventTypeL(*client); sl@0: sl@0: TheTest.Printf(_L("TestChangeEventTypeL\n")); sl@0: TestChangeEventTypeL(*client); sl@0: sl@0: TheTest.Printf(_L("TestDeleteEventTypeL\n")); sl@0: TestDeleteEventTypeL(*client); sl@0: sl@0: TheTest.Printf(_L("TestAddEventL\n")); sl@0: TestAddEventL(*client); sl@0: sl@0: TheTest.Printf(_L("TestGetEventL\n")); sl@0: TestGetEventL(*client); sl@0: sl@0: TheTest.Printf(_L("TestChangeEventL\n")); sl@0: TestChangeEventL(*client); sl@0: sl@0: TheTest.Printf(_L("TestDeleteEventL\n")); sl@0: TestDeleteEventL(*client); sl@0: sl@0: TheTest.Printf(_L("TestGetConfigL\n")); sl@0: TestGetConfigL(*client); sl@0: sl@0: TheTest.Printf(_L("TestChangeConfigL\n")); sl@0: TestChangeConfigL(*client); sl@0: sl@0: TheTest.Printf(_L("TestGetStringL\n")); sl@0: TestGetStringL(*client); sl@0: sl@0: TheTest.Printf(_L("TestClearEventLogL\n")); sl@0: TestClearEventLogL(*client); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // active, client sl@0: TheTest.Printf(_L("TestNoNotifierL - end\n")); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID PDS-LOGENG-CT-4016 sl@0: @SYMTestCaseDesc Tests for CLogChangeDefinition public APIs sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for CLogChangeDefinition::Find() functions, and different NewL() functions. sl@0: @SYMTestExpectedResults CLogChangeDefinition object need to be created propertly. Find() functions sl@0: need to return proper items from list. sl@0: @SYMDEF DEF135499 sl@0: */ sl@0: LOCAL_C void TestLogChangeDefinitionL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-CT-4016")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: CLogEvent* event = CLogEvent::NewL(); sl@0: CleanupStack::PushL(event); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetContact(KTestContact); sl@0: filter->SetEventType(KLogPacketDataEventTypeUid); sl@0: sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewChangeObserver* changeObs = CLogViewChangeObserver::NewLC(); sl@0: changeObs->SetActive(); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient, *changeObs); sl@0: CleanupStack::PushL(view); sl@0: sl@0: // Incoming sl@0: TBuf buf; sl@0: aClient.GetString(buf, R_LOG_DIR_IN); sl@0: sl@0: event->SetEventType(KLogPacketDataEventTypeUid); sl@0: event->SetDirection(buf); sl@0: event->SetContact(KTestContact); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: User::After(1 * 1000000); sl@0: sl@0: TEST2(view->CountL(), 0); sl@0: active->StartL(); sl@0: TBool res = view->SetFilterL(*filter, active->iStatus); sl@0: TEST(res); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST2(view->CountL(), 1); sl@0: sl@0: // Transients sl@0: TInt changeCount; sl@0: TLogId logId; sl@0: TInt viewIndex; sl@0: TLogDatabaseChangeType type; sl@0: sl@0: for(TInt count = 0; count < KTestEventNum; count++) sl@0: { sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: User::After(1 * 1000000); sl@0: } sl@0: sl@0: const CLogChangeDefinition& changes = changeObs->Changes(); sl@0: sl@0: changeCount = changes.Count(); sl@0: TheTest.Printf(_L("Change Count: %d\n"), changeCount); sl@0: TEST2(changeCount, KTestEventNum); sl@0: for(TInt i=0; i=0); sl@0: TEST(changes.Find(TLogId(100000000), ELogChangeTypeEventAdded)==KErrNotFound); sl@0: TEST(changes.Find(logId, ELogChangeTypeLogCleared)==KErrNotFound); sl@0: TEST(changes.FindByViewIndex(viewIndex)>=0); sl@0: TEST(changes.Find(TLogId(100000000))==KErrNotFound); sl@0: } sl@0: sl@0: CBufFlat* buffer = CBufFlat::NewL(10*1024); sl@0: CleanupStack::PushL(buffer); sl@0: RBufWriteStream wstr(*buffer,0); sl@0: wstr << changes; sl@0: wstr.CommitL(); sl@0: wstr.Close(); sl@0: RBufReadStream rstr(*buffer,0); sl@0: CLogChangeDefinition* changes2 = CLogChangeDefinition::NewL(rstr); sl@0: CleanupStack::PushL(changes2); sl@0: rstr.Close(); sl@0: sl@0: TEST(changes.Count()==changes2->Count()); sl@0: sl@0: CleanupStack::PopAndDestroy(3); // changes2, buffer, view sl@0: sl@0: // Check the change was as expected sl@0: TEST2(changes.Count(), 10); sl@0: type = changes.At(0, logId, viewIndex); sl@0: sl@0: CleanupStack::PopAndDestroy(4, event); // changeObs, active, filter, event sl@0: sl@0: TEST2(type, ELogChangeTypeEventAdded); sl@0: TEST2(viewIndex, 0); // first (newest) events in the view sl@0: sl@0: const TLogId expectedLogId = ((TLogId) 1); sl@0: TEST2(logId, expectedLogId); sl@0: } sl@0: sl@0: void DoStartL() sl@0: { sl@0: CActiveScheduler::Install(new(ELeave)CActiveScheduler); sl@0: RFs fs; sl@0: LEAVE_IF_ERROR(fs.Connect()); sl@0: CleanupClosePushL(fs); sl@0: CLogClient* client = CLogClient::NewL(fs); sl@0: delete client; sl@0: CleanupStack::PopAndDestroy(&fs); sl@0: delete CActiveScheduler::Current(); sl@0: } sl@0: sl@0: static TInt LaunchThread(TAny* /*aAny*/) sl@0: { sl@0: __UHEAP_MARK; sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: TRAPD(err, DoStartL()); sl@0: delete cleanup; sl@0: __UHEAP_MARKEND; sl@0: if(err != KErrNone) sl@0: { sl@0: RDebug::Print(_L("*** DoStartL() failed with err %d\r\n"), err); sl@0: User::Panic(_L("ThrChk5"), 5); sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0849 sl@0: @SYMTestCaseDesc Tests for creation of two simultaneous threads sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create two threads,start and close the threads sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestStartupL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0849 ")); sl@0: RThread thread1; sl@0: RThread thread2; sl@0: sl@0: // Create the threads sl@0: LEAVE_IF_ERROR(thread1.Create(_L("Thread1"), LaunchThread, KDefaultStackSize, KMinHeapSize , KMinHeapSize , NULL)); sl@0: LEAVE_IF_ERROR(thread2.Create(_L("Thread2"), LaunchThread, KDefaultStackSize, KMinHeapSize , KMinHeapSize, NULL)); sl@0: sl@0: // Let them run sl@0: TRequestStatus s1; sl@0: thread1.Logon(s1); sl@0: thread1.Resume(); sl@0: sl@0: TRequestStatus s2; sl@0: thread2.Logon(s2); sl@0: thread2.Resume(); sl@0: sl@0: User::WaitForRequest(s1); sl@0: TEST(thread1.ExitType() != EExitPanic); sl@0: thread1.Close(); sl@0: sl@0: User::WaitForRequest(s2); sl@0: TEST(thread2.ExitType() != EExitPanic); sl@0: thread2.Close(); sl@0: sl@0: TEST2(s1.Int(), KErrNone); sl@0: TEST2(s2.Int(), KErrNone); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0850 sl@0: @SYMTestCaseDesc Tests for invalid database scheme sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create a log event implementation,should leave if there is a problem sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestInvalidSchemaL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0850 ")); sl@0: TestUtils::TestInvalidSchemaL(); sl@0: } sl@0: sl@0: void doTestsL() sl@0: { sl@0: TestUtils::Initialize(_L("t_logapi")); sl@0: sl@0: // This test should be first to ensure no clients kicking around sl@0: TheTest.Next(_L("Invalid database scheme")); sl@0: TestInvalidSchemaL(); sl@0: theLog.Write(_L8("Test 0 OK\n")); sl@0: sl@0: TheTest.Start(_L("Simultaneous Startup")); sl@0: TestStartupL(); sl@0: theLog.Write(_L8("Test 1 OK\n")); sl@0: sl@0: CLogChangeNotifier* notifier = CLogChangeNotifier::NewL(); sl@0: CleanupStack::PushL(notifier); sl@0: sl@0: TheTest.Next(_L("Dying thread test")); sl@0: TestThreadDieL(); sl@0: theLog.Write(_L8("Test 2 OK\n")); sl@0: sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: CLogClient* client = CLogClient::NewL(theFs); sl@0: CleanupStack::PushL(client); sl@0: sl@0: CTestActive* active = new(ELeave) CTestActive(CActive::EPriorityIdle - 500); sl@0: CleanupStack::PushL(active); sl@0: sl@0: TheTest.Next(_L("Additional tests on CLogChangeDefinition.")); sl@0: TestLogChangeDefinitionL(*client); sl@0: theLog.Write(_L8("Test 2.1 OK\n")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: TheTest.Next(_L("Client death")); sl@0: TestClientFailL(); sl@0: theLog.Write(_L8("Test 3 OK\n")); sl@0: sl@0: TheTest.Next(_L("Testing client API")); sl@0: TestNoNotifierL(); sl@0: theLog.Write(_L8("Test 4 OK\n")); sl@0: sl@0: // Delay for testing change notification sl@0: TInt delay = 5000000; sl@0: User::After(delay); sl@0: sl@0: sl@0: active->StartL(); sl@0: client->NotifyChange(delay, active->iStatus); sl@0: sl@0: TheTest.Next(_L("Delete Event Type")); sl@0: TestDeleteEventTypeL(*client); sl@0: theLog.Write(_L8("Test 5 OK\n")); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus.Int() >= 0); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0834 Add Event Type ")); sl@0: TestAddEventTypeL(*client); sl@0: theLog.Write(_L8("Test 6 OK\n")); sl@0: sl@0: // Must delete the database before testing sl@0: // the notification API, since we just created the sl@0: // entry in the previous test (6) and therefore sl@0: // attempting to add the entry again just results in sl@0: // KErrAlreadyExists and does not cause a change to the sl@0: // database. sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: active->StartL(); sl@0: client->NotifyChange(delay, active->iStatus); sl@0: sl@0: TestAddEventTypeL(*client); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus.Int() >= 0); sl@0: active->StartL(); sl@0: client->NotifyChange(delay, active->iStatus); sl@0: sl@0: // The following doesn't make any changes sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0835 Get Event Type ")); sl@0: TestGetEventTypeL(*client); sl@0: theLog.Write(_L8("Test 7 OK\n")); sl@0: sl@0: TheTest.Next(_L("Change Event Type")); sl@0: TestChangeEventTypeL(*client); sl@0: theLog.Write(_L8("Test 8 OK\n")); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus.Int() >= 0); sl@0: active->StartL(); sl@0: client->NotifyChange(delay, active->iStatus); sl@0: sl@0: TheTest.Next(_L("Delete Event Type")); sl@0: TestDeleteEventTypeL(*client); sl@0: theLog.Write(_L8("Test 9 OK\n")); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus.Int() >= 0); sl@0: active->StartL(); sl@0: client->NotifyChange(delay, active->iStatus); sl@0: sl@0: TheTest.Next(_L("Add Event")); sl@0: TestAddEventL(*client); sl@0: theLog.Write(_L8("Test 10 OK\n")); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus.Int() >= 0); sl@0: active->StartL(); sl@0: client->NotifyChange(delay, active->iStatus); sl@0: sl@0: // The following doesn't make any changes sl@0: TheTest.Next(_L("Get Event")); sl@0: TestGetEventL(*client); sl@0: theLog.Write(_L8("Test 11 OK\n")); sl@0: sl@0: TheTest.Next(_L("Change Event")); sl@0: TestChangeEventL(*client); sl@0: theLog.Write(_L8("Test 12 OK\n")); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus.Int() >= 0); sl@0: active->StartL(); sl@0: client->NotifyChange(delay, active->iStatus); sl@0: sl@0: TheTest.Next(_L("Delete Event")); sl@0: TestDeleteEventL(*client); sl@0: theLog.Write(_L8("Test 13 OK\n")); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus.Int() >= 0); sl@0: active->StartL(); sl@0: client->NotifyChange(delay, active->iStatus); sl@0: sl@0: // The following doesn't make any changes sl@0: TheTest.Next(_L("Get Config")); sl@0: TestGetConfigL(*client); sl@0: theLog.Write(_L8("Test 14 OK\n")); sl@0: sl@0: TheTest.Next(_L("Change Config")); sl@0: TestChangeConfigL(*client); sl@0: theLog.Write(_L8("Test 15 OK\n")); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus.Int() >= 0); sl@0: active->StartL(); sl@0: client->NotifyChange(delay*3, active->iStatus); sl@0: sl@0: // The following doesn't make any changes sl@0: TheTest.Next(_L("Get String")); sl@0: TestGetStringL(*client); sl@0: theLog.Write(_L8("Test 16 OK\n")); sl@0: sl@0: TheTest.Next(_L("Clear Event Log")); sl@0: TestClearEventLogL(*client); sl@0: theLog.Write(_L8("Test 17 OK\n")); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST(active->iStatus.Int() >= 0); sl@0: active->StartL(); sl@0: client->NotifyChange(delay, active->iStatus); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0833 Test global change API ")); sl@0: TestClientObserverMechanismL(*client); sl@0: theLog.Write(_L8("Test 18 OK\n")); sl@0: sl@0: TheTest.Next(_L("Multiple client access")); sl@0: TestMultipleClientAccessL(); sl@0: theLog.Write(_L8("Test 19 OK\n")); sl@0: sl@0: theLog.Write(_L8("Destroying: active\n")); sl@0: CleanupStack::PopAndDestroy(active); sl@0: theLog.Write(_L8("Destroyed ok\n")); sl@0: theLog.Write(_L8("Destroying: client\n")); sl@0: CleanupStack::PopAndDestroy(client); sl@0: theLog.Write(_L8("Destroyed ok\n")); sl@0: theLog.Write(_L8("Destroying: notifier\n")); sl@0: CleanupStack::PopAndDestroy(notifier); sl@0: theLog.Write(_L8("Destroyed ok\n")); sl@0: sl@0: sl@0: #ifdef SYSLIBS_TEST sl@0: theLog.Write(_L8("Preparing the context for the test : @SYMTestCaseID:SYSLIB-LOGENG-UT-4015... \n")); sl@0: theLog.Write(_L8("Deleting the Log engine database... \n")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: theLog.Write(_L8("Allocating a new CLogClient object... \n")); sl@0: CLogClient* theClient = CLogClient::NewL(theFs); sl@0: CleanupStack::PushL(theClient); sl@0: TheTest.Next(_L("TestGetConfigSettingsFromRepositoryFileL () ")); sl@0: TestGetConfigSettingsFromRepositoryFileL(*theClient); sl@0: theLog.Write(_L8("TestGetConfigSettingsFromRepositoryFileL () OK\n")); sl@0: theLog.Write(_L8("Destroying the CLogClient object... \n")); sl@0: CleanupStack::PopAndDestroy(theClient); sl@0: theLog.Write(_L8("Destroyed ok\n")); sl@0: #else sl@0: theLog.Write(_L8("The Test PREQ2103 works only when SYSLIBS_TEST macro is defined")); sl@0: #endif sl@0: }