1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/loggingservices/eventlogger/test/src/t_logplatformsecurity.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1018 @@
1.4 +
1.5 +// Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
1.6 +// All rights reserved.
1.7 +// This component and the accompanying materials are made available
1.8 +// under the terms of "Eclipse Public License v1.0"
1.9 +// which accompanies this distribution, and is available
1.10 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +//
1.12 +// Initial Contributors:
1.13 +// Nokia Corporation - initial contribution.
1.14 +//
1.15 +// Contributors:
1.16 +//
1.17 +// Description:
1.18 +//
1.19 +
1.20 +
1.21 +#include <s32file.h>
1.22 +#include <logcntdef.h>
1.23 +#include "t_logutil2.h"
1.24 +#include <logview.h>
1.25 +
1.26 +//LOWCAP defined in t_loglowcapability.mmp file.
1.27 +#ifdef LOWCAP
1.28 + TBool TheHiCapability = EFalse;
1.29 + RTest TheTest(_L("t_loglowcapability"));
1.30 + _LIT(KTestTitle, "t_loglowcapability");
1.31 +#else
1.32 + TBool TheHiCapability = ETrue;
1.33 + RTest TheTest(_L("t_loghicapability"));
1.34 + _LIT(KTestTitle, "t_loghicapability");
1.35 +#endif
1.36 +
1.37 +const TUid KTestEventUid = {0x10005393};
1.38 +_LIT(KTestEventDesc1, "Event Type Description");
1.39 +_LIT(KTestEventDesc2, "Changed Event Description");
1.40 +_LIT(KTestRemoteParty1, "Remote Party");
1.41 +_LIT(KTestDirection1, "Direction");
1.42 +const TLogDurationType KTestDurationType1 = 1;
1.43 +const TLogDuration KTestDuration1 = 0x1234;
1.44 +_LIT(KTestStatus1, "Status");
1.45 +_LIT(KTestSubject1, "Subject");
1.46 +_LIT(KTestNumber1, "Number");
1.47 +const TLogContactItemId KTestContact1 = 0x1234;
1.48 +const TLogContactItemId KTestContact2 = 0x1234567;
1.49 +const TLogLink KTestLink1 = 0x1234;
1.50 +_LIT8(KTestData1, "ABCDEFGH");
1.51 +const TLogSize KTestMaxLogSize = 0xFFF;
1.52 +const TLogRecentSize KTestMaxRecentLogSize = 0xF;
1.53 +const TLogAge KTestMaxEventAge = 0xFFFFFFF;
1.54 +
1.55 +
1.56 +/**
1.57 +@SYMTestCaseID SYSLIB-LOGENG-CT-0118
1.58 +@SYMTestCaseDesc The test aims to ensure that the log server starts in reponse
1.59 +to a client request.
1.60 +@SYMTestPriority High
1.61 +@SYMTestActions The test asks the server for details of a built in event type.
1.62 +A successful server start-up is essential for the completion of subsequent tests.
1.63 +@SYMTestExpectedResults Success. (active->iStatus == 0) Regardless of the capability
1.64 +of the process running this test, it should always succeed because the GetEventType
1.65 +is not policed by platform security.
1.66 +@SYMREQ REQ3431
1.67 +*/
1.68 +LOCAL_C void TestStartupL()
1.69 + {
1.70 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0118 "));
1.71 + CLogClient* client = CLogClient::NewL(theFs);
1.72 + CleanupStack::PushL(client);
1.73 +
1.74 + CTestActive* active = new(ELeave)CTestActive();
1.75 + CleanupStack::PushL(active);
1.76 +
1.77 + CLogEventType *type = CLogEventType::NewL();
1.78 + CleanupStack::PushL(type);
1.79 +
1.80 + type->SetUid(KLogCallEventTypeUid);
1.81 + active->StartL();
1.82 + client->GetEventType(*type, active->iStatus);
1.83 + CActiveScheduler::Start();
1.84 + TEST2(active->iStatus.Int(), KErrNone);
1.85 +
1.86 + CleanupStack::PopAndDestroy(3); // client, active, type
1.87 + }
1.88 +
1.89 +
1.90 +
1.91 +
1.92 +/**
1.93 +@SYMTestCaseID SYSLIB-LOGENG-CT-0119
1.94 +@SYMTestCaseDesc Tests AddEvent, GetEvent, ChangeEvent and DeleteEvent.
1.95 +@SYMTestPriority High
1.96 +@SYMTestActions See the description and expected results.
1.97 +@SYMTestExpectedResults
1.98 +
1.99 +1. a client with sufficient capability succeed in all cases would expect the following...
1.100 +AddEvent - KErrNone
1.101 +GetEvent - KErrNone
1.102 +ChangeEvent - KErrNone
1.103 +DeleteEvent - KErrNone
1.104 +
1.105 +2. a client with insufficient capability would expect the following results...
1.106 +AddEvent - KErrPermissionDenied
1.107 +GetEvent - KErrNone
1.108 +ChangeEvent - KErrPermissionDenied
1.109 +DeleteEvent - KErrPermissionDenied
1.110 +
1.111 +@SYMREQ REQ3431
1.112 +*/
1.113 +LOCAL_C void TestBasicL(CLogClient& aClient)
1.114 + {
1.115 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0119 "));
1.116 + CTestActive* active = new(ELeave)CTestActive();
1.117 + CleanupStack::PushL(active);
1.118 +
1.119 + CLogEvent* event = CLogEvent::NewL();
1.120 + CleanupStack::PushL(event);
1.121 +
1.122 + TTime now;
1.123 + now.UniversalTime();
1.124 +
1.125 + event->SetEventType(KLogCallEventTypeUid);
1.126 +
1.127 + active->StartL();
1.128 + aClient.AddEvent(*event, active->iStatus);
1.129 + CActiveScheduler::Start();
1.130 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied);
1.131 +
1.132 + if(!TheHiCapability)
1.133 + {
1.134 + TInt eventId = TestUtils::AddEventL();
1.135 + TEST(eventId >= 0);
1.136 + event->SetId(eventId);
1.137 + }
1.138 +
1.139 +
1.140 + TEST(event->EventType() == KLogCallEventTypeUid);
1.141 +
1.142 + now = event->Time();
1.143 +
1.144 + TLogId id = event->Id();
1.145 +
1.146 + event->SetRemoteParty(KTestRemoteParty1);
1.147 + event->SetDirection(KTestDirection1);
1.148 + event->SetDurationType(KTestDurationType1);
1.149 + event->SetDuration(KTestDuration1);
1.150 + event->SetStatus(KTestStatus1);
1.151 + event->SetSubject(KTestSubject1);
1.152 + event->SetNumber(KTestNumber1);
1.153 + event->SetContact(KTestContact1);
1.154 + event->SetLink(KTestLink1);
1.155 + event->SetDataL(KTestData1);
1.156 +
1.157 + active->StartL();
1.158 + aClient.ChangeEvent(*event, active->iStatus);
1.159 + CActiveScheduler::Start();
1.160 + TheTest.Printf(_L("TestBasicL(), TheHiCapability=%d, event id=%d\r\n"), TheHiCapability, id);
1.161 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied);
1.162 +
1.163 + TEST(event->Id() == id );
1.164 + TEST(event->EventType() == KLogCallEventTypeUid);
1.165 +
1.166 + if(TheHiCapability)
1.167 + {
1.168 + TEST(event->Description().Length() > 0);
1.169 + TEST(event->Time() == now);
1.170 + TEST(event->RemoteParty() == KTestRemoteParty1);
1.171 + TEST(event->Direction() == KTestDirection1);
1.172 + TEST(event->DurationType() == KTestDurationType1);
1.173 + TEST(event->Duration() == KTestDuration1);
1.174 + TEST(event->Status() == KTestStatus1);
1.175 + TEST(event->Subject() == KTestSubject1);
1.176 + TEST(event->Number() == KTestNumber1);
1.177 + TEST(event->Contact() == KTestContact1);
1.178 + TEST(event->Link() == KTestLink1);
1.179 + TEST(event->Data() == KTestData1);
1.180 + }
1.181 +
1.182 + CleanupStack::PopAndDestroy(); // event;
1.183 +
1.184 + event = CLogEvent::NewL();
1.185 + CleanupStack::PushL(event);
1.186 +
1.187 + event->SetId(id);
1.188 +
1.189 + active->StartL();
1.190 + aClient.GetEvent(*event, active->iStatus);
1.191 + CActiveScheduler::Start();
1.192 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied);
1.193 +
1.194 + if(TheHiCapability)
1.195 + {
1.196 + TEST(event->Id() == id);
1.197 + TEST(event->EventType() == KLogCallEventTypeUid);
1.198 + TEST(event->Description().Length() > 0);
1.199 + TEST(event->Time() == now);
1.200 + TEST(event->RemoteParty() == KTestRemoteParty1);
1.201 + TEST(event->Direction() == KTestDirection1);
1.202 + TEST(event->DurationType() == KTestDurationType1);
1.203 + TEST(event->Duration() == KTestDuration1);
1.204 + TEST(event->Status() == KTestStatus1);
1.205 + TEST(event->Subject() == KTestSubject1);
1.206 + TEST(event->Number() == KTestNumber1);
1.207 + TEST(event->Contact() == KTestContact1);
1.208 + TEST(event->Link() == KTestLink1);
1.209 + TEST(event->Data() == KTestData1);
1.210 + }
1.211 +
1.212 + active->StartL();
1.213 + aClient.DeleteEvent(id, active->iStatus);
1.214 + CActiveScheduler::Start();
1.215 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied);
1.216 +
1.217 + active->StartL();
1.218 + aClient.GetEvent(*event, active->iStatus);
1.219 + CActiveScheduler::Start();
1.220 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrNotFound : KErrPermissionDenied);
1.221 +
1.222 + // try to delete a non-existent event...
1.223 + active->StartL();
1.224 + aClient.DeleteEvent(123, active->iStatus);
1.225 + CActiveScheduler::Start();
1.226 + TEST2(active->iStatus.Int(), KErrNotFound);
1.227 +
1.228 + CleanupStack::PopAndDestroy(2); // event, active
1.229 + }
1.230 +
1.231 +
1.232 +
1.233 +/**
1.234 +@SYMTestCaseID SYSLIB-LOGENG-CT-0120
1.235 +@SYMTestCaseDesc Test AddEventType for high and low capability clients
1.236 +@SYMTestPriority High
1.237 +@SYMTestActions
1.238 +1. For a clients of all capabilities...
1.239 + a. Add a new event type
1.240 + b. Fill a CLogEventType object with details of the new type
1.241 + c. Try to add the new event type for a second time
1.242 +
1.243 +@SYMTestExpectedResults
1.244 +1. For a client with sufficient capability...
1.245 + Test a. - KErrNone - the new event type was added OK
1.246 + Test b. - KErrNone - the new event type is fully visible
1.247 + Test c. - KErrAlreadyExists - it was already added by test a. !
1.248 +
1.249 +2. For a client with insufficient capability...
1.250 + Test a. - KErrPermissionDenied - not allowed !
1.251 + Test b. - KErrNotFound - allowed, but it isn't there because test a. failed.
1.252 + Test c. - KErrPermissionDenied - exactly the same as test a.
1.253 +
1.254 +@SYMREQ REQ3431
1.255 +*/
1.256 +LOCAL_C void TestAddEventTypeL(CLogClient& aClient)
1.257 + {
1.258 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0120 "));
1.259 + CLogEventType* type = CLogEventType::NewL();
1.260 + CleanupStack::PushL(type);
1.261 +
1.262 + type->SetUid(KTestEventUid);
1.263 + type->SetDescription(KTestEventDesc1);
1.264 + type->SetLoggingEnabled(ETrue);
1.265 +
1.266 + CTestActive* active = new(ELeave)CTestActive();
1.267 + CleanupStack::PushL(active);
1.268 +
1.269 + aClient.AddEventType(*type, active->iStatus);
1.270 + active->StartL();
1.271 + CActiveScheduler::Start();
1.272 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied);
1.273 +
1.274 + active->StartL();
1.275 + aClient.GetEventType(*type, active->iStatus);
1.276 + CActiveScheduler::Start();
1.277 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrNotFound);
1.278 +
1.279 + active->StartL();
1.280 + aClient.AddEventType(*type, active->iStatus);
1.281 + CActiveScheduler::Start();
1.282 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrAlreadyExists : KErrPermissionDenied);
1.283 +
1.284 + CleanupStack::PopAndDestroy(2); // active, type
1.285 + }
1.286 +
1.287 +
1.288 +
1.289 +/**
1.290 +@SYMTestCaseID SYSLIB-LOGENG-CT-0121
1.291 +@SYMTestCaseDesc Try to populate an CLogEventType object with details of a
1.292 +non built-in event type.
1.293 +@SYMTestPriority High
1.294 +@SYMTestActions Calls GetEventType(...)
1.295 +@SYMTestExpectedResults Always succeeds - all clients should be able to do this as
1.296 +the GetEventType operation is not policed by platform security.
1.297 +@SYMREQ REQ3431
1.298 +*/
1.299 +LOCAL_C void TestGetEventTypeL(CLogClient& aClient)
1.300 + //
1.301 + // This test should succeed, regardless of capability
1.302 + // GetEventType is not policed.
1.303 + //
1.304 + {
1.305 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0121 "));
1.306 + CLogEventType* type = CLogEventType::NewL();
1.307 + CleanupStack::PushL(type);
1.308 +
1.309 + type->SetUid(KTestEventUid);
1.310 +
1.311 + CTestActive* active = new(ELeave)CTestActive();
1.312 + CleanupStack::PushL(active);
1.313 +
1.314 + aClient.GetEventType(*type, active->iStatus);
1.315 + active->StartL();
1.316 + CActiveScheduler::Start();
1.317 + TEST2(active->iStatus.Int(), KErrNone);
1.318 +
1.319 + TEST(type->Uid() == KTestEventUid);
1.320 + TEST(type->Description() == KTestEventDesc1);
1.321 + TEST(type->LoggingEnabled());
1.322 +
1.323 + CleanupStack::PopAndDestroy(2); // active, type
1.324 + }
1.325 +
1.326 +
1.327 +
1.328 +
1.329 +/**
1.330 +@SYMTestCaseID SYSLIB-LOGENG-CT-0122
1.331 +@SYMTestCaseDesc Tries to change existing event types.
1.332 +@SYMTestActions See the description and expected results.
1.333 +@SYMTestPriority High
1.334 +@SYMTestExpectedResults Should always succeed
1.335 +@SYMREQ REQ3431
1.336 +*/
1.337 +LOCAL_C void TestChangeEventTypeL(CLogClient& aClient)
1.338 + {
1.339 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0122 "));
1.340 + CTestActive* active = new(ELeave)CTestActive();
1.341 + CleanupStack::PushL(active);
1.342 +
1.343 + CLogEventType* type = CLogEventType::NewL();
1.344 + CleanupStack::PushL(type);
1.345 +
1.346 + type->SetUid(KTestEventUid);
1.347 +
1.348 + type->SetDescription(KTestEventDesc1);
1.349 + type->SetDescription(KTestEventDesc2);
1.350 +
1.351 +#ifdef _DEBUG
1.352 + TInt failCount = 0;
1.353 +#endif
1.354 +
1.355 + TBool finished = EFalse;
1.356 + TInt error;
1.357 +
1.358 + while(!finished)
1.359 + {
1.360 + error = KErrNone;
1.361 +
1.362 + type->SetDescription(KTestEventDesc2);
1.363 + type->SetLoggingEnabled(EFalse);
1.364 +
1.365 + __UHEAP_FAILNEXT(failCount++);
1.366 +
1.367 + aClient.ChangeEventType(*type, active->iStatus);
1.368 +
1.369 + active->StartL();
1.370 + CActiveScheduler::Start();
1.371 +
1.372 + if (active->iStatus == KErrNone)
1.373 + finished = ETrue;
1.374 + else
1.375 + error = active->iStatus.Int();
1.376 +
1.377 + __UHEAP_RESET;
1.378 +
1.379 + if (error == KErrNoMemory)
1.380 + {
1.381 + active->StartL();
1.382 + aClient.GetEventType(*type, active->iStatus);
1.383 + CActiveScheduler::Start();
1.384 + TEST2(active->iStatus.Int(), KErrNone);
1.385 +
1.386 + TEST(type->Description() == KTestEventDesc1);
1.387 + TEST(type->LoggingEnabled());
1.388 + }
1.389 + else
1.390 + {
1.391 + TEST2(error, TheHiCapability ? KErrNone : KErrPermissionDenied);
1.392 +
1.393 + if(!TheHiCapability)
1.394 + finished = TRUE;
1.395 + }
1.396 + }
1.397 +
1.398 + type->SetUid(KTestEventUid);
1.399 +
1.400 + active->StartL();
1.401 + aClient.GetEventType(*type, active->iStatus);
1.402 + CActiveScheduler::Start();
1.403 + TEST2(active->iStatus.Int(), KErrNone);
1.404 +
1.405 + if(TheHiCapability)
1.406 + {
1.407 + TEST(type->Uid() == KTestEventUid);
1.408 + TEST(type->Description() == KTestEventDesc2);
1.409 + TEST(type->LoggingEnabled() == EFalse);
1.410 + }
1.411 + else
1.412 + {
1.413 + TEST(type->Uid() == KTestEventUid);
1.414 + TEST(type->Description() == KTestEventDesc1);
1.415 + TEST(type->LoggingEnabled());
1.416 + }
1.417 +
1.418 + CleanupStack::PopAndDestroy(2); // type, active
1.419 + }
1.420 +
1.421 +
1.422 +
1.423 +
1.424 +/**
1.425 +@SYMTestCaseID SYSLIB-LOGENG-CT-0123
1.426 +@SYMTestCaseDesc Delete event types
1.427 +@SYMTestActions See the description and expected results.
1.428 +@SYMTestPriority High
1.429 +@SYMTestExpectedResults Should always succeed
1.430 +@SYMREQ REQ3431
1.431 +*/
1.432 +LOCAL_C void TestDeleteEventTypeL(CLogClient& aClient)
1.433 + {
1.434 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0123 "));
1.435 + CTestActive* active = new(ELeave)CTestActive();
1.436 + CleanupStack::PushL(active);
1.437 +
1.438 + CLogEventType* type = CLogEventType::NewL();
1.439 + CleanupStack::PushL(type);
1.440 +
1.441 + type->SetUid(KTestEventUid);
1.442 +
1.443 +#ifdef _DEBUG
1.444 + TInt failCount = 0;
1.445 +#endif
1.446 +
1.447 + TBool finished = EFalse;
1.448 + TInt error;
1.449 +
1.450 + while(!finished)
1.451 + {
1.452 + error = KErrNone;
1.453 +
1.454 + __UHEAP_FAILNEXT(failCount++);
1.455 + aClient.DeleteEventType(KTestEventUid, active->iStatus);
1.456 +
1.457 + active->StartL();
1.458 + CActiveScheduler::Start();
1.459 +
1.460 + if (active->iStatus == KErrNone)
1.461 + finished = ETrue;
1.462 + else
1.463 + error = active->iStatus.Int();
1.464 +
1.465 + __UHEAP_RESET;
1.466 +
1.467 + if (error == KErrNoMemory)
1.468 + {
1.469 + active->StartL();
1.470 + aClient.GetEventType(*type, active->iStatus);
1.471 + CActiveScheduler::Start();
1.472 + TEST2(active->iStatus.Int(), KErrNone);
1.473 + }
1.474 + else
1.475 + {
1.476 + TEST2(error, TheHiCapability ? KErrNone : KErrPermissionDenied);
1.477 +
1.478 + if(!TheHiCapability)
1.479 + finished = TRUE;
1.480 + }
1.481 + }
1.482 +
1.483 + active->StartL();
1.484 + aClient.GetEventType(*type, active->iStatus);
1.485 + CActiveScheduler::Start();
1.486 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrNotFound : KErrNone);
1.487 +
1.488 + CleanupStack::PopAndDestroy(2); // type, active
1.489 + }
1.490 +
1.491 +
1.492 +
1.493 +
1.494 +/**
1.495 +@SYMTestCaseID SYSLIB-LOGENG-CT-0124
1.496 +@SYMTestCaseDesc Try to delete built in event types
1.497 +@SYMTestPriority High
1.498 +@SYMTestActions No one is allowed to delete built in event types !
1.499 +@SYMTestExpectedResults Should always succeed
1.500 +@SYMREQ REQ3431
1.501 +*/
1.502 +LOCAL_C void TestDeleteBuiltInEventTypeL(CLogClient& aClient)
1.503 + {
1.504 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0124 "));
1.505 + CTestActive* active = new(ELeave)CTestActive();
1.506 + CleanupStack::PushL(active);
1.507 +
1.508 + CLogEventType* type = CLogEventType::NewL();
1.509 + CleanupStack::PushL(type);
1.510 +
1.511 + TUid someBuiltInTypes [] =
1.512 + {
1.513 + KLogCallEventTypeUid,
1.514 + KLogDataEventTypeUid,
1.515 + KLogFaxEventTypeUid
1.516 + };
1.517 +
1.518 + for (TInt i=0; i < 3; i++)
1.519 + {
1.520 + aClient.DeleteEventType(someBuiltInTypes [i], active->iStatus);
1.521 + active->StartL();
1.522 + CActiveScheduler::Start();
1.523 + TEST2(active->iStatus.Int(), KErrPermissionDenied);
1.524 +
1.525 + type->SetUid(someBuiltInTypes [i]);
1.526 + active->StartL();
1.527 + aClient.GetEventType(*type, active->iStatus);
1.528 + CActiveScheduler::Start();
1.529 + TEST2(active->iStatus.Int(), KErrNone);
1.530 + TEST(type->Uid() == someBuiltInTypes [i]);
1.531 + }
1.532 +
1.533 + CleanupStack::PopAndDestroy(2); // type, active
1.534 + }
1.535 +
1.536 +
1.537 +
1.538 +
1.539 +
1.540 +/**
1.541 +@SYMTestCaseID SYSLIB-LOGENG-CT-0125
1.542 +@SYMTestCaseDesc Get database configuration
1.543 +@SYMTestPriority High
1.544 +@SYMTestActions All clients are allowed to do this
1.545 +@SYMTestExpectedResults Should always succeed
1.546 +@SYMREQ REQ3431
1.547 +*/
1.548 +LOCAL_C void TestGetConfigL(CLogClient& aClient)
1.549 + {
1.550 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0125 "));
1.551 + CTestActive* active = new(ELeave)CTestActive();
1.552 + CleanupStack::PushL(active);
1.553 +
1.554 + TLogConfig config;
1.555 +
1.556 + TEST(config.iMaxEventAge == 0);
1.557 + TEST(config.iMaxLogSize == 0);
1.558 + TEST(config.iMaxRecentLogSize == 0);
1.559 +
1.560 +#ifdef _DEBUG
1.561 + TInt failCount = 0;
1.562 +#endif
1.563 +
1.564 + TBool finished = EFalse;
1.565 +
1.566 + while(!finished)
1.567 + {
1.568 + __UHEAP_FAILNEXT(failCount++);
1.569 + aClient.GetConfig(config, active->iStatus);
1.570 +
1.571 + active->StartL();
1.572 + CActiveScheduler::Start();
1.573 +
1.574 + if (active->iStatus == KErrNone)
1.575 + finished = ETrue;
1.576 + else
1.577 + TEST2(active->iStatus.Int(), KErrNoMemory);
1.578 +
1.579 + __UHEAP_RESET;
1.580 + }
1.581 +
1.582 + TEST(config.iMaxEventAge > 0);
1.583 + TEST(config.iMaxLogSize > 0);
1.584 + TEST(config.iMaxRecentLogSize > 0);
1.585 +
1.586 + CleanupStack::PopAndDestroy(); // active
1.587 + }
1.588 +
1.589 +
1.590 +
1.591 +
1.592 +/**
1.593 +@SYMTestCaseID SYSLIB-LOGENG-CT-0126
1.594 +@SYMTestCaseDesc Change the database configuration
1.595 +@SYMTestPriority High
1.596 +@SYMTestActions Low capability clients can't do this
1.597 +@SYMTestExpectedResults Should always succeed
1.598 +@SYMREQ REQ3431
1.599 +*/
1.600 +LOCAL_C void TestChangeConfigL(CLogClient& aClient)
1.601 + {
1.602 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0126 "));
1.603 + CTestActive* active = new(ELeave)CTestActive();
1.604 + CleanupStack::PushL(active);
1.605 +
1.606 + TLogConfig configOld;
1.607 +
1.608 + active->StartL();
1.609 + aClient.GetConfig(configOld, active->iStatus);
1.610 + CActiveScheduler::Start();
1.611 + TEST2(active->iStatus.Int(), KErrNone);
1.612 +
1.613 + TLogConfig config;
1.614 +
1.615 +#ifdef _DEBUG
1.616 + TInt failCount = 0;
1.617 +#endif
1.618 +
1.619 + TBool finished = EFalse;
1.620 + TInt error;
1.621 +
1.622 + while(!finished)
1.623 + {
1.624 + error = KErrNone;
1.625 +
1.626 + config.iMaxLogSize = KTestMaxLogSize;
1.627 + config.iMaxRecentLogSize = KTestMaxRecentLogSize;
1.628 + config.iMaxEventAge = KTestMaxEventAge;
1.629 +
1.630 + __UHEAP_FAILNEXT(failCount++);
1.631 + aClient.ChangeConfig(config, active->iStatus);
1.632 +
1.633 + active->StartL();
1.634 + CActiveScheduler::Start();
1.635 +
1.636 + if (active->iStatus == KErrNone)
1.637 + finished = ETrue;
1.638 + else
1.639 + error = active->iStatus.Int();
1.640 +
1.641 + __UHEAP_RESET;
1.642 +
1.643 + if ((error == KErrNoMemory) || (error == KErrPermissionDenied))
1.644 + {
1.645 + active->StartL();
1.646 + aClient.GetConfig(config, active->iStatus);
1.647 + CActiveScheduler::Start();
1.648 + TEST2(active->iStatus.Int(), KErrNone);
1.649 +
1.650 + TEST(config.iMaxLogSize == configOld.iMaxLogSize);
1.651 + TEST(config.iMaxRecentLogSize == configOld.iMaxRecentLogSize);
1.652 + TEST(config.iMaxEventAge == configOld.iMaxEventAge);
1.653 + }
1.654 + else
1.655 + {
1.656 + TEST2(error, KErrNone);
1.657 + }
1.658 +
1.659 + if(! TheHiCapability)
1.660 + finished = TRUE;
1.661 +
1.662 + }
1.663 +
1.664 + if(TheHiCapability)
1.665 + {
1.666 + TEST(config.iMaxLogSize == KTestMaxLogSize);
1.667 + TEST(config.iMaxRecentLogSize == KTestMaxRecentLogSize);
1.668 + TEST(config.iMaxEventAge == KTestMaxEventAge);
1.669 + }
1.670 + else
1.671 + {
1.672 + TEST(config.iMaxLogSize == configOld.iMaxLogSize);
1.673 + TEST(config.iMaxRecentLogSize == configOld.iMaxRecentLogSize);
1.674 + TEST(config.iMaxEventAge == configOld.iMaxEventAge);
1.675 + }
1.676 +
1.677 + CleanupStack::PopAndDestroy(); // active
1.678 + }
1.679 +
1.680 +
1.681 +
1.682 +
1.683 +/**
1.684 +@SYMTestCaseID SYSLIB-LOGENG-CT-0127
1.685 +@SYMTestCaseDesc Clear the log
1.686 +@SYMTestPriority High
1.687 +@SYMTestActions Low capability clients can't do this
1.688 +@SYMTestExpectedResults Should always pass
1.689 +@SYMREQ REQ3431
1.690 +*/
1.691 +void ClearLogL(CLogClient& aClient)
1.692 + {
1.693 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0127 "));
1.694 + CTestActive* active = new(ELeave)CTestActive();
1.695 + CleanupStack::PushL(active);
1.696 +
1.697 + TTime now;
1.698 + now.UniversalTime();
1.699 +
1.700 + active->StartL();
1.701 + aClient.ClearLog(now, active->iStatus);
1.702 +
1.703 + CActiveScheduler::Start();
1.704 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied);
1.705 +
1.706 + CleanupStack::PopAndDestroy(); // active
1.707 + }
1.708 +
1.709 +/**
1.710 +@SYMTestCaseID SYSLIB-LOGENG-CT-0128
1.711 +@SYMTestCaseDesc Try to clear the recent event list
1.712 +@SYMTestPriority High
1.713 +@SYMTestActions Low capability clients will fail
1.714 +@SYMTestExpectedResults Should always succeed
1.715 +@SYMREQ REQ3431
1.716 +*/
1.717 +void ClearRecentListL(CLogClient& aClient)
1.718 + {
1.719 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0128 "));
1.720 + CTestActive* active = new(ELeave)CTestActive();
1.721 + CleanupStack::PushL(active);
1.722 +
1.723 + TTime now;
1.724 + now.UniversalTime();
1.725 +
1.726 + active->StartL();
1.727 + aClient.ClearLog(KLogRecentIncomingCalls, active->iStatus);
1.728 +
1.729 + CActiveScheduler::Start();
1.730 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied);
1.731 +
1.732 + CleanupStack::PopAndDestroy(); // active
1.733 + }
1.734 +
1.735 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
1.736 +
1.737 +/**
1.738 +@SYMTestCaseID PDS-LOGENG-UT-4040
1.739 +@SYMTestCaseDesc Clear log events with specific SimId - platform security test.
1.740 + This test is called from two test applications: t_logHicapability
1.741 + and t_loglowcapabilty. As the names state, t_loghicapability has platsec capabilities to
1.742 + call CLogClient::CLearLog(), t_loglowcapabilty - hasn't.
1.743 + When t_loghicapability calls ClearLogL(), "TheHiCapability" flag is true and it is expected
1.744 + the CLogClient::ClearLog() call to complete successfully.
1.745 + When t_loglowcapability calls ClearLogL(), "TheHiCapability" flag is false and it is expected
1.746 + the CLogClient::ClearLog() call to fail with KErrPermissionDenied.
1.747 +@SYMTestActions Clear log events with specific SimId - platform security test.
1.748 +@SYMTestExpectedResults Test must not fail
1.749 +@SYMTestPriority High
1.750 +@SYMREQ REQ12748
1.751 +*/
1.752 +void ClearLogL(CLogClient& aClient, TSimId aSimId)
1.753 + {//This test case is compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined.
1.754 + CTestActive* active = new(ELeave)CTestActive();
1.755 + CleanupStack::PushL(active);
1.756 +
1.757 + TTime now;
1.758 + now.UniversalTime();
1.759 +
1.760 + active->StartL();
1.761 + aClient.ClearLog(now, aSimId, active->iStatus);
1.762 +
1.763 + CActiveScheduler::Start();
1.764 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied);
1.765 +
1.766 + CleanupStack::PopAndDestroy(); // active
1.767 + }
1.768 +
1.769 +/**
1.770 +@SYMTestCaseID PDS-LOGENG-UT-4041
1.771 +@SYMTestCaseDesc Clear log events from the specified recent list with specific SimId - platform security test.
1.772 + This test is called from two test applications: t_logHicapability
1.773 + and t_loglowcapabilty. As the names state, t_loghicapability has platsec capabilities to
1.774 + call CLogClient::CLearLog(), t_loglowcapabilty - hasn't.
1.775 + When t_loghicapability calls ClearLogL(), "TheHiCapability" flag is true and it is expected
1.776 + the CLogClient::ClearLog() call to complete successfully.
1.777 + When t_loglowcapability calls ClearLogL(), "TheHiCapability" flag is false and it is expected
1.778 + the CLogClient::ClearLog() call to fail with KErrPermissionDenied.
1.779 +@SYMTestActions Clear log events from the specified recent list with specific SimId - platform security test.
1.780 +@SYMTestExpectedResults Test must not fail
1.781 +@SYMTestPriority High
1.782 +@SYMREQ REQ12748
1.783 +*/
1.784 +void ClearRecentListL(CLogClient& aClient, TSimId aSimId)
1.785 + {//This test case is compiled only when SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM macro is defined.
1.786 + CTestActive* active = new(ELeave)CTestActive();
1.787 + CleanupStack::PushL(active);
1.788 +
1.789 + TTime now;
1.790 + now.UniversalTime();
1.791 +
1.792 + active->StartL();
1.793 + aClient.ClearLog(KLogRecentIncomingCalls, aSimId, active->iStatus);
1.794 +
1.795 + CActiveScheduler::Start();
1.796 + TEST2(active->iStatus.Int(), TheHiCapability ? KErrNone : KErrPermissionDenied);
1.797 +
1.798 + CleanupStack::PopAndDestroy(); // active
1.799 + }
1.800 +
1.801 +#endif//SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
1.802 +
1.803 +/**
1.804 +@SYMTestCaseID SYSLIB-LOGENG-CT-0129
1.805 +@SYMTestCaseDesc Test that a view only contains events that are suitable for a clients cabability
1.806 +@SYMTestPriority High
1.807 +@SYMTestActions See comments in the trest code below for further info.
1.808 +@SYMTestExpectedResults Should always succeed
1.809 +@SYMREQ REQ3431
1.810 +*/
1.811 +LOCAL_C void TestEventViewWithFilterL(CLogClient& aClient)
1.812 + {
1.813 + // TestUtils::AddTestEventsL() --> should be called before this function.
1.814 + // It deletes the database, then...
1.815 + // adds 8 events - 2 are visible to clients with no capabilities
1.816 + // and 6 are of type KLogCallEventTypeUid, which is protected.
1.817 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0129 "));
1.818 + CTestActive* active = new(ELeave)CTestActive;
1.819 + CleanupStack::PushL(active);
1.820 +
1.821 + CLogFilterList* list = new(ELeave)CLogFilterList;
1.822 + CleanupStack::PushL(list);
1.823 +
1.824 + CLogViewEvent* view = CLogViewEvent::NewL(aClient);
1.825 + CleanupStack::PushL(view);
1.826 +
1.827 + CLogFilter* filter = CLogFilter::NewL();
1.828 + CleanupStack::PushL(filter);
1.829 +
1.830 + TLogString direction;
1.831 + aClient.GetString(direction, R_LOG_DIR_IN);
1.832 +
1.833 + // Test 1.
1.834 + // Of the 8 new events, 2 have KTestContact1 as the contact field
1.835 + // One of them is a secure type and the other isn't.
1.836 + // So, if running at hi capability, expect 2 events, else 1
1.837 + TInt expectedEventCount = (TheHiCapability) ? 2 : 1;
1.838 + filter->SetContact(KTestContact1);
1.839 + list->AppendL(filter);
1.840 + active->StartL();
1.841 + TEST(view->SetFilterL(*list, active->iStatus));
1.842 + CActiveScheduler::Start();
1.843 + TEST(view->CountL() == expectedEventCount);
1.844 +
1.845 + // Test 2.
1.846 + // Of the 8 new events, 6 have KTestContact2 as the contact field
1.847 + // One of them is a secure type and the other isn't.
1.848 + // The filters will be combined in the query, so expect
1.849 + // 8 events if running at hi capability, else 2
1.850 + expectedEventCount = (TheHiCapability) ? 8 : 2;
1.851 + CleanupStack::Pop(); // filter
1.852 + filter = CLogFilter::NewL();
1.853 + CleanupStack::PushL(filter);
1.854 + filter->SetContact(KTestContact2);
1.855 + list->AppendL(filter);
1.856 + active->StartL();
1.857 + TEST(view->SetFilterL(*list, active->iStatus));
1.858 + CActiveScheduler::Start();
1.859 + TEST(view->CountL() == expectedEventCount);
1.860 +
1.861 + // Test 3.
1.862 + // Of the 8 new events, 7 have R_LOG_DIR_IN as the direction field.
1.863 + // Two of these are only visible for hi capability clients, the other one
1.864 + // can be viewed by all clients.
1.865 + expectedEventCount = (TheHiCapability) ? 7 : 1;
1.866 + CleanupStack::Pop(); // filter
1.867 + filter = CLogFilter::NewL();
1.868 + CleanupStack::PushL(filter);
1.869 + filter->SetDirection(direction);
1.870 + list->AppendL(filter);
1.871 + active->StartL();
1.872 + TEST(view->SetFilterL(*list, active->iStatus));
1.873 + CActiveScheduler::Start();
1.874 + TEST(view->CountL() == expectedEventCount);
1.875 +
1.876 + // clear up...
1.877 + list->ResetAndDestroy();
1.878 + CleanupStack::Pop(); // filter
1.879 + CleanupStack::PopAndDestroy(3); // view, list, active
1.880 + }
1.881 +
1.882 +
1.883 +
1.884 +
1.885 +/**
1.886 +@SYMTestCaseID SYSLIB-LOGENG-CT-0130
1.887 +@SYMTestCaseDesc Test the clients ability to view recent events
1.888 +@SYMTestActions See the description and expected results.
1.889 +@SYMTestPriority High
1.890 +@SYMTestExpectedResults Should always succeed
1.891 +@SYMREQ REQ3431
1.892 +*/
1.893 +LOCAL_C void TestRecentViewL(CLogClient& aClient)
1.894 + {
1.895 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0130 "));
1.896 + CTestActive* active = new(ELeave)CTestActive();
1.897 + CleanupStack::PushL(active);
1.898 +
1.899 + CLogViewRecent* view = CLogViewRecent::NewL(aClient);
1.900 + CleanupStack::PushL(view);
1.901 +
1.902 + active->StartL();
1.903 +
1.904 + // will return FALSE if the view is empty, which should be the case
1.905 + // with low/no capability clients.
1.906 + if (view->SetRecentListL(KLogRecentIncomingCalls, active->iStatus))
1.907 + {
1.908 + __ASSERT_ALWAYS(TheHiCapability, _L("TestRecentViewL"));
1.909 + CActiveScheduler::Start();
1.910 + TEST2(active->iStatus.Int(), KErrNone);
1.911 + TEST(view->CountL() == 2);
1.912 + TInt count = view->CountL();
1.913 + }
1.914 + else // low capability client won't be able to see recent incoming calls
1.915 + {
1.916 + __ASSERT_ALWAYS(!TheHiCapability, _L("TestRecentViewL"));
1.917 + active->Cancel();
1.918 + }
1.919 +
1.920 + CleanupStack::PopAndDestroy(2); // view, active
1.921 + }
1.922 +
1.923 +//.............................................................................
1.924 +
1.925 +void doTestsL()
1.926 + {
1.927 + TestUtils::Initialize(KTestTitle);
1.928 +
1.929 + TheTest.Start(_L("Starting tests..."));
1.930 +
1.931 + CLogClient* client = CLogClient::NewL(theFs);
1.932 + CleanupStack::PushL(client);
1.933 +
1.934 + TestUtils::DeleteDatabaseL();
1.935 +
1.936 + TheTest.Next(_L("Server startup"));
1.937 + TestStartupL();
1.938 + User::After(100000);
1.939 +
1.940 + TheTest.Next(_L("Test Add, Get, Change & Delete event"));
1.941 + TestUtils::DeleteDatabaseL();
1.942 + TestBasicL(*client);
1.943 + theLog.Write(_L8("Basic tests OK\n"));
1.944 +
1.945 + TheTest.Next(_L("Add Event Type"));
1.946 + TestAddEventTypeL(*client);
1.947 + theLog.Write(_L8("Add Event Type test OK\n"));
1.948 +
1.949 + if(!TheHiCapability)
1.950 + {
1.951 + // TestAddEventTypeL() will have failed to add an event type, so
1.952 + // this will ensure one is present for the next tests.
1.953 + TestUtils::AddEventTypeL();
1.954 + }
1.955 +
1.956 + TheTest.Next(_L("Get Event Type"));
1.957 + TestGetEventTypeL(*client);
1.958 + theLog.Write(_L8("Get Event Type test OK\n"));
1.959 +
1.960 + TheTest.Next(_L("Change Event Type"));
1.961 + TestChangeEventTypeL(*client);
1.962 + theLog.Write(_L8("Change Event Type test OK\n"));
1.963 +
1.964 + TheTest.Next(_L("Delete Event Type"));
1.965 + TestDeleteEventTypeL(*client);
1.966 + theLog.Write(_L8("Delete Event Type test OK\n"));
1.967 +
1.968 + TheTest.Next(_L("Delete Built-in Event Type"));
1.969 + TestDeleteBuiltInEventTypeL(*client);
1.970 + theLog.Write(_L8("Delete Built-in Event Type test OK\n"));
1.971 +
1.972 + TheTest.Next(_L("Get Server Configuration"));
1.973 + TestGetConfigL(*client);
1.974 + theLog.Write(_L8("Get Server Configuration test OK\n"));
1.975 +
1.976 + TheTest.Next(_L("Change Server Configuration"));
1.977 + TestChangeConfigL(*client);
1.978 + theLog.Write(_L8("Change Server Configuration test OK\n"));
1.979 +
1.980 + TheTest.Next(_L("Clear the Log test"));
1.981 + ClearLogL(*client);
1.982 + theLog.Write(_L8("Clear the Log test OK\n"));
1.983 +
1.984 + TheTest.Next(_L("Clear Recent List test"));
1.985 + ClearRecentListL(*client);
1.986 + theLog.Write(_L8("Clear Recent List test OK\n"));
1.987 +
1.988 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
1.989 + const TSimId KSimId = 4000000000U;
1.990 +
1.991 + TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4040 Clear the \"Log + SimId\" test"));
1.992 + ClearLogL(*client, KSimId);
1.993 + theLog.Write(_L8("Clear the \"Log + SimId\" test OK\n"));
1.994 +
1.995 + TheTest.Next(_L(" @SYMTestCaseID:PDS-LOGENG-UT-4041 Clear \"Recent List + SimId\" test"));
1.996 + ClearRecentListL(*client, KSimId);
1.997 + theLog.Write(_L8("Clear \"Recent List + SimId\" test OK\n"));
1.998 +#endif
1.999 +
1.1000 + //
1.1001 + // View API tests below this
1.1002 + //
1.1003 + TestUtils::DeleteDatabaseL();
1.1004 +
1.1005 + // TestUtils::AddTestEventsL() --> adds 8 events.
1.1006 + // 2 are visible to clients with no capabilities
1.1007 + // and 6 are of type KLogCallEventTypeUid, which is protected.
1.1008 + TestUtils::AddViewTestEventsL();
1.1009 +
1.1010 + TheTest.Next(_L("Event View with Filter list"));
1.1011 + TestEventViewWithFilterL(*client);
1.1012 + theLog.Write(_L8("Event View with Filter list test OK\n"));
1.1013 +
1.1014 + TheTest.Next(_L("Recent View"));
1.1015 + TestRecentViewL(*client);
1.1016 + theLog.Write(_L8("Recent View test OK\n"));
1.1017 +
1.1018 + TestUtils::DeleteDatabaseL(); // ready for next test
1.1019 +
1.1020 + CleanupStack::PopAndDestroy(); // client
1.1021 + }