|
1 // Copyright (c) 2005-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 // Example CTestStep derived implementation |
|
15 // |
|
16 |
|
17 |
|
18 |
|
19 /** |
|
20 @file SELFStep.cpp |
|
21 @internalTechnology |
|
22 */ |
|
23 #include "SELFpluginstep.h" |
|
24 #include "tcoredumpserversuitedefs.h" |
|
25 |
|
26 CSELFPluginStep::~CSELFPluginStep() |
|
27 /** |
|
28 * Destructor |
|
29 */ |
|
30 { |
|
31 } |
|
32 |
|
33 CSELFPluginStep::CSELFPluginStep() |
|
34 /** |
|
35 * Constructor |
|
36 */ |
|
37 { |
|
38 // **MUST** call SetTestStepName in the constructor as the controlling |
|
39 // framework uses the test step name immediately following construction to set |
|
40 // up the step's unique logging ID. |
|
41 SetTestStepName(KSELFPluginStep); |
|
42 } |
|
43 |
|
44 TVerdict CSELFPluginStep::doTestStepPreambleL() |
|
45 /** |
|
46 * @return - TVerdict code |
|
47 * Override of base class virtual |
|
48 */ |
|
49 { |
|
50 |
|
51 TInt ret = KErrNone; |
|
52 ret = iSess.Connect(); |
|
53 if(ret != KErrNone) |
|
54 { |
|
55 SetTestStepResult( EFail ); |
|
56 INFO_PRINTF2(_L("Error %d from iSess->Connect()/n"), ret); |
|
57 } |
|
58 else |
|
59 { |
|
60 SetTestStepResult(EPass); |
|
61 } |
|
62 |
|
63 return TestStepResult(); |
|
64 } |
|
65 |
|
66 |
|
67 TVerdict CSELFPluginStep::doTestStepL() |
|
68 /** |
|
69 * @return - TVerdict code |
|
70 * Override of base class pure virtual |
|
71 * Our implementation only gets called if the base class doTestStepPreambleL() did |
|
72 * not leave. That being the case, the current test result value will be EPass. |
|
73 */ |
|
74 { |
|
75 if (TestStepResult()==EPass) |
|
76 { |
|
77 TInt ret = KErrNone; |
|
78 |
|
79 __UHEAP_MARK; |
|
80 |
|
81 TRAP(ret, ClientAppL()); |
|
82 if(KErrNone != ret) |
|
83 { |
|
84 SetTestStepResult(EFail); |
|
85 INFO_PRINTF2(_L("Error %d from CSELFStep->ClientAppL()"), ret); |
|
86 } |
|
87 |
|
88 __UHEAP_MARKEND; |
|
89 |
|
90 } |
|
91 return TestStepResult(); |
|
92 } |
|
93 |
|
94 void CSELFPluginStep::ClientAppL() |
|
95 /** |
|
96 * @return void |
|
97 * This calls each stage of the test |
|
98 */ |
|
99 { |
|
100 INFO_PRINTF1(_L("Starting SELF Plugin Test Suite") ); |
|
101 LoadPluginL(); |
|
102 UnloadPluginL(); |
|
103 for(TInt i = 1; i < SelfMultipleTries; i++) |
|
104 { |
|
105 LoadMultiplePluginsL(i); |
|
106 UnloadMultiplePluginsL(i); |
|
107 } |
|
108 |
|
109 } |
|
110 |
|
111 void CSELFPluginStep::LoadPluginL() |
|
112 /** |
|
113 * @return void |
|
114 * Tests that the plugin can be loaded correctly |
|
115 */ |
|
116 { |
|
117 if (TestStepResult()==EPass) |
|
118 { |
|
119 |
|
120 INFO_PRINTF1(_L("Attempting to load SELF Plugin")); |
|
121 |
|
122 TPluginRequest req; |
|
123 req.iPluginType = TPluginRequest::EFormatter; |
|
124 req.iLoad = ETrue; |
|
125 req.iUid = SELF_UID; |
|
126 |
|
127 // Should be allowed to load Symbian ELF |
|
128 TRAPD(ret, iSess.PluginRequestL( req )); |
|
129 if(ret != KErrNone) |
|
130 { |
|
131 INFO_PRINTF2(_L("Failed loading plugin with UID 0x%X -- SELF Plugin/n"), req.iUid ); |
|
132 User::Leave(ret); |
|
133 } |
|
134 |
|
135 //Now we need to look in the plugin list and make sure the SELF plugin isnt there |
|
136 RPluginList plugins; |
|
137 CleanupClosePushL(plugins); |
|
138 |
|
139 TRAP(ret, iSess.GetPluginListL(plugins)); |
|
140 if (ret != KErrNone) |
|
141 { |
|
142 INFO_PRINTF2(_L("Failed to get plugin list -- SELF Plugin. Error: %d"), ret); |
|
143 User::Leave(ret); |
|
144 } |
|
145 |
|
146 //Now we look through the list, until we find our plugin, its a fail |
|
147 SetTestStepResult(EFail); |
|
148 |
|
149 for (TInt i = 0; i < plugins.Count(); i++) |
|
150 { |
|
151 if (plugins[i].iUid == SELF_UID && plugins[i].iLoaded) |
|
152 { |
|
153 SetTestStepResult(EPass); |
|
154 INFO_PRINTF1(_L("SELF Plugin loaded successfully")); |
|
155 CleanupStack::PopAndDestroy();//take plugins off cleanupstack |
|
156 return; |
|
157 } |
|
158 } |
|
159 |
|
160 INFO_PRINTF1(_L("SELF Plugin failed to load successfully")); |
|
161 CleanupStack::PopAndDestroy(); |
|
162 |
|
163 } |
|
164 } |
|
165 |
|
166 void CSELFPluginStep::UnloadPluginL() |
|
167 /** |
|
168 * @return void |
|
169 * Tests the plugin can be successfully unloaded |
|
170 */ |
|
171 { |
|
172 if(TestStepResult()==EPass) |
|
173 { |
|
174 INFO_PRINTF1(_L("Attempting to unload SELF Plugin")); |
|
175 |
|
176 TPluginRequest req; |
|
177 req.iPluginType = TPluginRequest::EFormatter; |
|
178 req.iLoad = EFalse; |
|
179 req.iUid = SELF_UID; |
|
180 |
|
181 TRAPD(ret, iSess.PluginRequestL( req )); |
|
182 if(ret != KErrNone) |
|
183 { |
|
184 INFO_PRINTF2(_L("Failed unloading plugin with UID 0x%X -- SELF Plugin"), req.iUid ); |
|
185 User::Leave(ret); |
|
186 } |
|
187 |
|
188 //Now we need to look in the plugin list and make sure the SELF plugin isnt there |
|
189 RPluginList plugins; |
|
190 CleanupClosePushL(plugins); |
|
191 |
|
192 TRAP(ret, iSess.GetPluginListL(plugins)); |
|
193 if (ret != KErrNone) |
|
194 { |
|
195 INFO_PRINTF2(_L("Failed to get plugin list -- SELF Plugin. Error: %d"), ret); |
|
196 User::Leave(ret); |
|
197 } |
|
198 |
|
199 //Now we look through the list, until we find our plugin, its a fail |
|
200 SetTestStepResult(EFail); |
|
201 |
|
202 for (TInt i = 0; i < plugins.Count(); i++) |
|
203 { |
|
204 if (plugins[i].iUid == SELF_UID && !plugins[i].iLoaded) |
|
205 { |
|
206 SetTestStepResult(EPass); |
|
207 INFO_PRINTF1(_L("SELF Plugin unloaded successfully")); |
|
208 CleanupStack::PopAndDestroy(); |
|
209 return; |
|
210 } |
|
211 } |
|
212 |
|
213 INFO_PRINTF1(_L("SELF Plugin failed to unload successfully")); |
|
214 CleanupStack::PopAndDestroy(); |
|
215 } |
|
216 } |
|
217 |
|
218 void CSELFPluginStep::UnloadPluginL(const TInt aIndex) |
|
219 /** |
|
220 * @return void |
|
221 * Tests the plugin can be successfully unloaded |
|
222 */ |
|
223 { |
|
224 if(TestStepResult()==EPass) |
|
225 { |
|
226 INFO_PRINTF2(_L("Attempting to unload SELF Plugin. Index = [%d]"), aIndex); |
|
227 |
|
228 TPluginRequest req; |
|
229 req.iPluginType = TPluginRequest::EFormatter; |
|
230 req.iLoad = EFalse; |
|
231 req.iUid = SELF_UID; |
|
232 |
|
233 TRAPD(ret, iSess.PluginRequestL( req )); |
|
234 if(ret != KErrNone) |
|
235 { |
|
236 INFO_PRINTF2(_L("Failed unloading plugin with UID 0x%X -- SELF Plugin"), req.iUid ); |
|
237 User::Leave(ret); |
|
238 } |
|
239 |
|
240 INFO_PRINTF1(_L("SELF Plugin unloaded successfully")); |
|
241 } |
|
242 } |
|
243 |
|
244 void CSELFPluginStep::LoadMultiplePluginsL(const TInt aCount) |
|
245 /** |
|
246 * @return void |
|
247 * This tests behaviour when we attempt to load an already loaded SELF plugin. |
|
248 * Should only be loaded once, even after calling twice |
|
249 */ |
|
250 { |
|
251 if (TestStepResult()==EPass) |
|
252 { |
|
253 INFO_PRINTF1(_L("Testing loading the SELF plugin multiple times")); |
|
254 for(TInt i = 0; i < aCount; i++) |
|
255 { |
|
256 LoadPluginL(); |
|
257 } |
|
258 |
|
259 //Now we need to look in the plugin list and make sure the DEXEC plugin isnt there multiple times |
|
260 RPluginList plugins; |
|
261 CleanupClosePushL(plugins); |
|
262 |
|
263 TRAPD(ret, iSess.GetPluginListL(plugins)); |
|
264 if (ret != KErrNone) |
|
265 { |
|
266 INFO_PRINTF2(_L("Failed to get plugin list -- SELF Plugin. Error: %d"), ret); |
|
267 User::Leave(ret); |
|
268 } |
|
269 |
|
270 TInt selfCounter = 0; |
|
271 for (TInt i = 0; i < plugins.Count(); i++) |
|
272 { |
|
273 if (plugins[i].iUid == SELF_UID && plugins[i].iLoaded) |
|
274 { |
|
275 selfCounter++; |
|
276 break; |
|
277 } |
|
278 } |
|
279 |
|
280 if(selfCounter == 0) |
|
281 { |
|
282 SetTestStepResult(EFail); |
|
283 INFO_PRINTF1(_L("Fail - SELF plugin has been not marked as loaded")); |
|
284 } |
|
285 |
|
286 RPluginPointerList formatterList; |
|
287 TRAP(ret, iSess.GetFormattersL(formatterList)); |
|
288 selfCounter = 0; |
|
289 for(TInt i = 0; i < formatterList.Count(); i++) |
|
290 { |
|
291 if(TUid::Uid(formatterList[i]->Uid()) == SELF_UID) |
|
292 { |
|
293 selfCounter++; |
|
294 } |
|
295 } |
|
296 formatterList.ResetAndDestroy(); |
|
297 |
|
298 if(selfCounter != aCount) |
|
299 { |
|
300 SetTestStepResult(EFail); |
|
301 INFO_PRINTF2(_L("Fail - SELF plugin has not been found loaded %d times"), aCount); |
|
302 } |
|
303 else |
|
304 { |
|
305 INFO_PRINTF1(_L("Loading plugin multiple times is ok")); |
|
306 } |
|
307 |
|
308 CleanupStack::PopAndDestroy(); |
|
309 } |
|
310 } |
|
311 |
|
312 void CSELFPluginStep::UnloadMultiplePluginsL(const TInt aCount) |
|
313 /** |
|
314 * @return void |
|
315 * This tests behaviour when we attempt to unload the SELF plugin when it has |
|
316 * not been loaded |
|
317 */ |
|
318 { |
|
319 if (TestStepResult()==EPass) |
|
320 { |
|
321 INFO_PRINTF2(_L("Testing unloading the SELF plugin multiple times - %d"), aCount); |
|
322 for(TInt i = aCount; i > 0; i--) |
|
323 { |
|
324 UnloadPluginL(i - 1); |
|
325 } |
|
326 |
|
327 //Now we need to look in the plugin list and make sure the SELF plugin isnt there |
|
328 RPluginList plugins; |
|
329 CleanupClosePushL(plugins); |
|
330 |
|
331 TRAPD(ret, iSess.GetPluginListL(plugins)); |
|
332 if (ret != KErrNone) |
|
333 { |
|
334 INFO_PRINTF2(_L("Failed to get plugin list -- SELF Plugin. Error: %d"), ret); |
|
335 User::Leave(ret); |
|
336 } |
|
337 |
|
338 TInt selfCounter = aCount; |
|
339 for (TInt i = 0; i < plugins.Count(); i++) |
|
340 { |
|
341 if (plugins[i].iUid == SELF_UID && plugins[i].iLoaded) |
|
342 { |
|
343 selfCounter = 0; |
|
344 break; |
|
345 } |
|
346 } |
|
347 |
|
348 if(selfCounter == 0) |
|
349 { |
|
350 SetTestStepResult(EFail); |
|
351 INFO_PRINTF1(_L("Fail - SELF plugin has been found marked as loaded")); |
|
352 } |
|
353 |
|
354 RPluginPointerList formatterList; |
|
355 TRAP(ret, iSess.GetFormattersL(formatterList)); |
|
356 selfCounter = 0; |
|
357 for(TInt i = 0; i < formatterList.Count(); i++) |
|
358 { |
|
359 if(TUid::Uid(formatterList[i]->Uid()) == SELF_UID) |
|
360 { |
|
361 selfCounter++; |
|
362 } |
|
363 } |
|
364 formatterList.ResetAndDestroy(); |
|
365 |
|
366 if(selfCounter > 0) |
|
367 { |
|
368 SetTestStepResult(EFail); |
|
369 INFO_PRINTF2(_L("Fail - SELF %d plugins has been found loaded"), selfCounter); |
|
370 } |
|
371 else |
|
372 { |
|
373 INFO_PRINTF1(_L("Unloading plugin multiple times is ok")); |
|
374 } |
|
375 |
|
376 CleanupStack::PopAndDestroy(); |
|
377 } |
|
378 } |
|
379 |
|
380 TVerdict CSELFPluginStep::doTestStepPostambleL() |
|
381 /** |
|
382 * @return - TVerdict code |
|
383 * Override of base class virtual |
|
384 */ |
|
385 { |
|
386 iSess.Disconnect(); |
|
387 User::After(10000000); //ensure we give enough time for session to close |
|
388 return EPass; |
|
389 } |