|
1 // Copyright (c) 2007-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 #include <e32test.h> |
|
17 #include <f32file.h> |
|
18 #include <bautils.h> |
|
19 #include <ecom/ecom.h> |
|
20 #include <ecom/ecompanics.h> |
|
21 #include "EComUidCodes.h" |
|
22 #include "Interface.h" // interface to Plugins |
|
23 #include "../EcomTestUtils/EcomTestUtils.h" |
|
24 |
|
25 //The tests test all the new APIs added to REComSession created for EC43 |
|
26 |
|
27 TUid KCExampleImplUid = {0x10009DC3}; |
|
28 |
|
29 const TInt KOneSecond = 1000000; |
|
30 |
|
31 LOCAL_D RTest test(_L("t_extendedinterfaces")); |
|
32 LOCAL_D RFs TheFs; |
|
33 |
|
34 #define __UNUSED_VAR(var) var = var |
|
35 |
|
36 // Used for OOM test |
|
37 #define TEST_OOM_ERR if(err == KErrNoMemory) {User::Leave(err);} |
|
38 |
|
39 |
|
40 static void ResetAndDestroyArray(TAny* aPtr) |
|
41 { |
|
42 (static_cast<RImplInfoPtrArray*>(aPtr))->ResetAndDestroy(); |
|
43 } |
|
44 |
|
45 |
|
46 /** |
|
47 Test function for REcomSession::ListImplementationL |
|
48 |
|
49 @param aContainInvalidExtIf The bool value identifying if the extended interfaces list contains |
|
50 invalid extended interface Uid |
|
51 @param aUseDefResolver The bool value identifying if default resolver is used. |
|
52 @param aUseResolveParam The bool value identifying if resolve parameter is used. |
|
53 @param aNumEntriesInExtIFList The number of entries in the extended interfaces list. |
|
54 @param aImplInfoArray A reference to a client owned array which will be filled |
|
55 with interface implementation data. |
|
56 */ |
|
57 LOCAL_C void ListImplementationTestL(TBool aContainInvalidExtIf, |
|
58 TBool aUseDefResolver, |
|
59 TBool aUseResolveParam, |
|
60 TInt aNumEntriesInExtIFList, |
|
61 RImplInfoPtrArray& aImplInfoArray) |
|
62 { |
|
63 const TUid KInterfaceUid = {0x10009DBB}; |
|
64 const TUid KExtendedInterfaceUid1 = {0x10009E44}; |
|
65 const TUid KExtendedInterfaceUid2 = {0x10009E45}; |
|
66 const TUid KExtendedInterfaceUid3 = {0x10009E46}; |
|
67 const TUid KInvalidExtendedInterfaceUid2 = {0x10009E49}; |
|
68 _LIT8(KExample10ImplementationTest,"Example 10"); |
|
69 |
|
70 TUid resolverUid = {0x10009DD0}; |
|
71 |
|
72 // Set up extended interfaces |
|
73 RArray<TUid> extendedInterfaces; |
|
74 CleanupClosePushL(extendedInterfaces); |
|
75 |
|
76 if (!aContainInvalidExtIf) |
|
77 { |
|
78 if (aNumEntriesInExtIFList==1) |
|
79 { |
|
80 extendedInterfaces.AppendL(KExtendedInterfaceUid1); |
|
81 } |
|
82 else if (aNumEntriesInExtIFList>1) |
|
83 { |
|
84 extendedInterfaces.AppendL(KExtendedInterfaceUid2); |
|
85 extendedInterfaces.AppendL(KExtendedInterfaceUid3); |
|
86 } |
|
87 } |
|
88 else |
|
89 { |
|
90 extendedInterfaces.AppendL(KExtendedInterfaceUid1); |
|
91 extendedInterfaces.AppendL(KInvalidExtendedInterfaceUid2); |
|
92 } |
|
93 |
|
94 //Set up resolve parameter |
|
95 TEComResolverParams ResolverParams; |
|
96 if (aUseResolveParam) |
|
97 { |
|
98 ResolverParams.SetDataType(KExample10ImplementationTest()); |
|
99 ResolverParams.SetGenericMatch(ETrue); // Allow wildcard matching |
|
100 if (aUseDefResolver) //ListImplementationTest2L,ListImplementationTest4L |
|
101 { |
|
102 REComSession::ListImplementationsL(KInterfaceUid,extendedInterfaces,ResolverParams,aImplInfoArray); |
|
103 } |
|
104 else //ListImplementationTest3L |
|
105 { |
|
106 REComSession::ListImplementationsL(KInterfaceUid,extendedInterfaces,ResolverParams,resolverUid,aImplInfoArray); |
|
107 } |
|
108 |
|
109 } |
|
110 else //ListImplementationTest1L, ListImplementationTest5L |
|
111 { |
|
112 REComSession::ListImplementationsL(KInterfaceUid,extendedInterfaces,aImplInfoArray); |
|
113 } |
|
114 CleanupStack::PopAndDestroy(&extendedInterfaces); |
|
115 } |
|
116 |
|
117 |
|
118 /** |
|
119 @SYMTestCaseID SYSLIB-ECOM-CT-3597 |
|
120 @SYMTestCaseDesc Tests for CImplementationInformation structure. |
|
121 @SYMTestPriority High |
|
122 @SYMTestActions Call ListImplementationL method to get a list of implementations with extended interfaces. |
|
123 Check that the expected extended interfaces are available in the CImplementationInformation |
|
124 data structure via GetExtendedInterfaceList method. |
|
125 @SYMTestExpectedResults Extended interfaces are available in implementation information structure. |
|
126 @SYMEC EC43 |
|
127 */ |
|
128 LOCAL_C void ListImplementationTest5L() |
|
129 { |
|
130 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3597 ")); |
|
131 // Test Starts... |
|
132 RImplInfoPtrArray ifArray; |
|
133 TBool containInvalidExtIf = EFalse; |
|
134 TBool useDefResolver = ETrue; |
|
135 TBool useResolveParam = EFalse; |
|
136 TInt numEntriesOnExtIFList = 3; |
|
137 |
|
138 ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); |
|
139 |
|
140 //Checks the result |
|
141 //0x10009E38 is implemented in EcomExample10.dll |
|
142 TUid KExample10ImplUid = {0x10009E38}; |
|
143 TUid KExtendedInterfaceUid1 = {0x10009E44}; |
|
144 TUid KExtendedInterfaceUid2 = {0x10009E45}; |
|
145 TUid KExtendedInterfaceUid3 = {0x10009E46}; |
|
146 const TInt availCount = ifArray.Count(); |
|
147 test.Printf(_L("Found %d implementations.\n"),availCount); |
|
148 test(availCount == 1); |
|
149 |
|
150 //tests extended interfaces |
|
151 CImplementationInformation* info = ifArray[0]; |
|
152 test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); |
|
153 test (KExample10ImplUid==info->ImplementationUid()); |
|
154 |
|
155 CleanupStack::PushL(TCleanupItem(ResetAndDestroyArray, &ifArray)); |
|
156 |
|
157 // Gets extended interfaces list |
|
158 RArray<TUid> extInf; |
|
159 CleanupClosePushL(extInf); |
|
160 info->GetExtendedInterfaceListL(extInf); |
|
161 test(extInf[0] == KExtendedInterfaceUid1); |
|
162 test(extInf[1] == KExtendedInterfaceUid2); |
|
163 test(extInf[2] == KExtendedInterfaceUid3); |
|
164 CleanupStack::PopAndDestroy(&extInf); |
|
165 |
|
166 // Empty the array of implementations |
|
167 test.Printf(_L("Destroying List...")); |
|
168 CleanupStack::PopAndDestroy(&ifArray); |
|
169 } |
|
170 |
|
171 |
|
172 /** |
|
173 @SYMTestCaseID SYSLIB-ECOM-CT-3594 |
|
174 @SYMTestCaseDesc Tests for REComSession::ListImplementationL created with an Interface Uid |
|
175 and invalid extended Interfaces. |
|
176 @SYMTestPriority High |
|
177 @SYMTestActions Call ListImplementationL method supporting interface UID and extended interfaces |
|
178 that are invalid. |
|
179 @SYMTestExpectedResults No implementation is returned. |
|
180 @SYMEC EC43 |
|
181 */ |
|
182 LOCAL_C void ListImplementationTest4L() |
|
183 { |
|
184 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3594 ")); |
|
185 // Test Starts... |
|
186 RImplInfoPtrArray ifArray; |
|
187 TBool containInvalidExtIf = ETrue; |
|
188 TBool useDefResolver = ETrue; |
|
189 TBool useResolveParam = ETrue; |
|
190 TInt numEntriesOnExtIFList = 2; |
|
191 |
|
192 ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); |
|
193 |
|
194 //Checks the result |
|
195 const TInt availCount = ifArray.Count(); |
|
196 test.Printf(_L("Found %d implementations.\n"),availCount); |
|
197 test(availCount == 0); |
|
198 |
|
199 // Empty the array of implementations |
|
200 test.Printf(_L("Destroying List...")); |
|
201 ifArray.ResetAndDestroy(); |
|
202 } |
|
203 |
|
204 /** |
|
205 @SYMTestCaseID SYSLIB-ECOM-CT-3589 |
|
206 @SYMTestCaseDesc Tests for REComSession::ListImplementationsL for known Interface UID, |
|
207 resolver match characteristics, resolver UID and extended interfaces. |
|
208 @SYMTestPriority High |
|
209 @SYMTestActions Call ListImplementationL method supporting interface UID, resolver parameters |
|
210 resolver UID and extended interfaces. |
|
211 @SYMTestExpectedResults Expected implementations are returned. |
|
212 @SYMEC EC43 |
|
213 */ |
|
214 LOCAL_C void ListImplementationTest3L() |
|
215 { |
|
216 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3589 ")); |
|
217 // Test Starts... |
|
218 RImplInfoPtrArray ifArray; |
|
219 TBool containInvalidExtIf = EFalse; |
|
220 TBool useDefResolver = EFalse; |
|
221 TBool useResolveParam = ETrue; |
|
222 |
|
223 //Number of entries in extended interfaces is 3. |
|
224 TInt numEntriesOnExtIFList = 3; |
|
225 ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); |
|
226 |
|
227 //Checks the result |
|
228 TUid KImplementationUid = {0x10009E38}; |
|
229 TInt availCount = ifArray.Count(); |
|
230 test.Printf(_L("Found %d implementations.\n"),availCount); |
|
231 test(availCount == 1); |
|
232 |
|
233 //tests implementation uid |
|
234 for (TInt count = 0; count < availCount; ++count) |
|
235 { |
|
236 const CImplementationInformation* info = ifArray[count]; |
|
237 test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); |
|
238 test(KImplementationUid == info->ImplementationUid()); |
|
239 } |
|
240 |
|
241 // Empty the array of implementations |
|
242 test.Printf(_L("Destroying List...")); |
|
243 ifArray.ResetAndDestroy(); |
|
244 |
|
245 //Number of entries in extended interfaces is 0. |
|
246 numEntriesOnExtIFList = 0; |
|
247 ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); |
|
248 |
|
249 //Checks the result |
|
250 availCount = ifArray.Count(); |
|
251 test.Printf(_L("Found %d implementations.\n"),availCount); |
|
252 test(availCount == 1); |
|
253 |
|
254 //tests implementation uid |
|
255 for (TInt count = 0; count < availCount; ++count) |
|
256 { |
|
257 const CImplementationInformation* info = ifArray[count]; |
|
258 test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); |
|
259 } |
|
260 |
|
261 // Empty the array of implementations |
|
262 test.Printf(_L("Destroying List...")); |
|
263 ifArray.ResetAndDestroy(); |
|
264 |
|
265 //Number of entries in extended interfaces is 1. |
|
266 numEntriesOnExtIFList = 1; |
|
267 ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); |
|
268 |
|
269 //Checks the result |
|
270 availCount = ifArray.Count(); |
|
271 test.Printf(_L("Found %d implementations.\n"),availCount); |
|
272 test(availCount == 1); |
|
273 |
|
274 //tests implementation uid |
|
275 for (TInt count = 0; count < availCount; ++count) |
|
276 { |
|
277 const CImplementationInformation* info = ifArray[count]; |
|
278 test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); |
|
279 } |
|
280 |
|
281 // Empty the array of implementations |
|
282 test.Printf(_L("Destroying List...")); |
|
283 ifArray.ResetAndDestroy(); |
|
284 } |
|
285 |
|
286 |
|
287 /** |
|
288 @SYMTestCaseID SYSLIB-ECOM-CT-3588 |
|
289 @SYMTestCaseDesc Tests for REComSession::ListImplementationsL for known Interface UID, |
|
290 resolver match characteristics and extended interfaces. |
|
291 @SYMTestPriority High |
|
292 @SYMTestActions Call ListImplementationL method supporting interface UID, resolver parameters and extended interfaces. |
|
293 @SYMTestExpectedResults Expected implementations are returned. |
|
294 @SYMEC EC43 |
|
295 */ |
|
296 LOCAL_C void ListImplementationTest2L() |
|
297 { |
|
298 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3588 ")); |
|
299 // Test Starts... |
|
300 RImplInfoPtrArray ifArray; |
|
301 TBool containInvalidExtIf = EFalse; |
|
302 TBool useDefResolver = ETrue; |
|
303 TBool useResolveParam = ETrue; |
|
304 |
|
305 //Number of entries in extended interfaces is 3. |
|
306 TInt numEntriesOnExtIFList = 3; |
|
307 ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); |
|
308 |
|
309 //Checks the result |
|
310 TUid KImplementationUid = {0x10009E38}; |
|
311 TInt availCount = ifArray.Count(); |
|
312 test.Printf(_L("Found %d implementations.\n"),availCount); |
|
313 test(availCount == 1); |
|
314 |
|
315 //tests implementation uid |
|
316 for (TInt count = 0; count < availCount; ++count) |
|
317 { |
|
318 const CImplementationInformation* info = ifArray[count]; |
|
319 test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); |
|
320 test(KImplementationUid==info->ImplementationUid()); |
|
321 } |
|
322 |
|
323 // Empty the array of implementations |
|
324 test.Printf(_L("Destroying List...")); |
|
325 ifArray.ResetAndDestroy(); |
|
326 |
|
327 //Number of entries in extended interfaces is 0. |
|
328 numEntriesOnExtIFList = 0; |
|
329 ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); |
|
330 |
|
331 //Checks the result |
|
332 availCount = ifArray.Count(); |
|
333 test.Printf(_L("Found %d implementations.\n"),availCount); |
|
334 test(availCount == 1); |
|
335 |
|
336 //tests implementation uid |
|
337 for (TInt count = 0; count < availCount; ++count) |
|
338 { |
|
339 const CImplementationInformation* info = ifArray[count]; |
|
340 test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); |
|
341 } |
|
342 |
|
343 // Empty the array of implementations |
|
344 test.Printf(_L("Destroying List...")); |
|
345 ifArray.ResetAndDestroy(); |
|
346 |
|
347 //Number of entries in extended interfaces is 1. |
|
348 numEntriesOnExtIFList = 1; |
|
349 ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); |
|
350 |
|
351 //Checks the result |
|
352 availCount = ifArray.Count(); |
|
353 test.Printf(_L("Found %d implementations.\n"),availCount); |
|
354 test(availCount == 1); |
|
355 |
|
356 //tests implementation uid |
|
357 for (TInt count = 0; count < availCount; ++count) |
|
358 { |
|
359 const CImplementationInformation* info = ifArray[count]; |
|
360 test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); |
|
361 } |
|
362 |
|
363 // Empty the array of implementations |
|
364 test.Printf(_L("Destroying List...")); |
|
365 ifArray.ResetAndDestroy(); |
|
366 } |
|
367 |
|
368 |
|
369 /** |
|
370 @SYMTestCaseID SYSLIB-ECOM-CT-3587 |
|
371 @SYMTestCaseDesc Tests for REComSession::ListImplementationsL for known Interface UID and extended interfaces. |
|
372 @SYMTestPriority High |
|
373 @SYMTestActions Call ListImplementationL method supporting interface UID and extended interfaces. |
|
374 @SYMTestExpectedResults Expected implementations are returned. |
|
375 @SYMEC EC43 |
|
376 */ |
|
377 LOCAL_C void ListImplementationTest1L() |
|
378 { |
|
379 // |
|
380 // Testing a overloaded method for ListImplementationsL |
|
381 // ------------------------------------------------------------------ |
|
382 // |
|
383 // Test Starts... |
|
384 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3587 ")); |
|
385 RImplInfoPtrArray ifArray; |
|
386 |
|
387 TBool containInvalidExtIf = EFalse; |
|
388 TBool useDefResolver = ETrue; |
|
389 TBool useResolveParam = EFalse; |
|
390 |
|
391 //Number of entries in extended interfaces is 3. |
|
392 TInt numEntriesOnExtIFList = 3; |
|
393 ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); |
|
394 |
|
395 //Checks the result |
|
396 //0x10009E38 is implemented in EcomExample10.dll |
|
397 TUid KExample10ImplUid = {0x10009E38}; |
|
398 TInt availCount = ifArray.Count(); |
|
399 test.Printf(_L("Found %d implementations.\n"),availCount); |
|
400 test(availCount == 1); |
|
401 |
|
402 //tests implementation uid |
|
403 const CImplementationInformation* info = ifArray[0]; |
|
404 test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); |
|
405 test(KExample10ImplUid == info->ImplementationUid()); |
|
406 |
|
407 // Empty the array of implementations |
|
408 test.Printf(_L("Destroying List...")); |
|
409 ifArray.ResetAndDestroy(); |
|
410 |
|
411 //Number of entries in extended interfaces is 0. |
|
412 numEntriesOnExtIFList = 0; |
|
413 ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); |
|
414 |
|
415 //Checks the result |
|
416 availCount = ifArray.Count(); |
|
417 test.Printf(_L("Found %d implementations.\n"),availCount); |
|
418 test(availCount == 3); |
|
419 |
|
420 //tests implementation uid |
|
421 for (TInt count = 0;count < availCount; ++count) |
|
422 { |
|
423 const CImplementationInformation* info = ifArray[count]; |
|
424 test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); |
|
425 } |
|
426 |
|
427 // Empty the array of implementations |
|
428 test.Printf(_L("Destroying List...")); |
|
429 ifArray.ResetAndDestroy(); |
|
430 |
|
431 //Number of entries in extended interfaces is 1. |
|
432 numEntriesOnExtIFList = 1; |
|
433 ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); |
|
434 |
|
435 //Checks the result |
|
436 availCount = ifArray.Count(); |
|
437 test.Printf(_L("Found %d implementations.\n"),availCount); |
|
438 test(availCount == 2); |
|
439 |
|
440 //tests implementation uid |
|
441 for (TInt count = 0; count < availCount; ++count) |
|
442 { |
|
443 const CImplementationInformation* info = ifArray[count]; |
|
444 test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); |
|
445 } |
|
446 |
|
447 // Empty the array of implementations |
|
448 test.Printf(_L("Destroying List...")); |
|
449 ifArray.ResetAndDestroy(); |
|
450 } |
|
451 |
|
452 |
|
453 /** |
|
454 @SYMTestCaseID SYSLIB-ECOM-CT-3713 |
|
455 @SYMTestCaseDesc Tests for REComSession::CreateImplementationL and REComSession::ListImplementationL |
|
456 with a dummy Interface Uid, dummy implementation Uid or dummy resolver Uid. |
|
457 @SYMTestPriority High |
|
458 @SYMTestActions Call CreateImplementationL method with a dummy interface UID |
|
459 Call CreateImplementationL method with a dummy implementation UID |
|
460 Call CreateImplementationL method with a dummy Resolver UID |
|
461 Call ListImplementationL method with a dummy interface UID |
|
462 Call ListImplementationL method with a dummy Resolver UID |
|
463 @SYMTestExpectedResults Leave with KErrAugument and No implementation is created. |
|
464 @SYMDEF DEF111196 |
|
465 */ |
|
466 LOCAL_C void DummyUidTestL() |
|
467 { |
|
468 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3713 ")); |
|
469 TUid instanceKey; |
|
470 TUid dummyUid; |
|
471 dummyUid.iUid = 0; |
|
472 const TUid KInterfaceUid = {0x10009DBB}; |
|
473 const TUid KExample10InterfaceUid = {0x10009DBB}; |
|
474 _LIT8(KExample10ImplementationTest,"Example 10"); |
|
475 |
|
476 CExampleInterface* dllPtr = NULL; |
|
477 // Set up extended interfaces |
|
478 RArray<TUid> extendedInterfaces; |
|
479 CleanupClosePushL(extendedInterfaces); |
|
480 |
|
481 //Set up resolve parameter |
|
482 TEComResolverParams ResolverParams; |
|
483 ResolverParams.SetDataType(KExample10ImplementationTest()); |
|
484 ResolverParams.SetGenericMatch(ETrue); // Allow wildcard matching |
|
485 |
|
486 CExampleInterface::TExampleInterfaceInitParams initParams; |
|
487 // Set up some empty initialisation parameters |
|
488 initParams.integer = 0; |
|
489 initParams.descriptor = NULL; |
|
490 |
|
491 // CreateImplementationL with a dummy interface Uid |
|
492 TRAPD(err,dllPtr = REINTERPRET_CAST(CExampleInterface*, |
|
493 REComSession::CreateImplementationL(dummyUid, |
|
494 extendedInterfaces, |
|
495 instanceKey, |
|
496 ResolverParams, |
|
497 &initParams))); |
|
498 test(err == KErrArgument); |
|
499 test(dllPtr == NULL); |
|
500 |
|
501 // CreateImplementationL with a dummy implementation Uid |
|
502 TRAP(err,dllPtr = REINTERPRET_CAST(CExampleInterface*, |
|
503 REComSession::CreateImplementationL(dummyUid, |
|
504 instanceKey))); |
|
505 test(err == KErrArgument); |
|
506 test(dllPtr == NULL); |
|
507 |
|
508 // CreateImplementationL with a dummy resolver Uid |
|
509 TRAP(err, dllPtr = REINTERPRET_CAST(CExampleInterface*, |
|
510 REComSession::CreateImplementationL(KExample10InterfaceUid, |
|
511 extendedInterfaces, |
|
512 instanceKey, |
|
513 ResolverParams, |
|
514 dummyUid, |
|
515 &initParams))); |
|
516 test(err == KErrArgument); |
|
517 test(dllPtr == NULL); |
|
518 |
|
519 RImplInfoPtrArray ifArray; |
|
520 |
|
521 // ListImplementationL with a dummy interface Uid |
|
522 TRAP(err, REComSession::ListImplementationsL(dummyUid,extendedInterfaces,ResolverParams,ifArray)); |
|
523 test(err == KErrArgument); |
|
524 test(ifArray.Count() == 0); |
|
525 |
|
526 // ListImplementationL with a dummy resolver Uid |
|
527 TRAP(err, REComSession::ListImplementationsL(KInterfaceUid,extendedInterfaces,ResolverParams,dummyUid,ifArray)); |
|
528 test(err == KErrArgument); |
|
529 test(ifArray.Count() == 0); |
|
530 |
|
531 CleanupStack::PopAndDestroy(&extendedInterfaces); |
|
532 } |
|
533 |
|
534 /** |
|
535 @SYMTestCaseID SYSLIB-ECOM-CT-3715 |
|
536 @SYMTestCaseDesc Tests for REComSession::CreateImplementationL with ROMOnly resolver |
|
537 @SYMTestPriority High |
|
538 @SYMTestActions Call CreateImplementationL method with ROMOnly resolver |
|
539 @SYMTestExpectedResults Expected implementation is created. Ensure there is no OOM error. |
|
540 @SYMDEF DEF111196 |
|
541 */ |
|
542 LOCAL_C void CreateImplementationTest7L() |
|
543 { |
|
544 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3715 ")); |
|
545 // test start... |
|
546 const TUid KExample10InterfaceUid = {0x10009DBB}; |
|
547 const TUid KExtendedInterfaceUid1 = {0x10009E44}; |
|
548 const TUid KExtendedInterfaceUid2 = {0x10009E45}; |
|
549 const TUid KExtendedInterfaceUid3 = {0x10009E46}; |
|
550 const TUid KExample10ImplementationUid = {0x10009E38}; |
|
551 |
|
552 _LIT8(KExample10ImplementationTest,"Example 10"); |
|
553 |
|
554 // ROMOnly resolver Uid 0x10009D92 |
|
555 TUid resolverUid = {0x10009D92}; |
|
556 |
|
557 TUid instanceKey; |
|
558 |
|
559 CExampleInterface* dllPtr = NULL; |
|
560 // Set up extended interfaces |
|
561 RArray<TUid> extendedInterfaces; |
|
562 CleanupClosePushL(extendedInterfaces); |
|
563 extendedInterfaces.AppendL(KExtendedInterfaceUid1); |
|
564 extendedInterfaces.AppendL(KExtendedInterfaceUid2); |
|
565 extendedInterfaces.AppendL(KExtendedInterfaceUid3); |
|
566 |
|
567 //Set up resolve parameter |
|
568 TEComResolverParams ResolverParams; |
|
569 ResolverParams.SetDataType(KExample10ImplementationTest()); |
|
570 ResolverParams.SetGenericMatch(ETrue); // Allow wildcard matching |
|
571 |
|
572 dllPtr = REINTERPRET_CAST(CExampleInterface*, |
|
573 REComSession::CreateImplementationL(KExample10InterfaceUid, |
|
574 extendedInterfaces, |
|
575 instanceKey, |
|
576 ResolverParams, |
|
577 resolverUid)); |
|
578 CleanupStack::PopAndDestroy(&extendedInterfaces); |
|
579 |
|
580 //checks the implementation created |
|
581 test(dllPtr != NULL); |
|
582 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
583 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
584 |
|
585 test.Printf(_L("Destroying Plugin...")); |
|
586 REComSession::DestroyedImplementation(instanceKey); |
|
587 |
|
588 delete dllPtr; |
|
589 } |
|
590 |
|
591 |
|
592 /** |
|
593 Test function for REcomSession::CreateImplementationL |
|
594 |
|
595 @param aContainInvalidExtIf The bool value identifying if the extended interfaces list contains |
|
596 invalid extended interface Uid |
|
597 @param aUseDefResolver The bool value identifying if default resolver is used. |
|
598 @param aUseInitParam The bool value identifying if initialise parameter is used. |
|
599 @param aNumEntriesInExtIFList The number of entries in the extended interfaces list. |
|
600 @param aInstanceKey A 32 bit identifer returned by the ECom framework to |
|
601 identify this instance to the framework. |
|
602 @return A pointer to the implementation created. |
|
603 */ |
|
604 LOCAL_C CExampleInterface* CreateImplementationTestL(TBool aContainInvalidExtIf, |
|
605 TBool aUseDefResolver, |
|
606 TBool aUseInitParam, |
|
607 TUid& aInstanceKey) |
|
608 { |
|
609 const TUid KExample10InterfaceUid = {0x10009DBB}; |
|
610 const TUid KExtendedInterfaceUid1 = {0x10009E44}; |
|
611 const TUid KExtendedInterfaceUid2 = {0x10009E45}; |
|
612 const TUid KExtendedInterfaceUid3 = {0x10009E46}; |
|
613 const TUid KInvalidExtendedInterfaceUid2 = {0x10009E49}; |
|
614 _LIT8(KExample10ImplementationTest,"Example 10"); |
|
615 |
|
616 TUid resolverUid = {0x10009DD0}; |
|
617 |
|
618 CExampleInterface* dllPtr = NULL; |
|
619 // Set up extended interfaces |
|
620 RArray<TUid> extendedInterfaces; |
|
621 CleanupClosePushL(extendedInterfaces); |
|
622 |
|
623 if (!aContainInvalidExtIf) |
|
624 { |
|
625 extendedInterfaces.AppendL(KExtendedInterfaceUid1); |
|
626 extendedInterfaces.AppendL(KExtendedInterfaceUid2); |
|
627 extendedInterfaces.AppendL(KExtendedInterfaceUid3); |
|
628 } |
|
629 else |
|
630 { |
|
631 extendedInterfaces.AppendL(KExtendedInterfaceUid1); |
|
632 extendedInterfaces.AppendL(KInvalidExtendedInterfaceUid2); |
|
633 } |
|
634 |
|
635 //Set up resolve parameter |
|
636 TEComResolverParams ResolverParams; |
|
637 ResolverParams.SetDataType(KExample10ImplementationTest()); |
|
638 ResolverParams.SetGenericMatch(ETrue); // Allow wildcard matching |
|
639 |
|
640 CExampleInterface::TExampleInterfaceInitParams initParams; |
|
641 if (aUseInitParam) //CreateImplementationTest3L,CreateImplementationTest5L |
|
642 { |
|
643 // Set up some empty initialisation parameters |
|
644 initParams.integer = 0; |
|
645 initParams.descriptor = NULL; |
|
646 if (aUseDefResolver) //CreateImplementationTest3L |
|
647 { |
|
648 dllPtr = REINTERPRET_CAST(CExampleInterface*, |
|
649 REComSession::CreateImplementationL(KExample10InterfaceUid, |
|
650 extendedInterfaces, |
|
651 aInstanceKey, |
|
652 ResolverParams, |
|
653 &initParams)); |
|
654 } |
|
655 else //CreateImplementationTest5L |
|
656 { |
|
657 dllPtr = REINTERPRET_CAST(CExampleInterface*, |
|
658 REComSession::CreateImplementationL(KExample10InterfaceUid, |
|
659 extendedInterfaces, |
|
660 aInstanceKey, |
|
661 ResolverParams, |
|
662 resolverUid, |
|
663 &initParams)); |
|
664 } |
|
665 } |
|
666 else //CreateImplementationTest2L, CreateImplementationTest4L, CreateImplementationTest6 |
|
667 { |
|
668 if (aUseDefResolver) //CreateImplementationTest2L, CreateImplementationTest6 |
|
669 { |
|
670 dllPtr = REINTERPRET_CAST(CExampleInterface*, |
|
671 REComSession::CreateImplementationL(KExample10InterfaceUid, |
|
672 extendedInterfaces, |
|
673 aInstanceKey, |
|
674 ResolverParams)); |
|
675 } |
|
676 else //CreateImplementationTest4L |
|
677 { |
|
678 dllPtr = REINTERPRET_CAST(CExampleInterface*, |
|
679 REComSession::CreateImplementationL(KExample10InterfaceUid, |
|
680 extendedInterfaces, |
|
681 aInstanceKey, |
|
682 ResolverParams, |
|
683 resolverUid)); |
|
684 } |
|
685 } |
|
686 CleanupStack::PopAndDestroy(&extendedInterfaces); |
|
687 return dllPtr; |
|
688 } |
|
689 |
|
690 /** |
|
691 @SYMTestCaseID SYSLIB-ECOM-CT-3708 |
|
692 @SYMTestCaseDesc Tests for calling DestroyedImplementation() twice. |
|
693 @SYMTestPriority High |
|
694 @SYMTestActions Call CreateImplementationL method to load a plugin. |
|
695 Delete the plugin by calling DestroyedImplementation() twice. |
|
696 Delete pointer. Call DestroyedImplementation(). |
|
697 Cal FinalClose(). Call DestroyedImplementation(). |
|
698 @SYMTestExpectedResults Second call to DestroyedImplementation() should succeed. |
|
699 @SYMDEF DEF111428 |
|
700 */ |
|
701 LOCAL_C void DestroyedImplementationTestL() |
|
702 { |
|
703 // Test Starts... |
|
704 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3708 ")); |
|
705 TUid instanceKey; |
|
706 TBool containInvalidExtIf = EFalse; |
|
707 TBool useDefResolver = EFalse; |
|
708 TBool useInitParam = ETrue; |
|
709 TUid KExample10ImplementationUid = {0x10009E38}; |
|
710 |
|
711 test.Printf(_L("Loading Plugin...")); |
|
712 |
|
713 // Test create implementation by pass in instance key. |
|
714 CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); |
|
715 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
716 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
717 |
|
718 // the destructor calls DestroyedImplementation() |
|
719 test.Printf(_L("Calling DestroyedImplementation the 1st time through the plugin destructor...")); |
|
720 delete dllPtr; |
|
721 |
|
722 test.Printf(_L("Calling DestroyedImplementation a 2nd time directly through REComSession...")); |
|
723 REComSession::DestroyedImplementation(instanceKey); |
|
724 |
|
725 test.Printf(_L("Calling DestroyedImplementation a 3rd time directly through REComSession but after FinalClose...")); |
|
726 |
|
727 REComSession::DestroyedImplementation(instanceKey); |
|
728 } |
|
729 |
|
730 /** |
|
731 @SYMTestCaseID SYSLIB-ECOM-CT-3595 |
|
732 @SYMTestCaseDesc Tests for REComSession::CreateImplementationL created with an Interface Uid |
|
733 and invalid extended Interfaces. |
|
734 @SYMTestPriority High |
|
735 @SYMTestActions Call CreateImplementationL method supporting interface UID and extended interfaces |
|
736 that are invalid. |
|
737 @SYMTestExpectedResults No implementation is created. |
|
738 @SYMEC EC43 |
|
739 */ |
|
740 LOCAL_C void CreateImplementationTest6() |
|
741 { |
|
742 // Test Starts... |
|
743 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3595 ")); |
|
744 TUid instanceKey; |
|
745 TBool containInvalidExtIf = ETrue; |
|
746 TBool useDefResolver = ETrue; |
|
747 TBool useInitParam = EFalse; |
|
748 |
|
749 test.Printf(_L("Loading Plugin...")); |
|
750 TInt err; |
|
751 TRAP(err,CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey)); |
|
752 |
|
753 test(KErrNotFound == err); |
|
754 |
|
755 test.Printf(_L("Implementation is not found.\n")); |
|
756 } |
|
757 |
|
758 /** |
|
759 @SYMTestCaseID SYSLIB-ECOM-CT-3593 |
|
760 @SYMTestCaseDesc Tests for REComSession::CreateImplementationL created with an resolver Uid |
|
761 @SYMTestPriority High |
|
762 @SYMTestActions Call CreateImplementationL method supporting interface UID, extended interfaces, |
|
763 construction parameters, resolver parameters and resolver UID. |
|
764 @SYMTestExpectedResults Expected implementation is created and no memory leaks. |
|
765 @SYMEC EC43 |
|
766 */ |
|
767 LOCAL_C void CreateImplementationTest5L() |
|
768 { |
|
769 // Test Starts... |
|
770 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3593 ")); |
|
771 TUid instanceKey; |
|
772 TBool containInvalidExtIf = EFalse; |
|
773 TBool useDefResolver = EFalse; |
|
774 TBool useInitParam = ETrue; |
|
775 TUid KExample10ImplementationUid = {0x10009E38}; |
|
776 |
|
777 test.Printf(_L("Loading Plugin...")); |
|
778 |
|
779 // Test create implementation by pass in instance key. |
|
780 CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); |
|
781 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
782 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
783 |
|
784 test.Printf(_L("Destroying Plugin...")); |
|
785 REComSession::DestroyedImplementation(instanceKey); |
|
786 delete dllPtr; |
|
787 |
|
788 // Test create implementation by pass in offset of the instance key. |
|
789 dllPtr = CExampleInterface::NewL8(); |
|
790 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
791 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
792 |
|
793 test.Printf(_L("Destroying Plugin...")); |
|
794 delete dllPtr; |
|
795 } |
|
796 |
|
797 /** |
|
798 @SYMTestCaseID SYSLIB-ECOM-CT-3592 |
|
799 @SYMTestCaseDesc Tests for REComSession::CreateImplementationL created with an resolver Uid |
|
800 @SYMTestPriority High |
|
801 @SYMTestActions Call CreateImplementationL method supporting interface UID, extended interfaces, |
|
802 resolver parameters and resolver UID. |
|
803 @SYMTestExpectedResults Expected implementation is created and no memory leaks. |
|
804 @SYMEC EC43 |
|
805 */ |
|
806 LOCAL_C void CreateImplementationTest4L() |
|
807 { |
|
808 // Test Starts... |
|
809 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3592 ")); |
|
810 TUid instanceKey; |
|
811 TBool containInvalidExtIf = EFalse; |
|
812 TBool useDefResolver = EFalse; |
|
813 TBool useInitParam = EFalse; |
|
814 TUid KExample10ImplementationUid = {0x10009E38}; |
|
815 |
|
816 test.Printf(_L("Loading Plugin...")); |
|
817 |
|
818 // Test create implementation by pass in instance key. |
|
819 CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); |
|
820 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
821 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
822 |
|
823 test.Printf(_L("Destroying Plugin...")); |
|
824 REComSession::DestroyedImplementation(instanceKey); |
|
825 delete dllPtr; |
|
826 |
|
827 // Test create implementation by pass in offset of the instance key. |
|
828 dllPtr = CExampleInterface::NewL6(); |
|
829 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
830 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
831 |
|
832 test.Printf(_L("Destroying Plugin...")); |
|
833 delete dllPtr; |
|
834 } |
|
835 |
|
836 /** |
|
837 @SYMTestCaseID SYSLIB-ECOM-CT-3591 |
|
838 @SYMTestCaseDesc Tests for REComSession::CreateImplementationL created with an Interface Uid, |
|
839 ExtendedInterface, construction parameters and resolver parameters |
|
840 @SYMTestPriority High |
|
841 @SYMTestActions Call CreateImplementationL method supporting interface UID,extended interfaces, |
|
842 construction parameters and resolver parameters. |
|
843 @SYMTestExpectedResults Expected implementation is created and no memory leaks. |
|
844 @SYMEC EC43 |
|
845 */ |
|
846 LOCAL_C void CreateImplementationTest3L() |
|
847 { |
|
848 // Test Starts... |
|
849 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3591 ")); |
|
850 TUid instanceKey; |
|
851 TBool containInvalidExtIf = EFalse; |
|
852 TBool useDefResolver = ETrue; |
|
853 TBool useInitParam = ETrue; |
|
854 TUid KExample10ImplementationUid = {0x10009E38}; |
|
855 |
|
856 test.Printf(_L("Loading Plugin...")); |
|
857 |
|
858 // Test create implementation by pass in instance key. |
|
859 CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); |
|
860 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
861 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
862 |
|
863 test.Printf(_L("Destroying Plugin...")); |
|
864 REComSession::DestroyedImplementation(instanceKey); |
|
865 delete dllPtr; |
|
866 |
|
867 // Test create implementation by pass in offset of the instance key. |
|
868 dllPtr = CExampleInterface::NewL7(); |
|
869 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
870 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
871 |
|
872 test.Printf(_L("Destroying Plugin...")); |
|
873 delete dllPtr; |
|
874 } |
|
875 |
|
876 |
|
877 /** |
|
878 @SYMTestCaseID SYSLIB-ECOM-CT-3590 |
|
879 @SYMTestCaseDesc Tests for REComSession::CreateImplementationL created with an Interface Uid, |
|
880 ExtendedInterface and resolver parameters. |
|
881 @SYMTestPriority High |
|
882 @SYMTestActions Call CreateImplementationL method supporting interface UID,extended interfaces, and resolver parameters. |
|
883 @SYMTestExpectedResults Expected implementation is created and no memory leaks. |
|
884 @SYMEC EC43 |
|
885 */ |
|
886 LOCAL_C void CreateImplementationTest2L() |
|
887 { |
|
888 // Test Starts... |
|
889 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3590 ")); |
|
890 TUid instanceKey; |
|
891 TBool containInvalidExtIf = EFalse; |
|
892 TBool useDefResolver = ETrue; |
|
893 TBool useInitParam = EFalse; |
|
894 TUid KExample10ImplementationUid = {0x10009E38}; |
|
895 |
|
896 test.Printf(_L("Loading Plugin...")); |
|
897 // Test create implementation by pass in instance key. |
|
898 CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); |
|
899 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
900 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
901 |
|
902 test.Printf(_L("Destroying Plugin...")); |
|
903 REComSession::DestroyedImplementation(instanceKey); |
|
904 delete dllPtr; |
|
905 |
|
906 // Test create implementation by pass in offset of the instance key. |
|
907 dllPtr = CExampleInterface::NewL5(); |
|
908 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
909 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
910 |
|
911 test.Printf(_L("Destroying Plugin...")); |
|
912 delete dllPtr; |
|
913 } |
|
914 |
|
915 /** |
|
916 @SYMTestCaseID SYSLIB-ECOM-CT-3586 |
|
917 @SYMTestCaseDesc Tests for GetExtendedInterfaceL, Manual release |
|
918 @SYMTestPriority High |
|
919 @SYMTestActions Create an implementation. Fetch two extended interfaces (one build in, and one |
|
920 stand alone and requires release). Manually release the stand alone extended |
|
921 interface. Destroy implementation. |
|
922 @SYMTestExpectedResults Ensure that manual release releases the stand alone interface correctly. |
|
923 @SYMEC EC43 |
|
924 */ |
|
925 LOCAL_C void GetExtendedInterfaceTest4L() |
|
926 { |
|
927 // Test Starts... |
|
928 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3586 ")); |
|
929 test.Printf(_L("Loading Plugin...")); |
|
930 const TUid KExample10ImplementationUid = {0x10009E38}; |
|
931 |
|
932 CExampleInterface* dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); |
|
933 CleanupStack::PushL(dllPtr); |
|
934 |
|
935 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
936 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
937 |
|
938 // Call extended interface here. |
|
939 const TUid KExample10InterfaceUid1 = {0x10009E44}; |
|
940 const TUid KExample10InterfaceUid2 = {0x10009E45}; |
|
941 |
|
942 MExampleInterfaceExtended* ext1 = static_cast<MExampleInterfaceExtended*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); |
|
943 ext1->DoMethodExtended(); |
|
944 |
|
945 MExampleInterfaceExtended2* ext2 = static_cast<MExampleInterfaceExtended2*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid2)); |
|
946 ext2->DoMethodExtended2(); |
|
947 |
|
948 dllPtr->ManuallyReleaseExtendedInterfaceL(KExample10InterfaceUid2); |
|
949 |
|
950 test.Printf(_L("Destroying Plugin...")); |
|
951 CleanupStack::Pop(dllPtr); |
|
952 delete dllPtr; |
|
953 |
|
954 // Test Ends... |
|
955 } |
|
956 |
|
957 /** |
|
958 @SYMTestCaseID SYSLIB-ECOM-CT-4001 |
|
959 @SYMTestCaseDesc Tests GetExtendedInterfaceL with invalid instance keys |
|
960 @SYMTestPriority High |
|
961 @SYMTestActions Retrieve extended interface using unknown instance key |
|
962 Retrieve extended interface using null instance key |
|
963 @SYMTestExpectedResults Ensure that correct leaves occur. |
|
964 @SYMDEF DEF111553 |
|
965 */ |
|
966 LOCAL_C void GetExtendedInterfaceTest5L() |
|
967 { |
|
968 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-4001 ")); |
|
969 // Test Starts... |
|
970 TUid instanceKey; |
|
971 TBool containInvalidExtIf = EFalse; |
|
972 TBool useDefResolver = EFalse; |
|
973 TBool useInitParam = ETrue; |
|
974 |
|
975 // get valid instance key by creating implementation |
|
976 CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); |
|
977 |
|
978 // remove implementation |
|
979 REComSession::DestroyedImplementation(instanceKey); |
|
980 delete dllPtr; |
|
981 |
|
982 // Attempt to fetch extended interface with instance key that is no longer valid but |
|
983 // passes the ASSERT test |
|
984 const TUid KExtendedInterfaceUid = {0x10009E44}; |
|
985 TRAPD(err, REComSession::GetExtendedInterfaceL(instanceKey,KExtendedInterfaceUid)); |
|
986 test(err = KErrNotFound); |
|
987 |
|
988 // Attempt to fetch extended interface with null instance key |
|
989 TRAP(err, REComSession::GetExtendedInterfaceL(KNullUid,KExtendedInterfaceUid)); |
|
990 test(err = KErrArgument); |
|
991 |
|
992 // Test Ends... |
|
993 } |
|
994 |
|
995 /** |
|
996 @SYMTestCaseID SYSLIB-ECOM-CT-3581 |
|
997 @SYMTestCaseDesc Tests for REComSession::ListExtendedInterfaces with a valid Implementation UID. |
|
998 Tests also for non-existent Implementation UID and PLUGIN1 implementation UID. |
|
999 Does some create and destruction of implementations before and after calling |
|
1000 ListExtendedInterfaces to mimic typical usage. |
|
1001 @SYMTestPriority High |
|
1002 @SYMTestActions List the extended interfaces. Check expected extended interfaces are returned. |
|
1003 Create an implementation. Ensure that Listing of the extended interface |
|
1004 still works after the create. |
|
1005 Delete the implementation. List extended interfaces again. |
|
1006 List the extended interfaces with a PLUGIN1 implementation UID. |
|
1007 @SYMTestExpectedResults Ensure all ListExtendedInterfaces calls return with expected extended interfaces. |
|
1008 @SYMEC EC43 |
|
1009 @SYMDEF DEF111196 |
|
1010 */ |
|
1011 LOCAL_C void ListExtendedInterfaceTestL() |
|
1012 { |
|
1013 // Test Starts... |
|
1014 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3581 ")); |
|
1015 const TUid KExample10ImplementationUid = {0x10009E38}; |
|
1016 const TUid KExample10ImplementationUid2 = {0x10009E3A}; |
|
1017 const TUid KExample10ImplementationUid3 = {0x10009E3B}; |
|
1018 |
|
1019 const TUid KExample10InterfaceUid1 = {0x10009E44}; |
|
1020 const TUid KExample10InterfaceUid2 = {0x10009E45}; |
|
1021 const TUid KExample10InterfaceUid3 = {0x10009E46}; |
|
1022 |
|
1023 const TUid KImpUidPLUGIN1 = {0x10009DC3}; |
|
1024 |
|
1025 RArray<TUid> ifInfo; |
|
1026 CleanupClosePushL(ifInfo); |
|
1027 |
|
1028 REComSession::ListExtendedInterfacesL(KExample10ImplementationUid,ifInfo); |
|
1029 test(ifInfo.Count() == 3); |
|
1030 |
|
1031 // Checks that expected interfaces are in list. |
|
1032 test(ifInfo[0] == KExample10InterfaceUid1); |
|
1033 test(ifInfo[1] == KExample10InterfaceUid2); |
|
1034 test(ifInfo[2] == KExample10InterfaceUid3); |
|
1035 ifInfo.Reset(); |
|
1036 |
|
1037 // Creates an implementation |
|
1038 // Set up some empty initialisation parameters |
|
1039 test.Printf(_L("Loading Plugin...")); |
|
1040 |
|
1041 CExampleInterface* dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); |
|
1042 CleanupStack::PushL(dllPtr); |
|
1043 |
|
1044 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
1045 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
1046 |
|
1047 // Calls extended interface here. |
|
1048 MExampleInterfaceExtended* ext1 = static_cast<MExampleInterfaceExtended*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); |
|
1049 ext1->DoMethodExtended(); |
|
1050 |
|
1051 MExampleInterfaceExtended2* ext2 = static_cast<MExampleInterfaceExtended2*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid2)); |
|
1052 ext2->DoMethodExtended2(); |
|
1053 |
|
1054 // Checks that ListExtendedInterfaces works after a Create Implementation |
|
1055 REComSession::ListExtendedInterfacesL(KExample10ImplementationUid,ifInfo); |
|
1056 test(ifInfo.Count() == 3); |
|
1057 |
|
1058 // Checks that expected interfaces are in list. |
|
1059 test(ifInfo[0] == KExample10InterfaceUid1); |
|
1060 test(ifInfo[1] == KExample10InterfaceUid2); |
|
1061 test(ifInfo[2] == KExample10InterfaceUid3); |
|
1062 ifInfo.Reset(); |
|
1063 |
|
1064 test.Printf(_L("Destroying Plugin...")); |
|
1065 CleanupStack::Pop(dllPtr); |
|
1066 |
|
1067 delete dllPtr; |
|
1068 |
|
1069 // Test fetch of extended interfaces for an implementation that has no extended interfaces |
|
1070 REComSession::ListExtendedInterfacesL(KExample10ImplementationUid2,ifInfo); |
|
1071 test(ifInfo.Count() == 0); |
|
1072 ifInfo.Reset(); |
|
1073 |
|
1074 // Test fetch of extended interfaces for an implementation that does not exist |
|
1075 TRAPD(err,REComSession::ListExtendedInterfacesL(KNullUid,ifInfo)); |
|
1076 TEST_OOM_ERR; |
|
1077 test(err == KErrNotFound); |
|
1078 ifInfo.Reset(); |
|
1079 |
|
1080 // Test fetch of extended interfaces for an implementation that has one extended interface |
|
1081 REComSession::ListExtendedInterfacesL(KExample10ImplementationUid3,ifInfo); |
|
1082 test(ifInfo.Count() == 1); |
|
1083 ifInfo.Reset(); |
|
1084 |
|
1085 // Test fetch of extended interfaces for an implementation with PLUGIN1 IIC that has no extended interfaces |
|
1086 REComSession::ListExtendedInterfacesL(KImpUidPLUGIN1,ifInfo); |
|
1087 test(ifInfo.Count() == 0); |
|
1088 ifInfo.Reset(); |
|
1089 |
|
1090 // Close array, finished with it. |
|
1091 CleanupStack::PopAndDestroy(&ifInfo); |
|
1092 // Test Ends... |
|
1093 } |
|
1094 |
|
1095 /** |
|
1096 @SYMTestCaseID SYSLIB-ECOM-CT-3596 |
|
1097 @SYMTestCaseDesc Try to load a PLUGIN3 DLL with a version one resource file. Also try to load a PLUGIN1 DLL |
|
1098 with a version three resource file. Tests UID mismatch specified in the DLL .mmp file and |
|
1099 the resource type in the resource file. |
|
1100 @SYMTestPriority High |
|
1101 @SYMTestActions Create an implementation using the invalid plugin. |
|
1102 @SYMTestExpectedResults The plugin should not have been loaded due to a UID1 mismatch. |
|
1103 @SYMEC EC43 |
|
1104 */ |
|
1105 LOCAL_C void CreateImplementationTest1() |
|
1106 { |
|
1107 // Test Starts... |
|
1108 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3596 ")); |
|
1109 TUid instanceKey; |
|
1110 |
|
1111 // Set up some empty initialisation parameters |
|
1112 CExampleInterface::TExampleInterfaceInitParams initParams; |
|
1113 initParams.integer = 0; |
|
1114 initParams.descriptor = NULL; |
|
1115 |
|
1116 test.Printf(_L("Loading Plugin...")); |
|
1117 |
|
1118 // Interface with NULL get and release function pointers |
|
1119 const TUid KExample12InvalidDllImplementationUid = {0x10009E39}; |
|
1120 |
|
1121 TRAPD(err, TAny* dllPtr = REComSession::CreateImplementationL(KExample12InvalidDllImplementationUid,instanceKey,&initParams)); |
|
1122 |
|
1123 // The plugin should not have been loaded due to a UID1 mismatch. This is specified as the resource |
|
1124 // type in the resource file and UID1 in the DLL itself. |
|
1125 test(err==KErrNotFound); |
|
1126 |
|
1127 // Load a PLUGIN1 DLL with a version three resource file |
|
1128 const TUid KExample14InvalidDllImplementationUid = {0x10009E48}; |
|
1129 |
|
1130 TRAP(err, TAny* dllPtr = REComSession::CreateImplementationL(KExample14InvalidDllImplementationUid,instanceKey,&initParams)); |
|
1131 |
|
1132 // The plugin should not have been loaded due to a UID1 mismatch. This is specified as the resource |
|
1133 // type in the resource file and UID1 in the DLL itself. |
|
1134 test(err==KErrNotFound); |
|
1135 // Test Ends... |
|
1136 } |
|
1137 |
|
1138 /** |
|
1139 @SYMTestCaseID SYSLIB-ECOM-CT-3585 |
|
1140 @SYMTestCaseDesc Get and release extended interfaces in cases in which both get and release function pointers |
|
1141 do not exist. The tests will be: |
|
1142 1) Get/release function pointers are NULL |
|
1143 2) Only get function, no release function |
|
1144 3) Test with a PLUGIN1 DLL (get/release function pointers should be NULL) |
|
1145 @SYMTestPriority High |
|
1146 @SYMTestActions Create an implementation. |
|
1147 Try getting and releasing interfaces even though no get and release function pointers exist |
|
1148 Test with get extended interface function pointer and no release function pointer |
|
1149 @SYMTestExpectedResults NULL should be returned if get and release function pointers do not exist |
|
1150 Releasing an interface that has no release function pointer should finish with |
|
1151 no errors. |
|
1152 @SYMEC EC43 |
|
1153 */ |
|
1154 LOCAL_C void ReleaseExtendedInterfaceTest1L() |
|
1155 { |
|
1156 // Test Starts... |
|
1157 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3585 ")); |
|
1158 test.Printf(_L("Loading Plugin...")); |
|
1159 // Interface with NULL get and release function pointers |
|
1160 const TUid KExample10ImplementationUid = {0x10009E3A}; |
|
1161 |
|
1162 CExampleInterface* dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); |
|
1163 CleanupStack::PushL(dllPtr); |
|
1164 |
|
1165 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
1166 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
1167 |
|
1168 // Call extended interface here. |
|
1169 const TUid KExample10InterfaceUid1 = {0x10009E44}; |
|
1170 const TUid KExample10InterfaceUid2 = {0x10009E45}; |
|
1171 |
|
1172 // Try getting and releasing interfaces even though no get and release function pointers exist |
|
1173 MExampleInterfaceExtended* ext1 = static_cast<MExampleInterfaceExtended*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); |
|
1174 test(ext1 == NULL); |
|
1175 |
|
1176 MExampleInterfaceExtended2* ext2 = static_cast<MExampleInterfaceExtended2*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid2)); |
|
1177 test(ext2 == NULL); |
|
1178 |
|
1179 dllPtr->ManuallyReleaseExtendedInterfaceL(KExample10InterfaceUid2); |
|
1180 |
|
1181 test.Printf(_L("Destroying Plugin 1...")); |
|
1182 CleanupStack::Pop(dllPtr); |
|
1183 delete dllPtr; |
|
1184 |
|
1185 // Test with get extended interface function pointer and no release function pointer |
|
1186 const TUid KExample10ImplementationUidNoRelease = {0x10009E3B}; |
|
1187 |
|
1188 dllPtr = CExampleInterface::NewL2(KExample10ImplementationUidNoRelease); |
|
1189 CleanupStack::PushL(dllPtr); |
|
1190 |
|
1191 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUidNoRelease); |
|
1192 test(KExample10ImplementationUidNoRelease == dllPtr->ImplId()); |
|
1193 |
|
1194 // Try releasing interfaces even though no release function pointer exists |
|
1195 MExampleInterfaceExtended* ext = static_cast<MExampleInterfaceExtended*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); |
|
1196 ext->DoMethodExtended(); |
|
1197 |
|
1198 // This should do nothing |
|
1199 dllPtr->ManuallyReleaseExtendedInterfaceL(KExample10InterfaceUid1); |
|
1200 |
|
1201 test.Printf(_L("Destroying Plugin 2...")); |
|
1202 CleanupStack::Pop(dllPtr); |
|
1203 delete dllPtr; |
|
1204 |
|
1205 // PLUGIN1 test. Try getting and releasing interfaces even though no get and release function pointers exist. |
|
1206 dllPtr = CExampleInterface::NewL2(KCExampleImplUid); |
|
1207 CleanupStack::PushL(dllPtr); |
|
1208 |
|
1209 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KCExampleImplUid); |
|
1210 test(KCExampleImplUid == dllPtr->ImplId()); |
|
1211 |
|
1212 // Call extended interface here. |
|
1213 // Try getting and releasing interfaces even though no get and release function pointers exist |
|
1214 MExampleInterfaceExtended* ext3 = static_cast<MExampleInterfaceExtended*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); |
|
1215 test(ext3 == NULL); |
|
1216 |
|
1217 // Nothing should happen when releasing an extended interface for a PLUGIN1 DLL |
|
1218 dllPtr->ManuallyReleaseExtendedInterfaceL(KExample10InterfaceUid1); |
|
1219 |
|
1220 test.Printf(_L("Destroying Plugin 3...")); |
|
1221 CleanupStack::Pop(dllPtr); |
|
1222 delete dllPtr; |
|
1223 // Test Ends... |
|
1224 } |
|
1225 |
|
1226 /** |
|
1227 @SYMTestCaseID SYSLIB-ECOM-CT-4002 |
|
1228 @SYMTestCaseDesc Tests ManuallyReleaseExtendedInterfaceL with invalid instance keys |
|
1229 @SYMTestPriority High |
|
1230 @SYMTestActions Manually release extended interface using unknown instance key |
|
1231 Manually release extended interface using null instance key |
|
1232 @SYMTestExpectedResults Ensure that correct leaves occur. |
|
1233 @SYMDEF DEF111553 |
|
1234 */ |
|
1235 LOCAL_C void ReleaseExtendedInterfaceTest2L() |
|
1236 { |
|
1237 // Test Starts... |
|
1238 // get valid instance key by creating implementation |
|
1239 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-4002 ")); |
|
1240 const TUid KExample10ImplementationUid = {0x10009E3A}; |
|
1241 TUid instanceKey; |
|
1242 TAny* impl = REComSession::CreateImplementationL(KExample10ImplementationUid, instanceKey, 0); |
|
1243 |
|
1244 // remove implementation |
|
1245 REComSession::DestroyedImplementation(instanceKey); |
|
1246 delete impl; |
|
1247 |
|
1248 // Attempt to manually release extended interface with instance key that is no longer valid but |
|
1249 // passes the ASSERT test |
|
1250 const TUid KExample10InterfaceUid1 = {0x10009E44}; |
|
1251 TRAPD(err, REComSession::ManuallyReleaseExtendedInterfaceL(instanceKey,KExample10InterfaceUid1)); |
|
1252 test(err = KErrNotFound); |
|
1253 |
|
1254 // Attempt to manually release extended interface with null instance key |
|
1255 TRAP(err, REComSession::GetExtendedInterfaceL(KNullUid,KExample10InterfaceUid1)); |
|
1256 test(err = KErrArgument); |
|
1257 // Test Ends... |
|
1258 } |
|
1259 |
|
1260 /** |
|
1261 @SYMTestCaseID SYSLIB-ECOM-CT-3584 |
|
1262 @SYMTestCaseDesc Tests for GetExtendedInterfaceL, fetching an invalid extended interface |
|
1263 @SYMTestPriority High |
|
1264 @SYMTestActions Create an implementation. Fetch two extended interfaces (one build in, and one |
|
1265 stand alone and requires release). Fetch an invalid extended interface. Destroy implementation. |
|
1266 @SYMTestExpectedResults Ensure that the GetExtendedInterfaceL call with the invalid interface returns NULL. |
|
1267 @SYMEC EC43 |
|
1268 */ |
|
1269 LOCAL_C void GetExtendedInterfaceTest3L() |
|
1270 { |
|
1271 // |
|
1272 // Testing a overloaded method for CreateImplementationL |
|
1273 // ------------------------------------------------------------------ |
|
1274 // |
|
1275 // Test Starts... |
|
1276 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3584 ")); |
|
1277 test.Printf(_L("Loading Plugin...")); |
|
1278 const TUid KExample10ImplementationUid = {0x10009E38}; |
|
1279 |
|
1280 CExampleInterface* dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); |
|
1281 CleanupStack::PushL(dllPtr); |
|
1282 |
|
1283 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
1284 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
1285 |
|
1286 // Call extended interface here. |
|
1287 const TUid KExample10InterfaceUid1 = {0x10009E44}; |
|
1288 const TUid KExample10InterfaceUid2 = {0x10009E45}; |
|
1289 const TUid KExample10InvalidInterfaceUid = {0x10009E49}; |
|
1290 |
|
1291 MExampleInterfaceExtended* ext1 = static_cast<MExampleInterfaceExtended*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); |
|
1292 ext1->DoMethodExtended(); |
|
1293 |
|
1294 MExampleInterfaceExtended2* ext2 = static_cast<MExampleInterfaceExtended2*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid2)); |
|
1295 ext2->DoMethodExtended2(); |
|
1296 |
|
1297 // Get an invalid extended interface. |
|
1298 MExampleInterfaceExtended2* ext2invalid = static_cast<MExampleInterfaceExtended2*>(dllPtr->GetExtendedInterfaceL(KExample10InvalidInterfaceUid)); |
|
1299 // No interface should be returned if it is not found. |
|
1300 test(ext2invalid == NULL); |
|
1301 |
|
1302 test.Printf(_L("Destroying Plugin...")); |
|
1303 CleanupStack::Pop(dllPtr); |
|
1304 delete dllPtr; |
|
1305 |
|
1306 // Test Ends... |
|
1307 } |
|
1308 |
|
1309 /** |
|
1310 @SYMTestCaseID SYSLIB-ECOM-CT-3583 |
|
1311 @SYMTestCaseDesc Tests for GetExtendedInterfaceL, with an invalid instance key. |
|
1312 @SYMTestPriority High |
|
1313 @SYMTestActions Call REComSession::GetExtendedInterfaceL() with an invalid instance key. |
|
1314 GetExtendedInterfacePanic() and ThreadPanicTest() are used for this test case. |
|
1315 @SYMTestExpectedResults Ensure that the GetExtendedInterfaceL panics in debug mode and leaves in release |
|
1316 mode. |
|
1317 @SYMEC EC43 |
|
1318 */ |
|
1319 LOCAL_C void GetExtendedInterfaceTest2L() |
|
1320 { |
|
1321 // Test Starts... |
|
1322 TUid instanceKey; |
|
1323 TBool containInvalidExtIf = EFalse; |
|
1324 TBool useDefResolver = EFalse; |
|
1325 TBool useInitParam = ETrue; |
|
1326 |
|
1327 CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); |
|
1328 CleanupStack::PushL(dllPtr); |
|
1329 |
|
1330 const TUid KExtendedInterfaceUid = {0x10009E44}; |
|
1331 TUid invalidInstanceKey; |
|
1332 invalidInstanceKey.iUid = instanceKey.iUid + 1; |
|
1333 |
|
1334 // Fetches an extended interface with invalid instance key. |
|
1335 // When passed an invalid instance key, REComSession::GetExtendedInterfaceL() panics |
|
1336 // with KErrArgument in debug mode, but leaves with KErrNotFound in release mode. |
|
1337 MExampleInterfaceExtended* ext1 = static_cast<MExampleInterfaceExtended*>(REComSession::GetExtendedInterfaceL(invalidInstanceKey,KExtendedInterfaceUid)); |
|
1338 |
|
1339 REComSession::DestroyedImplementation(instanceKey); |
|
1340 CleanupStack::PopAndDestroy(dllPtr); |
|
1341 |
|
1342 // Test Ends... |
|
1343 } |
|
1344 |
|
1345 /** |
|
1346 A thread function. |
|
1347 Panics in debug mode. |
|
1348 Returns an error code in release mode. |
|
1349 */ |
|
1350 LOCAL_C TInt GetExtendedInterfacePanic(TAny*) |
|
1351 { |
|
1352 __UHEAP_MARK; |
|
1353 CTrapCleanup* threadcleanup = CTrapCleanup::New(); |
|
1354 |
|
1355 // In debug mode, GetExtendedInterfaceTest2L panics with reason KErrArgument. |
|
1356 // In release mode, it leaves with KErrNotFound. |
|
1357 TRAPD(err, GetExtendedInterfaceTest2L()); |
|
1358 |
|
1359 delete threadcleanup; |
|
1360 __UHEAP_MARKEND; |
|
1361 |
|
1362 return err; |
|
1363 } |
|
1364 |
|
1365 /** |
|
1366 The test code is used for capturing the PANIC that occurs as a result of calling GetExtendedInterfaceL |
|
1367 with an invalid instance key. |
|
1368 */ |
|
1369 LOCAL_C void ThreadPanicTest(const TDesC& aName,TThreadFunction aFunction) |
|
1370 { |
|
1371 test.Next(aName); |
|
1372 TRequestStatus threadStatus; |
|
1373 RThread thread; |
|
1374 TBool jit; |
|
1375 jit=User::JustInTime(); |
|
1376 User::SetJustInTime(EFalse); |
|
1377 |
|
1378 TInt err=thread.Create(aName,aFunction,KDefaultStackSize*8,KMinHeapSize,0x100000,0); |
|
1379 test(err==KErrNone); |
|
1380 thread.Logon(threadStatus) ; |
|
1381 thread.Resume(); |
|
1382 |
|
1383 User::WaitForRequest(threadStatus); |
|
1384 |
|
1385 // Different verifications for debug and release mode. |
|
1386 #ifdef _DEBUG |
|
1387 test(thread.ExitType()==EExitPanic); |
|
1388 test(thread.ExitReason()==EEComPanic_InvalidImplementationInstanceKey); |
|
1389 #else |
|
1390 test(thread.ExitType()==EExitKill); |
|
1391 test(thread.ExitReason()==KErrNotFound); |
|
1392 #endif |
|
1393 |
|
1394 thread.Close(); |
|
1395 User::SetJustInTime(jit); |
|
1396 } |
|
1397 |
|
1398 /** |
|
1399 @SYMTestCaseID SYSLIB-ECOM-CT-3582 |
|
1400 @SYMTestCaseDesc Tests for GetExtendedInterfaceL, stand alone and built in extended interfaces with |
|
1401 valid instance keys. |
|
1402 @SYMTestPriority High |
|
1403 @SYMTestActions Create an implementation. Fetch two extended interfaces (one build in, and one |
|
1404 stand alone and requires release). Call extended interfaces. Destroy implementation. |
|
1405 Re-create the same implementation again. Fetch extended interface. Destroy implementation. |
|
1406 Re-create again. Fetch two extended interfaces (both being stand alone and |
|
1407 require release). |
|
1408 @SYMTestExpectedResults Ensure that Extended interfaces can be created, called and cleaned up when |
|
1409 implementation is destroyed. |
|
1410 @SYMEC EC43 |
|
1411 */ |
|
1412 LOCAL_C void GetExtendedInterfaceTest1L() |
|
1413 { |
|
1414 // Test Starts... |
|
1415 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3582 ")); |
|
1416 test.Printf(_L("Loading Plugin...")); |
|
1417 const TUid KExample10ImplementationUid = {0x10009E38}; |
|
1418 |
|
1419 CExampleInterface* dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); |
|
1420 CleanupStack::PushL(dllPtr); |
|
1421 |
|
1422 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
1423 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
1424 |
|
1425 // Calls extended interface here. |
|
1426 const TUid KExample10InterfaceUid1 = {0x10009E44}; |
|
1427 const TUid KExample10InterfaceUid2 = {0x10009E45}; |
|
1428 |
|
1429 // Fetches an extended interface. |
|
1430 MExampleInterfaceExtended* ext1 = static_cast<MExampleInterfaceExtended*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); |
|
1431 // Sanity check by calling extended interface. |
|
1432 ext1->DoMethodExtended(); |
|
1433 |
|
1434 // Fetches an extended interface. Stand alone interface. |
|
1435 MExampleInterfaceExtended2* ext2 = static_cast<MExampleInterfaceExtended2*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid2)); |
|
1436 // Sanity check by calling extended interface. |
|
1437 ext2->DoMethodExtended2(); |
|
1438 |
|
1439 // Delete implementation, this will automatically destroy the stand alone interface. |
|
1440 test.Printf(_L("Destroying Plugin...")); |
|
1441 CleanupStack::Pop(dllPtr); |
|
1442 delete dllPtr; |
|
1443 |
|
1444 // Test to ensure that a new interface can be re-created immediately after deletion. This |
|
1445 // also tests that no problems occur when no extended interfaces require releasing yet |
|
1446 // a release function exists in the plug-in implementation. |
|
1447 dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); |
|
1448 CleanupStack::PushL(dllPtr); |
|
1449 |
|
1450 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
1451 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
1452 |
|
1453 // Ensure that the extended interface can also be fetched again |
|
1454 MExampleInterfaceExtended* ext = static_cast<MExampleInterfaceExtended*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); |
|
1455 ext->DoMethodExtended(); |
|
1456 |
|
1457 test.Printf(_L("Destroying Plugin...")); |
|
1458 CleanupStack::Pop(dllPtr); |
|
1459 delete dllPtr; |
|
1460 |
|
1461 // Re-creates implementation. This time create two extended interfaces that require release |
|
1462 dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); |
|
1463 CleanupStack::PushL(dllPtr); |
|
1464 |
|
1465 test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); |
|
1466 test(KExample10ImplementationUid == dllPtr->ImplId()); |
|
1467 |
|
1468 MExampleInterfaceExtended2* extension1 = static_cast<MExampleInterfaceExtended2*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid2)); |
|
1469 extension1->DoMethodExtended2(); |
|
1470 |
|
1471 const TUid KExample10InterfaceUid3 = {0x10009E46}; |
|
1472 |
|
1473 MExampleInterfaceExtended2* extension2 = static_cast<MExampleInterfaceExtended2*>(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid3)); |
|
1474 extension2->DoMethodExtended2(); |
|
1475 |
|
1476 // Destroy the implementation. This should automatically delete both extended interfaces above |
|
1477 test.Printf(_L("Destroying Plugin...")); |
|
1478 CleanupStack::Pop(dllPtr); |
|
1479 delete dllPtr; |
|
1480 // Test Ends... |
|
1481 } |
|
1482 |
|
1483 |
|
1484 typedef void (*ClassFuncPtrL) (void); |
|
1485 |
|
1486 /** |
|
1487 Wrapper function to call all test functions |
|
1488 @param testFuncL pointer to test function |
|
1489 @param aTestDesc test function name |
|
1490 */ |
|
1491 LOCAL_C void DoBasicTest(ClassFuncPtrL testFuncL, const TDesC& aTestDesc) |
|
1492 { |
|
1493 test.Next(aTestDesc); |
|
1494 |
|
1495 __UHEAP_MARK; |
|
1496 // find out the number of open handles |
|
1497 TInt pHCountStart; |
|
1498 TInt tHCountStart; |
|
1499 RThread().HandleCount(pHCountStart,tHCountStart); |
|
1500 |
|
1501 TRAPD(err, (*testFuncL)()); |
|
1502 test(KErrNone == err); |
|
1503 |
|
1504 // release handles |
|
1505 REComSession::FinalClose(); |
|
1506 |
|
1507 // check that no handles have leaked |
|
1508 TInt pHCountEnd; |
|
1509 TInt tHCountEnd; |
|
1510 RThread().HandleCount(pHCountEnd,tHCountEnd); |
|
1511 |
|
1512 test(pHCountStart == pHCountEnd); |
|
1513 test(tHCountStart == tHCountEnd); |
|
1514 test.Printf(_L("Great ! No handle mismatch.")); |
|
1515 |
|
1516 __UHEAP_MARKEND; |
|
1517 } |
|
1518 |
|
1519 /** |
|
1520 Wrapper function to call all OOM test functions |
|
1521 @param testFuncL pointer to OOM test function |
|
1522 @param aTestDesc test function name |
|
1523 */ |
|
1524 LOCAL_C void DoOOMTest(ClassFuncPtrL testFuncL, const TDesC& aTestDesc) |
|
1525 { |
|
1526 test.Next(aTestDesc); |
|
1527 TInt err; |
|
1528 TInt failAt = 1; |
|
1529 |
|
1530 do |
|
1531 { |
|
1532 __UHEAP_MARK; |
|
1533 // find out the number of open handles |
|
1534 TInt pHCountStart; |
|
1535 TInt tHCountStart; |
|
1536 RThread().HandleCount(pHCountStart,tHCountStart); |
|
1537 |
|
1538 // Setting Heap failure for OOM test |
|
1539 __UHEAP_SETFAIL(RHeap::EDeterministic, failAt++); |
|
1540 |
|
1541 TRAP(err, (*testFuncL)()); |
|
1542 |
|
1543 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
1544 |
|
1545 // release handles |
|
1546 REComSession::FinalClose(); |
|
1547 |
|
1548 // check that no handles have leaked |
|
1549 TInt pHCountEnd; |
|
1550 TInt tHCountEnd; |
|
1551 RThread().HandleCount(pHCountEnd,tHCountEnd); |
|
1552 |
|
1553 test(pHCountStart == pHCountEnd); |
|
1554 test(tHCountStart == tHCountEnd); |
|
1555 test.Printf(_L("Great ! No handle mismatch.")); |
|
1556 |
|
1557 __UHEAP_MARKEND; |
|
1558 } while(err == KErrNoMemory); |
|
1559 |
|
1560 test(err == KErrNone); |
|
1561 test.Printf(_L("- server succeeded at heap failure rate of %i\n"), failAt); |
|
1562 } |
|
1563 |
|
1564 |
|
1565 void DoTests() |
|
1566 { |
|
1567 //Basic test... |
|
1568 test.Printf(_L("Basic tests...\n")); |
|
1569 |
|
1570 DoBasicTest(&GetExtendedInterfaceTest1L,_L("GetExtendedInterfaceTest1L")); |
|
1571 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3583 ")); |
|
1572 ThreadPanicTest(_L("GetExtendedInterface Panic Testing"),GetExtendedInterfacePanic); |
|
1573 DoBasicTest(&GetExtendedInterfaceTest3L,_L("GetExtendedInterfaceTest3L")); |
|
1574 DoBasicTest(&GetExtendedInterfaceTest4L,_L("GetExtendedInterfaceTest4L")); |
|
1575 DoBasicTest(&GetExtendedInterfaceTest5L,_L("GetExtendedInterfaceTest5L")); |
|
1576 DoBasicTest(&ReleaseExtendedInterfaceTest1L,_L("ReleaseExtendedInterfaceTest1L")); |
|
1577 DoBasicTest(&ReleaseExtendedInterfaceTest2L,_L("ReleaseExtendedInterfaceTest2L")); |
|
1578 DoBasicTest(&ListExtendedInterfaceTestL,_L("ListExtendedInterfaceTestL")); |
|
1579 |
|
1580 DoBasicTest(&CreateImplementationTest1,_L("CreateImplementationTest1")); |
|
1581 DoBasicTest(&CreateImplementationTest2L,_L("CreateImplementationTest2L")); |
|
1582 DoBasicTest(&CreateImplementationTest3L,_L("CreateImplementationTest3L")); |
|
1583 DoBasicTest(&CreateImplementationTest4L,_L("CreateImplementationTest4L")); |
|
1584 DoBasicTest(&CreateImplementationTest5L,_L("CreateImplementationTest5L")); |
|
1585 DoBasicTest(&CreateImplementationTest6,_L("CreateImplementationTest6")); |
|
1586 DoBasicTest(&CreateImplementationTest7L,_L("CreateImplementationTest7L")); |
|
1587 DoBasicTest(&DestroyedImplementationTestL,_L("DestroyedImplementationTestL")); |
|
1588 |
|
1589 DoBasicTest(&ListImplementationTest1L,_L("ListImplementationTest1L")); |
|
1590 DoBasicTest(&ListImplementationTest2L,_L("ListImplementationTest2L")); |
|
1591 DoBasicTest(&ListImplementationTest3L,_L("ListImplementationTest3L")); |
|
1592 DoBasicTest(&ListImplementationTest4L,_L("ListImplementationTest4L")); |
|
1593 DoBasicTest(&ListImplementationTest5L,_L("ListImplementationTest5L")); |
|
1594 |
|
1595 DoBasicTest(&DummyUidTestL,_L("CreateImplementation and ListImplementation Dummy UID test")); |
|
1596 |
|
1597 // OOM test... |
|
1598 test.Printf(_L("OOM tests...\n")); |
|
1599 |
|
1600 DoOOMTest(&GetExtendedInterfaceTest1L,_L("OOM GetExtendedInterfaceTest1L")); |
|
1601 // GetExtendedInterfaceTest2L is a special test case, cannot do OOM testing. |
|
1602 DoOOMTest(&GetExtendedInterfaceTest3L,_L("OOM GetExtendedInterfaceTest3L")); |
|
1603 DoOOMTest(&GetExtendedInterfaceTest4L,_L("OOM GetExtendedInterfaceTest4L")); |
|
1604 DoOOMTest(&GetExtendedInterfaceTest5L,_L("OOM GetExtendedInterfaceTest5L")); |
|
1605 DoOOMTest(&ReleaseExtendedInterfaceTest1L,_L("OOM ReleaseExtendedInterfaceTest1L")); |
|
1606 DoOOMTest(&ReleaseExtendedInterfaceTest2L,_L("OOM ReleaseExtendedInterfaceTest2L")); |
|
1607 DoOOMTest(&ListExtendedInterfaceTestL,_L("OOM ListExtendedInterfaceTestL")); |
|
1608 |
|
1609 // CreateImplementationTest1 is a special test case, cannot do OOM testing. |
|
1610 DoOOMTest(&CreateImplementationTest2L,_L("OOM CreateImplementationTest2L")); |
|
1611 DoOOMTest(&CreateImplementationTest3L,_L("OOM CreateImplementationTest3L")); |
|
1612 DoOOMTest(&CreateImplementationTest4L,_L("OOM CreateImplementationTest4L")); |
|
1613 DoOOMTest(&CreateImplementationTest5L,_L("OOM CreateImplementationTest5L")); |
|
1614 // CreateImplementationTest6 is a special test case, cannot do OOM testing. |
|
1615 DoOOMTest(&CreateImplementationTest7L,_L("OOM CreateImplementationTest7L")); |
|
1616 DoOOMTest(&DestroyedImplementationTestL,_L("OOM DestroyedImplementationTestL")); |
|
1617 |
|
1618 DoOOMTest(&ListImplementationTest1L,_L("OOM ListImplementationTest1L")); |
|
1619 DoOOMTest(&ListImplementationTest2L,_L("OOM ListImplementationTest2L")); |
|
1620 DoOOMTest(&ListImplementationTest3L,_L("OOM ListImplementationTest3L")); |
|
1621 DoOOMTest(&ListImplementationTest4L,_L("OOM ListImplementationTest4L")); |
|
1622 DoOOMTest(&ListImplementationTest5L,_L("OOM ListImplementationTest5L")); |
|
1623 } |
|
1624 |
|
1625 |
|
1626 GLDEF_C TInt E32Main() |
|
1627 { |
|
1628 __UHEAP_MARK; |
|
1629 test.Title(); |
|
1630 |
|
1631 test.Start(_L("ExtendedInterfaces tests.")); |
|
1632 |
|
1633 // get clean-up stack |
|
1634 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
1635 |
|
1636 //The reason for the folowing delay is: |
|
1637 //ECOM server could be already started. It means that when we copy some |
|
1638 //ECOM plugins from Z: to C: drive - ECOM server should look for and |
|
1639 //find the new ECOM plugins. The ECOM server uses for that CDiscoverer::CIdleScanningTimer |
|
1640 //which is an active object. So the discovering service is asynchronous. We have to |
|
1641 //wait some time until it finishes. Otherwise ListImplementationsL could fail to find |
|
1642 //requested implementations. |
|
1643 User::After(KOneSecond * 5); |
|
1644 |
|
1645 DoTests(); |
|
1646 |
|
1647 delete cleanup; |
|
1648 |
|
1649 test.End(); |
|
1650 test.Close(); |
|
1651 __UHEAP_MARKEND; |
|
1652 return(0); |
|
1653 } |