os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/teststepcig711encoderconfig.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.
     1 // Copyright (c) 2007-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 //
    15 
    16 #include "teststepcig711encoderconfig.h"
    17 
    18 
    19 TVerdict CTestStepCIG711EncoderConfig::DoTestStepL()
    20 	{
    21 	iTestStepResult = ETestSuiteError;
    22 
    23 	INFO_PRINTF1(_L("Initializing test CI device"));
    24 
    25 	if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0045-HP")) == 0)
    26 		{
    27 		iTestStepResult = DoTestStep0045L();
    28 		}
    29 	else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0046-HP")) == 0)
    30 		{
    31 		iTestStepResult = DoTestStep0046L();
    32 		}
    33 	else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0047-HP")) == 0)
    34 		{
    35 		iTestStepResult = DoTestStep0047L();
    36 		}
    37 	else if (iTestStepName.Compare(_L("MM-MMF-DEVSOUNDCI-U-0048-HP")) == 0)
    38 		{
    39 		iTestStepResult = DoTestStep0048L();
    40 		}
    41 
    42 	return iTestStepResult;
    43 	}
    44 
    45 
    46 TVerdict CTestStepCIG711EncoderConfig::DoTestStep0045L()
    47 	{
    48 	iTestStepResult = EFail;
    49 
    50 	INFO_PRINTF1(_L("G711EncoderIntfc - Instantiating"));
    51 
    52 	//Initialize - with the UID of our test HwDevice
    53 	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
    54 	TUid testUID = {KUidG711EncoderConfigTestDevice};
    55 	#else
    56 	TFourCC testUID('T','0','1','6');
    57 	#endif
    58 		
    59 	iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
    60 
    61 	if (iTestStepResult != EPass)
    62 		{
    63 		INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
    64 		return EInconclusive;
    65 		}
    66 
    67 	// reset the value as previous test is pass
    68 	iTestStepResult = EFail;  
    69 
    70 	// KUidG711EncoderIntfc
    71 	MG711EncoderIntfc* ptr = static_cast <MG711EncoderIntfc*> (iMMFDevSound->CustomInterface(KUidG711EncoderIntfc));
    72 
    73 	if (ptr)
    74 		{
    75 		INFO_PRINTF1(_L("MG711EncoderIntfc instantiated successfully"));
    76 
    77 		iTestStepResult = EPass;
    78 		}
    79 	else
    80 		{
    81 		ERR_PRINTF1(_L("MG711EncoderIntfc failed to retrieve the interface"));
    82 		}
    83 
    84 	return iTestStepResult;
    85 	}
    86 
    87 
    88 TVerdict CTestStepCIG711EncoderConfig::DoTestStep0046L()
    89 	{
    90 	iTestStepResult = EFail;
    91 	TInt result = KErrGeneral;
    92 
    93 	INFO_PRINTF1(_L("G711EncoderIntfc - SetEncoderMode"));
    94 
    95 	//Initialize - with the UID of our test HwDevice
    96 	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
    97 	TUid testUID = {KUidG711EncoderConfigTestDevice};
    98 	#else
    99 	TFourCC testUID('T','0','1','6');
   100 	#endif
   101 	
   102 	iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
   103 
   104 	if (iTestStepResult != EPass)
   105 		{
   106 		INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
   107 		return EInconclusive;
   108 		}
   109 
   110 	// reset the value as previous test is pass
   111 	iTestStepResult = EFail;
   112 
   113 	// KUidG711EncoderIntfc
   114 	MG711EncoderIntfc* ptr = static_cast <MG711EncoderIntfc*> (iMMFDevSound->CustomInterface(KUidG711EncoderIntfc));
   115 
   116 	if (ptr)
   117 		{
   118 		MG711EncoderIntfc::TEncodeMode encodeMode = MG711EncoderIntfc::EEncULaw;
   119 		TInt setEncodeMode = MG711EncoderIntfc::EEncALaw;
   120 
   121 		result = ptr->SetEncoderMode(encodeMode) ; // call method
   122 		
   123 		if (result == KErrNone)
   124 			{
   125 			// This file is created by the test stub, the plugin device
   126 			_LIT(KFileName, "c:\\temp\\g711EncoderConfig.txt");
   127 
   128 			ReadFileL(KFileName, setEncodeMode);
   129 
   130 			if (static_cast<MG711EncoderIntfc::TEncodeMode>(setEncodeMode) == encodeMode)
   131 				{
   132 				INFO_PRINTF1(_L("MG711EncoderIntfc::SetEncoderMode finished successfully"));
   133 
   134 				iTestStepResult = EPass;
   135 				}
   136 			else
   137 				{
   138 				ERR_PRINTF2(_L("MIlbcEncoderIntfc::SetEncoderMode failed with encodeMode %d"), encodeMode);
   139 				}	
   140 			}
   141 		else
   142 			{
   143 			ERR_PRINTF2(_L("MG711DecoderIntfc::SetEncoderMode failed with error %d"), result);
   144 			}
   145 		}
   146 	else
   147 		{
   148 		INFO_PRINTF1(_L("MG711DecoderIntfc failed to retrieve the interface"));
   149 		iTestStepResult = EInconclusive;
   150 		}
   151 
   152 	return iTestStepResult;
   153 	}
   154 
   155 
   156 TVerdict CTestStepCIG711EncoderConfig::DoTestStep0047L()
   157 	{
   158 	iTestStepResult = EFail;
   159 	TInt result = KErrGeneral;
   160 
   161 	INFO_PRINTF1(_L("G711EncoderIntfc - SetVadMode"));
   162 
   163 	//Initialize - with the UID of our test HwDevice
   164 	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
   165 	TUid testUID = {KUidG711EncoderConfigTestDevice};
   166 	#else
   167 	TFourCC testUID('T','0','1','6');
   168 	#endif
   169 	
   170 	iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
   171 
   172 	if (iTestStepResult != EPass)
   173 		{
   174 		INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
   175 		return EInconclusive;
   176 		}
   177 
   178 	// reset the value as previous test is pass
   179 	iTestStepResult = EFail;
   180 
   181 	// KUidG711EncoderIntfc
   182 	MG711EncoderIntfc* ptr = static_cast <MG711EncoderIntfc*> (iMMFDevSound->CustomInterface(KUidG711EncoderIntfc));
   183 
   184 	if (ptr)
   185 		{
   186 		TBool vadModeOn = EFalse;
   187 
   188 		result = ptr->SetVadMode(ETrue); // call method
   189 
   190 		if (result == KErrNone)
   191 			{
   192 			INFO_PRINTF1(_L("MG711EncoderIntfc::SetVadMode finished successfully"));
   193 
   194 			result = ptr->GetVadMode(vadModeOn);
   195 
   196 			if ( (result == KErrNone) && vadModeOn)
   197 				{
   198 				INFO_PRINTF1(_L("MG711EncoderIntfc::GetVadMode finished successfully"));
   199 
   200 				iTestStepResult = EPass;
   201 				}
   202 			else
   203 				{
   204 				ERR_PRINTF3(_L("MG711EncoderIntfc::GetVadMode failed with result %d  vadModeOn %d"), result, vadModeOn);
   205 				}	
   206 			}
   207 		else
   208 			{
   209 			ERR_PRINTF2(_L("MG711DecoderIntfc::SetVadMode failed with error %d"), result);
   210 			}
   211 		}
   212 	else
   213 		{
   214 		INFO_PRINTF1(_L("MG711EncoderIntfc failed to retrieve the interface"));
   215 		iTestStepResult = EInconclusive;
   216 		}
   217 
   218 	return iTestStepResult;
   219 	}
   220 
   221 
   222 TVerdict CTestStepCIG711EncoderConfig::DoTestStep0048L()
   223 	{
   224 	iTestStepResult = EFail;
   225 	TInt result = KErrGeneral;
   226 
   227 	INFO_PRINTF1(_L("G711EncoderIntfc - GetVadMode"));
   228 
   229 	//Initialize - with the UID of our test HwDevice
   230 	#ifndef SYMBIAN_MULTIMEDIA_A3FDEVSOUND
   231 	TUid testUID = {KUidG711EncoderConfigTestDevice};
   232 	#else
   233 	TFourCC testUID('T','0','1','6');
   234 	#endif
   235 	
   236 	iTestStepResult = TestInitialize(testUID, EMMFStatePlaying);
   237 
   238 	if (iTestStepResult != EPass)
   239 		{
   240 		INFO_PRINTF1(_L("DevSound failed to instantiate the test device"));
   241 		return EInconclusive;
   242 		}
   243 
   244 	// reset the value as previous test is pass
   245 	iTestStepResult = EFail;
   246 
   247 	// KUidG711EncoderIntfc
   248 	MG711EncoderIntfc* ptr = static_cast <MG711EncoderIntfc*> (iMMFDevSound->CustomInterface(KUidG711EncoderIntfc));
   249 
   250 	if (ptr)
   251 		{
   252 		TBool vadModeOn = EFalse;
   253 
   254 		result = ptr->SetVadMode(ETrue); // call method
   255 		
   256 		if (result == KErrNone)
   257 			{
   258 			INFO_PRINTF1(_L("MG711EncoderIntfc::SetVadMode finished successfully"));
   259 
   260 			result = ptr->GetVadMode(vadModeOn);
   261 
   262 			if ( (result == KErrNone) && vadModeOn)
   263 				{
   264 				INFO_PRINTF1(_L("MG711EncoderIntfc::GetVadMode finished successfully"));
   265 
   266 				result = ptr->SetVadMode(EFalse);
   267 				
   268 				if (result == KErrNone)
   269 					{
   270 					INFO_PRINTF1(_L("MG711EncoderIntfc::SetVadMode finished successfully"));
   271 	
   272 					result = ptr->GetVadMode(vadModeOn);
   273 
   274 					if ( (result == KErrNone) && !vadModeOn)
   275 						{
   276 						INFO_PRINTF1(_L("MG711EncoderIntfc::GetVadMode finished successfully"));
   277 
   278 						iTestStepResult = EPass;
   279 						}
   280 					else
   281 						{
   282 						ERR_PRINTF3(_L("MG711EncoderIntfc::GetVadMode failed with result %d  vadModeOn %d"), result, vadModeOn);
   283 						}
   284 					}
   285 				else
   286 					{
   287 					ERR_PRINTF2(_L("MG711EncoderIntfc::SetVadMode failed with result %d"), result);
   288 					}
   289 				}
   290 			else
   291 				{
   292 				ERR_PRINTF3(_L("MG711EncoderIntfc::GetVadMode failed with result %d  vadModeOn %d"), result, vadModeOn);
   293 				}
   294 			}
   295 		else
   296 			{
   297 			ERR_PRINTF2(_L("MG711EncoderIntfc::SetVadMode failed with result %d"), result);	
   298 			}
   299 		}
   300 	else
   301 		{
   302 		INFO_PRINTF1(_L("MG711EncoderIntfc failed to retrieve the interface"));
   303 		iTestStepResult = EInconclusive;
   304 		}
   305 
   306 	return iTestStepResult;
   307 	}