sl@0: sl@0: // Copyright (c) 2005-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: sl@0: #include sl@0: #include sl@0: #include "t_logutil2.h" sl@0: #include sl@0: sl@0: //LOWCAP defined in t_loglowcapability.mmp file. sl@0: #ifdef LOWCAP sl@0: TBool TheHiCapability = EFalse; sl@0: RTest TheTest(_L("t_loglowcapability")); sl@0: _LIT(KTestTitle, "t_loglowcapability"); sl@0: #else sl@0: TBool TheHiCapability = ETrue; sl@0: RTest TheTest(_L("t_loghicapability")); sl@0: _LIT(KTestTitle, "t_loghicapability"); sl@0: #endif 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(KTestDirection1, "Direction"); sl@0: const TLogDurationType KTestDurationType1 = 1; sl@0: const TLogDuration KTestDuration1 = 0x1234; sl@0: _LIT(KTestStatus1, "Status"); sl@0: _LIT(KTestSubject1, "Subject"); sl@0: _LIT(KTestNumber1, "Number"); sl@0: const TLogContactItemId KTestContact1 = 0x1234; sl@0: const TLogContactItemId KTestContact2 = 0x1234567; sl@0: const TLogLink KTestLink1 = 0x1234; sl@0: _LIT8(KTestData1, "ABCDEFGH"); sl@0: const TLogSize KTestMaxLogSize = 0xFFF; sl@0: const TLogRecentSize KTestMaxRecentLogSize = 0xF; sl@0: const TLogAge KTestMaxEventAge = 0xFFFFFFF; sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0118 sl@0: @SYMTestCaseDesc The test aims to ensure that the log server starts in reponse sl@0: to a client request. sl@0: @SYMTestPriority High sl@0: @SYMTestActions The test asks the server for details of a built in event type. sl@0: A successful server start-up is essential for the completion of subsequent tests. sl@0: @SYMTestExpectedResults Success. (active->iStatus == 0) Regardless of the capability sl@0: of the process running this test, it should always succeed because the GetEventType sl@0: is not policed by platform security. sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: LOCAL_C void TestStartupL() sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0118 ")); 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: CLogEventType *type = CLogEventType::NewL(); sl@0: CleanupStack::PushL(type); sl@0: sl@0: type->SetUid(KLogCallEventTypeUid); sl@0: active->StartL(); sl@0: client->GetEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(3); // client, active, type sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0119 sl@0: @SYMTestCaseDesc Tests AddEvent, GetEvent, ChangeEvent and DeleteEvent. sl@0: @SYMTestPriority High sl@0: @SYMTestActions See the description and expected results. sl@0: @SYMTestExpectedResults sl@0: sl@0: 1. a client with sufficient capability succeed in all cases would expect the following... sl@0: AddEvent - KErrNone sl@0: GetEvent - KErrNone sl@0: ChangeEvent - KErrNone sl@0: DeleteEvent - KErrNone sl@0: sl@0: 2. a client with insufficient capability would expect the following results... sl@0: AddEvent - KErrPermissionDenied sl@0: GetEvent - KErrNone sl@0: ChangeEvent - KErrPermissionDenied sl@0: DeleteEvent - KErrPermissionDenied sl@0: sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: LOCAL_C void TestBasicL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0119 ")); 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: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); sl@0: sl@0: if(!TheHiCapability) sl@0: { sl@0: TInt eventId = TestUtils::AddEventL(); sl@0: TEST(eventId >= 0); sl@0: event->SetId(eventId); sl@0: } sl@0: sl@0: sl@0: TEST(event->EventType() == KLogCallEventTypeUid); sl@0: 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: active->StartL(); sl@0: aClient.ChangeEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TheTest.Printf(_L("TestBasicL(), TheHiCapability=%d, event id=%d\r\n"), TheHiCapability, id); sl@0: TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); sl@0: sl@0: TEST(event->Id() == id ); sl@0: TEST(event->EventType() == KLogCallEventTypeUid); sl@0: sl@0: if(TheHiCapability) sl@0: { sl@0: TEST(event->Description().Length() > 0); sl@0: TEST(event->Time() == now); 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: } 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: TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); sl@0: sl@0: if(TheHiCapability) sl@0: { sl@0: TEST(event->Id() == id); sl@0: TEST(event->EventType() == KLogCallEventTypeUid); sl@0: TEST(event->Description().Length() > 0); sl@0: TEST(event->Time() == now); 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: } sl@0: sl@0: active->StartL(); sl@0: aClient.DeleteEvent(id, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), TheHiCapability ? KErrNotFound : KErrPermissionDenied); sl@0: sl@0: // try to delete a non-existent event... sl@0: active->StartL(); sl@0: aClient.DeleteEvent(123, 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: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0120 sl@0: @SYMTestCaseDesc Test AddEventType for high and low capability clients sl@0: @SYMTestPriority High sl@0: @SYMTestActions sl@0: 1. For a clients of all capabilities... sl@0: a. Add a new event type sl@0: b. Fill a CLogEventType object with details of the new type sl@0: c. Try to add the new event type for a second time sl@0: sl@0: @SYMTestExpectedResults sl@0: 1. For a client with sufficient capability... sl@0: Test a. - KErrNone - the new event type was added OK sl@0: Test b. - KErrNone - the new event type is fully visible sl@0: Test c. - KErrAlreadyExists - it was already added by test a. ! sl@0: sl@0: 2. For a client with insufficient capability... sl@0: Test a. - KErrPermissionDenied - not allowed ! sl@0: Test b. - KErrNotFound - allowed, but it isn't there because test a. failed. sl@0: Test c. - KErrPermissionDenied - exactly the same as test a. sl@0: sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: LOCAL_C void TestAddEventTypeL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0120 ")); 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: aClient.AddEventType(*type, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); sl@0: sl@0: active->StartL(); sl@0: aClient.GetEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrNotFound); sl@0: sl@0: active->StartL(); sl@0: aClient.AddEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), TheHiCapability ? KErrAlreadyExists : KErrPermissionDenied); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // active, type sl@0: } sl@0: sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0121 sl@0: @SYMTestCaseDesc Try to populate an CLogEventType object with details of a sl@0: non built-in event type. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Calls GetEventType(...) sl@0: @SYMTestExpectedResults Always succeeds - all clients should be able to do this as sl@0: the GetEventType operation is not policed by platform security. sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: LOCAL_C void TestGetEventTypeL(CLogClient& aClient) sl@0: // sl@0: // This test should succeed, regardless of capability sl@0: // GetEventType is not policed. sl@0: // sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0121 ")); 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: aClient.GetEventType(*type, active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); 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: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0122 sl@0: @SYMTestCaseDesc Tries to change existing event types. sl@0: @SYMTestActions See the description and expected results. sl@0: @SYMTestPriority High sl@0: @SYMTestExpectedResults Should always succeed sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: LOCAL_C void TestChangeEventTypeL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0122 ")); 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: sl@0: type->SetDescription(KTestEventDesc1); sl@0: type->SetDescription(KTestEventDesc2); sl@0: sl@0: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: error = KErrNone; sl@0: sl@0: type->SetDescription(KTestEventDesc2); sl@0: type->SetLoggingEnabled(EFalse); sl@0: sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: sl@0: aClient.ChangeEventType(*type, active->iStatus); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus == KErrNone) sl@0: finished = ETrue; sl@0: else sl@0: error = active->iStatus.Int(); sl@0: sl@0: __UHEAP_RESET; sl@0: sl@0: if (error == KErrNoMemory) 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->Description() == KTestEventDesc1); sl@0: TEST(type->LoggingEnabled()); sl@0: } sl@0: else sl@0: { sl@0: TEST2(error, TheHiCapability ? KErrNone : KErrPermissionDenied); sl@0: sl@0: if(!TheHiCapability) sl@0: finished = TRUE; sl@0: } sl@0: } 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: if(TheHiCapability) sl@0: { sl@0: TEST(type->Uid() == KTestEventUid); sl@0: TEST(type->Description() == KTestEventDesc2); sl@0: TEST(type->LoggingEnabled() == EFalse); sl@0: } sl@0: else sl@0: { sl@0: TEST(type->Uid() == KTestEventUid); sl@0: TEST(type->Description() == KTestEventDesc1); sl@0: TEST(type->LoggingEnabled()); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2); // type, active sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0123 sl@0: @SYMTestCaseDesc Delete event types sl@0: @SYMTestActions See the description and expected results. sl@0: @SYMTestPriority High sl@0: @SYMTestExpectedResults Should always succeed sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: LOCAL_C void TestDeleteEventTypeL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0123 ")); 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: sl@0: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: error = KErrNone; sl@0: sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: aClient.DeleteEventType(KTestEventUid, active->iStatus); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus == KErrNone) sl@0: finished = ETrue; sl@0: else sl@0: error = active->iStatus.Int(); sl@0: sl@0: __UHEAP_RESET; sl@0: sl@0: if (error == KErrNoMemory) 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: else sl@0: { sl@0: TEST2(error, TheHiCapability ? KErrNone : KErrPermissionDenied); sl@0: sl@0: if(!TheHiCapability) sl@0: finished = TRUE; sl@0: } sl@0: } sl@0: sl@0: active->StartL(); sl@0: aClient.GetEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), TheHiCapability ? KErrNotFound : KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(2); // type, active sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0124 sl@0: @SYMTestCaseDesc Try to delete built in event types sl@0: @SYMTestPriority High sl@0: @SYMTestActions No one is allowed to delete built in event types ! sl@0: @SYMTestExpectedResults Should always succeed sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: LOCAL_C void TestDeleteBuiltInEventTypeL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0124 ")); 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: TUid someBuiltInTypes [] = sl@0: { sl@0: KLogCallEventTypeUid, sl@0: KLogDataEventTypeUid, sl@0: KLogFaxEventTypeUid sl@0: }; sl@0: sl@0: for (TInt i=0; i < 3; i++) sl@0: { sl@0: aClient.DeleteEventType(someBuiltInTypes [i], active->iStatus); sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrPermissionDenied); sl@0: sl@0: type->SetUid(someBuiltInTypes [i]); sl@0: active->StartL(); sl@0: aClient.GetEventType(*type, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST(type->Uid() == someBuiltInTypes [i]); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2); // type, active sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0125 sl@0: @SYMTestCaseDesc Get database configuration sl@0: @SYMTestPriority High sl@0: @SYMTestActions All clients are allowed to do this sl@0: @SYMTestExpectedResults Should always succeed sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: LOCAL_C void TestGetConfigL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0125 ")); 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: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: sl@0: while(!finished) sl@0: { sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: aClient.GetConfig(config, active->iStatus); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus == KErrNone) sl@0: finished = ETrue; sl@0: else sl@0: TEST2(active->iStatus.Int(), KErrNoMemory); sl@0: sl@0: __UHEAP_RESET; sl@0: } 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: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0126 sl@0: @SYMTestCaseDesc Change the database configuration sl@0: @SYMTestPriority High sl@0: @SYMTestActions Low capability clients can't do this sl@0: @SYMTestExpectedResults Should always succeed sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: LOCAL_C void TestChangeConfigL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0126 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: TLogConfig configOld; sl@0: sl@0: active->StartL(); sl@0: aClient.GetConfig(configOld, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TLogConfig config; sl@0: sl@0: #ifdef _DEBUG sl@0: TInt failCount = 0; sl@0: #endif sl@0: sl@0: TBool finished = EFalse; sl@0: TInt error; sl@0: sl@0: while(!finished) sl@0: { sl@0: error = KErrNone; sl@0: sl@0: config.iMaxLogSize = KTestMaxLogSize; sl@0: config.iMaxRecentLogSize = KTestMaxRecentLogSize; sl@0: config.iMaxEventAge = KTestMaxEventAge; sl@0: sl@0: __UHEAP_FAILNEXT(failCount++); sl@0: aClient.ChangeConfig(config, active->iStatus); sl@0: sl@0: active->StartL(); sl@0: CActiveScheduler::Start(); sl@0: sl@0: if (active->iStatus == KErrNone) sl@0: finished = ETrue; sl@0: else sl@0: error = active->iStatus.Int(); sl@0: sl@0: __UHEAP_RESET; sl@0: sl@0: if ((error == KErrNoMemory) || (error == KErrPermissionDenied)) sl@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: TEST(config.iMaxLogSize == configOld.iMaxLogSize); sl@0: TEST(config.iMaxRecentLogSize == configOld.iMaxRecentLogSize); sl@0: TEST(config.iMaxEventAge == configOld.iMaxEventAge); sl@0: } sl@0: else sl@0: { sl@0: TEST2(error, KErrNone); sl@0: } sl@0: sl@0: if(! TheHiCapability) sl@0: finished = TRUE; sl@0: sl@0: } sl@0: sl@0: if(TheHiCapability) sl@0: { sl@0: TEST(config.iMaxLogSize == KTestMaxLogSize); sl@0: TEST(config.iMaxRecentLogSize == KTestMaxRecentLogSize); sl@0: TEST(config.iMaxEventAge == KTestMaxEventAge); sl@0: } sl@0: else sl@0: { sl@0: TEST(config.iMaxLogSize == configOld.iMaxLogSize); sl@0: TEST(config.iMaxRecentLogSize == configOld.iMaxRecentLogSize); sl@0: TEST(config.iMaxEventAge == configOld.iMaxEventAge); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(); // active sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0127 sl@0: @SYMTestCaseDesc Clear the log sl@0: @SYMTestPriority High sl@0: @SYMTestActions Low capability clients can't do this sl@0: @SYMTestExpectedResults Should always pass sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: void ClearLogL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0127 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: sl@0: active->StartL(); sl@0: aClient.ClearLog(now, active->iStatus); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); sl@0: sl@0: CleanupStack::PopAndDestroy(); // active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0128 sl@0: @SYMTestCaseDesc Try to clear the recent event list sl@0: @SYMTestPriority High sl@0: @SYMTestActions Low capability clients will fail sl@0: @SYMTestExpectedResults Should always succeed sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: void ClearRecentListL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0128 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: sl@0: active->StartL(); sl@0: aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); sl@0: sl@0: CleanupStack::PopAndDestroy(); // active sl@0: } sl@0: sl@0: #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM sl@0: sl@0: /** sl@0: @SYMTestCaseID PDS-LOGENG-UT-4040 sl@0: @SYMTestCaseDesc Clear log events with specific SimId - platform security test. sl@0: This test is called from two test applications: t_logHicapability sl@0: and t_loglowcapabilty. As the names state, t_loghicapability has platsec capabilities to sl@0: call CLogClient::CLearLog(), t_loglowcapabilty - hasn't. sl@0: When t_loghicapability calls ClearLogL(), "TheHiCapability" flag is true and it is expected sl@0: the CLogClient::ClearLog() call to complete successfully. sl@0: When t_loglowcapability calls ClearLogL(), "TheHiCapability" flag is false and it is expected sl@0: the CLogClient::ClearLog() call to fail with KErrPermissionDenied. sl@0: @SYMTestActions Clear log events with specific SimId - platform security test. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMTestPriority High sl@0: @SYMREQ REQ12748 sl@0: */ sl@0: void ClearLogL(CLogClient& aClient, TSimId aSimId) sl@0: {//This test case is compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined. sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: sl@0: active->StartL(); sl@0: aClient.ClearLog(now, aSimId, active->iStatus); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); sl@0: sl@0: CleanupStack::PopAndDestroy(); // active sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID PDS-LOGENG-UT-4041 sl@0: @SYMTestCaseDesc Clear log events from the specified recent list with specific SimId - platform security test. sl@0: This test is called from two test applications: t_logHicapability sl@0: and t_loglowcapabilty. As the names state, t_loghicapability has platsec capabilities to sl@0: call CLogClient::CLearLog(), t_loglowcapabilty - hasn't. sl@0: When t_loghicapability calls ClearLogL(), "TheHiCapability" flag is true and it is expected sl@0: the CLogClient::ClearLog() call to complete successfully. sl@0: When t_loglowcapability calls ClearLogL(), "TheHiCapability" flag is false and it is expected sl@0: the CLogClient::ClearLog() call to fail with KErrPermissionDenied. sl@0: @SYMTestActions Clear log events from the specified recent list with specific SimId - platform security test. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMTestPriority High sl@0: @SYMREQ REQ12748 sl@0: */ sl@0: void ClearRecentListL(CLogClient& aClient, TSimId aSimId) sl@0: {//This test case is compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined. sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: TTime now; sl@0: now.UniversalTime(); sl@0: sl@0: active->StartL(); sl@0: aClient.ClearLog(KLogRecentIncomingCalls, aSimId, active->iStatus); sl@0: sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied); sl@0: sl@0: CleanupStack::PopAndDestroy(); // active sl@0: } sl@0: sl@0: #endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0129 sl@0: @SYMTestCaseDesc Test that a view only contains events that are suitable for a clients cabability sl@0: @SYMTestPriority High sl@0: @SYMTestActions See comments in the trest code below for further info. sl@0: @SYMTestExpectedResults Should always succeed sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: LOCAL_C void TestEventViewWithFilterL(CLogClient& aClient) sl@0: { sl@0: // TestUtils::AddTestEventsL() --> should be called before this function. sl@0: // It deletes the database, then... sl@0: // adds 8 events - 2 are visible to clients with no capabilities sl@0: // and 6 are of type KLogCallEventTypeUid, which is protected. sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0129 ")); sl@0: CTestActive* active = new(ELeave)CTestActive; sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogFilterList* list = new(ELeave)CLogFilterList; sl@0: CleanupStack::PushL(list); sl@0: sl@0: CLogViewEvent* view = CLogViewEvent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: CLogFilter* filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: sl@0: TLogString direction; sl@0: aClient.GetString(direction, R_LOG_DIR_IN); sl@0: sl@0: // Test 1. sl@0: // Of the 8 new events, 2 have KTestContact1 as the contact field sl@0: // One of them is a secure type and the other isn't. sl@0: // So, if running at hi capability, expect 2 events, else 1 sl@0: TInt expectedEventCount = (TheHiCapability) ? 2 : 1; sl@0: filter->SetContact(KTestContact1); sl@0: list->AppendL(filter); sl@0: active->StartL(); sl@0: TEST(view->SetFilterL(*list, active->iStatus)); sl@0: CActiveScheduler::Start(); sl@0: TEST(view->CountL() == expectedEventCount); sl@0: sl@0: // Test 2. sl@0: // Of the 8 new events, 6 have KTestContact2 as the contact field sl@0: // One of them is a secure type and the other isn't. sl@0: // The filters will be combined in the query, so expect sl@0: // 8 events if running at hi capability, else 2 sl@0: expectedEventCount = (TheHiCapability) ? 8 : 2; sl@0: CleanupStack::Pop(); // filter sl@0: filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetContact(KTestContact2); sl@0: list->AppendL(filter); sl@0: active->StartL(); sl@0: TEST(view->SetFilterL(*list, active->iStatus)); sl@0: CActiveScheduler::Start(); sl@0: TEST(view->CountL() == expectedEventCount); sl@0: sl@0: // Test 3. sl@0: // Of the 8 new events, 7 have R_LOG_DIR_IN as the direction field. sl@0: // Two of these are only visible for hi capability clients, the other one sl@0: // can be viewed by all clients. sl@0: expectedEventCount = (TheHiCapability) ? 7 : 1; sl@0: CleanupStack::Pop(); // filter sl@0: filter = CLogFilter::NewL(); sl@0: CleanupStack::PushL(filter); sl@0: filter->SetDirection(direction); sl@0: list->AppendL(filter); sl@0: active->StartL(); sl@0: TEST(view->SetFilterL(*list, active->iStatus)); sl@0: CActiveScheduler::Start(); sl@0: TEST(view->CountL() == expectedEventCount); sl@0: sl@0: // clear up... sl@0: list->ResetAndDestroy(); sl@0: CleanupStack::Pop(); // filter sl@0: CleanupStack::PopAndDestroy(3); // view, list, active sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-0130 sl@0: @SYMTestCaseDesc Test the clients ability to view recent events sl@0: @SYMTestActions See the description and expected results. sl@0: @SYMTestPriority High sl@0: @SYMTestExpectedResults Should always succeed sl@0: @SYMREQ REQ3431 sl@0: */ sl@0: LOCAL_C void TestRecentViewL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0130 ")); sl@0: CTestActive* active = new(ELeave)CTestActive(); sl@0: CleanupStack::PushL(active); sl@0: sl@0: CLogViewRecent* view = CLogViewRecent::NewL(aClient); sl@0: CleanupStack::PushL(view); sl@0: sl@0: active->StartL(); sl@0: sl@0: // will return FALSE if the view is empty, which should be the case sl@0: // with low/no capability clients. sl@0: if (view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus)) sl@0: { sl@0: __ASSERT_ALWAYS(TheHiCapability, _L("TestRecentViewL")); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: TEST(view->CountL() == 2); sl@0: TInt count = view->CountL(); sl@0: } sl@0: else // low capability client won't be able to see recent incoming calls sl@0: { sl@0: __ASSERT_ALWAYS(!TheHiCapability, _L("TestRecentViewL")); sl@0: active->Cancel(); sl@0: } sl@0: sl@0: CleanupStack::PopAndDestroy(2); // view, active sl@0: } sl@0: sl@0: //............................................................................. sl@0: sl@0: void doTestsL() sl@0: { sl@0: TestUtils::Initialize(KTestTitle); sl@0: sl@0: TheTest.Start(_L("Starting tests...")); sl@0: sl@0: CLogClient* client = CLogClient::NewL(theFs); sl@0: CleanupStack::PushL(client); sl@0: sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: TheTest.Next(_L("Server startup")); sl@0: TestStartupL(); sl@0: User::After(100000); sl@0: sl@0: TheTest.Next(_L("Test Add, Get, Change & Delete event")); sl@0: TestUtils::DeleteDatabaseL(); sl@0: TestBasicL(*client); sl@0: theLog.Write(_L8("Basic tests OK\n")); sl@0: sl@0: TheTest.Next(_L("Add Event Type")); sl@0: TestAddEventTypeL(*client); sl@0: theLog.Write(_L8("Add Event Type test OK\n")); sl@0: sl@0: if(!TheHiCapability) sl@0: { sl@0: // TestAddEventTypeL() will have failed to add an event type, so sl@0: // this will ensure one is present for the next tests. sl@0: TestUtils::AddEventTypeL(); sl@0: } sl@0: sl@0: TheTest.Next(_L("Get Event Type")); sl@0: TestGetEventTypeL(*client); sl@0: theLog.Write(_L8("Get Event Type test OK\n")); sl@0: sl@0: TheTest.Next(_L("Change Event Type")); sl@0: TestChangeEventTypeL(*client); sl@0: theLog.Write(_L8("Change Event Type test OK\n")); sl@0: sl@0: TheTest.Next(_L("Delete Event Type")); sl@0: TestDeleteEventTypeL(*client); sl@0: theLog.Write(_L8("Delete Event Type test OK\n")); sl@0: sl@0: TheTest.Next(_L("Delete Built-in Event Type")); sl@0: TestDeleteBuiltInEventTypeL(*client); sl@0: theLog.Write(_L8("Delete Built-in Event Type test OK\n")); sl@0: sl@0: TheTest.Next(_L("Get Server Configuration")); sl@0: TestGetConfigL(*client); sl@0: theLog.Write(_L8("Get Server Configuration test OK\n")); sl@0: sl@0: TheTest.Next(_L("Change Server Configuration")); sl@0: TestChangeConfigL(*client); sl@0: theLog.Write(_L8("Change Server Configuration test OK\n")); sl@0: sl@0: TheTest.Next(_L("Clear the Log test")); sl@0: ClearLogL(*client); sl@0: theLog.Write(_L8("Clear the Log test OK\n")); sl@0: sl@0: TheTest.Next(_L("Clear Recent List test")); sl@0: ClearRecentListL(*client); sl@0: theLog.Write(_L8("Clear Recent List test OK\n")); sl@0: sl@0: #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM sl@0: const TSimId KSimId = 4000000000U; sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4040 Clear the \"Log + SimId\" test")); sl@0: ClearLogL(*client, KSimId); sl@0: theLog.Write(_L8("Clear the \"Log + SimId\" test OK\n")); sl@0: sl@0: TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4041 Clear \"Recent List + SimId\" test")); sl@0: ClearRecentListL(*client, KSimId); sl@0: theLog.Write(_L8("Clear \"Recent List + SimId\" test OK\n")); sl@0: #endif sl@0: sl@0: // sl@0: // View API tests below this sl@0: // sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: // TestUtils::AddTestEventsL() --> adds 8 events. sl@0: // 2 are visible to clients with no capabilities sl@0: // and 6 are of type KLogCallEventTypeUid, which is protected. sl@0: TestUtils::AddViewTestEventsL(); sl@0: sl@0: TheTest.Next(_L("Event View with Filter list")); sl@0: TestEventViewWithFilterL(*client); sl@0: theLog.Write(_L8("Event View with Filter list test OK\n")); sl@0: sl@0: TheTest.Next(_L("Recent View")); sl@0: TestRecentViewL(*client); sl@0: theLog.Write(_L8("Recent View test OK\n")); sl@0: sl@0: TestUtils::DeleteDatabaseL(); // ready for next test sl@0: sl@0: CleanupStack::PopAndDestroy(); // client sl@0: }