1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/Framework/RomOnlyTest/t_romonly.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,220 @@
1.4 +// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// This test assumes the following setup:
1.18 +// EComRomOnlyExampleOnC/10009DB6 on C:
1.19 +// EComRomOnlyExampleOnZ/10009DB5 on Z:
1.20 +// The tests work by checking that the correct implementations are chosen from two plug-ins, one on C:, one on Z:
1.21 +// Implementation: On C: On Z: Expected result:
1.22 +// 10009DCA version 2 version 1, not ROM-only ECom selects version 2 on C:
1.23 +// 10009DCB version 2, ROM-only f version 1, not ROM-only ECom selects version 1 on Z:
1.24 +// 10009DCC version 1 version 2, not ROM-only ECom selects version 2 on Z:
1.25 +// 10009DCD version 2 version 1, ROM-only ECom selects version 1 on Z:
1.26 +// 10009DCE version 1 version 2, ROM-only ECom selects version 2 on Z:
1.27 +// 10009DCF version 3 version 1 & version 2, ROM-only ECom selects version 2 on Z:
1.28 +//
1.29 +//
1.30 +
1.31 +
1.32 +#include <e32test.h>
1.33 +#include <f32file.h>
1.34 +#include <bautils.h>
1.35 +
1.36 +#include <ecom/ecom.h>
1.37 +#include "EComUidCodes.h"
1.38 +#include "Interface.h" // interface to Plugins
1.39 +#include "../EcomTestUtils/EcomTestUtils.h"
1.40 +
1.41 +const TUid KUidInterface = {0x10009DC9};
1.42 +const TInt KUidImplementationAValue = 0x10009DCA;
1.43 +const TInt KUidImplementationBValue = 0x10009DCB;
1.44 +const TInt KUidImplementationCValue = 0x10009DCC;
1.45 +const TInt KUidImplementationDValue = 0x10009DCD;
1.46 +const TInt KUidImplementationEValue = 0x10009DCE;
1.47 +const TInt KUidImplementationFValue = 0x10009DCF;
1.48 +const TInt KOneSecond = 1000000;
1.49 +
1.50 +LOCAL_D RTest test(_L("t_romonly.exe"));
1.51 +
1.52 +_LIT(KEComPluginOnZ, "z:\\RAMOnly\\EComRomOnlyExampleOnC.dll");
1.53 +
1.54 +_LIT(KEComPluginOnC, "c:\\sys\\bin\\EComRomOnlyExampleOnC.dll");
1.55 +_LIT(KEComPluginRscOnZ, "z:\\RAMOnly\\EComRomOnlyExampleOnC.rsc");
1.56 +_LIT(KEComPluginRscOnC, "c:\\resource\\plugins\\EComRomOnlyExampleOnC.rsc");
1.57 +
1.58 +class TheTest
1.59 + {
1.60 +public:
1.61 + void StartTestL();
1.62 + };
1.63 +
1.64 +void CopyFiles()
1.65 + {
1.66 + TRAPD(err, EComTestUtils::FileManCopyFileL(KEComPluginOnZ, KEComPluginOnC));
1.67 + test(err==KErrNone);
1.68 +
1.69 + TRAP(err, EComTestUtils::FileManCopyFileL(KEComPluginRscOnZ, KEComPluginRscOnC));
1.70 + test(err==KErrNone);
1.71 + }
1.72 +
1.73 +void CleanupFiles()
1.74 + {
1.75 + TRAPD(err, EComTestUtils::FileManDeleteFileL(KEComPluginOnC));
1.76 + TRAP(err, EComTestUtils::FileManDeleteFileL(KEComPluginRscOnC));
1.77 + }
1.78 +
1.79 +/**
1.80 +@SYMTestCaseID SYSLIB-ECOM-CT-0665
1.81 +@SYMTestCaseDesc Tests for REComSession::ListImplementationsL() function
1.82 +@SYMTestPriority High
1.83 +@SYMTestActions Checks that the correct implementations are chosen from two plug-ins, one on C:, one on Z:
1.84 +@SYMTestExpectedResults The test must not fail.
1.85 +@SYMREQ REQ0000
1.86 +*/
1.87 +LOCAL_C void TestImplementationsL()
1.88 + {
1.89 + test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0665 TestImplementationsL "));
1.90 +
1.91 + // Set up for heap leak checking
1.92 + __UHEAP_MARK;
1.93 +
1.94 + // and leaking thread handles
1.95 + TInt startProcessHandleCount;
1.96 + TInt startThreadHandleCount;
1.97 + TInt endProcessHandleCount;
1.98 + TInt endThreadHandleCount;
1.99 + // Test Starts...
1.100 +
1.101 + RThread thisThread;
1.102 + thisThread.HandleCount(startProcessHandleCount, startThreadHandleCount);
1.103 +
1.104 + RImplInfoPtrArray ifArray;
1.105 +
1.106 + TEComResolverParams ResolverParams;
1.107 + _LIT8(KImplementationTest,"text/wml");
1.108 + ResolverParams.SetDataType(KImplementationTest());
1.109 + ResolverParams.SetWildcardMatch(ETrue); // Allow wildcard matching
1.110 +
1.111 + REComSession::ListImplementationsL(
1.112 + KUidInterface,
1.113 + ResolverParams,
1.114 + KDefaultResolverUid,
1.115 + ifArray);
1.116 +
1.117 + const TInt availCount = ifArray.Count();
1.118 + test.Printf(_L("Found %d implementations.\n"),availCount);
1.119 + test(availCount == 6);
1.120 +
1.121 + for (TInt count=0;count<availCount;++count)
1.122 + {
1.123 + const CImplementationInformation* info = ifArray[count];
1.124 +
1.125 + TDriveName driveName = info->Drive().Name();
1.126 + test.Printf(_L("%d. uid={%x} version=%d on drive %S\n"), count+1, info->ImplementationUid(), info->Version(), &driveName);
1.127 +
1.128 + switch(info->ImplementationUid().iUid)
1.129 + {
1.130 + case KUidImplementationAValue:
1.131 + test(info->Version()==1);
1.132 + test(info->Drive()==EDriveZ);
1.133 + break;
1.134 +
1.135 + case KUidImplementationBValue:
1.136 + test(info->Version()==1);
1.137 + test(info->Drive()==EDriveZ);
1.138 + break;
1.139 +
1.140 + case KUidImplementationCValue:
1.141 + test(info->Version()==2);
1.142 + test(info->Drive()==EDriveZ);
1.143 + break;
1.144 +
1.145 + case KUidImplementationDValue:
1.146 + test(info->Version()==1);
1.147 + test(info->Drive()==EDriveZ);
1.148 + break;
1.149 +
1.150 + case KUidImplementationEValue:
1.151 + test(info->Version()==2);
1.152 + test(info->Drive()==EDriveZ);
1.153 + break;
1.154 +
1.155 + case KUidImplementationFValue:
1.156 + test(info->Version()==2);
1.157 + test(info->Drive()==EDriveZ);
1.158 + break;
1.159 + }
1.160 + }
1.161 +
1.162 + // Empty the array of implementations
1.163 + test.Printf(_L("Destroying List..."));
1.164 + ifArray.ResetAndDestroy();
1.165 +
1.166 + REComSession::FinalClose(); // Don't want leaks outside the test
1.167 +
1.168 + // Check for open handles
1.169 + thisThread.HandleCount(endProcessHandleCount, endThreadHandleCount);
1.170 +
1.171 + test(startThreadHandleCount == endThreadHandleCount);
1.172 + test.Printf(_L("Great ! No handle mismatch."));
1.173 +
1.174 + // Test Ends...
1.175 +
1.176 + __UHEAP_MARKEND;
1.177 + }
1.178 +
1.179 +void TheTest::StartTestL()
1.180 + {
1.181 + TestImplementationsL();
1.182 + }
1.183 +
1.184 +TInt DoTestsL()
1.185 + {
1.186 + // Should any tests leave past the lowest level???
1.187 + TheTest theT;
1.188 + theT.StartTestL();
1.189 + return KErrNone;
1.190 + }
1.191 +
1.192 +GLDEF_C TInt E32Main()
1.193 + {
1.194 + __UHEAP_MARK;
1.195 + test.Title();
1.196 + test.Start(_L("Rom resolver tests"));
1.197 +
1.198 + // get clean-up stack
1.199 + CTrapCleanup* cleanup = CTrapCleanup::New();
1.200 +
1.201 + CopyFiles();
1.202 + //The reason for the folowing delay is:
1.203 + //ECOM server could be already started. It means that when we copy some
1.204 + //ECOM plugins from Z: to C: drive - ECOM server should look for and
1.205 + //find the new ECOM plugins. The ECOM server uses for that CDiscoverer::CIdleScanningTimer
1.206 + //which is an active object. So the discovering service is asynchronous. We have to
1.207 + //wait some time until it finishes. Otherwise ListImplementationsL could fail to find
1.208 + //requested implementations.
1.209 + User::After(KOneSecond * 3);
1.210 +
1.211 + TRAPD(err,DoTestsL());
1.212 + delete cleanup;
1.213 +
1.214 + test(err==KErrNone);
1.215 +
1.216 + CleanupFiles();
1.217 +
1.218 + test.Next(_L("/n"));
1.219 + test.End();
1.220 + test.Close();
1.221 + __UHEAP_MARKEND;
1.222 + return(0);
1.223 + }