|
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 |
|
21 #include "t_teststepbackup.h" |
|
22 |
|
23 namespace bur_ts |
|
24 { |
|
25 |
|
26 CBURTestStepBackup* CBURTestStepBackup::NewL(CBURTestServer& aTestServer) |
|
27 /** |
|
28 Symbian OS Constructor |
|
29 |
|
30 @internalComponent |
|
31 @released |
|
32 |
|
33 @param aParent - The parent CBURTestServer of this child test step. |
|
34 @return Pointer to a newly created CBURTestStepBackup object. |
|
35 */ |
|
36 { |
|
37 CBURTestStepBackup* self = new (ELeave) CBURTestStepBackup(aTestServer); |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop(); |
|
41 return self; |
|
42 } |
|
43 |
|
44 CBURTestStepBackup::CBURTestStepBackup(CBURTestServer& aTestServer) |
|
45 /** |
|
46 C++ Constructor |
|
47 |
|
48 @internalComponent |
|
49 @released |
|
50 |
|
51 @param aParent - The parent CBURTestServer of this child test step. |
|
52 */ |
|
53 : CBURTestStepBase(aTestServer), iDataTransferHandler(NULL) |
|
54 {} |
|
55 |
|
56 void CBURTestStepBackup::ConstructL() |
|
57 /** |
|
58 Symbian OS 2nd-phase Constructor |
|
59 |
|
60 @internalComponent |
|
61 @released |
|
62 */ |
|
63 { |
|
64 TInt error; |
|
65 |
|
66 // Initialise the drive list to empty |
|
67 iDriveList.FillZ(); |
|
68 |
|
69 User::LeaveIfError(iFs.Connect()); |
|
70 |
|
71 // Install an active scheduler for this test step |
|
72 iActiveScheduler = new(ELeave) CActiveScheduler; |
|
73 CActiveScheduler::Install(iActiveScheduler); |
|
74 |
|
75 TRAP(error, iBackupClient = CSBEClient::NewL()); |
|
76 if (error != KErrNone) |
|
77 { |
|
78 _LIT(KClientConnection, "SBEClientConnection"); |
|
79 User::Panic(KClientConnection,error); |
|
80 } |
|
81 |
|
82 _LIT(KBURTBackup, "BURTestServerBackup"); |
|
83 User::RenameThread(KBURTBackup); |
|
84 //User::SetCritical(User::ESystemCritical); |
|
85 |
|
86 SetTestStepName(KBURTestBackup); |
|
87 } |
|
88 |
|
89 CBURTestStepBackup::~CBURTestStepBackup() |
|
90 /** |
|
91 C++ Destructor |
|
92 |
|
93 @internalComponent |
|
94 @released |
|
95 */ |
|
96 { |
|
97 delete iDataTransferHandler; |
|
98 } |
|
99 |
|
100 TVerdict CBURTestStepBackup::doTestStepPreambleL() |
|
101 /** |
|
102 Override of base class virtual function |
|
103 |
|
104 @internalComponent |
|
105 @released |
|
106 |
|
107 @return TVerdict code |
|
108 */ |
|
109 { |
|
110 SetTestStepResult(EPass); |
|
111 return TestStepResult(); |
|
112 } |
|
113 |
|
114 TVerdict CBURTestStepBackup::doTestStepL() |
|
115 /** |
|
116 Override of base class pure virtual |
|
117 |
|
118 @internalComponent |
|
119 @released |
|
120 |
|
121 @return TVerdict code |
|
122 */ |
|
123 { |
|
124 _LIT(KLog1, "Processing user options..."); |
|
125 Log(LOG_LEVEL2, KLog1); |
|
126 ProcessUserOptionsL(); |
|
127 |
|
128 // Get a list of data owners: |
|
129 PopulateListOfDataOwnersL(); |
|
130 |
|
131 |
|
132 TBURPartType type = EBURBackupFull; |
|
133 |
|
134 if (iIsPartial) |
|
135 { |
|
136 _LIT(KLog2, "Preparing for PARTIAL backup..."); |
|
137 Log(LOG_LEVEL2, KLog2); |
|
138 type = EBURBackupPartial; |
|
139 PrepareForPartialBURL(); |
|
140 SetSIDListForPartialL(); |
|
141 } |
|
142 else |
|
143 { |
|
144 _LIT(KLog3, "Preparing for FULL backup..."); |
|
145 Log(LOG_LEVEL2, KLog3); |
|
146 } |
|
147 |
|
148 CheckValidRegistrationL(); |
|
149 |
|
150 _LIT(KLog4, "Saving Data Owners..."); |
|
151 Log(LOG_LEVEL2, KLog4); |
|
152 SaveDataOwners(); |
|
153 |
|
154 Log(LOG_LEVEL2, _L("Setting backup mode...")); |
|
155 TRAPD(err,SetBURModeL(type, iBackupIncType)); |
|
156 if (err != KErrNone) |
|
157 { |
|
158 _LIT(KBURError, "Error setting Backup mode "); |
|
159 Log(LOG_LEVEL3, KBURError); |
|
160 } |
|
161 |
|
162 iDataTransferHandler = CAsyncBackupTransferHandler::NewL(this); |
|
163 Log(LOG_LEVEL2, _L("Starting backup...")); |
|
164 |
|
165 //BackupRegistrationDataL(); |
|
166 |
|
167 BackupPublicDataL(); |
|
168 |
|
169 BackupJavaMidletsL(); |
|
170 BackupJavaMidletsDataL(); |
|
171 |
|
172 // Backup data according to user preferences |
|
173 if (iBackupIncType == EBackupIncrement) |
|
174 { |
|
175 IncrementalBackupL(); |
|
176 } |
|
177 else |
|
178 { |
|
179 BaseBackupL(); |
|
180 } |
|
181 |
|
182 Log(LOG_LEVEL2, _L("Setting backup mode to Normal ...")); |
|
183 TRAPD(err2,SetBURModeL(EBURNormal, ENoBackup)); |
|
184 if (err2 != KErrNone) |
|
185 { |
|
186 _LIT(KBURError, "Error setting Backup mode "); |
|
187 Log(LOG_LEVEL3, KBURError); |
|
188 } |
|
189 |
|
190 |
|
191 return TestStepResult(); |
|
192 } |
|
193 |
|
194 void CBURTestStepBackup::BaseBackupL() |
|
195 /** |
|
196 @internalComponent |
|
197 @released |
|
198 */ |
|
199 { |
|
200 // system data |
|
201 BackupSystemBaseDataL(); |
|
202 BackupSystemSnapshotDataL(); |
|
203 |
|
204 //active |
|
205 BackupActiveBaseDataL(); |
|
206 BackupActiveSnapshotDataL(); |
|
207 |
|
208 //passive |
|
209 BackupPassiveBaseDataL(); |
|
210 BackupPassiveSnapshotDataL(); |
|
211 } |
|
212 |
|
213 void CBURTestStepBackup::IncrementalBackupL() |
|
214 /** |
|
215 @internalComponent |
|
216 @released |
|
217 */ |
|
218 { |
|
219 _LIT(KInc, "Backup mode: INCREMENTAL"); |
|
220 Log(LOG_LEVEL2, KInc); |
|
221 //active |
|
222 SupplySystemSnapshotDataL(); |
|
223 SupplyActiveSnapshotDataL(); |
|
224 SupplyPassiveSnapshotDataL(); |
|
225 TRAPD(err,iBackupClient->AllSnapshotsSuppliedL()); |
|
226 if (err != KErrNone) |
|
227 { |
|
228 _LIT(KSnapErr, "Error Supplying Snapshot Data "); |
|
229 LogWithNum(LOG_LEVEL3, KSnapErr, err); |
|
230 } |
|
231 else |
|
232 { |
|
233 _LIT(KSnap, "All Snapshots Supplied"); |
|
234 Log(LOG_LEVEL3, KSnap); |
|
235 } |
|
236 |
|
237 // system data |
|
238 BackupSystemBaseDataL(); |
|
239 BackupSystemSnapshotDataL(); |
|
240 |
|
241 // active |
|
242 BackupActiveIncDataL(); |
|
243 BackupActiveSnapshotDataL(); |
|
244 |
|
245 //passive |
|
246 BackupPassiveIncDataL(); |
|
247 BackupPassiveSnapshotDataL(); |
|
248 } |
|
249 |
|
250 void CBURTestStepBackup::BackupSystemBaseDataL() |
|
251 /** |
|
252 @internalComponent |
|
253 @released |
|
254 */ |
|
255 { |
|
256 _LIT(KLog, "Backup System Data ..."); |
|
257 Log(LOG_LEVEL2, KLog); |
|
258 GeneratePIDTransferTypesL(iTransferTypes, ESystemData); |
|
259 DoBackupL(); |
|
260 } |
|
261 |
|
262 void CBURTestStepBackup::SupplySystemSnapshotDataL() |
|
263 /** |
|
264 @internalComponent |
|
265 @released |
|
266 */ |
|
267 { |
|
268 GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData); |
|
269 // go through each of them and check if we have snapshot to supply |
|
270 if (iTransferTypes.Count()) |
|
271 { |
|
272 _LIT(KLog, "Supply System Snapshot Data ..."); |
|
273 Log(LOG_LEVEL2, KLog); |
|
274 SupplyDataL(iTransferTypes); |
|
275 } |
|
276 } |
|
277 |
|
278 void CBURTestStepBackup::BackupSystemSnapshotDataL() |
|
279 /** |
|
280 @internalComponent |
|
281 @released |
|
282 */ |
|
283 { |
|
284 _LIT(KLog, "Backup System Snapshot Data ..."); |
|
285 Log(LOG_LEVEL2, KLog); |
|
286 GeneratePIDTransferTypesL(iTransferTypes, ESystemSnapshotData); |
|
287 DoBackupL(); |
|
288 } |
|
289 |
|
290 |
|
291 void CBURTestStepBackup::BackupRegistrationDataL() |
|
292 /** |
|
293 @internalComponent |
|
294 @released |
|
295 */ |
|
296 { |
|
297 _LIT(KReg, "Backup registration data..."); |
|
298 Log(LOG_LEVEL2, KReg); |
|
299 GenerateSIDTransferTypesL(iTransferTypes, ERegistrationData); |
|
300 DoBackupL(); |
|
301 } |
|
302 |
|
303 void CBURTestStepBackup::BackupPassiveSnapshotDataL() |
|
304 /** |
|
305 @internalComponent |
|
306 @released |
|
307 */ |
|
308 { |
|
309 _LIT(KPassSnap, "Backup passive snapshot data..."); |
|
310 Log(LOG_LEVEL2, KPassSnap); |
|
311 GenerateSIDTransferTypesL(iTransferTypes, EPassiveSnapshotData); |
|
312 DoBackupL(); |
|
313 } |
|
314 |
|
315 void CBURTestStepBackup::SupplyPassiveSnapshotDataL() |
|
316 /** |
|
317 @internalComponent |
|
318 @released |
|
319 */ |
|
320 { |
|
321 _LIT(KSupp, "Supplying passive snapshot data..."); |
|
322 Log(LOG_LEVEL2, KSupp); |
|
323 DoSupplyL(EPassiveSnapshotData); |
|
324 } |
|
325 |
|
326 void CBURTestStepBackup::BackupPassiveBaseDataL() |
|
327 /** |
|
328 @internalComponent |
|
329 @released |
|
330 */ |
|
331 { |
|
332 _LIT(KPassBase, "Backup passive base data..."); |
|
333 Log(LOG_LEVEL2, KPassBase); |
|
334 GenerateSIDTransferTypesL(iTransferTypes, EPassiveBaseData); |
|
335 DoBackupL(); |
|
336 } |
|
337 |
|
338 void CBURTestStepBackup::BackupPassiveIncDataL() |
|
339 /** |
|
340 @internalComponent |
|
341 @released |
|
342 */ |
|
343 { |
|
344 _LIT(KPassInc, "Backup passive incremental data..."); |
|
345 Log(LOG_LEVEL2, KPassInc); |
|
346 GenerateSIDTransferTypesL(iTransferTypes, EPassiveIncrementalData); |
|
347 DoBackupL(); |
|
348 } |
|
349 |
|
350 void CBURTestStepBackup::BackupActiveSnapshotDataL() |
|
351 /** |
|
352 @internalComponent |
|
353 @released |
|
354 */ |
|
355 { |
|
356 _LIT(KActSnap, "Backup active snapshot data..."); |
|
357 Log(LOG_LEVEL2, KActSnap); |
|
358 DoActiveBackupL(EActiveSnapshotData); |
|
359 } |
|
360 |
|
361 void CBURTestStepBackup::SupplyActiveSnapshotDataL() |
|
362 /** |
|
363 @internalComponent |
|
364 @released |
|
365 */ |
|
366 { |
|
367 _LIT(KSuppActSnap,"Supplying active snapshot data..."); |
|
368 Log(LOG_LEVEL2, KSuppActSnap); |
|
369 DoSupplyL(EActiveSnapshotData); |
|
370 } |
|
371 |
|
372 void CBURTestStepBackup::BackupActiveBaseDataL() |
|
373 /** |
|
374 @internalComponent |
|
375 @released |
|
376 */ |
|
377 { |
|
378 _LIT(KActBase, "Backup active base data..."); |
|
379 Log(LOG_LEVEL2, KActBase); |
|
380 DoActiveBackupL(EActiveBaseData); |
|
381 } |
|
382 |
|
383 void CBURTestStepBackup::BackupActiveIncDataL() |
|
384 /** |
|
385 @internalComponent |
|
386 @released |
|
387 */ |
|
388 { |
|
389 _LIT(KActInc, "Backup active incremental data..."); |
|
390 Log(LOG_LEVEL2, KActInc); |
|
391 DoActiveBackupL(EActiveIncrementalData); |
|
392 } |
|
393 |
|
394 void CBURTestStepBackup::BackupPublicDataL() |
|
395 /** |
|
396 @internalComponent |
|
397 @released |
|
398 */ |
|
399 { |
|
400 _LIT(KPublic, "Backup Public Data..."); |
|
401 Log(LOG_LEVEL2, KPublic); |
|
402 RPointerArray<CSBGenericDataType> array; |
|
403 TRAP_IGNORE(GeneratePublicTransferTypesL(array)); |
|
404 TRAP_IGNORE(DoPublicBackupL(array)); |
|
405 array.ResetAndDestroy(); |
|
406 array.Close(); |
|
407 } |
|
408 |
|
409 void CBURTestStepBackup::DoPublicBackupL(RPointerArray<CSBGenericDataType>& aTransferTypes) |
|
410 /** |
|
411 @internalComponent |
|
412 @released |
|
413 */ |
|
414 { |
|
415 _LIT(KNote, "Public data is Not saved it just for Testing purposes to show the list of files got from the device!"); |
|
416 Log(LOG_LEVEL2, KNote); |
|
417 RFileArray array; |
|
418 CleanupClosePushL(array); |
|
419 RRestoreFileFilterArray rawFileList; |
|
420 CleanupClosePushL(rawFileList); |
|
421 |
|
422 TInt length = iDriveList.Length(); |
|
423 TInt count = aTransferTypes.Count(); |
|
424 for (TInt driveCount = 0; driveCount < length && count; driveCount++) |
|
425 { |
|
426 if (iDriveList[driveCount]) |
|
427 { |
|
428 for (TInt i =0; i < count; i++) |
|
429 { |
|
430 iBackupClient->RawPublicFileListL(TDriveNumber(driveCount), *aTransferTypes[i], rawFileList); |
|
431 iBackupClient->PublicFileListL(TDriveNumber(driveCount), *aTransferTypes[i], array); |
|
432 |
|
433 TInt fileCount = array.Count(); |
|
434 _LIT(KFoundCount, "Found number of files: "); |
|
435 LogWithNum(LOG_LEVEL3, KFoundCount, fileCount); |
|
436 |
|
437 for (TInt j = 0; j < fileCount; j++) |
|
438 { |
|
439 _LIT(KFile, "Public File: "); |
|
440 LogWithText(LOG_LEVEL4, KFile, array[j].iName); |
|
441 } |
|
442 |
|
443 for (TInt j = 0; j < rawFileList.Count(); j++) |
|
444 { |
|
445 _LIT(KFile, "Raw Public File: "); |
|
446 LogWithText(LOG_LEVEL4, KFile, rawFileList[j].iName); |
|
447 } |
|
448 |
|
449 /** Only for one partial backup */ |
|
450 if (iPublicFileNames.Count() > 0) |
|
451 { |
|
452 if (fileCount != iPublicFileNames.Count()) |
|
453 { |
|
454 iFailures++; |
|
455 _LIT(KLogCount, "Backup count of public files don't match "); |
|
456 Log(LOG_LEVEL3, KLogCount); |
|
457 SetTestStepResult(TVerdict(EFail)); |
|
458 } |
|
459 |
|
460 for (TInt k=0; k<fileCount; ++k) |
|
461 { |
|
462 if (iPublicFileNames.Find(array[k].iName) == KErrNotFound) |
|
463 { |
|
464 iFailures++; |
|
465 _LIT(KLogName, "Backup name of public files don't match "); |
|
466 Log(LOG_LEVEL3, KLogName); |
|
467 SetTestStepResult(TVerdict(EFail)); |
|
468 } |
|
469 } |
|
470 } |
|
471 |
|
472 array.Reset(); |
|
473 rawFileList.Reset(); |
|
474 } |
|
475 } |
|
476 } |
|
477 CleanupStack::PopAndDestroy(&rawFileList); |
|
478 CleanupStack::PopAndDestroy(&array); |
|
479 } |
|
480 |
|
481 void CBURTestStepBackup::DoBackupL() |
|
482 /** |
|
483 Core backup method to carry out the transfer as well as the storage of |
|
484 data to the archive. |
|
485 |
|
486 @internalComponent |
|
487 @released |
|
488 |
|
489 @param aDataType - Type of data to be backed up. |
|
490 */ |
|
491 { |
|
492 if (iTransferTypes.Count()) |
|
493 { |
|
494 // STEP 2 - Start the data request handler to backup data: |
|
495 _LIT(KLog2, "Requesting backup data for IDs per drive..."); |
|
496 Log(LOG_LEVEL3, KLog2); |
|
497 iDataTransferHandler->StartL(); |
|
498 // Log success: |
|
499 if (iDataTransferHandler->Success()) |
|
500 { |
|
501 _LIT(KLog3, "Operation finished with no errors"); |
|
502 Log(LOG_LEVEL3, KLog3); |
|
503 } //if |
|
504 else |
|
505 { |
|
506 iFailures++; |
|
507 _LIT(KLog4, "Operation failed with errors "); |
|
508 Log(LOG_LEVEL3, KLog4); |
|
509 SetTestStepResult(TVerdict(EFail)); |
|
510 } //else |
|
511 } //if |
|
512 else |
|
513 { |
|
514 _LIT(KLogNoTrans, "Nothing to do "); |
|
515 Log(LOG_LEVEL3, KLogNoTrans); |
|
516 } //else |
|
517 } |
|
518 |
|
519 |
|
520 void CBURTestStepBackup::DoActiveBackupL(TTransferDataType aTransferDataType) |
|
521 /** |
|
522 @internalComponent |
|
523 @released |
|
524 */ |
|
525 { |
|
526 RTransferTypeArray transferTypes; |
|
527 GenerateSIDTransferTypesL(transferTypes, aTransferDataType); |
|
528 if (transferTypes.Count()) |
|
529 { |
|
530 TRAPD(error, |
|
531 for (TInt i=0; i < KRetries;) |
|
532 { |
|
533 CheckSIDStatusL(transferTypes, iTransferTypes); |
|
534 if (iTransferTypes.Count()) // dataowners ready |
|
535 { |
|
536 DoBackupL(); |
|
537 } |
|
538 else if (transferTypes.Count()) // data owners not ready |
|
539 { |
|
540 User::After(KDelay); |
|
541 i++; |
|
542 } |
|
543 else // finished with all sids |
|
544 { |
|
545 break; |
|
546 } |
|
547 } // for |
|
548 ); //TRAPD |
|
549 if (transferTypes.Count()) |
|
550 { |
|
551 iFailures++; |
|
552 _LIT(KLogNoTrans, "***Error: Some Data Owners were Not Ready or Failed to Connect"); |
|
553 Log(LOG_LEVEL3, KLogNoTrans); |
|
554 } //if |
|
555 transferTypes.ResetAndDestroy(); |
|
556 |
|
557 User::LeaveIfError(error); |
|
558 } |
|
559 else |
|
560 { |
|
561 _LIT(KLogNoTrans, "Nothing to do "); |
|
562 Log(LOG_LEVEL3, KLogNoTrans); |
|
563 } |
|
564 |
|
565 } |
|
566 |
|
567 void CBURTestStepBackup::BackupJavaMidletsL() |
|
568 /** |
|
569 @internalComponent |
|
570 @released |
|
571 */ |
|
572 { |
|
573 _LIT(KMidlet, "Backup midlets..."); |
|
574 Log(LOG_LEVEL2, KMidlet); |
|
575 GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDlet); |
|
576 DoBackupL(); |
|
577 } |
|
578 |
|
579 void CBURTestStepBackup::BackupJavaMidletsDataL() |
|
580 /** |
|
581 @internalComponent |
|
582 @released |
|
583 */ |
|
584 { |
|
585 _LIT(KMidletData, "Backup midlets data..."); |
|
586 Log(LOG_LEVEL2, KMidletData); |
|
587 GenerateJavaTransferTypesL(iTransferTypes, EJavaMIDletData); |
|
588 DoBackupL(); |
|
589 } |
|
590 |
|
591 TVerdict CBURTestStepBackup::doTestStepPostambleL() |
|
592 /** |
|
593 @return - TVerdict code |
|
594 Override of base class pure virtual |
|
595 */ |
|
596 { |
|
597 _LIT(KLog, "Number of failures:"); |
|
598 LogWithNum(LOG_LEVEL3, KLog, iFailures); |
|
599 if (iFailures) |
|
600 { |
|
601 SetTestStepResult(TVerdict(EFail)); |
|
602 } |
|
603 return TestStepResult(); |
|
604 } |
|
605 |
|
606 } // end namespace |