os/ossrv/lowlevellibsandfws/pluginfw/TestExecute/EComSWITests/src/checkPlugin.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// This File Provides implementations of CCheckListImplementation, which Checks the plugin for availble implementation
sl@0
    15
// and CCheckCreateImplementation, which uses the method provided the ECom Plugin.
sl@0
    16
// 
sl@0
    17
//
sl@0
    18
sl@0
    19
/**
sl@0
    20
 @file
sl@0
    21
*/
sl@0
    22
sl@0
    23
#include <ecom/resolver.h>
sl@0
    24
#include "checkPlugin.h"
sl@0
    25
sl@0
    26
sl@0
    27
CCheckListImplementation::~CCheckListImplementation()
sl@0
    28
	{
sl@0
    29
	}
sl@0
    30
sl@0
    31
sl@0
    32
CCheckListImplementation::CCheckListImplementation(TOperationType aOperationType)
sl@0
    33
	: iOperationType(aOperationType)
sl@0
    34
	{
sl@0
    35
    SetTestStepName(KListImplUidStep);
sl@0
    36
	}
sl@0
    37
	
sl@0
    38
	
sl@0
    39
	
sl@0
    40
TVerdict CCheckListImplementation::doTestStepPreambleL()
sl@0
    41
    {
sl@0
    42
    SetTestStepResult(EPass);
sl@0
    43
    // get step parameters
sl@0
    44
	
sl@0
    45
    TInt tempInterfaceuid=0;
sl@0
    46
 
sl@0
    47
    if (!GetHexFromConfig(ConfigSection(), KInterfaceUID, tempInterfaceuid))
sl@0
    48
		{
sl@0
    49
		INFO_PRINTF1(HTML_RED);
sl@0
    50
        ERR_PRINTF1(_L("FAIL: Missing Interface UID"));
sl@0
    51
        INFO_PRINTF1(HTML_RED_OFF);
sl@0
    52
        SetTestStepResult(EFail);
sl@0
    53
        return TestStepResult();
sl@0
    54
		}    
sl@0
    55
		
sl@0
    56
	 iInterfaceUid.iUid = tempInterfaceuid;
sl@0
    57
	  
sl@0
    58
    return TestStepResult();
sl@0
    59
	}
sl@0
    60
    
sl@0
    61
    
sl@0
    62
    
sl@0
    63
TVerdict CCheckListImplementation::doTestStepL()
sl@0
    64
    {
sl@0
    65
 	__UHEAP_MARK; 
sl@0
    66
  	
sl@0
    67
  	//First find out if the Check Plugin step is supposed to be successful.
sl@0
    68
  	TInt testStepOutcome=KErrNone;
sl@0
    69
  	TInt err = GetIntFromConfig(ConfigSection(), KExpectedErrorCheckPlugin, testStepOutcome);
sl@0
    70
  	if(err !=1) testStepOutcome=KErrNone;
sl@0
    71
sl@0
    72
	
sl@0
    73
	// and leaking thread handles
sl@0
    74
	TInt startProcessHandleCount;
sl@0
    75
	TInt startThreadHandleCount;
sl@0
    76
	TInt endProcessHandleCount;
sl@0
    77
	TInt endThreadHandleCount;
sl@0
    78
	
sl@0
    79
	RThread thisThread;
sl@0
    80
	thisThread.HandleCount(startProcessHandleCount, startThreadHandleCount);
sl@0
    81
sl@0
    82
   
sl@0
    83
    switch (iOperationType)
sl@0
    84
        {
sl@0
    85
        case EUseListImplUid:
sl@0
    86
          	{
sl@0
    87
          	        	
sl@0
    88
	        REComSession::ListImplementationsL(iInterfaceUid, iImplyArrayPtr);
sl@0
    89
          	
sl@0
    90
          	TInt eImplCount(0);   
sl@0
    91
    		iImplCount = iImplyArrayPtr.Count();
sl@0
    92
sl@0
    93
	    	if(!GetIntFromConfig(ConfigSection(), KExpectedCount, eImplCount))
sl@0
    94
          		{
sl@0
    95
          		INFO_PRINTF1(HTML_RED);
sl@0
    96
		        ERR_PRINTF1(_L("FAIL: Missing Implementation Count in the INI File"));
sl@0
    97
		        INFO_PRINTF1(HTML_RED_OFF);
sl@0
    98
		        SetTestStepResult(EFail);
sl@0
    99
		        return TestStepResult();
sl@0
   100
               	}
sl@0
   101
sl@0
   102
          	if(eImplCount != iImplCount)
sl@0
   103
          		{
sl@0
   104
          		INFO_PRINTF1(HTML_RED);
sl@0
   105
		       	ERR_PRINTF3( _L("The number Implemenation(s) in this ECom plugin do not match, expected %d implementation(s), got %d implementation(s)."), eImplCount, iImplCount );
sl@0
   106
        		INFO_PRINTF1(HTML_RED_OFF);
sl@0
   107
		        SetTestStepResult(EFail);
sl@0
   108
		        return TestStepResult();
sl@0
   109
          		}
sl@0
   110
sl@0
   111
          	//Ensuring that the ECom Plugin does have Implementations
sl@0
   112
	   		if( iImplCount > 0 && testStepOutcome == KErrNone)
sl@0
   113
	          	{
sl@0
   114
	          	TInt arrayIndex(0);
sl@0
   115
	          	//Checking Implementation UID
sl@0
   116
         		TUid eImplUid = KNullUid;
sl@0
   117
		        TInt tempImplUid(0);
sl@0
   118
		        
sl@0
   119
		        if (!GetHexFromConfig(ConfigSection(), KImplUID, tempImplUid))
sl@0
   120
					{
sl@0
   121
					INFO_PRINTF1(HTML_RED);
sl@0
   122
		        	ERR_PRINTF1(_L("FAIL: Missing Implementtaion UID"));
sl@0
   123
		        	INFO_PRINTF1(HTML_RED_OFF);
sl@0
   124
		        	SetTestStepResult(EFail);
sl@0
   125
		        	return TestStepResult();
sl@0
   126
					}
sl@0
   127
						
sl@0
   128
				eImplUid.iUid = tempImplUid;
sl@0
   129
				
sl@0
   130
	          	TBool foundImplementationUid(EFalse);
sl@0
   131
		          			          	
sl@0
   132
		        for(TInt i = 0; (i < iImplCount)  && !(foundImplementationUid); i++)
sl@0
   133
		        	{
sl@0
   134
		          	iImplUid = iImplyArrayPtr[i]->ImplementationUid();
sl@0
   135
		          		
sl@0
   136
		          	if(eImplUid == iImplUid)
sl@0
   137
		          		{
sl@0
   138
		          		foundImplementationUid = ETrue;
sl@0
   139
		          		arrayIndex = i;
sl@0
   140
		          		}
sl@0
   141
	       			}
sl@0
   142
		          	
sl@0
   143
	          	if(eImplUid != iImplUid)
sl@0
   144
	          		{
sl@0
   145
	          		INFO_PRINTF1(HTML_RED);
sl@0
   146
			       	ERR_PRINTF3( _L("The Implemenation UID  in this ECom plugin do not match, expected  %d Implementation UID  , got %d iImplementation UID."), eImplUid, iImplUid );
sl@0
   147
	        		INFO_PRINTF1(HTML_RED_OFF);
sl@0
   148
			        SetTestStepResult(EFail);
sl@0
   149
			        return TestStepResult();
sl@0
   150
	          		}
sl@0
   151
		  		
sl@0
   152
		  		//Checking Implementation's Version Numbers
sl@0
   153
	          	TInt eVersion(0);
sl@0
   154
	          		          	
sl@0
   155
		        if (!GetIntFromConfig(ConfigSection(), KExpectedVersion, eVersion))
sl@0
   156
		           	{
sl@0
   157
		         	INFO_PRINTF1(HTML_RED);
sl@0
   158
				    ERR_PRINTF1(_L("FAIL: Missing Version Number in the INI File"));
sl@0
   159
				    INFO_PRINTF1(HTML_RED_OFF);
sl@0
   160
				    SetTestStepResult(EFail);
sl@0
   161
				    return TestStepResult();
sl@0
   162
		            }
sl@0
   163
		            
sl@0
   164
				iVersion = iImplyArrayPtr[arrayIndex]->Version();
sl@0
   165
		            
sl@0
   166
		     	if(eVersion != iVersion)
sl@0
   167
		         	{
sl@0
   168
		          	INFO_PRINTF1(HTML_RED);
sl@0
   169
				   	ERR_PRINTF3( _L("The ECom plugin's implementation versions  do not match, expected %d version, got %d version."), eVersion, iVersion );
sl@0
   170
		        	INFO_PRINTF1(HTML_RED_OFF);
sl@0
   171
				    SetTestStepResult(EFail);
sl@0
   172
				    return TestStepResult();
sl@0
   173
		          	}
sl@0
   174
		          	
sl@0
   175
		          	
sl@0
   176
		        //Checking Implementation's Drive Letter
sl@0
   177
		        TDriveUnit eDrive;
sl@0
   178
		        TPtrC tempDrive;
sl@0
   179
		        
sl@0
   180
	        	iDrive = iImplyArrayPtr[arrayIndex]->Drive();
sl@0
   181
		         
sl@0
   182
		    	if (!GetStringFromConfig(ConfigSection(), KExpectedDrive, tempDrive))
sl@0
   183
		           	{
sl@0
   184
		         	INFO_PRINTF1(HTML_RED);
sl@0
   185
				    ERR_PRINTF1(_L("FAIL: Missing Plugin Drive Letter in the INI File"));
sl@0
   186
				    INFO_PRINTF1(HTML_RED_OFF);
sl@0
   187
				    SetTestStepResult(EFail);
sl@0
   188
				    return TestStepResult();
sl@0
   189
		        	}
sl@0
   190
		          	
sl@0
   191
		        eDrive = tempDrive;
sl@0
   192
		        		        
sl@0
   193
		     	if(eDrive!= iDrive)
sl@0
   194
		        	{
sl@0
   195
		        	TPtrC eDrv(eDrive.Name());
sl@0
   196
			        TPtrC iDrv(iDrive.Name());
sl@0
   197
		        	INFO_PRINTF1(HTML_RED);
sl@0
   198
				   	ERR_PRINTF3( _L("The ECom plugin's drive letters do not match, expected %S drive, got %S drive."), &eDrv, &iDrv);
sl@0
   199
				   	INFO_PRINTF1(HTML_RED_OFF);
sl@0
   200
				    SetTestStepResult(EFail);
sl@0
   201
				    return TestStepResult();
sl@0
   202
		        	}
sl@0
   203
		          	
sl@0
   204
		        //Checking Implementation's Vendor ID
sl@0
   205
		        TInt tempVendorID(0);
sl@0
   206
		        TUid eVendorID = KNullUid; 
sl@0
   207
								
sl@0
   208
		        iVendorID = iImplyArrayPtr[arrayIndex]->VendorId();
sl@0
   209
				  	    		
sl@0
   210
	    		if (!GetHexFromConfig(ConfigSection(), KExpectedVendorID, tempVendorID))
sl@0
   211
	    			{
sl@0
   212
					INFO_PRINTF1(HTML_RED);
sl@0
   213
			        ERR_PRINTF1(_L("FAIL: Missing vendor UID In the INI File"));
sl@0
   214
			        INFO_PRINTF1(HTML_RED_OFF);
sl@0
   215
			        SetTestStepResult(EFail);
sl@0
   216
			        return TestStepResult();
sl@0
   217
					}    
sl@0
   218
		    		
sl@0
   219
		    	eVendorID.iUid = tempVendorID;
sl@0
   220
		    		
sl@0
   221
		    		if(eVendorID != iVendorID)
sl@0
   222
		          		{
sl@0
   223
		          		INFO_PRINTF1(HTML_RED);
sl@0
   224
				       	ERR_PRINTF3( _L("The ECom Vendor IDs do not match, expected %d VID, got %d VID."), eVendorID, iVendorID );
sl@0
   225
		        		INFO_PRINTF1(HTML_RED_OFF);
sl@0
   226
				        SetTestStepResult(EFail);
sl@0
   227
				        return TestStepResult();
sl@0
   228
		          		}
sl@0
   229
		          
sl@0
   230
	          	}
sl@0
   231
	          		
sl@0
   232
	          else
sl@0
   233
	          	{
sl@0
   234
	          	INFO_PRINTF1(HTML_RED);
sl@0
   235
	          	INFO_PRINTF2(_L("This is a Negative test whose expected outcome is %d "), testStepOutcome);
sl@0
   236
	          	INFO_PRINTF1(HTML_RED_OFF);         	
sl@0
   237
	          	}
sl@0
   238
          	
sl@0
   239
           	}
sl@0
   240
     
sl@0
   241
        }
sl@0
   242
    
sl@0
   243
   	//Reseting The ECOM Array
sl@0
   244
   	iImplyArrayPtr.ResetAndDestroy();     
sl@0
   245
   	
sl@0
   246
   	//Closing session with ECom Server
sl@0
   247
    REComSession::FinalClose();
sl@0
   248
    
sl@0
   249
   	thisThread.HandleCount(endProcessHandleCount, endThreadHandleCount);
sl@0
   250
 
sl@0
   251
 	if(startThreadHandleCount != endThreadHandleCount)
sl@0
   252
 		{
sl@0
   253
 		INFO_PRINTF1(HTML_RED);
sl@0
   254
		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."));
sl@0
   255
        ERR_PRINTF3(_L("At the start there %d handles open and the end there are %d"), startThreadHandleCount, endThreadHandleCount);
sl@0
   256
        INFO_PRINTF1(HTML_RED_OFF);
sl@0
   257
		SetTestStepResult(EFail);
sl@0
   258
		return TestStepResult();
sl@0
   259
 		}
sl@0
   260
 
sl@0
   261
    thisThread.Close();
sl@0
   262
    __UHEAP_MARKEND;    
sl@0
   263
	
sl@0
   264
	return TestStepResult();
sl@0
   265
	}
sl@0
   266
    
sl@0
   267
sl@0
   268
sl@0
   269
sl@0
   270
sl@0
   271
TVerdict CCheckListImplementation::doTestStepPostambleL()
sl@0
   272
	{
sl@0
   273
	 return TestStepResult();
sl@0
   274
	}
sl@0
   275
sl@0
   276
sl@0
   277
sl@0
   278
sl@0
   279
CCheckCreateImplementation::CCheckCreateImplementation(TOperationType aOperationType)
sl@0
   280
	: iOperationType(aOperationType)
sl@0
   281
	{
sl@0
   282
    SetTestStepName(KCreateImpl_ImpId_DtorId_Step);
sl@0
   283
	}
sl@0
   284
sl@0
   285
TVerdict CCheckCreateImplementation::doTestStepPreambleL()
sl@0
   286
    {
sl@0
   287
    SetTestStepResult(EPass);
sl@0
   288
   
sl@0
   289
   TInt tempImplUid=0;
sl@0
   290
   
sl@0
   291
    if (!GetHexFromConfig(ConfigSection(), KImplUID, tempImplUid))
sl@0
   292
		{
sl@0
   293
		INFO_PRINTF1(HTML_RED);
sl@0
   294
        ERR_PRINTF1(_L("FAIL: Missing Implementation UID"));
sl@0
   295
        INFO_PRINTF1(HTML_RED_OFF);
sl@0
   296
        SetTestStepResult(EFail);
sl@0
   297
        return TestStepResult();
sl@0
   298
		}    
sl@0
   299
		
sl@0
   300
	iImplUid.iUid = tempImplUid;
sl@0
   301
sl@0
   302
    return TestStepResult();
sl@0
   303
	}
sl@0
   304
sl@0
   305
sl@0
   306
TVerdict CCheckCreateImplementation::doTestStepL()
sl@0
   307
 	{
sl@0
   308
 	__UHEAP_MARK; 
sl@0
   309
	
sl@0
   310
	
sl@0
   311
	// Check for Memory leaks and also leaking thread handles
sl@0
   312
	TInt startProcessHandleCount;
sl@0
   313
	TInt startThreadHandleCount;
sl@0
   314
	TInt endProcessHandleCount;
sl@0
   315
	TInt endThreadHandleCount;
sl@0
   316
	
sl@0
   317
	RThread thisThread;
sl@0
   318
	thisThread.HandleCount(startProcessHandleCount, startThreadHandleCount);
sl@0
   319
sl@0
   320
		
sl@0
   321
	TInt eInt(0);
sl@0
   322
	
sl@0
   323
	CEComSwiPluginInterfaceDefiniton* iPluginPtr = CEComSwiPluginInterfaceDefiniton::NewL(iImplUid);
sl@0
   324
	
sl@0
   325
	iPluginPtr->ReturnInt(iInt);
sl@0
   326
	
sl@0
   327
	
sl@0
   328
	 if (!GetIntFromConfig(ConfigSection(), KExpectedPluginInt, eInt))
sl@0
   329
       	{
sl@0
   330
     	INFO_PRINTF1(HTML_RED);
sl@0
   331
	    ERR_PRINTF1(_L("FAIL: Missing ReturnInt value Number in the INI File"));
sl@0
   332
	    INFO_PRINTF1(HTML_RED_OFF);
sl@0
   333
	    SetTestStepResult(EFail);
sl@0
   334
	    return TestStepResult();
sl@0
   335
        }
sl@0
   336
        
sl@0
   337
        
sl@0
   338
      if(eInt != iInt)
sl@0
   339
  		{
sl@0
   340
  		INFO_PRINTF1(HTML_RED);
sl@0
   341
       	ERR_PRINTF3(_L("The values returned from the Plugins ReturnInt() do not match, expected Int Value %d, got %d."), eInt, iInt);
sl@0
   342
		INFO_PRINTF1(HTML_RED_OFF);
sl@0
   343
        SetTestStepResult(EFail);
sl@0
   344
        return TestStepResult();
sl@0
   345
  		}
sl@0
   346
sl@0
   347
  	delete iPluginPtr;		
sl@0
   348
sl@0
   349
    REComSession::FinalClose();   
sl@0
   350
sl@0
   351
	thisThread.HandleCount(endProcessHandleCount, endThreadHandleCount);
sl@0
   352
 
sl@0
   353
 	if(startThreadHandleCount != endThreadHandleCount)
sl@0
   354
 		{
sl@0
   355
 		INFO_PRINTF1(HTML_RED);
sl@0
   356
		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."));
sl@0
   357
        ERR_PRINTF3(_L("At the start there %d handles open and the end there are %d"), startThreadHandleCount, endThreadHandleCount);
sl@0
   358
        INFO_PRINTF1(HTML_RED_OFF);
sl@0
   359
		SetTestStepResult(EFail);
sl@0
   360
		return TestStepResult();
sl@0
   361
 		}
sl@0
   362
 
sl@0
   363
    thisThread.Close();
sl@0
   364
sl@0
   365
    __UHEAP_MARKEND;    
sl@0
   366
	
sl@0
   367
	return TestStepResult();
sl@0
   368
	}
sl@0
   369
sl@0
   370
sl@0
   371
sl@0
   372
TVerdict CCheckCreateImplementation::doTestStepPostambleL()
sl@0
   373
	{
sl@0
   374
	 return TestStepResult();
sl@0
   375
	}
sl@0
   376
sl@0
   377
CCheckCreateImplementation::~CCheckCreateImplementation()
sl@0
   378
	{
sl@0
   379
	}
sl@0
   380
sl@0
   381
/** Test step to issue a custom resolver list request so that
sl@0
   382
the resolver is cached. */
sl@0
   383
sl@0
   384
// constructor
sl@0
   385
CUseCustomResolver::CUseCustomResolver()
sl@0
   386
	{
sl@0
   387
    SetTestStepName(KUseCustomResolverStep);
sl@0
   388
	}
sl@0
   389
sl@0
   390
// destructor
sl@0
   391
CUseCustomResolver::~CUseCustomResolver()
sl@0
   392
	{
sl@0
   393
	}
sl@0
   394
sl@0
   395
// doTestStepL
sl@0
   396
TVerdict CUseCustomResolver::doTestStepL()
sl@0
   397
	{
sl@0
   398
	TUid resolverUid = KNullUid;
sl@0
   399
	TInt tempImplUid(0);
sl@0
   400
	TESTL(GetHexFromConfig(ConfigSection(), KImplUID, tempImplUid));
sl@0
   401
sl@0
   402
	resolverUid.iUid = tempImplUid;
sl@0
   403
	TEComResolverParams resolverparams;
sl@0
   404
	_LIT8(KDummyData,"dummy");
sl@0
   405
	resolverparams.SetDataType(KDummyData);
sl@0
   406
	RImplInfoPtrArray ifArray;
sl@0
   407
	TRAPD(err, REComSession::ListImplementationsL(KCustomResolverInterfaceUid,
sl@0
   408
		resolverparams, resolverUid, ifArray) );
sl@0
   409
	if (err != KErrNone)
sl@0
   410
		{
sl@0
   411
		// In particular looking for KEComErrMismatchedTags
sl@0
   412
        INFO_PRINTF1(HTML_RED);
sl@0
   413
		ERR_PRINTF2( _L("Custom Resolver list request failed with %d"), err);
sl@0
   414
        INFO_PRINTF1(HTML_RED_OFF);
sl@0
   415
		SetTestStepResult(EFail);
sl@0
   416
		return EFail;
sl@0
   417
		}
sl@0
   418
sl@0
   419
	_LIT(KExpectedVersion, "expectedversion");
sl@0
   420
	TInt expectedVersion;
sl@0
   421
  	if (GetIntFromConfig(ConfigSection(), KExpectedVersion, expectedVersion))
sl@0
   422
		{
sl@0
   423
		for (TInt i = 0; i < ifArray.Count(); i++)
sl@0
   424
			{
sl@0
   425
			const CImplementationInformation& impl = *ifArray[i];
sl@0
   426
			if (impl.ImplementationUid() == resolverUid)
sl@0
   427
				{
sl@0
   428
				if (impl.Version() !=  expectedVersion)
sl@0
   429
					{
sl@0
   430
					INFO_PRINTF1(HTML_RED);
sl@0
   431
					ERR_PRINTF3( _L("Expecting ver %d, got %d"), expectedVersion, impl.Version());
sl@0
   432
					INFO_PRINTF1(HTML_RED_OFF);
sl@0
   433
					SetTestStepResult(EFail);
sl@0
   434
					}
sl@0
   435
				break;
sl@0
   436
				}
sl@0
   437
			}
sl@0
   438
		}
sl@0
   439
	ifArray.ResetAndDestroy();
sl@0
   440
    REComSession::FinalClose();
sl@0
   441
	return TestStepResult();
sl@0
   442
	}