Update contrib.
1 // Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
17 #include "t_logutil2.h"
19 RTest TheTest(_L("t_logcontact"));
22 @SYMTestCaseID SYSLIB-LOGENG-CT-1018
23 @SYMTestCaseDesc Tests for backup operations
25 @SYMTestActions Check by adding events and closing the backup file.
26 Check for ErrNone flag.
27 @SYMTestExpectedResults Test must not fail
30 static void TestBackupL(CLogClient& aClient)
32 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1018 "));
33 CTestActive* active = new (ELeave) CTestActive;
34 CleanupStack::PushL(active);
36 CLogEvent* event = CLogEvent::NewL();
37 CleanupStack::PushL(event);
38 event->SetEventType(KLogCallEventTypeUid);
40 CBaBackupSessionWrapper* backup = CBaBackupSessionWrapper::NewL();
41 CleanupStack::PushL(backup);
45 aClient.AddEvent(*event, active->iStatus);
46 CActiveScheduler::Start();
47 TEST2(active->iStatus.Int(), KErrNone);
49 TDriveUnit driveUnit(EDriveC);
50 TDriveName name = driveUnit.Name();
53 LEAVE_IF_ERROR(parse.Set(KLogDatabaseName, &name, NULL));
55 //Close, then delete LogEng database file. Restart backup operations monitoring
57 backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
59 TestUtils::DeleteDatabaseL(EFalse);
60 backup->RestartFile(parse.FullName());
65 aClient.AddEvent(*event, active->iStatus);
66 CActiveScheduler::Start();
67 TEST2(active->iStatus.Int(), KErrNone);
71 aClient.AddEvent(*event, active->iStatus);
72 CActiveScheduler::Start();
73 TEST2(active->iStatus.Int(), KErrNone);
75 //Close LogEng database file
76 backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
77 //Delete LogEng database file
79 TestUtils::DeleteDatabaseL(EFalse);
80 //Restart backup operations monitoring on LogEng database.
81 backup->RestartFile(parse.FullName());
86 aClient.AddEvent(*event, active->iStatus);
87 CActiveScheduler::Start();
88 TEST2(active->iStatus.Int(), KErrNone);
90 //Close LogEng database file.
91 backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
92 //Delete LogEng database file.
94 TestUtils::DeleteDatabaseL(EFalse);
95 //Restart backup operations monitoring on LogEng database.
96 backup->RestartFile(parse.FullName());
101 aClient.AddEvent(*event, active->iStatus);
102 CActiveScheduler::Start();
103 TEST2(active->iStatus.Int(), KErrNone);
105 //Close LogEng database
106 backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
107 User::After(1000000);
108 //Delete LogEng database
109 TestUtils::DeleteDatabaseL(EFalse);
110 //Restart backup operations monitoring on LogEng database.
111 backup->RestartFile(parse.FullName());
115 aClient.AddEvent(*event, active->iStatus);
116 CActiveScheduler::Start();
117 TEST2(active->iStatus.Int(), KErrNone);
118 //Close LogEng database
119 backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess);
120 User::After(1000000);
121 //Delete LogEng database
122 TestUtils::DeleteDatabaseL(EFalse);
123 //Restart backup operations monitoring on LogEng database.
124 backup->RestartFile(parse.FullName());
125 User::After(1000000);
129 aClient.AddEvent(*event, active->iStatus);
130 CActiveScheduler::Start();
131 TEST2(active->iStatus.Int(), KErrNone);
134 backup->CloseAll(MBackupObserver::EReleaseLockNoAccess, active->iStatus);
135 CActiveScheduler::Start();
136 TEST2(active->iStatus.Int(), KErrNone);
137 User::After(1000000);
139 TestUtils::DeleteDatabaseL(EFalse);
140 backup->RestartAll();
141 User::After(1000000);
145 aClient.AddEvent(*event, active->iStatus);
146 CActiveScheduler::Start();
147 TEST2(active->iStatus.Int(), KErrNone);
149 CleanupStack::PopAndDestroy(3); // backup, event, active
155 TestUtils::Initialize(_L("t_logcontact"));
157 TheTest.Start(_L("Prepare the test environment"));
160 CLogClient* client = CLogClient::NewL(theFs);
161 CleanupStack::PushL(client);
163 // Send a message to the hicap helper to delete logeng DB
164 TestUtils::DeleteDatabaseL();
166 TheTest.Next(_L("Backup"));
167 TestBackupL(*client);
168 TheTest.Next(_L("Backup completed ok"));
169 theLog.Write(_L8("Test 2 OK\n"));
171 CleanupStack::PopAndDestroy(client);