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