lowlevellibsandfws/pluginfw/Framework/PluginUpgradeTest/t_pluginupgrade.cpp
changeset 0 e4d67989cc36
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     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 code to test the plugin upgrade feature of ecom as required by CR 65BCA3.
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32test.h>
       
    19 #include <e32panic.h>
       
    20 #include <f32file.h>
       
    21 #include <bautils.h>
       
    22 #include "../EcomTestUtils/EcomTestUtils.h"
       
    23 
       
    24 #include <ecom/ecom.h>
       
    25 #include "EComUidCodes.h"
       
    26 #include "Interface.h" // interface to Plugins
       
    27 
       
    28 // RAM Only RSC and DLL
       
    29 _LIT(KRamOnlyEComUpgradeExample1DLL,		"Z:\\RAMOnly\\EComUpgradeExample1.dll");
       
    30 _LIT(KRamOnlyEComUpgradeExample1RSC,		"Z:\\RAMOnly\\EComUpgradeExample1.rsc");
       
    31 
       
    32 _LIT(KRamOnlyEComUpgradeExample2DLL,		"Z:\\RAMOnly\\EComUpgradeExample2.dll");
       
    33 _LIT(KRamOnlyEComUpgradeExample2RSC,		"Z:\\RAMOnly\\EComUpgradeExample2.rsc");
       
    34 
       
    35 _LIT(KRamOnlyEComUpgradeExample3DLL,		"Z:\\RAMOnly\\EComUpgradeExample3.dll");
       
    36 _LIT(KRamOnlyEComUpgradeExample3RSC,		"Z:\\RAMOnly\\EComUpgradeExample3.rsc");
       
    37 
       
    38 _LIT(KEComUpgradeExample1DLLOnC,			"C:\\sys\\bin\\EComUpgradeExample1.dll");
       
    39 _LIT(KEComUpgradeExample1RSCOnC,			"C:\\Resource\\Plugins\\EComUpgradeExample1.rsc");
       
    40 
       
    41 _LIT(KEComUpgradeExample2DLLOnC,			"C:\\sys\\bin\\EComUpgradeExample2.dll");
       
    42 _LIT(KEComUpgradeExample2RSCOnC,			"C:\\Resource\\Plugins\\EComUpgradeExample2.rsc");
       
    43 
       
    44 _LIT(KEComUpgradeExample3DLLOnC,			"C:\\sys\\bin\\EComUpgradeExample3.dll");
       
    45 _LIT(KEComUpgradeExample3RSCOnC,			"C:\\Resource\\Plugins\\EComUpgradeExample3.rsc");
       
    46 
       
    47 _LIT(KRamOnlyEComUpgradeROExample1DLL,		"Z:\\RAMOnly\\EComUpgradeROExample1.dll");
       
    48 _LIT(KRamOnlyEComUpgradeROExample1RSC,		"Z:\\RAMOnly\\EComUpgradeROExample1.rsc");
       
    49 
       
    50 _LIT(KRamOnlyEComUpgradeROExample2DLL,		"Z:\\RAMOnly\\EComUpgradeROExample2.dll");
       
    51 _LIT(KRamOnlyEComUpgradeROExample2RSC,		"Z:\\RAMOnly\\EComUpgradeROExample2.rsc");
       
    52 
       
    53 _LIT(KRamOnlyEComUpgradeROExample3DLL,		"Z:\\RAMOnly\\EComUpgradeROExample3.dll");
       
    54 _LIT(KRamOnlyEComUpgradeROExample3RSC,		"Z:\\RAMOnly\\EComUpgradeROExample3.rsc");
       
    55 
       
    56 _LIT(KEComUpgradeROExample1DLLOnC,			"C:\\sys\\bin\\EComUpgradeROExample1.dll");
       
    57 _LIT(KEComUpgradeROExample1RSCOnC,			"C:\\Resource\\Plugins\\EComUpgradeROExample1.rsc");
       
    58 
       
    59 _LIT(KEComUpgradeROExample2DLLOnC,			"C:\\sys\\bin\\EComUpgradeROExample2.dll");
       
    60 _LIT(KEComUpgradeROExample2RSCOnC,			"C:\\Resource\\Plugins\\EComUpgradeROExample2.rsc");
       
    61 
       
    62 _LIT(KEComUpgradeROExample3DLLOnC,			"C:\\sys\\bin\\EComUpgradeROExample3.dll");
       
    63 _LIT(KEComUpgradeROExample3RSCOnC,			"C:\\Resource\\Plugins\\EComUpgradeROExample3.rsc");
       
    64 
       
    65 const TInt KOneSecond = 1000000;
       
    66 const TInt KInterfaceUid = 0x10009DBA;
       
    67 const TInt KRomOnlyInterfaceUid = 0x10009DBD;
       
    68 const TInt KImplementationUid = 0x10009DBB;
       
    69 const TInt KRomOnlyImplementationUid = 0x10009DBE;
       
    70 
       
    71 LOCAL_D RTest TheTest(_L("Plugin Upgrade Test"));
       
    72 
       
    73 /**
       
    74 Test macroes and functions
       
    75 */
       
    76 static  void Check(TInt aValue, TInt aExpected, TInt aLine)
       
    77 	{
       
    78 	if(aValue != aExpected)
       
    79 		{
       
    80 		RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue);
       
    81 		TheTest(EFalse, aLine);
       
    82 		}
       
    83 	}
       
    84 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__)
       
    85 
       
    86 /**
       
    87 Kill Ecom Server for testing purposes
       
    88 */
       
    89 static void KillEComServerL()
       
    90 	{
       
    91 	//Need to ensure that the EComServer process is killed before even starting this test by using
       
    92    	//the EComTestUtils library
       
    93    	_LIT(KEComServerProcessName,"ecomserver");
       
    94    	TRAPD(error, EComTestUtils::KillProcessL(KEComServerProcessName));
       
    95    	error=error;
       
    96 	}
       
    97 
       
    98 class RPluginUpgradeTest
       
    99 	{
       
   100 public:
       
   101 	static void UpgradePluginSameNameLowerVersionL(TBool aIsRomOnly);
       
   102 	static void UpgradePluginDifferentNameLowerVersionL(TBool aIsRomOnly);
       
   103 	static void UpgradePluginSameNameHigherVersionL(TBool aIsRomOnly);
       
   104 	static void UpgradePluginDifferentNameHigherVersionL(TBool aIsRomOnly);
       
   105 	static void UpgradePluginSameNameSameVersionL(TBool aIsRomOnly);
       
   106 	static void UpgradePluginDifferentNameSameVersionL(TBool aIsRomOnly);
       
   107 	};
       
   108 
       
   109 /**
       
   110 Copies the Plugins to specific folder for testing purpose
       
   111 */
       
   112 LOCAL_C void CopyPluginSameNameLowerVersion(TBool aIsRomOnly)
       
   113 	{
       
   114 	TInt err=KErrNone;
       
   115 	if(aIsRomOnly)
       
   116 		{
       
   117 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeROExample1DLL, KEComUpgradeROExample2DLLOnC));
       
   118 		TEST2(err, KErrNone);
       
   119 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeROExample1RSC, KEComUpgradeROExample2RSCOnC));
       
   120 		TEST2(err, KErrNone);
       
   121 		}
       
   122 	else
       
   123 		{
       
   124 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeExample1DLL, KEComUpgradeExample2DLLOnC));
       
   125 		TEST2(err, KErrNone);
       
   126 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeExample1RSC, KEComUpgradeExample2RSCOnC));
       
   127 		TEST2(err, KErrNone);
       
   128 		}
       
   129 	}
       
   130 
       
   131 LOCAL_C void CopyPluginDifferentNameLowerVersion(TBool aIsRomOnly)
       
   132 	{
       
   133 	TInt err=KErrNone;
       
   134 	if(aIsRomOnly)
       
   135 		{
       
   136 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeROExample1DLL, KEComUpgradeROExample1DLLOnC));
       
   137 		TEST2(err, KErrNone);
       
   138 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeROExample1RSC, KEComUpgradeROExample1RSCOnC));
       
   139 		TEST2(err, KErrNone);
       
   140 		}
       
   141 	else
       
   142 		{
       
   143 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeExample1DLL, KEComUpgradeExample1DLLOnC));
       
   144 		TEST2(err, KErrNone);
       
   145 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeExample1RSC, KEComUpgradeExample1RSCOnC));
       
   146 		TEST2(err, KErrNone);
       
   147 		}
       
   148 	}
       
   149 
       
   150 LOCAL_C void CopyPluginSameNameHigherVersion(TBool aIsRomOnly)
       
   151 	{
       
   152 	TInt err=KErrNone;
       
   153 	if(aIsRomOnly)
       
   154 		{
       
   155 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeROExample3DLL, KEComUpgradeROExample2DLLOnC));
       
   156 		TEST2(err, KErrNone);
       
   157 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeROExample3RSC, KEComUpgradeROExample2RSCOnC));
       
   158 		TEST2(err, KErrNone);
       
   159 		}
       
   160 	else
       
   161 		{
       
   162 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeExample3DLL, KEComUpgradeExample2DLLOnC));
       
   163 		TEST2(err, KErrNone);
       
   164 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeExample3RSC, KEComUpgradeExample2RSCOnC));
       
   165 		TEST2(err, KErrNone);
       
   166 		}
       
   167 	}
       
   168 
       
   169 LOCAL_C void CopyPluginDifferentNameHigherVersion(TBool aIsRomOnly)
       
   170 	{
       
   171 	TInt err=KErrNone;
       
   172 	if(aIsRomOnly)
       
   173 		{
       
   174 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeROExample3DLL, KEComUpgradeROExample3DLLOnC));
       
   175 		TEST2(err, KErrNone);
       
   176 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeROExample3RSC, KEComUpgradeROExample3RSCOnC));
       
   177 		TEST2(err, KErrNone);
       
   178 		}
       
   179 	else
       
   180 		{
       
   181 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeExample3DLL, KEComUpgradeExample3DLLOnC));
       
   182 		TEST2(err, KErrNone);
       
   183 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeExample3RSC, KEComUpgradeExample3RSCOnC));
       
   184 		TEST2(err, KErrNone);
       
   185 		}
       
   186 	}
       
   187 
       
   188 LOCAL_C void CopyPluginSameNameSameVersion(TBool aIsRomOnly)
       
   189 	{
       
   190 	TInt err=KErrNone;
       
   191 	if(aIsRomOnly)
       
   192 		{
       
   193 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeROExample2DLL, KEComUpgradeROExample2DLLOnC));
       
   194 		TEST2(err, KErrNone);
       
   195 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeROExample2RSC, KEComUpgradeROExample2RSCOnC));
       
   196 		TEST2(err, KErrNone);
       
   197 		}
       
   198 	else
       
   199 		{
       
   200 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeExample2DLL, KEComUpgradeExample2DLLOnC));
       
   201 		TEST2(err, KErrNone);
       
   202 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeExample2RSC, KEComUpgradeExample2RSCOnC));
       
   203 		TEST2(err, KErrNone);
       
   204 		}
       
   205 	}
       
   206 
       
   207 LOCAL_C void CopyPluginDifferentNameSameVersion(TBool aIsRomOnly)
       
   208 	{
       
   209 	TInt err=KErrNone;
       
   210 	if(aIsRomOnly)
       
   211 		{
       
   212 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeROExample2DLL, KEComUpgradeROExample3DLLOnC));
       
   213 		TEST2(err, KErrNone);
       
   214 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeROExample2RSC, KEComUpgradeROExample3RSCOnC));
       
   215 		TEST2(err, KErrNone);
       
   216 		}
       
   217 	else
       
   218 		{
       
   219 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeExample2DLL, KEComUpgradeExample3DLLOnC));
       
   220 		TEST2(err, KErrNone);
       
   221 		TRAP(err, EComTestUtils::FileManCopyFileL(KRamOnlyEComUpgradeExample2RSC, KEComUpgradeExample3RSCOnC));
       
   222 		TEST2(err, KErrNone);
       
   223 		}
       
   224 	}
       
   225 
       
   226 inline LOCAL_C void ResetEcom()
       
   227 	{
       
   228 	// close session
       
   229 	REComSession::FinalClose();
       
   230 
       
   231 	// kill ecomserver
       
   232 	KillEComServerL();
       
   233 	}
       
   234 
       
   235 // Deleting plugin from the RAM for cleanup purpose
       
   236 inline LOCAL_C void DeleteUpgradeExample1Plugins(TBool aIsRomOnly)
       
   237 	{
       
   238 	TInt err=KErrNone;
       
   239 	if(aIsRomOnly)
       
   240 		{
       
   241 		TRAP(err, EComTestUtils::FileManDeleteFileL(KEComUpgradeROExample1DLLOnC));
       
   242 		TRAP(err, EComTestUtils::FileManDeleteFileL(KEComUpgradeROExample1RSCOnC));
       
   243 		}
       
   244 	else
       
   245 		{
       
   246 		TRAP(err, EComTestUtils::FileManDeleteFileL(KEComUpgradeExample1DLLOnC));
       
   247 		TRAP(err, EComTestUtils::FileManDeleteFileL(KEComUpgradeExample1RSCOnC));
       
   248 		}
       
   249 	}
       
   250 
       
   251 inline LOCAL_C void DeleteUpgradeExample2Plugins(TBool aIsRomOnly)
       
   252 	{
       
   253 	TInt err=KErrNone;
       
   254 	if(aIsRomOnly)
       
   255 		{
       
   256 		TRAP(err, EComTestUtils::FileManDeleteFileL(KEComUpgradeROExample2DLLOnC));
       
   257 		TRAP(err, EComTestUtils::FileManDeleteFileL(KEComUpgradeROExample2RSCOnC));
       
   258 		}
       
   259 	else
       
   260 		{
       
   261 		TRAP(err, EComTestUtils::FileManDeleteFileL(KEComUpgradeExample2DLLOnC));
       
   262 		TRAP(err, EComTestUtils::FileManDeleteFileL(KEComUpgradeExample2RSCOnC));
       
   263 		}
       
   264 	}
       
   265 
       
   266 inline LOCAL_C void DeleteUpgradeExample3Plugins(TBool aIsRomOnly)
       
   267 	{
       
   268 	TInt err=KErrNone;
       
   269 	if(aIsRomOnly)
       
   270 		{
       
   271 		TRAP(err, EComTestUtils::FileManDeleteFileL(KEComUpgradeROExample3DLLOnC));
       
   272 		TRAP(err, EComTestUtils::FileManDeleteFileL(KEComUpgradeROExample3RSCOnC));
       
   273 		}
       
   274 	else
       
   275 		{
       
   276 		TRAP(err, EComTestUtils::FileManDeleteFileL(KEComUpgradeExample3DLLOnC));
       
   277 		TRAP(err, EComTestUtils::FileManDeleteFileL(KEComUpgradeExample3RSCOnC));
       
   278 		}
       
   279 	}
       
   280 
       
   281 inline LOCAL_C void CheckDefaultPluginOnZ(TBool aIsRomOnly)
       
   282 	{
       
   283 	RImplInfoPtrArray implArray;
       
   284 	TUid interfaceUid;
       
   285 
       
   286 	if(aIsRomOnly)
       
   287 		{
       
   288 		/**
       
   289 		The following Plugin exists on the Z drive and will be discovered by ECOM during startup.
       
   290 
       
   291 		Interface UID   DLL	UID     Imp. UID    Version    DllFile
       
   292 		---------------------------------------------------------------------------------------
       
   293 		0x10009DBD      0x10009DBC  0x10009DBE  2          Z:\\..\\EComUpgradeExample2.dll
       
   294 		**/
       
   295 		interfaceUid = TUid::Uid(KRomOnlyInterfaceUid);
       
   296 		}
       
   297 	else
       
   298 		{
       
   299 		/**
       
   300 		The following Plugin exists on the Z drive and will be discovered by ECOM during startup.
       
   301 
       
   302 		Interface UID   DLL	UID     Imp. UID    Version    DllFile
       
   303 		---------------------------------------------------------------------------------------
       
   304 		0x10009DBA      0x10009DB9  0x10009DBB  2          Z:\\..\\EComUpgradeExample2.dll
       
   305 		**/
       
   306 		interfaceUid = TUid::Uid(KInterfaceUid);
       
   307 		}
       
   308 
       
   309 	// Get implementations for IF UID 0x10009DBA
       
   310 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
   311 
       
   312 	//Expected number of implementations returned
       
   313 	TEST2(implArray.Count(), 1);
       
   314 
       
   315 	//Check that the implementation uid returned matched the specs above
       
   316 	TUid implUid = implArray[0]->ImplementationUid();
       
   317 	TInt version = implArray[0]->Version();
       
   318 	TInt drive = implArray[0]->Drive();
       
   319 
       
   320 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
   321 
       
   322 	// imp. uid
       
   323 	if(aIsRomOnly)
       
   324 		{
       
   325 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
   326 		}
       
   327 	else
       
   328 		{
       
   329 		TEST2(implUid.iUid, KImplementationUid);
       
   330 		}
       
   331 	// version
       
   332 	TEST2(version, 2);
       
   333 	// Z drive
       
   334 	TEST2(drive, EDriveZ);
       
   335 
       
   336 	implArray.ResetAndDestroy();
       
   337 	}
       
   338 
       
   339 /**
       
   340 @SYMTestCaseID			SYSLIB-ECOM-CT-1596
       
   341 @SYMTestCaseDesc		Tests to ensure that an implementation will not be upgraded when the
       
   342 						upgrading DLL/RSC name is the same as the DLL/RSC name to be
       
   343 						upgraded but has a lower version.
       
   344 @SYMTestPriority		High
       
   345 @SYMTestActions			Call REComSession::ListImplementations() and check V1 implementation
       
   346 						on Z drive exists.
       
   347 						Copy DLL/RSC with same name and lower version to C drive.
       
   348 						Call REComSession::ListImplementations() and check V1 implementation
       
   349 						upgrades on C drive has not upgraded the original implementation on Z drive.
       
   350 						Restart ECOM (to test subsequent boot condition i.e. loading from dat file
       
   351 						Call REComSession::ListImplementations() and check V1 implementation
       
   352 						upgrades on C drive has not upgraded the original implementation on Z drive.
       
   353 						Check for no crash and memory leaks.
       
   354 						The same test is repeated for Rom Only drives. And no upgrade in version is
       
   355 						observed.
       
   356 @SYMTestExpectedResults	The test must not fail.
       
   357 @SYMDEF					DEF080682
       
   358 */
       
   359 void RPluginUpgradeTest::UpgradePluginSameNameLowerVersionL(TBool aIsRomOnly)
       
   360 	{
       
   361 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1596 "));
       
   362 	__UHEAP_MARK;
       
   363 
       
   364 	ResetEcom();
       
   365 
       
   366 	CheckDefaultPluginOnZ(aIsRomOnly);
       
   367 
       
   368 	TUid interfaceUid;
       
   369 	if(aIsRomOnly)
       
   370 		{
       
   371 		interfaceUid = TUid::Uid(KRomOnlyInterfaceUid);
       
   372 		}
       
   373 	else
       
   374 		{
       
   375 		interfaceUid = TUid::Uid(KInterfaceUid);
       
   376 		}
       
   377 	RImplInfoPtrArray implArray;
       
   378 
       
   379 	/**
       
   380 	The following plugin is now added to the C drive and ECOM will do a rediscovery and
       
   381 	will not discover it.
       
   382 
       
   383 	Interface UID   DLL	UID     Imp. UID    Version    DllFile
       
   384 	---------------------------------------------------------------------------------------
       
   385 	for ROM only
       
   386 	0x10009DBD      0x10009DBC  0x10009DBE  1          C:\\..\\EComUpgradeROExample2.dll
       
   387 	otherwise
       
   388 	0x10009DBA      0x10009DB9  0x10009DBB  1          C:\\..\\EComUpgradeExample2.dll
       
   389 	**/
       
   390 
       
   391 	CopyPluginSameNameLowerVersion(aIsRomOnly);
       
   392 	// Give ECOM a chance to discover new plugins.
       
   393 	// Otherwise ListImplementationsL could fail to find requested implementations.
       
   394 	User::After(KOneSecond * 3);
       
   395 
       
   396 	// The directory notifier will now detect that a new plugin has been added to the C drive and will cause
       
   397 	// ECOM to perform a new discovery.
       
   398 
       
   399 	// Get implementations for IF UID 0x10009DBA
       
   400 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
   401 
       
   402 	//Expected number of implementations returned
       
   403 	TEST2(implArray.Count(), 1);
       
   404 
       
   405 	//Check that the implementation uid returned matched the specs above
       
   406 	TUid implUid = implArray[0]->ImplementationUid();
       
   407 	TInt version = implArray[0]->Version();
       
   408 	TInt drive = implArray[0]->Drive();
       
   409 
       
   410 	RDebug::Print(_L("After new implementation is discovered...\n"));
       
   411 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
   412 	if(aIsRomOnly)
       
   413 		{
       
   414 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
   415 		TEST2(version, 2);
       
   416 		TEST2(drive, EDriveZ);
       
   417 		}
       
   418 	else
       
   419 		{
       
   420 		TEST2(implUid.iUid, KImplementationUid);
       
   421 		TEST2(version, 2);
       
   422 		TEST2(drive, EDriveZ);
       
   423 		}
       
   424 
       
   425 	implArray.ResetAndDestroy();
       
   426 
       
   427 	// close session
       
   428 	REComSession::FinalClose();
       
   429 
       
   430 	// kill ecomserver
       
   431 	KillEComServerL();
       
   432 
       
   433 	// Get implementations for IF UID 0x10009DBA
       
   434 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
   435 
       
   436 	//Expected number of implementations returned
       
   437 	TEST2(implArray.Count(), 1);
       
   438 
       
   439 	//Check that the implementation uid returned matched the specs above
       
   440 	implUid = implArray[0]->ImplementationUid();
       
   441 	version = implArray[0]->Version();
       
   442 	drive = implArray[0]->Drive();
       
   443 
       
   444 	RDebug::Print(_L("After restart...\n"));
       
   445 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
   446 	if(aIsRomOnly)
       
   447 		{
       
   448 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
   449 		TEST2(version, 2);
       
   450 		TEST2(drive, EDriveZ);
       
   451 		}
       
   452 	else
       
   453 		{
       
   454 		TEST2(implUid.iUid, KImplementationUid);
       
   455 		TEST2(version, 2);
       
   456 		TEST2(drive, EDriveZ);
       
   457 		}
       
   458 
       
   459 	implArray.ResetAndDestroy();
       
   460 
       
   461 	// close session
       
   462 	REComSession::FinalClose();
       
   463 
       
   464 	// tidy up
       
   465 	// Remove plugins from C drive
       
   466 	DeleteUpgradeExample2Plugins(aIsRomOnly);
       
   467 
       
   468 	// Give ECOM a chance to rediscover after deletion of plugins.
       
   469 	User::After(KOneSecond * 3);
       
   470 
       
   471 	// close session
       
   472 	REComSession::FinalClose();
       
   473 
       
   474 	// kill ecomserver
       
   475 	KillEComServerL();
       
   476 
       
   477 	__UHEAP_MARKEND;
       
   478 	}
       
   479 
       
   480 
       
   481 /**
       
   482 @SYMTestCaseID			SYSLIB-ECOM-CT-1597
       
   483 @SYMTestCaseDesc		Tests to ensure that an implementation will not be upgraded when the
       
   484 						upgrading DLL/RSC name is different from the DLL/RSC to be upgraded.
       
   485 						See CR65BCA3 even when the version is lower.
       
   486 @SYMTestPriority		High
       
   487 @SYMTestActions			Call REComSession::ListImplementations() and check V2 implementation
       
   488 						on Z drive exists.
       
   489 						Copy DLL/RSC with different name and V1 to DLL/RSC to C drive.
       
   490 						Call REComSession::ListImplementations() and check the original V2
       
   491 						implementation on Z drive has not been upgraded.
       
   492 						Check for no crash and memory leaks.
       
   493 						The same test is repeated for Rom Only drives. And no upgrade in version is
       
   494 						observed.
       
   495 @SYMTestExpectedResults	The test must not fail.
       
   496 @SYMDEF					DEF080682
       
   497 */
       
   498 void RPluginUpgradeTest::UpgradePluginDifferentNameLowerVersionL(TBool aIsRomOnly)
       
   499 	{
       
   500 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-1597 "));
       
   501 	__UHEAP_MARK;
       
   502 
       
   503 	ResetEcom();
       
   504 
       
   505 	CheckDefaultPluginOnZ(aIsRomOnly);
       
   506 
       
   507 	TUid interfaceUid = TUid::Null();
       
   508 	if(aIsRomOnly)
       
   509 		{
       
   510 		interfaceUid = TUid::Uid(KRomOnlyInterfaceUid);
       
   511 		}
       
   512 	else
       
   513 		{
       
   514 		interfaceUid = TUid::Uid(KInterfaceUid);
       
   515 		}
       
   516 	RImplInfoPtrArray implArray;
       
   517 
       
   518 	/**
       
   519 	The following plugin is now added to the C drive and ECOM will do a rediscovery and attempt to discover it.
       
   520 
       
   521 	Interface UID   DLL	UID     Imp. UID    Version    DllFile
       
   522 	----------------------------------------------------------------------------------------
       
   523 	for ROM only
       
   524 	0x10009DBD      0x10009DBC  0x10009DBE  1          C:\\..\\EComUpgradeROExample1.dll
       
   525 	otherwise
       
   526 	0x10009DBA      0x10009DB9  0x10009DBB  1          C:\\..\\EComUpgradeExample1.dll
       
   527 	**/
       
   528 
       
   529 	CopyPluginDifferentNameLowerVersion(aIsRomOnly);
       
   530 	// Give ECOM a chance to discover new plugins.
       
   531 	// Otherwise ListImplementationsL could fail to find requested implementations.
       
   532 	User::After(KOneSecond * 3);
       
   533 
       
   534 	// The directory notifier will now detect that a new plugin has been added to the C drive and will cause
       
   535 	// ECOM to perform a new discovery.
       
   536 
       
   537 	// The upgrade should fail an dthe existing implementation on the Z should remain
       
   538 
       
   539 	// Get implementations for IF UID 0x10009DBA
       
   540 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
   541 
       
   542 	//Expected number of implementations returned
       
   543 	TEST2(implArray.Count(), 1);
       
   544 
       
   545 	//Check that the implementation uid returned matched the specs above
       
   546 	TUid implUid = implArray[0]->ImplementationUid();
       
   547 	TInt version = implArray[0]->Version();
       
   548 	TInt drive = implArray[0]->Drive();
       
   549 
       
   550 	RDebug::Print(_L("After new implementation is discovered...\n"));
       
   551 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
   552 	if(aIsRomOnly)
       
   553 		{
       
   554 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
   555 		TEST2(version, 2);
       
   556 		TEST2(drive, EDriveZ);
       
   557 		}
       
   558 	else
       
   559 		{
       
   560 		TEST2(implUid.iUid, KImplementationUid);
       
   561 		TEST2(version, 2);
       
   562 		TEST2(drive, EDriveZ);
       
   563 		}
       
   564 	implArray.ResetAndDestroy();
       
   565 
       
   566 	// close session
       
   567 	REComSession::FinalClose();
       
   568 
       
   569 	// kill ecomserver
       
   570 	KillEComServerL();
       
   571 
       
   572 	// Get implementations for IF UID 0x10009DBA
       
   573 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
   574 
       
   575 	//Expected number of implementations returned
       
   576 	TEST2(implArray.Count(), 1);
       
   577 
       
   578 	//Check that the implementation uid returned matched the specs above
       
   579 	implUid = implArray[0]->ImplementationUid();
       
   580 	version = implArray[0]->Version();
       
   581 	drive = implArray[0]->Drive();
       
   582 
       
   583 	RDebug::Print(_L("After restart...\n"));
       
   584 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
   585 	if(aIsRomOnly)
       
   586 		{
       
   587 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
   588 		TEST2(version, 2);
       
   589 		TEST2(drive, EDriveZ);
       
   590 		}
       
   591 	else
       
   592 		{
       
   593 		TEST2(implUid.iUid, KImplementationUid);
       
   594 		TEST2(version, 2);
       
   595 		TEST2(drive, EDriveZ);
       
   596 		}
       
   597 	implArray.ResetAndDestroy();
       
   598 
       
   599 	// close session
       
   600 	REComSession::FinalClose();
       
   601 
       
   602 	// tidy up
       
   603 	// Remove plugins from C drive
       
   604 	DeleteUpgradeExample1Plugins(aIsRomOnly);
       
   605 
       
   606 	// Give ECOM a chance to rediscover after deletion of plugins.
       
   607 	User::After(KOneSecond * 3);
       
   608 
       
   609 	// close session
       
   610 	REComSession::FinalClose();
       
   611 
       
   612 	// kill ecomserver
       
   613 	KillEComServerL();
       
   614 
       
   615 	__UHEAP_MARKEND;
       
   616 	}
       
   617 
       
   618 
       
   619 /*
       
   620 @SYMTestCaseID			SYSLIB-ECOM-CT-0286
       
   621 @SYMTestCaseDesc		Tests to ensure that an implementation can be upgraded when the
       
   622 						upgrading DLL/RSC name is the same as the DLL/RSC name to be
       
   623 						upgraded.
       
   624 						See CR65BCA3.
       
   625 @SYMTestPriority			High
       
   626 @SYMTestActions			Call REComSession::ListImplementations() and check V1 implementation
       
   627 						on Z drive exists.
       
   628 						Copy DLL/RSC with same name as DLL/RSC to be upgraded to C drive.
       
   629 						Call REComSession::ListImplementations() and check V3 implementation
       
   630 						upgrades on C drive has upgraded the original implementation on Z drive.
       
   631 						Restart ECOM (to test subsequent boot condition i.e. loading from dat file
       
   632 						Call REComSession::ListImplementations() and check V3 implementation
       
   633 						upgrades on C drive has upgraded the original implementation on Z drive.
       
   634 						Check for no crash and memory leaks.
       
   635 						The same test is repeated for Rom Only drives. And no upgrade in version is
       
   636 						observed.
       
   637 @SYMTestExpectedResults	The test must not fail.
       
   638 @SYMPREQ				PREQ277
       
   639 @SYMDEF					DEF080682
       
   640 */
       
   641 void RPluginUpgradeTest::UpgradePluginSameNameHigherVersionL(TBool aIsRomOnly)
       
   642 	{
       
   643 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0286 "));
       
   644 	__UHEAP_MARK;
       
   645 
       
   646 	ResetEcom();
       
   647 
       
   648 	CheckDefaultPluginOnZ(aIsRomOnly);
       
   649 
       
   650 	TUid interfaceUid;
       
   651 	if(aIsRomOnly)
       
   652 		{
       
   653 		interfaceUid = TUid::Uid(KRomOnlyInterfaceUid);
       
   654 		}
       
   655 	else
       
   656 		{
       
   657 		interfaceUid = TUid::Uid(KInterfaceUid);
       
   658 		}
       
   659 	RImplInfoPtrArray implArray;
       
   660 
       
   661 	/**
       
   662 	The following plugin is now added to the C drive and ECOM will do a rediscovery and discover it.
       
   663 
       
   664 	Interface UID		DLL	UID		Imp. UID		Version		DllFile
       
   665 	------------------------------------------------------------------------------------------------------------------------------------------
       
   666 	for ROM only
       
   667 	0x10009DBD      0x10009DBC  0x10009DBE  3          C:\\..\\EComUpgradeROExample2.dll
       
   668 	otherwise
       
   669 	0x10009DBA      0x10009DB9  0x10009DBB  3          C:\\..\\EComUpgradeExample2.dll
       
   670 	**/
       
   671 
       
   672 	CopyPluginSameNameHigherVersion(aIsRomOnly);
       
   673 	// Give ECOM a chance to discover new plugins.
       
   674 	// Otherwise ListImplementationsL could fail to find requested implementations.
       
   675 	User::After(KOneSecond * 3);
       
   676 
       
   677 	// The directory notifier will now detect that a new plugin has been added to the C drive and will cause
       
   678 	// ECOM to perform a new discovery.
       
   679 
       
   680 	// Get implementations for IF UID 0x10009DBA
       
   681 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
   682 
       
   683 	//Expected number of implementations returned
       
   684 	TEST2(implArray.Count(), 1);
       
   685 
       
   686 	//Check that the implementation uid returned matched the specs above
       
   687 	TUid implUid = implArray[0]->ImplementationUid();
       
   688 	TInt version = implArray[0]->Version();
       
   689 	TInt drive = implArray[0]->Drive();
       
   690 
       
   691 	RDebug::Print(_L("After new implementation is discovered...\n"));
       
   692 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
   693 	if(aIsRomOnly)
       
   694 		{
       
   695 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
   696 		TEST2(version, 2);
       
   697 		TEST2(drive, EDriveZ);
       
   698 		}
       
   699 	else
       
   700 		{
       
   701 		TEST2(implUid.iUid, KImplementationUid);
       
   702 		TEST2(version, 3);
       
   703 		TEST2(drive, EDriveC);
       
   704 		}
       
   705 
       
   706 	implArray.ResetAndDestroy();
       
   707 
       
   708 	// close session
       
   709 	REComSession::FinalClose();
       
   710 
       
   711 	// kill ecomserver
       
   712 	KillEComServerL();
       
   713 
       
   714 	// Get implementations for IF UID 0x10009DBA
       
   715 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
   716 
       
   717 	//Expected number of implementations returned
       
   718 	TEST2(implArray.Count(), 1);
       
   719 
       
   720 	//Check that the implementation uid returned matched the specs above
       
   721 	implUid = implArray[0]->ImplementationUid();
       
   722 	version = implArray[0]->Version();
       
   723 	drive = implArray[0]->Drive();
       
   724 
       
   725 	RDebug::Print(_L("After restart...\n"));
       
   726 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
   727 	if(aIsRomOnly)
       
   728 		{
       
   729 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
   730 		TEST2(version, 2);
       
   731 		TEST2(drive, EDriveZ);
       
   732 		}
       
   733 	else
       
   734 		{
       
   735 		TEST2(implUid.iUid, KImplementationUid);
       
   736 		TEST2(version, 3);
       
   737 		TEST2(drive, EDriveC);
       
   738 		}
       
   739 	implArray.ResetAndDestroy();
       
   740 
       
   741 	// close session
       
   742 	REComSession::FinalClose();
       
   743 
       
   744 	// tidy up
       
   745 	// Remove plugins from C drive
       
   746 	DeleteUpgradeExample2Plugins(aIsRomOnly);
       
   747 
       
   748 	// Give ECOM a chance to rediscover after deletion of plugins.
       
   749 	User::After(KOneSecond * 3);
       
   750 
       
   751 	// close session
       
   752 	REComSession::FinalClose();
       
   753 
       
   754 	// kill ecomserver
       
   755 	KillEComServerL();
       
   756 
       
   757 	__UHEAP_MARKEND;
       
   758 	}
       
   759 
       
   760 /**
       
   761 @SYMTestCaseID			SYSLIB-ECOM-CT-0287
       
   762 @SYMTestCaseDesc		Tests to ensure that an implementation will not be upgraded when the
       
   763 						upgrading DLL/RSC name is different from the DLL/RSC to be upgraded.
       
   764 						See CR65BCA3.
       
   765 @SYMTestPriority			High
       
   766 @SYMTestActions			Call REComSession::ListImplementations() and check V1 implementation
       
   767 						on Z drive exists.
       
   768 						Copy DLL/RSC with different name to DLL/RSC to be upgraded to C drive.
       
   769 						Call REComSession::ListImplementations() and check the original V2
       
   770 						implementation on Z drive has not been upgraded.
       
   771 						Check for no crash and memory leaks.
       
   772 						The same test is repeated for Rom Only drives. And no upgrade in version is
       
   773 						observed.
       
   774 @SYMTestExpectedResults	The test must not fail.
       
   775 @SYMPREQ				PREQ277
       
   776 @SYMDEF					DEF080682
       
   777 */
       
   778 void RPluginUpgradeTest::UpgradePluginDifferentNameHigherVersionL(TBool aIsRomOnly)
       
   779 	{
       
   780 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0287 "));
       
   781 	__UHEAP_MARK;
       
   782 
       
   783 	ResetEcom();
       
   784 
       
   785 	CheckDefaultPluginOnZ(aIsRomOnly);
       
   786 
       
   787 	TUid interfaceUid;
       
   788 	if(aIsRomOnly)
       
   789 		{
       
   790 		interfaceUid = TUid::Uid(KRomOnlyInterfaceUid);
       
   791 		}
       
   792 	else
       
   793 		{
       
   794 		interfaceUid = TUid::Uid(KInterfaceUid);
       
   795 		}
       
   796 	RImplInfoPtrArray implArray;
       
   797 
       
   798 	/**
       
   799 	The following plugin is now added to the C drive and ECOM will do a rediscovery and attempt to discover it.
       
   800 
       
   801 	Interface UID		DLL	UID		Imp. UID		Version		DllFile
       
   802 	------------------------------------------------------------------------------------------------------------------------------------------
       
   803 	for ROM only
       
   804 	0x10009DBD      0x10009DBC  0x10009DBE  3          C:\\..\\EComUpgradeROExample3.dll
       
   805 	otherwise
       
   806 	0x10009DBA      0x10009DB9  0x10009DBB  3          C:\\..\\EComUpgradeExample3.dll
       
   807 	**/
       
   808 
       
   809 	CopyPluginDifferentNameHigherVersion(aIsRomOnly);
       
   810 	// Give ECOM a chance to discover new plugins.
       
   811 	// Otherwise ListImplementationsL could fail to find requested implementations.
       
   812 	User::After(KOneSecond * 3);
       
   813 
       
   814 	// The directory notifier will now detect that a new plugin has been added to the C drive and will cause
       
   815 	// ECOM to perform a new discovery.
       
   816 
       
   817 	// The upgrade should fail an dthe existing implementation on the Z should remain
       
   818 
       
   819 	// Get implementations for IF UID 0x10009DBA
       
   820 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
   821 
       
   822 	//Expected number of implementations returned
       
   823 	TEST2(implArray.Count(), 1);
       
   824 
       
   825 	//Check that the implementation uid returned matched the specs above
       
   826 	TUid implUid = implArray[0]->ImplementationUid();
       
   827 	TInt version = implArray[0]->Version();
       
   828 	TInt drive = implArray[0]->Drive();
       
   829 
       
   830 	RDebug::Print(_L("After new implementation is discovered...\n"));
       
   831 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
   832 	if(aIsRomOnly)
       
   833 		{
       
   834 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
   835 		TEST2(version, 2);
       
   836 		TEST2(drive, EDriveZ);
       
   837 		}
       
   838 	else
       
   839 		{
       
   840 		TEST2(implUid.iUid, KImplementationUid);
       
   841 		TEST2(version, 2);
       
   842 		TEST2(drive, EDriveZ);
       
   843 		}
       
   844 	implArray.ResetAndDestroy();
       
   845 
       
   846 	// close session
       
   847 	REComSession::FinalClose();
       
   848 
       
   849 	// kill ecomserver
       
   850 	KillEComServerL();
       
   851 
       
   852 	// Get implementations for IF UID 0x10009DBA
       
   853 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
   854 
       
   855 	//Expected number of implementations returned
       
   856 	TEST2(implArray.Count(), 1);
       
   857 
       
   858 	//Check that the implementation uid returned matched the specs above
       
   859 	implUid = implArray[0]->ImplementationUid();
       
   860 	version = implArray[0]->Version();
       
   861 	drive = implArray[0]->Drive();
       
   862 
       
   863 	RDebug::Print(_L("After restart...\n"));
       
   864 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
   865 	if(aIsRomOnly)
       
   866 		{
       
   867 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
   868 		TEST2(version, 2);
       
   869 		TEST2(drive, EDriveZ);
       
   870 		}
       
   871 	else
       
   872 		{
       
   873 		TEST2(implUid.iUid, KImplementationUid);
       
   874 		TEST2(version, 2);
       
   875 		TEST2(drive, EDriveZ);
       
   876 		}
       
   877 	implArray.ResetAndDestroy();
       
   878 
       
   879 	// close session
       
   880 	REComSession::FinalClose();
       
   881 
       
   882 	// tidy up
       
   883 	// Remove plugins from C drive
       
   884 	DeleteUpgradeExample3Plugins(aIsRomOnly);
       
   885 
       
   886 	// Give ECOM a chance to rediscover after deletion of plugins.
       
   887 	User::After(KOneSecond * 3);
       
   888 
       
   889 	// close session
       
   890 	REComSession::FinalClose();
       
   891 
       
   892 	// kill ecomserver
       
   893 	KillEComServerL();
       
   894 
       
   895 	__UHEAP_MARKEND;
       
   896 	}
       
   897 
       
   898 /**
       
   899 @SYMTestCaseID			SYSLIB-ECOM-CT-0288
       
   900 @SYMTestCaseDesc		Tests to ensure that an implementation can be upgraded when the
       
   901 						upgrading DLL/RSC name is the same as the DLL/RSC name to be
       
   902 						upgraded and also the version is the same.
       
   903 						See CR65BCA3.
       
   904 @SYMTestPriority			High
       
   905 @SYMTestActions			Call REComSession::ListImplementations() and check V1 implementation
       
   906 						on Z drive exists.
       
   907 						Copy DLL/RSC with same name as DLL/RSC to be upgraded to C drive.
       
   908 						Call REComSession::ListImplementations() and check V2 implementation
       
   909 						upgrades on C drive has upgraded the original implementation on Z drive.
       
   910 						Check for no crash and memory leaks.
       
   911 						Restart ECOM (to test subsequent boot condition i.e. loading from dat file
       
   912 						Call REComSession::ListImplementations() and check V2 implementation
       
   913 						upgrades on C drive has upgraded the original implementation on Z drive.
       
   914 						The same test is repeated for Rom Only drives. And no upgrade in version is
       
   915 						observed.
       
   916 @SYMTestExpectedResults	The test must not fail.
       
   917 @SYMPREQ				PREQ277
       
   918 @SYMDEF					DEF080682
       
   919 */
       
   920 void RPluginUpgradeTest::UpgradePluginSameNameSameVersionL(TBool aIsRomOnly)
       
   921 	{
       
   922 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0288 "));
       
   923 	__UHEAP_MARK;
       
   924 
       
   925 	ResetEcom();
       
   926 
       
   927 	CheckDefaultPluginOnZ(aIsRomOnly);
       
   928 
       
   929 	TUid interfaceUid;
       
   930 	if(aIsRomOnly)
       
   931 		{
       
   932 		interfaceUid = TUid::Uid(KRomOnlyInterfaceUid);
       
   933 		}
       
   934 	else
       
   935 		{
       
   936 		interfaceUid = TUid::Uid(KInterfaceUid);
       
   937 		}
       
   938 	RImplInfoPtrArray implArray;
       
   939 
       
   940 	/**
       
   941 	The following plugin is now added to the C drive and ECOM will do a rediscovery and discover it.
       
   942 
       
   943 	Interface UID		DLL	UID		Imp. UID		Version		DllFile
       
   944 	------------------------------------------------------------------------------------------------------------------------------------------
       
   945 	for ROM only
       
   946 	0x10009DBD      0x10009DBC  0x10009DBE  2          C:\\..\\EComUpgradeROExample2.dll
       
   947 	otherwise
       
   948 	0x10009DBA      0x10009DB9  0x10009DBB  2          C:\\..\\EComUpgradeExample2.dll
       
   949 	**/
       
   950 
       
   951 	CopyPluginSameNameSameVersion(aIsRomOnly);
       
   952 	// Give ECOM a chance to discover new plugins.
       
   953 	// Otherwise ListImplementationsL could fail to find requested implementations.
       
   954 	User::After(KOneSecond * 3);
       
   955 
       
   956 	// The directory notifier will now detect that a new plugin has been added to the C drive and will cause
       
   957 	// ECOM to perform a new discovery.
       
   958 
       
   959 	// Get implementations for IF UID 0x10009DBA
       
   960 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
   961 
       
   962 	//Expected number of implementations returned
       
   963 	TEST2(implArray.Count(), 1);
       
   964 
       
   965 	//Check that the implementation uid returned matched the specs above
       
   966 	TUid implUid = implArray[0]->ImplementationUid();
       
   967 	TInt version = implArray[0]->Version();
       
   968 	TInt drive = implArray[0]->Drive();
       
   969 
       
   970 	RDebug::Print(_L("After new implementation is discovered...\n"));
       
   971 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
   972 	if(aIsRomOnly)
       
   973 		{
       
   974 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
   975 		TEST2(version, 2);
       
   976 		TEST2(drive, EDriveZ);
       
   977 		}
       
   978 	else
       
   979 		{
       
   980 		TEST2(implUid.iUid, KImplementationUid);
       
   981 		TEST2(version, 2);
       
   982 		TEST2(drive, EDriveC);
       
   983 		}
       
   984 	implArray.ResetAndDestroy();
       
   985 
       
   986 	// close session
       
   987 	REComSession::FinalClose();
       
   988 
       
   989 	// kill ecomserver
       
   990 	KillEComServerL();
       
   991 
       
   992 	// Get implementations for IF UID 0x10009DBA
       
   993 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
   994 
       
   995 	//Expected number of implementations returned
       
   996 	TEST2(implArray.Count(), 1);
       
   997 
       
   998 	//Check that the implementation uid returned matched the specs above
       
   999 	implUid = implArray[0]->ImplementationUid();
       
  1000 	version = implArray[0]->Version();
       
  1001 	drive = implArray[0]->Drive();
       
  1002 
       
  1003 	RDebug::Print(_L("After restart...\n"));
       
  1004 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
  1005 	if(aIsRomOnly)
       
  1006 		{
       
  1007 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
  1008 		TEST2(version, 2);
       
  1009 		TEST2(drive, EDriveZ);
       
  1010 		}
       
  1011 	else
       
  1012 		{
       
  1013 		TEST2(implUid.iUid, KImplementationUid);
       
  1014 		TEST2(version, 2);
       
  1015 		TEST2(drive, EDriveC);
       
  1016 		}
       
  1017 	implArray.ResetAndDestroy();
       
  1018 
       
  1019 	// close session
       
  1020 	REComSession::FinalClose();
       
  1021 
       
  1022 	// tidy up
       
  1023 	// Remove plugins from C drive
       
  1024 	DeleteUpgradeExample2Plugins(aIsRomOnly);
       
  1025 	// Give ECOM a chance to rediscover after deletion of plugins.
       
  1026 	User::After(KOneSecond * 3);
       
  1027 
       
  1028 	// close session
       
  1029 	REComSession::FinalClose();
       
  1030 
       
  1031 	// kill ecomserver
       
  1032 	KillEComServerL();
       
  1033 
       
  1034 	__UHEAP_MARKEND;
       
  1035 	}
       
  1036 
       
  1037 /**
       
  1038 @SYMTestCaseID			SYSLIB-ECOM-CT-0289
       
  1039 @SYMTestCaseDesc		Tests to ensure that an implementation will not be upgraded when the
       
  1040 						upgrading DLL/RSC name is different from the DLL/RSC to be upgraded
       
  1041 						and also the version is the same.
       
  1042 						See CR65BCA3.
       
  1043 @SYMTestPriority		High
       
  1044 @SYMTestActions			Call REComSession::ListImplementations() and check V2 implementation
       
  1045 						on Z drive exists.
       
  1046 						Copy DLL/RSC with different name, but same version, to DLL/RSC to be
       
  1047 						upgraded to C drive.
       
  1048 						Call REComSession::ListImplementations() and check the original V2
       
  1049 						implementation on Z drive has not been upgraded.
       
  1050 						Check for no crash and memory leaks.
       
  1051 						The same test is repeated for Rom Only drives. And no upgrade in version is
       
  1052 						observed.
       
  1053 @SYMTestExpectedResults	The test must not fail.
       
  1054 @SYMPREQ				PREQ277
       
  1055 @SYMDEF					DEF080682
       
  1056 */
       
  1057 void RPluginUpgradeTest::UpgradePluginDifferentNameSameVersionL(TBool aIsRomOnly)
       
  1058 	{
       
  1059 	TheTest.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-0289 "));
       
  1060 	__UHEAP_MARK;
       
  1061 
       
  1062 	ResetEcom();
       
  1063 
       
  1064 	CheckDefaultPluginOnZ(aIsRomOnly);
       
  1065 
       
  1066 	TUid interfaceUid;
       
  1067 	if(aIsRomOnly)
       
  1068 		{
       
  1069 		interfaceUid = TUid::Uid(KRomOnlyInterfaceUid);
       
  1070 		}
       
  1071 	else
       
  1072 		{
       
  1073 		interfaceUid = TUid::Uid(KInterfaceUid);
       
  1074 		}
       
  1075 	RImplInfoPtrArray implArray;
       
  1076 
       
  1077 	/**
       
  1078 	The following plugin is now added to the C drive and ECOM will do a rediscovery and attempt to discover it.
       
  1079 
       
  1080 	Interface UID		DLL	UID		Imp. UID		Version		DllFile
       
  1081 	----------------------------------------------------------------------------------------
       
  1082 	for ROM only
       
  1083 	0x10009DBD      0x10009DBC  0x10009DBE  2          C:\\..\\EComUpgradeROExample3.dll
       
  1084 	otherwise
       
  1085 	0x10009DBA      0x10009DB9  0x10009DBB  2          C:\\..\\EComUpgradeExample3.dll
       
  1086 	**/
       
  1087 
       
  1088 	CopyPluginDifferentNameSameVersion(aIsRomOnly);
       
  1089 	// Give ECOM a chance to discover new plugins.
       
  1090 	// Otherwise ListImplementationsL could fail to find requested implementations.
       
  1091 	User::After(KOneSecond * 3);
       
  1092 
       
  1093 	// The directory notifier will now detect that a new plugin has been added to the C drive and will cause
       
  1094 	// ECOM to perform a new discovery.
       
  1095 
       
  1096 	// The upgrade should fail an dthe existing implementation on the Z should remain
       
  1097 
       
  1098 	// Get implementations for IF UID 0x10009DBA
       
  1099 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
  1100 
       
  1101 	//Expected number of implementations returned
       
  1102 	TEST2(implArray.Count(), 1);
       
  1103 
       
  1104 	//Check that the implementation uid returned matched the specs above
       
  1105 	TUid implUid = implArray[0]->ImplementationUid();
       
  1106 	TInt version = implArray[0]->Version();
       
  1107 	TInt drive = implArray[0]->Drive();
       
  1108 	RDebug::Print(_L("After new implementation is discovered...\n"));
       
  1109 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
  1110 
       
  1111 	if(aIsRomOnly)
       
  1112 		{
       
  1113 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
  1114 		TEST2(version, 2);
       
  1115 		TEST2(drive, EDriveZ);
       
  1116 		}
       
  1117 	else
       
  1118 		{
       
  1119 		TEST2(implUid.iUid, KImplementationUid);
       
  1120 		TEST2(version, 2);
       
  1121 		TEST2(drive, EDriveZ);
       
  1122 		}
       
  1123 	implArray.ResetAndDestroy();
       
  1124 
       
  1125 	// close session
       
  1126 	REComSession::FinalClose();
       
  1127 
       
  1128 	// kill ecomserver
       
  1129 	KillEComServerL();
       
  1130 
       
  1131 	// Get implementations for IF UID 0x10009DBA
       
  1132 	REComSession::ListImplementationsL(interfaceUid, implArray);
       
  1133 
       
  1134 	//Expected number of implementations returned
       
  1135 	TEST2(implArray.Count(), 1);
       
  1136 
       
  1137 	//Check that the implementation uid returned matched the specs above
       
  1138 	implUid = implArray[0]->ImplementationUid();
       
  1139 	version = implArray[0]->Version();
       
  1140 	drive = implArray[0]->Drive();
       
  1141 	RDebug::Print(_L("After new implementation is discovered...\n"));
       
  1142 	RDebug::Print(_L("implUid = 0x%x, version = %d drive = %d \n"), implUid, version, drive);
       
  1143 
       
  1144 	if(aIsRomOnly)
       
  1145 		{
       
  1146 		TEST2(implUid.iUid, KRomOnlyImplementationUid);
       
  1147 		TEST2(version, 2);
       
  1148 		TEST2(drive, EDriveZ);
       
  1149 		}
       
  1150 	else
       
  1151 		{
       
  1152 		TEST2(implUid.iUid, KImplementationUid);
       
  1153 		TEST2(version, 2);
       
  1154 		TEST2(drive, EDriveZ);
       
  1155 		}
       
  1156 	implArray.ResetAndDestroy();
       
  1157 
       
  1158 	// close session
       
  1159 	REComSession::FinalClose();
       
  1160 
       
  1161 	// tidy up
       
  1162 	// Remove plugins from C drive
       
  1163 	DeleteUpgradeExample3Plugins(aIsRomOnly);
       
  1164 	// Give ECOM a chance to rediscover after deletion of plugins.
       
  1165 	User::After(KOneSecond * 3);
       
  1166 
       
  1167 	// close session
       
  1168 	REComSession::FinalClose();
       
  1169 
       
  1170 	// kill ecomserver
       
  1171 	KillEComServerL();
       
  1172 
       
  1173 	__UHEAP_MARKEND;
       
  1174 	}
       
  1175 
       
  1176 LOCAL_C void RunTestL()
       
  1177 	{
       
  1178 	__UHEAP_MARK;
       
  1179 
       
  1180 
       
  1181 	TheTest.Next(_L("Upgrade rom only plugin with same name and lower version"));
       
  1182 	RPluginUpgradeTest::UpgradePluginSameNameLowerVersionL(ETrue);
       
  1183 
       
  1184 	TheTest.Next(_L("Upgrade rom only plugin with different name and lower version"));
       
  1185 	RPluginUpgradeTest::UpgradePluginDifferentNameLowerVersionL(ETrue);
       
  1186 
       
  1187 	TheTest.Next(_L("Upgrade rom only plugin with same name and higher version"));
       
  1188 	RPluginUpgradeTest::UpgradePluginSameNameHigherVersionL(ETrue);
       
  1189 
       
  1190 	TheTest.Next(_L("Upgrade rom only plugin with different name and higher version"));
       
  1191 	RPluginUpgradeTest::UpgradePluginDifferentNameHigherVersionL(ETrue);
       
  1192 
       
  1193 	TheTest.Next(_L("Upgrade rom only plugin with same name and same version"));
       
  1194 	RPluginUpgradeTest::UpgradePluginSameNameSameVersionL(ETrue);
       
  1195 
       
  1196 	TheTest.Next(_L("Upgrade rom only plugin with different name and same version"));
       
  1197 	RPluginUpgradeTest::UpgradePluginDifferentNameSameVersionL(ETrue);
       
  1198 
       
  1199 	TheTest.Next(_L("Upgrade plugin with same name and lower version"));
       
  1200 	RPluginUpgradeTest::UpgradePluginSameNameLowerVersionL(EFalse);
       
  1201 
       
  1202 	TheTest.Next(_L("Upgrade plugin with different name and lower version"));
       
  1203 	RPluginUpgradeTest::UpgradePluginDifferentNameLowerVersionL(EFalse);
       
  1204 
       
  1205 	TheTest.Next(_L("Upgrade plugin with same name and higher version"));
       
  1206 	RPluginUpgradeTest::UpgradePluginSameNameHigherVersionL(EFalse);
       
  1207 
       
  1208 	TheTest.Next(_L("Upgrade plugin with different name and higher version"));
       
  1209 	RPluginUpgradeTest::UpgradePluginDifferentNameHigherVersionL(EFalse);
       
  1210 
       
  1211 	TheTest.Next(_L("Upgrade plugin with same name and same version"));
       
  1212 	RPluginUpgradeTest::UpgradePluginSameNameSameVersionL(EFalse);
       
  1213 
       
  1214 	TheTest.Next(_L("Upgrade plugin with different name and same version"));
       
  1215 	RPluginUpgradeTest::UpgradePluginDifferentNameSameVersionL(EFalse);
       
  1216 
       
  1217 	__UHEAP_MARKEND;
       
  1218 	}
       
  1219 
       
  1220 void CleanupPluginFiles()
       
  1221 	{
       
  1222 	DeleteUpgradeExample1Plugins(EFalse);
       
  1223 	DeleteUpgradeExample2Plugins(EFalse);
       
  1224 	DeleteUpgradeExample3Plugins(EFalse);
       
  1225 	DeleteUpgradeExample1Plugins(ETrue);
       
  1226 	DeleteUpgradeExample2Plugins(ETrue);
       
  1227 	DeleteUpgradeExample3Plugins(ETrue);
       
  1228 	}
       
  1229 
       
  1230 GLDEF_C TInt E32Main()
       
  1231 	{
       
  1232 	__UHEAP_MARK;
       
  1233 
       
  1234 	TheTest.Title();
       
  1235 	TheTest.Start(_L("Plugin Upgrade Tests."));
       
  1236 
       
  1237 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
  1238 	CActiveScheduler* scheduler = new(ELeave)CActiveScheduler;
       
  1239 	CActiveScheduler::Install(scheduler);
       
  1240 
       
  1241 	// Cleanup files
       
  1242 	CleanupPluginFiles();
       
  1243 
       
  1244 	//run tests
       
  1245 	TRAPD(err,RunTestL());
       
  1246 
       
  1247 	// Cleanup files
       
  1248 	if(err != KErrNone)
       
  1249 		{
       
  1250 		CleanupPluginFiles();
       
  1251 		}
       
  1252 
       
  1253 	TEST2(err, KErrNone);
       
  1254 
       
  1255 	// cleanup session
       
  1256 	REComSession::FinalClose();
       
  1257 
       
  1258 	delete scheduler;
       
  1259 	delete cleanup;
       
  1260 
       
  1261 	TheTest.End();
       
  1262 	TheTest.Close();
       
  1263 
       
  1264 	__UHEAP_MARKEND;
       
  1265 	return(0);
       
  1266 	}