omxil/mmilapi/unittest/src/tsu_milif_omxiliftests.cpp
changeset 56 b6488ac24ddc
parent 47 481b3bce574a
child 57 1cbb0d5bf7f2
equal deleted inserted replaced
47:481b3bce574a 56:b6488ac24ddc
     1 // Copyright (c) 2008-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 // Implementation of Unit test step classes for MILIF testing.
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "tsu_milif_omxiliftests.h"
       
    19 #include "iltestuids.hrh"
       
    20 #include "ilcomponentif.h"
       
    21 #include "tilstructtypes.h"
       
    22 #include "tomxilstruct.h"
       
    23 #include <openmax/il/khronos/v1_x/OMX_Core.h>
       
    24 
       
    25 _LIT8(KDummyDecoderILComponentName,"OMX.SYMBIAN.AUDIO.DECODER.DUMMY");
       
    26 _LIT8(KExtensionPortDefinitionName,"OMX.CompanyXYZ.index.param.PortDefinition");
       
    27 _LIT8(KFakeRole,"audio_decoder.vrb");
       
    28 
       
    29 const TUid KUidFormatAAC = {0x1028347C};
       
    30 
       
    31 const TInt KMaxComponentRoleLength = 128;
       
    32 
       
    33 const TInt KZerothPort = 0;
       
    34 
       
    35 
       
    36 //
       
    37 // RTestStepMILIFBase: Base class for all RTestStepMILIF* tests
       
    38 //
       
    39 
       
    40 /*
       
    41  *
       
    42  * RTestStepMILIFBase - Test step constructor
       
    43  *
       
    44  */
       
    45 RTestStepMILIFBase::RTestStepMILIFBase(const TDesC& aTestName)
       
    46 :RAsyncTestStep()
       
    47 	{
       
    48 	iTestStepName = aTestName; 
       
    49 	}
       
    50 
       
    51 /*
       
    52  *
       
    53  * KickoffTestL - Starts the test
       
    54  *
       
    55  */
       
    56 void RTestStepMILIFBase::KickoffTestL()
       
    57 	{
       
    58 	__MM_HEAP_MARK;
       
    59 	
       
    60 	DoKickoffTestL();
       
    61 	DoTestBody();
       
    62 	}
       
    63 
       
    64 /*
       
    65  *
       
    66  * DoKickoffTestL
       
    67  *
       
    68  */
       
    69 void RTestStepMILIFBase::DoKickoffTestL()
       
    70 	{
       
    71   	OMX_Init();
       
    72 
       
    73 	if ((iTestStepName == _L("MM-MILIF-DUMMYOMXILIF-U-0001"))||
       
    74 		(iTestStepName == _L("MM-MILIF-DUMMYOMXILIF-U-0002"))||
       
    75 		(iTestStepName == _L("MM-MILIF-DUMMYOMXILIF-U-0003"))||
       
    76 		(iTestStepName == _L("MM-MILIF-DUMMYOMXILIF-U-0004"))||
       
    77 		(iTestStepName == _L("MM-MILIF-DUMMYOMXILIF-U-0005"))||
       
    78 		(iTestStepName == _L("MM-MILIF-DUMMYOMXILIF-U-0006")))
       
    79 		{
       
    80 		INFO_PRINTF1(_L("1. Create an instance of the KUidOmxILAudioDecGenericIf test ECOM plugin interface."));
       
    81 		TRAPD(error, iDummyComponent = CILComponentIf::CreateImplementationL(TUid::Uid(KUidOmxILDummyAudioDecMILIFPlugin)));
       
    82 		if(error != KErrNone)
       
    83 			{
       
    84 			ERR_PRINTF2(_L("	ERROR! - Could not instantiate the generic audio decoder OMX IL test ECOM plugin interface: error = %d"), error);
       
    85 			StopTest(error, EFail);
       
    86 			return;
       
    87 			}	
       
    88 
       
    89 		INFO_PRINTF1(_L("2. Use the interface to instanciate a dummy omx component."));
       
    90 		TRAP(error, iDummyComponent->CreateComponentL(KDummyDecoderILComponentName, *this));
       
    91 		if(error != KErrNone)
       
    92 			{
       
    93 			ERR_PRINTF2(_L("	ERROR! - Could not create omx component: error = %d"), error);
       
    94 			StopTest(error, EFail);
       
    95 			return;
       
    96 			}
       
    97 				
       
    98 		INFO_PRINTF1(_L("3. Set the role of the interface."));
       
    99 		error = iDummyComponent->SetComponentIfRole(KUidFormatAAC); 
       
   100 		if(error != KErrNone)
       
   101 			{
       
   102 			ERR_PRINTF2(_L("	ERROR! - Could not set the role of the interface: error = %d"), error);
       
   103 			StopTest(error, EFail);
       
   104 			}	
       
   105 		}
       
   106 	else
       
   107 		{
       
   108 		StopTest(KErrGeneral, EFail);	
       
   109 		}
       
   110 	}
       
   111 
       
   112 /*
       
   113  *
       
   114  * DoTestBodyL
       
   115  *
       
   116  */
       
   117 void RTestStepMILIFBase::DoTestBody()
       
   118 	{
       
   119 	// Nothing to do in the base class
       
   120 	}
       
   121 	
       
   122 /*
       
   123  *
       
   124  * CloseTest
       
   125  *
       
   126  */
       
   127 void RTestStepMILIFBase::CloseTest()
       
   128 	{
       
   129 	if (iDummyComponent)
       
   130 		{
       
   131 		iDummyComponent->ReleaseComponent();
       
   132 		iDummyComponent = NULL;
       
   133 		}
       
   134 
       
   135 	iComponentInPortIf = NULL;
       
   136 	iComponentOutPortIf = NULL;
       
   137 	
       
   138 	OMX_Deinit();
       
   139 	
       
   140 	__MM_HEAP_MARKEND;
       
   141 	}
       
   142 
       
   143 /*
       
   144  *
       
   145  * MsgFromILComponent - Callback from component for component events
       
   146  *
       
   147  */
       
   148 TInt RTestStepMILIFBase::MsgFromILComponent(const MILComponentIf* /*aComponent*/, const TILEvent& /*aEvent*/)
       
   149 	{
       
   150 	// Nothing to do in the base class	
       
   151 	return KErrNotSupported;
       
   152 	}
       
   153 
       
   154 /*
       
   155  *
       
   156  * BufferDelivered	- Callback from component for buffer delivered events
       
   157  *
       
   158  */
       
   159 TInt RTestStepMILIFBase::BufferDelivered(const MILComponentPortIf* /*aPort*/, const CMMFBuffer* /*aBuffer*/)
       
   160 	{
       
   161 	// Nothing to do in the base class	
       
   162 	return KErrNotSupported;
       
   163 	}
       
   164 
       
   165 
       
   166 //
       
   167 // RTestStepMILIFPorts: To test access to IL component ports through MILIF.
       
   168 //
       
   169 
       
   170 /*
       
   171  *
       
   172  * RTestStepMILIFPorts - Test step constructor
       
   173  *
       
   174  */
       
   175 RTestStepMILIFPorts::RTestStepMILIFPorts(const TDesC& aTestName)
       
   176 	:RTestStepMILIFBase(aTestName)
       
   177 	{
       
   178 	}
       
   179 	
       
   180 /*
       
   181  *
       
   182  * NewL
       
   183  *
       
   184  */
       
   185 RTestStepMILIFPorts* RTestStepMILIFPorts::NewL(const TDesC& aTestName)
       
   186 	{
       
   187 	return (new (ELeave) RTestStepMILIFPorts(aTestName));
       
   188 	}
       
   189 
       
   190 /*
       
   191  *
       
   192  * DoKickoffTestL
       
   193  *
       
   194  */
       
   195 void RTestStepMILIFPorts::DoKickoffTestL()
       
   196 	{
       
   197 	INFO_PRINTF1(_L("RTestStepMILIFPorts: To test access to IL component ports through MILIF interface."));
       
   198 	
       
   199 	RTestStepMILIFBase::DoKickoffTestL();
       
   200 	}
       
   201 	
       
   202 /*
       
   203  *
       
   204  * DoTestBodyL
       
   205  *
       
   206  */
       
   207 void RTestStepMILIFPorts::DoTestBody()
       
   208 	{
       
   209 	RPointerArray<MILComponentPortIf> ifPorts;
       
   210 
       
   211 	INFO_PRINTF1(_L("4. Get Component Input ports through MILIF interface."));
       
   212 	TInt error = iDummyComponent->GetComponentInputPorts(ifPorts);		
       
   213 	if (error == KErrNone && ifPorts.Count() == 1)
       
   214 		{
       
   215 		iComponentInPortIf = ifPorts[KZerothPort];
       
   216 		ifPorts.Close();	
       
   217 		}
       
   218 	else
       
   219 		{
       
   220 		if (ifPorts.Count() != 1)
       
   221 			{
       
   222 			error = KErrNotFound;
       
   223 			}
       
   224 		ifPorts.Close();	
       
   225 		ERR_PRINTF2(_L("	ERROR! - Fail to grab input ports: error = %d"), error);
       
   226 		StopTest(error, EFail);
       
   227 		return;
       
   228 		}	
       
   229 
       
   230 
       
   231 	INFO_PRINTF1(_L("5. Get Component Output ports through MILIF interface."));
       
   232 	error = iDummyComponent->GetComponentOutputPorts(ifPorts);		
       
   233 	if (error == KErrNone && ifPorts.Count() > 0)
       
   234 		{
       
   235 		iComponentOutPortIf = ifPorts[KZerothPort];
       
   236 		ifPorts.Close();	
       
   237 		}
       
   238 	else
       
   239 		{
       
   240 		if (ifPorts.Count() != 1)
       
   241 			{
       
   242 			error = KErrNotFound;
       
   243 			}
       
   244 		ifPorts.Close();	
       
   245 		ERR_PRINTF2(_L("	ERROR! - Fail to grab output ports: error = %d"), error);
       
   246 		StopTest(error, EFail);
       
   247 		return;
       
   248 		}	
       
   249 	StopTest(KErrNone);
       
   250 	}
       
   251 
       
   252 
       
   253 //
       
   254 // RTestStepMILIFConfig: To test configuration of IL component through MILIF.
       
   255 //
       
   256 
       
   257 /*
       
   258  *
       
   259  * RTestStepMILIFConfig - Test step constructor
       
   260  *
       
   261  */
       
   262 RTestStepMILIFConfig::RTestStepMILIFConfig(const TDesC& aTestName)
       
   263 :RTestStepMILIFBase(aTestName)
       
   264 	{
       
   265 	}
       
   266 
       
   267 /*
       
   268  *
       
   269  * NewL
       
   270  *
       
   271  */
       
   272 RTestStepMILIFConfig* RTestStepMILIFConfig::NewL(const TDesC& aTestName)
       
   273 	{
       
   274 	RTestStepMILIFConfig* self = new (ELeave) RTestStepMILIFConfig(aTestName);
       
   275 	return self;
       
   276 	}
       
   277 
       
   278 /*
       
   279  *
       
   280  * DoKickoffTestL
       
   281  *
       
   282  */
       
   283 void RTestStepMILIFConfig::DoKickoffTestL()
       
   284 	{
       
   285 	INFO_PRINTF1(_L("RTestStepMILIFConfig: To test configuration of the IL component through MILIF interface."));
       
   286 	
       
   287 	RTestStepMILIFBase::DoKickoffTestL();
       
   288 	}
       
   289 
       
   290 /*
       
   291  *
       
   292  * DoTestBodyL - 
       
   293  *
       
   294  */
       
   295 void RTestStepMILIFConfig::DoTestBody()
       
   296 	{
       
   297 	TInt error = KErrNone;
       
   298 
       
   299 	INFO_PRINTF1(_L("4. Get Component Input ports through MILIF interface."));
       
   300 	RPointerArray<MILComponentPortIf> ifPorts;
       
   301 	error = iDummyComponent->GetComponentInputPorts(ifPorts);		
       
   302 	if (error == KErrNone && ifPorts.Count() == 1)
       
   303 		{
       
   304 		iComponentInPortIf = ifPorts[KZerothPort];
       
   305 		ifPorts.Close();	
       
   306 		}
       
   307 	else
       
   308 		{
       
   309 		if (ifPorts.Count() != 1)
       
   310 			{
       
   311 			error = KErrNotFound;
       
   312 			}
       
   313 		ifPorts.Close();	
       
   314 		ERR_PRINTF2(_L("	ERROR! - Fail to grab input ports: error = %d"), error);
       
   315 		StopTest(error, EFail);
       
   316 		return;
       
   317 		}
       
   318 	
       
   319 	INFO_PRINTF1(_L("5a. Set a (partial) config port parameter through the interface."));
       
   320 	INFO_PRINTF1(_L("		Using TPortDefinitionType and TILPortDefinition."));
       
   321 	TPortDefinitionType partialConfig_s;
       
   322 	partialConfig_s.nBufferCountActual = 1;
       
   323 	TILPortDefinition paramStruct_s(partialConfig_s);
       
   324 	error = iDummyComponent->SetConfig(paramStruct_s, iComponentInPortIf);
       
   325 	if (error != KErrNone)
       
   326 		{
       
   327 		ERR_PRINTF2(_L("	ERROR! - Fail to set TILPortDefinition: error = %d"), error);
       
   328 		StopTest(error, EFail);
       
   329 		return;
       
   330 		}
       
   331 
       
   332 	INFO_PRINTF1(_L("5b. Now Get the TPortDefinitionType config parameter through the interface."));
       
   333 	TILPortDefinition paramStruct_g;
       
   334 	TPortDefinitionType* partialConfig_g = NULL;
       
   335 	error = iDummyComponent->GetConfig(paramStruct_g, iComponentInPortIf);
       
   336 	if (error != KErrNone)
       
   337 		{
       
   338 		ERR_PRINTF2(_L("	ERROR! - Fail to get TILPortDefinition: error = %d"), error);
       
   339 		StopTest(error, EFail);
       
   340 		return;
       
   341 		}
       
   342  	partialConfig_g = TILPortDefinition::GetStructure(paramStruct_g);		
       
   343 	if(partialConfig_g->nBufferCountActual != 1)
       
   344 		{
       
   345 		ERR_PRINTF1(_L("	ERROR! - Unexpected value. The get value does not match the value set."));
       
   346 		StopTest(KErrCorrupt, EFail);
       
   347 		return;
       
   348 		}
       
   349 		
       
   350 	if ((iTestStepName == _L("MM-MILIF-DUMMYOMXILIF-U-0002")))
       
   351 		{
       
   352 		INFO_PRINTF1(_L("6a. Configure component through the interface."));
       
   353 		INFO_PRINTF1(_L("		Using TOMXILStructParam and TILPortDefinition."));
       
   354 		OMX_PARAM_PORTDEFINITIONTYPE omxconfig_s;
       
   355 		omxconfig_s.nBufferCountActual = 3;
       
   356 		TOMXILStructParam omxParamStruct_s(&omxconfig_s, OMX_IndexParamPortDefinition);
       
   357 		error = iDummyComponent->SetConfig(omxParamStruct_s, iComponentInPortIf);
       
   358 		if (error != KErrNone)
       
   359 			{
       
   360 			ERR_PRINTF2(_L("	ERROR! - Fail to set TOMXILStructParam: error = %d"), error);
       
   361 			StopTest(error, EFail);
       
   362 			return;
       
   363 			}
       
   364 
       
   365 		INFO_PRINTF1(_L("6b. Now Get the TOMXILStructParam config parameter through the interface."));
       
   366 		OMX_PARAM_PORTDEFINITIONTYPE omxconfig_g;
       
   367 		TOMXILStructParam omxParamStruct_g(&omxconfig_g, OMX_IndexParamPortDefinition);
       
   368 		error = iDummyComponent->GetConfig(omxParamStruct_g, iComponentInPortIf);
       
   369 		if (error != KErrNone)
       
   370 			{
       
   371 			ERR_PRINTF2(_L("	ERROR! - Fail to get TOMXILStructParam: error = %d"), error);
       
   372 			StopTest(error, EFail);
       
   373 			return;
       
   374 			}
       
   375 		if(omxconfig_g.nBufferCountActual != 3)
       
   376 			{
       
   377 			ERR_PRINTF1(_L("	ERROR! - Unexpected value. The get value does not match the value set."));
       
   378 			StopTest(KErrCorrupt, EFail);
       
   379 			return;
       
   380 			}
       
   381 		}
       
   382 		
       
   383 	StopTest(KErrNone);
       
   384 	}
       
   385 
       
   386 
       
   387 //
       
   388 // RTestStepMILIFStates: To test driving the IL component state machine through MILIF.
       
   389 //
       
   390 
       
   391 /*
       
   392  *
       
   393  * RTestStepMILIFStates - Test step constructor
       
   394  *
       
   395  */
       
   396 RTestStepMILIFStates::RTestStepMILIFStates(const TDesC& aTestName)
       
   397 :RTestStepMILIFBase(aTestName)
       
   398 	{
       
   399 	}
       
   400 
       
   401 /*
       
   402  *
       
   403  * NewL
       
   404  *
       
   405  */
       
   406 RTestStepMILIFStates* RTestStepMILIFStates::NewL(const TDesC& aTestName)
       
   407 	{
       
   408 	RTestStepMILIFStates* self = new (ELeave) RTestStepMILIFStates(aTestName);
       
   409 	return self;
       
   410 	}
       
   411 
       
   412 /*
       
   413  *
       
   414  * DoKickoffTestL
       
   415  *
       
   416  */
       
   417 void RTestStepMILIFStates::DoKickoffTestL()
       
   418 	{
       
   419 	INFO_PRINTF1(_L("RTestStepMILIFStates: To test driving the IL component state machine through MILIF interface."));
       
   420 	
       
   421 	RTestStepMILIFBase::DoKickoffTestL();
       
   422 	}
       
   423 	
       
   424 /*
       
   425  *
       
   426  * DoTestBodyL - 
       
   427  *
       
   428  */
       
   429 void RTestStepMILIFStates::DoTestBody()
       
   430 	{
       
   431 	Fsm(EEventInit, KErrNone); 
       
   432 	}
       
   433 	
       
   434 /*
       
   435  *
       
   436  * Fsm - Executes this test events in sequence
       
   437  *
       
   438  *
       
   439  */
       
   440 void RTestStepMILIFStates::Fsm(TTestEvents aEvent, TInt aError)
       
   441 	{
       
   442 	TInt error = KErrNone;
       
   443 	
       
   444 	switch (iTestState)
       
   445 		{
       
   446 		case ETestStateStart:
       
   447 			{
       
   448 			if (aEvent == EEventInit)
       
   449 				{
       
   450 				INFO_PRINTF1(_L("4. Trigger transition from Load to Idle in component by calling Initialize()"));
       
   451 				error = iDummyComponent->Initialize();
       
   452 				if (error != KErrNone)
       
   453 					{
       
   454 					ERR_PRINTF2(_L("	ERROR! - MILComponentIf::Initialize() error = %d"), error);
       
   455 					StopTest(error, EFail);
       
   456 					break;
       
   457 					}
       
   458 				INFO_PRINTF1(_L("	-> Test State: EStatePlayInitializing"));
       
   459 				iTestState = ETestStateInitializing;
       
   460 				}
       
   461 			else
       
   462 				{
       
   463 				ERR_PRINTF2(_L("	ERROR! - ETestStateStart did not received expected event. Received event: %d"), aEvent);
       
   464 				StopTest(aError, EFail);
       
   465 				}
       
   466 			break;
       
   467 			}
       
   468 			
       
   469 		case ETestStateInitializing:
       
   470 			{
       
   471 			if (aEvent == EEventInitComplete)
       
   472 				{
       
   473 				INFO_PRINTF1(_L("5a. Check the component was left in the correct state after EEventInitComplete event"));
       
   474 				TILComponentState aState;
       
   475 				error = iDummyComponent->GetState(aState);
       
   476 				if ((error != KErrNone) || (aState != EComponentIdle))
       
   477 					{
       
   478 					ERR_PRINTF3(_L("	ERROR! - MILComponentIf::GetState Incorrect state = %d, error = %d."), error, aState);
       
   479 					if (aState != EComponentIdle)
       
   480 						{
       
   481 						error = KErrGeneral;	
       
   482 						}
       
   483 					StopTest(error, EFail);
       
   484 					break;
       
   485 					}
       
   486 
       
   487 				INFO_PRINTF1(_L("5b. Trigger transition from Idle to Execute in component by calling Execute()"));
       
   488 				error = iDummyComponent->Execute();
       
   489 				if (error != KErrNone)
       
   490 					{
       
   491 					ERR_PRINTF2(_L("	ERROR! - MILComponentIf::Execute() error = %d"), error);
       
   492 					StopTest(error, EFail);
       
   493 					break;
       
   494 					}
       
   495 				INFO_PRINTF1(_L("	-> Test State: EStatePlayInitialized"));
       
   496 				iTestState = ETestStateInitialized;
       
   497 				}
       
   498 			else
       
   499 				{
       
   500 				ERR_PRINTF2(_L("	ERROR! - ETestStateInitializing did not received expected event. Received event: %d"), aEvent);
       
   501 				StopTest(aError, EFail);
       
   502 				}
       
   503 			break;
       
   504 			}
       
   505 
       
   506 		case ETestStateInitialized:
       
   507 			{
       
   508 			if (aEvent == EEventExecuteComplete)
       
   509 				{
       
   510 				INFO_PRINTF1(_L("6a. Check the component was left in the correct state after EEventExecuteComplete event"));
       
   511 				TILComponentState aState;
       
   512 				error = iDummyComponent->GetState(aState);
       
   513 				if ((error != KErrNone) || (aState != EComponentExecuting))
       
   514 					{
       
   515 					ERR_PRINTF3(_L("	ERROR! - MILComponentIf::GetState Incorrect state = %d, error = %d."), error, aState);
       
   516 					if (aState != EComponentExecuting)
       
   517 						{
       
   518 						error = KErrGeneral;	
       
   519 						}
       
   520 					StopTest(error, EFail);
       
   521 					break;
       
   522 					}
       
   523 
       
   524 				INFO_PRINTF1(_L("6b. Trigger transition from Executing to Pause in component by calling Pause()"));
       
   525 				error = iDummyComponent->Pause();
       
   526 				if (error != KErrNone)
       
   527 					{
       
   528 					ERR_PRINTF2(_L("	ERROR! - MILComponentIf::Pause() error = %d"), error);
       
   529 					StopTest(error, EFail);
       
   530 					break;
       
   531 					}
       
   532 				INFO_PRINTF1(_L("	-> Test State: EStatePlayPausing"));
       
   533 				iTestState = ETestStatePausing;
       
   534 				}
       
   535 			else
       
   536 				{
       
   537 				ERR_PRINTF2(_L("	ERROR! - ETestStateInitialized did not received expected event. Received event: %d"), aEvent);
       
   538 				StopTest(aError, EFail);
       
   539 				}
       
   540 			break;
       
   541 			}
       
   542 
       
   543 		case ETestStatePausing:
       
   544 			{
       
   545 			if (aEvent == EEventPauseComplete)
       
   546 				{
       
   547 				INFO_PRINTF1(_L("7a. Check the component was left in the correct state after EEventPauseComplete event"));
       
   548 				TILComponentState aState;
       
   549 				error = iDummyComponent->GetState(aState);
       
   550 				if ((error != KErrNone) || (aState != EComponentPaused))
       
   551 					{
       
   552 					ERR_PRINTF3(_L("	ERROR! - MILComponentIf::GetState error = %d, state = %d"), error, aState);
       
   553 					if (aState != EComponentPaused)
       
   554 						{
       
   555 						error = KErrGeneral;	
       
   556 						}
       
   557 					StopTest(error, EFail);
       
   558 					break;
       
   559 					}
       
   560 
       
   561 				INFO_PRINTF1(_L("7b. Trigger transition from Pause to Idle in component by calling Stop()"));
       
   562 				error = iDummyComponent->Stop();
       
   563 				if (error != KErrNone)
       
   564 					{
       
   565 					ERR_PRINTF2(_L("	ERROR! - MILComponentIf::Stop() error = %d"), error);
       
   566 					StopTest(error, EFail);
       
   567 					break;
       
   568 					}
       
   569 				INFO_PRINTF1(_L("	-> Test State: ETestStateStopping"));
       
   570 				iTestState = ETestStateStopping;
       
   571 				}
       
   572 			else
       
   573 				{
       
   574 				ERR_PRINTF2(_L("	ERROR! - ETestStatePausing did not received expected event. Received event: %d"), aEvent);
       
   575 				StopTest(aError, EFail);
       
   576 				}
       
   577 			break;
       
   578 			}
       
   579 			
       
   580 		case ETestStateStopping:
       
   581 			{
       
   582 			if (aEvent == EEventStopComplete)
       
   583 				{
       
   584 				INFO_PRINTF1(_L("8. Check the component was left in the correct state after EEventStopComplete event"));
       
   585 				TILComponentState aState;
       
   586 				error = iDummyComponent->GetState(aState);
       
   587 				if ((error != KErrNone) || (aState != EComponentIdle))
       
   588 					{
       
   589 					ERR_PRINTF3(_L("	ERROR! - MILComponentIf::GetState error = %d, state = %d"), error, aState);
       
   590 					if (aState != EComponentIdle)
       
   591 						{
       
   592 						error = KErrGeneral;	
       
   593 						}
       
   594 					StopTest(error, EFail);
       
   595 					break;
       
   596 					}
       
   597 				StopTest(KErrNone);
       
   598 				}
       
   599 			else
       
   600 				{
       
   601 				ERR_PRINTF2(_L("	ERROR! - ETestStateStopping did not received expected event. Received event: %d"), aEvent);
       
   602 				StopTest(aError, EFail);
       
   603 				}
       
   604 			break;
       
   605 			}
       
   606 
       
   607 		default:
       
   608 			{
       
   609 			ERR_PRINTF2(_L("	ERROR! - Invalid state received: %d"), iTestState);
       
   610 			StopTest(KErrGeneral, EFail);
       
   611 			}
       
   612 		}
       
   613 	
       
   614 	}
       
   615 
       
   616 /*
       
   617  *
       
   618  * MsgFromILComponent - 
       
   619  *
       
   620  */
       
   621 TInt RTestStepMILIFStates::MsgFromILComponent(const MILComponentIf* aComponent, const TILEvent& aEvent) 
       
   622 	{
       
   623 	TInt error = KErrNone;
       
   624 	
       
   625 	if (aComponent != iDummyComponent)
       
   626 		{
       
   627 		ERR_PRINTF1(_L("	ERROR! - Invalid callback received"));
       
   628 		StopTest(KErrGeneral, EFail);
       
   629 		return KErrGeneral;
       
   630 		}
       
   631 	
       
   632 	switch (aEvent.iEvent)
       
   633 		{
       
   634 		case EEventCmdComplete:
       
   635 			{
       
   636 			if (aEvent.iData1 == ECommandStateSet)
       
   637 				{
       
   638 				if (aEvent.iData2 == EComponentIdle)
       
   639 					{
       
   640 					INFO_PRINTF1(_L(" MsgFromILComponent:EEventCmdComplete -> EComponentIdle received"));
       
   641 					if (iTestState == ETestStateInitializing)
       
   642 						{
       
   643 						Fsm(EEventInitComplete, KErrNone); 
       
   644 						}
       
   645 					else if (iTestState == ETestStateStopping)
       
   646 						{
       
   647 						Fsm(EEventStopComplete, KErrNone); 
       
   648 						}
       
   649 					else
       
   650 						{
       
   651 						ERR_PRINTF1(_L("	ERROR! - Unexpected callback received"));
       
   652 						error = KErrGeneral;
       
   653 						}
       
   654 					}
       
   655 				else if(aEvent.iData2 == EComponentExecuting)
       
   656 					{
       
   657 					INFO_PRINTF1(_L(" MsgFromILComponent:EEventCmdComplete -> EComponentExecuting received"));
       
   658 					if (iTestState == ETestStateInitialized)
       
   659 						{
       
   660 						Fsm(EEventExecuteComplete, KErrNone); 
       
   661 						}
       
   662 					else
       
   663 						{
       
   664 						ERR_PRINTF1(_L("	ERROR! - Unexpected callback received"));
       
   665 						error = KErrGeneral;
       
   666 						}
       
   667 					}
       
   668 				else if(aEvent.iData2 == EComponentPaused)
       
   669 					{
       
   670 					INFO_PRINTF1(_L(" MsgFromILComponent:EEventCmdComplete -> EComponentPaused received"));
       
   671 					if (iTestState == ETestStatePausing)
       
   672 						{
       
   673 						Fsm(EEventPauseComplete, KErrNone); 
       
   674 						}
       
   675 					else
       
   676 						{
       
   677 						ERR_PRINTF1(_L("	ERROR! - Unexpected callback received"));
       
   678 						error = KErrGeneral;
       
   679 						}
       
   680 					}
       
   681 				else
       
   682 					{
       
   683 					ERR_PRINTF1(_L("	ERROR! - Unexpected callback received"));
       
   684 					error = KErrGeneral;
       
   685 					}			
       
   686 				break;
       
   687 				}
       
   688 			}
       
   689 		default:
       
   690 			{
       
   691 			ERR_PRINTF1(_L("	ERROR! - Unexpected callback received"));
       
   692 			error = KErrNotSupported;
       
   693 			}
       
   694 		}
       
   695 
       
   696 		if (error != KErrNone)
       
   697 			{
       
   698 			StopTest(error, EFail);
       
   699 			}
       
   700 		return error;
       
   701 	}
       
   702 
       
   703 		
       
   704 //
       
   705 // RTestStepMILIFCommands: To test sending commands to the IL component through MILIF.
       
   706 //
       
   707 
       
   708 /*
       
   709  *
       
   710  * RTestStepMILIFCommands - Test step constructor
       
   711  *
       
   712  */
       
   713 RTestStepMILIFCommands::RTestStepMILIFCommands(const TDesC& aTestName)
       
   714 :RTestStepMILIFBase(aTestName)
       
   715 	{
       
   716 	}
       
   717 
       
   718 /*
       
   719  *
       
   720  * NewL
       
   721  *
       
   722  */
       
   723 RTestStepMILIFCommands* RTestStepMILIFCommands::NewL(const TDesC& aTestName)
       
   724 	{
       
   725 	RTestStepMILIFCommands* self = new (ELeave) RTestStepMILIFCommands(aTestName);
       
   726 	return self;
       
   727 	}
       
   728 
       
   729 /*
       
   730  *
       
   731  * DoKickoffTestL
       
   732  *
       
   733  */
       
   734 void RTestStepMILIFCommands::DoKickoffTestL()
       
   735 	{
       
   736 	INFO_PRINTF1(_L("RTestStepMILIFCommands: To test sending commands to the IL component through MILIF interface."));
       
   737 	
       
   738 	RTestStepMILIFBase::DoKickoffTestL();
       
   739 	}
       
   740 
       
   741 /*
       
   742  *
       
   743  * DoTestBodyL - 
       
   744  *
       
   745  */
       
   746 void RTestStepMILIFCommands::DoTestBody()
       
   747 	{
       
   748 	Fsm(EEventInit, KErrNone); 
       
   749 	}
       
   750 	
       
   751 /*
       
   752  *
       
   753  * Fsm	- Executes this test events in sequence
       
   754  *
       
   755  */
       
   756 void RTestStepMILIFCommands::Fsm(TTestEvents aEvent, TInt aError)
       
   757 	{
       
   758 	TInt error = KErrNone;
       
   759 	
       
   760 	switch (iTestState)
       
   761 		{
       
   762 		case ETestStateStart:
       
   763 			{
       
   764 			if (aEvent == EEventInit)
       
   765 				{
       
   766 				INFO_PRINTF1(_L("4. Trigger FlushAllPorts"));
       
   767 				error = iDummyComponent->FlushAllPorts();
       
   768 				if (error != KErrNone)
       
   769 					{
       
   770 					ERR_PRINTF2(_L("	ERROR! - MILComponentIf::FlushAllPorts error = %d"), error);
       
   771 					StopTest(error, EFail);
       
   772 					break;
       
   773 					}
       
   774 				INFO_PRINTF1(_L("	-> Test State: ETestStateFlushing"));
       
   775 				iTestState = ETestStateFlushing;
       
   776 				}
       
   777 			else
       
   778 				{
       
   779 				ERR_PRINTF2(_L("	ERROR! - ETestStateFlushing did not received expected event. Received event: %d"), aEvent);
       
   780 				StopTest(aError, EFail);
       
   781 				}
       
   782 			break;
       
   783 			}
       
   784 
       
   785 		case ETestStateFlushing:
       
   786 			{
       
   787 			if (aEvent == EEventFlushComplete)
       
   788 				{
       
   789 				INFO_PRINTF1(_L("	Flush Command partially completed."));
       
   790 				INFO_PRINTF1(_L("	-> Test State: ETestStateFirstPortFlushed"));
       
   791 				iTestState = ETestStateFirstPortFlushed;
       
   792 				}
       
   793 			else
       
   794 				{
       
   795 				ERR_PRINTF2(_L("	ERROR! - ETestStateFlushing did not received expected event. Received event: %d"), aEvent);
       
   796 				StopTest(aError, EFail);
       
   797 				}
       
   798 			break;
       
   799 			}
       
   800 
       
   801 		case ETestStateFirstPortFlushed:
       
   802 			{
       
   803 			if (aEvent == EEventFlushComplete)
       
   804 				{
       
   805 				INFO_PRINTF1(_L("	Flush Command completed.")); 
       
   806 				INFO_PRINTF1(_L("5. Trigger SendCommand() with ECommandPortDisable"));
       
   807 				TILCommand aCommand;
       
   808 				aCommand.iCmd = ECommandPortDisable;
       
   809 				aCommand.iData1 = 0;
       
   810 				aCommand.iExtraData = NULL;
       
   811 				error = iDummyComponent->SendCommand(aCommand);
       
   812 
       
   813 				INFO_PRINTF1(_L("	-> Test State: ETestStateDisablingPort"));
       
   814 				iTestState = ETestStateDisablingPort;
       
   815 				}
       
   816 			else
       
   817 				{
       
   818 				ERR_PRINTF2(_L("	ERROR! - ETestStateFirstPortFlushed did not received expected event. Received event: %d"), aEvent);
       
   819 				StopTest(aError, EFail);
       
   820 				}
       
   821 			break;
       
   822 			}
       
   823 
       
   824 		case ETestStateDisablingPort:
       
   825 			{
       
   826 			if (aEvent == EEventPortDisableComplete)
       
   827 				{
       
   828 				INFO_PRINTF1(_L("	-> Test State: Port Disabled. Fisnished Test"));
       
   829 				StopTest(KErrNone);
       
   830 				}
       
   831 			else
       
   832 				{
       
   833 				ERR_PRINTF2(_L("	ERROR! - ETestStateInitialized did not received expected event. Received event: %d"), aEvent);
       
   834 				StopTest(aError, EFail);
       
   835 				}
       
   836 			break;
       
   837 			}
       
   838 
       
   839 		default:
       
   840 			{
       
   841 			ERR_PRINTF2(_L("	ERROR! - Invalid state received: %d"), iTestState);
       
   842 			StopTest(KErrGeneral, EFail);
       
   843 			}
       
   844 		}
       
   845 	}
       
   846 
       
   847 /*
       
   848  *
       
   849  * MsgFromILComponent - 
       
   850  *
       
   851  */
       
   852 TInt RTestStepMILIFCommands::MsgFromILComponent(const MILComponentIf* aComponent, const TILEvent& aEvent) 
       
   853 	{
       
   854 	TInt error = KErrNone;
       
   855 
       
   856 	if (aComponent != iDummyComponent)
       
   857 		{
       
   858 		ERR_PRINTF1(_L("	ERROR! - Invalid callback received"));
       
   859 		StopTest(KErrGeneral, EFail);
       
   860 		return KErrGeneral;
       
   861 		}
       
   862 
       
   863 	switch (aEvent.iEvent)
       
   864 		{
       
   865 		case EEventCmdComplete:
       
   866 			{
       
   867 			if (aEvent.iData1 == ECommandFlush)
       
   868 				{
       
   869 				INFO_PRINTF1(_L(" MsgFromILComponent:EEventCmdComplete -> ECommandFlush received"));
       
   870 				Fsm(EEventFlushComplete, KErrNone); 
       
   871 				}
       
   872 			else if (aEvent.iData1 == ECommandPortDisable)
       
   873 				{
       
   874 				INFO_PRINTF1(_L(" MsgFromILComponent:EEventCmdComplete -> ECommandPortDisable received"));
       
   875 				Fsm(EEventPortDisableComplete, KErrNone); 
       
   876 				}
       
   877 			else
       
   878 				{
       
   879 				ERR_PRINTF1(_L("	ERROR! - Unexpected callback received"));
       
   880 				error = KErrGeneral;
       
   881 				}			
       
   882 			break;
       
   883 			}
       
   884 		default:
       
   885 			{
       
   886 			ERR_PRINTF1(_L("	ERROR! - Unexpected callback received"));
       
   887 			error = KErrNotSupported;
       
   888 			}
       
   889 		}
       
   890 
       
   891 		if (error != KErrNone)
       
   892 			{
       
   893 			StopTest(error, EFail);
       
   894 			}
       
   895 		return error;
       
   896 	}
       
   897 
       
   898 
       
   899 //
       
   900 // RTestStepMILIFExtensions: To test configuration of the IL component with extended params through MILIF.
       
   901 //
       
   902 
       
   903 /*
       
   904  *
       
   905  * RTestStepMILIFExtensions - Test step constructor
       
   906  *
       
   907  */
       
   908 RTestStepMILIFExtensions::RTestStepMILIFExtensions(const TDesC& aTestName)
       
   909 :RTestStepMILIFBase(aTestName)
       
   910 	{
       
   911 	}
       
   912 
       
   913 /*
       
   914  *
       
   915  * NewL
       
   916  *
       
   917  */
       
   918 RTestStepMILIFExtensions* RTestStepMILIFExtensions::NewL(const TDesC& aTestName)
       
   919 	{
       
   920 	RTestStepMILIFExtensions* self = new (ELeave) RTestStepMILIFExtensions(aTestName);
       
   921 	return self;
       
   922 	}
       
   923 
       
   924 /*
       
   925  *
       
   926  * DoKickoffTestL
       
   927  *
       
   928  */
       
   929 void RTestStepMILIFExtensions::DoKickoffTestL()
       
   930 	{
       
   931 	INFO_PRINTF1(_L("RTestStepMILIFExtensions: To test configuration of the IL component with extended params through MILIF interface."));
       
   932 	
       
   933 	RTestStepMILIFBase::DoKickoffTestL();
       
   934 	}
       
   935 	
       
   936 /*
       
   937  *
       
   938  * DoTestBodyL - 
       
   939  *
       
   940  */
       
   941 void RTestStepMILIFExtensions::DoTestBody()
       
   942 	{
       
   943 
       
   944 	TInt error = KErrNone;
       
   945 
       
   946 	INFO_PRINTF1(_L("4. Get Component Input ports through MILIF interface."));
       
   947 	RPointerArray<MILComponentPortIf> ifPorts;
       
   948 	error = iDummyComponent->GetComponentInputPorts(ifPorts);		
       
   949 	if (error == KErrNone && ifPorts.Count() == 1)
       
   950 		{
       
   951 		iComponentInPortIf = ifPorts[KZerothPort];
       
   952 		ifPorts.Close();	
       
   953 		}
       
   954 	else
       
   955 		{
       
   956 		if (ifPorts.Count() != 1)
       
   957 			{
       
   958 			error = KErrNotFound;
       
   959 			}
       
   960 		ifPorts.Close();	
       
   961 		StopTest(error, EFail);
       
   962 		return;
       
   963 		}
       
   964 	
       
   965 	INFO_PRINTF1(_L("5a. Set a (partial) config port parameter through the interface's extension mechanism."));
       
   966 	TPortDefinitionType partialConfig_s;
       
   967 	partialConfig_s.nBufferCountActual = 1;
       
   968 	TILPortDefinition paramStruct_s(partialConfig_s);
       
   969 	error = iDummyComponent->SetExtConfig(KExtensionPortDefinitionName, paramStruct_s, iComponentInPortIf);
       
   970 	if ((iTestStepName == _L("MM-MILIF-DUMMYOMXILIF-U-0005")))
       
   971 		{
       
   972 		if (error != KErrNone)
       
   973 			{
       
   974 			ERR_PRINTF2(_L("	ERROR! - Fail to set extension: error = %d"), error);
       
   975 			StopTest(error, EFail);
       
   976 			return;
       
   977 			}
       
   978 		}
       
   979 	else
       
   980 		{
       
   981 		StopTest(KErrGeneral, EFail);
       
   982 		}
       
   983 
       
   984 	INFO_PRINTF1(_L("5b. Get the parameter set in 5a through the interface's extension mechanism."));
       
   985 	TILPortDefinition paramStruct_g;
       
   986 	TPortDefinitionType* partialConfig_g = NULL;
       
   987 	error = iDummyComponent->GetExtConfig(KExtensionPortDefinitionName, paramStruct_g, iComponentInPortIf);
       
   988 	if ((iTestStepName == _L("MM-MILIF-DUMMYOMXILIF-U-0005")))
       
   989 		{
       
   990 		if (error != KErrNone)
       
   991 			{
       
   992 			ERR_PRINTF2(_L("	ERROR! - Fail to get TILPortDefinition: error = %d"), error);
       
   993 			StopTest(error, EFail);
       
   994 			return;
       
   995 			}
       
   996 	 	partialConfig_g = TILPortDefinition::GetStructure(paramStruct_g);		
       
   997 		if(partialConfig_g->nBufferCountActual != 1)
       
   998 			{
       
   999 			ERR_PRINTF1(_L("	ERROR! - Unexpected value. The get value does not match the value set."));
       
  1000 			StopTest(KErrCorrupt, EFail);
       
  1001 			return;
       
  1002 			}
       
  1003 		}
       
  1004 	else
       
  1005 		{
       
  1006 		StopTest(KErrGeneral, EFail);
       
  1007 		return;
       
  1008 		}
       
  1009 		
       
  1010 	StopTest(KErrNone);
       
  1011 	}
       
  1012 
       
  1013 
       
  1014 //
       
  1015 // RTestStepMILIFComponentRole: To test access to the IL component role through MILIF.
       
  1016 //
       
  1017 
       
  1018 /*
       
  1019  *
       
  1020  * RTestStepMILIFComponentRole - Test step constructor
       
  1021  *
       
  1022  */
       
  1023 RTestStepMILIFComponentRole::RTestStepMILIFComponentRole(const TDesC& aTestName)
       
  1024 :RTestStepMILIFBase(aTestName)
       
  1025 	{
       
  1026 	}
       
  1027 
       
  1028 /*
       
  1029  *
       
  1030  * NewL
       
  1031  *
       
  1032  */
       
  1033 RTestStepMILIFComponentRole* RTestStepMILIFComponentRole::NewL(const TDesC& aTestName)
       
  1034 	{
       
  1035 	RTestStepMILIFComponentRole* self = new (ELeave) RTestStepMILIFComponentRole(aTestName);
       
  1036 	return self;
       
  1037 	}
       
  1038 
       
  1039 /*
       
  1040  *
       
  1041  * DoKickoffTestL
       
  1042  *
       
  1043  */
       
  1044 void RTestStepMILIFComponentRole::DoKickoffTestL()
       
  1045 	{
       
  1046 	INFO_PRINTF1(_L("RTestStepMILIFComponentRole: To test access to the IL component role through MILIF interface."));
       
  1047 	
       
  1048 	RTestStepMILIFBase::DoKickoffTestL();
       
  1049 	}
       
  1050 	
       
  1051 /*
       
  1052  *
       
  1053  * DoTestBodyL - 
       
  1054  *
       
  1055  */
       
  1056 void RTestStepMILIFComponentRole::DoTestBody()
       
  1057 	{
       
  1058 	TInt error = KErrNone;
       
  1059 	TInt index = 0;
       
  1060 
       
  1061 	HBufC8* buf = HBufC8::New(KMaxComponentRoleLength);
       
  1062 	if (buf == NULL)
       
  1063 		{
       
  1064 		StopTest(KErrNoMemory, EFail);
       
  1065 		}
       
  1066 	else
       
  1067 		{
       
  1068 		TPtr8 componentRole = buf->Des();
       
  1069 
       
  1070 		INFO_PRINTF1(_L("4. Get component role through MILIF interface."));
       
  1071 		error = iDummyComponent->ComponentRoleEnum(componentRole, index);
       
  1072 
       
  1073 		INFO_PRINTF1(_L("5. Check the component's role returned is the expected role."));
       
  1074 		if (error != KErrNone) 
       
  1075 			{
       
  1076 			ERR_PRINTF2(_L("	ERROR! - MILComponentIf::ComponentRoleEnum failed. Error returned = %d"), error);
       
  1077 			StopTest(error, EFail);
       
  1078 			delete buf;
       
  1079 			return;
       
  1080 			}
       
  1081 		else if	(buf->Compare(KFakeRole) != 0 )
       
  1082 			{
       
  1083 			ERR_PRINTF1(_L("	ERROR! - MILComponentIf::ComponentRoleEnum failed. Unexpected role."));
       
  1084 			StopTest(error, EFail);
       
  1085 			delete buf;
       
  1086 			return;
       
  1087 			}
       
  1088 		StopTest(KErrNone);
       
  1089 		
       
  1090 		delete buf;
       
  1091 		}
       
  1092 	}
       
  1093