sl@0: // Copyright (c) 1997-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: // This test assumes the following setup: sl@0: // EComRomRslvrExampleOnC on C: sl@0: // EComRomRslvrExampleOnZ on Z: sl@0: // The tests work by checking that the correct implementations are chosen from two plug-ins, one on C:, one on Z: sl@0: // Implementation: On C: On Z: Expected result: sl@0: // 10009DC6 version 2 version 1 ROM resolver selects version 2 on C: sl@0: // 10009DC7 version 1 version 2 ROM resolver selects version 2 on Z: sl@0: // 10009DCF version 1 - ROM resolver does not return this sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: 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: TUid KUidInterface = {0x10009DC8}; sl@0: const TInt KUidImplementationAValue = 0x10009DC6; sl@0: const TInt KUidImplementationBValue = 0x10009DC7; sl@0: const TInt KUidImplementationCValue = 0x10009DCF; sl@0: const TInt KOneSecond = 1000000; sl@0: sl@0: LOCAL_D RTest test(_L("t_romresolver.exe")); sl@0: sl@0: _LIT(KEComPlugin2OnZ, "z:\\RAMOnly\\EComRomRslvrExampleOnC.dll"); sl@0: sl@0: _LIT(KEComPluginRsc2OnZ, "z:\\RAMOnly\\EComRomRslvrExampleOnC.rsc"); sl@0: _LIT(KEComPlugin2OnC, "c:\\sys\\bin\\EComRomRslvrExampleOnC.dll"); sl@0: _LIT(KEComPluginRsc2OnC, "c:\\resource\\plugins\\EComRomRslvrExampleOnC.rsc"); sl@0: sl@0: sl@0: class TheTest sl@0: { sl@0: public: sl@0: void StartTestL(); sl@0: }; sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-0663 sl@0: @SYMTestCaseDesc Tests for REComSession::ListImplementationsL() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for interface implementation data sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestDefaultResolverL() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0663 TestDefaultResolverL ")); sl@0: sl@0: // sl@0: // Testing a overloaded method for ListImplementationsL sl@0: // ------------------------------------------------------------------ sl@0: // sl@0: sl@0: // Set up for heap leak checking sl@0: __UHEAP_MARK; sl@0: sl@0: // and leaking thread handles sl@0: TInt startProcessHandleCount; sl@0: TInt startThreadHandleCount; sl@0: TInt endProcessHandleCount; sl@0: TInt endThreadHandleCount; sl@0: // Test Starts... sl@0: sl@0: RThread thisThread; sl@0: thisThread.HandleCount(startProcessHandleCount, startThreadHandleCount); sl@0: sl@0: RImplInfoPtrArray ifArray; sl@0: sl@0: TEComResolverParams ResolverParams; sl@0: _LIT8(KImplementationTest,"text/wml"); sl@0: ResolverParams.SetDataType(KImplementationTest()); sl@0: ResolverParams.SetWildcardMatch(ETrue); // Allow wildcard matching sl@0: sl@0: REComSession::ListImplementationsL( sl@0: KUidInterface, sl@0: ResolverParams, sl@0: KDefaultResolverUid, sl@0: ifArray); sl@0: sl@0: const TInt availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount==3); sl@0: sl@0: for (TInt count=0;countDrive().Name(); sl@0: test.Printf(_L("%d. uid={%x} version=%d on drive %S\n"), count+1, info->ImplementationUid(), info->Version(), &driveName); sl@0: sl@0: switch(info->ImplementationUid().iUid) sl@0: { sl@0: case KUidImplementationAValue: sl@0: test(info->Version()==1); sl@0: test(info->Drive()==EDriveZ); sl@0: break; sl@0: sl@0: case KUidImplementationBValue: sl@0: test(info->Version()==2); sl@0: test(info->Drive()==EDriveZ); sl@0: break; sl@0: sl@0: case KUidImplementationCValue: sl@0: test(info->Version()==1); sl@0: test(info->Drive()==EDriveC); sl@0: break; sl@0: sl@0: default: sl@0: test.Printf(_L("Unknown implementation UID\n")); sl@0: test(0); sl@0: } 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: REComSession::FinalClose(); // Don't want leaks outside the test sl@0: sl@0: // Check for open handles sl@0: thisThread.HandleCount(endProcessHandleCount, endThreadHandleCount); sl@0: sl@0: test(startThreadHandleCount == endThreadHandleCount); sl@0: test.Printf(_L("Great ! No handle mismatch.")); sl@0: sl@0: // Test Ends... sl@0: sl@0: __UHEAP_MARKEND; } sl@0: sl@0: /** sl@0: @SYMTestCaseID SYSLIB-ECOM-CT-0664 sl@0: @SYMTestCaseDesc Tests for REComSession::ListImplementationsL() function sl@0: @SYMTestPriority High sl@0: @SYMTestActions Tests for interface implementation data sl@0: @SYMTestExpectedResults The test must not fail. sl@0: @SYMREQ REQ0000 sl@0: */ sl@0: LOCAL_C void TestRomResolverL() sl@0: { sl@0: test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0664 TestRomResolverL ")); sl@0: sl@0: // sl@0: // Testing a overloaded method for ListImplementationsL sl@0: // ------------------------------------------------------------------ sl@0: // sl@0: sl@0: // Set up for heap leak checking sl@0: __UHEAP_MARK; sl@0: sl@0: // and leaking thread handles sl@0: TInt startProcessHandleCount; sl@0: TInt startThreadHandleCount; sl@0: TInt endProcessHandleCount; sl@0: TInt endThreadHandleCount; sl@0: // Test Starts... sl@0: sl@0: RThread thisThread; sl@0: thisThread.HandleCount(startProcessHandleCount, startThreadHandleCount); sl@0: sl@0: RImplInfoPtrArray ifArray; sl@0: sl@0: TEComResolverParams ResolverParams; sl@0: _LIT8(KImplementationTest,"text/wml"); sl@0: ResolverParams.SetDataType(KImplementationTest()); sl@0: ResolverParams.SetWildcardMatch(ETrue); // Allow wildcard matching sl@0: sl@0: REComSession::ListImplementationsL( sl@0: KUidInterface, sl@0: ResolverParams, sl@0: KRomOnlyResolverUid, sl@0: ifArray); sl@0: sl@0: const TInt availCount = ifArray.Count(); sl@0: test.Printf(_L("Found %d implementations.\n"),availCount); sl@0: test(availCount == 2); sl@0: sl@0: for (TInt count=0;countDrive().Name(); sl@0: test.Printf(_L("%d. uid={%x} version=%d on drive %S\n"), count+1, info->ImplementationUid(), info->Version(), &driveName); sl@0: sl@0: switch(info->ImplementationUid().iUid) sl@0: { sl@0: case KUidImplementationAValue: sl@0: test(info->Version()==1); sl@0: test(info->Drive()==EDriveZ); sl@0: break; sl@0: sl@0: case KUidImplementationBValue: sl@0: test(info->Version()==2); sl@0: test(info->Drive()==EDriveZ); sl@0: break; sl@0: sl@0: default: sl@0: test.Printf(_L("Unknown implementation UID\n")); sl@0: test(0); sl@0: } 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: REComSession::FinalClose(); // Don't want leaks outside the test sl@0: sl@0: // Check for open handles sl@0: thisThread.HandleCount(endProcessHandleCount, endThreadHandleCount); sl@0: sl@0: test(startThreadHandleCount == endThreadHandleCount); sl@0: test.Printf(_L("Great ! No handle mismatch.")); sl@0: sl@0: // Test Ends... sl@0: sl@0: __UHEAP_MARKEND; } sl@0: sl@0: LOCAL_C void TestListImplementationL() sl@0: { sl@0: TestDefaultResolverL(); sl@0: TestRomResolverL(); sl@0: } sl@0: sl@0: void TheTest::StartTestL() sl@0: { sl@0: TestListImplementationL(); sl@0: } sl@0: sl@0: TInt DoTestsL() sl@0: { sl@0: // Should any tests leave past the lowest level??? sl@0: TheTest theT; sl@0: theT.StartTestL(); sl@0: return KErrNone; sl@0: } sl@0: sl@0: void CopyFiles() sl@0: { sl@0: TRAPD(err, EComTestUtils::FileManCopyFileL(KEComPlugin2OnZ, KEComPlugin2OnC)); sl@0: test(err==KErrNone); sl@0: sl@0: TRAP(err, EComTestUtils::FileManCopyFileL(KEComPluginRsc2OnZ, KEComPluginRsc2OnC)); sl@0: test(err==KErrNone); sl@0: } sl@0: sl@0: void CleanupFiles() sl@0: { sl@0: TRAPD(err, EComTestUtils::FileManDeleteFileL(KEComPlugin2OnC)); sl@0: TRAP(err, EComTestUtils::FileManDeleteFileL(KEComPluginRsc2OnC)); sl@0: } sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: test.Title(); sl@0: test.Start(_L("Rom resolver tests")); sl@0: sl@0: // get clean-up stack sl@0: CTrapCleanup* cleanup = CTrapCleanup::New(); sl@0: sl@0: CopyFiles(); 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 * 3); sl@0: sl@0: TRAPD(err,DoTestsL()); sl@0: sl@0: delete cleanup; sl@0: sl@0: test(err==KErrNone); sl@0: sl@0: CleanupFiles(); sl@0: sl@0: test.Next(_L("/n")); sl@0: test.End(); sl@0: test.Close(); sl@0: __UHEAP_MARKEND; sl@0: return(0); sl@0: }