sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "EComUidCodes.h" sl@0: #include "Interface.h" // interface to Plugins sl@0: #include "../EcomTestUtils/EcomTestUtils.h" sl@0: sl@0: //The tests test all the new APIs added to REComSession created for EC43 sl@0: sl@0: TUid KCExampleImplUid = {0x10009DC3}; sl@0: sl@0: const TInt KOneSecond = 1000000; sl@0: sl@0: LOCAL_D RTest test(_L("t_extendedinterfaces")); sl@0: LOCAL_D RFs TheFs; sl@0: sl@0: #define __UNUSED_VAR(var) var = var sl@0: sl@0: // Used for OOM test sl@0: #define TEST_OOM_ERR if(err == KErrNoMemory) {User::Leave(err);} sl@0: sl@0: sl@0: static void ResetAndDestroyArray(TAny* aPtr) sl@0: { sl@0: (static_cast(aPtr))->ResetAndDestroy(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Test function for REcomSession::ListImplementationL sl@0: sl@0: @param aContainInvalidExtIf The bool value identifying if the extended interfaces list contains sl@0: invalid extended interface Uid sl@0: @param aUseDefResolver The bool value identifying if default resolver is used. sl@0: @param aUseResolveParam The bool value identifying if resolve parameter is used. sl@0: @param aNumEntriesInExtIFList The number of entries in the extended interfaces list. sl@0: @param aImplInfoArray A reference to a client owned array which will be filled sl@0: with interface implementation data. sl@0: */ sl@0: LOCAL_C void ListImplementationTestL(TBool aContainInvalidExtIf, sl@0: TBool aUseDefResolver, sl@0: TBool aUseResolveParam, sl@0: TInt aNumEntriesInExtIFList, sl@0: RImplInfoPtrArray& aImplInfoArray) sl@0: { sl@0: const TUid KInterfaceUid = {0x10009DBB}; sl@0: const TUid KExtendedInterfaceUid1 = {0x10009E44}; sl@0: const TUid KExtendedInterfaceUid2 = {0x10009E45}; sl@0: const TUid KExtendedInterfaceUid3 = {0x10009E46}; sl@0: const TUid KInvalidExtendedInterfaceUid2 = {0x10009E49}; sl@0: _LIT8(KExample10ImplementationTest,"Example 10"); sl@0: sl@0: TUid resolverUid = {0x10009DD0}; sl@0: sl@0: // Set up extended interfaces sl@0: RArray extendedInterfaces; sl@0: CleanupClosePushL(extendedInterfaces); sl@0: sl@0: if (!aContainInvalidExtIf) sl@0: { sl@0: if (aNumEntriesInExtIFList==1) sl@0: { sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid1); sl@0: } sl@0: else if (aNumEntriesInExtIFList>1) sl@0: { sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid2); sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid3); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid1); sl@0: extendedInterfaces.AppendL(KInvalidExtendedInterfaceUid2); sl@0: } sl@0: sl@0: //Set up resolve parameter sl@0: TEComResolverParams ResolverParams; sl@0: if (aUseResolveParam) sl@0: { sl@0: ResolverParams.SetDataType(KExample10ImplementationTest()); sl@0: ResolverParams.SetGenericMatch(ETrue); // Allow wildcard matching sl@0: if (aUseDefResolver) //ListImplementationTest2L,ListImplementationTest4L sl@0: { sl@0: REComSession::ListImplementationsL(KInterfaceUid,extendedInterfaces,ResolverParams,aImplInfoArray); sl@0: } sl@0: else //ListImplementationTest3L sl@0: { sl@0: REComSession::ListImplementationsL(KInterfaceUid,extendedInterfaces,ResolverParams,resolverUid,aImplInfoArray); sl@0: } sl@0: sl@0: } sl@0: else //ListImplementationTest1L, ListImplementationTest5L sl@0: { sl@0: REComSession::ListImplementationsL(KInterfaceUid,extendedInterfaces,aImplInfoArray); sl@0: } sl@0: CleanupStack::PopAndDestroy(&extendedInterfaces); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3597 sl@0: @SYMTestCaseDesc Tests for CImplementationInformation structure. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call ListImplementationL method to get a list of implementations with extended interfaces. sl@0: Check that the expected extended interfaces are available in the CImplementationInformation sl@0: data structure via GetExtendedInterfaceList method. sl@0: @SYMTestExpectedResults Extended interfaces are available in implementation information structure. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void ListImplementationTest5L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3597 ")); sl@0: // Test Starts... sl@0: RImplInfoPtrArray ifArray; sl@0: TBool containInvalidExtIf = EFalse; sl@0: TBool useDefResolver = ETrue; sl@0: TBool useResolveParam = EFalse; sl@0: TInt numEntriesOnExtIFList = 3; sl@0: sl@0: ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); sl@0: sl@0: //Checks the result sl@0: //0x10009E38 is implemented in EcomExample10.dll sl@0: TUid KExample10ImplUid = {0x10009E38}; sl@0: TUid KExtendedInterfaceUid1 = {0x10009E44}; sl@0: TUid KExtendedInterfaceUid2 = {0x10009E45}; sl@0: TUid KExtendedInterfaceUid3 = {0x10009E46}; sl@0: const TInt availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount == 1); sl@0: sl@0: //tests extended interfaces sl@0: CImplementationInformation* info = ifArray[0]; sl@0: test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); sl@0: test (KExample10ImplUid==info->ImplementationUid()); sl@0: sl@0: CleanupStack::PushL(TCleanupItem(ResetAndDestroyArray, &ifArray)); sl@0: sl@0: // Gets extended interfaces list sl@0: RArray extInf; sl@0: CleanupClosePushL(extInf); sl@0: info->GetExtendedInterfaceListL(extInf); sl@0: test(extInf[0] == KExtendedInterfaceUid1); sl@0: test(extInf[1] == KExtendedInterfaceUid2); sl@0: test(extInf[2] == KExtendedInterfaceUid3); sl@0: CleanupStack::PopAndDestroy(&extInf); sl@0: sl@0: // Empty the array of implementations sl@0: test.Printf(_L("Destroying List...")); sl@0: CleanupStack::PopAndDestroy(&ifArray); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3594 sl@0: @SYMTestCaseDesc Tests for REComSession::ListImplementationL created with an Interface Uid sl@0: and invalid extended Interfaces. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call ListImplementationL method supporting interface UID and extended interfaces sl@0: that are invalid. sl@0: @SYMTestExpectedResults No implementation is returned. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void ListImplementationTest4L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3594 ")); sl@0: // Test Starts... sl@0: RImplInfoPtrArray ifArray; sl@0: TBool containInvalidExtIf = ETrue; sl@0: TBool useDefResolver = ETrue; sl@0: TBool useResolveParam = ETrue; sl@0: TInt numEntriesOnExtIFList = 2; sl@0: sl@0: ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); sl@0: sl@0: //Checks the result sl@0: const TInt availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount == 0); sl@0: sl@0: // Empty the array of implementations sl@0: test.Printf(_L("Destroying List...")); sl@0: ifArray.ResetAndDestroy(); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3589 sl@0: @SYMTestCaseDesc Tests for REComSession::ListImplementationsL for known Interface UID, sl@0: resolver match characteristics, resolver UID and extended interfaces. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call ListImplementationL method supporting interface UID, resolver parameters sl@0: resolver UID and extended interfaces. sl@0: @SYMTestExpectedResults Expected implementations are returned. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void ListImplementationTest3L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3589 ")); sl@0: // Test Starts... sl@0: RImplInfoPtrArray ifArray; sl@0: TBool containInvalidExtIf = EFalse; sl@0: TBool useDefResolver = EFalse; sl@0: TBool useResolveParam = ETrue; sl@0: sl@0: //Number of entries in extended interfaces is 3. sl@0: TInt numEntriesOnExtIFList = 3; sl@0: ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); sl@0: sl@0: //Checks the result sl@0: TUid KImplementationUid = {0x10009E38}; sl@0: TInt availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount == 1); sl@0: sl@0: //tests implementation uid sl@0: for (TInt count = 0; count < availCount; ++count) sl@0: { sl@0: const CImplementationInformation* info = ifArray[count]; sl@0: test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); sl@0: test(KImplementationUid == info->ImplementationUid()); sl@0: } sl@0: sl@0: // Empty the array of implementations sl@0: test.Printf(_L("Destroying List...")); sl@0: ifArray.ResetAndDestroy(); sl@0: sl@0: //Number of entries in extended interfaces is 0. sl@0: numEntriesOnExtIFList = 0; sl@0: ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); sl@0: sl@0: //Checks the result sl@0: availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount == 1); sl@0: sl@0: //tests implementation uid sl@0: for (TInt count = 0; count < availCount; ++count) sl@0: { sl@0: const CImplementationInformation* info = ifArray[count]; sl@0: test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); sl@0: } sl@0: sl@0: // Empty the array of implementations sl@0: test.Printf(_L("Destroying List...")); sl@0: ifArray.ResetAndDestroy(); sl@0: sl@0: //Number of entries in extended interfaces is 1. sl@0: numEntriesOnExtIFList = 1; sl@0: ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); sl@0: sl@0: //Checks the result sl@0: availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount == 1); sl@0: sl@0: //tests implementation uid sl@0: for (TInt count = 0; count < availCount; ++count) sl@0: { sl@0: const CImplementationInformation* info = ifArray[count]; sl@0: test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); sl@0: } sl@0: sl@0: // Empty the array of implementations sl@0: test.Printf(_L("Destroying List...")); sl@0: ifArray.ResetAndDestroy(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3588 sl@0: @SYMTestCaseDesc Tests for REComSession::ListImplementationsL for known Interface UID, sl@0: resolver match characteristics and extended interfaces. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call ListImplementationL method supporting interface UID, resolver parameters and extended interfaces. sl@0: @SYMTestExpectedResults Expected implementations are returned. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void ListImplementationTest2L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3588 ")); sl@0: // Test Starts... sl@0: RImplInfoPtrArray ifArray; sl@0: TBool containInvalidExtIf = EFalse; sl@0: TBool useDefResolver = ETrue; sl@0: TBool useResolveParam = ETrue; sl@0: sl@0: //Number of entries in extended interfaces is 3. sl@0: TInt numEntriesOnExtIFList = 3; sl@0: ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); sl@0: sl@0: //Checks the result sl@0: TUid KImplementationUid = {0x10009E38}; sl@0: TInt availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount == 1); sl@0: sl@0: //tests implementation uid sl@0: for (TInt count = 0; count < availCount; ++count) sl@0: { sl@0: const CImplementationInformation* info = ifArray[count]; sl@0: test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); sl@0: test(KImplementationUid==info->ImplementationUid()); sl@0: } sl@0: sl@0: // Empty the array of implementations sl@0: test.Printf(_L("Destroying List...")); sl@0: ifArray.ResetAndDestroy(); sl@0: sl@0: //Number of entries in extended interfaces is 0. sl@0: numEntriesOnExtIFList = 0; sl@0: ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); sl@0: sl@0: //Checks the result sl@0: availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount == 1); sl@0: sl@0: //tests implementation uid sl@0: for (TInt count = 0; count < availCount; ++count) sl@0: { sl@0: const CImplementationInformation* info = ifArray[count]; sl@0: test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); sl@0: } sl@0: sl@0: // Empty the array of implementations sl@0: test.Printf(_L("Destroying List...")); sl@0: ifArray.ResetAndDestroy(); sl@0: sl@0: //Number of entries in extended interfaces is 1. sl@0: numEntriesOnExtIFList = 1; sl@0: ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); sl@0: sl@0: //Checks the result sl@0: availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount == 1); sl@0: sl@0: //tests implementation uid sl@0: for (TInt count = 0; count < availCount; ++count) sl@0: { sl@0: const CImplementationInformation* info = ifArray[count]; sl@0: test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); sl@0: } sl@0: sl@0: // Empty the array of implementations sl@0: test.Printf(_L("Destroying List...")); sl@0: ifArray.ResetAndDestroy(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3587 sl@0: @SYMTestCaseDesc Tests for REComSession::ListImplementationsL for known Interface UID and extended interfaces. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call ListImplementationL method supporting interface UID and extended interfaces. sl@0: @SYMTestExpectedResults Expected implementations are returned. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void ListImplementationTest1L() sl@0: { sl@0: // sl@0: // Testing a overloaded method for ListImplementationsL sl@0: // ------------------------------------------------------------------ sl@0: // sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3587 ")); sl@0: RImplInfoPtrArray ifArray; sl@0: sl@0: TBool containInvalidExtIf = EFalse; sl@0: TBool useDefResolver = ETrue; sl@0: TBool useResolveParam = EFalse; sl@0: sl@0: //Number of entries in extended interfaces is 3. sl@0: TInt numEntriesOnExtIFList = 3; sl@0: ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); sl@0: sl@0: //Checks the result sl@0: //0x10009E38 is implemented in EcomExample10.dll sl@0: TUid KExample10ImplUid = {0x10009E38}; sl@0: TInt availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount == 1); sl@0: sl@0: //tests implementation uid sl@0: const CImplementationInformation* info = ifArray[0]; sl@0: test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); sl@0: test(KExample10ImplUid == info->ImplementationUid()); sl@0: sl@0: // Empty the array of implementations sl@0: test.Printf(_L("Destroying List...")); sl@0: ifArray.ResetAndDestroy(); sl@0: sl@0: //Number of entries in extended interfaces is 0. sl@0: numEntriesOnExtIFList = 0; sl@0: ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); sl@0: sl@0: //Checks the result sl@0: availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount == 3); sl@0: sl@0: //tests implementation uid sl@0: for (TInt count = 0;count < availCount; ++count) sl@0: { sl@0: const CImplementationInformation* info = ifArray[count]; sl@0: test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); sl@0: } sl@0: sl@0: // Empty the array of implementations sl@0: test.Printf(_L("Destroying List...")); sl@0: ifArray.ResetAndDestroy(); sl@0: sl@0: //Number of entries in extended interfaces is 1. sl@0: numEntriesOnExtIFList = 1; sl@0: ListImplementationTestL(containInvalidExtIf,useDefResolver,useResolveParam,numEntriesOnExtIFList,ifArray); sl@0: sl@0: //Checks the result sl@0: availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount == 2); sl@0: sl@0: //tests implementation uid sl@0: for (TInt count = 0; count < availCount; ++count) sl@0: { sl@0: const CImplementationInformation* info = ifArray[count]; sl@0: test.Printf(_L("Implementation Uid-%x. %s\n"),info->ImplementationUid(),((info->DisplayName()).Ptr())); sl@0: } sl@0: sl@0: // Empty the array of implementations sl@0: test.Printf(_L("Destroying List...")); sl@0: ifArray.ResetAndDestroy(); sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3713 sl@0: @SYMTestCaseDesc Tests for REComSession::CreateImplementationL and REComSession::ListImplementationL sl@0: with a dummy Interface Uid, dummy implementation Uid or dummy resolver Uid. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call CreateImplementationL method with a dummy interface UID sl@0: Call CreateImplementationL method with a dummy implementation UID sl@0: Call CreateImplementationL method with a dummy Resolver UID sl@0: Call ListImplementationL method with a dummy interface UID sl@0: Call ListImplementationL method with a dummy Resolver UID sl@0: @SYMTestExpectedResults Leave with KErrAugument and No implementation is created. sl@0: @SYMDEF DEF111196 sl@0: */ sl@0: LOCAL_C void DummyUidTestL() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3713 ")); sl@0: TUid instanceKey; sl@0: TUid dummyUid; sl@0: dummyUid.iUid = 0; sl@0: const TUid KInterfaceUid = {0x10009DBB}; sl@0: const TUid KExample10InterfaceUid = {0x10009DBB}; sl@0: _LIT8(KExample10ImplementationTest,"Example 10"); sl@0: sl@0: CExampleInterface* dllPtr = NULL; sl@0: // Set up extended interfaces sl@0: RArray extendedInterfaces; sl@0: CleanupClosePushL(extendedInterfaces); sl@0: sl@0: //Set up resolve parameter sl@0: TEComResolverParams ResolverParams; sl@0: ResolverParams.SetDataType(KExample10ImplementationTest()); sl@0: ResolverParams.SetGenericMatch(ETrue); // Allow wildcard matching sl@0: sl@0: CExampleInterface::TExampleInterfaceInitParams initParams; sl@0: // Set up some empty initialisation parameters sl@0: initParams.integer = 0; sl@0: initParams.descriptor = NULL; sl@0: sl@0: // CreateImplementationL with a dummy interface Uid sl@0: TRAPD(err,dllPtr = REINTERPRET_CAST(CExampleInterface*, sl@0: REComSession::CreateImplementationL(dummyUid, sl@0: extendedInterfaces, sl@0: instanceKey, sl@0: ResolverParams, sl@0: &initParams))); sl@0: test(err == KErrArgument); sl@0: test(dllPtr == NULL); sl@0: sl@0: // CreateImplementationL with a dummy implementation Uid sl@0: TRAP(err,dllPtr = REINTERPRET_CAST(CExampleInterface*, sl@0: REComSession::CreateImplementationL(dummyUid, sl@0: instanceKey))); sl@0: test(err == KErrArgument); sl@0: test(dllPtr == NULL); sl@0: sl@0: // CreateImplementationL with a dummy resolver Uid sl@0: TRAP(err, dllPtr = REINTERPRET_CAST(CExampleInterface*, sl@0: REComSession::CreateImplementationL(KExample10InterfaceUid, sl@0: extendedInterfaces, sl@0: instanceKey, sl@0: ResolverParams, sl@0: dummyUid, sl@0: &initParams))); sl@0: test(err == KErrArgument); sl@0: test(dllPtr == NULL); sl@0: sl@0: RImplInfoPtrArray ifArray; sl@0: sl@0: // ListImplementationL with a dummy interface Uid sl@0: TRAP(err, REComSession::ListImplementationsL(dummyUid,extendedInterfaces,ResolverParams,ifArray)); sl@0: test(err == KErrArgument); sl@0: test(ifArray.Count() == 0); sl@0: sl@0: // ListImplementationL with a dummy resolver Uid sl@0: TRAP(err, REComSession::ListImplementationsL(KInterfaceUid,extendedInterfaces,ResolverParams,dummyUid,ifArray)); sl@0: test(err == KErrArgument); sl@0: test(ifArray.Count() == 0); sl@0: sl@0: CleanupStack::PopAndDestroy(&extendedInterfaces); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3715 sl@0: @SYMTestCaseDesc Tests for REComSession::CreateImplementationL with ROMOnly resolver sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call CreateImplementationL method with ROMOnly resolver sl@0: @SYMTestExpectedResults Expected implementation is created. Ensure there is no OOM error. sl@0: @SYMDEF DEF111196 sl@0: */ sl@0: LOCAL_C void CreateImplementationTest7L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3715 ")); sl@0: // test start... sl@0: const TUid KExample10InterfaceUid = {0x10009DBB}; sl@0: const TUid KExtendedInterfaceUid1 = {0x10009E44}; sl@0: const TUid KExtendedInterfaceUid2 = {0x10009E45}; sl@0: const TUid KExtendedInterfaceUid3 = {0x10009E46}; sl@0: const TUid KExample10ImplementationUid = {0x10009E38}; sl@0: sl@0: _LIT8(KExample10ImplementationTest,"Example 10"); sl@0: sl@0: // ROMOnly resolver Uid 0x10009D92 sl@0: TUid resolverUid = {0x10009D92}; sl@0: sl@0: TUid instanceKey; sl@0: sl@0: CExampleInterface* dllPtr = NULL; sl@0: // Set up extended interfaces sl@0: RArray extendedInterfaces; sl@0: CleanupClosePushL(extendedInterfaces); sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid1); sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid2); sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid3); sl@0: sl@0: //Set up resolve parameter sl@0: TEComResolverParams ResolverParams; sl@0: ResolverParams.SetDataType(KExample10ImplementationTest()); sl@0: ResolverParams.SetGenericMatch(ETrue); // Allow wildcard matching sl@0: sl@0: dllPtr = REINTERPRET_CAST(CExampleInterface*, sl@0: REComSession::CreateImplementationL(KExample10InterfaceUid, sl@0: extendedInterfaces, sl@0: instanceKey, sl@0: ResolverParams, sl@0: resolverUid)); sl@0: CleanupStack::PopAndDestroy(&extendedInterfaces); sl@0: sl@0: //checks the implementation created sl@0: test(dllPtr != NULL); sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: REComSession::DestroyedImplementation(instanceKey); sl@0: sl@0: delete dllPtr; sl@0: } sl@0: sl@0: sl@0: /** sl@0: Test function for REcomSession::CreateImplementationL sl@0: sl@0: @param aContainInvalidExtIf The bool value identifying if the extended interfaces list contains sl@0: invalid extended interface Uid sl@0: @param aUseDefResolver The bool value identifying if default resolver is used. sl@0: @param aUseInitParam The bool value identifying if initialise parameter is used. sl@0: @param aNumEntriesInExtIFList The number of entries in the extended interfaces list. sl@0: @param aInstanceKey A 32 bit identifer returned by the ECom framework to sl@0: identify this instance to the framework. sl@0: @return A pointer to the implementation created. sl@0: */ sl@0: LOCAL_C CExampleInterface* CreateImplementationTestL(TBool aContainInvalidExtIf, sl@0: TBool aUseDefResolver, sl@0: TBool aUseInitParam, sl@0: TUid& aInstanceKey) sl@0: { sl@0: const TUid KExample10InterfaceUid = {0x10009DBB}; sl@0: const TUid KExtendedInterfaceUid1 = {0x10009E44}; sl@0: const TUid KExtendedInterfaceUid2 = {0x10009E45}; sl@0: const TUid KExtendedInterfaceUid3 = {0x10009E46}; sl@0: const TUid KInvalidExtendedInterfaceUid2 = {0x10009E49}; sl@0: _LIT8(KExample10ImplementationTest,"Example 10"); sl@0: sl@0: TUid resolverUid = {0x10009DD0}; sl@0: sl@0: CExampleInterface* dllPtr = NULL; sl@0: // Set up extended interfaces sl@0: RArray extendedInterfaces; sl@0: CleanupClosePushL(extendedInterfaces); sl@0: sl@0: if (!aContainInvalidExtIf) sl@0: { sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid1); sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid2); sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid3); sl@0: } sl@0: else sl@0: { sl@0: extendedInterfaces.AppendL(KExtendedInterfaceUid1); sl@0: extendedInterfaces.AppendL(KInvalidExtendedInterfaceUid2); sl@0: } sl@0: sl@0: //Set up resolve parameter sl@0: TEComResolverParams ResolverParams; sl@0: ResolverParams.SetDataType(KExample10ImplementationTest()); sl@0: ResolverParams.SetGenericMatch(ETrue); // Allow wildcard matching sl@0: sl@0: CExampleInterface::TExampleInterfaceInitParams initParams; sl@0: if (aUseInitParam) //CreateImplementationTest3L,CreateImplementationTest5L sl@0: { sl@0: // Set up some empty initialisation parameters sl@0: initParams.integer = 0; sl@0: initParams.descriptor = NULL; sl@0: if (aUseDefResolver) //CreateImplementationTest3L sl@0: { sl@0: dllPtr = REINTERPRET_CAST(CExampleInterface*, sl@0: REComSession::CreateImplementationL(KExample10InterfaceUid, sl@0: extendedInterfaces, sl@0: aInstanceKey, sl@0: ResolverParams, sl@0: &initParams)); sl@0: } sl@0: else //CreateImplementationTest5L sl@0: { sl@0: dllPtr = REINTERPRET_CAST(CExampleInterface*, sl@0: REComSession::CreateImplementationL(KExample10InterfaceUid, sl@0: extendedInterfaces, sl@0: aInstanceKey, sl@0: ResolverParams, sl@0: resolverUid, sl@0: &initParams)); sl@0: } sl@0: } sl@0: else //CreateImplementationTest2L, CreateImplementationTest4L, CreateImplementationTest6 sl@0: { sl@0: if (aUseDefResolver) //CreateImplementationTest2L, CreateImplementationTest6 sl@0: { sl@0: dllPtr = REINTERPRET_CAST(CExampleInterface*, sl@0: REComSession::CreateImplementationL(KExample10InterfaceUid, sl@0: extendedInterfaces, sl@0: aInstanceKey, sl@0: ResolverParams)); sl@0: } sl@0: else //CreateImplementationTest4L sl@0: { sl@0: dllPtr = REINTERPRET_CAST(CExampleInterface*, sl@0: REComSession::CreateImplementationL(KExample10InterfaceUid, sl@0: extendedInterfaces, sl@0: aInstanceKey, sl@0: ResolverParams, sl@0: resolverUid)); sl@0: } sl@0: } sl@0: CleanupStack::PopAndDestroy(&extendedInterfaces); sl@0: return dllPtr; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3708 sl@0: @SYMTestCaseDesc Tests for calling DestroyedImplementation() twice. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call CreateImplementationL method to load a plugin. sl@0: Delete the plugin by calling DestroyedImplementation() twice. sl@0: Delete pointer. Call DestroyedImplementation(). sl@0: Cal FinalClose(). Call DestroyedImplementation(). sl@0: @SYMTestExpectedResults Second call to DestroyedImplementation() should succeed. sl@0: @SYMDEF DEF111428 sl@0: */ sl@0: LOCAL_C void DestroyedImplementationTestL() sl@0: { sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3708 ")); sl@0: TUid instanceKey; sl@0: TBool containInvalidExtIf = EFalse; sl@0: TBool useDefResolver = EFalse; sl@0: TBool useInitParam = ETrue; sl@0: TUid KExample10ImplementationUid = {0x10009E38}; sl@0: sl@0: test.Printf(_L("Loading Plugin...")); sl@0: sl@0: // Test create implementation by pass in instance key. sl@0: CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: // the destructor calls DestroyedImplementation() sl@0: test.Printf(_L("Calling DestroyedImplementation the 1st time through the plugin destructor...")); sl@0: delete dllPtr; sl@0: sl@0: test.Printf(_L("Calling DestroyedImplementation a 2nd time directly through REComSession...")); sl@0: REComSession::DestroyedImplementation(instanceKey); sl@0: sl@0: test.Printf(_L("Calling DestroyedImplementation a 3rd time directly through REComSession but after FinalClose...")); sl@0: sl@0: REComSession::DestroyedImplementation(instanceKey); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3595 sl@0: @SYMTestCaseDesc Tests for REComSession::CreateImplementationL created with an Interface Uid sl@0: and invalid extended Interfaces. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call CreateImplementationL method supporting interface UID and extended interfaces sl@0: that are invalid. sl@0: @SYMTestExpectedResults No implementation is created. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void CreateImplementationTest6() sl@0: { sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3595 ")); sl@0: TUid instanceKey; sl@0: TBool containInvalidExtIf = ETrue; sl@0: TBool useDefResolver = ETrue; sl@0: TBool useInitParam = EFalse; sl@0: sl@0: test.Printf(_L("Loading Plugin...")); sl@0: TInt err; sl@0: TRAP(err,CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey)); sl@0: sl@0: test(KErrNotFound == err); sl@0: sl@0: test.Printf(_L("Implementation is not found.\n")); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3593 sl@0: @SYMTestCaseDesc Tests for REComSession::CreateImplementationL created with an resolver Uid sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call CreateImplementationL method supporting interface UID, extended interfaces, sl@0: construction parameters, resolver parameters and resolver UID. sl@0: @SYMTestExpectedResults Expected implementation is created and no memory leaks. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void CreateImplementationTest5L() sl@0: { sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3593 ")); sl@0: TUid instanceKey; sl@0: TBool containInvalidExtIf = EFalse; sl@0: TBool useDefResolver = EFalse; sl@0: TBool useInitParam = ETrue; sl@0: TUid KExample10ImplementationUid = {0x10009E38}; sl@0: sl@0: test.Printf(_L("Loading Plugin...")); sl@0: sl@0: // Test create implementation by pass in instance key. sl@0: CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: REComSession::DestroyedImplementation(instanceKey); sl@0: delete dllPtr; sl@0: sl@0: // Test create implementation by pass in offset of the instance key. sl@0: dllPtr = CExampleInterface::NewL8(); sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: delete dllPtr; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3592 sl@0: @SYMTestCaseDesc Tests for REComSession::CreateImplementationL created with an resolver Uid sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call CreateImplementationL method supporting interface UID, extended interfaces, sl@0: resolver parameters and resolver UID. sl@0: @SYMTestExpectedResults Expected implementation is created and no memory leaks. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void CreateImplementationTest4L() sl@0: { sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3592 ")); sl@0: TUid instanceKey; sl@0: TBool containInvalidExtIf = EFalse; sl@0: TBool useDefResolver = EFalse; sl@0: TBool useInitParam = EFalse; sl@0: TUid KExample10ImplementationUid = {0x10009E38}; sl@0: sl@0: test.Printf(_L("Loading Plugin...")); sl@0: sl@0: // Test create implementation by pass in instance key. sl@0: CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: REComSession::DestroyedImplementation(instanceKey); sl@0: delete dllPtr; sl@0: sl@0: // Test create implementation by pass in offset of the instance key. sl@0: dllPtr = CExampleInterface::NewL6(); sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: delete dllPtr; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3591 sl@0: @SYMTestCaseDesc Tests for REComSession::CreateImplementationL created with an Interface Uid, sl@0: ExtendedInterface, construction parameters and resolver parameters sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call CreateImplementationL method supporting interface UID,extended interfaces, sl@0: construction parameters and resolver parameters. sl@0: @SYMTestExpectedResults Expected implementation is created and no memory leaks. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void CreateImplementationTest3L() sl@0: { sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3591 ")); sl@0: TUid instanceKey; sl@0: TBool containInvalidExtIf = EFalse; sl@0: TBool useDefResolver = ETrue; sl@0: TBool useInitParam = ETrue; sl@0: TUid KExample10ImplementationUid = {0x10009E38}; sl@0: sl@0: test.Printf(_L("Loading Plugin...")); sl@0: sl@0: // Test create implementation by pass in instance key. sl@0: CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: REComSession::DestroyedImplementation(instanceKey); sl@0: delete dllPtr; sl@0: sl@0: // Test create implementation by pass in offset of the instance key. sl@0: dllPtr = CExampleInterface::NewL7(); sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: delete dllPtr; sl@0: } sl@0: sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3590 sl@0: @SYMTestCaseDesc Tests for REComSession::CreateImplementationL created with an Interface Uid, sl@0: ExtendedInterface and resolver parameters. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call CreateImplementationL method supporting interface UID,extended interfaces, and resolver parameters. sl@0: @SYMTestExpectedResults Expected implementation is created and no memory leaks. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void CreateImplementationTest2L() sl@0: { sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3590 ")); sl@0: TUid instanceKey; sl@0: TBool containInvalidExtIf = EFalse; sl@0: TBool useDefResolver = ETrue; sl@0: TBool useInitParam = EFalse; sl@0: TUid KExample10ImplementationUid = {0x10009E38}; sl@0: sl@0: test.Printf(_L("Loading Plugin...")); sl@0: // Test create implementation by pass in instance key. sl@0: CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: REComSession::DestroyedImplementation(instanceKey); sl@0: delete dllPtr; sl@0: sl@0: // Test create implementation by pass in offset of the instance key. sl@0: dllPtr = CExampleInterface::NewL5(); sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: delete dllPtr; sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3586 sl@0: @SYMTestCaseDesc Tests for GetExtendedInterfaceL, Manual release sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create an implementation. Fetch two extended interfaces (one build in, and one sl@0: stand alone and requires release). Manually release the stand alone extended sl@0: interface. Destroy implementation. sl@0: @SYMTestExpectedResults Ensure that manual release releases the stand alone interface correctly. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void GetExtendedInterfaceTest4L() sl@0: { sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3586 ")); sl@0: test.Printf(_L("Loading Plugin...")); sl@0: const TUid KExample10ImplementationUid = {0x10009E38}; sl@0: sl@0: CExampleInterface* dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); sl@0: CleanupStack::PushL(dllPtr); sl@0: sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: // Call extended interface here. sl@0: const TUid KExample10InterfaceUid1 = {0x10009E44}; sl@0: const TUid KExample10InterfaceUid2 = {0x10009E45}; sl@0: sl@0: MExampleInterfaceExtended* ext1 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); sl@0: ext1->DoMethodExtended(); sl@0: sl@0: MExampleInterfaceExtended2* ext2 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid2)); sl@0: ext2->DoMethodExtended2(); sl@0: sl@0: dllPtr->ManuallyReleaseExtendedInterfaceL(KExample10InterfaceUid2); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: CleanupStack::Pop(dllPtr); sl@0: delete dllPtr; sl@0: sl@0: // Test Ends... sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-4001 sl@0: @SYMTestCaseDesc Tests GetExtendedInterfaceL with invalid instance keys sl@0: @SYMTestPriority High sl@0: @SYMTestActions Retrieve extended interface using unknown instance key sl@0: Retrieve extended interface using null instance key sl@0: @SYMTestExpectedResults Ensure that correct leaves occur. sl@0: @SYMDEF DEF111553 sl@0: */ sl@0: LOCAL_C void GetExtendedInterfaceTest5L() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-4001 ")); sl@0: // Test Starts... sl@0: TUid instanceKey; sl@0: TBool containInvalidExtIf = EFalse; sl@0: TBool useDefResolver = EFalse; sl@0: TBool useInitParam = ETrue; sl@0: sl@0: // get valid instance key by creating implementation sl@0: CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); sl@0: sl@0: // remove implementation sl@0: REComSession::DestroyedImplementation(instanceKey); sl@0: delete dllPtr; sl@0: sl@0: // Attempt to fetch extended interface with instance key that is no longer valid but sl@0: // passes the ASSERT test sl@0: const TUid KExtendedInterfaceUid = {0x10009E44}; sl@0: TRAPD(err, REComSession::GetExtendedInterfaceL(instanceKey,KExtendedInterfaceUid)); sl@0: test(err = KErrNotFound); sl@0: sl@0: // Attempt to fetch extended interface with null instance key sl@0: TRAP(err, REComSession::GetExtendedInterfaceL(KNullUid,KExtendedInterfaceUid)); sl@0: test(err = KErrArgument); sl@0: sl@0: // Test Ends... sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3581 sl@0: @SYMTestCaseDesc Tests for REComSession::ListExtendedInterfaces with a valid Implementation UID. sl@0: Tests also for non-existent Implementation UID and PLUGIN1 implementation UID. sl@0: Does some create and destruction of implementations before and after calling sl@0: ListExtendedInterfaces to mimic typical usage. sl@0: @SYMTestPriority High sl@0: @SYMTestActions List the extended interfaces. Check expected extended interfaces are returned. sl@0: Create an implementation. Ensure that Listing of the extended interface sl@0: still works after the create. sl@0: Delete the implementation. List extended interfaces again. sl@0: List the extended interfaces with a PLUGIN1 implementation UID. sl@0: @SYMTestExpectedResults Ensure all ListExtendedInterfaces calls return with expected extended interfaces. sl@0: @SYMEC EC43 sl@0: @SYMDEF DEF111196 sl@0: */ sl@0: LOCAL_C void ListExtendedInterfaceTestL() sl@0: { sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3581 ")); sl@0: const TUid KExample10ImplementationUid = {0x10009E38}; sl@0: const TUid KExample10ImplementationUid2 = {0x10009E3A}; sl@0: const TUid KExample10ImplementationUid3 = {0x10009E3B}; sl@0: sl@0: const TUid KExample10InterfaceUid1 = {0x10009E44}; sl@0: const TUid KExample10InterfaceUid2 = {0x10009E45}; sl@0: const TUid KExample10InterfaceUid3 = {0x10009E46}; sl@0: sl@0: const TUid KImpUidPLUGIN1 = {0x10009DC3}; sl@0: sl@0: RArray ifInfo; sl@0: CleanupClosePushL(ifInfo); sl@0: sl@0: REComSession::ListExtendedInterfacesL(KExample10ImplementationUid,ifInfo); sl@0: test(ifInfo.Count() == 3); sl@0: sl@0: // Checks that expected interfaces are in list. sl@0: test(ifInfo[0] == KExample10InterfaceUid1); sl@0: test(ifInfo[1] == KExample10InterfaceUid2); sl@0: test(ifInfo[2] == KExample10InterfaceUid3); sl@0: ifInfo.Reset(); sl@0: sl@0: // Creates an implementation sl@0: // Set up some empty initialisation parameters sl@0: test.Printf(_L("Loading Plugin...")); sl@0: sl@0: CExampleInterface* dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); sl@0: CleanupStack::PushL(dllPtr); sl@0: sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: // Calls extended interface here. sl@0: MExampleInterfaceExtended* ext1 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); sl@0: ext1->DoMethodExtended(); sl@0: sl@0: MExampleInterfaceExtended2* ext2 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid2)); sl@0: ext2->DoMethodExtended2(); sl@0: sl@0: // Checks that ListExtendedInterfaces works after a Create Implementation sl@0: REComSession::ListExtendedInterfacesL(KExample10ImplementationUid,ifInfo); sl@0: test(ifInfo.Count() == 3); sl@0: sl@0: // Checks that expected interfaces are in list. sl@0: test(ifInfo[0] == KExample10InterfaceUid1); sl@0: test(ifInfo[1] == KExample10InterfaceUid2); sl@0: test(ifInfo[2] == KExample10InterfaceUid3); sl@0: ifInfo.Reset(); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: CleanupStack::Pop(dllPtr); sl@0: sl@0: delete dllPtr; sl@0: sl@0: // Test fetch of extended interfaces for an implementation that has no extended interfaces sl@0: REComSession::ListExtendedInterfacesL(KExample10ImplementationUid2,ifInfo); sl@0: test(ifInfo.Count() == 0); sl@0: ifInfo.Reset(); sl@0: sl@0: // Test fetch of extended interfaces for an implementation that does not exist sl@0: TRAPD(err,REComSession::ListExtendedInterfacesL(KNullUid,ifInfo)); sl@0: TEST_OOM_ERR; sl@0: test(err == KErrNotFound); sl@0: ifInfo.Reset(); sl@0: sl@0: // Test fetch of extended interfaces for an implementation that has one extended interface sl@0: REComSession::ListExtendedInterfacesL(KExample10ImplementationUid3,ifInfo); sl@0: test(ifInfo.Count() == 1); sl@0: ifInfo.Reset(); sl@0: sl@0: // Test fetch of extended interfaces for an implementation with PLUGIN1 IIC that has no extended interfaces sl@0: REComSession::ListExtendedInterfacesL(KImpUidPLUGIN1,ifInfo); sl@0: test(ifInfo.Count() == 0); sl@0: ifInfo.Reset(); sl@0: sl@0: // Close array, finished with it. sl@0: CleanupStack::PopAndDestroy(&ifInfo); sl@0: // Test Ends... sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3596 sl@0: @SYMTestCaseDesc Try to load a PLUGIN3 DLL with a version one resource file. Also try to load a PLUGIN1 DLL sl@0: with a version three resource file. Tests UID mismatch specified in the DLL .mmp file and sl@0: the resource type in the resource file. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create an implementation using the invalid plugin. sl@0: @SYMTestExpectedResults The plugin should not have been loaded due to a UID1 mismatch. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void CreateImplementationTest1() sl@0: { sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3596 ")); sl@0: TUid instanceKey; sl@0: sl@0: // Set up some empty initialisation parameters sl@0: CExampleInterface::TExampleInterfaceInitParams initParams; sl@0: initParams.integer = 0; sl@0: initParams.descriptor = NULL; sl@0: sl@0: test.Printf(_L("Loading Plugin...")); sl@0: sl@0: // Interface with NULL get and release function pointers sl@0: const TUid KExample12InvalidDllImplementationUid = {0x10009E39}; sl@0: sl@0: TRAPD(err, TAny* dllPtr = REComSession::CreateImplementationL(KExample12InvalidDllImplementationUid,instanceKey,&initParams)); sl@0: sl@0: // The plugin should not have been loaded due to a UID1 mismatch. This is specified as the resource sl@0: // type in the resource file and UID1 in the DLL itself. sl@0: test(err==KErrNotFound); sl@0: sl@0: // Load a PLUGIN1 DLL with a version three resource file sl@0: const TUid KExample14InvalidDllImplementationUid = {0x10009E48}; sl@0: sl@0: TRAP(err, TAny* dllPtr = REComSession::CreateImplementationL(KExample14InvalidDllImplementationUid,instanceKey,&initParams)); sl@0: sl@0: // The plugin should not have been loaded due to a UID1 mismatch. This is specified as the resource sl@0: // type in the resource file and UID1 in the DLL itself. sl@0: test(err==KErrNotFound); sl@0: // Test Ends... sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3585 sl@0: @SYMTestCaseDesc Get and release extended interfaces in cases in which both get and release function pointers sl@0: do not exist. The tests will be: sl@0: 1) Get/release function pointers are NULL sl@0: 2) Only get function, no release function sl@0: 3) Test with a PLUGIN1 DLL (get/release function pointers should be NULL) sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create an implementation. sl@0: Try getting and releasing interfaces even though no get and release function pointers exist sl@0: Test with get extended interface function pointer and no release function pointer sl@0: @SYMTestExpectedResults NULL should be returned if get and release function pointers do not exist sl@0: Releasing an interface that has no release function pointer should finish with sl@0: no errors. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void ReleaseExtendedInterfaceTest1L() sl@0: { sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3585 ")); sl@0: test.Printf(_L("Loading Plugin...")); sl@0: // Interface with NULL get and release function pointers sl@0: const TUid KExample10ImplementationUid = {0x10009E3A}; sl@0: sl@0: CExampleInterface* dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); sl@0: CleanupStack::PushL(dllPtr); sl@0: sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: // Call extended interface here. sl@0: const TUid KExample10InterfaceUid1 = {0x10009E44}; sl@0: const TUid KExample10InterfaceUid2 = {0x10009E45}; sl@0: sl@0: // Try getting and releasing interfaces even though no get and release function pointers exist sl@0: MExampleInterfaceExtended* ext1 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); sl@0: test(ext1 == NULL); sl@0: sl@0: MExampleInterfaceExtended2* ext2 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid2)); sl@0: test(ext2 == NULL); sl@0: sl@0: dllPtr->ManuallyReleaseExtendedInterfaceL(KExample10InterfaceUid2); sl@0: sl@0: test.Printf(_L("Destroying Plugin 1...")); sl@0: CleanupStack::Pop(dllPtr); sl@0: delete dllPtr; sl@0: sl@0: // Test with get extended interface function pointer and no release function pointer sl@0: const TUid KExample10ImplementationUidNoRelease = {0x10009E3B}; sl@0: sl@0: dllPtr = CExampleInterface::NewL2(KExample10ImplementationUidNoRelease); sl@0: CleanupStack::PushL(dllPtr); sl@0: sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUidNoRelease); sl@0: test(KExample10ImplementationUidNoRelease == dllPtr->ImplId()); sl@0: sl@0: // Try releasing interfaces even though no release function pointer exists sl@0: MExampleInterfaceExtended* ext = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); sl@0: ext->DoMethodExtended(); sl@0: sl@0: // This should do nothing sl@0: dllPtr->ManuallyReleaseExtendedInterfaceL(KExample10InterfaceUid1); sl@0: sl@0: test.Printf(_L("Destroying Plugin 2...")); sl@0: CleanupStack::Pop(dllPtr); sl@0: delete dllPtr; sl@0: sl@0: // PLUGIN1 test. Try getting and releasing interfaces even though no get and release function pointers exist. sl@0: dllPtr = CExampleInterface::NewL2(KCExampleImplUid); sl@0: CleanupStack::PushL(dllPtr); sl@0: sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KCExampleImplUid); sl@0: test(KCExampleImplUid == dllPtr->ImplId()); sl@0: sl@0: // Call extended interface here. sl@0: // Try getting and releasing interfaces even though no get and release function pointers exist sl@0: MExampleInterfaceExtended* ext3 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); sl@0: test(ext3 == NULL); sl@0: sl@0: // Nothing should happen when releasing an extended interface for a PLUGIN1 DLL sl@0: dllPtr->ManuallyReleaseExtendedInterfaceL(KExample10InterfaceUid1); sl@0: sl@0: test.Printf(_L("Destroying Plugin 3...")); sl@0: CleanupStack::Pop(dllPtr); sl@0: delete dllPtr; sl@0: // Test Ends... sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-4002 sl@0: @SYMTestCaseDesc Tests ManuallyReleaseExtendedInterfaceL with invalid instance keys sl@0: @SYMTestPriority High sl@0: @SYMTestActions Manually release extended interface using unknown instance key sl@0: Manually release extended interface using null instance key sl@0: @SYMTestExpectedResults Ensure that correct leaves occur. sl@0: @SYMDEF DEF111553 sl@0: */ sl@0: LOCAL_C void ReleaseExtendedInterfaceTest2L() sl@0: { sl@0: // Test Starts... sl@0: // get valid instance key by creating implementation sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-4002 ")); sl@0: const TUid KExample10ImplementationUid = {0x10009E3A}; sl@0: TUid instanceKey; sl@0: TAny* impl = REComSession::CreateImplementationL(KExample10ImplementationUid, instanceKey, 0); sl@0: sl@0: // remove implementation sl@0: REComSession::DestroyedImplementation(instanceKey); sl@0: delete impl; sl@0: sl@0: // Attempt to manually release extended interface with instance key that is no longer valid but sl@0: // passes the ASSERT test sl@0: const TUid KExample10InterfaceUid1 = {0x10009E44}; sl@0: TRAPD(err, REComSession::ManuallyReleaseExtendedInterfaceL(instanceKey,KExample10InterfaceUid1)); sl@0: test(err = KErrNotFound); sl@0: sl@0: // Attempt to manually release extended interface with null instance key sl@0: TRAP(err, REComSession::GetExtendedInterfaceL(KNullUid,KExample10InterfaceUid1)); sl@0: test(err = KErrArgument); sl@0: // Test Ends... sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3584 sl@0: @SYMTestCaseDesc Tests for GetExtendedInterfaceL, fetching an invalid extended interface sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create an implementation. Fetch two extended interfaces (one build in, and one sl@0: stand alone and requires release). Fetch an invalid extended interface. Destroy implementation. sl@0: @SYMTestExpectedResults Ensure that the GetExtendedInterfaceL call with the invalid interface returns NULL. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void GetExtendedInterfaceTest3L() sl@0: { sl@0: // sl@0: // Testing a overloaded method for CreateImplementationL sl@0: // ------------------------------------------------------------------ sl@0: // sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3584 ")); sl@0: test.Printf(_L("Loading Plugin...")); sl@0: const TUid KExample10ImplementationUid = {0x10009E38}; sl@0: sl@0: CExampleInterface* dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); sl@0: CleanupStack::PushL(dllPtr); sl@0: sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: // Call extended interface here. sl@0: const TUid KExample10InterfaceUid1 = {0x10009E44}; sl@0: const TUid KExample10InterfaceUid2 = {0x10009E45}; sl@0: const TUid KExample10InvalidInterfaceUid = {0x10009E49}; sl@0: sl@0: MExampleInterfaceExtended* ext1 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); sl@0: ext1->DoMethodExtended(); sl@0: sl@0: MExampleInterfaceExtended2* ext2 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid2)); sl@0: ext2->DoMethodExtended2(); sl@0: sl@0: // Get an invalid extended interface. sl@0: MExampleInterfaceExtended2* ext2invalid = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InvalidInterfaceUid)); sl@0: // No interface should be returned if it is not found. sl@0: test(ext2invalid == NULL); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: CleanupStack::Pop(dllPtr); sl@0: delete dllPtr; sl@0: sl@0: // Test Ends... sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3583 sl@0: @SYMTestCaseDesc Tests for GetExtendedInterfaceL, with an invalid instance key. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Call REComSession::GetExtendedInterfaceL() with an invalid instance key. sl@0: GetExtendedInterfacePanic() and ThreadPanicTest() are used for this test case. sl@0: @SYMTestExpectedResults Ensure that the GetExtendedInterfaceL panics in debug mode and leaves in release sl@0: mode. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void GetExtendedInterfaceTest2L() sl@0: { sl@0: // Test Starts... sl@0: TUid instanceKey; sl@0: TBool containInvalidExtIf = EFalse; sl@0: TBool useDefResolver = EFalse; sl@0: TBool useInitParam = ETrue; sl@0: sl@0: CExampleInterface* dllPtr = CreateImplementationTestL(containInvalidExtIf,useDefResolver,useInitParam,instanceKey); sl@0: CleanupStack::PushL(dllPtr); sl@0: sl@0: const TUid KExtendedInterfaceUid = {0x10009E44}; sl@0: TUid invalidInstanceKey; sl@0: invalidInstanceKey.iUid = instanceKey.iUid + 1; sl@0: sl@0: // Fetches an extended interface with invalid instance key. sl@0: // When passed an invalid instance key, REComSession::GetExtendedInterfaceL() panics sl@0: // with KErrArgument in debug mode, but leaves with KErrNotFound in release mode. sl@0: MExampleInterfaceExtended* ext1 = static_cast(REComSession::GetExtendedInterfaceL(invalidInstanceKey,KExtendedInterfaceUid)); sl@0: sl@0: REComSession::DestroyedImplementation(instanceKey); sl@0: CleanupStack::PopAndDestroy(dllPtr); sl@0: sl@0: // Test Ends... sl@0: } sl@0: sl@0: /** sl@0: A thread function. sl@0: Panics in debug mode. sl@0: Returns an error code in release mode. sl@0: */ sl@0: LOCAL_C TInt GetExtendedInterfacePanic(TAny*) sl@0: { sl@0: __UHEAP_MARK; sl@0: CTrapCleanup* threadcleanup = CTrapCleanup::New(); sl@0: sl@0: // In debug mode, GetExtendedInterfaceTest2L panics with reason KErrArgument. sl@0: // In release mode, it leaves with KErrNotFound. sl@0: TRAPD(err, GetExtendedInterfaceTest2L()); sl@0: sl@0: delete threadcleanup; sl@0: __UHEAP_MARKEND; sl@0: sl@0: return err; sl@0: } sl@0: sl@0: /** sl@0: The test code is used for capturing the PANIC that occurs as a result of calling GetExtendedInterfaceL sl@0: with an invalid instance key. sl@0: */ sl@0: LOCAL_C void ThreadPanicTest(const TDesC& aName,TThreadFunction aFunction) sl@0: { sl@0: test.Next(aName); sl@0: TRequestStatus threadStatus; sl@0: RThread thread; sl@0: TBool jit; sl@0: jit=User::JustInTime(); sl@0: User::SetJustInTime(EFalse); sl@0: sl@0: TInt err=thread.Create(aName,aFunction,KDefaultStackSize*8,KMinHeapSize,0x100000,0); sl@0: test(err==KErrNone); sl@0: thread.Logon(threadStatus) ; sl@0: thread.Resume(); sl@0: sl@0: User::WaitForRequest(threadStatus); sl@0: sl@0: // Different verifications for debug and release mode. sl@0: #ifdef _DEBUG sl@0: test(thread.ExitType()==EExitPanic); sl@0: test(thread.ExitReason()==EEComPanic_InvalidImplementationInstanceKey); sl@0: #else sl@0: test(thread.ExitType()==EExitKill); sl@0: test(thread.ExitReason()==KErrNotFound); sl@0: #endif sl@0: sl@0: thread.Close(); sl@0: User::SetJustInTime(jit); sl@0: } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-3582 sl@0: @SYMTestCaseDesc Tests for GetExtendedInterfaceL, stand alone and built in extended interfaces with sl@0: valid instance keys. sl@0: @SYMTestPriority High sl@0: @SYMTestActions Create an implementation. Fetch two extended interfaces (one build in, and one sl@0: stand alone and requires release). Call extended interfaces. Destroy implementation. sl@0: Re-create the same implementation again. Fetch extended interface. Destroy implementation. sl@0: Re-create again. Fetch two extended interfaces (both being stand alone and sl@0: require release). sl@0: @SYMTestExpectedResults Ensure that Extended interfaces can be created, called and cleaned up when sl@0: implementation is destroyed. sl@0: @SYMEC EC43 sl@0: */ sl@0: LOCAL_C void GetExtendedInterfaceTest1L() sl@0: { sl@0: // Test Starts... sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3582 ")); sl@0: test.Printf(_L("Loading Plugin...")); sl@0: const TUid KExample10ImplementationUid = {0x10009E38}; sl@0: sl@0: CExampleInterface* dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); sl@0: CleanupStack::PushL(dllPtr); sl@0: sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: // Calls extended interface here. sl@0: const TUid KExample10InterfaceUid1 = {0x10009E44}; sl@0: const TUid KExample10InterfaceUid2 = {0x10009E45}; sl@0: sl@0: // Fetches an extended interface. sl@0: MExampleInterfaceExtended* ext1 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); sl@0: // Sanity check by calling extended interface. sl@0: ext1->DoMethodExtended(); sl@0: sl@0: // Fetches an extended interface. Stand alone interface. sl@0: MExampleInterfaceExtended2* ext2 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid2)); sl@0: // Sanity check by calling extended interface. sl@0: ext2->DoMethodExtended2(); sl@0: sl@0: // Delete implementation, this will automatically destroy the stand alone interface. sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: CleanupStack::Pop(dllPtr); sl@0: delete dllPtr; sl@0: sl@0: // Test to ensure that a new interface can be re-created immediately after deletion. This sl@0: // also tests that no problems occur when no extended interfaces require releasing yet sl@0: // a release function exists in the plug-in implementation. sl@0: dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); sl@0: CleanupStack::PushL(dllPtr); sl@0: sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: // Ensure that the extended interface can also be fetched again sl@0: MExampleInterfaceExtended* ext = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid1)); sl@0: ext->DoMethodExtended(); sl@0: sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: CleanupStack::Pop(dllPtr); sl@0: delete dllPtr; sl@0: sl@0: // Re-creates implementation. This time create two extended interfaces that require release sl@0: dllPtr = CExampleInterface::NewL2(KExample10ImplementationUid); sl@0: CleanupStack::PushL(dllPtr); sl@0: sl@0: test.Printf(_L("Found dll uid %x, required %x.\n"),dllPtr->ImplId(), KExample10ImplementationUid); sl@0: test(KExample10ImplementationUid == dllPtr->ImplId()); sl@0: sl@0: MExampleInterfaceExtended2* extension1 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid2)); sl@0: extension1->DoMethodExtended2(); sl@0: sl@0: const TUid KExample10InterfaceUid3 = {0x10009E46}; sl@0: sl@0: MExampleInterfaceExtended2* extension2 = static_cast(dllPtr->GetExtendedInterfaceL(KExample10InterfaceUid3)); sl@0: extension2->DoMethodExtended2(); sl@0: sl@0: // Destroy the implementation. This should automatically delete both extended interfaces above sl@0: test.Printf(_L("Destroying Plugin...")); sl@0: CleanupStack::Pop(dllPtr); sl@0: delete dllPtr; sl@0: // Test Ends... sl@0: } sl@0: sl@0: sl@0: typedef void (*ClassFuncPtrL) (void); sl@0: sl@0: /** sl@0: Wrapper function to call all test functions sl@0: @param testFuncL pointer to test function sl@0: @param aTestDesc test function name sl@0: */ sl@0: LOCAL_C void DoBasicTest(ClassFuncPtrL testFuncL, const TDesC& aTestDesc) sl@0: { sl@0: test.Next(aTestDesc); sl@0: sl@0: __UHEAP_MARK; sl@0: // find out the number of open handles sl@0: TInt pHCountStart; sl@0: TInt tHCountStart; sl@0: RThread().HandleCount(pHCountStart,tHCountStart); sl@0: sl@0: TRAPD(err, (*testFuncL)()); sl@0: test(KErrNone == err); sl@0: sl@0: // release handles sl@0: REComSession::FinalClose(); sl@0: sl@0: // check that no handles have leaked sl@0: TInt pHCountEnd; sl@0: TInt tHCountEnd; sl@0: RThread().HandleCount(pHCountEnd,tHCountEnd); sl@0: sl@0: test(pHCountStart == pHCountEnd); sl@0: test(tHCountStart == tHCountEnd); sl@0: test.Printf(_L("Great ! No handle mismatch.")); sl@0: sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: /** sl@0: Wrapper function to call all OOM test functions sl@0: @param testFuncL pointer to OOM test function sl@0: @param aTestDesc test function name sl@0: */ sl@0: LOCAL_C void DoOOMTest(ClassFuncPtrL testFuncL, const TDesC& aTestDesc) sl@0: { sl@0: test.Next(aTestDesc); sl@0: TInt err; sl@0: TInt failAt = 1; sl@0: sl@0: do sl@0: { sl@0: __UHEAP_MARK; sl@0: // find out the number of open handles sl@0: TInt pHCountStart; sl@0: TInt tHCountStart; sl@0: RThread().HandleCount(pHCountStart,tHCountStart); sl@0: sl@0: // Setting Heap failure for OOM test sl@0: __UHEAP_SETFAIL(RHeap::EDeterministic, failAt++); sl@0: sl@0: TRAP(err, (*testFuncL)()); sl@0: sl@0: __UHEAP_SETFAIL(RHeap::ENone, 0); sl@0: sl@0: // release handles sl@0: REComSession::FinalClose(); sl@0: sl@0: // check that no handles have leaked sl@0: TInt pHCountEnd; sl@0: TInt tHCountEnd; sl@0: RThread().HandleCount(pHCountEnd,tHCountEnd); sl@0: sl@0: test(pHCountStart == pHCountEnd); sl@0: test(tHCountStart == tHCountEnd); sl@0: test.Printf(_L("Great ! No handle mismatch.")); sl@0: sl@0: __UHEAP_MARKEND; sl@0: } while(err == KErrNoMemory); sl@0: sl@0: test(err == KErrNone); sl@0: test.Printf(_L("- server succeeded at heap failure rate of %i\n"), failAt); sl@0: } sl@0: sl@0: sl@0: void DoTests() sl@0: { sl@0: //Basic test... sl@0: test.Printf(_L("Basic tests...\n")); sl@0: sl@0: DoBasicTest(&GetExtendedInterfaceTest1L,_L("GetExtendedInterfaceTest1L")); sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3583 ")); sl@0: ThreadPanicTest(_L("GetExtendedInterface Panic Testing"),GetExtendedInterfacePanic); sl@0: DoBasicTest(&GetExtendedInterfaceTest3L,_L("GetExtendedInterfaceTest3L")); sl@0: DoBasicTest(&GetExtendedInterfaceTest4L,_L("GetExtendedInterfaceTest4L")); sl@0: DoBasicTest(&GetExtendedInterfaceTest5L,_L("GetExtendedInterfaceTest5L")); sl@0: DoBasicTest(&ReleaseExtendedInterfaceTest1L,_L("ReleaseExtendedInterfaceTest1L")); sl@0: DoBasicTest(&ReleaseExtendedInterfaceTest2L,_L("ReleaseExtendedInterfaceTest2L")); sl@0: DoBasicTest(&ListExtendedInterfaceTestL,_L("ListExtendedInterfaceTestL")); sl@0: sl@0: DoBasicTest(&CreateImplementationTest1,_L("CreateImplementationTest1")); sl@0: DoBasicTest(&CreateImplementationTest2L,_L("CreateImplementationTest2L")); sl@0: DoBasicTest(&CreateImplementationTest3L,_L("CreateImplementationTest3L")); sl@0: DoBasicTest(&CreateImplementationTest4L,_L("CreateImplementationTest4L")); sl@0: DoBasicTest(&CreateImplementationTest5L,_L("CreateImplementationTest5L")); sl@0: DoBasicTest(&CreateImplementationTest6,_L("CreateImplementationTest6")); sl@0: DoBasicTest(&CreateImplementationTest7L,_L("CreateImplementationTest7L")); sl@0: DoBasicTest(&DestroyedImplementationTestL,_L("DestroyedImplementationTestL")); sl@0: sl@0: DoBasicTest(&ListImplementationTest1L,_L("ListImplementationTest1L")); sl@0: DoBasicTest(&ListImplementationTest2L,_L("ListImplementationTest2L")); sl@0: DoBasicTest(&ListImplementationTest3L,_L("ListImplementationTest3L")); sl@0: DoBasicTest(&ListImplementationTest4L,_L("ListImplementationTest4L")); sl@0: DoBasicTest(&ListImplementationTest5L,_L("ListImplementationTest5L")); sl@0: sl@0: DoBasicTest(&DummyUidTestL,_L("CreateImplementation and ListImplementation Dummy UID test")); sl@0: sl@0: // OOM test... sl@0: test.Printf(_L("OOM tests...\n")); sl@0: sl@0: DoOOMTest(&GetExtendedInterfaceTest1L,_L("OOM GetExtendedInterfaceTest1L")); sl@0: // GetExtendedInterfaceTest2L is a special test case, cannot do OOM testing. sl@0: DoOOMTest(&GetExtendedInterfaceTest3L,_L("OOM GetExtendedInterfaceTest3L")); sl@0: DoOOMTest(&GetExtendedInterfaceTest4L,_L("OOM GetExtendedInterfaceTest4L")); sl@0: DoOOMTest(&GetExtendedInterfaceTest5L,_L("OOM GetExtendedInterfaceTest5L")); sl@0: DoOOMTest(&ReleaseExtendedInterfaceTest1L,_L("OOM ReleaseExtendedInterfaceTest1L")); sl@0: DoOOMTest(&ReleaseExtendedInterfaceTest2L,_L("OOM ReleaseExtendedInterfaceTest2L")); sl@0: DoOOMTest(&ListExtendedInterfaceTestL,_L("OOM ListExtendedInterfaceTestL")); sl@0: sl@0: // CreateImplementationTest1 is a special test case, cannot do OOM testing. sl@0: DoOOMTest(&CreateImplementationTest2L,_L("OOM CreateImplementationTest2L")); sl@0: DoOOMTest(&CreateImplementationTest3L,_L("OOM CreateImplementationTest3L")); sl@0: DoOOMTest(&CreateImplementationTest4L,_L("OOM CreateImplementationTest4L")); sl@0: DoOOMTest(&CreateImplementationTest5L,_L("OOM CreateImplementationTest5L")); sl@0: // CreateImplementationTest6 is a special test case, cannot do OOM testing. sl@0: DoOOMTest(&CreateImplementationTest7L,_L("OOM CreateImplementationTest7L")); sl@0: DoOOMTest(&DestroyedImplementationTestL,_L("OOM DestroyedImplementationTestL")); sl@0: sl@0: DoOOMTest(&ListImplementationTest1L,_L("OOM ListImplementationTest1L")); sl@0: DoOOMTest(&ListImplementationTest2L,_L("OOM ListImplementationTest2L")); sl@0: DoOOMTest(&ListImplementationTest3L,_L("OOM ListImplementationTest3L")); sl@0: DoOOMTest(&ListImplementationTest4L,_L("OOM ListImplementationTest4L")); sl@0: DoOOMTest(&ListImplementationTest5L,_L("OOM ListImplementationTest5L")); sl@0: } sl@0: sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: test.Title(); sl@0: sl@0: test.Start(_L("ExtendedInterfaces tests.")); sl@0: sl@0: // get clean-up stack sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: sl@0: //The reason for the folowing delay is: sl@0: //ECOM server could be already started. It means that when we copy some sl@0: //ECOM plugins from Z: to C: drive - ECOM server should look for and sl@0: //find the new ECOM plugins. The ECOM server uses for that CDiscoverer::CIdleScanningTimer sl@0: //which is an active object. So the discovering service is asynchronous. We have to sl@0: //wait some time until it finishes. Otherwise ListImplementationsL could fail to find sl@0: //requested implementations. sl@0: User::After(KOneSecond * 5); sl@0: sl@0: DoTests(); sl@0: sl@0: delete cleanup; sl@0: sl@0: test.End(); sl@0: test.Close(); sl@0: __UHEAP_MARKEND; sl@0: return(0); sl@0: }