|
1 /* |
|
2 * Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "swifileutilitysteps.h" |
|
20 #include <e32std.h> |
|
21 |
|
22 CSwiCopyFilesStep::CSwiCopyFilesStep() |
|
23 { |
|
24 SetTestStepName(KSwiCopyFilesStep); |
|
25 } |
|
26 |
|
27 TVerdict CSwiCopyFilesStep::doTestStepL() |
|
28 { |
|
29 _LIT(KNumCopy, "numcopy"); |
|
30 _LIT(KSource, "source"); |
|
31 _LIT(KDest, "dest"); |
|
32 TInt numberFilesToCopy; |
|
33 |
|
34 TPtrC sourceFile; |
|
35 TPtrC destFile; |
|
36 |
|
37 SetTestStepResult(EFail); |
|
38 |
|
39 RTestUtilSessionSwi testUtil; |
|
40 User::LeaveIfError(testUtil.Connect()); |
|
41 CleanupClosePushL(testUtil); |
|
42 |
|
43 GetIntFromConfig(ConfigSection(), KNumCopy(), numberFilesToCopy); |
|
44 |
|
45 INFO_PRINTF2(_L("Config file read. Number of files to copy: %d"), numberFilesToCopy); |
|
46 |
|
47 HBufC* lookup = HBufC::NewLC((7 + numberFilesToCopy/10)); |
|
48 TPtr lookupPtr = lookup->Des(); |
|
49 |
|
50 for (TInt i=0; i<numberFilesToCopy; ++i) |
|
51 { |
|
52 lookupPtr.Zero(); |
|
53 lookupPtr.Append(KSource()); |
|
54 lookupPtr.AppendNum(i); |
|
55 |
|
56 GetStringFromConfig(ConfigSection(), lookupPtr, sourceFile); |
|
57 |
|
58 if (!testUtil.FileExistsL(sourceFile)) |
|
59 { |
|
60 ERR_PRINTF2(_L("Source file for copy not found: "), &sourceFile); |
|
61 return TestStepResult(); |
|
62 } |
|
63 |
|
64 lookupPtr.Zero(); |
|
65 lookupPtr.Append(KDest()); |
|
66 lookupPtr.AppendNum(i); |
|
67 |
|
68 GetStringFromConfig(ConfigSection(), lookupPtr, destFile); |
|
69 |
|
70 INFO_PRINTF3(_L("Copying file from %S to %S ..."), &sourceFile, &destFile); |
|
71 User::LeaveIfError(testUtil.Copy(sourceFile, destFile)); |
|
72 INFO_PRINTF1(_L("...Done.")); |
|
73 } |
|
74 |
|
75 CleanupStack::PopAndDestroy(2); |
|
76 |
|
77 SetTestStepResult(EPass); |
|
78 return TestStepResult(); |
|
79 } |
|
80 |
|
81 CSwiDeleteFilesStep::CSwiDeleteFilesStep() |
|
82 { |
|
83 SetTestStepName(KSwiDeleteFilesStep); |
|
84 } |
|
85 |
|
86 TVerdict CSwiDeleteFilesStep::doTestStepL() |
|
87 { |
|
88 _LIT(KNumDelete, "numdelete"); |
|
89 _LIT(KDelete, "delete"); |
|
90 TInt numberFilesToDelete; |
|
91 |
|
92 TPtrC target; |
|
93 |
|
94 SetTestStepResult(EFail); |
|
95 |
|
96 RTestUtilSessionSwi testUtil; |
|
97 User::LeaveIfError(testUtil.Connect()); |
|
98 CleanupClosePushL(testUtil); |
|
99 |
|
100 GetIntFromConfig(ConfigSection(), KNumDelete(), numberFilesToDelete); |
|
101 |
|
102 INFO_PRINTF2(_L("Config file read. Number of files to delete: %d"), numberFilesToDelete); |
|
103 |
|
104 HBufC* lookup = HBufC::NewLC((7 + numberFilesToDelete/10)); |
|
105 TPtr lookupPtr = lookup->Des(); |
|
106 |
|
107 for (TInt i=0; i<numberFilesToDelete; ++i) |
|
108 { |
|
109 lookupPtr.Zero(); |
|
110 lookupPtr.Append(KDelete()); |
|
111 lookupPtr.AppendNum(i); |
|
112 |
|
113 GetStringFromConfig(ConfigSection(), lookupPtr, target); |
|
114 |
|
115 if (!testUtil.FileExistsL(target)) |
|
116 { |
|
117 ERR_PRINTF2(_L("Target file for delete not found: "), &target); |
|
118 continue; |
|
119 } |
|
120 |
|
121 INFO_PRINTF2(_L("Deleting file %S ..."), &target); |
|
122 User::LeaveIfError(testUtil.Delete(target)); |
|
123 INFO_PRINTF1(_L("...Done.")); |
|
124 } |
|
125 |
|
126 CleanupStack::PopAndDestroy(2); |
|
127 |
|
128 SetTestStepResult(EPass); |
|
129 return TestStepResult(); |
|
130 } |