1 /* |
|
2 * Copyright (c) 2008-2010 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 "appmanagersteps.h" |
|
20 #include "tscrdefs.h" |
|
21 |
|
22 using namespace Usif; |
|
23 |
|
24 // -----------CScrIsMediaPresentStep----------------- |
|
25 |
|
26 CScrIsMediaPresentStep::CScrIsMediaPresentStep(CScrTestServer& aParent) : CScrTestStep(aParent) |
|
27 { |
|
28 } |
|
29 |
|
30 void CScrIsMediaPresentStep::ImplTestStepPreambleL() |
|
31 { |
|
32 CScrTestStep::ImplTestStepPreambleL(); |
|
33 } |
|
34 |
|
35 void CScrIsMediaPresentStep::ImplTestStepL() |
|
36 { |
|
37 TInt componentId = GetComponentIdL(); |
|
38 TBool expectedMediaPresent(EFalse); |
|
39 if (!GetBoolFromConfig(ConfigSection(), _L("ExpectedMediaPresent"), expectedMediaPresent)) |
|
40 { |
|
41 PrintErrorL(_L("ExpectedMediaPresent property not found"), KErrNotFound); |
|
42 } |
|
43 TBool foundMediaPresent = iScrSession.IsMediaPresentL(componentId); |
|
44 if (foundMediaPresent != expectedMediaPresent) |
|
45 { |
|
46 ERR_PRINTF4(_L("Mismatch for IsMediaPresentL for component id %d. Expected %d and the result was %d."), componentId, expectedMediaPresent, foundMediaPresent); |
|
47 SetTestStepResult(EFail); |
|
48 } |
|
49 } |
|
50 |
|
51 void CScrIsMediaPresentStep::ImplTestStepPostambleL() |
|
52 { |
|
53 CScrTestStep::ImplTestStepPostambleL(); |
|
54 } |
|
55 |
|
56 // -----------CScrIsComponentOrphanedStep----------------- |
|
57 |
|
58 CScrIsComponentOrphanedStep::CScrIsComponentOrphanedStep(CScrTestServer& aParent) : CScrTestStep(aParent) |
|
59 { |
|
60 } |
|
61 |
|
62 void CScrIsComponentOrphanedStep::ImplTestStepPreambleL() |
|
63 { |
|
64 CScrTestStep::ImplTestStepPreambleL(); |
|
65 } |
|
66 |
|
67 void CScrIsComponentOrphanedStep::ImplTestStepL() |
|
68 { |
|
69 TInt componentId = GetComponentIdL(); |
|
70 TBool expectedComponentOrphaned(EFalse); |
|
71 if (!GetBoolFromConfig(ConfigSection(), _L("ExpectedComponentOrphaned"), expectedComponentOrphaned)) |
|
72 { |
|
73 PrintErrorL(_L("ExpectedComponentOrphaned property not found"), KErrNotFound); |
|
74 } |
|
75 TBool foundComponentOrphaned = iScrSession.IsComponentOrphanedL(componentId); |
|
76 if (foundComponentOrphaned != expectedComponentOrphaned) |
|
77 { |
|
78 ERR_PRINTF4(_L("Mismatch for IsComponentOrphanedL for component id %d. Expected %d and the result was %d."), componentId, expectedComponentOrphaned, foundComponentOrphaned); |
|
79 SetTestStepResult(EFail); |
|
80 } |
|
81 } |
|
82 |
|
83 void CScrIsComponentOrphanedStep::ImplTestStepPostambleL() |
|
84 { |
|
85 CScrTestStep::ImplTestStepPostambleL(); |
|
86 } |
|
87 |
|
88 // -----------CScrCompareVersionsStep----------------- |
|
89 |
|
90 CScrCompareVersionsStep::CScrCompareVersionsStep(CScrTestServer& aParent) : CScrTestStep(aParent) |
|
91 { |
|
92 } |
|
93 |
|
94 void CScrCompareVersionsStep::ImplTestStepPreambleL() |
|
95 { |
|
96 CScrTestStep::ImplTestStepPreambleL(); |
|
97 } |
|
98 |
|
99 void CScrCompareVersionsStep::ImplTestStepL() |
|
100 { |
|
101 HBufC *lVer = GetVersionFromConfigL(KVersionLeft()); |
|
102 CleanupStack::PushL(lVer); |
|
103 |
|
104 HBufC *rVer = GetVersionFromConfigL(KVersionRight()); |
|
105 CleanupStack::PushL(rVer); |
|
106 |
|
107 if(!lVer || !rVer) |
|
108 PrintErrorL(_L("Missing version!"), KErrNotFound); |
|
109 |
|
110 TInt expectedResult; |
|
111 if (!GetIntFromConfig(ConfigSection(), KExpectedResult, expectedResult)) |
|
112 PrintErrorL(_L("The expected result param could not be found in configuration."), KErrNotFound); |
|
113 |
|
114 TInt retrievedResult = iScrSession.CompareVersionsL(*lVer, *rVer); |
|
115 |
|
116 if(retrievedResult > 0) |
|
117 retrievedResult = 1; |
|
118 else if(retrievedResult < 0) |
|
119 retrievedResult = -1; |
|
120 |
|
121 if(retrievedResult != expectedResult) |
|
122 PrintErrorL(_L("The retrieved result (%d) is different from the expected one (%d)."), KErrNotFound, retrievedResult, expectedResult); |
|
123 |
|
124 CleanupStack::PopAndDestroy(2, lVer); // lVer, rVer |
|
125 } |
|
126 |
|
127 void CScrCompareVersionsStep::ImplTestStepPostambleL() |
|
128 { |
|
129 CScrTestStep::ImplTestStepPostambleL(); |
|
130 } |
|
131 |
|
132 // -----------CScrIsComponentOnReadOnlyDriveStep----------------- |
|
133 |
|
134 CScrIsComponentOnReadOnlyDriveStep::CScrIsComponentOnReadOnlyDriveStep(CScrTestServer& aParent) : CScrTestStep(aParent) |
|
135 { |
|
136 } |
|
137 |
|
138 void CScrIsComponentOnReadOnlyDriveStep::ImplTestStepPreambleL() |
|
139 { |
|
140 CScrTestStep::ImplTestStepPreambleL(); |
|
141 } |
|
142 |
|
143 void CScrIsComponentOnReadOnlyDriveStep::ImplTestStepL() |
|
144 { |
|
145 TInt componentId = GetComponentIdL(); |
|
146 TBool expectedROMResult(EFalse); |
|
147 if (!GetBoolFromConfig(ConfigSection(), _L("ExpectedROMResult"), expectedROMResult)) |
|
148 { |
|
149 PrintErrorL(_L("ExpectedROMResult property not found"), KErrNotFound); |
|
150 } |
|
151 |
|
152 TBool result = iScrSession.IsComponentOnReadOnlyDriveL(componentId); |
|
153 if (result != expectedROMResult) |
|
154 { |
|
155 ERR_PRINTF4(_L("Mismatch for IsComponentOnReadOnlyDriveL for component id %d. Expected %d and the result was %d."), componentId, expectedROMResult, result); |
|
156 SetTestStepResult(EFail); |
|
157 } |
|
158 } |
|
159 |
|
160 void CScrIsComponentOnReadOnlyDriveStep::ImplTestStepPostambleL() |
|
161 { |
|
162 CScrTestStep::ImplTestStepPostambleL(); |
|
163 } |
|
164 |
|
165 // -----------CScrComponentPresenceStep----------------- |
|
166 |
|
167 CScrComponentPresenceStep::CScrComponentPresenceStep(CScrTestServer& aParent) : CScrTestStep(aParent) |
|
168 { |
|
169 } |
|
170 |
|
171 void CScrComponentPresenceStep::ImplTestStepPreambleL() |
|
172 { |
|
173 CScrTestStep::ImplTestStepPreambleL(); |
|
174 } |
|
175 |
|
176 void CScrComponentPresenceStep::ImplTestStepL() |
|
177 { |
|
178 TInt componentId = GetComponentIdL(); |
|
179 |
|
180 TBool compPresenceValue(ETrue); |
|
181 if (!GetBoolFromConfig(ConfigSection(), _L("CompPresenceValue"), compPresenceValue)) |
|
182 { |
|
183 PrintErrorL(_L("CompPresenceValue property not found"), KErrNotFound); |
|
184 } |
|
185 |
|
186 TBool setCompPresence(EFalse); |
|
187 GetBoolFromConfig(ConfigSection(), _L("SetCompPresence"), setCompPresence); |
|
188 if (setCompPresence) |
|
189 { |
|
190 iScrSession.SetIsComponentPresentL(componentId, compPresenceValue); |
|
191 } |
|
192 |
|
193 TBool result = iScrSession.IsComponentPresentL(componentId); |
|
194 if (result != compPresenceValue) |
|
195 { |
|
196 ERR_PRINTF4(_L("Mismatch for IsComponentPresentL for component id %d. Expected %d and the result was %d."), componentId, compPresenceValue, result); |
|
197 SetTestStepResult(EFail); |
|
198 } |
|
199 } |
|
200 |
|
201 void CScrComponentPresenceStep::ImplTestStepPostambleL() |
|
202 { |
|
203 CScrTestStep::ImplTestStepPostambleL(); |
|
204 } |
|
205 |
|
206 // -----------CScrEMMCComponentStep----------------- |
|
207 |
|
208 CScrEMMCComponentStep::CScrEMMCComponentStep(CScrTestServer& aParent) : CScrTestStep(aParent) |
|
209 { |
|
210 } |
|
211 |
|
212 void CScrEMMCComponentStep::ImplTestStepPreambleL() |
|
213 { |
|
214 CScrTestStep::ImplTestStepPreambleL(); |
|
215 } |
|
216 |
|
217 void CScrEMMCComponentStep::ImplTestStepL() |
|
218 { |
|
219 TInt noOfComponents(0); |
|
220 GetIntFromConfig(ConfigSection(), KNoOfComponents, noOfComponents); |
|
221 |
|
222 TPtrC formatDrive; |
|
223 GetStringFromConfig(ConfigSection(), KFormatDrive, formatDrive); |
|
224 TInt drive; |
|
225 RFs fs; |
|
226 User::LeaveIfError(fs.Connect()); |
|
227 User::LeaveIfError(fs.CharToDrive(formatDrive[0], drive)); |
|
228 fs.Close(); |
|
229 TDriveList filterFormatDrive; |
|
230 filterFormatDrive.FillZ(KMaxDrives); |
|
231 filterFormatDrive[drive] = 1; |
|
232 |
|
233 CComponentFilter* componentFilter = CComponentFilter::NewLC(); |
|
234 componentFilter->SetInstalledDrivesL(filterFormatDrive); |
|
235 |
|
236 RArray<TComponentId> foundComponentIds; |
|
237 CleanupClosePushL(foundComponentIds); |
|
238 |
|
239 iScrSession.GetComponentIdsL(foundComponentIds, componentFilter); |
|
240 |
|
241 if (foundComponentIds.Count() != noOfComponents) |
|
242 { |
|
243 ERR_PRINTF1(_L("Mismatch for number of components found.")); |
|
244 SetTestStepResult(EFail); |
|
245 } |
|
246 CleanupStack::PopAndDestroy(2); |
|
247 } |
|
248 |
|
249 void CScrEMMCComponentStep::ImplTestStepPostambleL() |
|
250 { |
|
251 CScrTestStep::ImplTestStepPostambleL(); |
|
252 } |
|
253 |
|
254 // -----------CScrComponentPresentForNameVendorStep----------------- |
|
255 |
|
256 CScrComponentPresentForNameVendorStep::CScrComponentPresentForNameVendorStep(CScrTestServer& aParent) : CScrTestStep(aParent) |
|
257 { |
|
258 } |
|
259 |
|
260 void CScrComponentPresentForNameVendorStep::ImplTestStepPreambleL() |
|
261 { |
|
262 CScrTestStep::ImplTestStepPreambleL(); |
|
263 } |
|
264 |
|
265 void CScrComponentPresentForNameVendorStep::ImplTestStepL() |
|
266 { |
|
267 TPtrC name; |
|
268 GetStringFromConfig(ConfigSection(), KComponentName, name); |
|
269 |
|
270 TPtrC vendor; |
|
271 GetStringFromConfig(ConfigSection(), KVendorName, vendor); |
|
272 |
|
273 CComponentFilter* componentFilter = CComponentFilter::NewLC(); |
|
274 componentFilter->SetNameL(name); |
|
275 componentFilter->SetVendorL(vendor); |
|
276 |
|
277 RArray<TComponentId> foundComponentIds; |
|
278 CleanupClosePushL(foundComponentIds); |
|
279 |
|
280 iScrSession.GetComponentIdsL(foundComponentIds, componentFilter); |
|
281 |
|
282 TInt noOfComponents(0); |
|
283 GetIntFromConfig(ConfigSection(), KNoOfComponents, noOfComponents); |
|
284 |
|
285 if (foundComponentIds.Count() != noOfComponents) |
|
286 { |
|
287 ERR_PRINTF1(_L("Mismatch for number of components found.")); |
|
288 SetTestStepResult(EFail); |
|
289 } |
|
290 CleanupStack::PopAndDestroy(2); |
|
291 } |
|
292 |
|
293 void CScrComponentPresentForNameVendorStep::ImplTestStepPostambleL() |
|
294 { |
|
295 CScrTestStep::ImplTestStepPostambleL(); |
|
296 } |
|