sl@0: // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include "t_logutil2.h" sl@0: sl@0: RTest TheTest(_L("t_logcontact")); sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-LOGENG-CT-1018 sl@0: @SYMTestCaseDesc Tests for backup operations sl@0: @SYMTestPriority High sl@0: @SYMTestActions Check by adding events and closing the backup file. sl@0: Check for ErrNone flag. sl@0: @SYMTestExpectedResults Test must not fail sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: static void TestBackupL(CLogClient& aClient) sl@0: { sl@0: TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1018 ")); 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: event->SetEventType(KLogCallEventTypeUid); sl@0: sl@0: CBaBackupSessionWrapper* backup = CBaBackupSessionWrapper::NewL(); sl@0: CleanupStack::PushL(backup); sl@0: sl@0: // Add event sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: TDriveUnit driveUnit(EDriveC); sl@0: TDriveName name = driveUnit.Name(); sl@0: sl@0: TParse parse; sl@0: LEAVE_IF_ERROR(parse.Set(KLogDatabaseName, &name, NULL)); sl@0: sl@0: //Close, then delete LogEng database file. Restart backup operations monitoring sl@0: //on LogEng database. sl@0: backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess); sl@0: User::After(1000000); sl@0: TestUtils::DeleteDatabaseL(EFalse); sl@0: backup->RestartFile(parse.FullName()); sl@0: User::After(1000000); sl@0: sl@0: // Add event sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: // Add event sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: //Close LogEng database file sl@0: backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess); sl@0: //Delete LogEng database file sl@0: User::After(1000000); sl@0: TestUtils::DeleteDatabaseL(EFalse); sl@0: //Restart backup operations monitoring on LogEng database. sl@0: backup->RestartFile(parse.FullName()); sl@0: User::After(1000000); sl@0: sl@0: // Add event sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: //Close LogEng database file. sl@0: backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess); sl@0: //Delete LogEng database file. sl@0: User::After(1000000); sl@0: TestUtils::DeleteDatabaseL(EFalse); sl@0: //Restart backup operations monitoring on LogEng database. sl@0: backup->RestartFile(parse.FullName()); sl@0: User::After(1000000); sl@0: sl@0: // Add event sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: //Close LogEng database sl@0: backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess); sl@0: User::After(1000000); sl@0: //Delete LogEng database sl@0: TestUtils::DeleteDatabaseL(EFalse); sl@0: //Restart backup operations monitoring on LogEng database. sl@0: backup->RestartFile(parse.FullName()); sl@0: sl@0: // Add event sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: //Close LogEng database sl@0: backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess); sl@0: User::After(1000000); sl@0: //Delete LogEng database sl@0: TestUtils::DeleteDatabaseL(EFalse); sl@0: //Restart backup operations monitoring on LogEng database. sl@0: backup->RestartFile(parse.FullName()); sl@0: User::After(1000000); sl@0: sl@0: // Add event sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: active->StartL(); sl@0: backup->CloseAll(MBackupObserver::EReleaseLockNoAccess, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: User::After(1000000); sl@0: sl@0: TestUtils::DeleteDatabaseL(EFalse); sl@0: backup->RestartAll(); sl@0: User::After(1000000); sl@0: sl@0: // Add event sl@0: active->StartL(); sl@0: aClient.AddEvent(*event, active->iStatus); sl@0: CActiveScheduler::Start(); sl@0: TEST2(active->iStatus.Int(), KErrNone); sl@0: sl@0: CleanupStack::PopAndDestroy(3); // backup, event, active sl@0: } sl@0: sl@0: sl@0: void doTestsL() sl@0: { sl@0: TestUtils::Initialize(_L("t_logcontact")); sl@0: sl@0: TheTest.Start(_L("Prepare the test environment")); sl@0: sl@0: // Create log client sl@0: CLogClient* client = CLogClient::NewL(theFs); sl@0: CleanupStack::PushL(client); sl@0: sl@0: // Send a message to the hicap helper to delete logeng DB sl@0: TestUtils::DeleteDatabaseL(); sl@0: sl@0: TheTest.Next(_L("Backup")); sl@0: TestBackupL(*client); sl@0: TheTest.Next(_L("Backup completed ok")); sl@0: theLog.Write(_L8("Test 2 OK\n")); sl@0: sl@0: CleanupStack::PopAndDestroy(client); sl@0: }