|
1 // Copyright (c) 2004-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 /** |
|
17 @file |
|
18 @released |
|
19 */ |
|
20 #include "t_teststeprestore.h" |
|
21 |
|
22 namespace bur_ts |
|
23 { |
|
24 |
|
25 CBURTestStepRestore* CBURTestStepRestore::NewL(CBURTestServer& aTestServer) |
|
26 /** |
|
27 Symbian OS Constructor |
|
28 |
|
29 @internalComponent |
|
30 @released |
|
31 |
|
32 @param aParent - The parent CBURTestServer of this child test step. |
|
33 @return Pointer to a newly created CBURTestStepRestore object. |
|
34 */ |
|
35 { |
|
36 CBURTestStepRestore* self = new (ELeave) CBURTestStepRestore(aTestServer); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop(); |
|
40 return self; |
|
41 } |
|
42 |
|
43 CBURTestStepRestore::CBURTestStepRestore(CBURTestServer& aTestServer) |
|
44 /** |
|
45 C++ Constructor |
|
46 |
|
47 @internalComponent |
|
48 @released |
|
49 |
|
50 @param aParent - The parent CBURTestServer of this child test step. |
|
51 */ |
|
52 :CBURTestStepBase(aTestServer) |
|
53 {} |
|
54 |
|
55 void CBURTestStepRestore::ConstructL() |
|
56 /** |
|
57 Symbian OS 2nd-phase Constructor |
|
58 |
|
59 @internalComponent |
|
60 @released |
|
61 */ |
|
62 { |
|
63 TInt error; |
|
64 |
|
65 // Initialise the drive list to empty: |
|
66 iDriveList.FillZ(); |
|
67 |
|
68 iMode = ERestoreMode; |
|
69 |
|
70 User::LeaveIfError(iFs.Connect()); |
|
71 |
|
72 // Install an active scheduler for this test step |
|
73 iActiveScheduler = new(ELeave) CActiveScheduler; |
|
74 CActiveScheduler::Install(iActiveScheduler); |
|
75 |
|
76 TRAP(error, iBackupClient = CSBEClient::NewL()); |
|
77 if (error != KErrNone) |
|
78 { |
|
79 _LIT(KClientConnection, "SBEClientConn"); |
|
80 User::Panic(KClientConnection,error); |
|
81 } |
|
82 |
|
83 _LIT(KBURTRestore, "BURTestServerRestore"); |
|
84 User::RenameThread(KBURTRestore); |
|
85 //User::SetCritical(User::ESystemCritical); |
|
86 |
|
87 SetTestStepName(KBURTestRestore); |
|
88 } |
|
89 |
|
90 CBURTestStepRestore::~CBURTestStepRestore() |
|
91 /** |
|
92 C++ Destructor |
|
93 |
|
94 @internalComponent |
|
95 @released |
|
96 */ |
|
97 { |
|
98 } |
|
99 |
|
100 TVerdict CBURTestStepRestore::doTestStepPreambleL() |
|
101 /** |
|
102 Override of base class virtual function |
|
103 |
|
104 @internalComponent |
|
105 @released |
|
106 @return TVerdict code |
|
107 */ |
|
108 { |
|
109 SetTestStepResult(EPass); |
|
110 return TestStepResult(); |
|
111 } |
|
112 |
|
113 TVerdict CBURTestStepRestore::doTestStepL() |
|
114 /** |
|
115 Override of base class pure virtual |
|
116 |
|
117 @internalComponent |
|
118 @released |
|
119 @return TVerdict code |
|
120 */ |
|
121 { |
|
122 _LIT(KLog1, "Processing user options..."); |
|
123 Log(LOG_LEVEL2, KLog1); |
|
124 ProcessUserOptionsL(); |
|
125 |
|
126 TBURPartType type = EBURRestoreFull; |
|
127 |
|
128 iStorageManager->ReadDataOwnersFromDiskL(iDataOwners); |
|
129 |
|
130 CheckValidRegistrationL(); |
|
131 |
|
132 if (iIsPartial) |
|
133 { |
|
134 _LIT(KLog2, "Preparing for PARTIAL restore..."); |
|
135 Log(LOG_LEVEL2, KLog2); |
|
136 PrepareForPartialBURL(); |
|
137 SetSIDListForPartialL(); |
|
138 type = EBURRestorePartial; |
|
139 } |
|
140 else |
|
141 { |
|
142 _LIT(KLog3, "Preparing for FULL restore..."); |
|
143 Log(LOG_LEVEL2, KLog3); |
|
144 } |
|
145 |
|
146 // Set restore mode: |
|
147 _LIT(KLog4, "Setting restore mode..."); |
|
148 Log(LOG_LEVEL2, KLog4); |
|
149 TRAPD(burmode, SetBURModeL(type, iBackupIncType)); |
|
150 if (burmode != KErrNone) |
|
151 { |
|
152 _LIT(KLog5, "Error setting restore Mode "); |
|
153 LogWithNum(LOG_LEVEL3, KLog5, burmode); |
|
154 } |
|
155 |
|
156 //SupplyRegistrationDataL(); |
|
157 |
|
158 // system data |
|
159 SupplySystemSnapshotDataL(); |
|
160 RestoreSystemBaseDataL(); |
|
161 |
|
162 RestoreJavaMidletL(); |
|
163 |
|
164 // confirm system files restored |
|
165 iBackupClient->AllSystemFilesRestored(); |
|
166 |
|
167 |
|
168 /** Restore data according to user preferences */ |
|
169 if (iBackupIncType == EBackupIncrement) |
|
170 { |
|
171 IncrementalRestoreL(); |
|
172 } |
|
173 else |
|
174 { |
|
175 BaseRestoreL(); |
|
176 } |
|
177 |
|
178 Log(LOG_LEVEL2, _L("Setting backup mode to Normal ...")); |
|
179 TRAPD(err2,SetBURModeL(EBURNormal, ENoBackup)); |
|
180 if (err2 != KErrNone) |
|
181 { |
|
182 _LIT(KBURError, "Error setting Backup mode "); |
|
183 LogWithNum(LOG_LEVEL3, KBURError, err2); |
|
184 } |
|
185 |
|
186 VerifyRestoreResultL(); |
|
187 |
|
188 return TestStepResult(); |
|
189 } |
|
190 |
|
191 void CBURTestStepRestore::VerifyRestoreResultL() |
|
192 { |
|
193 if (iPrivateFileNames.Count() != iPrivateFileSizes.Count()) |
|
194 { |
|
195 iFailures++; |
|
196 _LIT(KLogCount, "Restore name and size count of private files don't match"); |
|
197 Log(LOG_LEVEL3, KLogCount); |
|
198 SetTestStepResult(TVerdict(EFail)); |
|
199 return; |
|
200 } |
|
201 |
|
202 /** if we have configure name list of private file and then we check it. */ |
|
203 if (iPrivateFileNames.Count() > 0) |
|
204 { |
|
205 TInt count = iPrivateFileNames.Count(); |
|
206 for (TInt i=0; i<count; ++i) |
|
207 { |
|
208 RFile file; |
|
209 CleanupClosePushL(file); |
|
210 TInt err = file.Open(Fs(), iPrivateFileNames[i], EFileRead); |
|
211 if (err != KErrNone) |
|
212 { |
|
213 CleanupStack::PopAndDestroy(&file); |
|
214 User::Leave(err); |
|
215 } |
|
216 |
|
217 TInt size; |
|
218 file.Size(size); |
|
219 |
|
220 if (size != iPrivateFileSizes[i]) |
|
221 { |
|
222 iFailures++; |
|
223 _LIT(KLogRestore, "Restore private files error "); |
|
224 Log(LOG_LEVEL3, KLogRestore); |
|
225 SetTestStepResult(TVerdict(EFail)); |
|
226 } |
|
227 CleanupStack::PopAndDestroy(&file); // file |
|
228 }// end for |
|
229 }// end if |
|
230 } |
|
231 |
|
232 void CBURTestStepRestore::BaseRestoreL() |
|
233 /** |
|
234 @internalComponent |
|
235 @released |
|
236 */ |
|
237 { |
|
238 RestoreJavaMidletDataL(); |
|
239 |
|
240 // passive |
|
241 SupplyPassiveSnapshotDataL(); |
|
242 RestorePassiveBaseDataL(); |
|
243 |
|
244 //active |
|
245 SupplyActiveSnapshotDataL(); |
|
246 RestoreActiveBaseDataL(); |
|
247 } |
|
248 |
|
249 void CBURTestStepRestore::IncrementalRestoreL() |
|
250 /** |
|
251 @internalComponent |
|
252 @released |
|
253 */ |
|
254 { |
|
255 RestoreJavaMidletDataL(); |
|
256 |
|
257 // passive |
|
258 SupplyPassiveSnapshotDataL(); |
|
259 RestorePassiveBaseDataL(); |
|
260 RestorePassiveIncDataL(); |
|
261 |
|
262 |
|
263 //active |
|
264 SupplyActiveSnapshotDataL(); |
|
265 RestoreActiveBaseDataL(); |
|
266 RestoreActiveIncDataL(); |
|
267 } |
|
268 |
|
269 |
|
270 void CBURTestStepRestore::SupplyRegistrationDataL() |
|
271 /** |
|
272 @internalComponent |
|
273 @released |
|
274 */ |
|
275 { |
|
276 _LIT(KRes, "Supplying registration data..."); |
|
277 Log(LOG_LEVEL2, KRes); |
|
278 DoSupplyL(ERegistrationData); |
|
279 } |
|
280 |
|
281 void CBURTestStepRestore::SupplyPassiveSnapshotDataL() |
|
282 /** |
|
283 @internalComponent |
|
284 @released |
|
285 */ |
|
286 { |
|
287 _LIT(KSupp, "Supplying passive snapshot data..."); |
|
288 Log(LOG_LEVEL2, KSupp); |
|
289 DoSupplyL(EPassiveSnapshotData); |
|
290 } |
|
291 |
|
292 void CBURTestStepRestore::RestorePassiveBaseDataL() |
|
293 /** |
|
294 @internalComponent |
|
295 @released |
|
296 */ |
|
297 { |
|
298 _LIT(KResBase, "Restoring passive base data..."); |
|
299 Log(LOG_LEVEL2, KResBase); |
|
300 DoSupplyL(EPassiveBaseData); |
|
301 } |
|
302 |
|
303 void CBURTestStepRestore::RestorePassiveIncDataL() |
|
304 /** |
|
305 @internalComponent |
|
306 @released |
|
307 */ |
|
308 { |
|
309 _LIT(KPassInc, "Restoring passive incremental data..."); |
|
310 Log(LOG_LEVEL2, KPassInc); |
|
311 DoSupplyL(EPassiveIncrementalData); |
|
312 } |
|
313 |
|
314 void CBURTestStepRestore::SupplyActiveSnapshotDataL() |
|
315 /** |
|
316 @internalComponent |
|
317 @released |
|
318 */ |
|
319 { |
|
320 _LIT(KSuppSnap, "Supplying active snapshot data..."); |
|
321 Log(LOG_LEVEL2, KSuppSnap); |
|
322 DoSupplyL(EActiveSnapshotData); |
|
323 } |
|
324 |
|
325 void CBURTestStepRestore::RestoreActiveBaseDataL() |
|
326 /** |
|
327 @internalComponent |
|
328 @released |
|
329 */ |
|
330 { |
|
331 _LIT(KActBase, "Restoring active base data..."); |
|
332 Log(LOG_LEVEL2, KActBase); |
|
333 DoSupplyL(EActiveBaseData); |
|
334 } |
|
335 |
|
336 void CBURTestStepRestore::RestoreActiveIncDataL() |
|
337 /** |
|
338 @internalComponent |
|
339 @released |
|
340 */ |
|
341 { |
|
342 _LIT(KActIncD, "Restoring active incremental data..."); |
|
343 Log(LOG_LEVEL2, KActIncD); |
|
344 DoSupplyL(EActiveIncrementalData); |
|
345 } |
|
346 |
|
347 void CBURTestStepRestore::RestoreSystemBaseDataL() |
|
348 /** |
|
349 @internalComponent |
|
350 @released |
|
351 */ |
|
352 { |
|
353 GeneratePIDTransferTypesL(iTransferTypes, ESystemData); |
|
354 // go through each of them and check if we have snapshot to supply |
|
355 if (iTransferTypes.Count()) |
|
356 { |
|
357 _LIT(KSysBase, "Restoring system base data..."); |
|
358 Log(LOG_LEVEL2, KSysBase); |
|
359 SupplyDataL(iTransferTypes); |
|
360 } |
|
361 } |
|
362 |
|
363 void CBURTestStepRestore::SupplySystemSnapshotDataL() |
|
364 /** |
|
365 @internalComponent |
|
366 @released |
|
367 */ |
|
368 { |
|
369 GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData); |
|
370 // go through each of them and check if we have snapshot to supply |
|
371 if (iTransferTypes.Count()) |
|
372 { |
|
373 _LIT(KSysSnap, "Supply System Snapshot Data ..."); |
|
374 Log(LOG_LEVEL2, KSysSnap); |
|
375 SupplyDataL(iTransferTypes); |
|
376 } |
|
377 } |
|
378 |
|
379 void CBURTestStepRestore::RestoreJavaMidletL() |
|
380 /** |
|
381 @internalComponent |
|
382 @released |
|
383 */ |
|
384 { |
|
385 GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDlet); |
|
386 if (iTransferTypes.Count()) |
|
387 { |
|
388 _LIT(KJMidlet, "Restoring Java Midlets ..."); |
|
389 Log(LOG_LEVEL2, KJMidlet); |
|
390 SupplyDataL(iTransferTypes); |
|
391 } |
|
392 } |
|
393 |
|
394 void CBURTestStepRestore::RestoreJavaMidletDataL() |
|
395 /** |
|
396 @internalComponent |
|
397 @released |
|
398 */ |
|
399 { |
|
400 GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDletData); |
|
401 if (iTransferTypes.Count()) |
|
402 { |
|
403 _LIT(KJMidletData, "Restoring Java Midlets Data ..."); |
|
404 Log(LOG_LEVEL2, KJMidletData); |
|
405 SupplyDataL(iTransferTypes); |
|
406 } |
|
407 } |
|
408 |
|
409 TVerdict CBURTestStepRestore::doTestStepPostambleL() |
|
410 /** |
|
411 @return - TVerdict code |
|
412 Override of base class pure virtual |
|
413 */ |
|
414 { |
|
415 _LIT(KLog, "Number of failures:"); |
|
416 LogWithNum(LOG_LEVEL3, KLog, iFailures); |
|
417 if (iFailures) |
|
418 { |
|
419 SetTestStepResult(TVerdict(EFail)); |
|
420 } |
|
421 return TestStepResult(); |
|
422 } |
|
423 |
|
424 |
|
425 } // end namespace |