os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComSWITests/src/checkPlugin.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComSWITests/src/checkPlugin.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,442 @@
     1.4 +// Copyright (c) 2006-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 File Provides implementations of CCheckListImplementation, which Checks the plugin for availble implementation
    1.18 +// and CCheckCreateImplementation, which uses the method provided the ECom Plugin.
    1.19 +// 
    1.20 +//
    1.21 +
    1.22 +/**
    1.23 + @file
    1.24 +*/
    1.25 +
    1.26 +#include <ecom/resolver.h>
    1.27 +#include "checkPlugin.h"
    1.28 +
    1.29 +
    1.30 +CCheckListImplementation::~CCheckListImplementation()
    1.31 +	{
    1.32 +	}
    1.33 +
    1.34 +
    1.35 +CCheckListImplementation::CCheckListImplementation(TOperationType aOperationType)
    1.36 +	: iOperationType(aOperationType)
    1.37 +	{
    1.38 +    SetTestStepName(KListImplUidStep);
    1.39 +	}
    1.40 +	
    1.41 +	
    1.42 +	
    1.43 +TVerdict CCheckListImplementation::doTestStepPreambleL()
    1.44 +    {
    1.45 +    SetTestStepResult(EPass);
    1.46 +    // get step parameters
    1.47 +	
    1.48 +    TInt tempInterfaceuid=0;
    1.49 + 
    1.50 +    if (!GetHexFromConfig(ConfigSection(), KInterfaceUID, tempInterfaceuid))
    1.51 +		{
    1.52 +		INFO_PRINTF1(HTML_RED);
    1.53 +        ERR_PRINTF1(_L("FAIL: Missing Interface UID"));
    1.54 +        INFO_PRINTF1(HTML_RED_OFF);
    1.55 +        SetTestStepResult(EFail);
    1.56 +        return TestStepResult();
    1.57 +		}    
    1.58 +		
    1.59 +	 iInterfaceUid.iUid = tempInterfaceuid;
    1.60 +	  
    1.61 +    return TestStepResult();
    1.62 +	}
    1.63 +    
    1.64 +    
    1.65 +    
    1.66 +TVerdict CCheckListImplementation::doTestStepL()
    1.67 +    {
    1.68 + 	__UHEAP_MARK; 
    1.69 +  	
    1.70 +  	//First find out if the Check Plugin step is supposed to be successful.
    1.71 +  	TInt testStepOutcome=KErrNone;
    1.72 +  	TInt err = GetIntFromConfig(ConfigSection(), KExpectedErrorCheckPlugin, testStepOutcome);
    1.73 +  	if(err !=1) testStepOutcome=KErrNone;
    1.74 +
    1.75 +	
    1.76 +	// and leaking thread handles
    1.77 +	TInt startProcessHandleCount;
    1.78 +	TInt startThreadHandleCount;
    1.79 +	TInt endProcessHandleCount;
    1.80 +	TInt endThreadHandleCount;
    1.81 +	
    1.82 +	RThread thisThread;
    1.83 +	thisThread.HandleCount(startProcessHandleCount, startThreadHandleCount);
    1.84 +
    1.85 +   
    1.86 +    switch (iOperationType)
    1.87 +        {
    1.88 +        case EUseListImplUid:
    1.89 +          	{
    1.90 +          	        	
    1.91 +	        REComSession::ListImplementationsL(iInterfaceUid, iImplyArrayPtr);
    1.92 +          	
    1.93 +          	TInt eImplCount(0);   
    1.94 +    		iImplCount = iImplyArrayPtr.Count();
    1.95 +
    1.96 +	    	if(!GetIntFromConfig(ConfigSection(), KExpectedCount, eImplCount))
    1.97 +          		{
    1.98 +          		INFO_PRINTF1(HTML_RED);
    1.99 +		        ERR_PRINTF1(_L("FAIL: Missing Implementation Count in the INI File"));
   1.100 +		        INFO_PRINTF1(HTML_RED_OFF);
   1.101 +		        SetTestStepResult(EFail);
   1.102 +		        return TestStepResult();
   1.103 +               	}
   1.104 +
   1.105 +          	if(eImplCount != iImplCount)
   1.106 +          		{
   1.107 +          		INFO_PRINTF1(HTML_RED);
   1.108 +		       	ERR_PRINTF3( _L("The number Implemenation(s) in this ECom plugin do not match, expected %d implementation(s), got %d implementation(s)."), eImplCount, iImplCount );
   1.109 +        		INFO_PRINTF1(HTML_RED_OFF);
   1.110 +		        SetTestStepResult(EFail);
   1.111 +		        return TestStepResult();
   1.112 +          		}
   1.113 +
   1.114 +          	//Ensuring that the ECom Plugin does have Implementations
   1.115 +	   		if( iImplCount > 0 && testStepOutcome == KErrNone)
   1.116 +	          	{
   1.117 +	          	TInt arrayIndex(0);
   1.118 +	          	//Checking Implementation UID
   1.119 +         		TUid eImplUid = KNullUid;
   1.120 +		        TInt tempImplUid(0);
   1.121 +		        
   1.122 +		        if (!GetHexFromConfig(ConfigSection(), KImplUID, tempImplUid))
   1.123 +					{
   1.124 +					INFO_PRINTF1(HTML_RED);
   1.125 +		        	ERR_PRINTF1(_L("FAIL: Missing Implementtaion UID"));
   1.126 +		        	INFO_PRINTF1(HTML_RED_OFF);
   1.127 +		        	SetTestStepResult(EFail);
   1.128 +		        	return TestStepResult();
   1.129 +					}
   1.130 +						
   1.131 +				eImplUid.iUid = tempImplUid;
   1.132 +				
   1.133 +	          	TBool foundImplementationUid(EFalse);
   1.134 +		          			          	
   1.135 +		        for(TInt i = 0; (i < iImplCount)  && !(foundImplementationUid); i++)
   1.136 +		        	{
   1.137 +		          	iImplUid = iImplyArrayPtr[i]->ImplementationUid();
   1.138 +		          		
   1.139 +		          	if(eImplUid == iImplUid)
   1.140 +		          		{
   1.141 +		          		foundImplementationUid = ETrue;
   1.142 +		          		arrayIndex = i;
   1.143 +		          		}
   1.144 +	       			}
   1.145 +		          	
   1.146 +	          	if(eImplUid != iImplUid)
   1.147 +	          		{
   1.148 +	          		INFO_PRINTF1(HTML_RED);
   1.149 +			       	ERR_PRINTF3( _L("The Implemenation UID  in this ECom plugin do not match, expected  %d Implementation UID  , got %d iImplementation UID."), eImplUid, iImplUid );
   1.150 +	        		INFO_PRINTF1(HTML_RED_OFF);
   1.151 +			        SetTestStepResult(EFail);
   1.152 +			        return TestStepResult();
   1.153 +	          		}
   1.154 +		  		
   1.155 +		  		//Checking Implementation's Version Numbers
   1.156 +	          	TInt eVersion(0);
   1.157 +	          		          	
   1.158 +		        if (!GetIntFromConfig(ConfigSection(), KExpectedVersion, eVersion))
   1.159 +		           	{
   1.160 +		         	INFO_PRINTF1(HTML_RED);
   1.161 +				    ERR_PRINTF1(_L("FAIL: Missing Version Number in the INI File"));
   1.162 +				    INFO_PRINTF1(HTML_RED_OFF);
   1.163 +				    SetTestStepResult(EFail);
   1.164 +				    return TestStepResult();
   1.165 +		            }
   1.166 +		            
   1.167 +				iVersion = iImplyArrayPtr[arrayIndex]->Version();
   1.168 +		            
   1.169 +		     	if(eVersion != iVersion)
   1.170 +		         	{
   1.171 +		          	INFO_PRINTF1(HTML_RED);
   1.172 +				   	ERR_PRINTF3( _L("The ECom plugin's implementation versions  do not match, expected %d version, got %d version."), eVersion, iVersion );
   1.173 +		        	INFO_PRINTF1(HTML_RED_OFF);
   1.174 +				    SetTestStepResult(EFail);
   1.175 +				    return TestStepResult();
   1.176 +		          	}
   1.177 +		          	
   1.178 +		          	
   1.179 +		        //Checking Implementation's Drive Letter
   1.180 +		        TDriveUnit eDrive;
   1.181 +		        TPtrC tempDrive;
   1.182 +		        
   1.183 +	        	iDrive = iImplyArrayPtr[arrayIndex]->Drive();
   1.184 +		         
   1.185 +		    	if (!GetStringFromConfig(ConfigSection(), KExpectedDrive, tempDrive))
   1.186 +		           	{
   1.187 +		         	INFO_PRINTF1(HTML_RED);
   1.188 +				    ERR_PRINTF1(_L("FAIL: Missing Plugin Drive Letter in the INI File"));
   1.189 +				    INFO_PRINTF1(HTML_RED_OFF);
   1.190 +				    SetTestStepResult(EFail);
   1.191 +				    return TestStepResult();
   1.192 +		        	}
   1.193 +		          	
   1.194 +		        eDrive = tempDrive;
   1.195 +		        		        
   1.196 +		     	if(eDrive!= iDrive)
   1.197 +		        	{
   1.198 +		        	TPtrC eDrv(eDrive.Name());
   1.199 +			        TPtrC iDrv(iDrive.Name());
   1.200 +		        	INFO_PRINTF1(HTML_RED);
   1.201 +				   	ERR_PRINTF3( _L("The ECom plugin's drive letters do not match, expected %S drive, got %S drive."), &eDrv, &iDrv);
   1.202 +				   	INFO_PRINTF1(HTML_RED_OFF);
   1.203 +				    SetTestStepResult(EFail);
   1.204 +				    return TestStepResult();
   1.205 +		        	}
   1.206 +		          	
   1.207 +		        //Checking Implementation's Vendor ID
   1.208 +		        TInt tempVendorID(0);
   1.209 +		        TUid eVendorID = KNullUid; 
   1.210 +								
   1.211 +		        iVendorID = iImplyArrayPtr[arrayIndex]->VendorId();
   1.212 +				  	    		
   1.213 +	    		if (!GetHexFromConfig(ConfigSection(), KExpectedVendorID, tempVendorID))
   1.214 +	    			{
   1.215 +					INFO_PRINTF1(HTML_RED);
   1.216 +			        ERR_PRINTF1(_L("FAIL: Missing vendor UID In the INI File"));
   1.217 +			        INFO_PRINTF1(HTML_RED_OFF);
   1.218 +			        SetTestStepResult(EFail);
   1.219 +			        return TestStepResult();
   1.220 +					}    
   1.221 +		    		
   1.222 +		    	eVendorID.iUid = tempVendorID;
   1.223 +		    		
   1.224 +		    		if(eVendorID != iVendorID)
   1.225 +		          		{
   1.226 +		          		INFO_PRINTF1(HTML_RED);
   1.227 +				       	ERR_PRINTF3( _L("The ECom Vendor IDs do not match, expected %d VID, got %d VID."), eVendorID, iVendorID );
   1.228 +		        		INFO_PRINTF1(HTML_RED_OFF);
   1.229 +				        SetTestStepResult(EFail);
   1.230 +				        return TestStepResult();
   1.231 +		          		}
   1.232 +		          
   1.233 +	          	}
   1.234 +	          		
   1.235 +	          else
   1.236 +	          	{
   1.237 +	          	INFO_PRINTF1(HTML_RED);
   1.238 +	          	INFO_PRINTF2(_L("This is a Negative test whose expected outcome is %d "), testStepOutcome);
   1.239 +	          	INFO_PRINTF1(HTML_RED_OFF);         	
   1.240 +	          	}
   1.241 +          	
   1.242 +           	}
   1.243 +     
   1.244 +        }
   1.245 +    
   1.246 +   	//Reseting The ECOM Array
   1.247 +   	iImplyArrayPtr.ResetAndDestroy();     
   1.248 +   	
   1.249 +   	//Closing session with ECom Server
   1.250 +    REComSession::FinalClose();
   1.251 +    
   1.252 +   	thisThread.HandleCount(endProcessHandleCount, endThreadHandleCount);
   1.253 + 
   1.254 + 	if(startThreadHandleCount != endThreadHandleCount)
   1.255 + 		{
   1.256 + 		INFO_PRINTF1(HTML_RED);
   1.257 +		ERR_PRINTF1( _L("There is a memory leak as the number of thread handles open at the start do not equal the number of handles opened at the end."));
   1.258 +        ERR_PRINTF3(_L("At the start there %d handles open and the end there are %d"), startThreadHandleCount, endThreadHandleCount);
   1.259 +        INFO_PRINTF1(HTML_RED_OFF);
   1.260 +		SetTestStepResult(EFail);
   1.261 +		return TestStepResult();
   1.262 + 		}
   1.263 + 
   1.264 +    thisThread.Close();
   1.265 +    __UHEAP_MARKEND;    
   1.266 +	
   1.267 +	return TestStepResult();
   1.268 +	}
   1.269 +    
   1.270 +
   1.271 +
   1.272 +
   1.273 +
   1.274 +TVerdict CCheckListImplementation::doTestStepPostambleL()
   1.275 +	{
   1.276 +	 return TestStepResult();
   1.277 +	}
   1.278 +
   1.279 +
   1.280 +
   1.281 +
   1.282 +CCheckCreateImplementation::CCheckCreateImplementation(TOperationType aOperationType)
   1.283 +	: iOperationType(aOperationType)
   1.284 +	{
   1.285 +    SetTestStepName(KCreateImpl_ImpId_DtorId_Step);
   1.286 +	}
   1.287 +
   1.288 +TVerdict CCheckCreateImplementation::doTestStepPreambleL()
   1.289 +    {
   1.290 +    SetTestStepResult(EPass);
   1.291 +   
   1.292 +   TInt tempImplUid=0;
   1.293 +   
   1.294 +    if (!GetHexFromConfig(ConfigSection(), KImplUID, tempImplUid))
   1.295 +		{
   1.296 +		INFO_PRINTF1(HTML_RED);
   1.297 +        ERR_PRINTF1(_L("FAIL: Missing Implementation UID"));
   1.298 +        INFO_PRINTF1(HTML_RED_OFF);
   1.299 +        SetTestStepResult(EFail);
   1.300 +        return TestStepResult();
   1.301 +		}    
   1.302 +		
   1.303 +	iImplUid.iUid = tempImplUid;
   1.304 +
   1.305 +    return TestStepResult();
   1.306 +	}
   1.307 +
   1.308 +
   1.309 +TVerdict CCheckCreateImplementation::doTestStepL()
   1.310 + 	{
   1.311 + 	__UHEAP_MARK; 
   1.312 +	
   1.313 +	
   1.314 +	// Check for Memory leaks and also leaking thread handles
   1.315 +	TInt startProcessHandleCount;
   1.316 +	TInt startThreadHandleCount;
   1.317 +	TInt endProcessHandleCount;
   1.318 +	TInt endThreadHandleCount;
   1.319 +	
   1.320 +	RThread thisThread;
   1.321 +	thisThread.HandleCount(startProcessHandleCount, startThreadHandleCount);
   1.322 +
   1.323 +		
   1.324 +	TInt eInt(0);
   1.325 +	
   1.326 +	CEComSwiPluginInterfaceDefiniton* iPluginPtr = CEComSwiPluginInterfaceDefiniton::NewL(iImplUid);
   1.327 +	
   1.328 +	iPluginPtr->ReturnInt(iInt);
   1.329 +	
   1.330 +	
   1.331 +	 if (!GetIntFromConfig(ConfigSection(), KExpectedPluginInt, eInt))
   1.332 +       	{
   1.333 +     	INFO_PRINTF1(HTML_RED);
   1.334 +	    ERR_PRINTF1(_L("FAIL: Missing ReturnInt value Number in the INI File"));
   1.335 +	    INFO_PRINTF1(HTML_RED_OFF);
   1.336 +	    SetTestStepResult(EFail);
   1.337 +	    return TestStepResult();
   1.338 +        }
   1.339 +        
   1.340 +        
   1.341 +      if(eInt != iInt)
   1.342 +  		{
   1.343 +  		INFO_PRINTF1(HTML_RED);
   1.344 +       	ERR_PRINTF3(_L("The values returned from the Plugins ReturnInt() do not match, expected Int Value %d, got %d."), eInt, iInt);
   1.345 +		INFO_PRINTF1(HTML_RED_OFF);
   1.346 +        SetTestStepResult(EFail);
   1.347 +        return TestStepResult();
   1.348 +  		}
   1.349 +
   1.350 +  	delete iPluginPtr;		
   1.351 +
   1.352 +    REComSession::FinalClose();   
   1.353 +
   1.354 +	thisThread.HandleCount(endProcessHandleCount, endThreadHandleCount);
   1.355 + 
   1.356 + 	if(startThreadHandleCount != endThreadHandleCount)
   1.357 + 		{
   1.358 + 		INFO_PRINTF1(HTML_RED);
   1.359 +		ERR_PRINTF1( _L("There is a memory leak as the number of thread handles open at the start do not equal the number of handles opened at the end."));
   1.360 +        ERR_PRINTF3(_L("At the start there %d handles open and the end there are %d"), startThreadHandleCount, endThreadHandleCount);
   1.361 +        INFO_PRINTF1(HTML_RED_OFF);
   1.362 +		SetTestStepResult(EFail);
   1.363 +		return TestStepResult();
   1.364 + 		}
   1.365 + 
   1.366 +    thisThread.Close();
   1.367 +
   1.368 +    __UHEAP_MARKEND;    
   1.369 +	
   1.370 +	return TestStepResult();
   1.371 +	}
   1.372 +
   1.373 +
   1.374 +
   1.375 +TVerdict CCheckCreateImplementation::doTestStepPostambleL()
   1.376 +	{
   1.377 +	 return TestStepResult();
   1.378 +	}
   1.379 +
   1.380 +CCheckCreateImplementation::~CCheckCreateImplementation()
   1.381 +	{
   1.382 +	}
   1.383 +
   1.384 +/** Test step to issue a custom resolver list request so that
   1.385 +the resolver is cached. */
   1.386 +
   1.387 +// constructor
   1.388 +CUseCustomResolver::CUseCustomResolver()
   1.389 +	{
   1.390 +    SetTestStepName(KUseCustomResolverStep);
   1.391 +	}
   1.392 +
   1.393 +// destructor
   1.394 +CUseCustomResolver::~CUseCustomResolver()
   1.395 +	{
   1.396 +	}
   1.397 +
   1.398 +// doTestStepL
   1.399 +TVerdict CUseCustomResolver::doTestStepL()
   1.400 +	{
   1.401 +	TUid resolverUid = KNullUid;
   1.402 +	TInt tempImplUid(0);
   1.403 +	TESTL(GetHexFromConfig(ConfigSection(), KImplUID, tempImplUid));
   1.404 +
   1.405 +	resolverUid.iUid = tempImplUid;
   1.406 +	TEComResolverParams resolverparams;
   1.407 +	_LIT8(KDummyData,"dummy");
   1.408 +	resolverparams.SetDataType(KDummyData);
   1.409 +	RImplInfoPtrArray ifArray;
   1.410 +	TRAPD(err, REComSession::ListImplementationsL(KCustomResolverInterfaceUid,
   1.411 +		resolverparams, resolverUid, ifArray) );
   1.412 +	if (err != KErrNone)
   1.413 +		{
   1.414 +		// In particular looking for KEComErrMismatchedTags
   1.415 +        INFO_PRINTF1(HTML_RED);
   1.416 +		ERR_PRINTF2( _L("Custom Resolver list request failed with %d"), err);
   1.417 +        INFO_PRINTF1(HTML_RED_OFF);
   1.418 +		SetTestStepResult(EFail);
   1.419 +		return EFail;
   1.420 +		}
   1.421 +
   1.422 +	_LIT(KExpectedVersion, "expectedversion");
   1.423 +	TInt expectedVersion;
   1.424 +  	if (GetIntFromConfig(ConfigSection(), KExpectedVersion, expectedVersion))
   1.425 +		{
   1.426 +		for (TInt i = 0; i < ifArray.Count(); i++)
   1.427 +			{
   1.428 +			const CImplementationInformation& impl = *ifArray[i];
   1.429 +			if (impl.ImplementationUid() == resolverUid)
   1.430 +				{
   1.431 +				if (impl.Version() !=  expectedVersion)
   1.432 +					{
   1.433 +					INFO_PRINTF1(HTML_RED);
   1.434 +					ERR_PRINTF3( _L("Expecting ver %d, got %d"), expectedVersion, impl.Version());
   1.435 +					INFO_PRINTF1(HTML_RED_OFF);
   1.436 +					SetTestStepResult(EFail);
   1.437 +					}
   1.438 +				break;
   1.439 +				}
   1.440 +			}
   1.441 +		}
   1.442 +	ifArray.ResetAndDestroy();
   1.443 +    REComSession::FinalClose();
   1.444 +	return TestStepResult();
   1.445 +	}