1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/loggingservices/eventlogger/test/src/t_logbackup.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1065 @@
1.4 +// Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#include <s32file.h>
1.20 +#include <babackup.h>
1.21 +#include "t_logutil2.h"
1.22 +#include <logview.h>
1.23 +
1.24 +RTest TheTest(_L("t_logbackup"));
1.25 +
1.26 +CBaBackupSessionWrapper* theBackup = NULL;
1.27 +
1.28 +/////////////////////////////////////////////////////////////////////////////////////
1.29 +/////////////////////////////////////////////////////////////////////////////////////
1.30 +/////////////////////////////////////////////////////////////////////////////////////
1.31 +#ifdef __WINS__
1.32 +
1.33 +_LIT(KTestEventDesc, "Event Type Description");
1.34 +_LIT(KTestRemoteParty, "Remote Party");
1.35 +_LIT(KTestDirection, "Direction");
1.36 +const TLogDurationType KTestDurationType = 1;
1.37 +const TLogDuration KTestDuration = 0x1234;
1.38 +_LIT(KTestStatus, "Status");
1.39 +_LIT(KTestSubject, "Subject");
1.40 +_LIT(KTestNumber, "Number");
1.41 +const TLogContactItemId KTestContact = 0x1234;
1.42 +const TLogLink KTestLink = 0x1234;
1.43 +_LIT8(KTestData, "ABCDEFGH");
1.44 +_LIT(KTestNumber1, "TheNumber");
1.45 +_LIT(KTestNumber2, "Changed Number");
1.46 +
1.47 +class TClientObserverTestReceiver : public MLogClientChangeObserver
1.48 + {
1.49 +public:
1.50 + TClientObserverTestReceiver(TBool& aFlag) : iCallCount(0), iFlag(aFlag) { }
1.51 +
1.52 +public:
1.53 + void HandleLogClientChangeEventL(TUid aChangeType, TInt /*aChangeParam1*/, TInt /*aChangeParam2*/, TInt /*aChangeParam3*/)
1.54 + {
1.55 + ++iCallCount;
1.56 + iFlag = (aChangeType == KLogClientChangeEventRefreshView);
1.57 + }
1.58 + inline TInt CallCount() const { return iCallCount; }
1.59 + inline void Reset() { iCallCount = 0; iFlag = EFalse; }
1.60 +
1.61 +private:
1.62 + TInt iCallCount;
1.63 + TBool& iFlag;
1.64 + };
1.65 +
1.66 +LOCAL_C TBool IsLogOpenL()
1.67 + {
1.68 + return TestUtils::IsDatabaseOpenL();
1.69 + }
1.70 +
1.71 +/**
1.72 +@SYMTestCaseID SYSLIB-LOGENG-CT-0993
1.73 +@SYMTestCaseDesc Tests for a file open
1.74 +@SYMTestPriority High
1.75 +@SYMTestActions Check for errors while testing for file open
1.76 +@SYMTestExpectedResults Test must not fail
1.77 +@SYMREQ REQ0000
1.78 +*/
1.79 +LOCAL_C void TestLogOpenL()
1.80 + {
1.81 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0993 "));
1.82 + TEST(IsLogOpenL());
1.83 + }
1.84 +
1.85 +/**
1.86 +@SYMTestCaseID SYSLIB-LOGENG-CT-0994
1.87 +@SYMTestCaseDesc Tests for file close
1.88 +@SYMTestPriority High
1.89 +@SYMTestActions Check for errors while testing for file close
1.90 +@SYMTestExpectedResults Test must not fail
1.91 +@SYMREQ REQ0000
1.92 +*/
1.93 +LOCAL_C void TestLogClosedL()
1.94 + {
1.95 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0994 "));
1.96 + TEST(!IsLogOpenL());
1.97 + }
1.98 +
1.99 +LOCAL_C void StartBackupL()
1.100 + {
1.101 + User::InfoPrint(_L("Backup"));
1.102 +
1.103 + TDriveUnit driveUnit(EDriveC);
1.104 + TDriveName name = driveUnit.Name();
1.105 +
1.106 + TParse parse;
1.107 + LEAVE_IF_ERROR(parse.Set(KLogDatabaseName, &name, NULL));
1.108 +
1.109 + delete theBackup;
1.110 + theBackup = NULL;
1.111 + theBackup = CBaBackupSessionWrapper::NewL();
1.112 +
1.113 + theBackup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
1.114 + User::After(1000000);
1.115 + }
1.116 +
1.117 +LOCAL_C void DeleteLogDatabaseL()
1.118 + {
1.119 + User::InfoPrint(_L("delete"));
1.120 + TestUtils::DeleteDatabaseL(EFalse);
1.121 + }
1.122 +
1.123 +LOCAL_C void EndBackupL()
1.124 + {
1.125 + delete theBackup;
1.126 + theBackup = NULL;
1.127 + User::After(1000000);
1.128 + }
1.129 +
1.130 +LOCAL_C void DelayL(TInt aDelay)
1.131 + {
1.132 + CTestTimer* timer = CTestTimer::NewL();
1.133 + timer->After(aDelay);
1.134 + CActiveScheduler::Start();
1.135 + delete timer;
1.136 + }
1.137 +
1.138 +
1.139 +const TUid KTestEventUid = {0x10005393};
1.140 +_LIT(KTestEventDesc1, "Event Type Description");
1.141 +_LIT(KTestEventDesc2, "Changed Event Description");
1.142 +
1.143 +LOCAL_C void ForceClientImplInstL(CLogClient& aClient)
1.144 + {
1.145 + CLogEventType* type = CLogEventType::NewL();
1.146 + CleanupStack::PushL(type);
1.147 + type->SetUid(KTestEventUid);
1.148 + type->SetDescription(KTestEventDesc1);
1.149 + type->SetLoggingEnabled(ETrue);
1.150 +
1.151 + CTestActive* active = new(ELeave)CTestActive;
1.152 + CleanupStack::PushL(active);
1.153 + aClient.AddEventType(*type, active->iStatus);
1.154 + active->StartL();
1.155 + CActiveScheduler::Start();
1.156 + CleanupStack::PopAndDestroy(2);//type, active
1.157 +
1.158 + }
1.159 +
1.160 +/**
1.161 +@SYMTestCaseID SYSLIB-LOGENG-CT-0995
1.162 +@SYMTestCaseDesc Tests for starting and ending the backup session
1.163 +@SYMTestPriority High
1.164 +@SYMTestActions Test for file open and close,start and end of the backup session
1.165 +@SYMTestExpectedResults Test must not fail
1.166 +@SYMREQ REQ0000
1.167 +*/
1.168 +LOCAL_C void TestLockingL()
1.169 + {
1.170 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0995 "));
1.171 + CLogClient* client = CLogClient::NewL(theFs);
1.172 + CleanupStack::PushL(client);
1.173 +
1.174 + ForceClientImplInstL(*client);
1.175 +
1.176 +
1.177 + DelayL(1000000);
1.178 + TestLogOpenL();
1.179 + StartBackupL();
1.180 + DelayL(1000000);
1.181 +
1.182 + TestLogClosedL();
1.183 +
1.184 + EndBackupL();
1.185 + TestLogOpenL();
1.186 +
1.187 + CleanupStack::PopAndDestroy(); // client
1.188 + }
1.189 +
1.190 +/**
1.191 +@SYMTestCaseID SYSLIB-LOGENG-CT-0996
1.192 +@SYMTestCaseDesc Tests for deleting the file when its locked
1.193 +@SYMTestPriority High
1.194 +@SYMTestActions Attempt for deleting the file when its locked
1.195 +@SYMTestExpectedResults Test must not fail
1.196 +@SYMREQ REQ0000
1.197 +*/
1.198 +LOCAL_C void TestDeleteWhileLockedL()
1.199 + {
1.200 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0996 "));
1.201 + CLogClient* client = CLogClient::NewL(theFs);
1.202 + CleanupStack::PushL(client);
1.203 + ForceClientImplInstL(*client);
1.204 +
1.205 + TestLogOpenL();
1.206 + StartBackupL();
1.207 + DelayL(1000000);
1.208 + TestLogClosedL();
1.209 +
1.210 + CleanupStack::PopAndDestroy(); // client
1.211 + TestLogClosedL();
1.212 +
1.213 + client = CLogClient::NewL(theFs);
1.214 + CleanupStack::PushL(client);
1.215 + ForceClientImplInstL(*client);
1.216 + EndBackupL();
1.217 +
1.218 + TestLogOpenL();
1.219 + StartBackupL();
1.220 + DelayL(1000000);
1.221 + TestLogClosedL();
1.222 + EndBackupL();
1.223 + TestLogOpenL();
1.224 +
1.225 + CleanupStack::PopAndDestroy(); // client
1.226 + }
1.227 +
1.228 +/**
1.229 +@SYMTestCaseID SYSLIB-LOGENG-CT-0997
1.230 +@SYMTestCaseDesc Tests for deleting the view while its locked
1.231 +@SYMTestPriority High
1.232 +@SYMTestActions Delete the view when its locked
1.233 +@SYMTestExpectedResults Test must not fail
1.234 +@SYMREQ REQ0000
1.235 +*/
1.236 +LOCAL_C void TestDeleteViewWhileLockedL()
1.237 + {
1.238 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0997 "));
1.239 + CLogClient* client = CLogClient::NewL(theFs);
1.240 + CleanupStack::PushL(client);
1.241 + ForceClientImplInstL(*client);
1.242 +
1.243 + CLogFilter* filter = CLogFilter::NewL();
1.244 + CleanupStack::PushL(filter);
1.245 +
1.246 + CLogViewEvent* view = CLogViewEvent::NewL(*client);
1.247 + CleanupStack::PushL(view);
1.248 +
1.249 + TestLogOpenL();
1.250 + StartBackupL();
1.251 + DelayL(1000000);
1.252 + TestLogClosedL();
1.253 +
1.254 + CleanupStack::PopAndDestroy(3); // view, filter, client
1.255 + TestLogClosedL();
1.256 +
1.257 + client = CLogClient::NewL(theFs);
1.258 + CleanupStack::PushL(client);
1.259 + ForceClientImplInstL(*client);
1.260 +
1.261 + filter = CLogFilter::NewL();
1.262 + CleanupStack::PushL(filter);
1.263 +
1.264 + view = CLogViewEvent::NewL(*client);
1.265 + CleanupStack::PushL(view);
1.266 + EndBackupL();
1.267 +
1.268 + TestLogOpenL();
1.269 + StartBackupL();
1.270 + DelayL(1000000);
1.271 + TestLogClosedL();
1.272 + EndBackupL();
1.273 + TestLogOpenL();
1.274 +
1.275 + CleanupStack::PopAndDestroy(3); // view, filter, client
1.276 + }
1.277 +
1.278 +/**
1.279 +@SYMTestCaseID SYSLIB-LOGENG-CT-0998
1.280 +@SYMTestCaseDesc Multiple client logging test
1.281 +@SYMTestPriority High
1.282 +@SYMTestActions Open multiple clients and test for starting and ending the backup
1.283 +@SYMTestExpectedResults Test must not fail
1.284 +@SYMREQ REQ0000
1.285 +*/
1.286 +LOCAL_C void TestMultipleClientLockingL()
1.287 + {
1.288 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0998 "));
1.289 + CLogClient* client1 = CLogClient::NewL(theFs);
1.290 + CleanupStack::PushL(client1);
1.291 + ForceClientImplInstL(*client1);
1.292 +
1.293 + TestLogOpenL();
1.294 +
1.295 + CLogClient* client2 = CLogClient::NewL(theFs);
1.296 + CleanupStack::PushL(client2);
1.297 + ForceClientImplInstL(*client2);
1.298 +
1.299 + TestLogOpenL();
1.300 +
1.301 + StartBackupL();
1.302 + EndBackupL();
1.303 + TestLogOpenL();
1.304 +
1.305 + StartBackupL();
1.306 + TestLogClosedL();
1.307 +
1.308 + EndBackupL();
1.309 + TestLogOpenL();
1.310 +
1.311 + CleanupStack::PopAndDestroy(2); // client1, client2
1.312 + }
1.313 +
1.314 +/**
1.315 +@SYMTestCaseID SYSLIB-LOGENG-CT-0999
1.316 +@SYMTestCaseDesc Multiple view locking test
1.317 +@SYMTestPriority High
1.318 +@SYMTestActions Open multiple views and test for starting and ending of backup
1.319 +@SYMTestExpectedResults Test must not fail
1.320 +@SYMREQ REQ0000
1.321 +*/
1.322 +LOCAL_C void TestMultipleViewLockingL()
1.323 + {
1.324 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-0999 "));
1.325 + CLogClient* client = CLogClient::NewL(theFs);
1.326 + CleanupStack::PushL(client);
1.327 + ForceClientImplInstL(*client);
1.328 +
1.329 + CLogFilter* filter = CLogFilter::NewL();
1.330 + CleanupStack::PushL(filter);
1.331 +
1.332 + CLogViewEvent* view1 = CLogViewEvent::NewL(*client);
1.333 + CleanupStack::PushL(view1);
1.334 +
1.335 + CLogViewEvent* view2 = CLogViewEvent::NewL(*client);
1.336 + CleanupStack::PushL(view2);
1.337 +
1.338 + TestLogOpenL();
1.339 + StartBackupL();
1.340 + TestLogClosedL();
1.341 + EndBackupL();
1.342 + TestLogOpenL();
1.343 +
1.344 + CleanupStack::PopAndDestroy(4); // view2, view1, filter, client
1.345 + }
1.346 +
1.347 +LOCAL_C void DoTestLogL(CLogBase& aClient, TInt aError)
1.348 + {
1.349 + CTestActive* active = new(ELeave)CTestActive();
1.350 + CleanupStack::PushL(active);
1.351 +
1.352 + CLogEvent* event = CLogEvent::NewL();
1.353 + CleanupStack::PushL(event);
1.354 +
1.355 + TTime now;
1.356 + now.UniversalTime();
1.357 +
1.358 + event->SetEventType(KLogCallEventTypeUid);
1.359 +
1.360 + active->StartL();
1.361 + aClient.AddEvent(*event, active->iStatus);
1.362 + CActiveScheduler::Start();
1.363 + TEST2(active->iStatus.Int(), aError);
1.364 +
1.365 + if (aError == KErrNone)
1.366 + {
1.367 + TEST(event->EventType() == KLogCallEventTypeUid);
1.368 + TEST(event->Description().Length() > 0);
1.369 + TEST(event->Time() >= now);
1.370 + now = event->Time();
1.371 + }
1.372 + else
1.373 + {
1.374 + // User a dummy id to prevent assertion
1.375 + event->SetId(123);
1.376 + }
1.377 +
1.378 + TLogId id = event->Id();
1.379 +
1.380 + event->SetRemoteParty(KTestRemoteParty);
1.381 + event->SetDirection(KTestDirection);
1.382 + event->SetDurationType(KTestDurationType);
1.383 + event->SetDuration(KTestDuration);
1.384 + event->SetStatus(KTestStatus);
1.385 + event->SetSubject(KTestSubject);
1.386 + event->SetNumber(KTestNumber);
1.387 + event->SetContact(KTestContact);
1.388 + event->SetLink(KTestLink);
1.389 + event->SetDataL(KTestData);
1.390 +
1.391 + active->StartL();
1.392 + aClient.ChangeEvent(*event, active->iStatus);
1.393 + CActiveScheduler::Start();
1.394 + TEST2(active->iStatus.Int(), aError);
1.395 +
1.396 + if (aError == KErrNone)
1.397 + {
1.398 + TEST(event->Id() == id);
1.399 + TEST(event->EventType() == KLogCallEventTypeUid);
1.400 + TEST(event->Description().Length() > 0);
1.401 + TEST(event->Time() == now);
1.402 + TEST(event->RemoteParty() == KTestRemoteParty);
1.403 + TEST(event->Direction() == KTestDirection);
1.404 + TEST(event->DurationType() == KTestDurationType);
1.405 + TEST(event->Duration() == KTestDuration);
1.406 + TEST(event->Status() == KTestStatus);
1.407 + TEST(event->Subject() == KTestSubject);
1.408 + TEST(event->Number() == KTestNumber);
1.409 + TEST(event->Contact() == KTestContact);
1.410 + TEST(event->Link() == KTestLink);
1.411 + TEST(event->Data() == KTestData);
1.412 + }
1.413 +
1.414 + CleanupStack::PopAndDestroy(); // event;
1.415 +
1.416 + event = CLogEvent::NewL();
1.417 + CleanupStack::PushL(event);
1.418 +
1.419 + event->SetId(id);
1.420 +
1.421 + active->StartL();
1.422 + aClient.GetEvent(*event, active->iStatus);
1.423 + CActiveScheduler::Start();
1.424 + TEST2(active->iStatus.Int(), aError);
1.425 +
1.426 + if (aError == KErrNone)
1.427 + {
1.428 + TEST(event->Id() == id);
1.429 + TEST(event->EventType() == KLogCallEventTypeUid);
1.430 + TEST(event->Description().Length() > 0);
1.431 + TEST(event->Time() == now);
1.432 + TEST(event->RemoteParty() == KTestRemoteParty);
1.433 + TEST(event->Direction() == KTestDirection);
1.434 + TEST(event->DurationType() == KTestDurationType);
1.435 + TEST(event->Duration() == KTestDuration);
1.436 + TEST(event->Status() == KTestStatus);
1.437 + TEST(event->Subject() == KTestSubject);
1.438 + TEST(event->Number() == KTestNumber);
1.439 + TEST(event->Contact() == KTestContact);
1.440 + TEST(event->Link() == KTestLink);
1.441 + TEST(event->Data() == KTestData);
1.442 + }
1.443 +
1.444 + active->StartL();
1.445 + aClient.DeleteEvent(id, active->iStatus);
1.446 + CActiveScheduler::Start();
1.447 + TEST2(active->iStatus.Int(), aError);
1.448 +
1.449 + active->StartL();
1.450 + aClient.GetEvent(*event, active->iStatus);
1.451 + CActiveScheduler::Start();
1.452 + TheTest.Printf(_L("*** active->iStatus.Int()=%d\n"), active->iStatus.Int());
1.453 + TEST(active->iStatus.Int() == aError || active->iStatus.Int() == KErrNotFound);
1.454 +
1.455 + CleanupStack::PopAndDestroy(2); // event, active
1.456 + }
1.457 +
1.458 +/**
1.459 +@SYMTestCaseID SYSLIB-LOGENG-CT-1000
1.460 +@SYMTestCaseDesc Client requests test
1.461 +@SYMTestPriority High
1.462 +@SYMTestActions Tests for client requests when the file is opened and check for no errors
1.463 + Tests for client requests when the file is closed and check for access denied errors
1.464 + Re-test for client requests when file is opened and check for no errors
1.465 +@SYMTestExpectedResults Test must not fail
1.466 +@SYMREQ REQ0000
1.467 +*/
1.468 +LOCAL_C void TestClientRequestsL()
1.469 + {
1.470 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1000 "));
1.471 + CLogClient* client1 = CLogClient::NewL(theFs);
1.472 + CleanupStack::PushL(client1);
1.473 + ForceClientImplInstL(*client1);
1.474 +
1.475 + TestLogOpenL();
1.476 +
1.477 + CLogClient* client2 = CLogClient::NewL(theFs);
1.478 + CleanupStack::PushL(client2);
1.479 + ForceClientImplInstL(*client2);
1.480 +
1.481 + TestLogOpenL();
1.482 +
1.483 + DoTestLogL(*client1, KErrNone);
1.484 + DoTestLogL(*client2, KErrNone);
1.485 +
1.486 + StartBackupL();
1.487 + DelayL(1000000);
1.488 + TestLogClosedL();
1.489 +
1.490 + DoTestLogL(*client1, KErrAccessDenied);
1.491 + DoTestLogL(*client2, KErrAccessDenied);
1.492 +
1.493 + EndBackupL();
1.494 + TestLogOpenL();
1.495 +
1.496 + DoTestLogL(*client1, KErrNone);
1.497 + DoTestLogL(*client2, KErrNone);
1.498 +
1.499 + CleanupStack::PopAndDestroy(2); // client1, client2
1.500 + }
1.501 +
1.502 +/**
1.503 +@SYMTestCaseID SYSLIB-LOGENG-CT-1001
1.504 +@SYMTestCaseDesc Tests for notification changes
1.505 +@SYMTestPriority High
1.506 +@SYMTestActions Set up for client log notification changes.
1.507 + Change the log and unlock the log.Try and change the log again and check for access denied error.
1.508 +@SYMTestExpectedResults Test must not fail
1.509 +@SYMREQ REQ0000
1.510 +*/
1.511 +LOCAL_C void TestNotificationsL()
1.512 + {
1.513 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1001 "));
1.514 + CTestActive* notify = new(ELeave)CTestActive;
1.515 + CleanupStack::PushL(notify);
1.516 +
1.517 + CTestTimer* timer = CTestTimer::NewL();
1.518 + CleanupStack::PushL(timer);
1.519 +
1.520 + CLogClient* client = CLogClient::NewL(theFs);
1.521 + CleanupStack::PushL(client);
1.522 + ForceClientImplInstL(*client);
1.523 + EndBackupL();
1.524 +
1.525 + // Setup change notification
1.526 + notify->StartL();
1.527 + client->NotifyChange(10000000, notify->iStatus);
1.528 +
1.529 + // Wait a second
1.530 + timer->After(1000000);
1.531 + CActiveScheduler::Start();
1.532 +
1.533 + // Change the log
1.534 + DoTestLogL(*client, KErrNone);
1.535 +
1.536 + // Unlock the log
1.537 + TestLogOpenL();
1.538 + StartBackupL();
1.539 + DelayL(1000000);
1.540 + TestLogClosedL();
1.541 +
1.542 + // Try and change the log again
1.543 + DoTestLogL(*client, KErrAccessDenied);
1.544 +
1.545 + // Make sure the notifier doesn't complete
1.546 + timer->After(15000000);
1.547 + CActiveScheduler::Start();
1.548 + TEST(notify->IsActive());
1.549 +
1.550 + // Lock the log
1.551 + EndBackupL();
1.552 + TestLogOpenL();
1.553 +
1.554 + // Wait for notification
1.555 + CActiveScheduler::Start();
1.556 + TEST(!notify->IsActive());
1.557 +
1.558 + // Setup change notification
1.559 + notify->StartL();
1.560 + client->NotifyChange(10000000, notify->iStatus);
1.561 +
1.562 + // Wait a second
1.563 + timer->After(1000000);
1.564 + CActiveScheduler::Start();
1.565 +
1.566 + // Unlock the log
1.567 + TestLogOpenL();
1.568 + StartBackupL();
1.569 + DelayL(1000000);
1.570 + TestLogClosedL();
1.571 +
1.572 + // Check notification is completed when client destroyed
1.573 + TEST(notify->IsActive());
1.574 + CleanupStack::PopAndDestroy(client);
1.575 +
1.576 + // Wait for notification
1.577 + CActiveScheduler::Start();
1.578 + TEST(!notify->IsActive());
1.579 + TEST2(notify->iStatus.Int(), KErrCancel);
1.580 +
1.581 + // Recreate client
1.582 + client = CLogClient::NewL(theFs);
1.583 + CleanupStack::PushL(client);
1.584 +
1.585 + // Setup change notification
1.586 + notify->StartL();
1.587 + client->NotifyChange(10000000, notify->iStatus);
1.588 +
1.589 + // Wait a second
1.590 + timer->After(1000000);
1.591 + CActiveScheduler::Start();
1.592 +
1.593 + // Check notification is completed when cancelled
1.594 + TEST(notify->IsActive());
1.595 + client->NotifyChangeCancel();
1.596 +
1.597 + // Wait for notification
1.598 + CActiveScheduler::Start();
1.599 + TEST(!notify->IsActive());
1.600 + TEST2(notify->iStatus.Int(), KErrCancel);
1.601 +
1.602 + // Setup change notification
1.603 + notify->StartL();
1.604 + client->NotifyChange(10000000, notify->iStatus);
1.605 +
1.606 + // Wait a second
1.607 + timer->After(1000000);
1.608 + CActiveScheduler::Start();
1.609 +
1.610 + // Lock the log
1.611 + EndBackupL();
1.612 + TestLogOpenL();
1.613 +
1.614 + // Wait for notification
1.615 + TEST(notify->IsActive());
1.616 + CActiveScheduler::Start();
1.617 + TEST(!notify->IsActive());
1.618 + TEST(notify->iStatus >= 0);
1.619 +
1.620 + notify->StartL();
1.621 + client->NotifyChange(10000000, notify->iStatus);
1.622 +
1.623 + // Wait a second
1.624 + timer->After(1000000);
1.625 + CActiveScheduler::Start();
1.626 +
1.627 + // Change the log
1.628 + DoTestLogL(*client, KErrNone);
1.629 +
1.630 + // Wait for notification
1.631 + TEST(notify->IsActive());
1.632 + CActiveScheduler::Start();
1.633 + TEST(!notify->IsActive());
1.634 + TEST(notify->iStatus >= 0);
1.635 +
1.636 + CleanupStack::PopAndDestroy(3); // client, timer, notify
1.637 + }
1.638 +
1.639 +/**
1.640 +@SYMTestCaseID SYSLIB-LOGENG-CT-1002
1.641 +@SYMTestCaseDesc Tests for request in progress
1.642 +@SYMTestPriority High
1.643 +@SYMTestActions Add an event when backup is started and check for access denied error
1.644 +@SYMTestExpectedResults Test must not fail
1.645 +@SYMREQ REQ0000
1.646 +*/
1.647 +LOCAL_C void TestRequestInProgressL()
1.648 + {
1.649 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1002 "));
1.650 + CLogClient* client = CLogClient::NewL(theFs);
1.651 + CleanupStack::PushL(client);
1.652 + ForceClientImplInstL(*client);
1.653 + EndBackupL();
1.654 +
1.655 + CTestActive* active = new(ELeave)CTestActive();
1.656 + CleanupStack::PushL(active);
1.657 +
1.658 + CLogEvent* event = CLogEvent::NewL();
1.659 + CleanupStack::PushL(event);
1.660 +
1.661 + event->SetEventType(KLogCallEventTypeUid);
1.662 +
1.663 + active->StartL();
1.664 + client->AddEvent(*event, active->iStatus);
1.665 + StartBackupL();
1.666 + CActiveScheduler::Start();
1.667 + TEST2(active->iStatus.Int(), KErrAccessDenied);
1.668 + DelayL(1000000);
1.669 +
1.670 + // User a dummy id to prevent assertion
1.671 + event->SetId(123);
1.672 +
1.673 + EndBackupL();
1.674 + active->StartL();
1.675 + client->ChangeEvent(*event, active->iStatus);
1.676 + StartBackupL();
1.677 +
1.678 + CActiveScheduler::Start();
1.679 + TEST2(active->iStatus.Int(), KErrAccessDenied);
1.680 + DelayL(1000000);
1.681 +
1.682 + EndBackupL();
1.683 + active->StartL();
1.684 + client->GetEvent(*event, active->iStatus);
1.685 + StartBackupL();
1.686 +
1.687 + CActiveScheduler::Start();
1.688 + TEST2(active->iStatus.Int(), KErrAccessDenied);
1.689 + DelayL(1000000);
1.690 +
1.691 + EndBackupL();
1.692 + active->StartL();
1.693 + client->DeleteEvent(event->Id(), active->iStatus);
1.694 + StartBackupL();
1.695 +
1.696 + CActiveScheduler::Start();
1.697 + TEST2(active->iStatus.Int(), KErrAccessDenied);
1.698 + DelayL(1000000);
1.699 +
1.700 + EndBackupL();
1.701 + active->StartL();
1.702 + client->GetEvent(*event, active->iStatus);
1.703 + StartBackupL();
1.704 +
1.705 + CActiveScheduler::Start();
1.706 + TEST2(active->iStatus.Int(), KErrAccessDenied);
1.707 + DelayL(1000000);
1.708 +
1.709 + // Check the log is useable
1.710 + EndBackupL();
1.711 + DoTestLogL(*client, KErrNone);
1.712 +
1.713 + CleanupStack::PopAndDestroy(3); // client, event, active
1.714 + }
1.715 +
1.716 +/**
1.717 +@SYMTestCaseID SYSLIB-LOGENG-CT-1003
1.718 +@SYMTestCaseDesc Tests for log view when request is in progress
1.719 +@SYMTestPriority High
1.720 +@SYMTestActions Add events to the log,set a filter on log view and start the backup session
1.721 + and check for the request status for access denied.
1.722 +@SYMTestExpectedResults Test must not fail
1.723 +@SYMREQ REQ0000
1.724 +*/
1.725 +LOCAL_C void TestViewRequestInProgressL()
1.726 + {
1.727 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1003 "));
1.728 + CLogClient* client = CLogClient::NewL(theFs);
1.729 + CleanupStack::PushL(client);
1.730 + ForceClientImplInstL(*client);
1.731 + EndBackupL();
1.732 +
1.733 + CTestActive* active = new(ELeave)CTestActive();
1.734 + CleanupStack::PushL(active);
1.735 +
1.736 + CLogFilter* filter = CLogFilter::NewL();
1.737 + CleanupStack::PushL(filter);
1.738 +
1.739 + CLogViewEvent* view = CLogViewEvent::NewL(*client);
1.740 + CleanupStack::PushL(view);
1.741 +
1.742 + CLogEvent* event = CLogEvent::NewL();
1.743 + CleanupStack::PushL(event);
1.744 + event->SetEventType(KLogCallEventTypeUid);
1.745 +
1.746 + active->StartL();
1.747 + client->AddEvent(*event, active->iStatus);
1.748 + CActiveScheduler::Start();
1.749 + TEST2(active->iStatus.Int(), KErrNone);
1.750 +
1.751 + active->StartL();
1.752 + client->AddEvent(*event, active->iStatus);
1.753 + CActiveScheduler::Start();
1.754 + TEST2(active->iStatus.Int(), KErrNone);
1.755 +
1.756 + TestLogOpenL();
1.757 + TEST(view->SetFilterL(*filter, active->iStatus));
1.758 + active->StartL();
1.759 + StartBackupL();
1.760 +
1.761 + CActiveScheduler::Start();
1.762 + TEST2(active->iStatus.Int(), KErrAccessDenied);
1.763 + DelayL(1000000);
1.764 + TestLogClosedL();
1.765 +
1.766 + EndBackupL();
1.767 + TestLogOpenL();
1.768 +
1.769 + TEST(view->SetFilterL(*filter, active->iStatus));
1.770 + active->StartL();
1.771 + CActiveScheduler::Start();
1.772 + TEST2(active->iStatus.Int(), KErrNone);
1.773 +
1.774 + TEST(view->NextL(active->iStatus));
1.775 + active->StartL();
1.776 + StartBackupL();
1.777 +
1.778 + CActiveScheduler::Start();
1.779 + TEST2(active->iStatus.Int(), KErrAccessDenied);
1.780 + DelayL(1000000);
1.781 + TestLogClosedL();
1.782 +
1.783 + EndBackupL();
1.784 + TestLogOpenL();
1.785 +
1.786 + TEST(view->SetFilterL(*filter, active->iStatus));
1.787 + active->StartL();
1.788 + CActiveScheduler::Start();
1.789 + TEST2(active->iStatus.Int(), KErrNone);
1.790 +
1.791 + TEST(view->NextL(active->iStatus));
1.792 + active->StartL();
1.793 + CActiveScheduler::Start();
1.794 + TEST2(active->iStatus.Int(), KErrNone);
1.795 +
1.796 + // Now check a view is no longer valid after a backup
1.797 + TEST(view->SetFilterL(*filter, active->iStatus));
1.798 + active->StartL();
1.799 + CActiveScheduler::Start();
1.800 + TEST2(active->iStatus.Int(), KErrNone);
1.801 + TEST(view->CountL() > 1);
1.802 +
1.803 + StartBackupL();
1.804 + EndBackupL();
1.805 +
1.806 + DelayL(1000000);
1.807 +
1.808 + // Check the view can be setup again
1.809 + TEST(view->SetFilterL(*filter, active->iStatus));
1.810 + active->StartL();
1.811 + CActiveScheduler::Start();
1.812 + TEST2(active->iStatus.Int(), KErrNone);
1.813 + TEST(view->CountL() > 1);
1.814 +
1.815 + TEST(view->NextL(active->iStatus));
1.816 + active->StartL();
1.817 + CActiveScheduler::Start();
1.818 + TEST2(active->iStatus.Int(), KErrNone);
1.819 +
1.820 + CleanupStack::PopAndDestroy(5); // event, view, filter, active, client
1.821 + }
1.822 +
1.823 +/**
1.824 +@SYMTestCaseID SYSLIB-LOGENG-CT-1004
1.825 +@SYMTestCaseDesc Tests for view event log
1.826 +@SYMTestPriority High
1.827 +@SYMTestActions Create an event type and add the event to the log.
1.828 + Close the log and try setting the filter on view.Check for access denied error.
1.829 + Repeat the operation after opening the log and check for no error
1.830 +@SYMTestExpectedResults Test must not fail
1.831 +@SYMREQ REQ0000
1.832 +*/
1.833 +LOCAL_C void TestViewSetup1L()
1.834 + {
1.835 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1004 "));
1.836 + CLogClient* client = CLogClient::NewL(theFs);
1.837 + CleanupStack::PushL(client);
1.838 + ForceClientImplInstL(*client);
1.839 + EndBackupL();
1.840 +
1.841 + CTestActive* active = new(ELeave)CTestActive();
1.842 + CleanupStack::PushL(active);
1.843 +
1.844 + CLogFilter* filter = CLogFilter::NewL();
1.845 + CleanupStack::PushL(filter);
1.846 +
1.847 + CLogViewEvent* view = CLogViewEvent::NewL(*client);
1.848 + CleanupStack::PushL(view);
1.849 +
1.850 + CLogEvent* event = CLogEvent::NewL();
1.851 + CleanupStack::PushL(event);
1.852 + event->SetEventType(KLogCallEventTypeUid);
1.853 +
1.854 + active->StartL();
1.855 + client->AddEvent(*event, active->iStatus);
1.856 + CActiveScheduler::Start();
1.857 + TEST2(active->iStatus.Int(), KErrNone);
1.858 +
1.859 + TestLogOpenL();
1.860 + StartBackupL();
1.861 + DelayL(1000000);
1.862 + TestLogClosedL();
1.863 +
1.864 + TRAPD(error, view->SetFilterL(*filter, active->iStatus));
1.865 + TEST2(error, KErrAccessDenied);
1.866 +
1.867 + EndBackupL();
1.868 + TestLogOpenL();
1.869 +
1.870 + DelayL(1000000);
1.871 + TEST(view->SetFilterL(*filter, active->iStatus));
1.872 + active->StartL();
1.873 + CActiveScheduler::Start();
1.874 + TEST2(active->iStatus.Int(), KErrNone);
1.875 +
1.876 + StartBackupL();
1.877 + DelayL(1000000);
1.878 + TestLogClosedL();
1.879 + //
1.880 + CleanupStack::PopAndDestroy(5); // event, view, filter, active, client
1.881 + }
1.882 +
1.883 +/**
1.884 +@SYMTestCaseID SYSLIB-LOGENG-CT-1005
1.885 +@SYMTestCaseDesc Tests for view event log
1.886 +@SYMTestPriority High
1.887 +@SYMTestActions Create an event type and add the event to the log.
1.888 + Close the log and try setting the filter on view twice with an interval of one second.Check for access denied errors.
1.889 + Repeat the operation after opening the log and check for no error
1.890 +@SYMTestExpectedResults Test must not fail
1.891 +@SYMREQ REQ0000
1.892 +*/
1.893 +LOCAL_C void TestViewSetup2L()
1.894 + {
1.895 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1005 "));
1.896 + CLogClient* client = CLogClient::NewL(theFs);
1.897 + CleanupStack::PushL(client);
1.898 + ForceClientImplInstL(*client);
1.899 + EndBackupL();
1.900 +
1.901 + CTestActive* active = new(ELeave)CTestActive();
1.902 + CleanupStack::PushL(active);
1.903 +
1.904 + CLogFilter* filter = CLogFilter::NewL();
1.905 + CleanupStack::PushL(filter);
1.906 +
1.907 + CLogViewEvent* view = CLogViewEvent::NewL(*client);
1.908 + CleanupStack::PushL(view);
1.909 +
1.910 + CLogEvent* event = CLogEvent::NewL();
1.911 + CleanupStack::PushL(event);
1.912 + event->SetEventType(KLogCallEventTypeUid);
1.913 +
1.914 + active->StartL();
1.915 + client->AddEvent(*event, active->iStatus);
1.916 + CActiveScheduler::Start();
1.917 + TEST2(active->iStatus.Int(), KErrNone);
1.918 +
1.919 + DelayL(1000000);
1.920 + TEST(view->SetFilterL(*filter, active->iStatus));
1.921 + active->StartL();
1.922 + CActiveScheduler::Start();
1.923 + TEST2(active->iStatus.Int(), KErrNone);
1.924 +
1.925 + TestLogOpenL();
1.926 + StartBackupL();
1.927 + TestLogClosedL();
1.928 +
1.929 + TRAPD(error, view->SetFilterL(*filter, active->iStatus));
1.930 + TEST2(error, KErrAccessDenied);
1.931 +
1.932 + DelayL(1000000);
1.933 +
1.934 + TRAP(error, view->SetFilterL(*filter, active->iStatus));
1.935 + TEST2(error, KErrAccessDenied);
1.936 +
1.937 + EndBackupL();
1.938 + TestLogOpenL();
1.939 +
1.940 + // DelayL(1000000);
1.941 + TEST(view->SetFilterL(*filter, active->iStatus));
1.942 + active->StartL();
1.943 + CActiveScheduler::Start();
1.944 + TEST2(active->iStatus.Int(), KErrNone);
1.945 +
1.946 + StartBackupL();
1.947 + DelayL(1000000);
1.948 + TestLogClosedL();
1.949 + //
1.950 + CleanupStack::PopAndDestroy(5); // event, view, filter, active, client
1.951 + }
1.952 +
1.953 +/**
1.954 +Check that a KLogClientChangeEventRefreshView message is sent if the database is changed
1.955 +during a backup. This could occur if the database is restored.
1.956 +
1.957 +This was added to test the fix for DEF051602 - Problems with MLogViewChangeObserver when a backup occurs
1.958 +
1.959 +@SYMTestCaseID SYSLIB-LOGENG-CT-1006
1.960 +@SYMTestCaseDesc Check for any problems with MLogViewChangeObserver when a backup occurs
1.961 +@SYMTestPriority High
1.962 +@SYMTestActions Check that a KLogClientChangeEventRefreshView message is sent if the database is changed
1.963 + during a backup. This could occur if the database is restored.
1.964 +@SYMTestExpectedResults Test must not fail
1.965 +@SYMREQ REQ0000
1.966 +*/
1.967 +LOCAL_C void TestRefreshViewL()
1.968 +{
1.969 + TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1006 "));
1.970 + CLogClient* client = CLogClient::NewL(theFs);
1.971 + CleanupStack::PushL(client);
1.972 +
1.973 + // Create a test observer MLogClientChangeObserver
1.974 + TBool logRefreshViewFlag = EFalse;
1.975 + TClientObserverTestReceiver testReceiver(logRefreshViewFlag);
1.976 + client->SetGlobalChangeObserverL(&testReceiver);
1.977 +
1.978 + // start a backup
1.979 + TestLogOpenL();
1.980 + StartBackupL();
1.981 + DelayL(1000000);
1.982 + TestLogClosedL();
1.983 +
1.984 + // delete the database so a new empty db will be created
1.985 + // This will cause a KLogClientChangeEventRefreshViewRefresh
1.986 + // message to be sent
1.987 + DeleteLogDatabaseL();
1.988 +
1.989 + // end the backup
1.990 + EndBackupL();
1.991 + DelayL(1000000);
1.992 +
1.993 +
1.994 + // check the obsever hs recieved a message
1.995 + TEST(logRefreshViewFlag);
1.996 + //
1.997 +
1.998 + CleanupStack::PopAndDestroy(client);
1.999 +}
1.1000 +
1.1001 +
1.1002 +#endif//__WINS__
1.1003 +/////////////////////////////////////////////////////////////////////////////////////
1.1004 +/////////////////////////////////////////////////////////////////////////////////////
1.1005 +/////////////////////////////////////////////////////////////////////////////////////
1.1006 +
1.1007 +void doTestsL()
1.1008 + {
1.1009 + TestUtils::Initialize(_L("t_logbackup"));
1.1010 + TestUtils::DeleteDatabaseL();
1.1011 +
1.1012 + TheTest.Start(_L("t_logbackup"));
1.1013 +
1.1014 +#ifndef __WINS__
1.1015 + TheTest.Printf(_L("This test harness will only work on WINS\n"));
1.1016 + User::After(5000000);
1.1017 +#else//__WINS__
1.1018 + CLogChangeNotifier* notifier = CLogChangeNotifier::NewL();
1.1019 + CleanupStack::PushL(notifier);
1.1020 +
1.1021 + TheTest.Next(_L("Locking"));
1.1022 + TestLockingL();
1.1023 + theLog.Write(_L8("Test 1 OK\n"));
1.1024 +
1.1025 + TheTest.Next(_L("Delete client while locked"));
1.1026 + TestDeleteWhileLockedL();
1.1027 + theLog.Write(_L8("Test 2 OK\n"));
1.1028 +
1.1029 + TheTest.Next(_L("Delete view while locked"));
1.1030 + TestDeleteViewWhileLockedL();
1.1031 + theLog.Write(_L8("Test 3 OK\n"));
1.1032 +
1.1033 + TheTest.Next(_L("Multiple clients"));
1.1034 + TestMultipleClientLockingL();
1.1035 + theLog.Write(_L8("Test 4 OK\n"));
1.1036 +
1.1037 + TheTest.Next(_L("Multiple views"));
1.1038 + TestMultipleViewLockingL();
1.1039 + theLog.Write(_L8("Test 5 OK\n"));
1.1040 +
1.1041 + TheTest.Next(_L("Client Requests"));
1.1042 + TestClientRequestsL();
1.1043 + theLog.Write(_L8("Test 6 OK\n"));
1.1044 +
1.1045 + TheTest.Next(_L("View setup"));
1.1046 + TestViewSetup1L();
1.1047 + TestViewSetup2L();
1.1048 + theLog.Write(_L8("Test 7 OK\n"));
1.1049 +
1.1050 + TheTest.Next(_L("Notifications"));
1.1051 + TestNotificationsL();
1.1052 + theLog.Write(_L8("Test 8 OK\n"));
1.1053 +
1.1054 + TheTest.Next(_L("Request in progress"));
1.1055 + TestRequestInProgressL();
1.1056 + theLog.Write(_L8("Test 9 OK\n"));
1.1057 +
1.1058 + TheTest.Next(_L("View request in progress"));
1.1059 + TestViewRequestInProgressL();
1.1060 + theLog.Write(_L8("Test 10 OK\n"));
1.1061 +
1.1062 + TheTest.Next(_L("Refresh view"));
1.1063 + TestRefreshViewL();
1.1064 + theLog.Write(_L8("Test 11 OK\n"));
1.1065 +
1.1066 + CleanupStack::PopAndDestroy(notifier);
1.1067 +#endif//__WINS__
1.1068 + }