|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // This file contains test classes and their implementations |
|
15 // to test production class CLoadManager. Where necessary stubs |
|
16 // are implemented to help in writing test harness using RTest. |
|
17 // Plugins available to be used in this test |
|
18 // Interface UID DLL UID Implementation UID Version DllFile |
|
19 // 0x10009DC0 0x10009DB1 0x10009DC3 1 Z:\\..\\EComExample.dll |
|
20 // 0x10009DB1 0x10009DC4 1 Z:\\..\\EComExample.dll |
|
21 // 0x10009DB3 0x10009DC3 2 Z:\\..\\EComExample2.dll |
|
22 // 0x10009DB3 0x10009DC4 2 Z:\\..\\EComExample2.dll |
|
23 // 0x101F8477 0x101F8478 1 Z:\\..\\EComExample3.dll |
|
24 // 0x101F8479 0x101F847A 1 Z:\\..\\EComExample4.dll |
|
25 // 0x101F847B 0x101F847C 1 C:\\..\\EComExample5.dll |
|
26 // 0x10282331 0x10282330 0x10282332 1 Z:\\..\\EComLoadMgrExample1.dll |
|
27 // 0x10282330 0x10282334 1 Z:\\..\\EComLoadMgrExample1.dll |
|
28 // 0x10282335 0x10282333 1 Z:\\..\\EComLoadMgrExample2.dll |
|
29 // |
|
30 // |
|
31 |
|
32 #include <e32test.h> |
|
33 #include <f32file.h> |
|
34 #include <bautils.h> |
|
35 #include <e32uid.h> |
|
36 #include "LoadManager.h" |
|
37 #include <ecom/ecomerrorcodes.h> |
|
38 #include "EComUidCodes.h" |
|
39 #include "RegistryData.h" |
|
40 #include <ecom/implementationinformation.h> |
|
41 #include "../EcomTestUtils/EcomTestUtils.h" |
|
42 #include "Interface.h" |
|
43 #include "UnloadPolicy.h" |
|
44 // --------------------------------------------------------------------------- |
|
45 // Test and Leave framework |
|
46 |
|
47 LOCAL_D RTest TheTest(_L("t_loadmanager.exe")); |
|
48 |
|
49 LOCAL_C void Check(TInt aValue, TInt aLine) |
|
50 { |
|
51 if(!aValue) |
|
52 { |
|
53 //DeleteTestPlugin(); |
|
54 TheTest(EFalse, aLine); |
|
55 } |
|
56 } |
|
57 |
|
58 LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine) |
|
59 { |
|
60 if(aValue != aExpected) |
|
61 { |
|
62 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
63 //DeleteTestPlugin(); |
|
64 TheTest(EFalse, aLine); |
|
65 } |
|
66 } |
|
67 |
|
68 #define TEST(arg) ::Check((arg), __LINE__) |
|
69 |
|
70 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
71 |
|
72 //Leave with info message printed out |
|
73 LOCAL_C void Leave(TInt aError, TInt aLine) |
|
74 { |
|
75 RDebug::Print(_L("*** Leave. Error: %d, Line: %d\r\n"), aError, aLine); |
|
76 User::Leave(aError); |
|
77 } |
|
78 |
|
79 |
|
80 //Use LEAVE() macro instead of User::Leave() and LEAVE_IF_ERROR() macro instead of |
|
81 //User::LeaveIfError(). They will print the line number, where the "leave" was called. |
|
82 |
|
83 #define LEAVE(aError) ::Leave(aError, __LINE__) |
|
84 |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 |
|
88 LOCAL_D RFs TheFs; |
|
89 |
|
90 LOCAL_D CTrapCleanup* TheTrapCleanup = NULL; |
|
91 |
|
92 LOCAL_D CActiveScheduler* TheActiveScheduler = NULL; |
|
93 |
|
94 //Plugins files used for this test program |
|
95 _LIT(KResourceFileName5, "C:\\resource\\plugins\\EComExample5.RSC"); |
|
96 _LIT(KExampleDllFileName5, "C:\\sys\\bin\\EComExample5.dll"); |
|
97 _LIT(KExampleDllFileName4,"Z:\\sys\\bin\\EComExample4.dll"); |
|
98 _LIT(KExampleDllFileName3,"Z:\\sys\\bin\\EComExample3.dll"); |
|
99 _LIT(KExampleDllFileName2,"Z:\\sys\\bin\\EComExample2.dll"); |
|
100 _LIT(KLoadMgrExample1DllName,"Z:\\sys\\bin\\EComLoadMgrExample1.dll"); |
|
101 _LIT(KLoadMgrExample2DllName,"Z:\\sys\\bin\\EComLoadMgrExample2.dll"); |
|
102 |
|
103 _LIT(KResourceFileName5OnZ, "z:\\RAMOnly\\EComExample5.RSC"); |
|
104 _LIT(KExampleDllFileName10,"Z:\\sys\\bin\\EComExample10.dll"); |
|
105 _LIT(KNULLString,""); |
|
106 |
|
107 _LIT(KExampleDllFileName12,"C:\\sys\\bin\\EComExample12.dll"); |
|
108 _LIT(KExampleDllFileName12OnZ, "z:\\RAMOnly\\EComExample12.dll"); |
|
109 _LIT(KResourceFileName12, "C:\\resource\\plugins\\EComExample12.RSC"); |
|
110 _LIT(KResourceFileName12OnZ, "z:\\RAMOnly\\EComExample12.RSC"); |
|
111 |
|
112 //Contains files that are part of ROM that must be |
|
113 //Copied to the RAM for test purposes |
|
114 |
|
115 _LIT(KExampleDllFileName5OnZ, "z:\\RAMOnly\\EComExample5.dll"); |
|
116 |
|
117 |
|
118 // Used for supressing warning in OOM tests |
|
119 #define __UNUSED_VAR(var) var = var |
|
120 |
|
121 const TInt KOneSecond = 1000000; |
|
122 |
|
123 // Utility clean up function |
|
124 void CleanupEComArray(TAny* aArray); |
|
125 |
|
126 //It is used by some test methods which are called two times: |
|
127 //from normal test and from OOM TheTest. |
|
128 static void LeaveIfErrNoMemory(TInt aError) |
|
129 { |
|
130 if(aError == KErrNoMemory) |
|
131 { |
|
132 LEAVE(aError); |
|
133 } |
|
134 } |
|
135 |
|
136 /** |
|
137 Test State Accessor class for CLoadManager |
|
138 This class will be used to access the state |
|
139 of the policy array within CLoadManager |
|
140 */ |
|
141 class TLoadManager_StateAccessor |
|
142 { |
|
143 public: |
|
144 //Return the number of instance index inside iInstanceInfoList |
|
145 TInt InstanceIndexCount(CLoadManager& aLoadManager); |
|
146 //Return the number of unload policy inside iAllUnloadPolicies |
|
147 TInt UnloadPolicyCount(CLoadManager& aLoadManager); |
|
148 //Return a pointer to Instance Index item inside the instance index array |
|
149 CInstanceInfo* InstanceIndex(const TInt& aInt,CLoadManager& aLoadManager); |
|
150 //Return a pointer to UnloadPolicy item inside the array |
|
151 CUnloadPolicy* UnloadPolicy(const TInt& aInt,CLoadManager& aLoadManager); |
|
152 //Return a pointer to garbage UnloadPolicy |
|
153 CUnloadPolicy* GarbagePolicy(CLoadManager& aLoadManager); |
|
154 //Return a count to the number of extended objects within an Extended instance. |
|
155 // Must pass in the index of a valid extended instance |
|
156 TInt ExtendedInstanceCount(const TInt& aInt,CLoadManager& aLoadManager); |
|
157 }; |
|
158 |
|
159 TInt TLoadManager_StateAccessor::InstanceIndexCount(CLoadManager& aLoadManager) |
|
160 { |
|
161 return aLoadManager.iInstanceInfoList.Count(); |
|
162 } |
|
163 |
|
164 TInt TLoadManager_StateAccessor::UnloadPolicyCount(CLoadManager& aLoadManager) |
|
165 { |
|
166 return aLoadManager.iAllUnloadPolicies.Count(); |
|
167 } |
|
168 |
|
169 CInstanceInfo* TLoadManager_StateAccessor::InstanceIndex(const TInt& aInt,CLoadManager& aLoadManager) |
|
170 { |
|
171 return (aLoadManager.iInstanceInfoList[aInt]); |
|
172 } |
|
173 |
|
174 CUnloadPolicy* TLoadManager_StateAccessor::UnloadPolicy(const TInt& aInt,CLoadManager& aLoadManager) |
|
175 { |
|
176 return aLoadManager.iAllUnloadPolicies[aInt]; |
|
177 } |
|
178 CUnloadPolicy* TLoadManager_StateAccessor::GarbagePolicy(CLoadManager& aLoadManager) |
|
179 { |
|
180 return aLoadManager.iGarbagePolicy; |
|
181 } |
|
182 |
|
183 TInt TLoadManager_StateAccessor::ExtendedInstanceCount(const TInt& aInt,CLoadManager& aLoadManager) |
|
184 { |
|
185 CInstanceInfoExtended* instanceExtended = static_cast<CInstanceInfoExtended*>(aLoadManager.iInstanceInfoList[aInt]); |
|
186 return instanceExtended->iExtendedObjectInfo.Count(); |
|
187 } |
|
188 |
|
189 |
|
190 /** |
|
191 Test class for object CLoadManager. |
|
192 The class provides the parameters and behaviour that |
|
193 allows this class to behave normally under a test scenario. |
|
194 */ |
|
195 class CLoadManagerTest : public CBase |
|
196 { |
|
197 public: |
|
198 static CLoadManagerTest* NewL(); |
|
199 virtual inline ~CLoadManagerTest(); |
|
200 |
|
201 void InstantiationMethodTestL(TUid aDllUid, const TDesC& aDllName, const TUid aIICType); |
|
202 void DestroyThisTestL(TUid aDllUid, const TDesC& aDllName, const TUid aIICType); |
|
203 |
|
204 void CreateDestroyTestCase1L(TUid aDllUid1, |
|
205 TUid aImplUid1, |
|
206 const TDesC& aDllName1, |
|
207 TUid aDllUid2, |
|
208 TUid aImplUid2, |
|
209 const TDesC& aDllName2, |
|
210 const TUid aIICType); |
|
211 void CreateDestroyTestCase2L(TUid aDllUid, |
|
212 TUid aImplUid1, |
|
213 const TDesC& aDllName, |
|
214 TUid aImplUid2, |
|
215 const TUid aIICType); |
|
216 void CreateDestroyTestCase3L(); |
|
217 |
|
218 void CreateDestroyTestCase4L(TUid aDllUid,TUid aImplUid,const TDesC& aDllName,const TUid aIICType); |
|
219 |
|
220 void CreateDestroyTestCase5L(TUid aDllUid1, |
|
221 TUid aImplUid1, |
|
222 const TDesC& aDllName1, |
|
223 TUid aDllUid2, |
|
224 TUid aImplUid2, |
|
225 const TDesC& aDllName2, |
|
226 TUid aImplUid3, |
|
227 const TUid aIICType); |
|
228 |
|
229 void SpecialOOMTestCaseL(); |
|
230 |
|
231 void InstantiationMethodTestPlugin1L(); |
|
232 void InstantiationMethodTestPlugin3L(); |
|
233 void ImplementationObjectTestL(); |
|
234 |
|
235 void GetImplementationUidTestL(); |
|
236 |
|
237 void DestroyThisTestPlugin1L(); |
|
238 void DestroyThisTestPlugin3L(); |
|
239 |
|
240 void CreateDestroyTestCase1Plugin1L(); |
|
241 void CreateDestroyTestCase1Plugin3L(); |
|
242 |
|
243 void CreateDestroyTestCase2Plugin1L(); |
|
244 void CreateDestroyTestCase2Plugin3L(); |
|
245 |
|
246 void CreateDestroyTestCase3Plugin3L(); |
|
247 |
|
248 void CreateDestroyTestCase4Plugin1L(); |
|
249 void CreateDestroyTestCase4Plugin3L(); |
|
250 |
|
251 void CreateDestroyTestCase5Plugin1L(); |
|
252 void CreateDestroyTestCase5Plugin3L(); |
|
253 |
|
254 // Extended methods |
|
255 void ExtendedMethodTest1Plugin3L(); |
|
256 void ExtendedMethodTest2Plugin3L(); |
|
257 void ManuallyReleaseExtendedInterfaceTestL(); |
|
258 void CreateDestroyTestCase1PluginAndPlugin3L(); |
|
259 |
|
260 private: |
|
261 CLoadManagerTest(); |
|
262 void ConstructL(); |
|
263 |
|
264 public: |
|
265 /** The instance of the class under test */ |
|
266 CLoadManager* iLoadManager; |
|
267 |
|
268 /** Unique Id of an interface implementation */ |
|
269 TUid iImplementationUid; |
|
270 |
|
271 /** LoadManager State Accessor */ |
|
272 TLoadManager_StateAccessor iStateAccessor; |
|
273 }; |
|
274 |
|
275 /** |
|
276 Standardised safe construction which |
|
277 leaves nothing on the cleanup stack. |
|
278 |
|
279 @post CLoadManagerTest is fully constructed and initialised. |
|
280 */ |
|
281 CLoadManagerTest* CLoadManagerTest::NewL() |
|
282 { |
|
283 CLoadManagerTest* self = new(ELeave) CLoadManagerTest; |
|
284 CleanupStack::PushL(self); |
|
285 self->ConstructL(); |
|
286 CleanupStack::Pop(self); |
|
287 return self; |
|
288 } |
|
289 |
|
290 /** |
|
291 Standardized default constructor |
|
292 |
|
293 @post CLoadManagerTest is fully constructed. |
|
294 */ |
|
295 CLoadManagerTest::CLoadManagerTest() |
|
296 { |
|
297 // Implementation id for interface 0x10009DC0 |
|
298 // Implemented in test plugin EComExample4.dll |
|
299 iImplementationUid.iUid = 0x101F847A; |
|
300 } |
|
301 |
|
302 /** |
|
303 Destructor. |
|
304 |
|
305 @post This object is properly destroyed. |
|
306 */ |
|
307 CLoadManagerTest::~CLoadManagerTest() |
|
308 { |
|
309 delete iLoadManager; |
|
310 } |
|
311 |
|
312 /** |
|
313 Standardized 2nd(Initialization) phase of two phase construction. |
|
314 |
|
315 @post CLoadManagerTest is fully constructed. |
|
316 */ |
|
317 void CLoadManagerTest::ConstructL() |
|
318 { |
|
319 iLoadManager = CLoadManager::NewL(); |
|
320 } |
|
321 |
|
322 /** |
|
323 The test executes by getting the Instantiation method for |
|
324 the given ImplementationId |
|
325 */ |
|
326 void CLoadManagerTest::InstantiationMethodTestL(TUid aDllUid, const TDesC& aDllName, const TUid aIICType) |
|
327 { |
|
328 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
329 iInitParams.integer = 5; |
|
330 TBool initParamsFlag = ETrue; |
|
331 _LIT(KDummyText,"Dummy params"); |
|
332 iInitParams.descriptor = &KDummyText; |
|
333 |
|
334 TEntry entry; |
|
335 entry.iName=aDllName; |
|
336 entry.iModified=TTime(0); |
|
337 entry.iType=TUidType(KDynamicLibraryUid,aIICType,aDllUid); |
|
338 |
|
339 TAny* implementationPtr = 0; |
|
340 TUid instanceKey; |
|
341 TRAPD(err, implementationPtr = iLoadManager->ImplementationObjectL(iImplementationUid, entry,&iInitParams, initParamsFlag,instanceKey)); |
|
342 |
|
343 ::LeaveIfErrNoMemory(err); |
|
344 TEST2(err,KErrNone); |
|
345 TEST(implementationPtr != 0); |
|
346 |
|
347 //Checking the state of the arrays inside CLoadManager and garbage policy |
|
348 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager)==1); |
|
349 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager)==1); |
|
350 TEST(iStateAccessor.GarbagePolicy(*iLoadManager)==NULL); |
|
351 |
|
352 //Checking the instance index and UnloadPolicy info |
|
353 TEST(iStateAccessor.InstanceIndex(0,*iLoadManager)->ImplementationUid()==iImplementationUid); |
|
354 TEST(iStateAccessor.UnloadPolicy(0,*iLoadManager)->DllEntryInformation().GetName().CompareF(aDllName)==0); |
|
355 |
|
356 delete (CExampleInterface*)implementationPtr; |
|
357 implementationPtr=0; |
|
358 iLoadManager->DestroyedThis(instanceKey); |
|
359 iLoadManager->ClearGarbage(); |
|
360 } |
|
361 |
|
362 /** |
|
363 Test CLoadManager::ImplementationObjectL with parameters to test old proxy table |
|
364 */ |
|
365 void CLoadManagerTest::InstantiationMethodTestPlugin1L() |
|
366 { |
|
367 // This test tests with Ecom plugin EComExample4.dll |
|
368 // EComExample4.dll should be installed on Z: drive |
|
369 // The test executes by getting the Instantiation method for the given ImplementationId |
|
370 // implementationPtr method should get some valid address. |
|
371 // Manually creating the DLL info that in practice will be returned from the server side |
|
372 // Set up some init params to be used for testing purpose |
|
373 TUid dllUid; |
|
374 dllUid.iUid = 0x101F8479; |
|
375 iImplementationUid.iUid=0x101F847A; |
|
376 InstantiationMethodTestL(dllUid,KExampleDllFileName4,KUidInterfaceImplementationCollection); |
|
377 } |
|
378 |
|
379 /** |
|
380 @SYMTestCaseID SYSLIB-ECOM-UT-3549 |
|
381 @SYMTestCaseDesc Calls CLoadManager::ImplementationObjectL with parameters to test new proxy table |
|
382 @SYMTestPriority High |
|
383 @SYMTestActions Instantiate implementation for the given ImplementationId with construction parameters |
|
384 and check the CLoadManager data structures. |
|
385 Destroy the implementation object and again check the CLoadManager data structures. |
|
386 (ECom plugin EComExample10.dll will be used for the test.) |
|
387 @SYMTestExpectedResults Ensure the CLoadManager data structures are as expected after the ImplementationObjectL calls |
|
388 @SYMEC EC43 |
|
389 */ |
|
390 void CLoadManagerTest::InstantiationMethodTestPlugin3L() |
|
391 { |
|
392 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3549 ")); |
|
393 TUid dllUid; |
|
394 dllUid.iUid = 0x10009E37; |
|
395 iImplementationUid.iUid = 0x10009E38; |
|
396 InstantiationMethodTestL(dllUid,KExampleDllFileName10,KUidInterfaceImplementationCollection3); |
|
397 } |
|
398 |
|
399 |
|
400 /** |
|
401 @SYMTestCaseID SYSLIB-ECOM-UT-3710 |
|
402 @SYMTestCaseDesc Tests CLoadManager::ImplementationObjectL with some extreme conditions to improve the |
|
403 condition coverage rate. |
|
404 1. implementationUid is NULL. The function will leave with KErrNotFound |
|
405 2. dllName is NULL. The function will leave with KErrNotFound |
|
406 3. second Uid of the PlugIn is neither IIC or IIC3. The function will leave with KErrNotSupported |
|
407 @SYMTestPriority High |
|
408 @SYMTestActions Calls CLoadManager::ImplementationObjectL and check the result. |
|
409 @SYMTestExpectedResults Expected error is return. |
|
410 @SYMDEF DEF111196 |
|
411 */ |
|
412 void CLoadManagerTest::ImplementationObjectTestL() |
|
413 { |
|
414 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3710 ")); |
|
415 TUid dummyUid; |
|
416 dummyUid.iUid = 0; |
|
417 |
|
418 TUid dllUid; |
|
419 dllUid.iUid = 0x10009E37; |
|
420 |
|
421 iImplementationUid.iUid = 0x10009E38; |
|
422 |
|
423 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
424 iInitParams.integer = 5; |
|
425 TBool initParamsFlag = ETrue; |
|
426 _LIT(KDummyText,"Dummy params"); |
|
427 iInitParams.descriptor = &KDummyText; |
|
428 |
|
429 TEntry entry; |
|
430 entry.iName=KExampleDllFileName10; |
|
431 entry.iModified=TTime(0); |
|
432 entry.iType=TUidType(KDynamicLibraryUid,KUidInterfaceImplementationCollection3,dllUid); |
|
433 |
|
434 TUid instanceKey; |
|
435 |
|
436 // 1. Calls ImplementationObjectL with implementationUid is NULL. The function will leave with KErrNotFound |
|
437 TRAPD(err, TAny* implementationPtr = iLoadManager->ImplementationObjectL(dummyUid, entry,&iInitParams, initParamsFlag,instanceKey)); |
|
438 TEST2(err,KErrNotFound); |
|
439 |
|
440 // 2. Calls ImplementationObjectL with dllName is NULL. The function will leave with KErrNotFound |
|
441 entry.iName = KNULLString; |
|
442 TRAP(err, TAny* implementationPtr = iLoadManager->ImplementationObjectL(iImplementationUid,entry,&iInitParams, initParamsFlag,instanceKey)); |
|
443 TEST2(err,KErrNotFound); |
|
444 |
|
445 // 3. Calls ImplementationObjectL with second Uid of the PlugIn is neither IIC or IIC3 |
|
446 entry.iName=KExampleDllFileName10; |
|
447 entry.iModified=TTime(0); |
|
448 entry.iType=TUidType(KDynamicLibraryUid,dummyUid,dllUid); |
|
449 TRAP(err, TAny* implementationPtr = iLoadManager->ImplementationObjectL(iImplementationUid,entry,&iInitParams, initParamsFlag,instanceKey)); |
|
450 TEST2(err,KErrNotSupported); |
|
451 } |
|
452 |
|
453 |
|
454 /** |
|
455 Test CLoadManager::DestroyThis(). DestroyThis will actually either remove the UnloadPolicy from the list or decrease |
|
456 referencecount(to UnloadPolicy) by one. |
|
457 */ |
|
458 void CLoadManagerTest::DestroyThisTestL(TUid aDllUid, const TDesC& aDllName, const TUid aIICType) |
|
459 { |
|
460 // We must call DestroyedThis only after getting a reference to the Implementation |
|
461 // so that reference count to this implementaion have value greater than zero. |
|
462 // ImplementationObjectL is called to increase the reference count of the test implementation, |
|
463 // so that its reference count goes to 1. |
|
464 // This test executes by verifing the reference count to this implementation. |
|
465 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
466 iInitParams.integer = 5; |
|
467 TBool initParamsFlag = ETrue; |
|
468 _LIT(KDummyText,"Dummy params"); |
|
469 iInitParams.descriptor = &KDummyText; |
|
470 |
|
471 TEntry entry; |
|
472 entry.iName=aDllName; |
|
473 entry.iModified=TTime(0); |
|
474 entry.iType=TUidType(KDynamicLibraryUid, aIICType, aDllUid); |
|
475 |
|
476 TAny* implementationPtr = 0; |
|
477 TUid instanceKey; |
|
478 TRAPD(err, implementationPtr = iLoadManager->ImplementationObjectL(iImplementationUid, entry, &iInitParams, initParamsFlag,instanceKey)); |
|
479 |
|
480 ::LeaveIfErrNoMemory(err); |
|
481 TEST2(err,KErrNone); |
|
482 TEST(implementationPtr != 0); |
|
483 |
|
484 //Checking the state of the arrays inside CLoadManager and the garbage policy |
|
485 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager)==1); |
|
486 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager)==1); |
|
487 TEST(iStateAccessor.GarbagePolicy(*iLoadManager)==NULL); |
|
488 |
|
489 // The purpose of DestroyedThis is to decrease the reference count of UnloadPolicy or |
|
490 // remove the Dll from RegistryData if its on grabagelist and reference count reaches 0 |
|
491 iLoadManager->DestroyedThis(instanceKey); |
|
492 |
|
493 //Checking the state of the arrays inside CLoadManager and the garbage policy |
|
494 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager)==0); |
|
495 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager)==0); |
|
496 TEST(iStateAccessor.GarbagePolicy(*iLoadManager)!=NULL); |
|
497 |
|
498 //delete the instantiation |
|
499 delete (CExampleInterface*)implementationPtr; |
|
500 implementationPtr=0; |
|
501 } |
|
502 |
|
503 /** |
|
504 @SYMTestCaseID SYSLIB-ECOM-UT-3709 |
|
505 @SYMTestCaseDesc This testcase checks GetImplementationUidL(). |
|
506 @SYMTestPriority High |
|
507 @SYMTestActions Instantiate an implementation. |
|
508 Call GetImplementationUidL() and check impl id. |
|
509 Call GetImplementationUidL() and check impl id again. |
|
510 Destroy plugin. |
|
511 Call GetImplementationUidL() and check for error. |
|
512 @SYMTestExpectedResults Returns impl uid when valid destructor uid is used otherwise |
|
513 leaves with the appropriate error. |
|
514 @SYMDEF DEF111789 |
|
515 */ |
|
516 void CLoadManagerTest::GetImplementationUidTestL() |
|
517 { |
|
518 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3709 ")); |
|
519 // EComExample5.dll (dlluid 0x101F847B) in C:\ with Implementation Uid =0x101F847C |
|
520 TUid dllUid; |
|
521 dllUid.iUid = 0x101F847B; |
|
522 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
523 iInitParams.integer = 5; |
|
524 TBool initParamsFlag = ETrue; |
|
525 _LIT(KDummyText,"Dummy params"); |
|
526 iInitParams.descriptor = &KDummyText; |
|
527 |
|
528 TEntry entry; |
|
529 entry.iName=KExampleDllFileName5; |
|
530 |
|
531 entry.iModified=TTime(0); |
|
532 entry.iType=TUidType(KDynamicLibraryUid, KUidInterfaceImplementationCollection, dllUid); |
|
533 |
|
534 iImplementationUid.iUid=0x101F847C; |
|
535 |
|
536 TAny* implementationPtr = 0; |
|
537 TUid instanceKey; |
|
538 TRAPD(err, implementationPtr = iLoadManager->ImplementationObjectL(iImplementationUid, entry, &iInitParams, initParamsFlag, instanceKey)); |
|
539 |
|
540 ::LeaveIfErrNoMemory(err); |
|
541 TEST2(err,KErrNone); |
|
542 TEST(implementationPtr != 0); |
|
543 |
|
544 // Retrieve impl uid corresponding to detructor key id |
|
545 TUid implId = iLoadManager->GetImplementationUidL(instanceKey); |
|
546 // Check that the impl uid corresponding to destructor key id is as expected |
|
547 TEST(implId == iImplementationUid); |
|
548 |
|
549 // Do it again to be sure... |
|
550 implId = iLoadManager->GetImplementationUidL(instanceKey); |
|
551 // Check that the impl uid corresponding to destructor key id is as expected |
|
552 TEST(implId == iImplementationUid); |
|
553 |
|
554 iLoadManager->DestroyedThis(instanceKey); |
|
555 |
|
556 //delete the instantiation |
|
557 delete (CExampleInterface*)implementationPtr; |
|
558 implementationPtr=0; |
|
559 |
|
560 // Call GetImplementationUidL() again now that the instance has been deleted |
|
561 // Expecting a Leave... |
|
562 TRAP(err,implId = iLoadManager->GetImplementationUidL(instanceKey)); |
|
563 TEST2(err, KErrNotFound); |
|
564 } |
|
565 |
|
566 /** |
|
567 Test executes by getting the CUnloadPolicy* associated to the testing DLL EComExample5.dll. |
|
568 */ |
|
569 void CLoadManagerTest::DestroyThisTestPlugin1L() |
|
570 { |
|
571 // EComExample5.dll (dlluid 0x101F847B) in C:\ with Implementation Uid =0x101F847C |
|
572 TUid dllUid; |
|
573 dllUid.iUid = 0x101F847B; |
|
574 iImplementationUid.iUid=0x101F847C; |
|
575 DestroyThisTestL(dllUid,KExampleDllFileName5,KUidInterfaceImplementationCollection); |
|
576 } |
|
577 |
|
578 /** |
|
579 @SYMTestCaseID SYSLIB-ECOM-UT-3550 |
|
580 @SYMTestCaseDesc Calls CLoadManager::DestroyedThis with parameters to test new proxy table |
|
581 @SYMTestPriority High |
|
582 @SYMTestActions Test executes by getting the CUnloadPolicy* associated to the testing DLL EComExample10.dll. |
|
583 DestroyThis will actually either remove the UnloadPolicy from the list or decrease |
|
584 referencecount(to UnloadPolicy) by one. |
|
585 @SYMTestExpectedResults Ensure the CLoadManager data structures are as expected after the ImplementationObjectL calls |
|
586 @SYMEC EC43 |
|
587 */ |
|
588 void CLoadManagerTest::DestroyThisTestPlugin3L() |
|
589 { |
|
590 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3550 ")); |
|
591 // EComExample10.dll |
|
592 TUid dllUid; |
|
593 dllUid.iUid = 0x10009E37; |
|
594 iImplementationUid.iUid = 0x10009E38; |
|
595 DestroyThisTestL(dllUid,KExampleDllFileName10,KUidInterfaceImplementationCollection3); |
|
596 } |
|
597 |
|
598 /** |
|
599 Tests for create and destroy load manager |
|
600 Test case 1:Creates two implementations from two DIFFERENT DLL Z: C: |
|
601 Test case 2:Creates two implementations from one SAME DLL |
|
602 Test case 3:Invalid argument testing for Create Implementation |
|
603 Invalid Entry and Implementation uid argument in ImplementationObjectL |
|
604 Test case 4:Creates two instance of the same implementation Uid from one single DLL |
|
605 Test case 5:DEF101930: Incorrect policy object returned in |
|
606 This testcase checks for the case where 2 implementations |
|
607 are created each on separate DLL's then an additional |
|
608 implementation is created from one of the already loaded DLL's. |
|
609 The impl uid of the newly created impl is lower then the 2 |
|
610 existing impl uids. The impl uids from the same DLL are such |
|
611 that 1 is higher then the uid of the other impl and 1 is lower than |
|
612 the other impl. |
|
613 */ |
|
614 |
|
615 // Test case 1:Create two implementation from two DIFFERENT DLL Z: C: |
|
616 |
|
617 void CLoadManagerTest::CreateDestroyTestCase1L(TUid aDllUid1, |
|
618 TUid aImplUid1, |
|
619 const TDesC& aDllName1, |
|
620 TUid aDllUid2, |
|
621 TUid aImplUid2, |
|
622 const TDesC& aDllName2, |
|
623 const TUid aIICType) |
|
624 { |
|
625 //Some interface instantiation parameters |
|
626 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
627 iInitParams.integer = 5; |
|
628 TBool initParamsFlag = ETrue; |
|
629 _LIT(KDummyText,"Dummy params"); |
|
630 iInitParams.descriptor = &KDummyText; |
|
631 TAny* impl1 = NULL; |
|
632 TAny* impl2 = NULL; |
|
633 |
|
634 TEntry entry1; |
|
635 entry1.iName = aDllName1; |
|
636 entry1.iModified = TTime(0); |
|
637 entry1.iType = TUidType(KDynamicLibraryUid,aIICType,aDllUid1); |
|
638 |
|
639 TEntry entry2; |
|
640 entry2.iName = aDllName2; |
|
641 entry2.iModified = TTime(0); |
|
642 entry2.iType = TUidType(KDynamicLibraryUid,aIICType,aDllUid2); |
|
643 |
|
644 TInt err; |
|
645 //Creates 1st Implementation |
|
646 TUid instanceKey; |
|
647 TRAP(err,impl1 = iLoadManager->ImplementationObjectL(aImplUid1,entry1, &iInitParams,initParamsFlag,instanceKey)); |
|
648 ::LeaveIfErrNoMemory(err); |
|
649 TEST2(err,KErrNone); |
|
650 |
|
651 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
652 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 1); |
|
653 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 1); |
|
654 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
655 |
|
656 //Creates 2nd Implementation |
|
657 TUid instanceKey2; |
|
658 TRAP(err,impl2 = iLoadManager->ImplementationObjectL(aImplUid2,entry2, &iInitParams,initParamsFlag,instanceKey2)); |
|
659 // If impl2 fails here due to KErrNoMemory we need to clear the previous impl1 |
|
660 // to avoid memory leak |
|
661 if (err==KErrNoMemory) |
|
662 { |
|
663 iLoadManager->DestroyedThis(instanceKey); |
|
664 delete (CExampleInterface*)impl1; |
|
665 impl1 = NULL; |
|
666 ::LeaveIfErrNoMemory(err); |
|
667 } |
|
668 TEST(err == KErrNone); |
|
669 |
|
670 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
671 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 2); |
|
672 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 2); |
|
673 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
674 |
|
675 //Now destroy the 2nd Implementation |
|
676 iLoadManager->DestroyedThis(instanceKey2); |
|
677 delete (CExampleInterface*)impl2; |
|
678 impl2 = NULL; |
|
679 |
|
680 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
681 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 1); |
|
682 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 1); |
|
683 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) != NULL); |
|
684 |
|
685 //Now destroy the 1st Implementation; |
|
686 iLoadManager->DestroyedThis(instanceKey); |
|
687 delete (CExampleInterface*)impl1; |
|
688 impl1 = NULL; |
|
689 |
|
690 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
691 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 0); |
|
692 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 0); |
|
693 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) != NULL); |
|
694 |
|
695 iLoadManager->ClearGarbage(); |
|
696 |
|
697 //Checks the final state of the garbage policy |
|
698 //Tests for the new API ClearGarbage() |
|
699 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
700 } |
|
701 |
|
702 /** |
|
703 Plugins used: |
|
704 - Z:\\..\\EComExample3.dll contains ImplUid=0x101F8478 |
|
705 - C:\\..\\EComExample5.dll contains ImplUid=0x101F847C |
|
706 |
|
707 @SYMTestCaseID SYSLIB-ECOM-CT-0701 |
|
708 @SYMTestCaseDesc Tests for create and delete of CLoadManager |
|
709 @SYMTestPriority High |
|
710 @SYMTestActions Create two implementation from two DIFFERENT DLL Z: C: |
|
711 @SYMTestExpectedResults Two UnloadPolicy inside the array because of Two DLL loaded |
|
712 Two Instance indexes because of two Different Implementation Uid's |
|
713 @SYMREQ REQ0000 |
|
714 */ |
|
715 void CLoadManagerTest::CreateDestroyTestCase1Plugin1L() |
|
716 { |
|
717 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-0701 ")); |
|
718 //Implementation Uid inside Z:\\..\\EComExample3.dll |
|
719 TUid implUid1={0x101F8478}; |
|
720 //Implementation Uid inside C:\\..\\EComExample5.dll |
|
721 TUid implUid2={0x101F847C}; |
|
722 //EComExample3.dll entry |
|
723 TUid dllUid1; |
|
724 dllUid1.iUid = 0x101F8477; |
|
725 //EComExample5.dll entry |
|
726 TUid dllUid2; |
|
727 dllUid2.iUid = 0x101F847B; |
|
728 |
|
729 CreateDestroyTestCase1L(dllUid1,implUid1,KExampleDllFileName3,dllUid2,implUid2,KExampleDllFileName5,KUidInterfaceImplementationCollection); |
|
730 } |
|
731 |
|
732 /** |
|
733 @SYMTestCaseID SYSLIB-ECOM-UT-3551 |
|
734 @SYMTestCaseDesc Tests for create and delete of implementations using PLUGIN3 from two DIFFERENT DLL's |
|
735 @SYMTestPriority High |
|
736 @SYMTestActions Create two implementations from two DIFFERENT DLL's using new Dll type PLUGIN3. |
|
737 Test executes by getting the CUnloadPolicy* associated to the testing DLL EComExample10.dll. |
|
738 DestroyThis will actually either remove the UnloadPolicy from the list or decrease |
|
739 referencecount(to UnloadPolicy) by one. |
|
740 @SYMTestExpectedResults Ensure the CLoadManager data structures are as expected after the ImplementationObjectL calls |
|
741 Two UnloadPolicy inside the array because of Two DLL loaded |
|
742 Two Instance indexes because of two Different Implementation Uid's |
|
743 @SYMEC EC43 |
|
744 */ |
|
745 void CLoadManagerTest::CreateDestroyTestCase1Plugin3L() |
|
746 { |
|
747 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3551 ")); |
|
748 //Implementation Uid inside Z:\\..\\EComExample10.dll |
|
749 TUid implUid1 = {0x10009E38}; |
|
750 //Implementation Uid inside C:\\..\\EComExample12.dll |
|
751 TUid implUid2 = {0x10009E39}; |
|
752 //EComExample10.dll entry |
|
753 TUid dllUid1; |
|
754 dllUid1.iUid = 0x10009E37; |
|
755 //EComExample12.dll entry |
|
756 TUid dllUid2; |
|
757 dllUid2.iUid = 0x10009E3E; |
|
758 |
|
759 CreateDestroyTestCase1L(dllUid1,implUid1,KExampleDllFileName10,dllUid2,implUid2,KExampleDllFileName12,KUidInterfaceImplementationCollection3); |
|
760 } |
|
761 |
|
762 /** |
|
763 @SYMTestCaseID SYSLIB-ECOM-UT-3552 |
|
764 @SYMTestCaseDesc Tests for create and delete of implementations using PLUGIN1 and PLUGIN3 |
|
765 @SYMTestPriority High |
|
766 @SYMTestActions Create two implementations from two DIFFERENT DLL's one of PLUGIN1, the other Dll |
|
767 of type PLUGIN3. Test executes by getting the CUnloadPolicy* associated to the |
|
768 testing DLL EComExample10.dll. DestroyThis will actually either remove the |
|
769 UnloadPolicy from the list or decrease referencecount(to UnloadPolicy) by one. |
|
770 Plugins used: |
|
771 - Z:\\..\\EComExample3.dll contains ImplUid=0x101F8478 - PLUGIN type dll |
|
772 - Z:\\..\\EComExample10.dll contains ImplUid=0x10009E38 - PLUGIN3 type dll |
|
773 @SYMTestExpectedResults Ensure the CLoadManager data structures are as expected after the ImplementationObjectL calls |
|
774 Two UnloadPolicy inside the array because of Two DLL loaded |
|
775 Two Instance indexes because of two Different Implementations |
|
776 @SYMEC EC43 |
|
777 */ |
|
778 void CLoadManagerTest::CreateDestroyTestCase1PluginAndPlugin3L() |
|
779 { |
|
780 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3552 ")); |
|
781 //Implementation Uid inside Z:\\..\\EComExample3.dll |
|
782 TUid ImplUid1 = {0x101F8478}; |
|
783 //Implementation Uid inside Z:\\..\\EComExample10.dll |
|
784 TUid ImplUid2 = {0x10009E38}; |
|
785 //Some interface instantiation parameters |
|
786 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
787 iInitParams.integer = 5; |
|
788 TBool initParamsFlag = ETrue; |
|
789 _LIT(KDummyText,"Dummy params"); |
|
790 iInitParams.descriptor = &KDummyText; |
|
791 TAny* impl1 = NULL; |
|
792 TAny* impl2 = NULL; |
|
793 |
|
794 //EComExample3.dll entry |
|
795 TUid dllUid1; |
|
796 dllUid1.iUid = 0x101F8477; |
|
797 |
|
798 TEntry entry1; |
|
799 entry1.iName = KExampleDllFileName3; |
|
800 entry1.iModified = TTime(0); |
|
801 entry1.iType = TUidType(KDynamicLibraryUid,KUidInterfaceImplementationCollection,dllUid1); |
|
802 |
|
803 //EComExample10.dll entry |
|
804 TUid dllUid2; |
|
805 dllUid2.iUid = 0x10009E37; |
|
806 |
|
807 TEntry entry2; |
|
808 entry2.iName = KExampleDllFileName10; |
|
809 entry2.iModified = TTime(0); |
|
810 entry2.iType = TUidType(KDynamicLibraryUid,KUidInterfaceImplementationCollection3,dllUid2); |
|
811 |
|
812 TInt err; |
|
813 //Creates Implementation with Uid=0x101F8478 |
|
814 TUid instanceKey; |
|
815 TRAP(err,impl1 = iLoadManager->ImplementationObjectL(ImplUid1,entry1, &iInitParams,initParamsFlag,instanceKey)); |
|
816 ::LeaveIfErrNoMemory(err); |
|
817 TEST2(err,KErrNone); |
|
818 |
|
819 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
820 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 1); |
|
821 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 1); |
|
822 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
823 |
|
824 //Creates 2nd Implementation with Uid=0x10009E38 |
|
825 TUid instanceKey2; |
|
826 TRAP(err,impl2 = iLoadManager->ImplementationObjectL(ImplUid2,entry2, &iInitParams,initParamsFlag,instanceKey2)); |
|
827 // If impl2 fails here due to KErrNoMemory we need to clear the previous impl1 |
|
828 // to avoid memory leak |
|
829 if (err==KErrNoMemory) |
|
830 { |
|
831 iLoadManager->DestroyedThis(instanceKey); |
|
832 delete (CExampleInterface*)impl1; |
|
833 impl1 = NULL; |
|
834 ::LeaveIfErrNoMemory(err); |
|
835 } |
|
836 TEST(err == KErrNone); |
|
837 |
|
838 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
839 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 2); |
|
840 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 2); |
|
841 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
842 |
|
843 //Now destroy the 2nd Implementation |
|
844 iLoadManager->DestroyedThis(instanceKey2); |
|
845 delete (CExampleInterface*)impl2; |
|
846 impl2 = NULL; |
|
847 |
|
848 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
849 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 1); |
|
850 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 1); |
|
851 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) != NULL); |
|
852 |
|
853 //Now destroy the 1st Implementation; |
|
854 iLoadManager->DestroyedThis(instanceKey); |
|
855 delete (CExampleInterface*)impl1; |
|
856 impl1 = NULL; |
|
857 |
|
858 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
859 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 0); |
|
860 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 0); |
|
861 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) != NULL); |
|
862 |
|
863 iLoadManager->ClearGarbage(); |
|
864 |
|
865 //Checks the final state of the garbage policy |
|
866 //Tests for the new API ClearGarbage() |
|
867 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
868 } |
|
869 |
|
870 |
|
871 // Test case 2:Create two implementation from one SAME DLL |
|
872 |
|
873 void CLoadManagerTest::CreateDestroyTestCase2L(TUid aDllUid, |
|
874 TUid aImplUid1, |
|
875 const TDesC& aDllName, |
|
876 TUid aImplUid2, |
|
877 const TUid aIICType) |
|
878 { |
|
879 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
880 iInitParams.integer = 5; |
|
881 TBool initParamsFlag = ETrue; |
|
882 _LIT(KDummyText,"Dummy params"); |
|
883 iInitParams.descriptor = &KDummyText; |
|
884 TAny* impl1 = NULL; |
|
885 TAny* impl2 = NULL; |
|
886 |
|
887 TEntry entry; |
|
888 entry.iName = aDllName; |
|
889 entry.iModified = TTime(0); |
|
890 entry.iType = TUidType(KDynamicLibraryUid,aIICType,aDllUid); |
|
891 |
|
892 TInt err; |
|
893 //Creates Implementation 1 |
|
894 TUid instanceKey; |
|
895 TRAP(err,impl1 = iLoadManager->ImplementationObjectL(aImplUid1,entry, &iInitParams,initParamsFlag,instanceKey)); |
|
896 ::LeaveIfErrNoMemory(err); |
|
897 TEST(err==KErrNone); |
|
898 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
899 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 1); |
|
900 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 1); |
|
901 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
902 |
|
903 TAny* impl4 = NULL; |
|
904 //Recreates another Implementation 1 |
|
905 TUid instanceKey2; |
|
906 TRAP(err,impl4 = iLoadManager->ImplementationObjectL(aImplUid1,entry, &iInitParams,initParamsFlag,instanceKey2)); |
|
907 if (err == KErrNoMemory) |
|
908 { |
|
909 iLoadManager->DestroyedThis(instanceKey); |
|
910 delete (CExampleInterface*)impl1; |
|
911 impl1 = NULL; |
|
912 ::LeaveIfErrNoMemory(err); |
|
913 } |
|
914 TEST2(err,KErrNone); |
|
915 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
916 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 2); |
|
917 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 1); |
|
918 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
919 |
|
920 //Creates Implementation 2 |
|
921 TUid instanceKey3; |
|
922 TRAP(err,impl2 = iLoadManager->ImplementationObjectL(aImplUid2,entry, &iInitParams,initParamsFlag,instanceKey3)); |
|
923 // If impl2 fails here due to KErrNoMemory we need to clear the previous impl1 |
|
924 // to avoid memory leak |
|
925 if (err == KErrNoMemory) |
|
926 { |
|
927 iLoadManager->DestroyedThis(instanceKey); |
|
928 delete (CExampleInterface*)impl1; |
|
929 impl1 = NULL; |
|
930 iLoadManager->DestroyedThis(instanceKey2); |
|
931 delete (CExampleInterface*)impl4; |
|
932 impl4 = NULL; |
|
933 ::LeaveIfErrNoMemory(err); |
|
934 } |
|
935 |
|
936 TEST2(err,KErrNone); |
|
937 |
|
938 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
939 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 3); |
|
940 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 1); |
|
941 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
942 |
|
943 //Creates another Implementation 2 |
|
944 TAny* impl3 = NULL; |
|
945 TUid instanceKey4; |
|
946 TRAP(err,impl3 = iLoadManager->ImplementationObjectL(aImplUid2,entry, &iInitParams,initParamsFlag,instanceKey4)); |
|
947 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
948 if (err == KErrNoMemory) |
|
949 { |
|
950 //cleanup the previously loaded implementation before leaving |
|
951 iLoadManager->DestroyedThis(instanceKey); |
|
952 delete (CExampleInterface*)impl1; |
|
953 impl1 = NULL; |
|
954 iLoadManager->DestroyedThis(instanceKey2); |
|
955 delete (CExampleInterface*)impl4; |
|
956 impl4 = NULL; |
|
957 iLoadManager->DestroyedThis(instanceKey3); |
|
958 delete (CExampleInterface*)impl2; |
|
959 impl2 = NULL; |
|
960 ::LeaveIfErrNoMemory(err); |
|
961 } |
|
962 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 4); |
|
963 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 1); |
|
964 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
965 |
|
966 //Destroy Implementation 1 |
|
967 iLoadManager->DestroyedThis(instanceKey); |
|
968 delete (CExampleInterface*)impl1; |
|
969 impl1 = NULL; |
|
970 iLoadManager->DestroyedThis(instanceKey2); |
|
971 delete (CExampleInterface*)impl4; |
|
972 impl4 = NULL; |
|
973 |
|
974 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
975 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 2); |
|
976 //Note here after destroying Impl1, the DLL is still in used, so no garbage policy |
|
977 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 1); |
|
978 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
979 |
|
980 //Destroy Implementation 2 |
|
981 iLoadManager->DestroyedThis(instanceKey3); |
|
982 delete (CExampleInterface*)impl2; |
|
983 impl2 = NULL; |
|
984 |
|
985 //Destroy 2nd Implementation 2 |
|
986 iLoadManager->DestroyedThis(instanceKey4); |
|
987 delete (CExampleInterface*)impl3; |
|
988 impl3 = NULL; |
|
989 |
|
990 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
991 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 0); |
|
992 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 0); |
|
993 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) != NULL); |
|
994 |
|
995 iLoadManager->ClearGarbage(); |
|
996 |
|
997 //Checks the final state of the garbage policy |
|
998 //Tests for the new API ClearGarbage() |
|
999 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
1000 } |
|
1001 |
|
1002 |
|
1003 /** |
|
1004 Plugins used: |
|
1005 - Z:\\..\\EComExample2.dll contains ImplUid 0x10009DC3 & 0x10009DC4 |
|
1006 |
|
1007 @SYMTestCaseID SYSLIB-ECOM-CT-0702 |
|
1008 @SYMTestCaseDesc Tests for create and delete of CLoadManager |
|
1009 @SYMTestPriority High |
|
1010 @SYMTestActions Create two implementation from the SAME DLL |
|
1011 @SYMTestExpectedResults One UnloadPolicy since both Implementation is based on SAME DLL |
|
1012 Two Instance indexes because of two Different Implementations |
|
1013 @SYMREQ REQ0000 |
|
1014 */ |
|
1015 void CLoadManagerTest::CreateDestroyTestCase2Plugin1L() |
|
1016 { |
|
1017 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-0702 ")); |
|
1018 TUid implUid1={0x10009DC3}; |
|
1019 TUid implUid2={0x10009DC4}; |
|
1020 |
|
1021 TUid dllUid; |
|
1022 dllUid.iUid = 0x10009DB3; |
|
1023 |
|
1024 CreateDestroyTestCase2L(dllUid,implUid1,KExampleDllFileName2,implUid2,KUidInterfaceImplementationCollection); |
|
1025 |
|
1026 } |
|
1027 |
|
1028 /** |
|
1029 @SYMTestCaseID SYSLIB-ECOM-UT-3553 |
|
1030 @SYMTestCaseDesc Tests for create and delete of implementations using PLUGIN3 from the SAME DLL |
|
1031 @SYMTestPriority High |
|
1032 @SYMTestActions Create two implementation from the SAME DLL using new Dll type PLUGIN3. |
|
1033 Test executes by getting the CUnloadPolicy* associated to the testing DLL EComExample10.dll. |
|
1034 DestroyThis will actually either remove the UnloadPolicy from the list or decrease |
|
1035 referencecount(to UnloadPolicy) by one. |
|
1036 @SYMTestExpectedResults Ensure the CLoadManager data structures are as expected after the ImplementationObjectL calls |
|
1037 One UnloadPolicy since both Implementation is based on SAME DLL |
|
1038 Two Instance indexes because of two Different Implementations |
|
1039 @SYMEC EC43 |
|
1040 */ |
|
1041 void CLoadManagerTest::CreateDestroyTestCase2Plugin3L() |
|
1042 { |
|
1043 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3553 ")); |
|
1044 TUid implUid1 = {0x10009E38}; |
|
1045 TUid implUid2 = {0x10009E3A}; |
|
1046 |
|
1047 TUid dllUid; |
|
1048 dllUid.iUid = 0x10009E37; |
|
1049 |
|
1050 CreateDestroyTestCase2L(dllUid,implUid1,KExampleDllFileName10,implUid2,KUidInterfaceImplementationCollection3); |
|
1051 } |
|
1052 |
|
1053 |
|
1054 //Test case 3:Invalid argument testing for Create Implementation |
|
1055 // - Invalid Entry and Implementation uid argument in ImplementationObjectL |
|
1056 |
|
1057 /** |
|
1058 @SYMTestCaseID SYSLIB-ECOM-CT-0703 |
|
1059 @SYMTestCaseDesc Tests for create CLoadManager |
|
1060 @SYMTestPriority High |
|
1061 @SYMTestActions Passing invalid Entry and Implementation uid argument in ImplementationObjectL |
|
1062 @SYMTestExpectedResults The test must not fail. |
|
1063 @SYMREQ REQ0000 |
|
1064 */ |
|
1065 void CLoadManagerTest::CreateDestroyTestCase3L() |
|
1066 { |
|
1067 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0703 ")); |
|
1068 TUid invalidUid={0x10007777}; |
|
1069 |
|
1070 //Try supplying invalid implementaion Uid and invalid entry argument |
|
1071 TUid dllUid; |
|
1072 dllUid.iUid = 0; |
|
1073 |
|
1074 TEntry invalidentry; |
|
1075 invalidentry.iName=_L("Z:\\system\\LIBS\\PLUGINS\\EComExample9.dll"); |
|
1076 invalidentry.iModified=TTime(0); |
|
1077 invalidentry.iType=TUidType(KDynamicLibraryUid,KUidInterfaceImplementationCollection,dllUid); |
|
1078 |
|
1079 TBool initParamsFlag = ETrue; |
|
1080 |
|
1081 TUid instanceKey; |
|
1082 TRAPD(err,iLoadManager->ImplementationObjectL(invalidUid,invalidentry, NULL,initParamsFlag,instanceKey)); |
|
1083 ::LeaveIfErrNoMemory(err); |
|
1084 //It will return KErrNotFound as the DLL is invalid |
|
1085 TEST2(err,KErrNotFound); |
|
1086 |
|
1087 //Checking the state of the arrays inside CLoadManager and the garbage policy |
|
1088 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager)==0); |
|
1089 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager)==0); |
|
1090 TEST(iStateAccessor.GarbagePolicy(*iLoadManager)==NULL); |
|
1091 } |
|
1092 |
|
1093 /** |
|
1094 @SYMTestCaseID SYSLIB-ECOM-UT-3554 |
|
1095 @SYMTestCaseDesc Invalid argument testing for Create Implementation using new DLL type PLUGIN3 |
|
1096 @SYMTestPriority High |
|
1097 @SYMTestActions Passing invalid Entry and Implementation uid argument in ImplementationObjectL |
|
1098 @SYMTestExpectedResults KErrNotFound will be returned as the DLL is invalid |
|
1099 @SYMEC EC43 |
|
1100 */ |
|
1101 void CLoadManagerTest::CreateDestroyTestCase3Plugin3L() |
|
1102 { |
|
1103 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3554 ")); |
|
1104 // this implementation(0x10009E48) is implemented in EComExample14Upgraded.dll, not in EComExample10.dll |
|
1105 TUid implementationUid = {0x10009E48}; |
|
1106 |
|
1107 //Try supplying invalid implementaion Uid and invalid entry argument |
|
1108 TUid dllUid; |
|
1109 dllUid.iUid = 0; |
|
1110 |
|
1111 // Invalid entry for EComExample14Upgraded.dll, because it is not under Z:\\system\\LIBS\\PLUGINS |
|
1112 TEntry invalidentry; |
|
1113 invalidentry.iName = _L("Z:\\system\\LIBS\\PLUGINS\\EComExample14Upgraded.dll"); |
|
1114 invalidentry.iModified = TTime(0); |
|
1115 invalidentry.iType = TUidType(KDynamicLibraryUid,KUidInterfaceImplementationCollection3,dllUid); |
|
1116 |
|
1117 TUid dllUid1; |
|
1118 dllUid1.iUid = 0x10009E37; |
|
1119 // Valid entry for EComExample10.dll |
|
1120 TEntry entry; |
|
1121 entry.iName = KExampleDllFileName10; |
|
1122 entry.iModified = TTime(0); |
|
1123 entry.iType = TUidType(KDynamicLibraryUid,KUidInterfaceImplementationCollection3,dllUid1); |
|
1124 TBool initParamsFlag = ETrue; |
|
1125 |
|
1126 // Test for valid implementation Uid with invalid entry. |
|
1127 TUid instanceKey; |
|
1128 TRAPD(err,iLoadManager->ImplementationObjectL(implementationUid,invalidentry, NULL,initParamsFlag,instanceKey)); |
|
1129 ::LeaveIfErrNoMemory(err); |
|
1130 //Returns KErrNotFound as the DLL is invalid |
|
1131 TEST2(err,KErrNotFound); |
|
1132 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
1133 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager)==0); |
|
1134 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager)==0); |
|
1135 TEST(iStateAccessor.GarbagePolicy(*iLoadManager)==NULL); |
|
1136 |
|
1137 // Tests for invalid implementation Uid with valid entry. |
|
1138 TRAP(err,iLoadManager->ImplementationObjectL(implementationUid,entry, NULL,initParamsFlag,instanceKey)); |
|
1139 ::LeaveIfErrNoMemory(err); |
|
1140 //Returns KErrNotFound as the implementation Uid is not within the DLL |
|
1141 TEST2(err,KErrNotFound); |
|
1142 |
|
1143 //Checks the state of the arrays inside CLoadManager and the garbage policy |
|
1144 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 0); |
|
1145 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 0); |
|
1146 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) != NULL); |
|
1147 } |
|
1148 |
|
1149 //Test case 4:Create two instance of the same implementation Uid from one single DLL |
|
1150 |
|
1151 void CLoadManagerTest::CreateDestroyTestCase4L(TUid aDllUid, |
|
1152 TUid aImplUid, |
|
1153 const TDesC& aDllName, |
|
1154 const TUid aIICType) |
|
1155 { |
|
1156 TInt err; |
|
1157 TEntry entry; |
|
1158 entry.iName=aDllName; |
|
1159 entry.iModified=TTime(0); |
|
1160 entry.iType=TUidType(KDynamicLibraryUid,aIICType,aDllUid); |
|
1161 |
|
1162 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
1163 iInitParams.integer = 5; |
|
1164 TBool initParamsFlag = ETrue; |
|
1165 _LIT(KDummyText,"Dummy params"); |
|
1166 iInitParams.descriptor = &KDummyText; |
|
1167 TAny* impl1=NULL; |
|
1168 TAny* impl2=NULL; |
|
1169 |
|
1170 //Create 1st instance of implementation |
|
1171 TUid instanceKey; |
|
1172 TRAP(err,impl1=iLoadManager->ImplementationObjectL(aImplUid,entry, &iInitParams,initParamsFlag,instanceKey)); |
|
1173 ::LeaveIfErrNoMemory(err); |
|
1174 TEST2(err,KErrNone); |
|
1175 |
|
1176 //Checking the state of the arrays inside CLoadManager and the garbage policy |
|
1177 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager)==1); |
|
1178 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager)==1); |
|
1179 TEST(iStateAccessor.GarbagePolicy(*iLoadManager)==NULL); |
|
1180 |
|
1181 //Create 2nd instance of the same implementation |
|
1182 TUid instanceKey2; |
|
1183 TRAP(err,impl2=iLoadManager->ImplementationObjectL(aImplUid,entry, &iInitParams,initParamsFlag,instanceKey2)); |
|
1184 // If impl2 fails here due to KErrNoMemory we need to clear the previous impl1 |
|
1185 // to avoid memory leak |
|
1186 if (err==KErrNoMemory) |
|
1187 { |
|
1188 iLoadManager->DestroyedThis(instanceKey); |
|
1189 delete (CExampleInterface*)impl1; |
|
1190 impl1=NULL; |
|
1191 ::LeaveIfErrNoMemory(err); |
|
1192 } |
|
1193 |
|
1194 TEST(err==KErrNone); |
|
1195 |
|
1196 //Checking the state of the arrays inside CLoadManager and the garbage policy |
|
1197 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager)==2); |
|
1198 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager)==1); |
|
1199 TEST(iStateAccessor.GarbagePolicy(*iLoadManager)==NULL); |
|
1200 |
|
1201 //Destroyed the 2nd instance of implementation |
|
1202 iLoadManager->DestroyedThis(instanceKey2); |
|
1203 delete (CExampleInterface*)impl2; |
|
1204 impl2=NULL; |
|
1205 |
|
1206 //Checking the state of the arrays inside CLoadManager and the garbage policy |
|
1207 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager)==1); |
|
1208 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager)==1); |
|
1209 TEST(iStateAccessor.GarbagePolicy(*iLoadManager)==NULL); |
|
1210 |
|
1211 //Destroyed the 1st instance of implementation |
|
1212 iLoadManager->DestroyedThis(instanceKey); |
|
1213 delete (CExampleInterface*)impl1; |
|
1214 impl1=NULL; |
|
1215 |
|
1216 //Checking the state of the arrays inside CLoadManager and the garbage policy |
|
1217 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager)==0); |
|
1218 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager)==0); |
|
1219 TEST(iStateAccessor.GarbagePolicy(*iLoadManager)!=NULL); |
|
1220 |
|
1221 iLoadManager->ClearGarbage(); |
|
1222 //Checking the final state of the garbage policy |
|
1223 TEST(iStateAccessor.GarbagePolicy(*iLoadManager)==NULL); |
|
1224 } |
|
1225 |
|
1226 |
|
1227 /** |
|
1228 Plugins used: |
|
1229 - Z:\\..\\EComExample2.dll contains ImplUid 0x10009DC3 & 0x10009DC4 |
|
1230 |
|
1231 @SYMTestCaseID SYSLIB-ECOM-CT-0704 |
|
1232 @SYMTestCaseDesc Tests for create and delete of CLoadManager |
|
1233 @SYMTestPriority High |
|
1234 @SYMTestActions Create two instance of the same implementation Uid from one single DLL |
|
1235 @SYMTestExpectedResults CLoadManager only maintains a single UnloadPolicy and one policy |
|
1236 mapping index |
|
1237 @SYMREQ REQ0000 |
|
1238 */ |
|
1239 void CLoadManagerTest::CreateDestroyTestCase4Plugin1L() |
|
1240 { |
|
1241 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0704 ")); |
|
1242 TUid implUid={0x10009DC3}; |
|
1243 |
|
1244 TUid dllUid; |
|
1245 dllUid.iUid = 0x10009DB3; |
|
1246 |
|
1247 CreateDestroyTestCase4L(dllUid,implUid,KExampleDllFileName2,KUidInterfaceImplementationCollection); |
|
1248 } |
|
1249 |
|
1250 /** |
|
1251 @SYMTestCaseID SYSLIB-ECOM-UT-3555 |
|
1252 @SYMTestCaseDesc Create two instance of the same implementation Uid from one single DLL using PLUGIN3 |
|
1253 Plugins used: |
|
1254 - Z:\\..\\EComExample10.dll contains ImplUid 0x10009E38 & 0x10009E3A |
|
1255 @SYMTestPriority High |
|
1256 @SYMTestActions Create two instance of the same implementation Uid from one single DLL |
|
1257 @SYMTestExpectedResults Ensure the CLoadManager data structures are as expected after the ImplementationObjectL calls |
|
1258 CLoadManager only maintains a single UnloadPolicy and one instance |
|
1259 @SYMEC EC43 |
|
1260 */ |
|
1261 void CLoadManagerTest::CreateDestroyTestCase4Plugin3L() |
|
1262 { |
|
1263 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3555 ")); |
|
1264 TUid implUid={0x10009E38}; |
|
1265 |
|
1266 TUid dllUid; |
|
1267 dllUid.iUid = 0x10009E37; |
|
1268 |
|
1269 CreateDestroyTestCase4L(dllUid,implUid,KExampleDllFileName10,KUidInterfaceImplementationCollection3); |
|
1270 } |
|
1271 |
|
1272 |
|
1273 // Test case 5: DEF101930: Incorrect policy object returned in |
|
1274 |
|
1275 |
|
1276 void CLoadManagerTest::CreateDestroyTestCase5L(TUid aDllUid1, |
|
1277 TUid aImplUid1, |
|
1278 const TDesC& aDllName1, |
|
1279 TUid aDllUid2, |
|
1280 TUid aImplUid2, |
|
1281 const TDesC& aDllName2, |
|
1282 TUid aImplUid3, |
|
1283 const TUid aIICType) |
|
1284 { |
|
1285 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
1286 iInitParams.integer = 5; |
|
1287 TBool initParamsFlag = ETrue; |
|
1288 _LIT(KDummyText,"Dummy params"); |
|
1289 iInitParams.descriptor = &KDummyText; |
|
1290 TAny* impl1 = NULL; |
|
1291 TAny* impl2 = NULL; |
|
1292 TAny* impl3 = NULL; |
|
1293 |
|
1294 TEntry entryExample1; |
|
1295 entryExample1.iName = aDllName1; |
|
1296 entryExample1.iModified = TTime(0); |
|
1297 entryExample1.iType = TUidType(KDynamicLibraryUid,aIICType,aDllUid1); |
|
1298 |
|
1299 TEntry entryExample2; |
|
1300 entryExample2.iName = aDllName2; |
|
1301 entryExample2.iModified = TTime(0); |
|
1302 entryExample2.iType = TUidType(KDynamicLibraryUid,aIICType,aDllUid2); |
|
1303 |
|
1304 TInt err; |
|
1305 TUid instanceKey2; |
|
1306 |
|
1307 //Create Implementation 2 |
|
1308 TRAP(err,impl2 = iLoadManager->ImplementationObjectL(aImplUid2,entryExample1, &iInitParams,initParamsFlag,instanceKey2)); |
|
1309 ::LeaveIfErrNoMemory(err); |
|
1310 TEST(err == KErrNone); |
|
1311 //Checking the state of the arrays inside CLoadManager and the garbage policy |
|
1312 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 1); |
|
1313 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 1); |
|
1314 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
1315 |
|
1316 TUid instanceKey3; |
|
1317 //Create Implementation 3 |
|
1318 TRAP(err,impl3 = iLoadManager->ImplementationObjectL(aImplUid3,entryExample2, &iInitParams,initParamsFlag,instanceKey3)); |
|
1319 // If impl3 fails here due to KErrNoMemory we need to clear the previous impl2 |
|
1320 // to avoid memory leak |
|
1321 if (err == KErrNoMemory) |
|
1322 { |
|
1323 iLoadManager->DestroyedThis(instanceKey2); |
|
1324 delete (CExampleInterface*)impl2; |
|
1325 impl2 = NULL; |
|
1326 ::LeaveIfErrNoMemory(err); |
|
1327 } |
|
1328 TEST2(err,KErrNone); |
|
1329 |
|
1330 //Checking the state of the arrays inside CLoadManager and the garbage policy |
|
1331 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 2); |
|
1332 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 2); |
|
1333 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
1334 |
|
1335 //Create Implementation 1 |
|
1336 TUid instanceKey1; |
|
1337 TRAP(err,impl1 = iLoadManager->ImplementationObjectL(aImplUid1,entryExample1, &iInitParams,initParamsFlag,instanceKey1)); |
|
1338 // If impl1 fails here due to KErrNoMemory we need to clear the previous impl2 and impl3 |
|
1339 // to avoid memory leak |
|
1340 if (err == KErrNoMemory) |
|
1341 { |
|
1342 iLoadManager->DestroyedThis(instanceKey2); |
|
1343 delete (CExampleInterface*)impl2; |
|
1344 impl2=NULL; |
|
1345 iLoadManager->DestroyedThis(instanceKey3); |
|
1346 delete (CExampleInterface*)impl3; |
|
1347 impl3=NULL; |
|
1348 ::LeaveIfErrNoMemory(err); |
|
1349 } |
|
1350 TEST2(err,KErrNone); |
|
1351 |
|
1352 //Checking the state of the arrays inside CLoadManager and the garbage policy |
|
1353 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 3); |
|
1354 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 2); |
|
1355 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
1356 |
|
1357 //Destroy Implementation 1 |
|
1358 iLoadManager->DestroyedThis(instanceKey1); |
|
1359 delete (CExampleInterface*)impl1; |
|
1360 impl1 = NULL; |
|
1361 |
|
1362 //Destroy Implementation 2 |
|
1363 iLoadManager->DestroyedThis(instanceKey2); |
|
1364 delete (CExampleInterface*)impl2; |
|
1365 impl2 = NULL; |
|
1366 |
|
1367 //Destroy Implementation 3 |
|
1368 iLoadManager->DestroyedThis(instanceKey3); |
|
1369 delete (CExampleInterface*)impl3; |
|
1370 impl3 = NULL; |
|
1371 |
|
1372 //Checking the state of the arrays inside CLoadManager and the garbage policy |
|
1373 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 0); |
|
1374 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 0); |
|
1375 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) != NULL); |
|
1376 |
|
1377 iLoadManager->ClearGarbage(); |
|
1378 |
|
1379 //Checking the final state of the garbage policy |
|
1380 //Test for the new API ClearGarbage() |
|
1381 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
1382 |
|
1383 } |
|
1384 |
|
1385 /** |
|
1386 Plugins used: |
|
1387 - Z:\\..\\EComLoadMgrExample1.dll contains ImplUid 0x10282332 & 0x10282334 |
|
1388 - Z:\\..\\EComLoadMgrExample2.dll contains ImplUid 0x10282333 |
|
1389 |
|
1390 @SYMTestCaseID SYSLIB-ECOM-UT-3372 |
|
1391 @SYMTestCaseDesc This testcase checks for the case where 2 implementations |
|
1392 are created each on separate DLL's then an additional |
|
1393 implementation is created from one of the already loaded DLL's. |
|
1394 The impl uid of the newly created impl is lower then the 2 |
|
1395 existing impl uids. The impl uids from the same DLL are such |
|
1396 that 1 is higher then the uid of the other impl and 1 is lower than |
|
1397 the other impl. |
|
1398 @SYMTestPriority High |
|
1399 @SYMTestActions Load impls 0x10282333 and 0x10282334 first and then load impl |
|
1400 0x10282332. |
|
1401 @SYMTestExpectedResults Leave with KErrNotFound must not occur. |
|
1402 Policy and unload policy counts must be updated |
|
1403 as described in the test. |
|
1404 @SYMDEF DEF101930 |
|
1405 */ |
|
1406 void CLoadManagerTest::CreateDestroyTestCase5Plugin1L() |
|
1407 { |
|
1408 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3372 ")); |
|
1409 TUid implUid1={0x10282332}; |
|
1410 TUid implUid2={0x10282334}; |
|
1411 TUid implUid3={0x10282333}; |
|
1412 |
|
1413 TUid dllUidExample1; |
|
1414 dllUidExample1.iUid = 0x10282330; |
|
1415 |
|
1416 TUid dllUidExample2; |
|
1417 dllUidExample2.iUid = 0x10282335; |
|
1418 |
|
1419 CreateDestroyTestCase5L(dllUidExample1, |
|
1420 implUid1, |
|
1421 KLoadMgrExample1DllName, |
|
1422 dllUidExample2, |
|
1423 implUid2, |
|
1424 KLoadMgrExample2DllName, |
|
1425 implUid3, |
|
1426 KUidInterfaceImplementationCollection); |
|
1427 } |
|
1428 |
|
1429 /** |
|
1430 @SYMTestCaseID SYSLIB-ECOM-UT-3556 |
|
1431 @SYMTestCaseDesc DEF101930: Incorrect policy object returned in |
|
1432 This testcase checks for the case where 2 implementations |
|
1433 are created each on separate DLL's then an additional |
|
1434 implementation is created from one of the already loaded DLL's. |
|
1435 The impl uid of the newly created impl is lower then the 2 |
|
1436 existing impl uids. The impl uids from the same DLL are such |
|
1437 that 1 is higher then the uid of the other impl and 1 is lower than |
|
1438 the other impl. DEF101930: Incorrect policy object returned in |
|
1439 |
|
1440 Plugins used: |
|
1441 - Z:\\..\\EComExample10.dll contains ImplUid 0x10009E38 & 0x10009E3A |
|
1442 - Z:\\..\\EComExample12.dll contains ImplUid 0x10009E39 |
|
1443 @SYMTestPriority High |
|
1444 @SYMTestActions Load impls 0x10009E3A and 0x10009E39 first and then load impl 0x10009E38. |
|
1445 @SYMTestExpectedResults Leave with KErrNotFound must not occur. |
|
1446 Policy and unload policy counts must be updated |
|
1447 as described in the test. |
|
1448 @SYMEC EC43 (tested for PLUGIN3 too now, copied from UT-3372) |
|
1449 */ |
|
1450 void CLoadManagerTest::CreateDestroyTestCase5Plugin3L() |
|
1451 { |
|
1452 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3556 ")); |
|
1453 TUid implUid1={0x10009E38}; |
|
1454 TUid implUid2={0x10009E3A}; |
|
1455 TUid implUid3={0x10009E39}; |
|
1456 |
|
1457 TUid dllUidExample1; |
|
1458 dllUidExample1.iUid = 0x10009E37; |
|
1459 |
|
1460 TUid dllUidExample2; |
|
1461 dllUidExample2.iUid = 0x10009E3E; |
|
1462 |
|
1463 CreateDestroyTestCase5L(dllUidExample1, |
|
1464 implUid1, |
|
1465 KExampleDllFileName10, |
|
1466 dllUidExample2, |
|
1467 implUid2, |
|
1468 KExampleDllFileName12, |
|
1469 implUid3, |
|
1470 KUidInterfaceImplementationCollection3); |
|
1471 } |
|
1472 |
|
1473 |
|
1474 /** |
|
1475 @SYMTestCaseID SYSLIB-ECOM-CT-0705 |
|
1476 @SYMTestCaseDesc Tests for production class CLoadManager |
|
1477 @SYMTestPriority High |
|
1478 @SYMTestActions Check for null condition while creating a new CLoadManagerTest object. |
|
1479 @SYMTestExpectedResults The test must not fail. |
|
1480 @SYMREQ REQ0000 |
|
1481 */ |
|
1482 LOCAL_C void CreateDeleteTestL() |
|
1483 { |
|
1484 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0705 CreateDeleteTestL ")); |
|
1485 |
|
1486 // |
|
1487 // Tests the Creating and deletion of CLoadManager |
|
1488 // ------------------------------------------------------------------ |
|
1489 // |
|
1490 // Set up for heap leak checking |
|
1491 __UHEAP_MARK; |
|
1492 |
|
1493 TInt startProcessHandleCount = 0; |
|
1494 TInt startThreadHandleCount = 0; |
|
1495 TInt endProcessHandleCount = 0; |
|
1496 TInt endThreadHandleCount = 0; |
|
1497 |
|
1498 RThread rThread; |
|
1499 rThread.HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
1500 |
|
1501 //CREATE DELETE TEST START// |
|
1502 |
|
1503 CLoadManagerTest* loadManagerTest = CLoadManagerTest::NewL(); |
|
1504 |
|
1505 TEST(loadManagerTest != NULL); |
|
1506 |
|
1507 delete loadManagerTest; |
|
1508 |
|
1509 //CREATE DELETE TEST END// |
|
1510 |
|
1511 rThread.HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
1512 TEST(startThreadHandleCount == endThreadHandleCount); |
|
1513 |
|
1514 __UHEAP_MARKEND; |
|
1515 } |
|
1516 |
|
1517 /** |
|
1518 @SYMTestCaseID SYSLIB-ECOM-CT-0706 |
|
1519 @SYMTestCaseDesc OOM test while creating and deleting CLoadManager |
|
1520 @SYMTestPriority High |
|
1521 @SYMTestActions Create and delete CLoadManager object and test that no handles have leaked |
|
1522 @SYMTestExpectedResults The test must not fail. |
|
1523 @SYMREQ REQ0000 |
|
1524 */ |
|
1525 LOCAL_C void OOMCreateDeleteTest() |
|
1526 { |
|
1527 // |
|
1528 // Out of memory test |
|
1529 // ------------------------------------------------------------------ |
|
1530 // |
|
1531 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0706 OOMCreateDeleteTest ")); |
|
1532 TInt err; |
|
1533 TInt failAt = 1; |
|
1534 __UNUSED_VAR(failAt); |
|
1535 |
|
1536 CLoadManagerTest* loadManagerTest = NULL; |
|
1537 |
|
1538 do |
|
1539 { |
|
1540 __UHEAP_MARK; |
|
1541 // find out the number of open handles |
|
1542 TInt startProcessHandleCount; |
|
1543 TInt startThreadHandleCount; |
|
1544 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
1545 |
|
1546 // Setting Heap failure for OOM test |
|
1547 __UHEAP_SETFAIL(RHeap::EDeterministic, failAt++); |
|
1548 |
|
1549 TRAP(err, loadManagerTest = CLoadManagerTest::NewL()); |
|
1550 |
|
1551 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
1552 |
|
1553 delete loadManagerTest; |
|
1554 loadManagerTest = NULL; |
|
1555 |
|
1556 // check that no handles have leaked |
|
1557 TInt endProcessHandleCount; |
|
1558 TInt endThreadHandleCount; |
|
1559 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
1560 |
|
1561 TEST(startProcessHandleCount == endProcessHandleCount); |
|
1562 TEST(startThreadHandleCount == endThreadHandleCount); |
|
1563 |
|
1564 __UHEAP_MARKEND; |
|
1565 } |
|
1566 while (err == KErrNoMemory); |
|
1567 |
|
1568 TheTest.Printf(_L("- Succeeded at heap failure rate of %i\n"), failAt); |
|
1569 TEST(err == KErrNone); |
|
1570 } |
|
1571 |
|
1572 /** |
|
1573 @SYMTestCaseID SYSLIB-ECOM-UT-3557 |
|
1574 @SYMTestCaseDesc This testcase tests fetching extended interfaces for ImplUid 0x10009E38. |
|
1575 One interface will be the part of the main implementation object, the |
|
1576 second interface will be a separate interface requiring release. Also tests |
|
1577 that the extended interfaces are automatically destroyed. |
|
1578 |
|
1579 Plugins used: |
|
1580 - Z:\\..\\EComExample10.dll contains ImplUid 0x10009E38 with extended interface |
|
1581 0x10009E44, 0x10009E45 and 0x10009E46 |
|
1582 @SYMTestPriority High |
|
1583 @SYMTestActions This testcase will test one implementation with two extended interfaces. |
|
1584 Create implementation, then fetch extended interface 0x10009E44. Secondly, |
|
1585 fetch 0x10009E45 interface. This will be a separate interface requiring release. |
|
1586 Destroy the interfaces. |
|
1587 Attempt fetch of interface again. Expect Leave with KErrNotFound as implementation |
|
1588 no longer exists. |
|
1589 @SYMTestExpectedResults Extended instance count will be zero for 0x10009E44 extended interface, |
|
1590 0x10009E45 will have an extended instance count of one. No memory leaks |
|
1591 after implementation, including extended interfaces are automatically |
|
1592 destroyed. |
|
1593 @SYMEC EC43 |
|
1594 @SYMDEF DEF111553 |
|
1595 */ |
|
1596 void CLoadManagerTest::ExtendedMethodTest1Plugin3L() |
|
1597 { |
|
1598 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3557 ")); |
|
1599 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
1600 iInitParams.integer = 5; |
|
1601 TBool initParamsFlag = ETrue; |
|
1602 _LIT(KDummyText,"Dummy params"); |
|
1603 iInitParams.descriptor = &KDummyText; |
|
1604 TUid dllUid; |
|
1605 dllUid.iUid = 0x10009E37; |
|
1606 |
|
1607 TEntry entry; |
|
1608 entry.iName = KExampleDllFileName10; |
|
1609 entry.iModified = TTime(0); |
|
1610 entry.iType = TUidType(KDynamicLibraryUid,KUidInterfaceImplementationCollection3,dllUid); |
|
1611 |
|
1612 iImplementationUid.iUid = 0x10009E38; |
|
1613 |
|
1614 CExampleInterface* implementationPtr = 0; |
|
1615 TUid instanceKey; |
|
1616 TRAPD(err, implementationPtr = reinterpret_cast<CExampleInterface*>(iLoadManager->ImplementationObjectL(iImplementationUid, entry,&iInitParams, initParamsFlag,instanceKey))); |
|
1617 |
|
1618 ::LeaveIfErrNoMemory(err); |
|
1619 TEST2(err,KErrNone); |
|
1620 TEST(implementationPtr != 0); |
|
1621 |
|
1622 CleanupStack::PushL(implementationPtr); |
|
1623 |
|
1624 //Checks the state of the arrays inside CLoadManager and garbage policy |
|
1625 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 1); |
|
1626 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 1); |
|
1627 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
1628 |
|
1629 //Checks the instance index and UnloadPolicy info |
|
1630 TEST(iStateAccessor.InstanceIndex(0,*iLoadManager)->ImplementationUid() == iImplementationUid); |
|
1631 TEST(iStateAccessor.UnloadPolicy(0,*iLoadManager)->DllEntryInformation().GetName().CompareF(KExampleDllFileName10) == 0); |
|
1632 |
|
1633 // Call extended interface here. |
|
1634 const TUid KExample10InterfaceUid1 = {0x10009E44}; // Part of main interface |
|
1635 const TUid KExample10InterfaceUid2 = {0x10009E45}; // Separate interface |
|
1636 |
|
1637 MExampleInterfaceExtended* ext1 = static_cast<MExampleInterfaceExtended*>(iLoadManager->GetExtendedInterfaceL(instanceKey, KExample10InterfaceUid1 )); |
|
1638 // Extended interface part of main interface, so no extended object info is needed to be created. |
|
1639 TEST2(iStateAccessor.ExtendedInstanceCount(0,*iLoadManager),0); |
|
1640 ext1->DoMethodExtended(); |
|
1641 |
|
1642 MExampleInterfaceExtended2* ext2 = static_cast<MExampleInterfaceExtended2*>(iLoadManager->GetExtendedInterfaceL(instanceKey, KExample10InterfaceUid2 )); |
|
1643 // Separate extended interface, so there will be an extended object info created to track |
|
1644 // this extended interface so it can be deleted later when the extended interface is no |
|
1645 // longer needed. |
|
1646 TEST(iStateAccessor.ExtendedInstanceCount(0,*iLoadManager)==1); |
|
1647 ext2->DoMethodExtended2(); |
|
1648 |
|
1649 CleanupStack::PopAndDestroy(implementationPtr); |
|
1650 implementationPtr = 0; |
|
1651 iLoadManager->DestroyedThis(instanceKey); |
|
1652 iLoadManager->ClearGarbage(); |
|
1653 //Checks the state of the arrays inside CLoadManager and garbage policy |
|
1654 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 0); |
|
1655 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 0); |
|
1656 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
1657 |
|
1658 // call again now that implementation has been removed. Expecting a Leave |
|
1659 TRAP(err, iLoadManager->GetExtendedInterfaceL(instanceKey, KExample10InterfaceUid2 )); |
|
1660 TEST2(err, KErrNotFound); |
|
1661 } |
|
1662 |
|
1663 /** |
|
1664 @SYMTestCaseID SYSLIB-ECOM-UT-3558 |
|
1665 @SYMTestCaseDesc This testcase tests fetching extended interfaces for ImplUid 0x10009E38. |
|
1666 One interface will be the part of the main implementation object, the |
|
1667 second interface will be a separate interface requiring release. Tests |
|
1668 that manual release successful for interface requiring release. Tests |
|
1669 no memory leaks, and no double release of manually released interface. |
|
1670 |
|
1671 Plugins used: |
|
1672 - Z:\\..\\EComExample10.dll contains ImplUid 0x10009E38 with extended interface |
|
1673 0x10009E44, 0x10009E45 and 0x10009E46 |
|
1674 @SYMTestPriority High |
|
1675 @SYMTestActions This testcase will test one implementation with two extended interfaces. |
|
1676 Create implementation, then fetch extended interface 0x10009E44. Secondly, |
|
1677 fetch 0x10009E45 interface. This will be a separate interface requiring release. |
|
1678 Manually release extended interface. Destroy the interfaces. |
|
1679 Attempt fetch of interface again. Expect Leave with KErrNotFound as implementation |
|
1680 no longer exists. |
|
1681 @SYMTestExpectedResults Extended instance count will be zero for 0x10009E44 extended interface, |
|
1682 0x10009E45 will have an extended instance count of one. After manual |
|
1683 release, the extended interface count will be zero. No memory leaks after |
|
1684 implementation, including extended interfaces are automatically destroyed. |
|
1685 No double release of extended interface already manually released. |
|
1686 @SYMEC EC43 |
|
1687 @SYMDEF DEF111553 |
|
1688 */ |
|
1689 void CLoadManagerTest::ExtendedMethodTest2Plugin3L() |
|
1690 { |
|
1691 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3558 ")); |
|
1692 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
1693 iInitParams.integer = 5; |
|
1694 TBool initParamsFlag = ETrue; |
|
1695 _LIT(KDummyText,"Dummy params"); |
|
1696 iInitParams.descriptor = &KDummyText; |
|
1697 TUid dllUid; |
|
1698 dllUid.iUid = 0x10009E37; |
|
1699 |
|
1700 TEntry entry; |
|
1701 entry.iName = KExampleDllFileName10; |
|
1702 entry.iModified = TTime(0); |
|
1703 entry.iType = TUidType(KDynamicLibraryUid,KUidInterfaceImplementationCollection3,dllUid); |
|
1704 |
|
1705 iImplementationUid.iUid = 0x10009E38; |
|
1706 |
|
1707 CExampleInterface* implementationPtr = 0; |
|
1708 TUid instanceKey; |
|
1709 TRAPD(err, implementationPtr = reinterpret_cast<CExampleInterface*>(iLoadManager->ImplementationObjectL(iImplementationUid, entry,&iInitParams, initParamsFlag,instanceKey))); |
|
1710 |
|
1711 ::LeaveIfErrNoMemory(err); |
|
1712 TEST2(err,KErrNone); |
|
1713 TEST(implementationPtr != 0); |
|
1714 |
|
1715 CleanupStack::PushL(implementationPtr); |
|
1716 |
|
1717 //Checks the state of the arrays inside CLoadManager and garbage policy |
|
1718 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 1); |
|
1719 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 1); |
|
1720 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
1721 |
|
1722 //Checks the instance index and UnloadPolicy info |
|
1723 TEST(iStateAccessor.InstanceIndex(0,*iLoadManager)->ImplementationUid() == iImplementationUid); |
|
1724 TEST(iStateAccessor.UnloadPolicy(0,*iLoadManager)->DllEntryInformation().GetName().CompareF(KExampleDllFileName10) == 0); |
|
1725 |
|
1726 // Call extended interface here. |
|
1727 const TUid KExample10InterfaceUid1 = {0x10009E44}; |
|
1728 const TUid KExample10InterfaceUid2 = {0x10009E45}; // separate interface object |
|
1729 |
|
1730 MExampleInterfaceExtended* ext1 = static_cast<MExampleInterfaceExtended*>(iLoadManager->GetExtendedInterfaceL(instanceKey, KExample10InterfaceUid1 )); |
|
1731 TEST(iStateAccessor.ExtendedInstanceCount(0,*iLoadManager) == 0); // Does not need to be released, so will not be added to extended object array |
|
1732 ext1->DoMethodExtended(); |
|
1733 |
|
1734 MExampleInterfaceExtended2* ext2 = static_cast<MExampleInterfaceExtended2*>(iLoadManager->GetExtendedInterfaceL(instanceKey, KExample10InterfaceUid2 )); |
|
1735 TEST(iStateAccessor.ExtendedInstanceCount(0,*iLoadManager) == 1); // Needs to be released |
|
1736 ext2->DoMethodExtended2(); |
|
1737 |
|
1738 iLoadManager->ManuallyReleaseExtendedInterfaceL(instanceKey, KExample10InterfaceUid2); |
|
1739 TEST(iStateAccessor.ExtendedInstanceCount(0,*iLoadManager) == 0); |
|
1740 |
|
1741 CleanupStack::PopAndDestroy(implementationPtr); |
|
1742 implementationPtr = 0; |
|
1743 iLoadManager->DestroyedThis(instanceKey); |
|
1744 iLoadManager->ClearGarbage(); |
|
1745 //Checks the state of the arrays inside CLoadManager and garbage policy |
|
1746 TEST(iStateAccessor.InstanceIndexCount(*iLoadManager) == 0); |
|
1747 TEST(iStateAccessor.UnloadPolicyCount(*iLoadManager) == 0); |
|
1748 TEST(iStateAccessor.GarbagePolicy(*iLoadManager) == NULL); |
|
1749 |
|
1750 // call again now that implementation has been removed. Expecting a Leave |
|
1751 TRAP(err, iLoadManager->GetExtendedInterfaceL(instanceKey, KExample10InterfaceUid2 )); |
|
1752 TEST2(err, KErrNotFound); |
|
1753 } |
|
1754 |
|
1755 /** |
|
1756 @SYMTestCaseID SYSLIB-ECOM-UT-3711 |
|
1757 @SYMTestCaseDesc This testcase tests ManuallyReleaseExtendedInterfaces function for releasing |
|
1758 extended interface which require release and releasing extended interface |
|
1759 which doesn't require release. Also tests for releasing same extended interface twice |
|
1760 |
|
1761 Plugins used: |
|
1762 - Z:\\..\\EComExample10.dll contains ImplUid 0x10009E38 with extended interface |
|
1763 0x10009E44, 0x10009E45 and 0x10009E46 |
|
1764 @SYMTestPriority High |
|
1765 @SYMTestActions This testcase will do the tests as below: |
|
1766 1. create implementation 0x10009E38. |
|
1767 2. Get extended interface 0x10009E44,0x10009E45 and 0x10009E46. |
|
1768 3. Manually release extended interface 0x10009E44 which does not require release. |
|
1769 4. Manually release extended interface 0x10009E45 which require manually release. |
|
1770 5. Again manually release extended interface 0x10009E45 which require manually release. |
|
1771 6. Manually release extended interface 0x10009E46 which require manually release. |
|
1772 7. Destroy the interfaces |
|
1773 8. Attempt fetch manual release again. Expect Leave with KErrNotFound as implementation |
|
1774 no longer exists. |
|
1775 @SYMTestExpectedResults Extended instance count is set correctly. |
|
1776 @SYMDEF DEF111196 |
|
1777 @SYMDEF DEF111553 |
|
1778 */ |
|
1779 void CLoadManagerTest::ManuallyReleaseExtendedInterfaceTestL() |
|
1780 { |
|
1781 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-UT-3711 ")); |
|
1782 CExampleInterface::TExampleInterfaceInitParams iInitParams; |
|
1783 iInitParams.integer = 5; |
|
1784 TBool initParamsFlag = ETrue; |
|
1785 _LIT(KDummyText,"Dummy params"); |
|
1786 iInitParams.descriptor = &KDummyText; |
|
1787 TUid dllUid; |
|
1788 dllUid.iUid = 0x10009E37; |
|
1789 |
|
1790 TEntry entry; |
|
1791 entry.iName = KExampleDllFileName10; |
|
1792 entry.iModified = TTime(0); |
|
1793 entry.iType = TUidType(KDynamicLibraryUid,KUidInterfaceImplementationCollection3,dllUid); |
|
1794 |
|
1795 iImplementationUid.iUid = 0x10009E38; |
|
1796 |
|
1797 CExampleInterface* implementationPtr = 0; |
|
1798 TUid instanceKey; |
|
1799 TRAPD(err, implementationPtr = reinterpret_cast<CExampleInterface*>(iLoadManager->ImplementationObjectL(iImplementationUid, entry,&iInitParams, initParamsFlag,instanceKey))); |
|
1800 |
|
1801 ::LeaveIfErrNoMemory(err); |
|
1802 TEST2(err,KErrNone); |
|
1803 TEST(implementationPtr != 0); |
|
1804 |
|
1805 CleanupStack::PushL(implementationPtr); |
|
1806 |
|
1807 const TUid KExample10InterfaceUid1 = {0x10009E44}; |
|
1808 const TUid KExample10InterfaceUid2 = {0x10009E45}; // separate interface object |
|
1809 const TUid KExample10InterfaceUid3 = {0x10009E46}; // separate interface object |
|
1810 |
|
1811 // Gets extended interface 0x10009E44 |
|
1812 MExampleInterfaceExtended* ext1 = static_cast<MExampleInterfaceExtended*>(iLoadManager->GetExtendedInterfaceL(instanceKey, KExample10InterfaceUid1 )); |
|
1813 TEST(iStateAccessor.ExtendedInstanceCount(0,*iLoadManager) == 0); // Does not need to be released, so will not be added to extended object array |
|
1814 |
|
1815 // Gets extended interface 0x10009E45 |
|
1816 MExampleInterfaceExtended2* ext2 = static_cast<MExampleInterfaceExtended2*>(iLoadManager->GetExtendedInterfaceL(instanceKey, KExample10InterfaceUid2 )); |
|
1817 TEST(iStateAccessor.ExtendedInstanceCount(0,*iLoadManager) == 1); // Needs to be released |
|
1818 |
|
1819 // Gets extended interface 0x10009E46 |
|
1820 MExampleInterfaceExtended2* ext3 = static_cast<MExampleInterfaceExtended2*>(iLoadManager->GetExtendedInterfaceL(instanceKey, KExample10InterfaceUid3 )); |
|
1821 TEST(iStateAccessor.ExtendedInstanceCount(0,*iLoadManager) == 2); // Needs to be released |
|
1822 |
|
1823 // call ManuallyReleaseExtendedInterface for 0x10009E44. |
|
1824 // Nothing would happen because 0x10009E44 is not require release. |
|
1825 iLoadManager->ManuallyReleaseExtendedInterfaceL(instanceKey, KExample10InterfaceUid1); |
|
1826 TEST(iStateAccessor.ExtendedInstanceCount(0,*iLoadManager) == 2); |
|
1827 |
|
1828 // call ManuallyReleaseExtendedInterface for 0x10009E45. |
|
1829 // extended instance count would be 1 |
|
1830 iLoadManager->ManuallyReleaseExtendedInterfaceL(instanceKey, KExample10InterfaceUid2); |
|
1831 TEST(iStateAccessor.ExtendedInstanceCount(0,*iLoadManager) == 1); |
|
1832 |
|
1833 // call ManuallyReleaseExtendedInterface again, nothing would happen because 0x10009E45 has been released. |
|
1834 iLoadManager->ManuallyReleaseExtendedInterfaceL(instanceKey, KExample10InterfaceUid2); |
|
1835 TEST(iStateAccessor.ExtendedInstanceCount(0,*iLoadManager) == 1); |
|
1836 |
|
1837 // call ManuallyReleaseExtendedInterface for 0x10009E46. |
|
1838 // extended instance count would be 0 |
|
1839 iLoadManager->ManuallyReleaseExtendedInterfaceL(instanceKey, KExample10InterfaceUid3); |
|
1840 TEST(iStateAccessor.ExtendedInstanceCount(0,*iLoadManager) == 0); |
|
1841 |
|
1842 CleanupStack::PopAndDestroy(implementationPtr); |
|
1843 implementationPtr = 0; |
|
1844 iLoadManager->DestroyedThis(instanceKey); |
|
1845 iLoadManager->ClearGarbage(); |
|
1846 |
|
1847 // call again now that implementation has been removed. Expecting a Leave |
|
1848 TRAP(err, iLoadManager->ManuallyReleaseExtendedInterfaceL(instanceKey, KExample10InterfaceUid3 )); |
|
1849 TEST2(err, KErrNotFound); |
|
1850 } |
|
1851 |
|
1852 |
|
1853 |
|
1854 typedef void (CLoadManagerTest::*ClassFuncPtrL) (void); |
|
1855 |
|
1856 /** |
|
1857 @SYMTestCaseID SYSLIB-ECOM-CT-0707 |
|
1858 @SYMTestCaseDesc Wrapper function to call all test functions |
|
1859 @SYMTestPriority High |
|
1860 @SYMTestActions Calls up CLoadManagerTest's test function. |
|
1861 @SYMTestExpectedResults The test must not fail. |
|
1862 @SYMREQ REQ0000 |
|
1863 */ |
|
1864 /** |
|
1865 Wrapper function to call all test functions |
|
1866 |
|
1867 @param testFuncL pointer to test function |
|
1868 @param aTestDesc test function name |
|
1869 */ |
|
1870 LOCAL_C void DoBasicTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc) |
|
1871 { |
|
1872 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0707 ")); |
|
1873 TheTest.Next(aTestDesc); |
|
1874 |
|
1875 __UHEAP_MARK; |
|
1876 // find out the number of open handles |
|
1877 TInt startProcessHandleCount; |
|
1878 TInt startThreadHandleCount; |
|
1879 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
1880 |
|
1881 CLoadManagerTest* loadManagerTest = CLoadManagerTest::NewL(); |
|
1882 CleanupStack::PushL(loadManagerTest); |
|
1883 |
|
1884 (loadManagerTest->*testFuncL)(); |
|
1885 |
|
1886 CleanupStack::PopAndDestroy(loadManagerTest); |
|
1887 |
|
1888 // check that no handles have leaked |
|
1889 TInt endProcessHandleCount; |
|
1890 TInt endThreadHandleCount; |
|
1891 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
1892 |
|
1893 TEST(startProcessHandleCount == endProcessHandleCount); |
|
1894 TEST(startThreadHandleCount == endThreadHandleCount); |
|
1895 |
|
1896 __UHEAP_MARKEND; |
|
1897 } |
|
1898 |
|
1899 /** |
|
1900 @SYMTestCaseID SYSLIB-ECOM-CT-0708 |
|
1901 @SYMTestCaseDesc Function to call all OOM test functions |
|
1902 @SYMTestPriority High |
|
1903 @SYMTestActions Calls up all test functions for OOM test. |
|
1904 @SYMTestExpectedResults The test must not fail. |
|
1905 @SYMREQ REQ0000 |
|
1906 */ |
|
1907 /** |
|
1908 Wrapper function to call all OOM test functions |
|
1909 |
|
1910 @param testFuncL pointer to OOM test function |
|
1911 @param aTestDesc test function name |
|
1912 */ |
|
1913 LOCAL_C void DoOOMTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc) |
|
1914 { |
|
1915 TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0708 ")); |
|
1916 TheTest.Next(aTestDesc); |
|
1917 |
|
1918 TInt err, tryCount = 0; |
|
1919 do |
|
1920 { |
|
1921 __UHEAP_MARK; |
|
1922 // find out the number of open handles |
|
1923 TInt startProcessHandleCount; |
|
1924 TInt startThreadHandleCount; |
|
1925 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
1926 |
|
1927 CLoadManagerTest* loadManagerTest = CLoadManagerTest::NewL(); |
|
1928 CleanupStack::PushL(loadManagerTest); |
|
1929 |
|
1930 // Setting Heap failure for OOM test |
|
1931 __UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount); |
|
1932 |
|
1933 TRAP(err, (loadManagerTest->*testFuncL)()); |
|
1934 |
|
1935 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
1936 |
|
1937 CleanupStack::PopAndDestroy(loadManagerTest); |
|
1938 loadManagerTest = NULL; |
|
1939 |
|
1940 // check that no handles have leaked |
|
1941 TInt endProcessHandleCount; |
|
1942 TInt endThreadHandleCount; |
|
1943 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
1944 |
|
1945 TEST(startProcessHandleCount == endProcessHandleCount); |
|
1946 TEST(startThreadHandleCount == endThreadHandleCount); |
|
1947 |
|
1948 __UHEAP_MARKEND; |
|
1949 } while(err == KErrNoMemory); |
|
1950 |
|
1951 TEST(err == KErrNone); |
|
1952 TheTest.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount); |
|
1953 } |
|
1954 |
|
1955 void DoTestL() |
|
1956 { |
|
1957 __UHEAP_MARK; |
|
1958 |
|
1959 // Basic tests |
|
1960 CreateDeleteTestL(); |
|
1961 DoBasicTestL(&CLoadManagerTest::InstantiationMethodTestPlugin1L, _L("InstantiationMethodTestPlugin1L")); |
|
1962 DoBasicTestL(&CLoadManagerTest::DestroyThisTestPlugin1L, _L("DestroyThisTestPlugin1L")); |
|
1963 DoBasicTestL(&CLoadManagerTest::GetImplementationUidTestL, _L("GetImplementationUidTestL")); |
|
1964 DoBasicTestL(&CLoadManagerTest::CreateDestroyTestCase1Plugin1L,_L("Create Destroy Test case 1")); |
|
1965 DoBasicTestL(&CLoadManagerTest::CreateDestroyTestCase2Plugin1L,_L("Create Destroy Test case 2")); |
|
1966 DoBasicTestL(&CLoadManagerTest::CreateDestroyTestCase3L,_L("Create Destroy Test case 3")); |
|
1967 DoBasicTestL(&CLoadManagerTest::CreateDestroyTestCase4Plugin1L,_L("Create Destroy Test case 4")); |
|
1968 DoBasicTestL(&CLoadManagerTest::CreateDestroyTestCase5Plugin1L,_L("Create Destroy Test case 5")); |
|
1969 |
|
1970 DoBasicTestL(&CLoadManagerTest::InstantiationMethodTestPlugin3L, _L("InstantiationMethodTest3L")); |
|
1971 DoBasicTestL(&CLoadManagerTest::DestroyThisTestPlugin3L, _L("DestroyThisTest3L")); |
|
1972 DoBasicTestL(&CLoadManagerTest::CreateDestroyTestCase1Plugin3L,_L("Create Destroy Test case 1,Plugin3")); |
|
1973 DoBasicTestL(&CLoadManagerTest::CreateDestroyTestCase2Plugin3L,_L("Create Destroy Test case 2")); |
|
1974 DoBasicTestL(&CLoadManagerTest::CreateDestroyTestCase3Plugin3L,_L("Create Destroy Test case 3")); |
|
1975 DoBasicTestL(&CLoadManagerTest::CreateDestroyTestCase4Plugin3L,_L("Create Destroy Test case 4")); |
|
1976 DoBasicTestL(&CLoadManagerTest::CreateDestroyTestCase5Plugin3L,_L("Create Destroy Test case 5")); |
|
1977 |
|
1978 //Create an implementation from a PLUGIN dll and one from a PLUGIN3 dll also. |
|
1979 DoBasicTestL(&CLoadManagerTest::CreateDestroyTestCase1PluginAndPlugin3L,_L("CreateDestroyTestCase1PluginAndPlugin3L")); |
|
1980 |
|
1981 // Get and Release extended interfaces |
|
1982 DoBasicTestL(&CLoadManagerTest::ExtendedMethodTest1Plugin3L,_L("ExtendedMethodTest1Plugin3L")); |
|
1983 DoBasicTestL(&CLoadManagerTest::ExtendedMethodTest2Plugin3L,_L("ExtendedMethodTest2Plugin3L")); |
|
1984 DoBasicTestL(&CLoadManagerTest::ManuallyReleaseExtendedInterfaceTestL,_L("ManuallyReleaseExtendedInterfaceTestL")); |
|
1985 |
|
1986 DoBasicTestL(&CLoadManagerTest::ImplementationObjectTestL,_L("ImplementationObjectTestL")); |
|
1987 |
|
1988 |
|
1989 OOMCreateDeleteTest(); |
|
1990 |
|
1991 DoOOMTestL(&CLoadManagerTest::InstantiationMethodTestPlugin1L, _L("OOM InstantiationMethodTestPlugin1L")); |
|
1992 DoOOMTestL(&CLoadManagerTest::DestroyThisTestPlugin1L, _L("OOM DestroyThisTestPlugin1L")); |
|
1993 DoOOMTestL(&CLoadManagerTest::GetImplementationUidTestL, _L("OOM GetImplementationUidTestL")); |
|
1994 DoOOMTestL(&CLoadManagerTest::CreateDestroyTestCase1Plugin1L,_L("OOM Create Destroy Test case 1")); |
|
1995 DoOOMTestL(&CLoadManagerTest::CreateDestroyTestCase2Plugin1L,_L("OOM Create Destroy Test case 2")); |
|
1996 DoOOMTestL(&CLoadManagerTest::CreateDestroyTestCase3L,_L("OOM Create Destroy Test case 3")); |
|
1997 DoOOMTestL(&CLoadManagerTest::CreateDestroyTestCase4Plugin1L,_L("OOM Create Destroy Test case 4")); |
|
1998 DoOOMTestL(&CLoadManagerTest::CreateDestroyTestCase5Plugin1L,_L("OOM Create Destroy Test case 5")); |
|
1999 |
|
2000 DoOOMTestL(&CLoadManagerTest::InstantiationMethodTestPlugin3L, _L("OOM InstantiationMethodTest3L")); |
|
2001 DoOOMTestL(&CLoadManagerTest::DestroyThisTestPlugin3L, _L("OOM DestroyThisTest3L")); |
|
2002 DoOOMTestL(&CLoadManagerTest::CreateDestroyTestCase1Plugin3L,_L("OOM Create Destroy Test case 1,Plugin3")); |
|
2003 DoOOMTestL(&CLoadManagerTest::CreateDestroyTestCase2Plugin3L,_L("OOM Create Destroy Test case 2")); |
|
2004 DoOOMTestL(&CLoadManagerTest::CreateDestroyTestCase3Plugin3L,_L("OOM Create Destroy Test case 3")); |
|
2005 DoOOMTestL(&CLoadManagerTest::CreateDestroyTestCase4Plugin3L,_L("OOM Create Destroy Test case 4")); |
|
2006 DoOOMTestL(&CLoadManagerTest::CreateDestroyTestCase5Plugin3L,_L("OOM Create Destroy Test case 5")); |
|
2007 |
|
2008 //Create an implementation from a PLUGIN dll and one from a PLUGIN3 dll also. |
|
2009 DoOOMTestL(&CLoadManagerTest::CreateDestroyTestCase1PluginAndPlugin3L,_L("OOM CreateDestroyTestCase1PluginAndPlugin3L")); |
|
2010 |
|
2011 // Get and Release extended interfaces |
|
2012 DoOOMTestL(&CLoadManagerTest::ExtendedMethodTest1Plugin3L,_L("OOM ExtendedMethodTest1Plugin3L")); |
|
2013 DoOOMTestL(&CLoadManagerTest::ExtendedMethodTest2Plugin3L,_L("OOM ExtendedMethodTest2Plugin3L")); |
|
2014 DoOOMTestL(&CLoadManagerTest::ManuallyReleaseExtendedInterfaceTestL,_L("OOM ManuallyReleaseExtendedInterfaceTestL")); |
|
2015 |
|
2016 __UHEAP_MARKEND; |
|
2017 } |
|
2018 |
|
2019 //Leave if aError < 0 with info message printed out |
|
2020 LOCAL_C void LeaveIfError(TInt aError, TInt aLine) |
|
2021 { |
|
2022 if(aError < KErrNone) |
|
2023 { |
|
2024 ::Leave(aError, aLine); |
|
2025 } |
|
2026 } |
|
2027 |
|
2028 #define LEAVE_IF_ERROR(aError) ::LeaveIfError(aError, __LINE__) |
|
2029 // |
|
2030 // Copies the Plugins to specific folder for testing purpose |
|
2031 // |
|
2032 LOCAL_C void CopyPlugins() |
|
2033 { |
|
2034 // Connect the file server instance |
|
2035 LEAVE_IF_ERROR(TheFs.Connect()); |
|
2036 |
|
2037 TRAPD(err, EComTestUtils::FileManCopyFileL(KResourceFileName5OnZ, KResourceFileName5)); |
|
2038 TEST(err==KErrNone); |
|
2039 |
|
2040 TRAP(err, EComTestUtils::FileManCopyFileL(KExampleDllFileName5OnZ, KExampleDllFileName5)); |
|
2041 TEST(err==KErrNone); |
|
2042 |
|
2043 TRAP(err, EComTestUtils::FileManCopyFileL(KResourceFileName12OnZ, KResourceFileName12)); |
|
2044 TEST(err==KErrNone); |
|
2045 |
|
2046 TRAP(err, EComTestUtils::FileManCopyFileL(KExampleDllFileName12OnZ, KExampleDllFileName12)); |
|
2047 TEST(err==KErrNone); |
|
2048 } |
|
2049 |
|
2050 // Deleting plugin from the RAM for cleanup purpose |
|
2051 LOCAL_C void DeleteTestPlugin() |
|
2052 { |
|
2053 TRAPD(err, EComTestUtils::FileManDeleteFileL(KResourceFileName5)); |
|
2054 TRAP(err, EComTestUtils::FileManDeleteFileL(KExampleDllFileName5)); |
|
2055 TRAP(err, EComTestUtils::FileManDeleteFileL(KResourceFileName12)); |
|
2056 TRAP(err, EComTestUtils::FileManDeleteFileL(KExampleDllFileName12)); |
|
2057 } |
|
2058 |
|
2059 // |
|
2060 //Initialise the Active Scheduler |
|
2061 // |
|
2062 LOCAL_C void SetupL() |
|
2063 { |
|
2064 // Construct and install the Active Scheduler. The Active Schedular is needed |
|
2065 // by components used by this test as they are ActiveObjects. |
|
2066 TheActiveScheduler = new(ELeave)CActiveScheduler; |
|
2067 CActiveScheduler::Install(TheActiveScheduler); |
|
2068 } |
|
2069 |
|
2070 GLDEF_C TInt E32Main() |
|
2071 { |
|
2072 __UHEAP_MARK; |
|
2073 |
|
2074 TheTest.Printf(_L("\n")); |
|
2075 TheTest.Title(); |
|
2076 TheTest.Start( _L("LoadManager Tests.") ); |
|
2077 |
|
2078 TheTrapCleanup = CTrapCleanup::New(); |
|
2079 |
|
2080 TRAPD(err, SetupL()); |
|
2081 TEST(err == KErrNone); |
|
2082 |
|
2083 CopyPlugins(); |
|
2084 // The reason for the folowing delay is: |
|
2085 // ECOM server could be already started. It means that when we copy some |
|
2086 // ECOM plugins from Z: to C: drive - ECOM server should look for and |
|
2087 // find the new ECOM plugins. The ECOM server uses for that an active object, |
|
2088 // which scans plugin directories. So the discovering service is asynchronous. |
|
2089 // We have to wait some time until it finishes. |
|
2090 // Otherwise ListImplementationsL could fail to find requested implementations. |
|
2091 User::After(KOneSecond * 3); |
|
2092 |
|
2093 //Call the main tess |
|
2094 TRAP(err, DoTestL()); |
|
2095 TEST2(err,KErrNone); |
|
2096 |
|
2097 // Cleanup files. If the cleanup fails that is no problem, |
|
2098 // as any subsequent tests will replace them. The only downside |
|
2099 // would be the disk not being tidied |
|
2100 DeleteTestPlugin(); |
|
2101 |
|
2102 TheFs.Close(); |
|
2103 |
|
2104 delete TheActiveScheduler; |
|
2105 delete TheTrapCleanup; |
|
2106 |
|
2107 TheTest.End(); |
|
2108 TheTest.Close(); |
|
2109 |
|
2110 __UHEAP_MARKEND; |
|
2111 return KErrNone; |
|
2112 } |