|
1 // Copyright (c) 2002-2009 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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <logview.h> |
|
17 #include "TEST.H" |
|
18 |
|
19 |
|
20 #undef test //there is a "test" macro which hides "RTest test" declaration. |
|
21 |
|
22 RTest test(_L("Contact Test Harness")); |
|
23 |
|
24 /** |
|
25 @SYMTestCaseID SYSLIB-LOGENG-CT-1018 |
|
26 @SYMTestCaseDesc Tests for backup operations |
|
27 @SYMTestPriority High |
|
28 @SYMTestActions Check by adding events and closing the backup file. |
|
29 Check for ErrNone flag. |
|
30 @SYMTestExpectedResults Test must not fail |
|
31 @SYMREQ REQ0000 |
|
32 */ |
|
33 static void TestBackupL(CLogClient& aClient) |
|
34 { |
|
35 test.Next(_L(" @SYMTestCaseID:SYSLIB-LOGENG-CT-1018 ")); |
|
36 CTestActive* active = new (ELeave) CTestActive; |
|
37 CleanupStack::PushL(active); |
|
38 |
|
39 CLogEvent* event = CLogEvent::NewL(); |
|
40 CleanupStack::PushL(event); |
|
41 event->SetEventType(KLogCallEventTypeUid); |
|
42 |
|
43 CBaBackupSessionWrapper* backup = CBaBackupSessionWrapper::NewL(); |
|
44 CleanupStack::PushL(backup); |
|
45 |
|
46 // Add event |
|
47 active->StartL(); |
|
48 aClient.AddEvent(*event, active->iStatus); |
|
49 CActiveScheduler::Start(); |
|
50 TEST2(active->iStatus.Int(), KErrNone); |
|
51 |
|
52 TDriveUnit driveUnit(EDriveC); |
|
53 TDriveName name = driveUnit.Name(); |
|
54 |
|
55 TParse parse; |
|
56 LEAVE_IF_ERROR(parse.Set(KLogDatabaseName, &name, NULL)); |
|
57 |
|
58 //Close, then delete LogEng database file. Restart backup operations monitoring |
|
59 //on LogEng database. |
|
60 backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess); |
|
61 User::After(1000000); |
|
62 TestUtils::DeleteDatabaseL(EFalse); |
|
63 backup->RestartFile(parse.FullName()); |
|
64 User::After(1000000); |
|
65 |
|
66 // Add event |
|
67 active->StartL(); |
|
68 aClient.AddEvent(*event, active->iStatus); |
|
69 CActiveScheduler::Start(); |
|
70 TEST2(active->iStatus.Int(), KErrNone); |
|
71 |
|
72 // Add event |
|
73 active->StartL(); |
|
74 aClient.AddEvent(*event, active->iStatus); |
|
75 CActiveScheduler::Start(); |
|
76 TEST2(active->iStatus.Int(), KErrNone); |
|
77 |
|
78 //Close LogEng database file |
|
79 backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess); |
|
80 //Delete LogEng database file |
|
81 User::After(1000000); |
|
82 TestUtils::DeleteDatabaseL(EFalse); |
|
83 //Restart backup operations monitoring on LogEng database. |
|
84 backup->RestartFile(parse.FullName()); |
|
85 User::After(1000000); |
|
86 |
|
87 // Add event |
|
88 active->StartL(); |
|
89 aClient.AddEvent(*event, active->iStatus); |
|
90 CActiveScheduler::Start(); |
|
91 TEST2(active->iStatus.Int(), KErrNone); |
|
92 |
|
93 //Close LogEng database file. |
|
94 backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess); |
|
95 //Delete LogEng database file. |
|
96 User::After(1000000); |
|
97 TestUtils::DeleteDatabaseL(EFalse); |
|
98 //Restart backup operations monitoring on LogEng database. |
|
99 backup->RestartFile(parse.FullName()); |
|
100 User::After(1000000); |
|
101 |
|
102 // Add event |
|
103 active->StartL(); |
|
104 aClient.AddEvent(*event, active->iStatus); |
|
105 CActiveScheduler::Start(); |
|
106 TEST2(active->iStatus.Int(), KErrNone); |
|
107 |
|
108 //Close LogEng database |
|
109 backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess); |
|
110 User::After(1000000); |
|
111 //Delete LogEng database |
|
112 TestUtils::DeleteDatabaseL(EFalse); |
|
113 //Restart backup operations monitoring on LogEng database. |
|
114 backup->RestartFile(parse.FullName()); |
|
115 |
|
116 // Add event |
|
117 active->StartL(); |
|
118 aClient.AddEvent(*event, active->iStatus); |
|
119 CActiveScheduler::Start(); |
|
120 TEST2(active->iStatus.Int(), KErrNone); |
|
121 //Close LogEng database |
|
122 backup->CloseFileL(parse.FullName(), MBackupObserver::EReleaseLockNoAccess); |
|
123 User::After(1000000); |
|
124 //Delete LogEng database |
|
125 TestUtils::DeleteDatabaseL(EFalse); |
|
126 //Restart backup operations monitoring on LogEng database. |
|
127 backup->RestartFile(parse.FullName()); |
|
128 User::After(1000000); |
|
129 |
|
130 // Add event |
|
131 active->StartL(); |
|
132 aClient.AddEvent(*event, active->iStatus); |
|
133 CActiveScheduler::Start(); |
|
134 TEST2(active->iStatus.Int(), KErrNone); |
|
135 |
|
136 active->StartL(); |
|
137 backup->CloseAll(MBackupObserver::EReleaseLockNoAccess, active->iStatus); |
|
138 CActiveScheduler::Start(); |
|
139 TEST2(active->iStatus.Int(), KErrNone); |
|
140 User::After(1000000); |
|
141 |
|
142 TestUtils::DeleteDatabaseL(EFalse); |
|
143 backup->RestartAll(); |
|
144 User::After(1000000); |
|
145 |
|
146 // Add event |
|
147 active->StartL(); |
|
148 aClient.AddEvent(*event, active->iStatus); |
|
149 CActiveScheduler::Start(); |
|
150 TEST2(active->iStatus.Int(), KErrNone); |
|
151 |
|
152 CleanupStack::PopAndDestroy(3); // backup, event, active |
|
153 } |
|
154 |
|
155 |
|
156 void doTestsL() |
|
157 { |
|
158 TestUtils::Initialize(_L("T_LOGCONTACT")); |
|
159 |
|
160 test.Start(_L("Prepare the test environment")); |
|
161 |
|
162 // Create log client |
|
163 CLogClient* client = CLogClient::NewL(theFs); |
|
164 CleanupStack::PushL(client); |
|
165 |
|
166 // Send a message to the hicap helper to delete logeng DB |
|
167 TestUtils::DeleteDatabaseL(); |
|
168 |
|
169 test.Next(_L("Backup")); |
|
170 TestBackupL(*client); |
|
171 test.Next(_L("Backup completed ok")); |
|
172 theLog.Write(_L8("Test 2 OK\n")); |
|
173 |
|
174 CleanupStack::PopAndDestroy(client); |
|
175 } |