os/mm/devsound/a3fcharacterisationtest/src/char_a3f_devsound_tonetest.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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 //
    15 
    16 #include "char_a3f_devsound_tonetest.h"
    17 
    18 
    19 /*
    20  *========================================================================================================
    21  * MM-A3F-DEVSOUND-CHRTZ-TONE-0001
    22  */
    23 RA3FDevSoundToneSetConfigTest::RA3FDevSoundToneSetConfigTest(const TDesC& aTestName)
    24 	:	RA3FDevSoundTestBase(aTestName), iSampleRate(0),
    25 		iChannels(0)
    26 	{
    27 	}
    28 
    29 RA3FDevSoundToneSetConfigTest* RA3FDevSoundToneSetConfigTest::NewL(const TDesC& aTestName)
    30 	{
    31 	RA3FDevSoundToneSetConfigTest * self = new(ELeave)RA3FDevSoundToneSetConfigTest(aTestName);
    32 	return self;
    33 	}
    34 
    35 void RA3FDevSoundToneSetConfigTest::DoKickoffTestL()
    36 	{
    37 	if (!GetIntFromConfig(iTestStepName, KSampleRate, iSampleRate))
    38 		{
    39 		ERR_PRINTF2(KMsgErrorGetParameter, &KSampleRate);
    40 		StopTest(KErrNotFound);
    41 		return;
    42 		}
    43 	if (!GetIntFromConfig(iTestStepName, KChannel, iChannels))
    44 		{
    45 		ERR_PRINTF2(KMsgErrorGetParameter, &KChannel);
    46 		StopTest(KErrNotFound);
    47 		return;
    48 		}
    49 	}
    50 
    51 
    52 void RA3FDevSoundToneSetConfigTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
    53 	{
    54 	switch(iDevSoundState)
    55 		{
    56 		case EStateCreated:
    57 			{
    58 			if(aDevSoundEvent == EEventInitialize)
    59 				{
    60 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetConfigTest"), EFsmIncorrectErrorPassed));
    61 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
    62 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
    63 				if (err != KErrNone)
    64 					{
    65 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
    66 					StopTest(err);
    67 					break;
    68 					}
    69 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
    70 				iDevSoundState = EStateInitializing;
    71 				}
    72 			else
    73 				{
    74 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
    75 				StopTest(aError, EFail);
    76 				}
    77 			break;
    78 			}
    79 		case EStateInitializing:
    80 			{
    81 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
    82 				{
    83 				TMMFCapabilities capabilitiesSet;
    84 				TBuf<KMaxSampleRateStringLength> stringSampleRateSet;
    85 				TBuf<KMaxChannelsStringLength> stringChannelsSet;
    86 				TMMFSampleRate eSampleRate;
    87 				SampleRateFromTIntToTMMFSampleRate (iSampleRate, eSampleRate);
    88 				capabilitiesSet.iRate = eSampleRate;
    89 				capabilitiesSet.iChannels = iChannels;
    90 				SampleRateFromTUintToString (capabilitiesSet.iRate,	stringSampleRateSet);
    91 				ChannelsFromTUintToString (capabilitiesSet.iChannels, stringChannelsSet);
    92 				INFO_PRINTF3(_L("Calling CMMFDevSound::SetConfigL using sample rate = %S and channel mode =%S"), &stringSampleRateSet, &stringChannelsSet);
    93 				TRAPD(err, iMMFDevSound->SetConfigL(capabilitiesSet));
    94 				if (err != KErrNone)
    95 					{
    96 					ERR_PRINTF2(_L("CMMFDevSound::SetConfigL left with error = %d"), err);
    97 					StopTest(err);
    98 					break;
    99 					}
   100 				TMMFCapabilities capabilitiesGet;
   101 				TBuf<KMaxSampleRateStringLength> stringSampleRateGet;
   102 				TBuf<KMaxChannelsStringLength> stringChannelsGet;
   103 				capabilitiesGet=iMMFDevSound->Config();
   104 				SampleRateFromTUintToString (capabilitiesGet.iRate, stringSampleRateGet);
   105 				ChannelsFromTUintToString (capabilitiesGet.iChannels, stringChannelsGet);
   106 				if (capabilitiesGet.iRate != capabilitiesSet.iRate && capabilitiesGet.iChannels != capabilitiesSet.iChannels)
   107 					{
   108 					ERR_PRINTF3(_L("Retrieved sample rate and channel %S %S"), &stringSampleRateGet, &stringChannelsGet);
   109 					ERR_PRINTF3(_L("Expected %S %S"), &stringSampleRateSet, &stringChannelsSet);
   110 					StopTest(aError, EFail);
   111 					break;
   112 					}
   113 				INFO_PRINTF1(_L("========== Test Case Successfully Completed =========="));
   114 				StopTest();
   115 				}
   116 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
   117 				{
   118 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
   119 				StopTest(aError);
   120 				}
   121 			else
   122 				{
   123 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
   124 				StopTest(aError, EFail);
   125 				}
   126 			break;
   127 			}
   128 		default:
   129 			{
   130 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
   131 			StopTest(aError, EFail);
   132 			}
   133 		}
   134 	}
   135 
   136 /*
   137  *========================================================================================================
   138  * MM-A3F-DEVSOUND-CHRTZ-TONE-0002
   139  */
   140 RA3FDevSoundToneSetPrioritySettingsTest::RA3FDevSoundToneSetPrioritySettingsTest(const TDesC& aTestName)
   141 	:	RA3FDevSoundTestBase(aTestName), iPriority(0)
   142 	{
   143 	}
   144 
   145 RA3FDevSoundToneSetPrioritySettingsTest* RA3FDevSoundToneSetPrioritySettingsTest::NewL(const TDesC& aTestName)
   146 	{
   147 	RA3FDevSoundToneSetPrioritySettingsTest * self = new(ELeave)RA3FDevSoundToneSetPrioritySettingsTest(aTestName);
   148 	return self;
   149 	}
   150 
   151 void RA3FDevSoundToneSetPrioritySettingsTest::DoKickoffTestL()
   152 	{
   153 	if (!GetIntFromConfig(iTestStepName, KPriority, iPriority))
   154 		{
   155 		ERR_PRINTF2(KMsgErrorGetParameter, &KPriority);
   156 		StopTest(KErrUnknown);
   157 		}
   158 	}
   159 
   160 void RA3FDevSoundToneSetPrioritySettingsTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
   161 	{
   162 	switch (iDevSoundState)
   163 		{
   164 		case EStateCreated:
   165 			{
   166 			if (aDevSoundEvent == EEventInitialize)
   167 				{
   168 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetPrioritySettingsTest"), EFsmIncorrectErrorPassed));
   169 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
   170 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
   171 				if (err != KErrNone)
   172 					{
   173 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
   174 					StopTest(err);
   175 					break;
   176 					}
   177 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
   178 				iDevSoundState = EStateInitializing;
   179 				}
   180 			else
   181 				{
   182 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
   183 				StopTest(aError, EFail);
   184 				}
   185 			break;
   186 			}
   187 		case EStateInitializing:
   188 			{
   189 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
   190 				{
   191 				TMMFPrioritySettings priority;
   192 				priority.iPriority = iPriority;
   193 				INFO_PRINTF2(_L("Calling CMMFDevSound::SetPrioritySettings using a priority value = %d"), iPriority);
   194 				iMMFDevSound->SetPrioritySettings (priority);
   195 				INFO_PRINTF1(_L("========== Test Case Successfully Completed =========="));
   196 				StopTest();
   197 				}
   198 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
   199 				{
   200 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
   201 				StopTest(aError);
   202 				}
   203 			else
   204 				{
   205 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
   206 				StopTest(aError, EFail);
   207 				}
   208 			break;
   209 			}
   210 		default:
   211 			{
   212 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
   213 			StopTest(aError, EFail);
   214 			}
   215 		}
   216 	}
   217 
   218 /*
   219  *========================================================================================================
   220  * MM-A3F-DEVSOUND-CHRTZ-TONE-0003
   221  */
   222 RA3FDevSoundToneSetVolumeTest::RA3FDevSoundToneSetVolumeTest(const TDesC& aTestName)
   223 	:	RA3FDevSoundTestBase(aTestName), iVolume(0)
   224 	{
   225 	}
   226 
   227 RA3FDevSoundToneSetVolumeTest* RA3FDevSoundToneSetVolumeTest::NewL(const TDesC& aTestName)
   228 	{
   229 	RA3FDevSoundToneSetVolumeTest * self = new(ELeave)RA3FDevSoundToneSetVolumeTest(aTestName);
   230 	return self;
   231 	}
   232 
   233 void RA3FDevSoundToneSetVolumeTest::DoKickoffTestL()
   234 	{
   235 	if (!GetIntFromConfig(iTestStepName, KVolume, iVolume))
   236 		{
   237 		ERR_PRINTF2(KMsgErrorGetParameter, &KVolume);
   238 		StopTest(KErrUnknown);
   239 		return;
   240 		}
   241 	}
   242 
   243 void RA3FDevSoundToneSetVolumeTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
   244 	{
   245 	switch (iDevSoundState)
   246 		{
   247 		case EStateCreated:
   248 			{
   249 			if (aDevSoundEvent == EEventInitialize)
   250 				{
   251 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetVolumeTest"), EFsmIncorrectErrorPassed));
   252 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
   253 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
   254 				if (err != KErrNone)
   255 					{
   256 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
   257 					StopTest(err);
   258 					break;
   259 					}
   260 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
   261 				iDevSoundState = EStateInitializing;
   262 				}
   263 			else
   264 				{
   265 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
   266 				StopTest(aError, EFail);
   267 				}
   268 			break;
   269 			}
   270 		case EStateInitializing:
   271 			{
   272 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
   273 				{
   274 				INFO_PRINTF2(_L("Calling CMMFDevSound::SetVolume with volume value = %d"), iVolume);
   275 				iMMFDevSound->SetVolume(iVolume);
   276 				TInt volumeGet;
   277 				volumeGet=iMMFDevSound->Volume();
   278 				if (volumeGet == iVolume)
   279 					{
   280 					INFO_PRINTF2(_L("CMMFDevSound::SetVolume succeeded with value = %d"), volumeGet);
   281 					StopTest();
   282 					}
   283 				else
   284 					{
   285 					ERR_PRINTF2(_L("CMMFDevSound::SetVolume failed with value = %d"), volumeGet);
   286 					ERR_PRINTF2(_L("Expected value = %d"), iVolume);
   287 					StopTest(aError, EFail);
   288 					}
   289 				}
   290 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
   291 				{
   292 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
   293 				StopTest(aError);
   294 				}
   295 			else
   296 				{
   297 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
   298 				StopTest(aError, EFail);
   299 				}
   300 			break;
   301 			}
   302 		default:
   303 			{
   304 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
   305 			StopTest(aError, EFail);
   306 			}
   307 		}
   308 	}
   309 
   310 /*
   311  *========================================================================================================
   312  * MM-A3F-DEVSOUND-CHRTZ-TONE-0004
   313  */
   314 RA3FDevSoundToneVolumeRampTest::RA3FDevSoundToneVolumeRampTest(const TDesC& aTestName)
   315 	:	RA3FDevSoundTestBase(aTestName), iVolumeRamp(0),
   316 		iDuration(0), iFrequencyTone1(0)
   317 	{
   318 	}
   319 
   320 RA3FDevSoundToneVolumeRampTest* RA3FDevSoundToneVolumeRampTest::NewL(const TDesC& aTestName)
   321 	{
   322 	RA3FDevSoundToneVolumeRampTest * self = new(ELeave)RA3FDevSoundToneVolumeRampTest(aTestName);
   323 	return self;
   324 	}
   325 
   326 void RA3FDevSoundToneVolumeRampTest::DoKickoffTestL()
   327 	{
   328 	if (!GetIntFromConfig(iTestStepName, KVolumeRamp, iVolumeRamp))
   329 		{
   330 		ERR_PRINTF2(KMsgErrorGetParameter, &KVolumeRamp);
   331 		StopTest(KErrNotFound);
   332 		return;
   333 		}
   334 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
   335 			{
   336 			ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
   337 			StopTest(KErrNotFound);
   338 			return;
   339 			}
   340 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
   341 		{
   342 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
   343 		StopTest(KErrNotFound);
   344 		return;
   345 		}
   346 	}
   347 
   348 void RA3FDevSoundToneVolumeRampTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
   349 	{
   350 	switch (iDevSoundState)
   351 		{
   352 		case EStateCreated:
   353 			{
   354 			if (aDevSoundEvent == EEventInitialize)
   355 				{
   356 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneVolumeRampTest"), EFsmIncorrectErrorPassed));
   357 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
   358 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
   359 				if (err != KErrNone)
   360 					{
   361 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
   362 					StopTest(err);
   363 					break;
   364 					}
   365 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
   366 				iDevSoundState = EStateInitializing;
   367 				}
   368 			else
   369 				{
   370 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
   371 				StopTest(aError, EFail);
   372 				}
   373 			break;
   374 			}
   375 		case EStateInitializing:
   376 			{
   377 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
   378 				{
   379 				INFO_PRINTF2(_L("Calling CMMFDevSound::SetVolumeRamp using volume ramp time = %d"), iVolumeRamp);
   380 				iMMFDevSound->SetVolumeRamp(iVolumeRamp);
   381 				iStartTime.HomeTime();
   382 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL %d Hz during %d secs "), iFrequencyTone1, iDuration);
   383 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
   384 				if (err != KErrNone)
   385 					{
   386 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
   387 					StopTest(err);
   388 					break;
   389 					}
   390 				}
   391 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
   392 				{
   393 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
   394 				StopTest(aError);
   395 				}
   396 			else
   397 				{
   398 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
   399 				StopTest(aError, EFail);
   400 				}
   401 			break;
   402 			}
   403 		default:
   404 			{
   405 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
   406 			StopTest(aError, EFail);
   407 			}
   408 		}
   409 	}
   410 
   411 void RA3FDevSoundToneVolumeRampTest::ToneFinished(TInt aError)
   412 	{
   413 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
   414 	if (aError == KErrUnderflow)
   415 		{
   416 		iEndTime.HomeTime();
   417 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
   418 		TInt totalExpectedReproductionTime = iDuration * KMicroSecsInOneSec;
   419 		if(iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
   420 			{
   421 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
   422 			StopTest();
   423 			}
   424 		else
   425 			{
   426 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
   427 			StopTest(KErrNone, EFail);
   428 			}
   429 		}
   430 	else
   431 		{
   432 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
   433 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
   434 		StopTest(aError, EFail);
   435 		}
   436 	}
   437 
   438 /*
   439  *========================================================================================================
   440  * MM-A3F-DEVSOUND-CHRTZ-TONE-0005
   441  */
   442 RA3FDevSoundToneSetToneRepeatsTest::RA3FDevSoundToneSetToneRepeatsTest(const TDesC& aTestName)
   443 	:	RA3FDevSoundTestBase(aTestName),
   444 		iDuration(0),
   445 		iFrequencyTone1(0),
   446 		iRepeatTrailingSilence(0),
   447 		iRepeatCount(0)
   448 	{
   449 	}
   450 
   451 RA3FDevSoundToneSetToneRepeatsTest* RA3FDevSoundToneSetToneRepeatsTest::NewL(const TDesC& aTestName)
   452 	{
   453 	RA3FDevSoundToneSetToneRepeatsTest * self = new(ELeave)RA3FDevSoundToneSetToneRepeatsTest(aTestName);
   454 	return self;
   455 	}
   456 
   457 void RA3FDevSoundToneSetToneRepeatsTest::DoKickoffTestL()
   458 	{
   459 	if (!GetIntFromConfig(iTestStepName, KRepeatCount, iRepeatCount))
   460 		{
   461 		ERR_PRINTF2(KMsgErrorGetParameter, &KRepeatCount);
   462 		StopTest(KErrNotFound);
   463 		return;
   464 		}
   465 	if (!GetIntFromConfig(iTestStepName, KRepeatTrailingSilence, iRepeatTrailingSilence))
   466 		{
   467 		ERR_PRINTF2(KMsgErrorGetParameter, &KRepeatTrailingSilence);
   468 		StopTest(KErrNotFound);
   469 		return;
   470 		}
   471 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
   472 		{
   473 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
   474 		StopTest(KErrNotFound);
   475 		return;
   476 		}
   477 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
   478 		{
   479 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
   480 		StopTest(KErrNotFound);
   481 		return;
   482 		}
   483 	}
   484 
   485 void RA3FDevSoundToneSetToneRepeatsTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
   486 	{
   487 	switch (iDevSoundState)
   488 		{
   489 		case EStateCreated:
   490 			{
   491 			if (aDevSoundEvent == EEventInitialize)
   492 				{
   493 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetToneRepeatsTest"), EFsmIncorrectErrorPassed));
   494 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
   495 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
   496 				if (err != KErrNone)
   497 					{
   498 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
   499 					StopTest(err);
   500 					break;
   501 					}
   502 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
   503 				iDevSoundState = EStateInitializing;
   504 				}
   505 			else
   506 				{
   507 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
   508 				StopTest(aError, EFail);
   509 				}
   510 			break;
   511 			}
   512 		case EStateInitializing:
   513 			{
   514 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
   515 				{
   516 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
   517 				iStartTime.HomeTime();
   518 				INFO_PRINTF3(_L("Calling CMMFDevSound::SetToneRepeats using repeatCount = %d and trailingSilence = %d"), iRepeatCount, iRepeatTrailingSilence);
   519 				iMMFDevSound->SetToneRepeats(iRepeatCount, iRepeatTrailingSilence);
   520 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL %d Hz during %d secs "), iFrequencyTone1, iDuration);
   521 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
   522 				if (err != KErrNone)
   523 					{
   524 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
   525 					StopTest(err);
   526 					break;
   527 					}
   528 				}
   529 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
   530 				{
   531 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
   532 				StopTest(aError);
   533 				}
   534 			else
   535 				{
   536 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
   537 				StopTest(aError, EFail);
   538 				}
   539 			break;
   540 			}
   541 		default:
   542 			{
   543 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
   544 			StopTest(aError, EFail);
   545 			}
   546 		}
   547 	}
   548 
   549 void RA3FDevSoundToneSetToneRepeatsTest::ToneFinished(TInt aError)
   550 	{
   551 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
   552 	if (aError == KErrUnderflow)
   553 		{
   554 		iEndTime.HomeTime();
   555 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
   556 		TInt repeatTrailingSilenceToSecs = iRepeatTrailingSilence/KMicroSecsInOneSec;
   557 		TInt totalExpectedReproductionTime = (iRepeatCount * iDuration + iDuration + (repeatTrailingSilenceToSecs*iRepeatCount))*KMicroSecsInOneSec;
   558 		if(iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
   559 			{
   560 			INFO_PRINTF1(_L("Play tone repeats succeded."));
   561 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
   562 			StopTest();
   563 			}
   564 		else
   565 			{
   566 			ERR_PRINTF1(_L("Play tone repeats did not work as planned."));
   567 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
   568 			StopTest(KErrNone, EFail);
   569 			}
   570 		}
   571 	else
   572 		{
   573 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
   574 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
   575 		StopTest(aError, EFail);
   576 		}
   577 	}
   578 
   579 /*
   580  *========================================================================================================
   581  * MM-A3F-DEVSOUND-CHRTZ-TONE-0006
   582  */
   583 RA3FDevSoundToneSetDTMFLengthsTest::RA3FDevSoundToneSetDTMFLengthsTest(const TDesC& aTestName)
   584 	:	RA3FDevSoundTestBase(aTestName), iToneOnLength(0),
   585 		iToneOffLength(0), iPauseLength(0), iDTMFPauses(0),
   586 		iDTMFTones(0)
   587 	{
   588 	}
   589 
   590 RA3FDevSoundToneSetDTMFLengthsTest* RA3FDevSoundToneSetDTMFLengthsTest::NewL(const TDesC& aTestName)
   591 	{
   592 	RA3FDevSoundToneSetDTMFLengthsTest * self = new(ELeave)RA3FDevSoundToneSetDTMFLengthsTest(aTestName);
   593 	return self;
   594 	}
   595 
   596 void RA3FDevSoundToneSetDTMFLengthsTest::DoKickoffTestL()
   597 	{
   598 	if (!GetIntFromConfig(iTestStepName, KToneOnLength, iToneOnLength))
   599 		{
   600 		ERR_PRINTF2(KMsgErrorGetParameter, &KToneOnLength);
   601 		StopTest(KErrNotFound);
   602 		return;
   603 		}
   604 	if (!GetIntFromConfig(iTestStepName, KToneOffLength, iToneOffLength))
   605 		{
   606 		ERR_PRINTF2(KMsgErrorGetParameter, &KToneOffLength);
   607 		StopTest(KErrNotFound);
   608 		return;
   609 		}
   610 	if (!GetIntFromConfig(iTestStepName, KPauseLength, iPauseLength))
   611 		{
   612 		ERR_PRINTF2(KMsgErrorGetParameter, &KPauseLength);
   613 		StopTest(KErrNotFound);
   614 		return;
   615 		}
   616 	TPtrC DTMF;
   617 	if (!GetStringFromConfig(iTestStepName, KDTMFString, DTMF))
   618 		{
   619 		ERR_PRINTF2(KMsgErrorGetParameter, &KDTMFString);
   620 		StopTest(KErrNotFound);
   621 		return;
   622 		}
   623 	iDTMFString.Copy(DTMF);
   624 	for(TInt i =0 ; i< iDTMFString.Length() ; i++)
   625 		{
   626 		if (iDTMFString[i] == ',')
   627 			{
   628 			iDTMFPauses++;
   629 			}
   630 		else
   631 			{
   632 			iDTMFTones++;
   633 			}
   634 		}
   635 	}
   636 
   637 void RA3FDevSoundToneSetDTMFLengthsTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
   638 	{
   639 	switch (iDevSoundState)
   640 		{
   641 		case EStateCreated:
   642 			{
   643 			if (aDevSoundEvent == EEventInitialize)
   644 				{
   645 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetDTMFLengthsTest"), EFsmIncorrectErrorPassed));
   646 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
   647 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
   648 				if (err != KErrNone)
   649 					{
   650 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
   651 					StopTest(err);
   652 					break;
   653 					}
   654 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
   655 				iDevSoundState = EStateInitializing;
   656 				}
   657 			else
   658 				{
   659 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
   660 				StopTest(aError, EFail);
   661 				}
   662 			break;
   663 			}
   664 		case EStateInitializing:
   665 			{
   666 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
   667 				{
   668 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
   669 				TTimeIntervalMicroSeconds32 ToneOnLength(iToneOnLength);
   670 				TTimeIntervalMicroSeconds32 ToneOffLength(iToneOffLength);
   671 				TTimeIntervalMicroSeconds32 PauseLength(iPauseLength);
   672 				INFO_PRINTF4(_L("Calling CMMFDevSound::SetDTMFLengths. ToneOnLength = %d, ToneOffLength = %d and PauseLength = %d"), ToneOnLength.Int(), ToneOffLength.Int(), PauseLength.Int());
   673 				iMMFDevSound->SetDTMFLengths(ToneOnLength, ToneOffLength, PauseLength);
   674 				iStartTime.HomeTime();
   675 				INFO_PRINTF2(_L("Calling CMMFDevSound::PlayDTMFStringL %S"), &iDTMFString);
   676 				TRAPD(err, iMMFDevSound->PlayDTMFStringL(iDTMFString));
   677 				if (err != KErrNone)
   678 					{
   679 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error : %d!"), err);
   680 					StopTest(err);
   681 					break;
   682 					}
   683 				}
   684 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
   685 				{
   686 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
   687 				StopTest(aError);
   688 				}
   689 			else
   690 				{
   691 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
   692 				StopTest(aError, EFail);
   693 				}
   694 			break;
   695 			}
   696 		default:
   697 			{
   698 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
   699 			StopTest(aError, EFail);
   700 			}
   701 		}
   702 	}
   703 
   704 void RA3FDevSoundToneSetDTMFLengthsTest::ToneFinished(TInt aError)
   705 	{
   706 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
   707 	if (aError == KErrUnderflow)
   708 		{
   709 		iEndTime.HomeTime();
   710 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
   711 		TInt totalExpectedReproductionTime = iToneOnLength*iDTMFTones + iToneOffLength * iDTMFTones + iDTMFPauses * iPauseLength;
   712 		if (iPlayToneTime.Int64() < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime.Int64() > totalExpectedReproductionTime - KPlayVarianceTime)
   713 			{
   714 			INFO_PRINTF1(_L("Calling CMMFDevSound::SetDTMFLengths succeded."));
   715 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
   716 			StopTest();
   717 			}
   718 		else
   719 			{
   720 			ERR_PRINTF2(_L("Calling CMMFDevSound::SetDTMFLengths failed with %Ld"), iPlayToneTime.Int64());
   721 			ERR_PRINTF2(_L("Expected time %d"), totalExpectedReproductionTime);
   722 			StopTest(KErrNone, EFail);
   723 			}
   724 		}
   725 	else
   726 		{
   727 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
   728 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
   729 		StopTest(aError, EFail);
   730 		}
   731 	}
   732 
   733 /*
   734  *========================================================================================================
   735  * MM-A3F-DEVSOUND-CHRTZ-TONE-0007
   736  */
   737 RA3FDevSoundToneSetVolumeWhilePlayingTest::RA3FDevSoundToneSetVolumeWhilePlayingTest(const TDesC& aTestName)
   738 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
   739 		iVolume(0), iFrequencyTone1(0)
   740 	{
   741 	}
   742 
   743 RA3FDevSoundToneSetVolumeWhilePlayingTest* RA3FDevSoundToneSetVolumeWhilePlayingTest::NewL(const TDesC& aTestName)
   744 	{
   745 	RA3FDevSoundToneSetVolumeWhilePlayingTest * self = new(ELeave)RA3FDevSoundToneSetVolumeWhilePlayingTest(aTestName);
   746 	return self;
   747 	}
   748 
   749 void RA3FDevSoundToneSetVolumeWhilePlayingTest::DoKickoffTestL()
   750 	{
   751 	if (!GetIntFromConfig(iTestStepName, KVolume, iVolume))
   752 		{
   753 		ERR_PRINTF2(KMsgErrorGetParameter, &KVolume);
   754 		StopTest(KErrNotFound);
   755 		return;
   756 		}
   757 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
   758 		{
   759 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
   760 		StopTest(KErrNotFound);
   761 		return;
   762 		}
   763 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
   764 		{
   765 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
   766 		StopTest(KErrNotFound);
   767 		return;
   768 		}
   769 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   770 	}
   771 
   772 void RA3FDevSoundToneSetVolumeWhilePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
   773 	{
   774 	switch (iDevSoundState)
   775 		{
   776 		case EStateCreated:
   777 			{
   778 			if (aDevSoundEvent == EEventInitialize)
   779 				{
   780 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetVolumeWhilePlayingTest"), EFsmIncorrectErrorPassed));
   781 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
   782 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
   783 				if (err != KErrNone)
   784 					{
   785 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
   786 					StopTest(err);
   787 					break;
   788 					}
   789 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
   790 				iDevSoundState = EStateInitializing;
   791 				}
   792 			else
   793 				{
   794 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
   795 				StopTest(aError, EFail);
   796 				}
   797 			break;
   798 			}
   799 		case EStateInitializing:
   800 			{
   801 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
   802 				{
   803 				iStartTime.HomeTime();
   804 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using frequency = %d Hz and duration = %d secs "), iFrequencyTone1, iDuration);
   805 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
   806 				if (err != KErrNone)
   807 					{
   808 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
   809 					StopTest(err);
   810 					break;
   811 					}
   812 				StartTimer(KMicroSecsTwoSec);
   813 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
   814 				iDevSoundState = EStatePlaying;
   815 				}
   816 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
   817 				{
   818 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
   819 				StopTest(aError);
   820 				}
   821 			else
   822 				{
   823 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
   824 				StopTest(aError, EFail);
   825 				}
   826 			break;
   827 			}
   828 		default:
   829 			{
   830 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
   831 			StopTest(aError, EFail);
   832 			}
   833 		}
   834 	}
   835 
   836 void RA3FDevSoundToneSetVolumeWhilePlayingTest::DoTimerCallback()
   837 	{
   838 	iTimer->Cancel();
   839 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
   840 	INFO_PRINTF2(_L("Calling CMMFDevSound::SetVolume with volume value = %d"), iVolume);
   841 	iMMFDevSound->SetVolume(iVolume);
   842 	TInt volumeGet;
   843 	volumeGet=iMMFDevSound->Volume();
   844 	if (volumeGet == iVolume)
   845 		{
   846 		INFO_PRINTF2(_L("CMMFDevSound::SetVolume succeeded with value = %d"), volumeGet);
   847 		}
   848 	else
   849 		{
   850 		ERR_PRINTF2(_L("CMMFDevSound::SetVolume failed with value = %d"), volumeGet);
   851 		ERR_PRINTF2(_L("Expected value = %d"), iVolume);
   852 		StopTest(KErrNone, EFail);
   853 		}
   854 	}
   855 
   856 void RA3FDevSoundToneSetVolumeWhilePlayingTest::ToneFinished(TInt aError)
   857 	{
   858 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
   859 	if (aError == KErrUnderflow)
   860 		{
   861 		iEndTime.HomeTime();
   862 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
   863 		TInt totalExpectedReproductionTime = iDuration * KMicroSecsInOneSec;
   864 		if(iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
   865 			{
   866 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
   867 			StopTest();
   868 			}
   869 		else
   870 			{
   871 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
   872 			StopTest(KErrNone, EFail);
   873 			}
   874 		}
   875 	else
   876 		{
   877 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
   878 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
   879 		StopTest(aError, EFail);
   880 		}
   881 	}
   882 
   883 /*
   884  *========================================================================================================
   885  * MM-A3F-DEVSOUND-CHRTZ-TONE-0008
   886  */
   887 RA3FDevSoundToneSetPlayBalanceWhilePlayingTest::RA3FDevSoundToneSetPlayBalanceWhilePlayingTest(const TDesC& aTestName)
   888 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
   889 		iVolume(0), iFrequencyTone1(0), iLSpeakerBalance(0),
   890 		iRSpeakerBalance(0)
   891 
   892 	{
   893 	}
   894 
   895 RA3FDevSoundToneSetPlayBalanceWhilePlayingTest* RA3FDevSoundToneSetPlayBalanceWhilePlayingTest::NewL(const TDesC& aTestName)
   896 	{
   897 	RA3FDevSoundToneSetPlayBalanceWhilePlayingTest * self = new(ELeave)RA3FDevSoundToneSetPlayBalanceWhilePlayingTest(aTestName);
   898 	return self;
   899 	}
   900 
   901 void RA3FDevSoundToneSetPlayBalanceWhilePlayingTest::DoKickoffTestL()
   902 	{
   903 	if (!GetIntFromConfig(iTestStepName, KVolume, iVolume))
   904 		{
   905 		ERR_PRINTF2(KMsgErrorGetParameter, &KVolume);
   906 		StopTest(KErrNotFound);
   907 		return;
   908 		}
   909 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
   910 		{
   911 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
   912 		StopTest(KErrNotFound);
   913 		return;
   914 		}
   915 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
   916 		{
   917 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
   918 		StopTest(KErrNotFound);
   919 		return;
   920 		}
   921 	if (!GetIntFromConfig(iTestStepName, KLSpeakerBalance, iLSpeakerBalance))
   922 		{
   923 		ERR_PRINTF2(KMsgErrorGetParameter, &KLSpeakerBalance);
   924 		StopTest(KErrNotFound);
   925 		return;
   926 		}
   927 	if (!GetIntFromConfig(iTestStepName, KRSpeakerBalance, iRSpeakerBalance))
   928 		{
   929 		ERR_PRINTF2(KMsgErrorGetParameter, &KRSpeakerBalance);
   930 		StopTest(KErrNotFound);
   931 		return;
   932 		}
   933 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
   934 	}
   935 
   936 void RA3FDevSoundToneSetPlayBalanceWhilePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
   937 	{
   938 	switch (iDevSoundState)
   939 		{
   940 		case EStateCreated:
   941 			{
   942 			if (aDevSoundEvent == EEventInitialize)
   943 				{
   944 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetPlayBalanceWhilePlayingTest"), EFsmIncorrectErrorPassed));
   945 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
   946 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
   947 				if (err != KErrNone)
   948 					{
   949 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
   950 					StopTest(err);
   951 					break;
   952 					}
   953 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
   954 				iDevSoundState = EStateInitializing;
   955 				}
   956 			else
   957 				{
   958 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
   959 				StopTest(aError, EFail);
   960 				}
   961 			break;
   962 			}
   963 		case EStateInitializing:
   964 			{
   965 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
   966 				{
   967 				iStartTime.HomeTime();
   968 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using frequency = %d Hz and duration = %d secs "), iFrequencyTone1, iDuration);
   969 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
   970 				if (err != KErrNone)
   971 					{
   972 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
   973 					StopTest(err);
   974 					break;
   975 					}
   976 				StartTimer(KMicroSecsTwoSec);
   977 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
   978 				iDevSoundState = EStatePlaying;
   979 				}
   980 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
   981 				{
   982 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
   983 				StopTest(aError);
   984 				}
   985 			else
   986 				{
   987 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
   988 				StopTest(aError, EFail);
   989 				}
   990 			break;
   991 			}
   992 		default:
   993 			{
   994 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
   995 			StopTest(aError, EFail);
   996 			}
   997 		}
   998 	}
   999 
  1000 void RA3FDevSoundToneSetPlayBalanceWhilePlayingTest::DoTimerCallback()
  1001 	{
  1002 	iTimer->Cancel();
  1003 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  1004 	INFO_PRINTF3(_L("Calling CMMFDevSound::SetPlayBalanceL using left = %d right = %d"), iLSpeakerBalance, iRSpeakerBalance);
  1005 	TRAPD(err, iMMFDevSound->SetPlayBalanceL(iLSpeakerBalance, iRSpeakerBalance));
  1006 	if (err == KErrNone)
  1007 		{
  1008 		TInt getBalanceL, getBalanceR;
  1009 		TRAPD(err, iMMFDevSound->GetPlayBalanceL(getBalanceL, getBalanceR));
  1010 		if (err == KErrNone)
  1011 			{
  1012 			if(iLSpeakerBalance == getBalanceL && iRSpeakerBalance == getBalanceR)
  1013 				{
  1014 				INFO_PRINTF3(_L("Calling CMMFDevSound::SetPlayBalanceL to set balance values succeeded, left = %d right = %d"), getBalanceL, getBalanceR);
  1015 				}
  1016 			else
  1017 				{
  1018 				ERR_PRINTF3(_L("Calling CMMFDevSound::SetPlayBalanceL to set balance values failed, left = %d right = %d"), getBalanceL, getBalanceR);
  1019 				ERR_PRINTF3(_L("Expected balances values for right and left respectively %d, %d"),iLSpeakerBalance, iRSpeakerBalance);
  1020 				StopTest(err,EFail);
  1021 				}
  1022 			}
  1023 		}
  1024 	else
  1025 		{
  1026 		ERR_PRINTF1(_L("Error in setting left and right play balance."));
  1027 		StopTest (err, EFail);
  1028 		}
  1029 	}
  1030 
  1031 void RA3FDevSoundToneSetPlayBalanceWhilePlayingTest::ToneFinished(TInt aError)
  1032 	{
  1033 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  1034 	if (aError == KErrUnderflow)
  1035 		{
  1036 		iEndTime.HomeTime();
  1037 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  1038 		TInt totalExpectedReproductionTime = iDuration * KMicroSecsInOneSec;
  1039 		if(iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
  1040 			{
  1041 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  1042 			StopTest();
  1043 			}
  1044 		else
  1045 			{
  1046 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
  1047 			StopTest(KErrNone, EFail);
  1048 			}
  1049 		}
  1050 	else
  1051 		{
  1052 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  1053 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  1054 		StopTest(aError, EFail);
  1055 		}
  1056 	}
  1057 
  1058 /*
  1059  *  **========================================================================================================
  1060  * MM-A3F-DEVSOUND-CHRTZ-TONE-0009
  1061  */
  1062 RA3FDevSoundToneSetVolumeWhilePausePlayingTest::RA3FDevSoundToneSetVolumeWhilePausePlayingTest(const TDesC& aTestName)
  1063 	:	RA3FDevSoundTestBase(aTestName),
  1064 		iDuration(0), iVolume(0),
  1065 		iFrequencyTone1(0),
  1066 		iTimeToEnterPauseElapsed(EFalse)
  1067 	{
  1068 	}
  1069 
  1070 RA3FDevSoundToneSetVolumeWhilePausePlayingTest* RA3FDevSoundToneSetVolumeWhilePausePlayingTest::NewL(const TDesC& aTestName)
  1071 	{
  1072 	RA3FDevSoundToneSetVolumeWhilePausePlayingTest * self = new(ELeave)RA3FDevSoundToneSetVolumeWhilePausePlayingTest(aTestName);
  1073 	return self;
  1074 	}
  1075 
  1076 void RA3FDevSoundToneSetVolumeWhilePausePlayingTest::DoKickoffTestL()
  1077 	{
  1078 	if (!GetIntFromConfig(iTestStepName, KVolume, iVolume))
  1079 		{
  1080 		ERR_PRINTF2(KMsgErrorGetParameter, &KVolume);
  1081 		StopTest(KErrNotFound);
  1082 		return;
  1083 		}
  1084 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  1085 		{
  1086 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  1087 		StopTest(KErrNotFound);
  1088 		return;
  1089 		}
  1090 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  1091 		{
  1092 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  1093 		StopTest(KErrNotFound);
  1094 		return;
  1095 		}
  1096 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  1097 	}
  1098 
  1099 void RA3FDevSoundToneSetVolumeWhilePausePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent,  TInt aError)
  1100 	{
  1101 	switch (iDevSoundState)
  1102 		{
  1103 		case EStateCreated:
  1104 			{
  1105 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetVolumeWhilePausePlayingTest"), EFsmIncorrectErrorPassed));
  1106 			if (aDevSoundEvent == EEventInitialize)
  1107 				{
  1108 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  1109 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  1110 				if (err != KErrNone)
  1111 					{
  1112 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  1113 					StopTest(err);
  1114 					break;
  1115 					}
  1116 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  1117 				iDevSoundState = EStateInitializing;
  1118 				}
  1119 			else
  1120 				{
  1121 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  1122 				StopTest(aError, EFail);
  1123 				}
  1124 			break;
  1125 			}
  1126 		case EStateInitializing:
  1127 			{
  1128 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  1129 				{
  1130 				INFO_PRINTF3(_L("CMMFDevSound::PlayToneL %d Hz during %d secs "), iFrequencyTone1, iDuration);
  1131 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  1132 				if (err != KErrNone)
  1133 					{
  1134 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  1135 					StopTest(err);
  1136 					break;
  1137 					}
  1138 				StartTimer(KMicroSecsTwoSec);
  1139 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  1140 				iDevSoundState = EStatePlaying;
  1141 				}
  1142 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  1143 				{
  1144 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  1145 				StopTest(aError);
  1146 				}
  1147 			else
  1148 				{
  1149 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"),  aDevSoundEvent);
  1150 				StopTest(aError, EFail);
  1151 				}
  1152 			break;
  1153 			}
  1154 		case EStatePlaying:
  1155 			{
  1156 			if(aDevSoundEvent == EEventTimerComplete)
  1157 				{
  1158 				INFO_PRINTF1(_L("Calling CMMFDevSound::Pause"));
  1159 				iMMFDevSound->Pause();
  1160 				INFO_PRINTF1(_L("DevSound State: EStatePause"));
  1161 				iDevSoundState = EStatePause;
  1162 				}
  1163 			else
  1164 				{
  1165 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  1166 				StopTest(aError, EFail);
  1167 				}
  1168 			break;
  1169 			}
  1170 		case EStatePause:
  1171 			{
  1172 			if(aDevSoundEvent == EEventTimerComplete)
  1173 				{
  1174 				INFO_PRINTF2(_L("Calling CMMFDevSound::SetVolume with volume value = %d"), iVolume);
  1175 				iMMFDevSound->SetVolume(iVolume);
  1176 				TInt volumeGet;
  1177 				volumeGet=iMMFDevSound->Volume();
  1178 				if (volumeGet == iVolume)
  1179 					{
  1180 					INFO_PRINTF2(_L("CMMFDevSound::SetVolume succeeded with value = %d"), volumeGet);
  1181 					StopTest();
  1182 					}
  1183 				else
  1184 					{
  1185 					ERR_PRINTF2(_L("CMMFDevSound::SetVolume failed with value = %d"), volumeGet);
  1186 					ERR_PRINTF2(_L("Expected value = %d"), iVolume);
  1187 					StopTest(aError, EFail);
  1188 					}
  1189 				}
  1190 			else
  1191 				{
  1192 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  1193 				StopTest(aError, EFail);
  1194 				}
  1195 			break;
  1196 			}
  1197 		default:
  1198 			{
  1199 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  1200 			StopTest(aError, EFail);
  1201 			}
  1202 		}
  1203 	}
  1204 
  1205 void RA3FDevSoundToneSetVolumeWhilePausePlayingTest::DoTimerCallback()
  1206 	{
  1207 	INFO_PRINTF1(_L("TimerEvent called"));
  1208 	if(!iTimeToEnterPauseElapsed)
  1209 		{
  1210 		iTimeToEnterPauseElapsed = ETrue;
  1211 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  1212 		Fsm(EEventTimerComplete, KErrNone);
  1213 		iTimeToEnterPauseElapsed = ETrue;
  1214 		}
  1215 	else
  1216 		{
  1217 		iTimer->Cancel();
  1218 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  1219 		Fsm(EEventTimerComplete, KErrNone);
  1220 		}
  1221 	}
  1222 
  1223 void RA3FDevSoundToneSetVolumeWhilePausePlayingTest::ToneFinished(TInt aError)
  1224 	{
  1225 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  1226 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to be paused"));
  1227 	StopTest(aError, EFail);
  1228 	}
  1229 /*
  1230  *========================================================================================================
  1231  * MM-A3F-DEVSOUND-CHRTZ-TONE-0010
  1232  */
  1233 RA3FDevSoundToneSetVolumeThenInitializeToPlayAudioTest::RA3FDevSoundToneSetVolumeThenInitializeToPlayAudioTest(const TDesC& aTestName)
  1234 	:	RA3FDevSoundTestBase(aTestName), iVolume(0),
  1235 		iReinitialized(EFalse)
  1236 	{
  1237 	}
  1238 
  1239 RA3FDevSoundToneSetVolumeThenInitializeToPlayAudioTest* RA3FDevSoundToneSetVolumeThenInitializeToPlayAudioTest::NewL(const TDesC& aTestName)
  1240 	{
  1241 	RA3FDevSoundToneSetVolumeThenInitializeToPlayAudioTest * self = new(ELeave)RA3FDevSoundToneSetVolumeThenInitializeToPlayAudioTest(aTestName);
  1242 	return self;
  1243 	}
  1244 
  1245 void RA3FDevSoundToneSetVolumeThenInitializeToPlayAudioTest::DoKickoffTestL()
  1246 	{
  1247 	if (!GetIntFromConfig(iTestStepName, KVolume, iVolume))
  1248 		{
  1249 		ERR_PRINTF2(KMsgErrorGetParameter, &KVolume);
  1250 		StopTest(KErrNotFound);
  1251 		return;
  1252 		}
  1253 	}
  1254 
  1255 void RA3FDevSoundToneSetVolumeThenInitializeToPlayAudioTest::Fsm(TMmfDevSoundEvent aDevSoundEvent,  TInt aError)
  1256 	{
  1257 	switch (iDevSoundState)
  1258 		{
  1259 		case EStateCreated:
  1260 			{
  1261 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetVolumeThenInitializeToPlayAudioTest"), EFsmIncorrectErrorPassed));
  1262 			if (aDevSoundEvent == EEventInitialize)
  1263 				{
  1264 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  1265 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  1266 				if (err != KErrNone)
  1267 					{
  1268 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  1269 					StopTest(err);
  1270 					break;
  1271 					}
  1272 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  1273 				iDevSoundState = EStateInitializing;
  1274 				}
  1275 			else
  1276 				{
  1277 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  1278 				StopTest(aError, EFail);
  1279 				}
  1280 			break;
  1281 			}
  1282 		case EStateInitializing:
  1283 			{
  1284 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  1285 				{
  1286 				if(!iReinitialized)
  1287 					{
  1288 					INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  1289 					TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  1290 					if (err != KErrNone)
  1291 						{
  1292 						ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  1293 						StopTest(err);
  1294 						break;
  1295 						}
  1296 					INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  1297 					iDevSoundState = EStateInitializing;
  1298 					iReinitialized = ETrue;
  1299 					INFO_PRINTF2(_L("Calling CMMFDevSound::SetVolume with volume value = %d"), iVolume);
  1300 					iMMFDevSound->SetVolume(iVolume);
  1301 					INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  1302 					iDevSoundState = EStateInitializing;
  1303 					}
  1304 				else
  1305 					{
  1306 					TInt volumeGet;
  1307 					volumeGet=iMMFDevSound->Volume();
  1308 					if (volumeGet == iVolume)
  1309 						{
  1310 						INFO_PRINTF1(_L("After calling CMMFDevSound::InitializeL for playing audio, "));
  1311 						INFO_PRINTF2(_L("the volume which was set when calling CMMFDevSound::InitializeL for playing tones is kept. Volume = %d"), volumeGet);
  1312 						StopTest();
  1313 						}
  1314 					else
  1315 						{
  1316 						INFO_PRINTF1(_L("After calling CMMFDevSound::InitializeL for playing audio, "));
  1317 						INFO_PRINTF2(_L("the volume which was set when calling CMMFDevSound::InitializeL for playing tones is  NOT kept. Volume = %d"), volumeGet);
  1318 						ERR_PRINTF2(_L("Expected value = %d"), iVolume);
  1319 						StopTest(aError, EFail);
  1320 						}
  1321 					}
  1322 				}
  1323 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  1324 				{
  1325 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  1326 				StopTest(aError);
  1327 				}
  1328 			else
  1329 				{
  1330 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"),  aDevSoundEvent);
  1331 				StopTest(aError, EFail);
  1332 				}
  1333 			break;
  1334 			}
  1335 		default:
  1336 			{
  1337 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  1338 			StopTest(aError, EFail);
  1339 			}
  1340 		}
  1341 	}
  1342 
  1343 /*
  1344  *========================================================================================================
  1345  * MM-A3F-DEVSOUND-CHRTZ-TONE-0011
  1346  */
  1347 RA3FDevSoundToneSetVolumeRampWhilePlayingTest::RA3FDevSoundToneSetVolumeRampWhilePlayingTest(const TDesC& aTestName)
  1348 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  1349 		iVolume(0), iFrequencyTone1(0),iTonePlayedTwice(EFalse),
  1350 		iTimesToneFinishedCalled(0)
  1351 	{
  1352 	}
  1353 
  1354 RA3FDevSoundToneSetVolumeRampWhilePlayingTest* RA3FDevSoundToneSetVolumeRampWhilePlayingTest::NewL(const TDesC& aTestName)
  1355 	{
  1356 	RA3FDevSoundToneSetVolumeRampWhilePlayingTest * self = new(ELeave)RA3FDevSoundToneSetVolumeRampWhilePlayingTest(aTestName);
  1357 	return self;
  1358 	}
  1359 
  1360 void RA3FDevSoundToneSetVolumeRampWhilePlayingTest::DoKickoffTestL()
  1361 	{
  1362 	if (!GetIntFromConfig(iTestStepName, KVolume, iVolume))
  1363 		{
  1364 		ERR_PRINTF2(KMsgErrorGetParameter, &KVolume);
  1365 		StopTest(KErrNotFound);
  1366 		return;
  1367 		}
  1368 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  1369 		{
  1370 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  1371 		StopTest(KErrNotFound);
  1372 		return;
  1373 		}
  1374 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  1375 		{
  1376 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  1377 		StopTest(KErrNotFound);
  1378 		return;
  1379 		}
  1380 	if (!GetIntFromConfig(iTestStepName, KVolumeRamp, iVolumeRamp))
  1381 			{
  1382 			ERR_PRINTF2(KMsgErrorGetParameter, &KVolumeRamp);
  1383 			StopTest(KErrNotFound);
  1384 			return;
  1385 			}
  1386 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  1387 	}
  1388 
  1389 void RA3FDevSoundToneSetVolumeRampWhilePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent,  TInt aError)
  1390 	{
  1391 	switch (iDevSoundState)
  1392 		{
  1393 		case EStateCreated:
  1394 			{
  1395 			if (aDevSoundEvent == EEventInitialize)
  1396 				{
  1397 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetVolumeRampWhilePlayingTest"), EFsmIncorrectErrorPassed));
  1398 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  1399 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  1400 				if (err != KErrNone)
  1401 					{
  1402 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"),  err);
  1403 					StopTest(err);
  1404 					break;
  1405 					}
  1406 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  1407 				iDevSoundState = EStateInitializing;
  1408 				}
  1409 			else
  1410 				{
  1411 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  1412 				StopTest(aError, EFail);
  1413 				}
  1414 			break;
  1415 			}
  1416 		case EStateInitializing:
  1417 			{
  1418 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  1419 				{
  1420 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  1421 				iStartTime.HomeTime();
  1422 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using frequency = %d Hz and duration = %d secs "), iFrequencyTone1, iDuration);
  1423 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  1424 				if (err != KErrNone)
  1425 					{
  1426 					ERR_PRINTF2(_L("Play tone left with error : %d!"), err);
  1427 					StopTest(err);
  1428 					break;
  1429 					}
  1430 				StartTimer(KMicroSecsTwoSec);
  1431 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  1432 				iDevSoundState = EStatePlaying;
  1433 				}
  1434 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  1435 				{
  1436 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  1437 				StopTest(aError);
  1438 				}
  1439 			else
  1440 				{
  1441 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  1442 				StopTest(aError, EFail);
  1443 				}
  1444 			break;
  1445 			}
  1446 		default:
  1447 			{
  1448 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  1449 			StopTest(aError, EFail);
  1450 			}
  1451 		}
  1452 	}
  1453 
  1454 void RA3FDevSoundToneSetVolumeRampWhilePlayingTest::DoTimerCallback()
  1455 	{
  1456 	iTimer->Cancel();
  1457 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  1458 	INFO_PRINTF2(_L("Calling CMMFDevSound::SetVolumeRamp using volume ramp time = %d"), iVolumeRamp);
  1459 	iMMFDevSound->SetVolumeRamp(iVolumeRamp);
  1460 	}
  1461 
  1462 void RA3FDevSoundToneSetVolumeRampWhilePlayingTest::ToneFinished(TInt aError)
  1463 	{
  1464 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  1465 	if (aError == KErrUnderflow)
  1466 		{
  1467 		TInt totalExpectedReproductionTime;
  1468 		iTimesToneFinishedCalled++;
  1469 		totalExpectedReproductionTime = iDuration * iTimesToneFinishedCalled * KMicroSecsInOneSec;
  1470 		iEndTime.HomeTime();
  1471 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  1472 		if(!iTonePlayedTwice)
  1473 			{
  1474 			INFO_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  1475 			INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using frequency = %d Hz and duration = %d secs "), iFrequencyTone1, iDuration);
  1476 			TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  1477 			if (err != KErrNone)
  1478 				{
  1479 				ERR_PRINTF2(_L("CMMFDevSound::PlayToneL with error : %d!"), err);
  1480 				StopTest(err);
  1481 				}
  1482 			iTonePlayedTwice = ETrue;
  1483 			}
  1484 		else if (iPlayToneTime < totalExpectedReproductionTime + (2*KPlayVarianceTime) && iPlayToneTime > totalExpectedReproductionTime - (2*KPlayVarianceTime))
  1485 			{
  1486 			INFO_PRINTF2(_L("DevSound called ToneFinished twice with error = %d"), aError);
  1487 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  1488 			StopTest();
  1489 			}
  1490 		else
  1491 			{
  1492 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
  1493 			StopTest(KErrNone, EFail);
  1494 			}
  1495 		}
  1496 	else
  1497 		{
  1498 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  1499 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  1500 		StopTest(aError, EFail);
  1501 		}
  1502 	}
  1503 
  1504 /*
  1505  *========================================================================================================
  1506  * MM-A3F-DEVSOUND-CHRTZ-TONE-0012
  1507  */
  1508 RA3FDevSoundToneSetToneRepetitionsWhilePlayingTest::RA3FDevSoundToneSetToneRepetitionsWhilePlayingTest(const TDesC& aTestName)
  1509 	:	RA3FDevSoundTestBase(aTestName),
  1510 		iDuration(0),
  1511 		iFrequencyTone1(0),
  1512 		iRepeatTrailingSilence(0),
  1513 		iRepeatCount(0)
  1514 	{
  1515 	}
  1516 
  1517 RA3FDevSoundToneSetToneRepetitionsWhilePlayingTest* RA3FDevSoundToneSetToneRepetitionsWhilePlayingTest::NewL(const TDesC& aTestName)
  1518 	{
  1519 	RA3FDevSoundToneSetToneRepetitionsWhilePlayingTest * self = new(ELeave)RA3FDevSoundToneSetToneRepetitionsWhilePlayingTest(aTestName);
  1520 	return self;
  1521 	}
  1522 
  1523 void RA3FDevSoundToneSetToneRepetitionsWhilePlayingTest::DoKickoffTestL()
  1524 	{
  1525 	if (!GetIntFromConfig(iTestStepName, KRepeatCount, iRepeatCount))
  1526 		{
  1527 		ERR_PRINTF2(KMsgErrorGetParameter, &KRepeatCount);
  1528 		StopTest(KErrNotFound);
  1529 		return;
  1530 		}
  1531 	if (!GetIntFromConfig(iTestStepName, KRepeatTrailingSilence, iRepeatTrailingSilence))
  1532 		{
  1533 		ERR_PRINTF2(KMsgErrorGetParameter, &KRepeatTrailingSilence);
  1534 		StopTest(KErrNotFound);
  1535 		return;
  1536 		}
  1537 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  1538 		{
  1539 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  1540 		StopTest(KErrNotFound);
  1541 		return;
  1542 		}
  1543 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  1544 		{
  1545 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  1546 		StopTest(KErrNotFound);
  1547 		return;
  1548 		}
  1549 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  1550 	}
  1551 
  1552 void RA3FDevSoundToneSetToneRepetitionsWhilePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  1553 	{
  1554 	switch (iDevSoundState)
  1555 		{
  1556 		case EStateCreated:
  1557 			{
  1558 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetToneRepetitionsWhilePlayingConfigurationTest"), EFsmIncorrectErrorPassed));
  1559 			if(aDevSoundEvent == EEventInitialize)
  1560 				{
  1561 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  1562 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  1563 				if (err != KErrNone)
  1564 					{
  1565 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  1566 					StopTest(err);
  1567 					break;
  1568 					}
  1569 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  1570 				iDevSoundState = EStateInitializing;
  1571 				}
  1572 			else
  1573 				{
  1574 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  1575 				StopTest(aError, EFail);
  1576 				}
  1577 			break;
  1578 			}
  1579 		case EStateInitializing:
  1580 			{
  1581 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  1582 				{
  1583 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  1584 				iStartTime.HomeTime();
  1585 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL %d Hz during %d secs "), iFrequencyTone1, iDuration);
  1586 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  1587 				if (err != KErrNone)
  1588 					{
  1589 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  1590 					StopTest(err);
  1591 					break;
  1592 					}
  1593 				StartTimer(KMicroSecsTwoSec);
  1594 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  1595 				iDevSoundState = EStatePlaying;
  1596 				}
  1597 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  1598 				{
  1599 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  1600 				StopTest(aError);
  1601 				}
  1602 			else
  1603 				{
  1604 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  1605 				StopTest(aError, EFail);
  1606 				}
  1607 			break;
  1608 			}
  1609 		default:
  1610 			{
  1611 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  1612 			StopTest(aError, EFail);
  1613 			}
  1614 		}
  1615 	}
  1616 
  1617 void RA3FDevSoundToneSetToneRepetitionsWhilePlayingTest::DoTimerCallback()
  1618 	{
  1619 	iTimer->Cancel();
  1620 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  1621 	INFO_PRINTF3(_L("Calling CMMFDevSound::SetToneRepeats using RepeatCount = %d and RepeatTrailingSilence = %d microsecs"), iRepeatCount, iRepeatTrailingSilence);
  1622 	iMMFDevSound->SetToneRepeats(iRepeatCount, iRepeatTrailingSilence);
  1623 	}
  1624 
  1625 void RA3FDevSoundToneSetToneRepetitionsWhilePlayingTest::ToneFinished(TInt aError)
  1626 	{
  1627 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  1628 	const TInt KtimesPlayToneIsCalled = 2;
  1629 	if (aError == KErrUnderflow)
  1630 		{
  1631 		iEndTime.HomeTime();
  1632 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  1633 		TInt repeatTrailingSilenceToSecs = iRepeatTrailingSilence/KMicroSecsInOneSec;
  1634 		TInt totalExpectedReproductionTime = (KtimesPlayToneIsCalled*iDuration+iRepeatCount*iDuration + (repeatTrailingSilenceToSecs*iRepeatCount))*KMicroSecsInOneSec;
  1635 		if(iPlayToneTime < ((iDuration*KMicroSecsInOneSec) + KPlayVarianceTime)&& iPlayToneTime > (iDuration*KMicroSecsInOneSec) - KPlayVarianceTime)
  1636 			{
  1637 			INFO_PRINTF1(_L("First play tone succeded."));
  1638 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  1639 			TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  1640 			if (err != KErrNone)
  1641 				{
  1642 				ERR_PRINTF2(_L("CMMFDevSound::PlayToneL failed with error : %d!"), err);
  1643 				StopTest(err);
  1644 				}
  1645 			}
  1646 		else if(iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
  1647 			{
  1648 			INFO_PRINTF1(_L("Play tone repeats succeded."));
  1649 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  1650 			StopTest();
  1651 			}
  1652 		else
  1653 			{
  1654 			ERR_PRINTF1(_L("Play tone repeats did not work as planned."));
  1655 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
  1656 			StopTest(KErrNone, EFail);
  1657 			}
  1658 		}
  1659 	else
  1660 		{
  1661 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  1662 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  1663 		StopTest(aError, EFail);
  1664 		}
  1665 	}
  1666 
  1667 /*
  1668  *========================================================================================================
  1669  * MM-A3F-DEVSOUND-CHRTZ-TONE-0013
  1670  */
  1671 RA3FDevSoundToneSetDTMFLengthsWhilePlayingTest::RA3FDevSoundToneSetDTMFLengthsWhilePlayingTest(const TDesC& aTestName)
  1672 	:	RA3FDevSoundTestBase(aTestName),
  1673 		iFirstToneFinishedCall(EFalse),
  1674 		iToneOnLength(0), iToneOffLength(0),
  1675 		iPauseLength(0), iDTMFString(KNullDesC),
  1676 		iDTMFPauses(0), iDTMFTones(0),
  1677 		iTotalExpectedPlayToneTime(0)
  1678 	{
  1679 	}
  1680 RA3FDevSoundToneSetDTMFLengthsWhilePlayingTest* RA3FDevSoundToneSetDTMFLengthsWhilePlayingTest::NewL(const TDesC& aTestName)
  1681 	{
  1682 	RA3FDevSoundToneSetDTMFLengthsWhilePlayingTest * self = new(ELeave)RA3FDevSoundToneSetDTMFLengthsWhilePlayingTest(aTestName);
  1683 	return self;
  1684 	}
  1685 
  1686 void RA3FDevSoundToneSetDTMFLengthsWhilePlayingTest::DoKickoffTestL()
  1687 	{
  1688 	if (!GetIntFromConfig(iTestStepName, KToneOnLength, iToneOnLength))
  1689 		{
  1690 		ERR_PRINTF2(KMsgErrorGetParameter, &KToneOnLength);
  1691 		StopTest(KErrNotFound);
  1692 		return;
  1693 		}
  1694 	if (!GetIntFromConfig(iTestStepName, KToneOffLength, iToneOffLength))
  1695 		{
  1696 		ERR_PRINTF2(KMsgErrorGetParameter, &KToneOffLength);
  1697 		StopTest(KErrNotFound);
  1698 		return;
  1699 		}
  1700 	if (!GetIntFromConfig(iTestStepName, KPauseLength, iPauseLength))
  1701 		{
  1702 		ERR_PRINTF2(KMsgErrorGetParameter, &KPauseLength);
  1703 		StopTest(KErrNotFound);
  1704 		return;
  1705 		}
  1706 	TPtrC DTMF;
  1707 	if (!GetStringFromConfig(iTestStepName, KDTMFString, DTMF))
  1708 		{
  1709 		ERR_PRINTF2(KMsgErrorGetParameter, &KDTMFString);
  1710 		StopTest(KErrNotFound);
  1711 		return;
  1712 		}
  1713 	iDTMFString.Copy(DTMF);
  1714 	for(TInt i =0 ; i< iDTMFString.Length() ; i++)
  1715 		{
  1716 		if (iDTMFString[i] == ',')
  1717 			{
  1718 			iDTMFPauses++;
  1719 			}
  1720 		else
  1721 			{
  1722 			iDTMFTones++;
  1723 			}
  1724 		}
  1725 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  1726 	}
  1727 
  1728 void RA3FDevSoundToneSetDTMFLengthsWhilePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  1729 	{
  1730 	switch (iDevSoundState)
  1731 		{
  1732 		case EStateCreated:
  1733 			{
  1734 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetDTMFToneRepetitionsWhilePlayingConfigurationTest"), EFsmIncorrectErrorPassed));
  1735 			if(aDevSoundEvent == EEventInitialize)
  1736 				{
  1737 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  1738 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  1739 				if (err != KErrNone)
  1740 					{
  1741 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  1742 					StopTest(err);
  1743 					break;
  1744 					}
  1745 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  1746 				iDevSoundState = EStateInitializing;
  1747 				}
  1748 			else
  1749 				{
  1750 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  1751 				StopTest(aError, EFail);
  1752 				}
  1753 			break;
  1754 			}
  1755 		case EStateInitializing:
  1756 			{
  1757 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  1758 				{
  1759 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  1760 				iStartTime.HomeTime();
  1761 				INFO_PRINTF2(_L("Calling CMMFDevSound::L %S"), &iDTMFString);
  1762 				TRAPD(err, iMMFDevSound->PlayDTMFStringL(iDTMFString));
  1763 				if (err != KErrNone)
  1764 					{
  1765 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error : %d!"), err);
  1766 					StopTest(err);
  1767 					break;
  1768 					}
  1769 				StartTimer(KMicroSecsTwoSec);
  1770 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  1771 				iDevSoundState=EStatePlaying;
  1772 				}
  1773 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  1774 				{
  1775 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  1776 				StopTest(aError);
  1777 				}
  1778 			else
  1779 				{
  1780 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  1781 				StopTest(aError, EFail);
  1782 				}
  1783 			break;
  1784 			}
  1785 		default:
  1786 			{
  1787 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  1788 			StopTest(aError, EFail);
  1789 			}
  1790 		}
  1791 	}
  1792 
  1793 void RA3FDevSoundToneSetDTMFLengthsWhilePlayingTest::DoTimerCallback()
  1794 	{
  1795 	iTimer->Cancel();
  1796 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  1797 	TTimeIntervalMicroSeconds32 ToneOnLength(iToneOnLength);
  1798 	TTimeIntervalMicroSeconds32 ToneOffLength(iToneOffLength);
  1799 	TTimeIntervalMicroSeconds32 PauseLength(iPauseLength);
  1800 	INFO_PRINTF4(_L("Calling CMMFDevSound::SetDTMFLengths. ToneOnLength = %d, ToneOffLength = %d and PauseLength = %d"), ToneOnLength.Int(), ToneOffLength.Int(), PauseLength.Int());
  1801 	iMMFDevSound->SetDTMFLengths(ToneOnLength, ToneOffLength, PauseLength);
  1802 	}
  1803 
  1804 void RA3FDevSoundToneSetDTMFLengthsWhilePlayingTest::ToneFinished(TInt aError)
  1805 	{
  1806 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  1807 	if (aError == KErrUnderflow)
  1808 		{
  1809 		iEndTime.HomeTime();
  1810 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  1811 		if (!iFirstToneFinishedCall)
  1812 			{
  1813 			INFO_PRINTF1(_L("First play tone succeded"));
  1814 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  1815 			iFirstToneFinishedCall = ETrue;
  1816 			INFO_PRINTF2(_L("Calling CMMFDevSound::PlayDTMFStringL %S"), &iDTMFString);
  1817 			TRAPD(err, iMMFDevSound->PlayDTMFStringL(iDTMFString));
  1818 			if (err != KErrNone)
  1819 				{
  1820 				ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error = %d"), err);
  1821 				StopTest(err);
  1822 				}
  1823 			iTotalExpectedPlayToneTime = iToneOnLength*iDTMFTones + iToneOffLength * iDTMFTones + iDTMFPauses * iPauseLength + iPlayToneTime.Int64();
  1824 			return;
  1825 			}
  1826 		if (iPlayToneTime.Int64() < iTotalExpectedPlayToneTime + KPlayVarianceTime && iPlayToneTime.Int64() > iTotalExpectedPlayToneTime - KPlayVarianceTime)
  1827 			{
  1828 			INFO_PRINTF1(_L("Calling CMMFDevSound::SetDTMFLengths succeded."));
  1829 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  1830 			StopTest();
  1831 			}
  1832 		else
  1833 			{
  1834 			ERR_PRINTF2(_L("Calling CMMFDevSound::SetDTMFLengths failed with %Ld"), iPlayToneTime.Int64());
  1835 			ERR_PRINTF2(_L("Expected time %d"), iTotalExpectedPlayToneTime);
  1836 			StopTest(KErrNone, EFail);
  1837 			}
  1838 		}
  1839 	else
  1840 		{
  1841 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  1842 		ERR_PRINTF2(_L("Expected error = %Ld"), KErrUnderflow);
  1843 		StopTest(aError, EFail);
  1844 		}
  1845 	}
  1846 
  1847 /*
  1848  *========================================================================================================
  1849  * MM-A3F-DEVSOUND-CHRTZ-TONE-0014
  1850  */
  1851 RA3FDevSoundToneSetToneRepetitionsNotPlayingTonesModeTest::RA3FDevSoundToneSetToneRepetitionsNotPlayingTonesModeTest(const TDesC& aTestName)
  1852 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  1853 		iFrequencyTone1(0),
  1854 		iRepeatTrailingSilence(0), iRepeatCount(0),
  1855 		iInitializedToPlayTones(EFalse)
  1856 	{
  1857 	}
  1858 
  1859 RA3FDevSoundToneSetToneRepetitionsNotPlayingTonesModeTest* RA3FDevSoundToneSetToneRepetitionsNotPlayingTonesModeTest::NewL(const TDesC& aTestName)
  1860 	{
  1861 	RA3FDevSoundToneSetToneRepetitionsNotPlayingTonesModeTest * self = new(ELeave)RA3FDevSoundToneSetToneRepetitionsNotPlayingTonesModeTest(aTestName);
  1862 	return self;
  1863 	}
  1864 
  1865 void RA3FDevSoundToneSetToneRepetitionsNotPlayingTonesModeTest::DoKickoffTestL()
  1866 	{
  1867 	if (!GetIntFromConfig(iTestStepName, KRepeatCount, iRepeatCount))
  1868 		{
  1869 		ERR_PRINTF2(KMsgErrorGetParameter, &KRepeatCount);
  1870 		StopTest(KErrNotFound);
  1871 		return;
  1872 		}
  1873 	if (!GetIntFromConfig(iTestStepName, KRepeatTrailingSilence, iRepeatTrailingSilence))
  1874 		{
  1875 		ERR_PRINTF2(KMsgErrorGetParameter, &KRepeatTrailingSilence);
  1876 		StopTest(KErrNotFound);
  1877 		return;
  1878 		}
  1879 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  1880 		{
  1881 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  1882 		StopTest(KErrNotFound);
  1883 		return;
  1884 		}
  1885 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  1886 		{
  1887 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  1888 		StopTest(KErrNotFound);
  1889 		return;
  1890 		}
  1891 	}
  1892 
  1893 void RA3FDevSoundToneSetToneRepetitionsNotPlayingTonesModeTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  1894 	{
  1895 	switch (iDevSoundState)
  1896 		{
  1897 		case EStateCreated:
  1898 			{
  1899 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetToneRepetitionsNotPlayingTonesModeConfigurationTest"), EFsmIncorrectErrorPassed));
  1900 			if(aDevSoundEvent == EEventInitialize)
  1901 				{
  1902 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  1903 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
  1904 				if (err != KErrNone)
  1905 					{
  1906 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  1907 					StopTest(err);
  1908 					break;
  1909 					}
  1910 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  1911 				iDevSoundState = EStateInitializing;
  1912 				}
  1913 			else
  1914 				{
  1915 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  1916 				StopTest(aError, EFail);
  1917 				}
  1918 			break;
  1919 			}
  1920 		case EStateInitializing:
  1921 			{
  1922 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  1923 				{
  1924 				if(!iInitializedToPlayTones)
  1925 					{
  1926 					INFO_PRINTF3(_L("Calling CMMFDevSound::SetToneRepeats using RepeatCount = %d and RepeatTrailingSilence = %d microsecs"), iRepeatCount, iRepeatTrailingSilence);
  1927 					iMMFDevSound->SetToneRepeats(iRepeatCount, iRepeatTrailingSilence);
  1928 					INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL for playing tones"));
  1929 					TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  1930 					if (err != KErrNone)
  1931 						{
  1932 						ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  1933 						StopTest(err);
  1934 						break;
  1935 						}
  1936 					iInitializedToPlayTones = ETrue;
  1937 					}
  1938 				else
  1939 					{
  1940 					iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  1941 					iStartTime.HomeTime();
  1942 					INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL %d Hz during %d secs "), iFrequencyTone1, iDuration);
  1943 					TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  1944 					if (err != KErrNone)
  1945 						{
  1946 						ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  1947 						StopTest(err);
  1948 						break;
  1949 						}
  1950 					INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  1951 					iDevSoundState = EStatePlaying;
  1952 					}
  1953 				}
  1954 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  1955 				{
  1956 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  1957 				StopTest(aError);
  1958 				}
  1959 			else
  1960 				{
  1961 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  1962 				StopTest(aError, EFail);
  1963 				}
  1964 			break;
  1965 			}
  1966 		default:
  1967 			{
  1968 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  1969 			StopTest(aError, EFail);
  1970 			}
  1971 		}
  1972 	}
  1973 
  1974 
  1975 void RA3FDevSoundToneSetToneRepetitionsNotPlayingTonesModeTest::ToneFinished(TInt aError)
  1976 	{
  1977 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  1978 	if (aError == KErrUnderflow)
  1979 		{
  1980 		iEndTime.HomeTime();
  1981 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  1982 		TInt repeatTrailingSilenceToSecs = iRepeatTrailingSilence/KMicroSecsInOneSec;
  1983 		TInt totalExpectedReproductionTime = (iDuration + iRepeatCount * iDuration+ (repeatTrailingSilenceToSecs*iRepeatCount)) * KMicroSecsInOneSec;
  1984 		if(iPlayToneTime < (totalExpectedReproductionTime + KPlayVarianceTime) && iPlayToneTime > (totalExpectedReproductionTime - KPlayVarianceTime))
  1985 			{
  1986 			INFO_PRINTF1(_L("Play tone repeats succeded."));
  1987 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  1988 			StopTest();
  1989 			}
  1990 		else
  1991 			{
  1992 			ERR_PRINTF1(_L("Play tone repeats did not work as planned."));
  1993 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
  1994 			StopTest(KErrNone, EFail);
  1995 			}
  1996 		}
  1997 	else
  1998 		{
  1999 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  2000 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  2001 		StopTest(aError, EFail);
  2002 		}
  2003 	}
  2004 
  2005 /*
  2006  *========================================================================================================
  2007  * MM-A3F-DEVSOUND-CHRTZ-TONE-0015
  2008  */
  2009 RA3FDevSoundToneSetDTMFLengthsNotPlayingTonesModeTest::RA3FDevSoundToneSetDTMFLengthsNotPlayingTonesModeTest(const TDesC& aTestName)
  2010 	:	RA3FDevSoundTestBase(aTestName), iInitializedToPlayTones(EFalse),
  2011 		iDTMFString(KNullDesC), iToneOnLength(0),
  2012 		iToneOffLength(0), iPauseLength(0),
  2013 		iDTMFPauses(0), iDTMFTones(0)
  2014 
  2015 	{
  2016 	}
  2017 
  2018 RA3FDevSoundToneSetDTMFLengthsNotPlayingTonesModeTest* RA3FDevSoundToneSetDTMFLengthsNotPlayingTonesModeTest::NewL(const TDesC& aTestName)
  2019 	{
  2020 	RA3FDevSoundToneSetDTMFLengthsNotPlayingTonesModeTest * self = new(ELeave)RA3FDevSoundToneSetDTMFLengthsNotPlayingTonesModeTest(aTestName);
  2021 	return self;
  2022 	}
  2023 
  2024 void RA3FDevSoundToneSetDTMFLengthsNotPlayingTonesModeTest::DoKickoffTestL()
  2025 	{
  2026 	if (!GetIntFromConfig(iTestStepName, KToneOnLength, iToneOnLength))
  2027 		{
  2028 		ERR_PRINTF2(KMsgErrorGetParameter, &KToneOnLength);
  2029 		StopTest(KErrNotFound);
  2030 		return;
  2031 		}
  2032 	if (!GetIntFromConfig(iTestStepName, KToneOffLength, iToneOffLength))
  2033 		{
  2034 		ERR_PRINTF2(KMsgErrorGetParameter, &KToneOffLength);
  2035 		StopTest(KErrNotFound);
  2036 		return;
  2037 		}
  2038 	if (!GetIntFromConfig(iTestStepName, KPauseLength, iPauseLength))
  2039 		{
  2040 		ERR_PRINTF2(KMsgErrorGetParameter, &KPauseLength);
  2041 		StopTest(KErrNotFound);
  2042 		return;
  2043 		}
  2044 	TPtrC DTMF;
  2045 	if (!GetStringFromConfig(iTestStepName, KDTMFString, DTMF))
  2046 		{
  2047 		ERR_PRINTF2(KMsgErrorGetParameter, &KDTMFString);
  2048 		StopTest(KErrNotFound);
  2049 		return;
  2050 		}
  2051 	iDTMFString.Copy(DTMF);
  2052 	for(TInt i =0 ; i< iDTMFString.Length() ; i++)
  2053 		{
  2054 		if (iDTMFString[i] == ',')
  2055 			{
  2056 			iDTMFPauses++;
  2057 			}
  2058 		else
  2059 			{
  2060 			iDTMFTones++;
  2061 			}
  2062 		}
  2063 	}
  2064 
  2065 void RA3FDevSoundToneSetDTMFLengthsNotPlayingTonesModeTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  2066 	{
  2067 	switch (iDevSoundState)
  2068 		{
  2069 		case EStateCreated:
  2070 			{
  2071 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetDTMFLengthsNotPlayingTonesModeConfigurationTest"), EFsmIncorrectErrorPassed));
  2072 			if(aDevSoundEvent == EEventInitialize)
  2073 				{
  2074 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  2075 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateRecording));
  2076 				if (err != KErrNone)
  2077 					{
  2078 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  2079 					StopTest(err);
  2080 					break;
  2081 					}
  2082 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  2083 				iDevSoundState = EStateInitializing;
  2084 				}
  2085 			else
  2086 				{
  2087 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"),  aDevSoundEvent);
  2088 				StopTest(aError, EFail);
  2089 				}
  2090 			break;
  2091 			}
  2092 		case EStateInitializing:
  2093 			{
  2094 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  2095 				{
  2096 				if(!iInitializedToPlayTones)
  2097 					{
  2098 					TTimeIntervalMicroSeconds32 ToneOnLength(iToneOnLength);
  2099 					TTimeIntervalMicroSeconds32 ToneOffLength(iToneOffLength);
  2100 					TTimeIntervalMicroSeconds32 PauseLength(iPauseLength);
  2101 					INFO_PRINTF4(_L("Calling CMMFDevSound::SetDTMFLengths. ToneOnLength = %d, ToneOffLength = %d and PauseLength = %d"), ToneOnLength.Int(), ToneOffLength.Int(), PauseLength.Int());
  2102 					iMMFDevSound->SetDTMFLengths(ToneOnLength, ToneOffLength, PauseLength);
  2103 					INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  2104 					TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  2105 					if (err != KErrNone)
  2106 						{
  2107 						ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  2108 						StopTest(err);
  2109 						break;
  2110 						}
  2111 					iInitializedToPlayTones = ETrue;
  2112 					}
  2113 				else
  2114 					{
  2115 					iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  2116 					iStartTime.HomeTime();
  2117 					INFO_PRINTF2(_L("Calling CMMFDevSound::PlayDTMFStringL %S"), &iDTMFString);
  2118 					TRAPD(err, iMMFDevSound->PlayDTMFStringL(iDTMFString));
  2119 					if (err != KErrNone)
  2120 						{
  2121 						ERR_PRINTF2(_L("Play DTMF string failed with error : %d!"), err);
  2122 						StopTest(err);
  2123 						break;
  2124 						}
  2125 					INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  2126 					iDevSoundState = EStatePlaying;
  2127 					}
  2128 				}
  2129 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  2130 				{
  2131 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  2132 				StopTest(aError);
  2133 				}
  2134 			else
  2135 				{
  2136 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  2137 				StopTest(aError, EFail);
  2138 				}
  2139 			break;
  2140 			}
  2141 		default:
  2142 			{
  2143 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  2144 			StopTest(aError, EFail);
  2145 			}
  2146 		}
  2147 	}
  2148 
  2149 void RA3FDevSoundToneSetDTMFLengthsNotPlayingTonesModeTest::ToneFinished(TInt aError)
  2150 	{
  2151 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  2152 	if (aError == KErrUnderflow)
  2153 		{
  2154 		iEndTime.HomeTime();
  2155 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  2156 		TInt totalExpectedReproductionTime = iToneOnLength*iDTMFTones + iToneOffLength * iDTMFTones + iDTMFPauses * iPauseLength;
  2157 		if (iPlayToneTime.Int64() < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime.Int64() > totalExpectedReproductionTime - KPlayVarianceTime)
  2158 			{
  2159 			INFO_PRINTF1(_L("CMMFDevSound::SetDTMFLengths settings were remembered after re-initialization."));
  2160 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  2161 			StopTest();
  2162 			}
  2163 		else
  2164 			{
  2165 			ERR_PRINTF1(_L("CMMFDevSound::SetDTMFLengths settings were not remembered after re-initialization."));
  2166 			ERR_PRINTF2(_L("Expected time %d"), totalExpectedReproductionTime);
  2167 			StopTest(KErrNone, EFail);
  2168 			}
  2169 		}
  2170 	else
  2171 		{
  2172 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  2173 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  2174 		StopTest(aError, EFail);
  2175 		}
  2176 	}
  2177 
  2178 /*
  2179  *========================================================================================================
  2180  * MM-A3F-DEVSOUND-CHRTZ-TONE-0016
  2181  */
  2182 RA3FDevSoundToneSetConfigWhilePlayingTest::RA3FDevSoundToneSetConfigWhilePlayingTest(const TDesC& aTestName)
  2183 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  2184 		iVolume(0), iFrequencyTone1(0),
  2185 		iSampleRate(0), iChannels(0)
  2186 	{
  2187 	}
  2188 
  2189 RA3FDevSoundToneSetConfigWhilePlayingTest* RA3FDevSoundToneSetConfigWhilePlayingTest::NewL(const TDesC& aTestName)
  2190 	{
  2191 	RA3FDevSoundToneSetConfigWhilePlayingTest * self = new(ELeave)RA3FDevSoundToneSetConfigWhilePlayingTest(aTestName);
  2192 	return self;
  2193 	}
  2194 
  2195 void RA3FDevSoundToneSetConfigWhilePlayingTest::DoKickoffTestL()
  2196 	{
  2197 	if (!GetIntFromConfig(iTestStepName, KSampleRate, iSampleRate))
  2198 		{
  2199 		ERR_PRINTF2(KMsgErrorGetParameter, &KSampleRate);
  2200 		StopTest(KErrNotFound);
  2201 		return;
  2202 		}
  2203 	if (!GetIntFromConfig(iTestStepName, KChannel, iChannels))
  2204 		{
  2205 		ERR_PRINTF2(KMsgErrorGetParameter, &KChannel);
  2206 		StopTest(KErrNotFound);
  2207 		return;
  2208 		}
  2209 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  2210 		{
  2211 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  2212 		StopTest(KErrNotFound);
  2213 		return;
  2214 		}
  2215 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  2216 		{
  2217 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  2218 		StopTest(KErrNotFound);
  2219 		return;
  2220 		}
  2221 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  2222 	}
  2223 
  2224 void RA3FDevSoundToneSetConfigWhilePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent,  TInt aError)
  2225 	{
  2226 	switch (iDevSoundState)
  2227 		{
  2228 		case EStateCreated:
  2229 			{
  2230 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetConfigWhilePlayingTest"), EFsmIncorrectErrorPassed));
  2231 			if (aDevSoundEvent == EEventInitialize)
  2232 				{
  2233 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  2234 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  2235 				if (err != KErrNone)
  2236 					{
  2237 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  2238 					StopTest(err);
  2239 					break;
  2240 					}
  2241 				StartTimer(KMicroSecsTwoSec);
  2242 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  2243 				iDevSoundState = EStateInitializing;
  2244 				}
  2245 			else
  2246 				{
  2247 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  2248 				StopTest(aError, EFail);
  2249 				}
  2250 			break;
  2251 			}
  2252 		case EStateInitializing:
  2253 			{
  2254 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  2255 				{
  2256 				INFO_PRINTF1(_L("CMMFDevSound::PlayToneL"));
  2257 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1,  iDuration*KMicroSecsInOneSec));
  2258 				if (err != KErrNone)
  2259 					{
  2260 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d"), err);
  2261 					StopTest(err);
  2262 					break;
  2263 					}
  2264 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  2265 				iDevSoundState = EStatePlaying;
  2266 				}
  2267 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  2268 				{
  2269 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  2270 				StopTest(aError);
  2271 				}
  2272 			else
  2273 				{
  2274 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  2275 				StopTest(aError, EFail);
  2276 				}
  2277 			break;
  2278 			}
  2279 		default:
  2280 			{
  2281 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  2282 			StopTest(aError, EFail);
  2283 			}
  2284 		}
  2285 	}
  2286 
  2287 void RA3FDevSoundToneSetConfigWhilePlayingTest::DoTimerCallback()
  2288 	{
  2289 	iTimer->Cancel();
  2290 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  2291 	TMMFCapabilities capabilitiesSet;
  2292 	TBuf<KMaxSampleRateStringLength> stringSampleRateSet;
  2293 	TBuf<KMaxChannelsStringLength> stringChannelsSet;
  2294 	TMMFSampleRate eSampleRate;
  2295 	SampleRateFromTIntToTMMFSampleRate (iSampleRate, eSampleRate);
  2296 	capabilitiesSet.iRate = eSampleRate;
  2297 	capabilitiesSet.iChannels = iChannels;
  2298 	SampleRateFromTUintToString (capabilitiesSet.iRate,	stringSampleRateSet);
  2299 	ChannelsFromTUintToString (capabilitiesSet.iChannels, stringChannelsSet);
  2300 	INFO_PRINTF3(_L("Calling CMMFDevSound::SetConfigL using sample rate = %S and channel mode = %S"), &stringSampleRateSet, &stringChannelsSet);
  2301 	TRAPD(err, iMMFDevSound->SetConfigL(capabilitiesSet));
  2302 	if (err == KErrNotReady)
  2303 		{
  2304 		INFO_PRINTF2(_L("CMMFDevSound::SetConfigL succeeded with error = %d"), err);
  2305 		StopTest(err, EPass);
  2306 		}
  2307 	else
  2308 		{
  2309 		ERR_PRINTF2(_L("CMMFDevSound::SetConfigL failed with error = %d"), err);
  2310 		ERR_PRINTF2(_L("Expected  error = %d"), KErrNotReady);
  2311 		StopTest(err, EFail);
  2312 		}
  2313 	}
  2314 
  2315 /*
  2316  *========================================================================================================
  2317  * MM-A3F-DEVSOUND-CHRTZ-TONE-0017
  2318  */
  2319 RA3FDevSoundToneSetPriorityWhilePlayingTest::RA3FDevSoundToneSetPriorityWhilePlayingTest(const TDesC& aTestName)
  2320 	:	RA3FDevSoundTestBase(aTestName),
  2321 		iDuration(0), iFrequencyTone1(0)
  2322 	{
  2323 	}
  2324 
  2325 RA3FDevSoundToneSetPriorityWhilePlayingTest* RA3FDevSoundToneSetPriorityWhilePlayingTest::NewL(const TDesC& aTestName)
  2326 	{
  2327 	RA3FDevSoundToneSetPriorityWhilePlayingTest * self = new(ELeave)RA3FDevSoundToneSetPriorityWhilePlayingTest(aTestName);
  2328 	return self;
  2329 	}
  2330 
  2331 void RA3FDevSoundToneSetPriorityWhilePlayingTest::DoKickoffTestL()
  2332 	{
  2333 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  2334 		{
  2335 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  2336 		StopTest(KErrNotFound);
  2337 		return;
  2338 		}
  2339 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  2340 		{
  2341 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  2342 		StopTest(KErrNotFound);
  2343 		return;
  2344 		}
  2345 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  2346 	iDevsoundToneClient = CA3FDevSoundToneClient::NewL(*this);
  2347 	}
  2348 
  2349 void RA3FDevSoundToneSetPriorityWhilePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  2350 	{
  2351 	switch(iDevSoundState)
  2352 		{
  2353 		case EStateCreated:
  2354 			{
  2355 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetPriorityWhilePlayingConfigurationTest"), EFsmIncorrectErrorPassed));
  2356 			if(aDevSoundEvent == EEventInitialize)
  2357 				{
  2358 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  2359 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  2360 				if (err != KErrNone)
  2361 					{
  2362 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  2363 					StopTest(err);
  2364 					break;
  2365 					}
  2366 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  2367 				iDevSoundState = EStateInitializing;
  2368 				}
  2369 			else
  2370 				{
  2371 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  2372 				StopTest(aError, EFail);
  2373 				}
  2374 			break;
  2375 			}
  2376 		case EStateInitializing:
  2377 			{
  2378 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  2379 				{
  2380 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume ());
  2381 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneL"));
  2382 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  2383 				if (err != KErrNone)
  2384 					{
  2385 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  2386 					StopTest(err);
  2387 					break;
  2388 					}
  2389 				StartTimer(KMicroSecsTwoSec);
  2390 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  2391 				iDevSoundState = EStatePlaying;
  2392 				INFO_PRINTF2(_L("Calling CMMFDevSound::SetPrioritySettings using a priority(highest) value = %d"), KMaximumPriority);
  2393 				TMMFPrioritySettings priority;
  2394 				priority.iPriority = KMaximumPriority;
  2395 				iMMFDevSound->SetPrioritySettings(priority);
  2396 				}
  2397 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  2398 				{
  2399 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  2400 				StopTest(aError);
  2401 				}
  2402 			else
  2403 				{
  2404 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  2405 				StopTest(aError,  EFail);
  2406 				}
  2407 			break;
  2408 			}
  2409 		default:
  2410 			{
  2411 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  2412 			StopTest(aError, EFail);
  2413 			}
  2414 		}
  2415 	}
  2416 
  2417 void RA3FDevSoundToneSetPriorityWhilePlayingTest::ClientInitializeCompleteCallback(TInt aError)
  2418 	{
  2419 	INFO_PRINTF1(_L("==========Second DevSound client called InitializeComplete()=========="));
  2420 	if (aError == KErrNone)
  2421 		{
  2422 		TInt err = iDevsoundToneClient->PlayTone ();
  2423 		if (err != KErrNone)
  2424 			{
  2425 			ERR_PRINTF2(_L("Second Devsound client called PlayTone and failed with error = %d"), err);
  2426 			StopTest(err);
  2427 			}
  2428 		}
  2429 	else
  2430 		{
  2431 		ERR_PRINTF2(_L("Second Devsound InitializeComplete received an error = %d"), aError);
  2432 		StopTest(aError);
  2433 		}
  2434 	}
  2435 
  2436 void RA3FDevSoundToneSetPriorityWhilePlayingTest::ClientToneFinishedCallback(TInt aError)
  2437 	{
  2438 	INFO_PRINTF1(_L("========== Second  DevSound client called ToneFinished()=========="));
  2439 	if (aError == KErrUnderflow)
  2440 		{
  2441 		INFO_PRINTF2(_L("Second DevSound client called ToneFinished and succeeded with error = %d"), aError);
  2442 		StopTest(aError, EPass);
  2443 		}
  2444 	else
  2445 		{
  2446 		ERR_PRINTF2(_L("Second DevSound client called ToneFinished and failed with error = %d"), aError);
  2447 		StopTest(aError, EFail);
  2448 		}
  2449 	}
  2450 
  2451 void RA3FDevSoundToneSetPriorityWhilePlayingTest::DoTimerCallback()
  2452 	{
  2453 	INFO_PRINTF1(_L("TimerEvent called"));
  2454 	iTimer->Cancel();
  2455 	INFO_PRINTF1(_L("Starting another devsound client using the highest priority"));
  2456 	iDevsoundToneClient->SetPriority(KMaximumPriority);
  2457 	TInt err = iDevsoundToneClient->InitTonePlay(iFrequencyTone1, iDuration*KMicroSecsInOneSec);
  2458 	if(err != KErrNone)
  2459 		{
  2460 		ERR_PRINTF1(_L("Initialization to play tone thru second devsound client failed"));
  2461 		StopTest(err);
  2462 		}
  2463 	}
  2464 
  2465 void RA3FDevSoundToneSetPriorityWhilePlayingTest::ToneFinished(TInt aError)
  2466 	{
  2467 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  2468 	if (aError == KErrInUse || aError == KErrDied || aError == KErrAccessDenied)
  2469 		{
  2470 		INFO_PRINTF1(_L("========== Preempting 1st DevSound Instance=========="));
  2471 		}
  2472 	else
  2473 		{
  2474 		ERR_PRINTF2(_L("DevSound called ToneFinished and failed with error = %d"), aError);
  2475 		ERR_PRINTF4(_L("Expected errors posibilities %d %d %d"), KErrInUse, KErrDied, KErrAccessDenied);
  2476 		StopTest(aError, EFail);
  2477 		}
  2478 	}
  2479 
  2480 /*
  2481  *========================================================================================================
  2482  * MM-A3F-DEVSOUND-CHRTZ-TONE-0018
  2483  */
  2484 RA3FDevSoundToneSetConfigTestToInvalidSampleRateValue::RA3FDevSoundToneSetConfigTestToInvalidSampleRateValue(const TDesC& aTestName)
  2485 	:	RA3FDevSoundTestBase(aTestName), iSampleRate(0),
  2486 		iChannels(0)
  2487 	{
  2488 	}
  2489 
  2490 RA3FDevSoundToneSetConfigTestToInvalidSampleRateValue* RA3FDevSoundToneSetConfigTestToInvalidSampleRateValue::NewL(const TDesC& aTestName)
  2491 	{
  2492 	RA3FDevSoundToneSetConfigTestToInvalidSampleRateValue * self = new(ELeave)RA3FDevSoundToneSetConfigTestToInvalidSampleRateValue(aTestName);
  2493 	return self;
  2494 	}
  2495 
  2496 void RA3FDevSoundToneSetConfigTestToInvalidSampleRateValue::DoKickoffTestL()
  2497 	{
  2498 	if (!GetIntFromConfig(iTestStepName, KSampleRate, iSampleRate))
  2499 		{
  2500 		ERR_PRINTF2(KMsgErrorGetParameter, &KSampleRate);
  2501 		StopTest(KErrNotFound);
  2502 		return;
  2503 		}
  2504 	if (!GetIntFromConfig(iTestStepName, KChannel, iChannels))
  2505 		{
  2506 		ERR_PRINTF2(KMsgErrorGetParameter, &KChannel);
  2507 		StopTest(KErrNotFound);
  2508 		return;
  2509 		}
  2510 	}
  2511 
  2512 void RA3FDevSoundToneSetConfigTestToInvalidSampleRateValue::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  2513 	{
  2514 #ifdef MM_TB101_L
  2515 		//Reason: Check remains since this is a valid test case, but we need to know why we are not testing invalid rates.
  2516 		INFO_PRINTF1(_L("MM_TB101_L defined: All sample rates are valid for MM_TB101_L (HW), therefore no invalid rates can be tested."));
  2517 		StopTest(KErrNotSupported, EPass);
  2518 #else
  2519 	switch(iDevSoundState)
  2520 		{
  2521 		case EStateCreated:
  2522 			{
  2523 			if(aDevSoundEvent == EEventInitialize)
  2524 				{
  2525 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetConfigTestToInvalidSampleRateValue"), EFsmIncorrectErrorPassed));
  2526 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  2527 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  2528 				if (err != KErrNone)
  2529 					{
  2530 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  2531 					StopTest(err);
  2532 					break;
  2533 					}
  2534 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  2535 				iDevSoundState = EStateInitializing;
  2536 				}
  2537 			else
  2538 				{
  2539 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  2540 				StopTest(aError, EFail);
  2541 				}
  2542 			break;
  2543 			}
  2544 		case EStateInitializing:
  2545 			{
  2546 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  2547 				{
  2548 				TMMFCapabilities capabilitiesSet;
  2549 				TBuf<KMaxSampleRateStringLength> stringSampleRateSet;
  2550 				TBuf<KMaxChannelsStringLength> stringChannelsSet;
  2551 				TMMFSampleRate eSampleRate;
  2552 				SampleRateFromTIntToTMMFSampleRate (iSampleRate, eSampleRate);
  2553 				capabilitiesSet.iRate = eSampleRate;
  2554 				capabilitiesSet.iChannels = iChannels;
  2555 				SampleRateFromTUintToString (capabilitiesSet.iRate,	stringSampleRateSet);
  2556 				ChannelsFromTUintToString (capabilitiesSet.iChannels, stringChannelsSet);
  2557 				INFO_PRINTF3(_L("Calling CMMFDevSound::SetConfigL using an invalid sample rate = %S and channel mode = %S"), &stringSampleRateSet, &stringChannelsSet);
  2558 				TRAPD(err, iMMFDevSound->SetConfigL(capabilitiesSet));
  2559 				if (err == KErrNotSupported || err == KErrArgument)
  2560 					{
  2561 					INFO_PRINTF2(_L("CMMFDevSound::SetConfigL succeeded with error = %d"), err);
  2562 					StopTest(err, EPass);
  2563 					}
  2564 				else
  2565 					{
  2566 					ERR_PRINTF2(_L("CMMFDevSound::SetConfigL failed with error = %d"), err);
  2567 					ERR_PRINTF3(_L("Expected  error posibilities %d %d"), KErrArgument, KErrNotSupported);
  2568 					StopTest(err, EFail);
  2569 					}
  2570 				}
  2571 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  2572 				{
  2573 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  2574 				StopTest(aError);
  2575 				}
  2576 			else
  2577 				{
  2578 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  2579 				StopTest(aError, EFail);
  2580 				}
  2581 			break;
  2582 			}
  2583 		default:
  2584 			{
  2585 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  2586 			StopTest(aError, EFail);
  2587 			}
  2588 		}
  2589 #endif// MM_TB101_L
  2590 	}
  2591 
  2592 /*
  2593  *========================================================================================================
  2594  * MM-A3F-DEVSOUND-CHRTZ-TONE-0019
  2595  */
  2596 RA3FDevSoundToneSetConfigTestToInvalidChannelValueTest::RA3FDevSoundToneSetConfigTestToInvalidChannelValueTest(const TDesC& aTestName)
  2597 	:	RA3FDevSoundTestBase(aTestName), iSampleRate(0),
  2598 		iChannels(0)
  2599 	{
  2600 	}
  2601 
  2602 RA3FDevSoundToneSetConfigTestToInvalidChannelValueTest* RA3FDevSoundToneSetConfigTestToInvalidChannelValueTest::NewL(const TDesC& aTestName)
  2603 	{
  2604 	RA3FDevSoundToneSetConfigTestToInvalidChannelValueTest * self = new(ELeave)RA3FDevSoundToneSetConfigTestToInvalidChannelValueTest(aTestName);
  2605 	return self;
  2606 	}
  2607 
  2608 void RA3FDevSoundToneSetConfigTestToInvalidChannelValueTest::DoKickoffTestL()
  2609 	{
  2610 	if (!GetIntFromConfig(iTestStepName, KSampleRate, iSampleRate))
  2611 		{
  2612 		ERR_PRINTF2(KMsgErrorGetParameter, &KSampleRate);
  2613 		StopTest(KErrNotFound);
  2614 		return;
  2615 		}
  2616 	if (!GetIntFromConfig(iTestStepName, KChannel, iChannels))
  2617 		{
  2618 		ERR_PRINTF2(KMsgErrorGetParameter, &KChannel);
  2619 		StopTest(KErrNotFound);
  2620 		return;
  2621 		}
  2622 	}
  2623 
  2624 void RA3FDevSoundToneSetConfigTestToInvalidChannelValueTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  2625 	{
  2626 	switch(iDevSoundState)
  2627 		{
  2628 		case EStateCreated:
  2629 			{
  2630 			if(aDevSoundEvent == EEventInitialize)
  2631 				{
  2632 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetConfigTestToInvalidChannelValueTest"), EFsmIncorrectErrorPassed));
  2633 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  2634 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  2635 				if (err != KErrNone)
  2636 					{
  2637 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  2638 					StopTest(err);
  2639 					break;
  2640 					}
  2641 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  2642 				iDevSoundState = EStateInitializing;
  2643 				}
  2644 			else
  2645 				{
  2646 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  2647 				StopTest(aError, EFail);
  2648 				}
  2649 			break;
  2650 			}
  2651 		case EStateInitializing:
  2652 			{
  2653 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  2654 				{
  2655 				TMMFCapabilities capabilitiesSet;
  2656 				TBuf<KMaxSampleRateStringLength> stringSampleRateSet;
  2657 				TBuf<KMaxChannelsStringLength> stringChannelsSet;
  2658 				TMMFSampleRate eSampleRate;
  2659 				SampleRateFromTIntToTMMFSampleRate (iSampleRate, eSampleRate);
  2660 				capabilitiesSet.iRate = eSampleRate;
  2661 				capabilitiesSet.iChannels = iChannels;
  2662 				SampleRateFromTUintToString (capabilitiesSet.iRate,	stringSampleRateSet);
  2663 				INFO_PRINTF3(_L("Calling CMMFDevSound::SetConfigL using a sample rate = %S and an invalid channel mode = %d"), &stringSampleRateSet, iChannels);
  2664 				TRAPD(err, iMMFDevSound->SetConfigL(capabilitiesSet));
  2665 				if (err == KErrNotSupported || err == KErrArgument)
  2666 					{
  2667 					INFO_PRINTF2(_L("CMMFDevSound::SetConfigL succeeded with error = %d"), err);
  2668 					StopTest(err, EPass);
  2669 					}
  2670 				else
  2671 					{
  2672 					ERR_PRINTF2(_L("CMMFDevSound::SetConfigL failed with error = %d"), err);
  2673 					ERR_PRINTF3(_L("Expected  error posibilities %d %d"), KErrArgument, KErrNotSupported);
  2674 					StopTest(err, EFail);
  2675 					}
  2676 				}
  2677 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  2678 				{
  2679 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  2680 				StopTest(aError);
  2681 				}
  2682 			else
  2683 				{
  2684 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  2685 				StopTest(aError, EFail);
  2686 				}
  2687 			break;
  2688 			}
  2689 		default:
  2690 			{
  2691 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  2692 			StopTest(aError, EFail);
  2693 			}
  2694 		}
  2695 	}
  2696 
  2697 /*
  2698  *========================================================================================================
  2699  * MM-A3F-DEVSOUND-CHRTZ-TONE-0020
  2700  */
  2701 RA3FDevSoundToneSetDTMFLengthsToNegativeTest::RA3FDevSoundToneSetDTMFLengthsToNegativeTest(const TDesC& aTestName)
  2702 	:	RA3FDevSoundTestBase(aTestName), iToneOnLength(0),
  2703 		iToneOffLength(0), iPauseLength(0),
  2704 		iDTMFString(KNullDesC)
  2705 	{
  2706 	}
  2707 
  2708 RA3FDevSoundToneSetDTMFLengthsToNegativeTest* RA3FDevSoundToneSetDTMFLengthsToNegativeTest::NewL(const TDesC& aTestName)
  2709 	{
  2710 	RA3FDevSoundToneSetDTMFLengthsToNegativeTest * self = new(ELeave)RA3FDevSoundToneSetDTMFLengthsToNegativeTest(aTestName);
  2711 	return self;
  2712 	}
  2713 
  2714 void RA3FDevSoundToneSetDTMFLengthsToNegativeTest::DoKickoffTestL()
  2715 	{
  2716 	if ( !GetIntFromConfig(iTestStepName, KToneOnLength, iToneOnLength) )
  2717 		{
  2718 		ERR_PRINTF2(KMsgErrorGetParameter, &KToneOnLength);
  2719 		StopTest(KErrNotFound);
  2720 		return;
  2721 		}
  2722 	if ( !GetIntFromConfig(iTestStepName, KToneOffLength, iToneOffLength) )
  2723 		{
  2724 		ERR_PRINTF2(KMsgErrorGetParameter, &KToneOffLength);
  2725 		StopTest(KErrNotFound);
  2726 		return;
  2727 		}
  2728 	if ( !GetIntFromConfig(iTestStepName, KPauseLength, iPauseLength) )
  2729 		{
  2730 		ERR_PRINTF2(KMsgErrorGetParameter, &KPauseLength);
  2731 		StopTest(KErrNotFound);
  2732 		return;
  2733 		}
  2734 	TPtrC DTMF;
  2735 	if ( !GetStringFromConfig(iTestStepName,  KDTMFString,  DTMF) )
  2736 		{
  2737 		ERR_PRINTF2(KMsgErrorGetParameter, &KDTMFString);
  2738 		StopTest(KErrNotFound);
  2739 		return;
  2740 		}
  2741 	iDTMFString.Copy(DTMF);
  2742 	}
  2743 
  2744 void RA3FDevSoundToneSetDTMFLengthsToNegativeTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  2745 	{
  2746 	switch (iDevSoundState)
  2747 		{
  2748 		case EStateCreated:
  2749 			{
  2750 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetDTMFLengthsToNegativeConfigurationTest"), EFsmIncorrectErrorPassed));
  2751 			if (aDevSoundEvent == EEventInitialize)
  2752 				{
  2753 				INFO_PRINTF1(_L("Calling iMMFDevSound::InitializeL"));
  2754 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  2755 				if (err != KErrNone)
  2756 					{
  2757 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  2758 					StopTest(err);
  2759 					break;
  2760 					}
  2761 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  2762 				iDevSoundState = EStateInitializing;
  2763 				}
  2764 			else
  2765 				{
  2766 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  2767 				StopTest(aError, EFail);
  2768 				}
  2769 			break;
  2770 			}
  2771 		case EStateInitializing:
  2772 			{
  2773 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  2774 				{
  2775 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  2776 				TTimeIntervalMicroSeconds32 ToneOnLength(iToneOnLength);
  2777 				TTimeIntervalMicroSeconds32 ToneOffLength(iToneOffLength);
  2778 				TTimeIntervalMicroSeconds32 PauseLength(iPauseLength);
  2779 				INFO_PRINTF4(_L("Setting DTMF tone to negative lengths. ToneOnLength %d, ToneOffLength %d and PauseLength %d"), iToneOnLength, iToneOffLength, iPauseLength);
  2780 				iMMFDevSound->SetDTMFLengths(ToneOnLength, ToneOffLength, PauseLength);
  2781 				iStartTime.HomeTime();
  2782 				INFO_PRINTF2(_L("Calling CMMFDevSound::PlayDTMFStringL %S"), &iDTMFString);
  2783 				TRAPD(err, iMMFDevSound->PlayDTMFStringL(iDTMFString));
  2784 				if (err != KErrNone)
  2785 					{
  2786 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error : %d!"),  err);
  2787 					StopTest(err);
  2788 					break;
  2789 					}
  2790 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  2791 				iDevSoundState = EStatePlaying;
  2792 				}
  2793 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  2794 				{
  2795 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  2796 				StopTest(aError);
  2797 				}
  2798 			else
  2799 				{
  2800 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  2801 				StopTest(aError, EFail);
  2802 				}
  2803 			break;
  2804 			}
  2805 		default:
  2806 			{
  2807 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  2808 			StopTest(aError, EFail);
  2809 			}
  2810 		}
  2811 	}
  2812 
  2813 void RA3FDevSoundToneSetDTMFLengthsToNegativeTest::ToneFinished(TInt aError)
  2814 	{
  2815 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  2816 	INFO_PRINTF3(KMsgErrorDevSoundCallback, &KToneFinishedText, aError);
  2817 
  2818 	if (aError == KErrUnderflow)
  2819 		{
  2820 		iEndTime.HomeTime();
  2821 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  2822 		if(iPlayToneTime <= KPlayVarianceTime)
  2823 			{
  2824 			INFO_PRINTF2(_L("Setting DTMF tone lengths to negative gives a reproduction time of %Ld microseconds which is the expected result"), iPlayToneTime.Int64());
  2825 			StopTest(aError, EPass);
  2826 			}
  2827 		}
  2828 	else
  2829 		{
  2830 		INFO_PRINTF2(_L("DevSound called ToneFinished with error = %d that was NOT expected"), aError);
  2831 		StopTest(aError, EFail);
  2832 		}
  2833 	}
  2834 
  2835 /*
  2836  *========================================================================================================
  2837  * MM-A3F-DEVSOUND-CHRTZ-TONE-0021
  2838  */
  2839 RA3FDevSoundToneSetDTMFToneOnLengthToMinusOneTest::RA3FDevSoundToneSetDTMFToneOnLengthToMinusOneTest(const TDesC& aTestName)
  2840 	:	RA3FDevSoundTestBase(aTestName),
  2841 		iFirstToneFinishedCall(EFalse),
  2842 		iToneOnLength(0), iToneOffLength(0),
  2843 		iPauseLength(0), iDTMFString(KNullDesC)
  2844 	{
  2845 	}
  2846 RA3FDevSoundToneSetDTMFToneOnLengthToMinusOneTest* RA3FDevSoundToneSetDTMFToneOnLengthToMinusOneTest::NewL(const TDesC& aTestName)
  2847 	{
  2848 	RA3FDevSoundToneSetDTMFToneOnLengthToMinusOneTest * self = new(ELeave)RA3FDevSoundToneSetDTMFToneOnLengthToMinusOneTest(aTestName);
  2849 	return self;
  2850 	}
  2851 
  2852 void RA3FDevSoundToneSetDTMFToneOnLengthToMinusOneTest::DoKickoffTestL()
  2853 	{
  2854 	if (!GetIntFromConfig(iTestStepName, KToneOnLength, iToneOnLength))
  2855 		{
  2856 		ERR_PRINTF2(KMsgErrorGetParameter, &KToneOnLength);
  2857 		StopTest(KErrNotFound);
  2858 		return;
  2859 		}
  2860 	if (!GetIntFromConfig(iTestStepName, KToneOffLength, iToneOffLength))
  2861 		{
  2862 		ERR_PRINTF2(KMsgErrorGetParameter, &KToneOffLength);
  2863 		StopTest(KErrNotFound);
  2864 		return;
  2865 		}
  2866 	if (!GetIntFromConfig(iTestStepName, KPauseLength, iPauseLength))
  2867 		{
  2868 		ERR_PRINTF2(KMsgErrorGetParameter, &KPauseLength);
  2869 		StopTest(KErrNotFound);
  2870 		return;
  2871 		}
  2872 	TPtrC DTMF;
  2873 	if (!GetStringFromConfig(iTestStepName, KDTMFString, DTMF))
  2874 		{
  2875 		ERR_PRINTF2(KMsgErrorGetParameter, &KDTMFString);
  2876 		StopTest(KErrNotFound);
  2877 		return;
  2878 		}
  2879 	iDTMFString.Copy(DTMF);
  2880 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  2881 	}
  2882 
  2883 void RA3FDevSoundToneSetDTMFToneOnLengthToMinusOneTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  2884 	{
  2885 	switch (iDevSoundState)
  2886 		{
  2887 		case EStateCreated:
  2888 			{
  2889 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetDTMFToneOnLengthToMinusOneTest"), EFsmIncorrectErrorPassed));
  2890 			if(aDevSoundEvent == EEventInitialize)
  2891 				{
  2892 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  2893 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  2894 				if (err != KErrNone)
  2895 					{
  2896 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  2897 					StopTest(err);
  2898 					break;
  2899 					}
  2900 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  2901 				iDevSoundState = EStateInitializing;
  2902 				}
  2903 			else
  2904 				{
  2905 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  2906 				StopTest(aError, EFail);
  2907 				}
  2908 			break;
  2909 			}
  2910 		case EStateInitializing:
  2911 			{
  2912 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  2913 				{
  2914 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  2915 				iStartTime.HomeTime();
  2916 				TTimeIntervalMicroSeconds32 ToneOnLength(iToneOnLength);
  2917 				TTimeIntervalMicroSeconds32 ToneOffLength(iToneOffLength);
  2918 				TTimeIntervalMicroSeconds32 PauseLength(iPauseLength);
  2919 				INFO_PRINTF4(_L("Calling CMMFDevSound::SetDTMFLengths. ToneOnLength = %Ld, ToneOffLength = %Ld and PauseLength = %Ld"), iToneOnLength, iToneOffLength, iPauseLength);
  2920 				iMMFDevSound->SetDTMFLengths(ToneOnLength, ToneOffLength, PauseLength);
  2921 				INFO_PRINTF2(_L("Calling CMMFDevSound::PlayDTMFStringL %S"), &iDTMFString);
  2922 				TRAPD(err, iMMFDevSound->PlayDTMFStringL(iDTMFString));
  2923 				if (err != KErrNone)
  2924 					{
  2925 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error : %d!"), err);
  2926 					StopTest(err);
  2927 					break;
  2928 					}
  2929 				StartTimer(KMicrosecsInTenSec);
  2930 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  2931 				iDevSoundState=EStatePlaying;
  2932 				}
  2933 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  2934 				{
  2935 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  2936 				StopTest(aError);
  2937 				}
  2938 			else
  2939 				{
  2940 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  2941 				StopTest(aError, EFail);
  2942 				}
  2943 			break;
  2944 			}
  2945 		default:
  2946 			{
  2947 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  2948 			StopTest(aError, EFail);
  2949 			}
  2950 		}
  2951 	}
  2952 
  2953 void RA3FDevSoundToneSetDTMFToneOnLengthToMinusOneTest::DoTimerCallback()
  2954 	{
  2955 	iTimer->Cancel();
  2956 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  2957 	iEndTime.HomeTime();
  2958 	iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  2959 	INFO_PRINTF1(_L("SetDTMF lengths succeded."));
  2960 	INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  2961 	StopTest();
  2962 	}
  2963 
  2964 void RA3FDevSoundToneSetDTMFToneOnLengthToMinusOneTest::ToneFinished(TInt aError)
  2965 	{
  2966 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  2967 	if (aError == KErrUnderflow)
  2968 		{
  2969 		INFO_PRINTF1(_L("ToneFinished was called before the timer event."));
  2970 		StopTest(aError);
  2971 		}
  2972 	else
  2973 		{
  2974 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  2975 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  2976 		StopTest(aError, EFail);
  2977 		}
  2978 	}
  2979 
  2980 /*
  2981  *========================================================================================================
  2982  * MM-A3F-DEVSOUND-CHRTZ-TONE-0022
  2983  */
  2984 RA3FDevSoundToneSetToneRepetitionsRepeatTrailingSilenceToNegativeTest::RA3FDevSoundToneSetToneRepetitionsRepeatTrailingSilenceToNegativeTest(const TDesC& aTestName)
  2985 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  2986 		iFrequencyTone1(0),
  2987 		iRepeatTrailingSilence(0), iRepeatCount(0),
  2988 		iInitializedToPlayTones(EFalse)
  2989 	{
  2990 	}
  2991 
  2992 RA3FDevSoundToneSetToneRepetitionsRepeatTrailingSilenceToNegativeTest* RA3FDevSoundToneSetToneRepetitionsRepeatTrailingSilenceToNegativeTest::NewL(const TDesC& aTestName)
  2993 	{
  2994 	RA3FDevSoundToneSetToneRepetitionsRepeatTrailingSilenceToNegativeTest * self = new(ELeave)RA3FDevSoundToneSetToneRepetitionsRepeatTrailingSilenceToNegativeTest(aTestName);
  2995 	return self;
  2996 	}
  2997 
  2998 void RA3FDevSoundToneSetToneRepetitionsRepeatTrailingSilenceToNegativeTest::DoKickoffTestL()
  2999 	{
  3000 	if (!GetIntFromConfig(iTestStepName, KRepeatCount, iRepeatCount))
  3001 		{
  3002 		ERR_PRINTF2(KMsgErrorGetParameter, &KRepeatCount);
  3003 		StopTest(KErrNotFound);
  3004 		return;
  3005 		}
  3006 	if (!GetIntFromConfig(iTestStepName, KRepeatTrailingSilence, iRepeatTrailingSilence))
  3007 		{
  3008 		ERR_PRINTF2(KMsgErrorGetParameter, &KRepeatTrailingSilence);
  3009 		StopTest(KErrNotFound);
  3010 		return;
  3011 		}
  3012 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  3013 		{
  3014 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  3015 		StopTest(KErrNotFound);
  3016 		return;
  3017 		}
  3018 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  3019 		{
  3020 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  3021 		StopTest(KErrNotFound);
  3022 		return;
  3023 		}
  3024 	}
  3025 
  3026 void RA3FDevSoundToneSetToneRepetitionsRepeatTrailingSilenceToNegativeTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  3027 	{
  3028 	switch (iDevSoundState)
  3029 		{
  3030 		case EStateCreated:
  3031 			{
  3032 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetToneRepetitionsRepeatTrailingSilenceToNegativeTest"), EFsmIncorrectErrorPassed));
  3033 			if(aDevSoundEvent == EEventInitialize)
  3034 				{
  3035 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  3036 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  3037 				if (err != KErrNone)
  3038 					{
  3039 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  3040 					StopTest(err);
  3041 					break;
  3042 					}
  3043 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  3044 				iDevSoundState = EStateInitializing;
  3045 				}
  3046 			else
  3047 				{
  3048 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  3049 				StopTest(aError, EFail);
  3050 				}
  3051 			break;
  3052 			}
  3053 		case EStateInitializing:
  3054 			{
  3055 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  3056 				{
  3057 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  3058 				INFO_PRINTF3(_L("Calling CMMFDevSound::SetToneRepeats using RepeatCount = %d and RepeatTrailingSilence = %d microsecs"), iRepeatCount, iRepeatTrailingSilence);
  3059 				iMMFDevSound->SetToneRepeats(iRepeatCount, iRepeatTrailingSilence);
  3060 				iStartTime.HomeTime();
  3061 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL %d Hz during %d secs "), iFrequencyTone1, iDuration);
  3062 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  3063 				if (err != KErrNone)
  3064 					{
  3065 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  3066 					StopTest(err);
  3067 					break;
  3068 					}
  3069 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  3070 				iDevSoundState = EStatePlaying;
  3071 				}
  3072 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  3073 				{
  3074 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  3075 				StopTest(aError);
  3076 				}
  3077 			else
  3078 				{
  3079 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  3080 				StopTest(aError, EFail);
  3081 				}
  3082 			break;
  3083 			}
  3084 		default:
  3085 			{
  3086 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  3087 			StopTest(aError, EFail);
  3088 			}
  3089 		}
  3090 	}
  3091 
  3092 
  3093 void RA3FDevSoundToneSetToneRepetitionsRepeatTrailingSilenceToNegativeTest::ToneFinished(TInt aError)
  3094 	{
  3095 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  3096 	if (aError == KErrUnderflow)
  3097 		{
  3098 		iEndTime.HomeTime();
  3099 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  3100 		TInt repeatTrailingSilenceToSecs = iRepeatTrailingSilence/KMicroSecsInOneSec;
  3101 		TInt totalExpectedReproductionTime = (iRepeatCount * iDuration + iDuration + (repeatTrailingSilenceToSecs*iRepeatCount))*KMicroSecsInOneSec;
  3102 		if(iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
  3103 			{
  3104 			INFO_PRINTF1(_L("Play tone repeats succeded."));
  3105 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  3106 			StopTest();
  3107 			}
  3108 		else
  3109 			{
  3110 			ERR_PRINTF1(_L("Play tone repeats did not work as planned."));
  3111 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
  3112 			StopTest(KErrNone, EFail);
  3113 			}
  3114 		}
  3115 	else
  3116 		{
  3117 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  3118 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  3119 		StopTest(aError);
  3120 		}
  3121 	}
  3122 
  3123 /*
  3124  *========================================================================================================
  3125  * MM-A3F-DEVSOUND-CHRTZ-TONE-0023
  3126  */
  3127 RA3FDevSoundToneSetToneRepetitionsRepeatCountToKMdaRepeatForeverTest::RA3FDevSoundToneSetToneRepetitionsRepeatCountToKMdaRepeatForeverTest(const TDesC& aTestName)
  3128 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  3129 		iFrequencyTone1(0),
  3130 		iRepeatTrailingSilence(0), iRepeatCount(0),
  3131 		iInitializedToPlayTones(EFalse)
  3132 	{
  3133 	}
  3134 
  3135 RA3FDevSoundToneSetToneRepetitionsRepeatCountToKMdaRepeatForeverTest* RA3FDevSoundToneSetToneRepetitionsRepeatCountToKMdaRepeatForeverTest::NewL(const TDesC& aTestName)
  3136 	{
  3137 	RA3FDevSoundToneSetToneRepetitionsRepeatCountToKMdaRepeatForeverTest * self = new(ELeave)RA3FDevSoundToneSetToneRepetitionsRepeatCountToKMdaRepeatForeverTest(aTestName);
  3138 	return self;
  3139 	}
  3140 
  3141 void RA3FDevSoundToneSetToneRepetitionsRepeatCountToKMdaRepeatForeverTest::DoKickoffTestL()
  3142 	{
  3143 	if (!GetIntFromConfig(iTestStepName, KRepeatCount, iRepeatCount))
  3144 		{
  3145 		ERR_PRINTF2(KMsgErrorGetParameter, &KRepeatCount);
  3146 		StopTest(KErrNotFound);
  3147 		return;
  3148 		}
  3149 	if (!GetIntFromConfig(iTestStepName, KRepeatTrailingSilence, iRepeatTrailingSilence))
  3150 		{
  3151 		ERR_PRINTF2(KMsgErrorGetParameter, &KRepeatTrailingSilence);
  3152 		StopTest(KErrNotFound);
  3153 		return;
  3154 		}
  3155 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  3156 		{
  3157 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  3158 		StopTest(KErrNotFound);
  3159 		return;
  3160 		}
  3161 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  3162 		{
  3163 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  3164 		StopTest(KErrNotFound);
  3165 		return;
  3166 		}
  3167 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  3168 	}
  3169 
  3170 void RA3FDevSoundToneSetToneRepetitionsRepeatCountToKMdaRepeatForeverTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  3171 	{
  3172 	switch (iDevSoundState)
  3173 		{
  3174 		case EStateCreated:
  3175 			{
  3176 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneSetToneRepetitionsRepeatCountToKMdaRepeatForeverTest"), EFsmIncorrectErrorPassed));
  3177 			if(aDevSoundEvent == EEventInitialize)
  3178 				{
  3179 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  3180 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  3181 				if (err != KErrNone)
  3182 					{
  3183 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  3184 					StopTest(err);
  3185 					break;
  3186 					}
  3187 				StartTimer(KMicrosecsInTenSec);
  3188 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  3189 				iDevSoundState = EStateInitializing;
  3190 				}
  3191 			else
  3192 				{
  3193 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  3194 				StopTest(aError, EFail);
  3195 				}
  3196 			break;
  3197 			}
  3198 		case EStateInitializing:
  3199 			{
  3200 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  3201 				{
  3202 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  3203 				INFO_PRINTF3(_L("Calling CMMFDevSound::SetToneRepeats using RepeatCount = %d and RepeatTrailingSilence = %d microsecs"), iRepeatCount, iRepeatTrailingSilence);
  3204 				iMMFDevSound->SetToneRepeats(iRepeatCount, iRepeatTrailingSilence);
  3205 				iStartTime.HomeTime();
  3206 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL %d Hz during %d secs "), iFrequencyTone1, iDuration);
  3207 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  3208 				if (err != KErrNone)
  3209 					{
  3210 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  3211 					StopTest(err);
  3212 					break;
  3213 					}
  3214 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  3215 				iDevSoundState = EStatePlaying;
  3216 				}
  3217 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  3218 				{
  3219 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  3220 				StopTest(aError);
  3221 				}
  3222 			else
  3223 				{
  3224 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  3225 				StopTest(aError, EFail);
  3226 				}
  3227 			break;
  3228 			}
  3229 		default:
  3230 			{
  3231 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  3232 			StopTest(aError, EFail);
  3233 			}
  3234 		}
  3235 	}
  3236 
  3237 
  3238 void RA3FDevSoundToneSetToneRepetitionsRepeatCountToKMdaRepeatForeverTest::DoTimerCallback()
  3239 	{
  3240 	iTimer->Cancel();
  3241 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  3242 	iEndTime.HomeTime();
  3243 	iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  3244 	INFO_PRINTF1(_L("Setting repeatCount value to KMdaRepeatForeverTest succeded."));
  3245 	INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  3246 	iMMFDevSound->Stop();
  3247 	StopTest();
  3248 	}
  3249 
  3250 void RA3FDevSoundToneSetToneRepetitionsRepeatCountToKMdaRepeatForeverTest::ToneFinished(TInt aError)
  3251 	{
  3252 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  3253 	if (aError == KErrUnderflow)
  3254 		{
  3255 		INFO_PRINTF1(_L("ToneFinished was called before the timer event."));
  3256 		StopTest(aError);
  3257 		}
  3258 	else
  3259 		{
  3260 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  3261 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  3262 		StopTest(aError, EFail);
  3263 		}
  3264 	}
  3265 
  3266 /*
  3267  *========================================================================================================
  3268  * MM-A3F-DEVSOUND-CHRTZ-TONE-0024
  3269  */
  3270 RA3FDevSoundToneCapsTest::RA3FDevSoundToneCapsTest(const TDesC& aTestName)
  3271 	:	RA3FDevSoundTestBase(aTestName), iExCapRate(0), iExCapChannels(0)
  3272 	{
  3273 	}
  3274 
  3275 RA3FDevSoundToneCapsTest* RA3FDevSoundToneCapsTest::NewL(const TDesC& aTestName)
  3276 	{
  3277 	RA3FDevSoundToneCapsTest * self = new(ELeave)RA3FDevSoundToneCapsTest(aTestName);
  3278 	return self;
  3279 	}
  3280 
  3281 void RA3FDevSoundToneCapsTest::DoKickoffTestL()
  3282 	{
  3283 	if (!GetIntFromConfig(iTestStepName, KExCapRate, iExCapRate))
  3284 		{
  3285 		ERR_PRINTF2(KMsgErrorGetParameter, &KSampleRate);
  3286 		StopTest(KErrNotFound);
  3287 		return;
  3288 		}
  3289 	if (!GetIntFromConfig(iTestStepName, KExCapChannels, iExCapChannels))
  3290 		{
  3291 		ERR_PRINTF2(KMsgErrorGetParameter, &KChannel);
  3292 		StopTest(KErrNotFound);
  3293 		return;
  3294 		}
  3295 	}
  3296 
  3297 void RA3FDevSoundToneCapsTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  3298 	{
  3299 	switch(iDevSoundState)
  3300 		{
  3301 		case EStateCreated:
  3302 			{
  3303 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneCapsTest"), EFsmIncorrectErrorPassed));
  3304 			if (aDevSoundEvent == EEventInitialize)
  3305 				{
  3306 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  3307 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  3308 				if (err != KErrNone)
  3309 					{
  3310 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  3311 					StopTest(err);
  3312 					break;
  3313 					}
  3314 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  3315 				iDevSoundState = EStateInitializing;
  3316 				}
  3317 			else
  3318 				{
  3319 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  3320 				StopTest(aError,  EFail);
  3321 				}
  3322 			break;
  3323 			}
  3324 		case EStateInitializing:
  3325 			{
  3326 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  3327 				{
  3328 				TMMFCapabilities capabilities;
  3329 				INFO_PRINTF1(_L("Calling CMMFDevSound::Capabilities"));
  3330 				capabilities = iMMFDevSound->Capabilities();
  3331 				PrintSupportedCapabilities(capabilities.iRate, capabilities.iChannels);
  3332 				if(capabilities.iRate == iExCapRate)
  3333 					{
  3334 					INFO_PRINTF2(_L("The total of possible sample rate values is 0x%08x"), capabilities.iRate);
  3335 					}
  3336 				else
  3337 					{
  3338 					ERR_PRINTF2(_L("The total of possible sample rate values failed with 0x%08x"), capabilities.iRate);
  3339 					ERR_PRINTF2(_L("Expected value = %d"), iExCapRate);
  3340 					StopTest(aError, EFail);
  3341 					}
  3342 				if(capabilities.iChannels == iExCapChannels)
  3343 					{
  3344 					INFO_PRINTF2(_L("The total of possible channel values is 0x%08x"),capabilities.iChannels );
  3345 					StopTest();
  3346 					}
  3347 				else
  3348 					{
  3349 					ERR_PRINTF2(_L("The total of possible channel values failed with 0x%08x"), capabilities.iChannels );
  3350 					ERR_PRINTF2(_L("Expected value = %d"), iExCapChannels);
  3351 					StopTest(aError, EFail);
  3352 					}
  3353 				}
  3354 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  3355 				{
  3356 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  3357 				StopTest(aError);
  3358 				}
  3359 			else
  3360 				{
  3361 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  3362 				StopTest(aError, EFail);
  3363 				}
  3364 			break;
  3365 			}
  3366 		default:
  3367 			{
  3368 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  3369 			StopTest(aError, EFail);
  3370 			}
  3371 		}
  3372 	}
  3373 
  3374 /*
  3375  *========================================================================================================
  3376  * MM-A3F-DEVSOUND-CHRTZ-TONE-0025
  3377  */
  3378 RA3FDevSoundToneConfigDefaultTest::RA3FDevSoundToneConfigDefaultTest(const TDesC& aTestName)
  3379 	:	RA3FDevSoundTestBase(aTestName), iExCapRate(0),
  3380 		iExCapChannels(0)
  3381 	{
  3382 	}
  3383 
  3384 RA3FDevSoundToneConfigDefaultTest* RA3FDevSoundToneConfigDefaultTest::NewL(const TDesC& aTestName)
  3385 	{
  3386 	RA3FDevSoundToneConfigDefaultTest * self = new(ELeave)RA3FDevSoundToneConfigDefaultTest(aTestName);
  3387 	return self;
  3388 	}
  3389 
  3390 void RA3FDevSoundToneConfigDefaultTest::DoKickoffTestL()
  3391 	{
  3392 	if (!GetIntFromConfig(iTestStepName, KExCapRate, iExCapRate))
  3393 			{
  3394 			ERR_PRINTF2(KMsgErrorGetParameter, &KExCapRate);
  3395 			StopTest(KErrNotFound);
  3396 			return;
  3397 			}
  3398 	if (!GetIntFromConfig(iTestStepName, KExCapChannels, iExCapChannels))
  3399 		{
  3400 		ERR_PRINTF2(KMsgErrorGetParameter, &KExCapChannels);
  3401 		StopTest(KErrNotFound);
  3402 		return;
  3403 		}
  3404 	}
  3405 
  3406 void RA3FDevSoundToneConfigDefaultTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  3407 	{
  3408 		switch(iDevSoundState)
  3409 		{
  3410 		case EStateCreated:
  3411 			{
  3412 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneConfigDefaultTest"), EFsmIncorrectErrorPassed));
  3413 			if (aDevSoundEvent == EEventInitialize)
  3414 				{
  3415 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  3416 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  3417 				if (err != KErrNone)
  3418 					{
  3419 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  3420 					StopTest(err);
  3421 					}
  3422 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  3423 				iDevSoundState=EStateInitializing;
  3424 				}
  3425 			else
  3426 				{
  3427 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  3428 				StopTest(aError, EFail);
  3429 				}
  3430 			break;
  3431 			}
  3432 		case EStateInitializing:
  3433 			{
  3434 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  3435 				{
  3436 				TMMFCapabilities capabilitiesGet;
  3437 				TBuf<KMaxSampleRateStringLength> stringSampleRateGet;
  3438 				TBuf<KMaxChannelsStringLength> stringChannelsGet;
  3439 				TBuf<KMaxSampleRateStringLength> stringSampleRateExpected;
  3440 				TBuf<KMaxChannelsStringLength> stringChannelsExpected;
  3441 				INFO_PRINTF1(_L("Calling CMMFDevSound::Config"));
  3442 				capabilitiesGet=iMMFDevSound->Config();
  3443 				SampleRateFromTUintToString (capabilitiesGet.iRate, stringSampleRateGet);
  3444 				ChannelsFromTUintToString (capabilitiesGet.iChannels, stringChannelsGet);
  3445 				SampleRateFromTIntToTMMFSampleRate (iExCapRate, iExSampleRate);
  3446 				SampleRateFromTUintToString (iExSampleRate, stringSampleRateExpected);
  3447 				ChannelsFromTUintToString (iExCapChannels, stringChannelsExpected);
  3448 				if (stringSampleRateExpected.Compare(stringSampleRateGet) == 0)
  3449 					{
  3450 					INFO_PRINTF2(_L("Sample rate value match default as expected with %S"), &stringSampleRateGet);
  3451 					if (stringChannelsExpected.Compare(stringChannelsGet) == 0)
  3452 						{
  3453 						INFO_PRINTF2(_L("Channel mode value match default as expected with %S"), &stringChannelsGet);
  3454 						StopTest();
  3455 						}
  3456 					else
  3457 						{
  3458 						INFO_PRINTF2(_L("Channel mode value failed with %S"), &stringChannelsGet);
  3459 						ERR_PRINTF2(_L("Expected channel mode %S"), &stringChannelsExpected);
  3460 						StopTest(aError, EFail);
  3461 						}
  3462 					}
  3463 				else
  3464 					{
  3465 					ERR_PRINTF2(_L("Sample rate value failed with %S"), &stringSampleRateGet);
  3466 					ERR_PRINTF2(_L("Expected sample rate %S"), &stringSampleRateExpected);
  3467 					StopTest(aError, EFail);
  3468 					}
  3469 				}
  3470 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  3471 				{
  3472 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  3473 				StopTest(aError);
  3474 				}
  3475 			else
  3476 				{
  3477 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  3478 				StopTest(aError, EFail);
  3479 				}
  3480 			break;
  3481 			}
  3482 		default:
  3483 			{
  3484 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  3485 			StopTest(aError, EFail);
  3486 			}
  3487 		}
  3488 	}
  3489 
  3490 /*
  3491  *========================================================================================================
  3492  * MM-A3F-DEVSOUND-CHRTZ-TONE-0026
  3493  */
  3494 RA3FDevSoundToneMaxVolumeTest::RA3FDevSoundToneMaxVolumeTest(const TDesC& aTestName)
  3495 	:	RA3FDevSoundTestBase(aTestName), iExVolume(0)
  3496 	{
  3497 	}
  3498 
  3499 RA3FDevSoundToneMaxVolumeTest* RA3FDevSoundToneMaxVolumeTest::NewL(const TDesC& aTestName)
  3500 	{
  3501 	RA3FDevSoundToneMaxVolumeTest * self = new(ELeave)RA3FDevSoundToneMaxVolumeTest(aTestName);
  3502 	return self;
  3503 	}
  3504 
  3505 void RA3FDevSoundToneMaxVolumeTest::DoKickoffTestL()
  3506 	{
  3507 	if (!GetIntFromConfig(iTestStepName, KExVolume, iExVolume))
  3508 		{
  3509 		ERR_PRINTF2(KMsgErrorGetParameter, &KExVolume);
  3510 		StopTest(KErrNotFound);
  3511 		return;
  3512 		}
  3513 	}
  3514 
  3515 void RA3FDevSoundToneMaxVolumeTest::Fsm(TMmfDevSoundEvent aDevSoundEvent,  TInt aError)
  3516 	{
  3517 	switch(iDevSoundState)
  3518 		{
  3519 		case EStateCreated:
  3520 			{
  3521 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneMaxVolumeTest"), EFsmIncorrectErrorPassed));
  3522 			if (aDevSoundEvent == EEventInitialize)
  3523 				{
  3524 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  3525 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  3526 				if (err != KErrNone)
  3527 					{
  3528 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  3529 					StopTest(err);
  3530 					break;
  3531 					}
  3532 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  3533 				iDevSoundState = EStateInitializing;
  3534 				}
  3535 			else
  3536 				{
  3537 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  3538 				StopTest(aError, EFail);
  3539 				}
  3540 			break;
  3541 			}
  3542 		case EStateInitializing:
  3543 			{
  3544 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  3545 				{
  3546 				INFO_PRINTF1(_L("Calling CMMFDevSound::MaxVolume"));
  3547 				TInt maxVolumeGet = iMMFDevSound->MaxVolume();
  3548 				if (maxVolumeGet == iExVolume)
  3549 					{
  3550 					INFO_PRINTF2(_L("The max device supported volume is %d."), maxVolumeGet);
  3551 					StopTest();
  3552 					}
  3553 				else
  3554 					{
  3555 					INFO_PRINTF2(_L("The max device supported volume failed with %d."), maxVolumeGet);
  3556 					ERR_PRINTF2(_L("Expected value = %d."), iExVolume);
  3557 					StopTest(aError, EFail);
  3558 					}
  3559 				}
  3560 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  3561 				{
  3562 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  3563 				StopTest(aError);
  3564 				}
  3565 			else
  3566 				{
  3567 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  3568 				StopTest(aError, EFail);
  3569 				}
  3570 			break;
  3571 			}
  3572 		default:
  3573 			{
  3574 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  3575 			StopTest(aError, EFail);
  3576 			}
  3577 		}
  3578 	}
  3579 
  3580 /*
  3581  *========================================================================================================
  3582  * MM-A3F-DEVSOUND-CHRTZ-TONE-0027
  3583  */
  3584 RA3FDevSoundToneVolumeTest::RA3FDevSoundToneVolumeTest(const TDesC& aTestName)
  3585 	:	RA3FDevSoundTestBase(aTestName), iExVolume(0)
  3586 	{
  3587 	}
  3588 
  3589 RA3FDevSoundToneVolumeTest* RA3FDevSoundToneVolumeTest::NewL(const TDesC& aTestName)
  3590 	{
  3591 	RA3FDevSoundToneVolumeTest * self = new(ELeave)RA3FDevSoundToneVolumeTest(aTestName);
  3592 	return self;
  3593 	}
  3594 
  3595 void RA3FDevSoundToneVolumeTest::DoKickoffTestL()
  3596 	{
  3597 	if (!GetIntFromConfig(iTestStepName, KExVolume, iExVolume))
  3598 		{
  3599 		ERR_PRINTF2(KMsgErrorGetParameter, &KExVolume);
  3600 		StopTest(KErrNotFound);
  3601 		return;
  3602 		}
  3603 	}
  3604 
  3605 void RA3FDevSoundToneVolumeTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  3606 	{
  3607 	switch (iDevSoundState)
  3608 		{
  3609 		case EStateCreated:
  3610 			{
  3611 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneVolumeTest"), EFsmIncorrectErrorPassed));
  3612 			if (aDevSoundEvent == EEventInitialize)
  3613 				{
  3614 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  3615 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  3616 				if (err != KErrNone)
  3617 					{
  3618 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  3619 					StopTest(err);
  3620 					break;
  3621 					}
  3622 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  3623 				iDevSoundState = EStateInitializing;
  3624 				}
  3625 			else
  3626 				{
  3627 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  3628 				StopTest(aError, EFail);
  3629 				}
  3630 			break;
  3631 			}
  3632 		case EStateInitializing:
  3633 			{
  3634 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  3635 				{
  3636 				INFO_PRINTF1(_L("Calling CMMFDevSound::Volume"));
  3637 				TInt volumeGet = iMMFDevSound->Volume();
  3638 				if(volumeGet == iExVolume)
  3639 					{
  3640 					INFO_PRINTF2(_L("Default device volume succeeded with = %d"), volumeGet);
  3641 					StopTest();
  3642 					}
  3643 				else
  3644 					{
  3645 					ERR_PRINTF2(_L("Default device volume failed with = %d"), volumeGet);
  3646 					ERR_PRINTF2(_L("Expected value % d"), iExVolume);
  3647 					StopTest(aError , EFail);
  3648 					}
  3649 				}
  3650 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  3651 				{
  3652 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  3653 				StopTest(aError);
  3654 				}
  3655 			else
  3656 				{
  3657 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  3658 				StopTest(aError, EFail);
  3659 				}
  3660 			break;
  3661 			}
  3662 		default:
  3663 			{
  3664 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  3665 			StopTest(aError, EFail);
  3666 			}
  3667 		}
  3668 	}
  3669 
  3670 
  3671 /*
  3672  *========================================================================================================
  3673  * MM-A3F-DEVSOUND-CHRTZ-TONE-0028
  3674  */
  3675 RA3FDevSoundToneQueryCapsWhilePlayingTest::RA3FDevSoundToneQueryCapsWhilePlayingTest(const TDesC& aTestName)
  3676 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  3677 		iFrequencyTone1(0), iExCapRate(0), iExCapChannels(0)
  3678 	{
  3679 	}
  3680 
  3681 RA3FDevSoundToneQueryCapsWhilePlayingTest* RA3FDevSoundToneQueryCapsWhilePlayingTest::NewL(const TDesC& aTestName)
  3682 	{
  3683 	RA3FDevSoundToneQueryCapsWhilePlayingTest * self = new(ELeave)RA3FDevSoundToneQueryCapsWhilePlayingTest(aTestName);
  3684 	return self;
  3685 	}
  3686 
  3687 void RA3FDevSoundToneQueryCapsWhilePlayingTest::DoKickoffTestL()
  3688 	{
  3689 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  3690 		{
  3691 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  3692 		StopTest(KErrNotFound);
  3693 		return;
  3694 		}
  3695 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  3696 		{
  3697 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  3698 		StopTest(KErrNotFound);
  3699 		return;
  3700 		}
  3701 	if (!GetIntFromConfig(iTestStepName, KExCapRate, iExCapRate))
  3702 		{
  3703 		ERR_PRINTF2(KMsgErrorGetParameter, &KSampleRate);
  3704 		StopTest(KErrNotFound);
  3705 		return;
  3706 		}
  3707 	if (!GetIntFromConfig(iTestStepName, KExCapChannels, iExCapChannels))
  3708 		{
  3709 		ERR_PRINTF2(KMsgErrorGetParameter, &KChannel);
  3710 		StopTest(KErrNotFound);
  3711 		return;
  3712 		}
  3713 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  3714 	}
  3715 
  3716 void RA3FDevSoundToneQueryCapsWhilePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  3717 	{
  3718 	switch (iDevSoundState)
  3719 		{
  3720 		case EStateCreated:
  3721 			{
  3722 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneQueryCapsWhilePlayingTest"), EFsmIncorrectErrorPassed));
  3723 			if (aDevSoundEvent == EEventInitialize)
  3724 				{
  3725 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  3726 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  3727 				if (err != KErrNone)
  3728 					{
  3729 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  3730 					StopTest(err);
  3731 					break;
  3732 					}
  3733 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  3734 				iDevSoundState = EStateInitializing;
  3735 				}
  3736 			else
  3737 				{
  3738 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  3739 				StopTest(aError, EFail);
  3740 				}
  3741 			break;
  3742 			}
  3743 		case EStateInitializing:
  3744 			{
  3745 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  3746 				{
  3747 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  3748 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  3749 				if (err != KErrNone)
  3750 					{
  3751 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  3752 					StopTest(err);
  3753 					break;
  3754 					}
  3755 				StartTimer(KMicroSecsTwoSec);
  3756 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  3757 				iDevSoundState = EStatePlaying;
  3758 				}
  3759 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  3760 				{
  3761 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  3762 				StopTest(aError);
  3763 				}
  3764 			else
  3765 				{
  3766 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  3767 				StopTest(aError, EFail);
  3768 				}
  3769 			break;
  3770 			}
  3771 		default:
  3772 			{
  3773 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  3774 			StopTest(aError, EFail);
  3775 			}
  3776 		}
  3777 	}
  3778 
  3779 void RA3FDevSoundToneQueryCapsWhilePlayingTest::DoTimerCallback()
  3780 	{
  3781 	iTimer->Cancel();
  3782 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  3783 	TMMFCapabilities capabilities;
  3784 	INFO_PRINTF1(_L("Calling CMMFDevSound::Capabilities"));
  3785 	capabilities = iMMFDevSound->Capabilities();
  3786 	PrintSupportedCapabilities(capabilities.iRate, capabilities.iChannels);
  3787 	if(capabilities.iRate == iExCapRate)
  3788 		{
  3789 		INFO_PRINTF2(_L("The total of possible sample rate values is 0x%08x"), capabilities.iRate);
  3790 		}
  3791 	else
  3792 		{
  3793 		ERR_PRINTF2(_L("The total of possible sample rate values failed with 0x%08x"), capabilities.iRate);
  3794 		ERR_PRINTF2(_L("Expected value = %d"), iExCapRate);
  3795 		StopTest(KErrNone, EFail);
  3796 		}
  3797 	if(capabilities.iChannels == iExCapChannels)
  3798 		{
  3799 		INFO_PRINTF2(_L("The total of possible channel values is 0x%08x"),capabilities.iChannels );
  3800 		}
  3801 	else
  3802 		{
  3803 		ERR_PRINTF2(_L("The total of possible channel values failed with 0x%08x"), capabilities.iChannels );
  3804 		ERR_PRINTF2(_L("Expected value = %d"), iExCapChannels);
  3805 		StopTest(KErrNone, EFail);
  3806 		}
  3807 	}
  3808 
  3809 /*
  3810  *========================================================================================================
  3811  * MM-A3F-DEVSOUND-CHRTZ-TONE-0029
  3812  */
  3813 RA3FDevSoundToneConfigWhilePlayingTest::RA3FDevSoundToneConfigWhilePlayingTest(const TDesC& aTestName)
  3814 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  3815 		iFrequencyTone1(0)
  3816 	{
  3817 	}
  3818 RA3FDevSoundToneConfigWhilePlayingTest* RA3FDevSoundToneConfigWhilePlayingTest::NewL(const TDesC& aTestName)
  3819 	{
  3820 	RA3FDevSoundToneConfigWhilePlayingTest * self = new(ELeave)RA3FDevSoundToneConfigWhilePlayingTest(aTestName);
  3821 	return self;
  3822 	}
  3823 
  3824 void RA3FDevSoundToneConfigWhilePlayingTest::DoKickoffTestL()
  3825 	{
  3826 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  3827 		{
  3828 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  3829 		StopTest(KErrNotFound);
  3830 		return;
  3831 		}
  3832 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  3833 		{
  3834 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  3835 		StopTest(KErrNotFound);
  3836 		return;
  3837 		}
  3838 	if (!GetIntFromConfig(iTestStepName, KExCapRate, iExCapRate))
  3839 			{
  3840 			ERR_PRINTF2(KMsgErrorGetParameter, &KExCapRate);
  3841 			StopTest(KErrNotFound);
  3842 			return;
  3843 			}
  3844 	if (!GetIntFromConfig(iTestStepName, KExCapChannels, iExCapChannels))
  3845 		{
  3846 		ERR_PRINTF2(KMsgErrorGetParameter, &KExCapChannels);
  3847 		StopTest(KErrNotFound);
  3848 		return;
  3849 		}
  3850 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  3851 	}
  3852 
  3853 void RA3FDevSoundToneConfigWhilePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  3854 	{
  3855 	switch(iDevSoundState)
  3856 		{
  3857 		case EStateCreated:
  3858 			{
  3859 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneConfigWhilePlayingTest"), EFsmIncorrectErrorPassed));
  3860 			if (aDevSoundEvent == EEventInitialize)
  3861 				{
  3862 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  3863 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  3864 				if (err != KErrNone)
  3865 					{
  3866 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  3867 					StopTest(err);
  3868 					break;
  3869 					}
  3870 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  3871 				iDevSoundState = EStateInitializing;
  3872 				}
  3873 			else
  3874 				{
  3875 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  3876 				StopTest(aError, EFail);
  3877 				}
  3878 			break;
  3879 			}
  3880 		case EStateInitializing:
  3881 			{
  3882 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  3883 				{
  3884 				iStartTime.HomeTime();
  3885 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  3886 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  3887 				if (err != KErrNone)
  3888 					{
  3889 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"),  err);
  3890 					StopTest(err);
  3891 					break;
  3892 					}
  3893 				StartTimer(KMicroSecsTwoSec);
  3894 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  3895 				iDevSoundState = EStatePlaying;
  3896 				}
  3897 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  3898 				{
  3899 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  3900 				StopTest(aError);
  3901 				}
  3902 			else
  3903 				{
  3904 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  3905 				StopTest(aError, EFail);
  3906 				}
  3907 			break;
  3908 			}
  3909 		default:
  3910 			{
  3911 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  3912 			StopTest(aError, EFail);
  3913 			}
  3914 		}
  3915 	}
  3916 
  3917 void RA3FDevSoundToneConfigWhilePlayingTest::DoTimerCallback()
  3918 	{
  3919 	iTimer->Cancel();
  3920 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  3921 	TMMFCapabilities capabilitiesGet;
  3922 	TBuf<KMaxSampleRateStringLength> stringSampleRateGet;
  3923 	TBuf<KMaxChannelsStringLength> stringChannelsGet;
  3924 	TBuf<KMaxSampleRateStringLength> stringSampleRateExpected;
  3925 	TBuf<KMaxChannelsStringLength> stringChannelsExpected;
  3926 	INFO_PRINTF1(_L("Calling CMMFDevSound::Config while playing"));
  3927 	capabilitiesGet=iMMFDevSound->Config();
  3928 	SampleRateFromTUintToString (capabilitiesGet.iRate, stringSampleRateGet);
  3929 	ChannelsFromTUintToString (capabilitiesGet.iChannels, stringChannelsGet);
  3930 	SampleRateFromTIntToTMMFSampleRate (iExCapRate, iExSampleRate);
  3931 	SampleRateFromTUintToString (iExSampleRate, stringSampleRateExpected);
  3932 	ChannelsFromTUintToString (iExCapChannels, stringChannelsExpected);
  3933 	if (stringSampleRateExpected.Compare(stringSampleRateGet) == 0)
  3934 		{
  3935 		INFO_PRINTF2(_L("Sample rate value match default as expected with %S"), &stringSampleRateGet);
  3936 		if (stringChannelsExpected.Compare(stringChannelsGet) == 0)
  3937 			{
  3938 			INFO_PRINTF2(_L("Channel mode value match default as expected with %S"), &stringChannelsGet);
  3939 			StopTest();
  3940 			}
  3941 		else
  3942 			{
  3943 			INFO_PRINTF2(_L("Channel mode value failed with %S"), &stringChannelsGet);
  3944 			ERR_PRINTF2(_L("Expected channel mode %S"), &stringChannelsExpected);
  3945 			StopTest(KErrNone, EFail);
  3946 			}
  3947 		}
  3948 	else
  3949 		{
  3950 		ERR_PRINTF2(_L("Sample rate value failed with %S"), &stringSampleRateGet);
  3951 		ERR_PRINTF2(_L("Expected sample rate %S"), &stringSampleRateExpected);
  3952 		StopTest(KErrNone, EFail);
  3953 		}
  3954 	}
  3955 
  3956 void RA3FDevSoundToneConfigWhilePlayingTest::ToneFinished(TInt aError)
  3957 	{
  3958 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  3959 	if (aError == KErrUnderflow)
  3960 		{
  3961 		iEndTime.HomeTime();
  3962 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  3963 		TInt totalExpectedReproductionTime = iDuration * KMicroSecsInOneSec;
  3964 		if(iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
  3965 			{
  3966 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  3967 			StopTest();
  3968 			}
  3969 		else
  3970 			{
  3971 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
  3972 			StopTest(KErrNone, EFail);
  3973 			}
  3974 		}
  3975 	else
  3976 		{
  3977 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  3978 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  3979 		StopTest(aError, EFail);
  3980 		}
  3981 	}
  3982 
  3983 /*
  3984  *========================================================================================================
  3985  * MM-A3F-DEVSOUND-CHRTZ-TONE-0030
  3986  */
  3987 RA3FDevSoundToneMaxVolumeWhilePlayingTest::RA3FDevSoundToneMaxVolumeWhilePlayingTest(const TDesC& aTestName)
  3988 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  3989 		iFrequencyTone1(0), iExVolume(0)
  3990 	{
  3991 	}
  3992 
  3993 RA3FDevSoundToneMaxVolumeWhilePlayingTest* RA3FDevSoundToneMaxVolumeWhilePlayingTest::NewL(const TDesC& aTestName)
  3994 	{
  3995 	RA3FDevSoundToneMaxVolumeWhilePlayingTest * self = new(ELeave)RA3FDevSoundToneMaxVolumeWhilePlayingTest(aTestName);
  3996 	return self;
  3997 	}
  3998 
  3999 void RA3FDevSoundToneMaxVolumeWhilePlayingTest::DoKickoffTestL()
  4000 	{
  4001 	if (!GetIntFromConfig(iTestStepName, KExVolume, iExVolume))
  4002 		{
  4003 		ERR_PRINTF2(KMsgErrorGetParameter, &KExVolume);
  4004 		StopTest(KErrNotFound);
  4005 		return;
  4006 		}
  4007 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  4008 		{
  4009 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  4010 		StopTest(KErrNotFound);
  4011 		return;
  4012 		}
  4013 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  4014 		{
  4015 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  4016 		StopTest(KErrNotFound);
  4017 		return;
  4018 		}
  4019 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  4020 	}
  4021 
  4022 void RA3FDevSoundToneMaxVolumeWhilePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  4023 	{
  4024 	switch (iDevSoundState)
  4025 		{
  4026 		case EStateCreated:
  4027 			{
  4028 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneMaxVolumeWhilePlayingTest"), EFsmIncorrectErrorPassed));
  4029 			if (aDevSoundEvent == EEventInitialize)
  4030 				{
  4031 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  4032 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  4033 				if (err != KErrNone)
  4034 					{
  4035 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  4036 					StopTest(err);
  4037 					break;
  4038 					}
  4039 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  4040 				iDevSoundState = EStateInitializing;
  4041 				}
  4042 			else
  4043 				{
  4044 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  4045 				StopTest(aError, EFail);
  4046 				}
  4047 			break;
  4048 			}
  4049 		case EStateInitializing:
  4050 			{
  4051 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  4052 				{
  4053 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  4054 				iStartTime.HomeTime();
  4055 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  4056 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  4057 				if (err != KErrNone)
  4058 					{
  4059 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"),  err);
  4060 					StopTest(err);
  4061 					break;
  4062 					}
  4063 				StartTimer(KMicroSecsTwoSec);
  4064 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  4065 				iDevSoundState = EStatePlaying;
  4066 				}
  4067 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  4068 				{
  4069 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  4070 				StopTest(aError);
  4071 				}
  4072 			else
  4073 				{
  4074 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4075 				StopTest(aError, EFail);
  4076 				}
  4077 			break;
  4078 			}
  4079 		default:
  4080 			{
  4081 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  4082 			StopTest(aError, EFail);
  4083 			}
  4084 		}
  4085 	}
  4086 
  4087 void RA3FDevSoundToneMaxVolumeWhilePlayingTest::DoTimerCallback()
  4088 	{
  4089 	iTimer->Cancel();
  4090 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  4091 	INFO_PRINTF1(_L("Calling CMMFDevSound::MaxVolume"));
  4092 	TInt maxVolumeGet = iMMFDevSound->MaxVolume();
  4093 	if (maxVolumeGet == iExVolume)
  4094 		{
  4095 		INFO_PRINTF2(_L("The max device supported volume is %d."), maxVolumeGet);
  4096 		}
  4097 	else
  4098 		{
  4099 		INFO_PRINTF2(_L("The max device supported volume failed with %d."), maxVolumeGet);
  4100 		ERR_PRINTF2(_L("Expected value = %d."), iExVolume);
  4101 		StopTest(KErrNone, EFail);
  4102 		}
  4103 	}
  4104 
  4105 void RA3FDevSoundToneMaxVolumeWhilePlayingTest::ToneFinished(TInt aError)
  4106 	{
  4107 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  4108 	if (aError == KErrUnderflow)
  4109 		{
  4110 		iEndTime.HomeTime();
  4111 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  4112 		TInt totalExpectedReproductionTime = iDuration * KMicroSecsInOneSec;
  4113 		if(iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
  4114 			{
  4115 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  4116 			StopTest();
  4117 			}
  4118 		else
  4119 			{
  4120 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
  4121 			StopTest(KErrNone, EFail);
  4122 			}
  4123 		}
  4124 	else
  4125 		{
  4126 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  4127 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  4128 		StopTest(aError, EFail);
  4129 		}
  4130 	}
  4131 
  4132 /*
  4133  *========================================================================================================
  4134  * MM-A3F-DEVSOUND-CHRTZ-TONE-0031
  4135  */
  4136 RA3FDevSoundToneVolumeWhilePlayingTest::RA3FDevSoundToneVolumeWhilePlayingTest(const TDesC& aTestName)
  4137 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  4138 		iFrequencyTone1(0), iExVolume(0)
  4139 	{
  4140 	}
  4141 
  4142 RA3FDevSoundToneVolumeWhilePlayingTest* RA3FDevSoundToneVolumeWhilePlayingTest::NewL(const TDesC& aTestName)
  4143 	{
  4144 	RA3FDevSoundToneVolumeWhilePlayingTest * self = new(ELeave)RA3FDevSoundToneVolumeWhilePlayingTest(aTestName);
  4145 	return self;
  4146 	}
  4147 
  4148 void RA3FDevSoundToneVolumeWhilePlayingTest::DoKickoffTestL()
  4149 	{
  4150 	if (!GetIntFromConfig(iTestStepName, KExVolume, iExVolume))
  4151 		{
  4152 		ERR_PRINTF2(KMsgErrorGetParameter, &KExVolume);
  4153 		StopTest(KErrNotFound);
  4154 		return;
  4155 		}
  4156 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  4157 		{
  4158 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  4159 		StopTest(KErrNotFound);
  4160 		return;
  4161 		}
  4162 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  4163 		{
  4164 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  4165 		StopTest(KErrNotFound);
  4166 		return;
  4167 		}
  4168 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  4169 	}
  4170 
  4171 void RA3FDevSoundToneVolumeWhilePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  4172 	{
  4173 	switch (iDevSoundState)
  4174 		{
  4175 		case EStateCreated:
  4176 			{
  4177 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneVolumeWhilePlayingTest"), EFsmIncorrectErrorPassed));
  4178 			if (aDevSoundEvent == EEventInitialize)
  4179 				{
  4180 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  4181 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  4182 				if (err != KErrNone)
  4183 					{
  4184 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  4185 					StopTest(err);
  4186 					break;
  4187 					}
  4188 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  4189 				iDevSoundState = EStateInitializing;
  4190 				}
  4191 			else
  4192 				{
  4193 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  4194 				StopTest(aError, EFail);
  4195 				}
  4196 			break;
  4197 			}
  4198 		case EStateInitializing:
  4199 			{
  4200 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  4201 				{
  4202 				iStartTime.HomeTime();
  4203 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  4204 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  4205 				if (err != KErrNone)
  4206 					{
  4207 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  4208 					StopTest(err);
  4209 					break;
  4210 					}
  4211 				StartTimer(KMicroSecsTwoSec);
  4212 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  4213 				iDevSoundState = EStatePlaying;
  4214 				}
  4215 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  4216 				{
  4217 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  4218 				StopTest(aError);
  4219 				}
  4220 			else
  4221 				{
  4222 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4223 				StopTest(aError, EFail);
  4224 				}
  4225 			break;
  4226 			}
  4227 		default:
  4228 			{
  4229 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  4230 			StopTest(aError, EFail);
  4231 			}
  4232 		}
  4233 	}
  4234 
  4235 void RA3FDevSoundToneVolumeWhilePlayingTest::DoTimerCallback()
  4236 	{
  4237 	iTimer->Cancel();
  4238 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  4239 	INFO_PRINTF1(_L("Calling CMMFDevSound::Volume"));
  4240 	TInt maxVolumeGet = iMMFDevSound->Volume();
  4241 	if (maxVolumeGet == iExVolume)
  4242 		{
  4243 		INFO_PRINTF2(_L("The device default supported volume value is %d."), maxVolumeGet);
  4244 		}
  4245 	else
  4246 		{
  4247 		INFO_PRINTF2(_L("The device default supported volume value failed with %d."), maxVolumeGet);
  4248 		ERR_PRINTF2(_L("Expected value = %d."), iExVolume);
  4249 		StopTest(KErrNone, EFail);
  4250 		}
  4251 	}
  4252 
  4253 void RA3FDevSoundToneVolumeWhilePlayingTest::ToneFinished(TInt aError)
  4254 	{
  4255 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  4256 	if (aError == KErrUnderflow)
  4257 		{
  4258 		iEndTime.HomeTime();
  4259 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  4260 		TInt totalExpectedReproductionTime = iDuration * KMicroSecsInOneSec;
  4261 		if(iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
  4262 			{
  4263 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  4264 			StopTest();
  4265 			}
  4266 		else
  4267 			{
  4268 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
  4269 			StopTest(KErrNone, EFail);
  4270 			}
  4271 		}
  4272 	else
  4273 		{
  4274 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  4275 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  4276 		StopTest(aError, EFail);
  4277 		}
  4278 	}
  4279 
  4280 /*
  4281  *========================================================================================================
  4282  * MM-A3F-DEVSOUND-CHRTZ-TONE-0032
  4283  */
  4284 RA3FDevSoundToneQueryCapsWhilePausePlayingTest::RA3FDevSoundToneQueryCapsWhilePausePlayingTest(const TDesC& aTestName)
  4285 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  4286 		iFrequencyTone1(0), iExCapRate(0), iExCapChannels(0),
  4287 		iTimeToEnterPauseElapsed(EFalse)
  4288 	{
  4289 	}
  4290 
  4291 RA3FDevSoundToneQueryCapsWhilePausePlayingTest* RA3FDevSoundToneQueryCapsWhilePausePlayingTest::NewL(const TDesC& aTestName)
  4292 	{
  4293 	RA3FDevSoundToneQueryCapsWhilePausePlayingTest * self = new(ELeave)RA3FDevSoundToneQueryCapsWhilePausePlayingTest(aTestName);
  4294 	return self;
  4295 	}
  4296 
  4297 void RA3FDevSoundToneQueryCapsWhilePausePlayingTest::DoKickoffTestL()
  4298 	{
  4299 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  4300 		{
  4301 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  4302 		StopTest(KErrNotFound);
  4303 		return;
  4304 		}
  4305 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  4306 		{
  4307 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  4308 		StopTest(KErrNotFound);
  4309 		return;
  4310 		}
  4311 	if (!GetIntFromConfig(iTestStepName, KExCapRate, iExCapRate))
  4312 		{
  4313 		ERR_PRINTF2(KMsgErrorGetParameter, &KSampleRate);
  4314 		StopTest(KErrNotFound);
  4315 		return;
  4316 		}
  4317 	if (!GetIntFromConfig(iTestStepName, KExCapChannels, iExCapChannels))
  4318 		{
  4319 		ERR_PRINTF2(KMsgErrorGetParameter, &KChannel);
  4320 		StopTest(KErrNotFound);
  4321 		return;
  4322 		}
  4323 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  4324 	}
  4325 
  4326 void RA3FDevSoundToneQueryCapsWhilePausePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  4327 	{
  4328 	switch (iDevSoundState)
  4329 		{
  4330 		case EStateCreated:
  4331 			{
  4332 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneQueryCapsWhilePausePlayingTest"), EFsmIncorrectErrorPassed));
  4333 			if (aDevSoundEvent == EEventInitialize)
  4334 				{
  4335 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  4336 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  4337 				if (err != KErrNone)
  4338 					{
  4339 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  4340 					StopTest(err);
  4341 					break;
  4342 					}
  4343 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  4344 				iDevSoundState = EStateInitializing;
  4345 				}
  4346 			else
  4347 				{
  4348 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  4349 				StopTest(aError, EFail);
  4350 				}
  4351 			break;
  4352 			}
  4353 		case EStateInitializing:
  4354 			{
  4355 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  4356 				{
  4357 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  4358 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  4359 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  4360 				if (err != KErrNone)
  4361 					{
  4362 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  4363 					StopTest(err);
  4364 					break;
  4365 					}
  4366 				StartTimer(KMicroSecsTwoSec);
  4367 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  4368 				iDevSoundState = EStatePlaying;
  4369 				}
  4370 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  4371 				{
  4372 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  4373 				StopTest(aError);
  4374 				}
  4375 			else
  4376 				{
  4377 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4378 				StopTest(aError, EFail);
  4379 				}
  4380 			break;
  4381 			}
  4382 		case EStatePlaying:
  4383 			{
  4384 			if(aDevSoundEvent == EEventTimerComplete)
  4385 				{
  4386 				INFO_PRINTF1(_L("Calling CMMFDevSound::Pause"));
  4387 				iMMFDevSound->Pause();
  4388 				INFO_PRINTF1(_L("DevSound State: EStatePause"));
  4389 				iDevSoundState = EStatePause;
  4390 				}
  4391 			else
  4392 				{
  4393 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4394 				StopTest(aError, EFail);
  4395 				}
  4396 			break;
  4397 			}
  4398 		case EStatePause:
  4399 			{
  4400 			if(aDevSoundEvent == EEventTimerComplete)
  4401 				{
  4402 				TMMFCapabilities capabilities;
  4403 				INFO_PRINTF1(_L("Calling CMMFDevSound::Capabilities"));
  4404 				capabilities = iMMFDevSound->Capabilities();
  4405 				PrintSupportedCapabilities(capabilities.iRate, capabilities.iChannels);
  4406 				if(capabilities.iRate == iExCapRate)
  4407 					{
  4408 					INFO_PRINTF2(_L("The total of possible sample rate values is 0x%08x"), capabilities.iRate);
  4409 					if(capabilities.iChannels == iExCapChannels)
  4410 						{
  4411 						INFO_PRINTF2(_L("The total of possible channel values is 0x%08x"),capabilities.iChannels );
  4412 						StopTest();
  4413 						}
  4414 					else
  4415 						{
  4416 						ERR_PRINTF2(_L("The total of possible channel values failed with 0x%08x"), capabilities.iChannels );
  4417 						ERR_PRINTF2(_L("Expected value = %d"), iExCapChannels);
  4418 						StopTest(aError, EFail);
  4419 						}
  4420 					}
  4421 				else
  4422 					{
  4423 					ERR_PRINTF2(_L("The total of possible sample rate values failed with 0x%08x"), capabilities.iRate);
  4424 					ERR_PRINTF2(_L("Expected value = %d"), iExCapRate);
  4425 					StopTest(aError, EFail);
  4426 					}
  4427 				}
  4428 			else
  4429 				{
  4430 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4431 				StopTest(aError, EFail);
  4432 				}
  4433 			break;
  4434 			}
  4435 		default:
  4436 			{
  4437 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  4438 			StopTest(aError, EFail);
  4439 			}
  4440 		}
  4441 	}
  4442 
  4443 void RA3FDevSoundToneQueryCapsWhilePausePlayingTest::DoTimerCallback()
  4444 	{
  4445 	INFO_PRINTF1(_L("TimerEvent called"));
  4446 	if(!iTimeToEnterPauseElapsed)
  4447 		{
  4448 		iTimeToEnterPauseElapsed = ETrue;
  4449 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  4450 		Fsm(EEventTimerComplete, KErrNone);
  4451 		iTimeToEnterPauseElapsed = ETrue;
  4452 		}
  4453 	else
  4454 		{
  4455 		iTimer->Cancel();
  4456 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  4457 		Fsm(EEventTimerComplete, KErrNone);
  4458 		}
  4459 	}
  4460 
  4461 void RA3FDevSoundToneQueryCapsWhilePausePlayingTest::ToneFinished(TInt aError)
  4462 	{
  4463 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  4464 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to be paused then stopped"));
  4465 	StopTest(aError, EFail);
  4466 	}
  4467 
  4468 
  4469 /*
  4470  *========================================================================================================
  4471  * MM-A3F-DEVSOUND-CHRTZ-TONE-0033
  4472  */
  4473 RA3FDevSoundToneConfigWhilePausePlayingTest::RA3FDevSoundToneConfigWhilePausePlayingTest(const TDesC& aTestName)
  4474 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  4475 		iFrequencyTone1(0), iTimeToEnterPauseElapsed(EFalse),
  4476 		iExCapRate(0), iExCapChannels(0)
  4477 	{
  4478 	}
  4479 
  4480 RA3FDevSoundToneConfigWhilePausePlayingTest* RA3FDevSoundToneConfigWhilePausePlayingTest::NewL(const TDesC& aTestName)
  4481 	{
  4482 	RA3FDevSoundToneConfigWhilePausePlayingTest * self = new(ELeave)RA3FDevSoundToneConfigWhilePausePlayingTest(aTestName);
  4483 	return self;
  4484 	}
  4485 
  4486 void RA3FDevSoundToneConfigWhilePausePlayingTest::DoKickoffTestL()
  4487 	{
  4488 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  4489 		{
  4490 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  4491 		StopTest(KErrNotFound);
  4492 		return;
  4493 		}
  4494 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  4495 		{
  4496 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  4497 		StopTest(KErrNotFound);
  4498 		return;
  4499 		}
  4500 	if (!GetIntFromConfig(iTestStepName, KExCapRate, iExCapRate))
  4501 			{
  4502 			ERR_PRINTF2(KMsgErrorGetParameter, &KExCapRate);
  4503 			StopTest(KErrNotFound);
  4504 			return;
  4505 			}
  4506 	if (!GetIntFromConfig(iTestStepName, KExCapChannels, iExCapChannels))
  4507 		{
  4508 		ERR_PRINTF2(KMsgErrorGetParameter, &KExCapChannels);
  4509 		StopTest(KErrNotFound);
  4510 		return;
  4511 		}
  4512 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  4513 	}
  4514 
  4515 void RA3FDevSoundToneConfigWhilePausePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  4516 	{
  4517 	switch (iDevSoundState)
  4518 		{
  4519 		case EStateCreated:
  4520 			{
  4521 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneConfigWhilePausePlayingTest"), EFsmIncorrectErrorPassed));
  4522 			if (aDevSoundEvent == EEventInitialize)
  4523 				{
  4524 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  4525 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  4526 				if (err != KErrNone)
  4527 					{
  4528 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  4529 					StopTest(err);
  4530 					break;
  4531 					}
  4532 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  4533 				iDevSoundState = EStateInitializing;
  4534 				}
  4535 			else
  4536 				{
  4537 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  4538 				StopTest(aError, EFail);
  4539 				}
  4540 			break;
  4541 			}
  4542 		case EStateInitializing:
  4543 			{
  4544 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  4545 				{
  4546 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  4547 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  4548 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  4549 				if (err != KErrNone)
  4550 					{
  4551 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  4552 					StopTest(err);
  4553 					break;
  4554 					}
  4555 				StartTimer(KMicroSecsTwoSec);
  4556 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  4557 				iDevSoundState = EStatePlaying;
  4558 				}
  4559 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  4560 				{
  4561 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  4562 				StopTest(aError);
  4563 				}
  4564 			else
  4565 				{
  4566 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4567 				StopTest(aError, EFail);
  4568 				}
  4569 			break;
  4570 			}
  4571 		case EStatePlaying:
  4572 			{
  4573 			if(aDevSoundEvent == EEventTimerComplete)
  4574 				{
  4575 				INFO_PRINTF1(_L("Calling CMMFDevSound::Pause"));
  4576 				iMMFDevSound->Pause();
  4577 				INFO_PRINTF1(_L("DevSound State: EStatePause"));
  4578 				iDevSoundState = EStatePause;
  4579 				}
  4580 			else
  4581 				{
  4582 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4583 				StopTest(aError, EFail);
  4584 				}
  4585 			break;
  4586 			}
  4587 		case EStatePause:
  4588 			{
  4589 			if(aDevSoundEvent == EEventTimerComplete)
  4590 				{
  4591 				TMMFCapabilities capabilitiesGet;
  4592 				TBuf<KMaxSampleRateStringLength> stringSampleRateGet;
  4593 				TBuf<KMaxChannelsStringLength> stringChannelsGet;
  4594 				TBuf<KMaxSampleRateStringLength> stringSampleRateExpected;
  4595 				TBuf<KMaxChannelsStringLength> stringChannelsExpected;
  4596 				INFO_PRINTF1(_L("Calling CMMFDevSound::Config while playing"));
  4597 				capabilitiesGet=iMMFDevSound->Config();
  4598 				SampleRateFromTUintToString (capabilitiesGet.iRate, stringSampleRateGet);
  4599 				ChannelsFromTUintToString (capabilitiesGet.iChannels, stringChannelsGet);
  4600 				SampleRateFromTIntToTMMFSampleRate (iExCapRate, iExSampleRate);
  4601 				SampleRateFromTUintToString (iExSampleRate, stringSampleRateExpected);
  4602 				ChannelsFromTUintToString (iExCapChannels, stringChannelsExpected);
  4603 				if (stringSampleRateExpected.Compare(stringSampleRateGet) == 0)
  4604 					{
  4605 					INFO_PRINTF2(_L("Sample rate value match default as expected with %S"), &stringSampleRateGet);
  4606 					if (stringChannelsExpected.Compare(stringChannelsGet) == 0)
  4607 						{
  4608 						INFO_PRINTF2(_L("Channel mode value match default as expected with %S"), &stringChannelsGet);
  4609 						StopTest();
  4610 						}
  4611 					else
  4612 						{
  4613 						INFO_PRINTF2(_L("Channel mode value failed with %S"), &stringChannelsGet);
  4614 						ERR_PRINTF2(_L("Expected channel mode %S"), &stringChannelsExpected);
  4615 						StopTest(aError, EFail);
  4616 						}
  4617 					}
  4618 				else
  4619 					{
  4620 					ERR_PRINTF2(_L("Sample rate value failed with %S"), &stringSampleRateGet);
  4621 					ERR_PRINTF2(_L("Expected sample rate %S"), &stringSampleRateExpected);
  4622 					StopTest(aError, EFail);
  4623 					}
  4624 				}
  4625 			else
  4626 				{
  4627 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4628 				StopTest(aError, EFail);
  4629 				}
  4630 			break;
  4631 			}
  4632 		default:
  4633 			{
  4634 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  4635 			StopTest(aError, EFail);
  4636 			}
  4637 		}
  4638 	}
  4639 
  4640 void RA3FDevSoundToneConfigWhilePausePlayingTest::DoTimerCallback()
  4641 	{
  4642 	INFO_PRINTF1(_L("TimerEvent called"));
  4643 	if(!iTimeToEnterPauseElapsed)
  4644 		{
  4645 		iTimeToEnterPauseElapsed = ETrue;
  4646 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  4647 		Fsm(EEventTimerComplete, KErrNone);
  4648 		iTimeToEnterPauseElapsed = ETrue;
  4649 		}
  4650 	else
  4651 		{
  4652 		iTimer->Cancel();
  4653 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  4654 		Fsm(EEventTimerComplete, KErrNone);
  4655 		}
  4656 	}
  4657 
  4658 void RA3FDevSoundToneConfigWhilePausePlayingTest::ToneFinished(TInt aError)
  4659 	{
  4660 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  4661 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to be paused then stopped"));
  4662 	StopTest(aError, EFail);
  4663 	}
  4664 
  4665 
  4666 /*
  4667  *========================================================================================================
  4668  * MM-A3F-DEVSOUND-CHRTZ-TONE-0034
  4669  */
  4670 RA3FDevSoundToneMaxVolumeWhilePausePlayingTest::RA3FDevSoundToneMaxVolumeWhilePausePlayingTest(const TDesC& aTestName)
  4671 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  4672 		iFrequencyTone1(0), iExVolume(0),
  4673 		iTimeToEnterPauseElapsed(EFalse)
  4674 	{
  4675 	}
  4676 
  4677 RA3FDevSoundToneMaxVolumeWhilePausePlayingTest* RA3FDevSoundToneMaxVolumeWhilePausePlayingTest::NewL(const TDesC& aTestName)
  4678 	{
  4679 	RA3FDevSoundToneMaxVolumeWhilePausePlayingTest * self = new(ELeave)RA3FDevSoundToneMaxVolumeWhilePausePlayingTest(aTestName);
  4680 	return self;
  4681 	}
  4682 
  4683 void RA3FDevSoundToneMaxVolumeWhilePausePlayingTest::DoKickoffTestL()
  4684 	{
  4685 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  4686 		{
  4687 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  4688 		StopTest(KErrNotFound);
  4689 		return;
  4690 		}
  4691 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  4692 		{
  4693 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  4694 		StopTest(KErrNotFound);
  4695 		return;
  4696 		}
  4697 	if (!GetIntFromConfig(iTestStepName, KExVolume, iExVolume))
  4698 		{
  4699 		ERR_PRINTF2(KMsgErrorGetParameter, &KExVolume);
  4700 		StopTest(KErrNotFound);
  4701 		return;
  4702 		}
  4703 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  4704 	}
  4705 
  4706 void RA3FDevSoundToneMaxVolumeWhilePausePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  4707 	{
  4708 	switch (iDevSoundState)
  4709 		{
  4710 		case EStateCreated:
  4711 			{
  4712 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneMaxVolumeWhilePausePlayingTest"), EFsmIncorrectErrorPassed));
  4713 			if (aDevSoundEvent == EEventInitialize)
  4714 				{
  4715 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  4716 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  4717 				if (err != KErrNone)
  4718 					{
  4719 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  4720 					StopTest(err);
  4721 					break;
  4722 					}
  4723 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  4724 				iDevSoundState = EStateInitializing;
  4725 				}
  4726 			else
  4727 				{
  4728 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  4729 				StopTest(aError, EFail);
  4730 				}
  4731 			break;
  4732 			}
  4733 		case EStateInitializing:
  4734 			{
  4735 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  4736 				{
  4737 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  4738 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  4739 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  4740 				if (err != KErrNone)
  4741 					{
  4742 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  4743 					StopTest(err);
  4744 					break;
  4745 					}
  4746 				StartTimer(KMicroSecsTwoSec);
  4747 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  4748 				iDevSoundState = EStatePlaying;
  4749 				}
  4750 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  4751 				{
  4752 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  4753 				StopTest(aError);
  4754 				}
  4755 			else
  4756 				{
  4757 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4758 				StopTest(aError, EFail);
  4759 				}
  4760 			break;
  4761 			}
  4762 		case EStatePlaying:
  4763 			{
  4764 			if(aDevSoundEvent == EEventTimerComplete)
  4765 				{
  4766 				INFO_PRINTF1(_L("Calling CMMFDevSound::Pause"));
  4767 				iMMFDevSound->Pause();
  4768 				INFO_PRINTF1(_L("DevSound State: EStatePause"));
  4769 				iDevSoundState = EStatePause;
  4770 				}
  4771 			else
  4772 				{
  4773 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4774 				StopTest(aError, EFail);
  4775 				}
  4776 			break;
  4777 			}
  4778 		case EStatePause:
  4779 			{
  4780 			if(aDevSoundEvent == EEventTimerComplete)
  4781 				{
  4782 				INFO_PRINTF1(_L("Calling CMMFDevSound::MaxVolume"));
  4783 				TInt maxVolumeGet = iMMFDevSound->MaxVolume();
  4784 				if (maxVolumeGet == iExVolume)
  4785 					{
  4786 					INFO_PRINTF2(_L("The max device supported volume is %d."), maxVolumeGet);
  4787 					StopTest();
  4788 					}
  4789 				else
  4790 					{
  4791 					INFO_PRINTF2(_L("The max device supported volume failed with %d."), maxVolumeGet);
  4792 					ERR_PRINTF2(_L("Expected value = %d."), iExVolume);
  4793 					StopTest(aError, EFail);
  4794 					}
  4795 				}
  4796 			else
  4797 				{
  4798 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4799 				StopTest(aError, EFail);
  4800 				}
  4801 			break;
  4802 			}
  4803 		default:
  4804 			{
  4805 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  4806 			StopTest(aError, EFail);
  4807 			}
  4808 		}
  4809 	}
  4810 
  4811 void RA3FDevSoundToneMaxVolumeWhilePausePlayingTest::DoTimerCallback()
  4812 	{
  4813 	INFO_PRINTF1(_L("TimerEvent called"));
  4814 	if(!iTimeToEnterPauseElapsed)
  4815 		{
  4816 		iTimeToEnterPauseElapsed = ETrue;
  4817 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  4818 		Fsm(EEventTimerComplete, KErrNone);
  4819 		iTimeToEnterPauseElapsed = ETrue;
  4820 		}
  4821 	else
  4822 		{
  4823 		iTimer->Cancel();
  4824 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  4825 		Fsm(EEventTimerComplete, KErrNone);
  4826 		}
  4827 	}
  4828 
  4829 void RA3FDevSoundToneMaxVolumeWhilePausePlayingTest::ToneFinished(TInt aError)
  4830 	{
  4831 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  4832 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to be paused then stopped"));
  4833 	StopTest(aError, EFail);
  4834 	}
  4835 
  4836 /*
  4837  *========================================================================================================
  4838  * MM-A3F-DEVSOUND-CHRTZ-TONE-0035
  4839  */
  4840 RA3FDevSoundToneVolumeWhilePausePlayingTest::RA3FDevSoundToneVolumeWhilePausePlayingTest(const TDesC& aTestName)
  4841 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  4842 		iFrequencyTone1(0), iExVolume(0),
  4843 		iTimeToEnterPauseElapsed(EFalse)
  4844 	{
  4845 	}
  4846 
  4847 RA3FDevSoundToneVolumeWhilePausePlayingTest* RA3FDevSoundToneVolumeWhilePausePlayingTest::NewL(const TDesC& aTestName)
  4848 	{
  4849 	RA3FDevSoundToneVolumeWhilePausePlayingTest * self = new(ELeave)RA3FDevSoundToneVolumeWhilePausePlayingTest(aTestName);
  4850 	return self;
  4851 	}
  4852 
  4853 void RA3FDevSoundToneVolumeWhilePausePlayingTest::DoKickoffTestL()
  4854 	{
  4855 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  4856 		{
  4857 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  4858 		StopTest(KErrNotFound);
  4859 		return;
  4860 		}
  4861 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  4862 		{
  4863 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  4864 		StopTest(KErrNotFound);
  4865 		return;
  4866 		}
  4867 	if (!GetIntFromConfig(iTestStepName, KExVolume, iExVolume))
  4868 		{
  4869 		ERR_PRINTF2(KMsgErrorGetParameter, &KExVolume);
  4870 		StopTest(KErrNotFound);
  4871 		return;
  4872 		}
  4873 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  4874 	}
  4875 
  4876 void RA3FDevSoundToneVolumeWhilePausePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  4877 	{
  4878 	switch (iDevSoundState)
  4879 		{
  4880 		case EStateCreated:
  4881 			{
  4882 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneVolumeWhilePausePlayingTest"), EFsmIncorrectErrorPassed));
  4883 			if (aDevSoundEvent == EEventInitialize)
  4884 				{
  4885 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  4886 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  4887 				if (err != KErrNone)
  4888 					{
  4889 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  4890 					StopTest(err);
  4891 					break;
  4892 					}
  4893 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  4894 				iDevSoundState = EStateInitializing;
  4895 				}
  4896 			else
  4897 				{
  4898 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  4899 				StopTest(aError, EFail);
  4900 				}
  4901 			break;
  4902 			}
  4903 		case EStateInitializing:
  4904 			{
  4905 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  4906 				{
  4907 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  4908 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  4909 				if (err != KErrNone)
  4910 					{
  4911 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  4912 					StopTest(err);
  4913 					break;
  4914 					}
  4915 				StartTimer(KMicroSecsTwoSec);
  4916 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  4917 				iDevSoundState = EStatePlaying;
  4918 				}
  4919 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  4920 				{
  4921 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  4922 				StopTest(aError);
  4923 				}
  4924 			else
  4925 				{
  4926 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4927 				StopTest(aError, EFail);
  4928 				}
  4929 			break;
  4930 			}
  4931 		case EStatePlaying:
  4932 			{
  4933 			if(aDevSoundEvent == EEventTimerComplete)
  4934 				{
  4935 				INFO_PRINTF1(_L("Calling CMMFDevSound::Pause"));
  4936 				iMMFDevSound->Pause();
  4937 				INFO_PRINTF1(_L("DevSound State: EStatePause"));
  4938 				iDevSoundState = EStatePause;
  4939 				}
  4940 			else
  4941 				{
  4942 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4943 				StopTest(aError, EFail);
  4944 				}
  4945 			break;
  4946 			}
  4947 		case EStatePause:
  4948 			{
  4949 			if(aDevSoundEvent == EEventTimerComplete)
  4950 				{
  4951 				INFO_PRINTF1(_L("Calling CMMFDevSound::Volume"));
  4952 				TInt maxVolumeGet = iMMFDevSound->Volume();
  4953 				if (maxVolumeGet == iExVolume)
  4954 					{
  4955 					INFO_PRINTF2(_L("The device default supported volume value is %d."), maxVolumeGet);
  4956 					StopTest();
  4957 					}
  4958 				else
  4959 					{
  4960 					INFO_PRINTF2(_L("The device default supported volume value failed with %d."), maxVolumeGet);
  4961 					ERR_PRINTF2(_L("Expected value = %d."), iExVolume);
  4962 					StopTest(aError, EFail);
  4963 					}
  4964 				}
  4965 			else
  4966 				{
  4967 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  4968 				StopTest(aError, EFail);
  4969 				}
  4970 			break;
  4971 			}
  4972 		default:
  4973 			{
  4974 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  4975 			StopTest(aError, EFail);
  4976 			}
  4977 		}
  4978 	}
  4979 
  4980 void RA3FDevSoundToneVolumeWhilePausePlayingTest::DoTimerCallback()
  4981 	{
  4982 	INFO_PRINTF1(_L("TimerEvent called"));
  4983 	if(!iTimeToEnterPauseElapsed)
  4984 		{
  4985 		iTimeToEnterPauseElapsed = ETrue;
  4986 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  4987 		Fsm(EEventTimerComplete, KErrNone);
  4988 		iTimeToEnterPauseElapsed = ETrue;
  4989 		}
  4990 	else
  4991 		{
  4992 		iTimer->Cancel();
  4993 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  4994 		Fsm(EEventTimerComplete, KErrNone);
  4995 		}
  4996 	}
  4997 
  4998 void RA3FDevSoundToneVolumeWhilePausePlayingTest::ToneFinished(TInt aError)
  4999 	{
  5000 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  5001 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to be paused then stopped"));
  5002 	StopTest(aError, EFail);
  5003 	}
  5004 
  5005 /*
  5006  *========================================================================================================
  5007  * MM-A3F-DEVSOUND-CHRTZ-TONE-0036
  5008  */
  5009 RA3FDevSoundTonePlayToneOnceTest::RA3FDevSoundTonePlayToneOnceTest(const TDesC& aTestName)
  5010 	:	RA3FDevSoundTestBase(aTestName),
  5011 		iDuration(0), iFrequencyTone1(0)
  5012 	{
  5013 	}
  5014 
  5015 RA3FDevSoundTonePlayToneOnceTest* RA3FDevSoundTonePlayToneOnceTest::NewL(const TDesC& aTestName)
  5016 	{
  5017 	RA3FDevSoundTonePlayToneOnceTest * self = new(ELeave)RA3FDevSoundTonePlayToneOnceTest(aTestName);
  5018 	return self;
  5019 	}
  5020 
  5021 void RA3FDevSoundTonePlayToneOnceTest::DoKickoffTestL()
  5022 	{
  5023 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  5024 		{
  5025 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  5026 		StopTest(KErrNotFound);
  5027 		return;
  5028 		}
  5029 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  5030 		{
  5031 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  5032 		StopTest(KErrNotFound);
  5033 		return;
  5034 		}
  5035 	}
  5036 
  5037 void RA3FDevSoundTonePlayToneOnceTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  5038 	{
  5039 	switch (iDevSoundState)
  5040 		{
  5041 		case EStateCreated:
  5042 			{
  5043 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneOnceTest"), EFsmIncorrectErrorPassed));
  5044 			if (aDevSoundEvent == EEventInitialize)
  5045 				{
  5046 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  5047 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  5048 				if (err != KErrNone)
  5049 					{
  5050 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  5051 					StopTest(err);
  5052 					break;
  5053 					}
  5054 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  5055 				iDevSoundState = EStateInitializing;
  5056 				}
  5057 			else
  5058 				{
  5059 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  5060 				StopTest(aError, EFail);
  5061 				}
  5062 			break;
  5063 			}
  5064 		case EStateInitializing:
  5065 			{
  5066 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  5067 				{
  5068 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  5069 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz  during %d secs "), iFrequencyTone1, iDuration);
  5070 				iStartTime.HomeTime();
  5071 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  5072 				if (err != KErrNone)
  5073 					{
  5074 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL failed with error : %d!"), err);
  5075 					StopTest(err);
  5076 					}
  5077 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  5078 				iDevSoundState = EStatePlaying;
  5079 				}
  5080 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  5081 				{
  5082 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  5083 				StopTest(aError);
  5084 				}
  5085 			else
  5086 				{
  5087 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  5088 				StopTest(aError, EFail);
  5089 				}
  5090 			break;
  5091 			}
  5092 		default:
  5093 			{
  5094 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  5095 			StopTest(aError, EFail);
  5096 			}
  5097 		}
  5098 	}
  5099 
  5100 void RA3FDevSoundTonePlayToneOnceTest::ToneFinished(TInt aError)
  5101 	{
  5102 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  5103 	if (aError == KErrUnderflow)
  5104 		{
  5105 		iEndTime.HomeTime();
  5106 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  5107 		TInt totalExpectedReproductionTime = iDuration * KMicroSecsInOneSec;
  5108 		if(iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
  5109 			{
  5110 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  5111 			StopTest();
  5112 			}
  5113 		else
  5114 			{
  5115 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
  5116 			StopTest(KErrNone, EFail);
  5117 			}
  5118 		}
  5119 	else
  5120 		{
  5121 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  5122 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  5123 		StopTest(aError, EFail);
  5124 		}
  5125 	}
  5126 
  5127 /*
  5128  *========================================================================================================
  5129  * MM-A3F-DEVSOUND-CHRTZ-TONE-0037
  5130  */
  5131 RA3FDevSoundTonePlayDualToneTest::RA3FDevSoundTonePlayDualToneTest(const TDesC& aTestName)
  5132 	:	RA3FDevSoundTestBase(aTestName),
  5133 		iDuration(0), iFrequencyTone1(0),
  5134 		iFrequencyTone2(0)
  5135 	{
  5136 	}
  5137 RA3FDevSoundTonePlayDualToneTest* RA3FDevSoundTonePlayDualToneTest::NewL(const TDesC& aTestName)
  5138 	{
  5139 	RA3FDevSoundTonePlayDualToneTest * self = new(ELeave)RA3FDevSoundTonePlayDualToneTest(aTestName);
  5140 	return self;
  5141 	}
  5142 void RA3FDevSoundTonePlayDualToneTest::DoKickoffTestL()
  5143 	{
  5144 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  5145 		{
  5146 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  5147 		StopTest(KErrNotFound);
  5148 		return;
  5149 		}
  5150 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  5151 		{
  5152 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  5153 		StopTest(KErrNotFound);
  5154 		return;
  5155 		}
  5156 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone2, iFrequencyTone2))
  5157 		{
  5158 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone2);
  5159 		StopTest(KErrNotFound);
  5160 		return;
  5161 		}
  5162 	}
  5163 
  5164 void RA3FDevSoundTonePlayDualToneTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  5165 	{
  5166 	switch (iDevSoundState)
  5167 		{
  5168 		case EStateCreated:
  5169 			{
  5170 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayDualToneTest"), EFsmIncorrectErrorPassed));
  5171 			if (aDevSoundEvent == EEventInitialize)
  5172 				{
  5173 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  5174 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  5175 				if (err != KErrNone)
  5176 					{
  5177 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  5178 					StopTest(err);
  5179 					break;
  5180 					}
  5181 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  5182 				iDevSoundState = EStateInitializing;
  5183 				}
  5184 			else
  5185 				{
  5186 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  5187 				StopTest(aError, EFail);
  5188 				}
  5189 			break;
  5190 			}
  5191 		case EStateInitializing:
  5192 			{
  5193 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  5194 				{
  5195 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  5196 				iStartTime.HomeTime();
  5197 				INFO_PRINTF4(_L("Calling CMMFDevSound::PlayDualToneL using %d Hz %d Hz during %d secs "), iFrequencyTone1, iFrequencyTone2, iDuration);
  5198 				TRAPD(err, iMMFDevSound->PlayDualToneL(iFrequencyTone1, iFrequencyTone2, iDuration*KMicroSecsInOneSec));
  5199 				if (err != KErrNone)
  5200 					{
  5201 					ERR_PRINTF2(_L("CMMFDevSound::PlayDualToneL left with error : %d!"),  err);
  5202 					StopTest(err);
  5203 					break;
  5204 					}
  5205 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  5206 				iDevSoundState = EStatePlaying;
  5207 				}
  5208 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  5209 				{
  5210 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  5211 				StopTest(aError);
  5212 				}
  5213 			else
  5214 				{
  5215 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  5216 				StopTest(aError, EFail);
  5217 				}
  5218 			break;
  5219 			}
  5220 		default:
  5221 			{
  5222 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  5223 			StopTest(aError, EFail);
  5224 			}
  5225 		}
  5226 	}
  5227 
  5228 void RA3FDevSoundTonePlayDualToneTest::ToneFinished(TInt aError)
  5229 	{
  5230 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  5231 	if (aError == KErrUnderflow)
  5232 		{
  5233 		iEndTime.HomeTime();
  5234 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  5235 		TInt totalExpectedReproductionTime = iDuration * KMicroSecsInOneSec;
  5236 		if(iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
  5237 			{
  5238 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  5239 			StopTest();
  5240 			}
  5241 		else
  5242 			{
  5243 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
  5244 			StopTest(KErrNone, EFail);
  5245 			}
  5246 		}
  5247 	else
  5248 		{
  5249 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  5250 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  5251 		StopTest(aError, EFail);
  5252 		}
  5253 	}
  5254 
  5255 /*
  5256  *========================================================================================================
  5257  * MM-A3F-DEVSOUND-CHRTZ-TONE-0038
  5258  */
  5259 RA3FDevSoundTonePlayDTMFToneTest::RA3FDevSoundTonePlayDTMFToneTest(const TDesC& aTestName)
  5260 	:	RA3FDevSoundTestBase(aTestName),iDTMFString(KNullDesC),
  5261 		iDTMFPauses(0), iDTMFTones(0)
  5262 
  5263 	{
  5264 	}
  5265 
  5266 RA3FDevSoundTonePlayDTMFToneTest* RA3FDevSoundTonePlayDTMFToneTest::NewL(const TDesC& aTestName)
  5267 	{
  5268 	RA3FDevSoundTonePlayDTMFToneTest * self = new(ELeave)RA3FDevSoundTonePlayDTMFToneTest(aTestName);
  5269 	return self;
  5270 	}
  5271 
  5272 void RA3FDevSoundTonePlayDTMFToneTest::DoKickoffTestL()
  5273 	{
  5274 	TPtrC DTMF;
  5275 	if (!GetStringFromConfig(iTestStepName, KDTMFString, DTMF))
  5276 		{
  5277 		ERR_PRINTF2(KMsgErrorGetParameter, &KDTMFString);
  5278 		StopTest(KErrNotFound);
  5279 		return;
  5280 		}
  5281 	iDTMFString.Copy(DTMF);
  5282 	for(TInt i =0 ; i< iDTMFString.Length() ; i++)
  5283 		{
  5284 		if (iDTMFString[i] == ',')
  5285 			{
  5286 			iDTMFPauses++;
  5287 			}
  5288 		else
  5289 			{
  5290 			iDTMFTones++;
  5291 			}
  5292 		}
  5293 	}
  5294 
  5295 void RA3FDevSoundTonePlayDTMFToneTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  5296 	{
  5297 	switch (iDevSoundState)
  5298 		{
  5299 		case EStateCreated:
  5300 			{
  5301 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayDTMFToneTest"), EFsmIncorrectErrorPassed));
  5302 			if (aDevSoundEvent == EEventInitialize)
  5303 				{
  5304 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  5305 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  5306 				if (err != KErrNone)
  5307 					{
  5308 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"),  err);
  5309 					StopTest(err);
  5310 					break;
  5311 					}
  5312 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  5313 				iDevSoundState = EStateInitializing;
  5314 				}
  5315 			else
  5316 				{
  5317 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  5318 				StopTest(aError,  EFail);
  5319 				}
  5320 			break;
  5321 			}
  5322 		case EStateInitializing:
  5323 			{
  5324 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  5325 				{
  5326 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  5327 				iStartTime.HomeTime();
  5328 				INFO_PRINTF2(_L("Calling CMMFDevSound::PlayDTMFStringL %S"), &iDTMFString);
  5329 				TRAPD(err, iMMFDevSound->PlayDTMFStringL(iDTMFString));
  5330 				if (err != KErrNone)
  5331 					{
  5332 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error : %d!"), err);
  5333 					StopTest(err);
  5334 					break;
  5335 					}
  5336 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  5337 				iDevSoundState = EStatePlaying;
  5338 				}
  5339 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  5340 				{
  5341 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  5342 				StopTest(aError);
  5343 				}
  5344 			else
  5345 				{
  5346 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  5347 				StopTest(aError, EFail);
  5348 				}
  5349 			break;
  5350 			}
  5351 		default:
  5352 			{
  5353 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  5354 			StopTest(aError, EFail);
  5355 			}
  5356 		}
  5357 	}
  5358 
  5359 void RA3FDevSoundTonePlayDTMFToneTest::ToneFinished(TInt aError)
  5360 	{
  5361 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  5362 	if (aError == KErrUnderflow)
  5363 		{
  5364 		iEndTime.HomeTime();
  5365 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  5366 		TInt defaultToneOn = 250000;
  5367 		TInt defaultToneOff = 50000;
  5368 		TInt defaultPauseLength = 250000;
  5369 		TInt totalExpectedReproductionTime = defaultToneOn*iDTMFTones + defaultToneOff * iDTMFTones + iDTMFPauses * defaultPauseLength;
  5370 		if (iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
  5371 			{
  5372 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  5373 			StopTest();
  5374 			}
  5375 		else
  5376 			{
  5377 			ERR_PRINTF2(_L("Calling CMMFDevSound::PlayDTMFStringL failed with %Ld"), iPlayToneTime.Int64());
  5378 			ERR_PRINTF2(_L("Expected time %d"), totalExpectedReproductionTime);
  5379 			StopTest(KErrNone, EFail);
  5380 			}
  5381 		}
  5382 	else
  5383 		{
  5384 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  5385 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  5386 		StopTest(aError, EFail);
  5387 		}
  5388 	}
  5389 
  5390 /*
  5391  *========================================================================================================
  5392  * MM-A3F-DEVSOUND-CHRTZ-TONE-0039
  5393  */
  5394 RA3FDevSoundTonePlayToneSequenceTest::RA3FDevSoundTonePlayToneSequenceTest(const TDesC& aTestName)
  5395 	:	RA3FDevSoundTestBase(aTestName)
  5396 	{
  5397 	}
  5398 
  5399 RA3FDevSoundTonePlayToneSequenceTest* RA3FDevSoundTonePlayToneSequenceTest::NewL(const TDesC& aTestName)
  5400 	{
  5401 	RA3FDevSoundTonePlayToneSequenceTest * self = new(ELeave)RA3FDevSoundTonePlayToneSequenceTest(aTestName);
  5402 	return self;
  5403 	}
  5404 
  5405 void RA3FDevSoundTonePlayToneSequenceTest::DoKickoffTestL()
  5406 	{
  5407 	}
  5408 
  5409 void RA3FDevSoundTonePlayToneSequenceTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  5410 	{
  5411 	switch(iDevSoundState)
  5412 		{
  5413 		case EStateCreated:
  5414 			{
  5415 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneSequenceTest"), EFsmIncorrectErrorPassed));
  5416 			if (aDevSoundEvent == EEventInitialize)
  5417 				{
  5418 				INFO_PRINTF1(_L("Calling MMFDevSound::InitializeL"));
  5419 				TRAPD(err, iMMFDevSound->InitializeL(*this,  EMMFStateTonePlaying));
  5420 				if (err != KErrNone)
  5421 					{
  5422 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  5423 					StopTest(err);
  5424 					break;
  5425 					}
  5426 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  5427 				iDevSoundState = EStateInitializing;
  5428 				}
  5429 			else
  5430 				{
  5431 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  5432 				StopTest(aError, EFail);
  5433 				}
  5434 			break;
  5435 			}
  5436 		case EStateInitializing:
  5437 			{
  5438 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  5439 				{
  5440 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  5441 				TUint8* tablePointer = const_cast<TUint8*>(&(KFixedSequenceTestSequenceDataX[0]));
  5442 				TPtrC8 KFixedSequenceData(tablePointer, sizeof(KFixedSequenceTestSequenceDataX));
  5443 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneSequenceL"));
  5444 				TRAPD(err, iMMFDevSound->PlayToneSequenceL(KFixedSequenceData));
  5445 				if (err != KErrNone)
  5446 					{
  5447 					ERR_PRINTF2(_L("Play tone sequence failed with error = %d!"), err);
  5448 					StopTest(err);
  5449 					break;
  5450 					}
  5451 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  5452 				iDevSoundState = EStatePlaying;
  5453 				}
  5454 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  5455 				{
  5456 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  5457 				StopTest(aError);
  5458 				}
  5459 			else
  5460 				{
  5461 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  5462 				StopTest(aError, EFail);
  5463 				}
  5464 			break;
  5465 			}
  5466 		default:
  5467 			{
  5468 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  5469 			StopTest(aError, EFail);
  5470 			}
  5471 		}
  5472 	}
  5473 
  5474 /*
  5475  *========================================================================================================
  5476  * MM-A3F-DEVSOUND-CHRTZ-TONE-0040
  5477  */
  5478 RA3FDevSoundToneNewToneRequestWhilePlayingTest::RA3FDevSoundToneNewToneRequestWhilePlayingTest(const TDesC& aTestName)
  5479 	:	RA3FDevSoundTestBase(aTestName),
  5480 		iDuration(0), iFrequencyTone1(0)
  5481 	{
  5482 	}
  5483 
  5484 RA3FDevSoundToneNewToneRequestWhilePlayingTest* RA3FDevSoundToneNewToneRequestWhilePlayingTest::NewL(const TDesC& aTestName)
  5485 	{
  5486 	RA3FDevSoundToneNewToneRequestWhilePlayingTest * self = new(ELeave)RA3FDevSoundToneNewToneRequestWhilePlayingTest(aTestName);
  5487 	return self;
  5488 	}
  5489 
  5490 void RA3FDevSoundToneNewToneRequestWhilePlayingTest::DoKickoffTestL()
  5491 	{
  5492 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  5493 		{
  5494 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  5495 		StopTest(KErrNotFound);
  5496 		return;
  5497 		}
  5498 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  5499 		{
  5500 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  5501 		StopTest(KErrNotFound);
  5502 		return;
  5503 		}
  5504 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  5505 	}
  5506 
  5507 void RA3FDevSoundToneNewToneRequestWhilePlayingTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  5508 	{
  5509 	switch (iDevSoundState)
  5510 		{
  5511 		case EStateCreated:
  5512 			{
  5513 			if (aDevSoundEvent == EEventInitialize)
  5514 				{
  5515 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneNewToneRequestWhilePlayingTest"), EFsmIncorrectErrorPassed));
  5516 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  5517 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  5518 				if (err != KErrNone)
  5519 					{
  5520 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  5521 					StopTest(err);
  5522 					break;
  5523 					}
  5524 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  5525 				iDevSoundState = EStateInitializing;
  5526 				}
  5527 			else
  5528 				{
  5529 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  5530 				StopTest(aError, EFail);
  5531 				}
  5532 			break;
  5533 			}
  5534 		case EStateInitializing:
  5535 			{
  5536 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  5537 				{
  5538 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  5539 				iStartTime.HomeTime();
  5540 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  5541 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  5542 				if (err != KErrNone)
  5543 					{
  5544 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  5545 					StopTest(err);
  5546 					break;
  5547 					}
  5548 				StartTimer(KMicroSecsTwoSec);
  5549 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  5550 				iDevSoundState = EStatePlaying;
  5551 				}
  5552 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  5553 				{
  5554 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  5555 				StopTest(aError);
  5556 				}
  5557 			else
  5558 				{
  5559 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  5560 				StopTest(aError, EFail);
  5561 				}
  5562 			break;
  5563 			}
  5564 		case EStatePlaying:
  5565 			{
  5566 			if(aDevSoundEvent == EEventTimerComplete)
  5567 				{
  5568 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  5569 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  5570 				if (err == KErrNone)
  5571 					{
  5572 					INFO_PRINTF2(_L("CMMFDevSound::PlayToneL left with the expected error = %d"), err);
  5573 					}
  5574 				else
  5575 					{
  5576 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error = %d"), err);
  5577 					ERR_PRINTF2(_L("Expected error value = %d!"), KErrNotReady);
  5578 					StopTest(err);
  5579 					break;
  5580 					}
  5581 				}
  5582 			break;
  5583 			}
  5584 		default:
  5585 			{
  5586 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  5587 			StopTest(aError, EFail);
  5588 			}
  5589 		}
  5590 	}
  5591 
  5592 void RA3FDevSoundToneNewToneRequestWhilePlayingTest::DoTimerCallback()
  5593 	{
  5594 	INFO_PRINTF1(_L("TimerEvent called"));
  5595 	iTimer->Cancel();
  5596 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  5597 	Fsm(EEventTimerComplete, KErrNone);
  5598 	}
  5599 
  5600 void RA3FDevSoundToneNewToneRequestWhilePlayingTest::ToneFinished(TInt aError)
  5601 	{
  5602 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  5603 	if (aError == KErrUnderflow)
  5604 		{
  5605 		iEndTime.HomeTime();
  5606 		iPlayToneTime = iEndTime.MicroSecondsFrom(iStartTime);
  5607 		TInt totalExpectedReproductionTime = iDuration * KMicroSecsInOneSec;
  5608 		if(iPlayToneTime < totalExpectedReproductionTime + KPlayVarianceTime && iPlayToneTime > totalExpectedReproductionTime - KPlayVarianceTime)
  5609 			{
  5610 			INFO_PRINTF2(_L("Play time is %Ld microseconds"), iPlayToneTime.Int64());
  5611 			StopTest();
  5612 			}
  5613 		else
  5614 			{
  5615 			ERR_PRINTF3(_L("Play time is %Ld microseconds and it should have been %d microseconds"), iPlayToneTime.Int64(), totalExpectedReproductionTime);
  5616 			StopTest(KErrNone, EFail);
  5617 			}
  5618 		}
  5619 	else
  5620 		{
  5621 		ERR_PRINTF2(_L("DevSound called ToneFinished with error = %d"), aError);
  5622 		ERR_PRINTF2(_L("Expected error = %d"), KErrUnderflow);
  5623 		StopTest(aError, EFail);
  5624 		}
  5625 	}
  5626 
  5627 /*
  5628  *========================================================================================================
  5629  * MM-A3F-DEVSOUND-CHRTZ-TONE-0041
  5630  */
  5631 RA3FDevSoundTonePreemptionTest::RA3FDevSoundTonePreemptionTest(const TDesC& aTestName)
  5632 	:	RA3FDevSoundTestBase(aTestName),
  5633 		iDuration(0), iFrequencyTone1(0)
  5634 	{
  5635 	}
  5636 
  5637 RA3FDevSoundTonePreemptionTest* RA3FDevSoundTonePreemptionTest::NewL(const TDesC& aTestName)
  5638 	{
  5639 	RA3FDevSoundTonePreemptionTest * self = new(ELeave)RA3FDevSoundTonePreemptionTest(aTestName);
  5640 	return self;
  5641 	}
  5642 
  5643 void RA3FDevSoundTonePreemptionTest::DoKickoffTestL()
  5644 	{
  5645 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  5646 		{
  5647 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  5648 		StopTest(KErrNotFound);
  5649 		return;
  5650 		}
  5651 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  5652 		{
  5653 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  5654 		StopTest(KErrNotFound);
  5655 		return;
  5656 		}
  5657 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  5658 	iDevsoundToneClient = CA3FDevSoundToneClient::NewL(*this);
  5659 	}
  5660 
  5661 void RA3FDevSoundTonePreemptionTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  5662 	{
  5663 	switch (iDevSoundState)
  5664 		{
  5665 		case EStateCreated:
  5666 			{
  5667 			if (aDevSoundEvent == EEventInitialize)
  5668 				{
  5669 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePreemptionTest"), EFsmIncorrectErrorPassed));
  5670 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  5671 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  5672 				if (err != KErrNone)
  5673 					{
  5674 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  5675 					StopTest(err);
  5676 					break;
  5677 					}
  5678 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  5679 				iDevSoundState = EStateInitializing;
  5680 				}
  5681 			else
  5682 				{
  5683 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  5684 				StopTest(aError, EFail);
  5685 				}
  5686 			break;
  5687 			}
  5688 		case EStateInitializing:
  5689 			{
  5690 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  5691 				{
  5692 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  5693 				TMMFPrioritySettings prioritySettings;
  5694 				prioritySettings.iPriority = KMinimumPriority;
  5695 				prioritySettings.iPref = EMdaPriorityPreferenceTime;
  5696 				prioritySettings.iState = EMMFStateIdle;
  5697 				iMMFDevSound->SetPrioritySettings(prioritySettings);
  5698 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  5699 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  5700 				if (err != KErrNone)
  5701 					{
  5702 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  5703 					StopTest(err);
  5704 					break;
  5705 					}
  5706 				StartTimer(KMicroSecsTwoSec);
  5707 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  5708 				iDevSoundState = EStatePlaying;
  5709 				}
  5710 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  5711 				{
  5712 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  5713 				StopTest(aError);
  5714 				}
  5715 			else
  5716 				{
  5717 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  5718 				StopTest(aError, EFail);
  5719 				}
  5720 			break;
  5721 			}
  5722 		case EStatePlaying:
  5723 			{
  5724 			if(aDevSoundEvent == EEventTimerComplete)
  5725 				{
  5726 				INFO_PRINTF1(_L("Starting lower priority devsound client"));
  5727 				iDevsoundToneClient->SetPriority(KMaximumPriority);
  5728 				TInt err = iDevsoundToneClient->InitTonePlay(iFrequencyTone1, iDuration*KMicroSecsInOneSec);
  5729 				if(err != KErrNone)
  5730 					{
  5731 					ERR_PRINTF1(_L("Initialization to play tone thru second devsound client failed"));
  5732 					StopTest(err);
  5733 					}
  5734 				}
  5735 			break;
  5736 			}
  5737 		default:
  5738 			{
  5739 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  5740 			StopTest(aError, EFail);
  5741 			}
  5742 		}
  5743 	}
  5744 
  5745 void RA3FDevSoundTonePreemptionTest::DoTimerCallback()
  5746 	{
  5747 	INFO_PRINTF1(_L("TimerEvent called"));
  5748 	iTimer->Cancel();
  5749 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  5750 	Fsm(EEventTimerComplete, KErrNone);
  5751 	}
  5752 
  5753 void RA3FDevSoundTonePreemptionTest::ToneFinished(TInt aError)
  5754 	{
  5755 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  5756 	if (aError == KErrInUse || aError == KErrDied || aError == KErrAccessDenied)
  5757 		{
  5758 		INFO_PRINTF1(_L("========== Preempting 1st DevSound Instance=========="));
  5759 		}
  5760 	else
  5761 		{
  5762 		ERR_PRINTF2(_L("First DevSound client called ToneFinished() and failed with error = %d "), aError);
  5763 		ERR_PRINTF4(_L("Expected posibilities %d %d %d "), KErrInUse, KErrDied, KErrAccessDenied);
  5764 		StopTest(aError, EFail);
  5765 		}
  5766 	}
  5767 
  5768 
  5769 void RA3FDevSoundTonePreemptionTest::ClientInitializeCompleteCallback(TInt aError)
  5770 	{
  5771 	INFO_PRINTF1(_L("========== Second Client DevSound InitializeComplete() callback =========="));
  5772 	if (aError != KErrNone)
  5773 		{
  5774 		ERR_PRINTF2(_L("Second Devsound InitializeComplete received an error = %d"), aError);
  5775 		StopTest(aError);
  5776 		}
  5777 	else
  5778 		{
  5779 		INFO_PRINTF1(_L("Starting to play audio thru second devsound client"));
  5780 		TInt err = iDevsoundToneClient->PlayTone();
  5781 		if (err != KErrNone)
  5782 			{
  5783 			ERR_PRINTF2(_L("Starting to play tones thru second devsound client left with error = %d"), err);
  5784 			StopTest(err);
  5785 			}
  5786 		}
  5787 	}
  5788 
  5789 void RA3FDevSoundTonePreemptionTest::ClientToneFinishedCallback(TInt aError)
  5790 	{
  5791 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  5792 		if (aError == KErrUnderflow)
  5793 			{
  5794 			INFO_PRINTF2(_L("Second DevSound instance called ToneFinished with error = %d"), aError);
  5795 			StopTest(aError,EPass);
  5796 			}
  5797 		else
  5798 			{
  5799 			ERR_PRINTF2(_L("Second DevSound instance called ToneFinished with error = %d that was NOT expected"), aError);
  5800 			ERR_PRINTF2(_L("Expected error = %d"), aError);
  5801 			StopTest(aError);
  5802 			}
  5803 	}
  5804 
  5805 /*
  5806  *========================================================================================================
  5807  * MM-A3F-DEVSOUND-CHRTZ-TONE-0042
  5808  */
  5809 RA3FDevSoundToneRejectionTest::RA3FDevSoundToneRejectionTest(const TDesC& aTestName)
  5810 	:	RA3FDevSoundTestBase(aTestName),
  5811 		iDuration(0), iFrequencyTone1(0)
  5812 	{
  5813 	}
  5814 
  5815 RA3FDevSoundToneRejectionTest* RA3FDevSoundToneRejectionTest::NewL(const TDesC& aTestName)
  5816 	{
  5817 	RA3FDevSoundToneRejectionTest * self = new(ELeave)RA3FDevSoundToneRejectionTest(aTestName);
  5818 	return self;
  5819 	}
  5820 
  5821 void RA3FDevSoundToneRejectionTest::DoKickoffTestL()
  5822 	{
  5823 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  5824 		{
  5825 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  5826 		StopTest(KErrNotFound);
  5827 		return;
  5828 		}
  5829 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  5830 		{
  5831 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  5832 		StopTest(KErrNotFound);
  5833 		return;
  5834 		}
  5835 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  5836 	iDevsoundToneClient = CA3FDevSoundToneClient::NewL(*this);
  5837 	}
  5838 
  5839 void RA3FDevSoundToneRejectionTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  5840 	{
  5841 	switch (iDevSoundState)
  5842 		{
  5843 		case EStateCreated:
  5844 			{
  5845 			if (aDevSoundEvent == EEventInitialize)
  5846 				{
  5847 				__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundToneRejectionTest"), EFsmIncorrectErrorPassed));
  5848 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  5849 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  5850 				if (err != KErrNone)
  5851 					{
  5852 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  5853 					StopTest(err);
  5854 					break;
  5855 					}
  5856 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  5857 				iDevSoundState = EStateInitializing;
  5858 				}
  5859 			else
  5860 				{
  5861 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  5862 				StopTest(aError, EFail);
  5863 				}
  5864 			break;
  5865 			}
  5866 		case EStateInitializing:
  5867 			{
  5868 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  5869 				{
  5870 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  5871 				TMMFPrioritySettings prioritySettings;
  5872 				prioritySettings.iPriority = KMinimumPriority;
  5873 				prioritySettings.iPref = EMdaPriorityPreferenceTime;
  5874 				prioritySettings.iState = EMMFStateIdle;
  5875 				iMMFDevSound->SetPrioritySettings(prioritySettings);
  5876 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  5877 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  5878 				if (err != KErrNone)
  5879 					{
  5880 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  5881 					StopTest(err);
  5882 					break;
  5883 					}
  5884 				StartTimer(KMicroSecsTwoSec);
  5885 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  5886 				iDevSoundState = EStatePlaying;
  5887 				}
  5888 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  5889 				{
  5890 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  5891 				StopTest(aError);
  5892 				}
  5893 			else
  5894 				{
  5895 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  5896 				StopTest(aError, EFail);
  5897 				}
  5898 			break;
  5899 			}
  5900 		case EStatePlaying:
  5901 			{
  5902 			if(aDevSoundEvent == EEventTimerComplete)
  5903 				{
  5904 				INFO_PRINTF1(_L("Starting lower priority devsound client"));
  5905 				iDevsoundToneClient->SetPriority(KMinimumPriority);
  5906 				TInt err = iDevsoundToneClient->InitTonePlay(iFrequencyTone1, iDuration*KMicroSecsInOneSec);
  5907 				if(err != KErrNone)
  5908 					{
  5909 					ERR_PRINTF1(_L("Initialization to play tone thru second devsound client failed"));
  5910 					StopTest(err);
  5911 					}
  5912 				}
  5913 			break;
  5914 			}
  5915 		default:
  5916 			{
  5917 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  5918 			StopTest(aError, EFail);
  5919 			}
  5920 		}
  5921 	}
  5922 
  5923 void RA3FDevSoundToneRejectionTest::DoTimerCallback()
  5924 	{
  5925 	INFO_PRINTF1(_L("TimerEvent called"));
  5926 	iTimer->Cancel();
  5927 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  5928 	Fsm(EEventTimerComplete, KErrNone);
  5929 	}
  5930 
  5931 void RA3FDevSoundToneRejectionTest::ToneFinished(TInt aError)
  5932 	{
  5933 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  5934 	if (aError == KErrUnderflow)
  5935 		{
  5936 		INFO_PRINTF2(_L("First DevSound instance called ToneFinished with error = %d"), aError);
  5937 		StopTest(aError,EPass);
  5938 		}
  5939 	else
  5940 		{
  5941 		ERR_PRINTF2(_L("First DevSound instance called ToneFinished with error = %d that was NOT expected"), aError);
  5942 		ERR_PRINTF2(_L("Expected error = %d"), aError);
  5943 		StopTest(aError, EFail);
  5944 		}
  5945 	}
  5946 
  5947 
  5948 void RA3FDevSoundToneRejectionTest::ClientInitializeCompleteCallback(TInt aError)
  5949 	{
  5950 	INFO_PRINTF1(_L("========== Second Client DevSound InitializeComplete() callback =========="));
  5951 	if (aError != KErrNone)
  5952 		{
  5953 		ERR_PRINTF2(_L("Second Devsound InitializeComplete received an error = %d"), aError);
  5954 		StopTest(aError);
  5955 		}
  5956 	else
  5957 		{
  5958 		INFO_PRINTF1(_L("Starting to play audio thru second devsound client"));
  5959 		TInt err = iDevsoundToneClient->PlayTone();
  5960 		if (err != KErrNone)
  5961 			{
  5962 			ERR_PRINTF2(_L("Starting to play tones thru second devsound client left with error = %d"), err);
  5963 			StopTest(err);
  5964 			}
  5965 		}
  5966 	}
  5967 
  5968 void RA3FDevSoundToneRejectionTest::ClientToneFinishedCallback(TInt aError)
  5969 	{
  5970 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  5971 	if (aError == KErrInUse || aError == KErrDied || aError == KErrAccessDenied)
  5972 		{
  5973 		INFO_PRINTF1(_L("========== Rejection 2nd DevSound Instance=========="));
  5974 		}
  5975 	else
  5976 		{
  5977 		ERR_PRINTF2(_L("Second DevSound client called ToneFinished() and failed with error = %d "), aError);
  5978 		ERR_PRINTF4(_L("Expected posibilities %d %d %d "), KErrInUse, KErrDied, KErrAccessDenied);
  5979 		StopTest(aError, EFail);
  5980 		}
  5981 	}
  5982 
  5983 /*
  5984  *========================================================================================================
  5985  * MM-A3F-DEVSOUND-CHRTZ-TONE-0043
  5986  */
  5987 RA3FDevSoundTonePlayToneOnceAndStopTest::RA3FDevSoundTonePlayToneOnceAndStopTest(const TDesC& aTestName)
  5988 	:	RA3FDevSoundTestBase(aTestName),
  5989 		iDuration(0), iFrequencyTone1(0),
  5990 		iToneStopped(EFalse)
  5991 	{
  5992 	}
  5993 
  5994 RA3FDevSoundTonePlayToneOnceAndStopTest* RA3FDevSoundTonePlayToneOnceAndStopTest::NewL(const TDesC& aTestName)
  5995 	{
  5996 	RA3FDevSoundTonePlayToneOnceAndStopTest * self = new(ELeave)RA3FDevSoundTonePlayToneOnceAndStopTest(aTestName);
  5997 	return self;
  5998 	}
  5999 
  6000 void RA3FDevSoundTonePlayToneOnceAndStopTest::DoKickoffTestL()
  6001 	{
  6002 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  6003 		{
  6004 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  6005 		StopTest(KErrNotFound);
  6006 		return;
  6007 		}
  6008 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  6009 		{
  6010 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  6011 		StopTest(KErrNotFound);
  6012 		return;
  6013 		}
  6014 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  6015 	}
  6016 
  6017 void RA3FDevSoundTonePlayToneOnceAndStopTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  6018 	{
  6019 	switch (iDevSoundState)
  6020 		{
  6021 		case EStateCreated:
  6022 			{
  6023 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneOnceAndStopTest"), EFsmIncorrectErrorPassed));
  6024 			if (aDevSoundEvent == EEventInitialize)
  6025 				{
  6026 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  6027 				TRAPD(err, iMMFDevSound->InitializeL(*this,  EMMFStateTonePlaying));
  6028 				if (err != KErrNone)
  6029 					{
  6030 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"),  err);
  6031 					StopTest(err);
  6032 					break;
  6033 					}
  6034 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  6035 				iDevSoundState = EStateInitializing;
  6036 				}
  6037 			else
  6038 				{
  6039 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  6040 				StopTest(aError, EFail);
  6041 				}
  6042 			break;
  6043 			}
  6044 		case EStateInitializing:
  6045 			{
  6046 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  6047 				{
  6048 				if (!iToneStopped)
  6049 					{
  6050 					iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  6051 					INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  6052 					TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  6053 					if (err != KErrNone)
  6054 						{
  6055 						ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error : %d!"), err);
  6056 						StopTest(err);
  6057 						break;
  6058 						}
  6059 					StartTimer(KMicroSecsTwoSec);
  6060 					INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  6061 					iDevSoundState = EStatePlaying;
  6062 					}
  6063 				else
  6064 					{
  6065 					INFO_PRINTF1(_L("Calling CMMFDevSound::Stop succeeded"));
  6066 					StopTest(aError);
  6067 					}
  6068 				}
  6069 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  6070 				{
  6071 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  6072 				StopTest(aError);
  6073 				}
  6074 			else
  6075 				{
  6076 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6077 				StopTest(aError, EFail);
  6078 				}
  6079 			break;
  6080 			}
  6081 		case EStatePlaying:
  6082 			{
  6083 			if(aDevSoundEvent == EEventTimerComplete)
  6084 				{
  6085 				INFO_PRINTF1(_L("Calling CMMFDevSound::Stop"));
  6086 				iMMFDevSound->Stop();
  6087 				}
  6088 			else
  6089 				{
  6090 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6091 				StopTest(aError, EFail);
  6092 				}
  6093 			break;
  6094 			}
  6095 		default:
  6096 			{
  6097 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  6098 			StopTest(aError, EFail);
  6099 			}
  6100 		}
  6101 
  6102 	}
  6103 
  6104 void RA3FDevSoundTonePlayToneOnceAndStopTest::DoTimerCallback()
  6105 	{
  6106 	INFO_PRINTF1(_L("TimerEvent called"));
  6107 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  6108 	if(!iToneStopped)
  6109 		{
  6110 		Fsm(EEventTimerComplete, KErrNone);
  6111 		iToneStopped = ETrue;
  6112 		}
  6113 	else
  6114 		{
  6115 		iTimer->Cancel();
  6116 		INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  6117 		TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  6118 		if (err != KErrNone)
  6119 			{
  6120 			ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"),  err);
  6121 			ERR_PRINTF2(_L("Expected error = %d"), KErrNone);
  6122 			StopTest(err);
  6123 			}
  6124 		INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  6125 		iDevSoundState = EStateInitializing;
  6126 		}
  6127 	}
  6128 
  6129 void RA3FDevSoundTonePlayToneOnceAndStopTest::ToneFinished(TInt aError)
  6130 	{
  6131 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  6132 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to have been stopped"));
  6133 	StopTest(aError, EFail);
  6134 	}
  6135 
  6136 
  6137 /*
  6138  *========================================================================================================
  6139  * MM-A3F-DEVSOUND-CHRTZ-TONE-0044
  6140  */
  6141 RA3FDevSoundTonePlayDualToneOnceAndStopTest::RA3FDevSoundTonePlayDualToneOnceAndStopTest(const TDesC& aTestName)
  6142 	:	RA3FDevSoundTestBase(aTestName),
  6143 		iDuration(0), iFrequencyTone1(0),
  6144 		iFrequencyTone2(0), iToneStopped(EFalse)
  6145 	{
  6146 	}
  6147 
  6148 RA3FDevSoundTonePlayDualToneOnceAndStopTest* RA3FDevSoundTonePlayDualToneOnceAndStopTest::NewL(const TDesC& aTestName)
  6149 	{
  6150 	RA3FDevSoundTonePlayDualToneOnceAndStopTest * self = new(ELeave)RA3FDevSoundTonePlayDualToneOnceAndStopTest(aTestName);
  6151 	return self;
  6152 	}
  6153 
  6154 void RA3FDevSoundTonePlayDualToneOnceAndStopTest::DoKickoffTestL()
  6155 	{
  6156 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  6157 		{
  6158 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  6159 		StopTest(KErrNotFound);
  6160 		return;
  6161 		}
  6162 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  6163 		{
  6164 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  6165 		StopTest(KErrNotFound);
  6166 		return;
  6167 		}
  6168 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone2, iFrequencyTone2))
  6169 		{
  6170 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone2);
  6171 		StopTest(KErrNotFound);
  6172 		return;
  6173 		}
  6174 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  6175 	}
  6176 
  6177 void RA3FDevSoundTonePlayDualToneOnceAndStopTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  6178 	{
  6179 	switch (iDevSoundState)
  6180 		{
  6181 		case EStateCreated:
  6182 			{
  6183 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayDualToneOnceAndStopTest"), EFsmIncorrectErrorPassed));
  6184 			if (aDevSoundEvent == EEventInitialize)
  6185 				{
  6186 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  6187 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  6188 				if (err != KErrNone)
  6189 					{
  6190 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"),  err);
  6191 					StopTest(err);
  6192 					break;
  6193 					}
  6194 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  6195 				iDevSoundState = EStateInitializing;
  6196 				}
  6197 			else
  6198 				{
  6199 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  6200 				StopTest(aError, EFail);
  6201 				}
  6202 			break;
  6203 			}
  6204 		case EStateInitializing:
  6205 			{
  6206 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  6207 				{
  6208 				if (!iToneStopped)
  6209 					{
  6210 					iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  6211 					INFO_PRINTF4(_L("Calling CMMFDevSound::PlayDualToneL using %d Hz %d Hz during %d secs "), iFrequencyTone1, iFrequencyTone2, iDuration);
  6212 					TRAPD(err, iMMFDevSound->PlayDualToneL(iFrequencyTone1, iFrequencyTone2, iDuration*KMicroSecsInOneSec));
  6213 					if (err != KErrNone)
  6214 						{
  6215 						ERR_PRINTF2(_L("CMMFDevSound::PlayDualToneL left with error = %d!"),  err);
  6216 						StopTest(err);
  6217 						break;
  6218 						}
  6219 					StartTimer(KMicroSecsTwoSec);
  6220 					INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  6221 					iDevSoundState = EStatePlaying;
  6222 					}
  6223 				else
  6224 					{
  6225 					INFO_PRINTF1(_L("Calling CMMFDevSound::Stop succeeded"));
  6226 					StopTest(aError);
  6227 					}
  6228 				}
  6229 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  6230 				{
  6231 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  6232 				StopTest(aError);
  6233 				}
  6234 			else
  6235 				{
  6236 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6237 				StopTest(aError, EFail);
  6238 				}
  6239 			break;
  6240 			}
  6241 		case EStatePlaying:
  6242 			{
  6243 			if(aDevSoundEvent == EEventTimerComplete)
  6244 				{
  6245 				INFO_PRINTF1(_L("Calling CMMFDevSound::Stop"));
  6246 				iMMFDevSound->Stop();
  6247 				}
  6248 			else
  6249 				{
  6250 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6251 				StopTest(aError, EFail);
  6252 				}
  6253 			break;
  6254 			}
  6255 		default:
  6256 			{
  6257 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  6258 			StopTest(aError, EFail);
  6259 			}
  6260 		}
  6261 	}
  6262 
  6263 void RA3FDevSoundTonePlayDualToneOnceAndStopTest::DoTimerCallback()
  6264 	{
  6265 	INFO_PRINTF1(_L("TimerEvent called"));
  6266 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  6267 	if(!iToneStopped)
  6268 		{
  6269 		Fsm(EEventTimerComplete, KErrNone);
  6270 		iToneStopped = ETrue;
  6271 		}
  6272 	else
  6273 		{
  6274 		iTimer->Cancel();
  6275 		INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  6276 		TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  6277 		if (err != KErrNone)
  6278 			{
  6279 			ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"),  err);
  6280 			ERR_PRINTF2(_L("Expected error = %d"), KErrNone);
  6281 			StopTest(err);
  6282 			}
  6283 		INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  6284 		iDevSoundState = EStateInitializing;
  6285 		}
  6286 	}
  6287 
  6288 void RA3FDevSoundTonePlayDualToneOnceAndStopTest::ToneFinished(TInt aError)
  6289 	{
  6290 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  6291 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to have been stopped"));
  6292 	StopTest(aError, EFail);
  6293 	}
  6294 
  6295 /*
  6296  *========================================================================================================
  6297  * MM-A3F-DEVSOUND-CHRTZ-TONE-0045
  6298  */
  6299 RA3FDevSoundTonePlayDTMFStringOnceAndStopTest::RA3FDevSoundTonePlayDTMFStringOnceAndStopTest(const TDesC& aTestName)
  6300 	:	RA3FDevSoundTestBase(aTestName),iDTMFString(KNullDesC),
  6301 		iToneStopped(EFalse)
  6302 	{
  6303 	}
  6304 
  6305 RA3FDevSoundTonePlayDTMFStringOnceAndStopTest* RA3FDevSoundTonePlayDTMFStringOnceAndStopTest::NewL(const TDesC& aTestName)
  6306 	{
  6307 	RA3FDevSoundTonePlayDTMFStringOnceAndStopTest * self = new(ELeave)RA3FDevSoundTonePlayDTMFStringOnceAndStopTest(aTestName);
  6308 	return self;
  6309 	}
  6310 
  6311 void RA3FDevSoundTonePlayDTMFStringOnceAndStopTest::DoKickoffTestL()
  6312 	{
  6313 	TPtrC DTMF;
  6314 	if ( !GetStringFromConfig(iTestStepName, KDTMFString, DTMF) )
  6315 		{
  6316 		ERR_PRINTF2(KMsgErrorGetParameter, &KDTMFString);
  6317 		StopTest(KErrNotFound);
  6318 		return;
  6319 		}
  6320 	iDTMFString.Copy(DTMF);
  6321 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  6322 	}
  6323 
  6324 void RA3FDevSoundTonePlayDTMFStringOnceAndStopTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  6325 	{
  6326 	switch(iDevSoundState)
  6327 		{
  6328 		case EStateCreated:
  6329 			{
  6330 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayDTMFStringOnceAndStopTest"), EFsmIncorrectErrorPassed));
  6331 			if (aDevSoundEvent == EEventInitialize)
  6332 				{
  6333 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  6334 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  6335 				if (err != KErrNone)
  6336 					{
  6337 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  6338 					StopTest(err);
  6339 					break;
  6340 					}
  6341 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  6342 				iDevSoundState = EStateInitializing;
  6343 				}
  6344 			else
  6345 				{
  6346 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  6347 				StopTest(aError, EFail);
  6348 				}
  6349 			break;
  6350 			}
  6351 		case EStateInitializing:
  6352 			{
  6353 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  6354 				{
  6355 				if (!iToneStopped)
  6356 					{
  6357 					iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  6358 					INFO_PRINTF2(_L("Calling CMMFDevSound::PlayDTMFStringL %S"), &iDTMFString);
  6359 					TRAPD(err, iMMFDevSound->PlayDTMFStringL(iDTMFString));
  6360 					if (err != KErrNone)
  6361 						{
  6362 						ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error = %d"), err);
  6363 						StopTest(err);
  6364 						break;
  6365 						}
  6366 					StartTimer(KMicroSecsTwoSec);
  6367 					INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  6368 					iDevSoundState = EStatePlaying;
  6369 					}
  6370 				else
  6371 					{
  6372 					INFO_PRINTF1(_L("Calling CMMFDevSound::Stop succeeded"));
  6373 					StopTest(aError);
  6374 					}
  6375 				}
  6376 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  6377 				{
  6378 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  6379 				StopTest(aError);
  6380 				}
  6381 			else
  6382 				{
  6383 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6384 				StopTest(aError, EFail);
  6385 				}
  6386 			break;
  6387 			}
  6388 		case EStatePlaying:
  6389 			{
  6390 			if(aDevSoundEvent == EEventTimerComplete)
  6391 				{
  6392 				INFO_PRINTF1(_L("Calling CMMFDevSound::Stop"));
  6393 				iMMFDevSound->Stop();
  6394 				}
  6395 			else
  6396 				{
  6397 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6398 				StopTest(aError, EFail);
  6399 				}
  6400 			break;
  6401 			}
  6402 		default:
  6403 			{
  6404 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  6405 			StopTest(aError, EFail);
  6406 			}
  6407 		}
  6408 	}
  6409 
  6410 void RA3FDevSoundTonePlayDTMFStringOnceAndStopTest::DoTimerCallback()
  6411 	{
  6412 	INFO_PRINTF1(_L("TimerEvent called"));
  6413 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  6414 	if(!iToneStopped)
  6415 		{
  6416 		Fsm(EEventTimerComplete, KErrNone);
  6417 		iToneStopped = ETrue;
  6418 		}
  6419 	else
  6420 		{
  6421 		iTimer->Cancel();
  6422 		INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  6423 		TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  6424 		if (err != KErrNone)
  6425 			{
  6426 			ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"),  err);
  6427 			ERR_PRINTF2(_L("Expected error = %d"), KErrNone);
  6428 			StopTest(err);
  6429 			}
  6430 		INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  6431 		iDevSoundState = EStateInitializing;
  6432 		}
  6433 	}
  6434 
  6435 void RA3FDevSoundTonePlayDTMFStringOnceAndStopTest::ToneFinished(TInt aError)
  6436 	{
  6437 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  6438 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to have been stopped"));
  6439 	StopTest(aError, EFail);
  6440 	}
  6441 /*
  6442  *========================================================================================================
  6443  * MM-A3F-DEVSOUND-CHRTZ-TONE-0046
  6444  */
  6445 RA3FDevSoundTonePlayToneSequenceOnceAndStopTest::RA3FDevSoundTonePlayToneSequenceOnceAndStopTest(const TDesC& aTestName)
  6446 	:	RA3FDevSoundTestBase(aTestName), iToneStopped(EFalse)
  6447 	{
  6448 	}
  6449 
  6450 RA3FDevSoundTonePlayToneSequenceOnceAndStopTest* RA3FDevSoundTonePlayToneSequenceOnceAndStopTest::NewL(const TDesC& aTestName)
  6451 	{
  6452 	RA3FDevSoundTonePlayToneSequenceOnceAndStopTest * self = new(ELeave)RA3FDevSoundTonePlayToneSequenceOnceAndStopTest(aTestName);
  6453 	return self;
  6454 	}
  6455 
  6456 void RA3FDevSoundTonePlayToneSequenceOnceAndStopTest::DoKickoffTestL()
  6457 	{
  6458 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  6459 	}
  6460 
  6461 void RA3FDevSoundTonePlayToneSequenceOnceAndStopTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  6462 	{
  6463 	switch (iDevSoundState)
  6464 		{
  6465 		case EStateCreated:
  6466 			{
  6467 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneSequenceOnceAndStopTest"), EFsmIncorrectErrorPassed));
  6468 			if (aDevSoundEvent == EEventInitialize)
  6469 				{
  6470 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  6471 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  6472 				if (err != KErrNone)
  6473 					{
  6474 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"),  err);
  6475 					StopTest(err);
  6476 					break;
  6477 					}
  6478 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  6479 				iDevSoundState = EStateInitializing;
  6480 				}
  6481 			else
  6482 				{
  6483 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  6484 				StopTest(aError, EFail);
  6485 				}
  6486 			break;
  6487 			}
  6488 		case EStateInitializing:
  6489 			{
  6490 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  6491 				{
  6492 				if (!iToneStopped)
  6493 					{
  6494 					iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  6495 					TUint8* tablePointer = const_cast<TUint8*>( &(KFixedSequenceTestSequenceDataX[0]));
  6496 					TPtrC8 KFixedSequenceData(tablePointer,  sizeof(KFixedSequenceTestSequenceDataX));
  6497 					INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneSequenceL"));
  6498 					TRAPD(err, iMMFDevSound->PlayToneSequenceL(KFixedSequenceData));
  6499 					if (err != KErrNone)
  6500 						{
  6501 						ERR_PRINTF2(_L("CMMFDevSound::PlayToneSequenceL left with error = %d!"), err);
  6502 						StopTest(err);
  6503 						break;
  6504 						}
  6505 					StartTimer(KMicroSecsTwoSec);
  6506 					INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  6507 					iDevSoundState = EStatePlaying;
  6508 					}
  6509 				else
  6510 					{
  6511 					INFO_PRINTF1(_L("Calling CMMFDevSound::Stop succeeded"));
  6512 					StopTest(aError);
  6513 					}
  6514 
  6515 				}
  6516 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  6517 				{
  6518 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  6519 				StopTest(aError);
  6520 				}
  6521 			else
  6522 				{
  6523 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6524 				StopTest(aError, EFail);
  6525 				}
  6526 			break;
  6527 			}
  6528 		case EStatePlaying:
  6529 			{
  6530 			if(aDevSoundEvent == EEventTimerComplete)
  6531 				{
  6532 				INFO_PRINTF1(_L("Calling CMMFDevSound::Stop"));
  6533 				iMMFDevSound->Stop();
  6534 				}
  6535 			else
  6536 				{
  6537 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6538 				StopTest(aError, EFail);
  6539 				}
  6540 			break;
  6541 			}
  6542 		default:
  6543 			{
  6544 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"),  iDevSoundState);
  6545 			StopTest(aError, EFail);
  6546 			}
  6547 		}
  6548 	}
  6549 
  6550 void RA3FDevSoundTonePlayToneSequenceOnceAndStopTest::DoTimerCallback()
  6551 	{
  6552 	INFO_PRINTF1(_L("TimerEvent called"));
  6553 	INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  6554 	if(!iToneStopped)
  6555 		{
  6556 		Fsm(EEventTimerComplete, KErrNone);
  6557 		iToneStopped = ETrue;
  6558 		}
  6559 	else
  6560 		{
  6561 		iTimer->Cancel();
  6562 		INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  6563 		TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  6564 		if (err != KErrNone)
  6565 			{
  6566 			ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"),  err);
  6567 			ERR_PRINTF2(_L("Expected error = %d"), KErrNone);
  6568 			StopTest(err);
  6569 			}
  6570 		INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  6571 		iDevSoundState = EStateInitializing;
  6572 		}
  6573 	}
  6574 
  6575 void RA3FDevSoundTonePlayToneSequenceOnceAndStopTest::ToneFinished(TInt aError)
  6576 	{
  6577 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  6578 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to have been stopped"));
  6579 	StopTest(aError, EFail);
  6580 	}
  6581 
  6582 /*
  6583  *========================================================================================================
  6584  * MM-A3F-DEVSOUND-CHRTZ-TONE-0047
  6585  */
  6586 RA3FDevSoundTonePlayToneOncePauseTest::RA3FDevSoundTonePlayToneOncePauseTest(const TDesC& aTestName)
  6587 	:	RA3FDevSoundTestBase(aTestName),iDuration(0),
  6588 		iFrequencyTone1(0), iPaused(EFalse),
  6589 		iSamplesPlayedPaused(0)
  6590 	{
  6591 	}
  6592 
  6593 RA3FDevSoundTonePlayToneOncePauseTest* RA3FDevSoundTonePlayToneOncePauseTest::NewL(const TDesC& aTestName)
  6594 	{
  6595 	RA3FDevSoundTonePlayToneOncePauseTest * self = new(ELeave)RA3FDevSoundTonePlayToneOncePauseTest(aTestName);
  6596 	return self;
  6597 	}
  6598 
  6599 void RA3FDevSoundTonePlayToneOncePauseTest::DoKickoffTestL()
  6600 	{
  6601 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  6602 		{
  6603 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  6604 		StopTest(KErrNotFound);
  6605 		return;
  6606 		}
  6607 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  6608 		{
  6609 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  6610 		StopTest(KErrNotFound);
  6611 		return;
  6612 		}
  6613 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  6614 	}
  6615 
  6616 void RA3FDevSoundTonePlayToneOncePauseTest::Fsm(TMmfDevSoundEvent aDevSoundEvent,  TInt aError)
  6617 	{
  6618 	switch (iDevSoundState)
  6619 		{
  6620 		case EStateCreated:
  6621 			{
  6622 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneOncePauseTest"), EFsmIncorrectErrorPassed));
  6623 			if (aDevSoundEvent == EEventInitialize)
  6624 				{
  6625 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  6626 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  6627 				if (err != KErrNone)
  6628 					{
  6629 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"),  err);
  6630 					StopTest(err);
  6631 					break;
  6632 					}
  6633 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  6634 				iDevSoundState = EStateInitializing;
  6635 				}
  6636 			else
  6637 				{
  6638 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  6639 				StopTest(aError, EFail);
  6640 				}
  6641 			break;
  6642 			}
  6643 		case EStateInitializing:
  6644 			{
  6645 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  6646 				{
  6647 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  6648 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs "), iFrequencyTone1, iDuration);
  6649 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  6650 				if (err != KErrNone)
  6651 					{
  6652 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error = %d!"),  err);
  6653 					StopTest(err);
  6654 					break;
  6655 					}
  6656 				StartTimer(KMicroSecsTwoSec);
  6657 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  6658 				iDevSoundState = EStatePlaying;
  6659 				}
  6660 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  6661 				{
  6662 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  6663 				StopTest(aError);
  6664 				}
  6665 			else
  6666 				{
  6667 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"),  aDevSoundEvent);
  6668 				StopTest(aError, EFail);
  6669 				}
  6670 			break;
  6671 			}
  6672 		case EStatePlaying:
  6673 			{
  6674 			if(aDevSoundEvent == EEventTimerComplete)
  6675 				{
  6676 				INFO_PRINTF1(_L("Calling CMMFDevSound::Pause"));
  6677 				iMMFDevSound->Pause();
  6678 				INFO_PRINTF1(_L("DevSound State: EStatePause"));
  6679 				iDevSoundState = EStatePause;
  6680 				INFO_PRINTF1(_L("Calling CMMFDevSound::SamplesPlayed"));
  6681 				iSamplesPlayedPaused = iMMFDevSound->SamplesPlayed();
  6682 				INFO_PRINTF2(_L("The number of samples played is %d"), iSamplesPlayedPaused);
  6683 				}
  6684 			else
  6685 				{
  6686 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6687 				StopTest(aError, EFail);
  6688 				}
  6689 			break;
  6690 			}
  6691 		case EStatePause:
  6692 			{
  6693 			if (aDevSoundEvent == EEventTimerComplete)
  6694 				{
  6695 				TInt samplesPlayed = iMMFDevSound->SamplesPlayed();
  6696 				if(iSamplesPlayedPaused == samplesPlayed)
  6697 					{
  6698 					INFO_PRINTF2(_L("After waiting a couple of seconds, the samples played are still being the same %d"), iSamplesPlayedPaused);
  6699 					StopTest();
  6700 					}
  6701 				else
  6702 					{
  6703 					ERR_PRINTF2(_L("After waiting a couple of seconds, the samples played are not the same %d"), samplesPlayed);
  6704 					ERR_PRINTF2(_L("Expected samples played = %d"), iSamplesPlayedPaused);
  6705 					StopTest(aError,EFail);
  6706 					}
  6707 				}
  6708 			else
  6709 				{
  6710 				ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6711 				StopTest(aError, EFail);
  6712 				}
  6713 			break;
  6714 			}
  6715 		default:
  6716 			{
  6717 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  6718 			StopTest(aError, EFail);
  6719 			}
  6720 		}
  6721 	}
  6722 
  6723 void RA3FDevSoundTonePlayToneOncePauseTest::DoTimerCallback()
  6724 	{
  6725 	INFO_PRINTF1(_L("TimerEvent called"));
  6726 	if (!iPaused)
  6727 		{
  6728 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  6729 		Fsm(EEventTimerComplete, KErrNone);
  6730 		iPaused = ETrue;
  6731 		}
  6732 	else
  6733 		{
  6734 		iTimer->Cancel();
  6735 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  6736 		Fsm(EEventTimerComplete, KErrNone);
  6737 		}
  6738 	}
  6739 
  6740 void RA3FDevSoundTonePlayToneOncePauseTest::ToneFinished(TInt aError)
  6741 	{
  6742 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  6743 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to be paused"));
  6744 	StopTest(aError, EFail);
  6745 	}
  6746 
  6747 /*
  6748  *========================================================================================================
  6749  * MM-A3F-DEVSOUND-CHRTZ-TONE-0048
  6750  */
  6751 RA3FDevSoundTonePlayDualToneOncePauseTest::RA3FDevSoundTonePlayDualToneOncePauseTest(const TDesC& aTestName)
  6752 	:	RA3FDevSoundTestBase(aTestName),
  6753 		iDuration(0),iFrequencyTone1(0),
  6754 		iFrequencyTone2(0), iPaused(EFalse),
  6755 		iSamplesPlayedPaused(0)
  6756 	{
  6757 	}
  6758 
  6759 RA3FDevSoundTonePlayDualToneOncePauseTest* RA3FDevSoundTonePlayDualToneOncePauseTest::NewL(const TDesC& aTestName)
  6760 	{
  6761 	RA3FDevSoundTonePlayDualToneOncePauseTest * self = new(ELeave)RA3FDevSoundTonePlayDualToneOncePauseTest(aTestName);
  6762 	return self;
  6763 	}
  6764 
  6765 void RA3FDevSoundTonePlayDualToneOncePauseTest::DoKickoffTestL()
  6766 	{
  6767 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  6768 		{
  6769 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  6770 		StopTest(KErrNotFound);
  6771 		return;
  6772 		}
  6773 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  6774 		{
  6775 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  6776 		StopTest(KErrNotFound);
  6777 		return;
  6778 		}
  6779 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone2, iFrequencyTone2))
  6780 		{
  6781 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone2);
  6782 		StopTest(KErrNotFound);
  6783 		return;
  6784 		}
  6785 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  6786 	}
  6787 
  6788 void RA3FDevSoundTonePlayDualToneOncePauseTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  6789 	{
  6790 	switch (iDevSoundState)
  6791 		{
  6792 		case EStateCreated:
  6793 			{
  6794 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayDualToneOncePauseTest"), EFsmIncorrectErrorPassed));
  6795 			if (aDevSoundEvent == EEventInitialize)
  6796 				{
  6797 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  6798 				TRAPD(err, iMMFDevSound->InitializeL(*this,  EMMFStateTonePlaying));
  6799 				if (err != KErrNone)
  6800 					{
  6801 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  6802 					StopTest(err);
  6803 					break;
  6804 					}
  6805 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  6806 				iDevSoundState = EStateInitializing;
  6807 				}
  6808 			else
  6809 				{
  6810 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  6811 				StopTest(aError, EFail);
  6812 				}
  6813 			break;
  6814 			}
  6815 		case EStateInitializing:
  6816 			{
  6817 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  6818 				{
  6819 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  6820 				INFO_PRINTF4(_L("Calling CMMFDevSound::PlayDualToneL using %d Hz %d Hz during %d secs "), iFrequencyTone1, iFrequencyTone2, iDuration);
  6821 				TRAPD(err, iMMFDevSound->PlayDualToneL(iFrequencyTone1, iFrequencyTone2, iDuration*KMicroSecsInOneSec));
  6822 				if (err != KErrNone)
  6823 					{
  6824 					ERR_PRINTF2(_L("CMMFDevSound::PlayDualToneL left with error : %d!"),  err);
  6825 					StopTest(err);
  6826 					break;
  6827 					}
  6828 				StartTimer(KMicroSecsTwoSec);
  6829 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  6830 				iDevSoundState = EStatePlaying;
  6831 				}
  6832 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  6833 				{
  6834 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  6835 				StopTest(aError);
  6836 				}
  6837 			else
  6838 				{
  6839 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6840 				StopTest(aError, EFail);
  6841 				}
  6842 			break;
  6843 			}
  6844 		case EStatePlaying:
  6845 			{
  6846 			if(aDevSoundEvent == EEventTimerComplete)
  6847 				{
  6848 				INFO_PRINTF1(_L("Calling CMMFDevSound::Pause"));
  6849 				iMMFDevSound->Pause();
  6850 				INFO_PRINTF1(_L("DevSound State: EStatePause"));
  6851 				iDevSoundState = EStatePause;
  6852 				INFO_PRINTF1(_L("Calling CMMFDevSound::SamplesPlayed"));
  6853 				iSamplesPlayedPaused = iMMFDevSound->SamplesPlayed();
  6854 				INFO_PRINTF2(_L("The number of samples played is %d"), iSamplesPlayedPaused);
  6855 				StopTest();
  6856 				}
  6857 			else
  6858 				{
  6859 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6860 				StopTest(aError, EFail);
  6861 				}
  6862 			break;
  6863 			}
  6864 		case EStatePause:
  6865 			{
  6866 			if (aDevSoundEvent == EEventTimerComplete)
  6867 				{
  6868 				TInt samplesPlayed = iMMFDevSound->SamplesPlayed();
  6869 				if(iSamplesPlayedPaused == samplesPlayed)
  6870 					{
  6871 					INFO_PRINTF2(_L("After waiting a couple of seconds, the samples played are still being the same %d"), iSamplesPlayedPaused);
  6872 					StopTest();
  6873 					}
  6874 				else
  6875 					{
  6876 					ERR_PRINTF2(_L("After waiting a couple of seconds, the samples played are not the same %d"), samplesPlayed);
  6877 					ERR_PRINTF2(_L("Expected samples played = %d"), iSamplesPlayedPaused);
  6878 					StopTest(aError,EFail);
  6879 					}
  6880 				}
  6881 			else
  6882 				{
  6883 				ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  6884 				StopTest(aError, EFail);
  6885 				}
  6886 			break;
  6887 			}
  6888 		default:
  6889 			{
  6890 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  6891 			StopTest(aError, EFail);
  6892 			}
  6893 		}
  6894 	}
  6895 
  6896 void RA3FDevSoundTonePlayDualToneOncePauseTest::DoTimerCallback()
  6897 	{
  6898 	INFO_PRINTF1(_L("TimerEvent called"));
  6899 	if (!iPaused)
  6900 		{
  6901 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  6902 		Fsm(EEventTimerComplete, KErrNone);
  6903 		iPaused = ETrue;
  6904 		}
  6905 	else
  6906 		{
  6907 		iTimer->Cancel();
  6908 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  6909 		Fsm(EEventTimerComplete, KErrNone);
  6910 		}
  6911 	}
  6912 
  6913 void RA3FDevSoundTonePlayDualToneOncePauseTest::ToneFinished(TInt aError)
  6914 	{
  6915 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  6916 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to be paused"));
  6917 	StopTest(aError, EFail);
  6918 	}
  6919 
  6920 /*
  6921  *========================================================================================================
  6922  * MM-A3F-DEVSOUND-CHRTZ-TONE-0049
  6923  */
  6924 RA3FDevSoundTonePlayDTMFStringOncePauseTest::RA3FDevSoundTonePlayDTMFStringOncePauseTest(const TDesC& aTestName)
  6925 	:	RA3FDevSoundTestBase(aTestName),
  6926 		iDTMFString(KNullDesC),iPaused(EFalse),
  6927 		iSamplesPlayedPaused(0),iDTMFPauses(0),
  6928 		iDTMFTones(0)
  6929 	{
  6930 	}
  6931 
  6932 RA3FDevSoundTonePlayDTMFStringOncePauseTest* RA3FDevSoundTonePlayDTMFStringOncePauseTest::NewL(const TDesC& aTestName)
  6933 	{
  6934 	RA3FDevSoundTonePlayDTMFStringOncePauseTest * self = new(ELeave)RA3FDevSoundTonePlayDTMFStringOncePauseTest(aTestName);
  6935 	return self;
  6936 	}
  6937 
  6938 void RA3FDevSoundTonePlayDTMFStringOncePauseTest::DoKickoffTestL()
  6939 	{
  6940 	TPtrC DTMF;
  6941 	if ( !GetStringFromConfig(iTestStepName, KDTMFString, DTMF) )
  6942 		{
  6943 		ERR_PRINTF2(KMsgErrorGetParameter, &KDTMFString);
  6944 		StopTest(KErrNotFound);
  6945 		return;
  6946 		}
  6947 	iDTMFString.Copy(DTMF);
  6948 	for(TInt i =0 ; i< iDTMFString.Length() ; i++)
  6949 		{
  6950 		if (iDTMFString[i] == ',')
  6951 			{
  6952 			iDTMFPauses++;
  6953 			}
  6954 		else
  6955 			{
  6956 			iDTMFTones++;
  6957 			}
  6958 		}
  6959 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  6960 	}
  6961 
  6962 void RA3FDevSoundTonePlayDTMFStringOncePauseTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  6963 	{
  6964 	switch (iDevSoundState)
  6965 		{
  6966 		case EStateCreated:
  6967 			{
  6968 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayDTMFStringOncePauseTest"), EFsmIncorrectErrorPassed));
  6969 			if (aDevSoundEvent == EEventInitialize)
  6970 				{
  6971 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  6972 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  6973 				if (err != KErrNone)
  6974 					{
  6975 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  6976 					StopTest(err);
  6977 					break;
  6978 					}
  6979 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  6980 				iDevSoundState = EStateInitializing;
  6981 				}
  6982 			else
  6983 				{
  6984 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  6985 				StopTest(aError, EFail);
  6986 				}
  6987 			break;
  6988 			}
  6989 		case EStateInitializing:
  6990 			{
  6991 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  6992 				{
  6993 				iMMFDevSound->SetVolume(iMMFDevSound->MaxVolume());
  6994 				INFO_PRINTF2(_L("Calling CMMFDevSound::PlayDTMFStringL %S"),  &iDTMFString);
  6995 				TRAPD(err, iMMFDevSound->PlayDTMFStringL(iDTMFString));
  6996 				if (err != KErrNone)
  6997 					{
  6998 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error : %d!"),  err);
  6999 					StopTest(err);
  7000 					}
  7001 				StartTimer(KMicroSecsTwoSec);
  7002 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  7003 				iDevSoundState = EStatePlaying;
  7004 				}
  7005 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  7006 				{
  7007 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  7008 				StopTest(aError);
  7009 				}
  7010 			else
  7011 				{
  7012 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7013 				StopTest(aError, EFail);
  7014 				}
  7015 			break;
  7016 			}
  7017 		case EStatePlaying:
  7018 			{
  7019 			if(aDevSoundEvent == EEventTimerComplete)
  7020 				{
  7021 				INFO_PRINTF1(_L("Calling CMMFDevSound::Pause"));
  7022 				iMMFDevSound->Pause();
  7023 				INFO_PRINTF1(_L("DevSound State: EStatePause"));
  7024 				iDevSoundState = EStatePause;
  7025 				INFO_PRINTF1(_L("Calling CMMFDevSound::SamplesPlayed"));
  7026 				iSamplesPlayedPaused = iMMFDevSound->SamplesPlayed();
  7027 				INFO_PRINTF2(_L("The number of samples played is %d"), iSamplesPlayedPaused);
  7028 				}
  7029 			else
  7030 				{
  7031 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7032 				StopTest(aError, EFail);
  7033 				}
  7034 			break;
  7035 			}
  7036 		case EStatePause:
  7037 			{
  7038 			if (aDevSoundEvent == EEventTimerComplete)
  7039 				{
  7040 				TInt samplesPlayed = iMMFDevSound->SamplesPlayed();
  7041 				if(iSamplesPlayedPaused == samplesPlayed)
  7042 					{
  7043 					INFO_PRINTF2(_L("After waiting a couple of seconds, the samples played are still being the same %d"), iSamplesPlayedPaused);
  7044 					StopTest();
  7045 					}
  7046 				else
  7047 					{
  7048 					ERR_PRINTF2(_L("After waiting a couple of seconds, the samples played are not the same %d"), samplesPlayed);
  7049 					ERR_PRINTF2(_L("Expected samples played = %d"), iSamplesPlayedPaused);
  7050 					StopTest(aError,EFail);
  7051 					}
  7052 				}
  7053 			else
  7054 				{
  7055 				ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7056 				StopTest(aError, EFail);
  7057 				}
  7058 			break;
  7059 			}
  7060 		default:
  7061 			{
  7062 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  7063 			StopTest(aError, EFail);
  7064 			}
  7065 		}
  7066 	}
  7067 
  7068 void RA3FDevSoundTonePlayDTMFStringOncePauseTest::DoTimerCallback()
  7069 	{
  7070 	INFO_PRINTF1(_L("TimerEvent called"));
  7071 	if (!iPaused)
  7072 		{
  7073 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  7074 		Fsm(EEventTimerComplete, KErrNone);
  7075 		iPaused = ETrue;
  7076 		}
  7077 	else
  7078 		{
  7079 		iTimer->Cancel();
  7080 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  7081 		Fsm(EEventTimerComplete, KErrNone);
  7082 		}
  7083 	}
  7084 
  7085 void RA3FDevSoundTonePlayDTMFStringOncePauseTest::ToneFinished(TInt aError)
  7086 	{
  7087 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  7088 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to be paused"));
  7089 	StopTest(aError, EFail);
  7090 	}
  7091 
  7092 /*
  7093  *========================================================================================================
  7094  * MM-A3F-DEVSOUND-CHRTZ-TONE-0050
  7095  */
  7096 RA3FDevSoundTonePlayToneSequenceOncePauseTest::RA3FDevSoundTonePlayToneSequenceOncePauseTest(const TDesC& aTestName)
  7097 	:	RA3FDevSoundTestBase(aTestName), iPaused(EFalse),
  7098 		iSamplesPlayedPaused(0)
  7099 	{
  7100 	}
  7101 
  7102 RA3FDevSoundTonePlayToneSequenceOncePauseTest* RA3FDevSoundTonePlayToneSequenceOncePauseTest::NewL(const TDesC& aTestName)
  7103 	{
  7104 	RA3FDevSoundTonePlayToneSequenceOncePauseTest * self = new(ELeave)RA3FDevSoundTonePlayToneSequenceOncePauseTest(aTestName);
  7105 	return self;
  7106 	}
  7107 
  7108 void RA3FDevSoundTonePlayToneSequenceOncePauseTest::DoKickoffTestL()
  7109 	{
  7110 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
  7111 	}
  7112 
  7113 void RA3FDevSoundTonePlayToneSequenceOncePauseTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  7114 	{
  7115 	switch(iDevSoundState)
  7116 		{
  7117 		case EStateCreated:
  7118 			{
  7119 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneSequenceOncePauseTest"), EFsmIncorrectErrorPassed));
  7120 			if (aDevSoundEvent == EEventInitialize)
  7121 				{
  7122 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
  7123 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  7124 				if (err != KErrNone)
  7125 					{
  7126 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  7127 					StopTest(err);
  7128 					break;
  7129 					}
  7130 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  7131 				iDevSoundState = EStateInitializing;
  7132 				}
  7133 			else
  7134 				{
  7135 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  7136 				StopTest(aError, EFail);
  7137 				}
  7138 			break;
  7139 			}
  7140 		case EStateInitializing:
  7141 			{
  7142 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  7143 				{
  7144 				TUint8* tablePointer = const_cast<TUint8*>( &(KFixedSequenceTestSequenceDataX[0] ) );
  7145 				TPtrC8 KFixedSequenceData(tablePointer, sizeof(KFixedSequenceTestSequenceDataX));
  7146 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneSequenceL"));
  7147 				TRAPD(err, iMMFDevSound->PlayToneSequenceL(KFixedSequenceData));
  7148 				if (err != KErrNone)
  7149 					{
  7150 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneSequenceL left  with error : %d!"),  err);
  7151 					StopTest(err);
  7152 					break;
  7153 					}
  7154 				StartTimer(KMicroSecsTwoSec);
  7155 				INFO_PRINTF1(_L("DevSound State: EStatePlaying"));
  7156 				iDevSoundState = EStatePlaying;
  7157 				}
  7158 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  7159 				{
  7160 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  7161 				StopTest(aError);
  7162 				}
  7163 			else
  7164 				{
  7165 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7166 				StopTest(aError, EFail);
  7167 				}
  7168 			break;
  7169 			}
  7170 		case EStatePlaying:
  7171 			{
  7172 			if(aDevSoundEvent == EEventTimerComplete)
  7173 				{
  7174 				INFO_PRINTF1(_L("Calling CMMFDevSound::Pause"));
  7175 				iMMFDevSound->Pause();
  7176 				INFO_PRINTF1(_L("DevSound State: EStatePause"));
  7177 				iDevSoundState = EStatePause;
  7178 				INFO_PRINTF1(_L("Calling CMMFDevSound::SamplesPlayed"));
  7179 				iSamplesPlayedPaused = iMMFDevSound->SamplesPlayed();
  7180 				INFO_PRINTF2(_L("The number of samples played is %d"), iSamplesPlayedPaused);
  7181 				}
  7182 			else
  7183 				{
  7184 				ERR_PRINTF2(_L("DevSound EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7185 				StopTest(aError, EFail);
  7186 				}
  7187 			break;
  7188 			}
  7189 		case EStatePause:
  7190 			{
  7191 			if (aDevSoundEvent == EEventTimerComplete)
  7192 				{
  7193 				TInt samplesPlayed = iMMFDevSound->SamplesPlayed();
  7194 				if(iSamplesPlayedPaused == samplesPlayed)
  7195 					{
  7196 					INFO_PRINTF2(_L("After waiting a couple of seconds, the samples played are still being the same %d"), iSamplesPlayedPaused);
  7197 					StopTest();
  7198 					}
  7199 				else
  7200 					{
  7201 					ERR_PRINTF2(_L("After waiting a couple of seconds, the samples played are not the same %d"), samplesPlayed);
  7202 					ERR_PRINTF2(_L("Expected samples played = %d"), iSamplesPlayedPaused);
  7203 					StopTest(aError,EFail);
  7204 					}
  7205 				}
  7206 			else
  7207 				{
  7208 				ERR_PRINTF2(_L("EEventTimerComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7209 				StopTest(aError, EFail);
  7210 				}
  7211 			break;
  7212 			}
  7213 		default:
  7214 			{
  7215 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  7216 			StopTest(aError, EFail);
  7217 			}
  7218 		}
  7219 	}
  7220 
  7221 void RA3FDevSoundTonePlayToneSequenceOncePauseTest::DoTimerCallback()
  7222 	{
  7223 	INFO_PRINTF1(_L("TimerEvent called"));
  7224 	if (!iPaused)
  7225 		{
  7226 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  7227 		Fsm(EEventTimerComplete, KErrNone);
  7228 		iPaused = ETrue;
  7229 		}
  7230 	else
  7231 		{
  7232 		iTimer->Cancel();
  7233 		INFO_PRINTF1(_L("DevSound Event: EEventTimerComplete"));
  7234 		Fsm(EEventTimerComplete, KErrNone);
  7235 		}
  7236 	}
  7237 
  7238 void RA3FDevSoundTonePlayToneSequenceOncePauseTest::ToneFinished(TInt aError)
  7239 	{
  7240 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  7241 	ERR_PRINTF1(_L("DevSound should not have called ToneFinished because it is supposed to be paused"));
  7242 	StopTest(aError, EFail);
  7243 	}
  7244 
  7245 /*
  7246  *========================================================================================================
  7247  * MM-A3F-DEVSOUND-CHRTZ-TONE-0051
  7248  */
  7249 RA3FDevSoundTonePlayToneOnceInitializedToPlayAudioTest::RA3FDevSoundTonePlayToneOnceInitializedToPlayAudioTest(const TDesC& aTestName)
  7250 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  7251 		iFrequencyTone1(0)
  7252 	{
  7253 	}
  7254 
  7255 RA3FDevSoundTonePlayToneOnceInitializedToPlayAudioTest* RA3FDevSoundTonePlayToneOnceInitializedToPlayAudioTest::NewL(const TDesC& aTestName)
  7256 	{
  7257 	RA3FDevSoundTonePlayToneOnceInitializedToPlayAudioTest * self = new(ELeave)RA3FDevSoundTonePlayToneOnceInitializedToPlayAudioTest(aTestName);
  7258 	return self;
  7259 	}
  7260 
  7261 void RA3FDevSoundTonePlayToneOnceInitializedToPlayAudioTest::DoKickoffTestL()
  7262 	{
  7263 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  7264 		{
  7265 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  7266 		StopTest(KErrNotFound);
  7267 		return;
  7268 		}
  7269 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  7270 		{
  7271 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  7272 		StopTest(KErrNotFound);
  7273 		return;
  7274 		}
  7275 	}
  7276 
  7277 void RA3FDevSoundTonePlayToneOnceInitializedToPlayAudioTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  7278 	{
  7279 	switch (iDevSoundState)
  7280 		{
  7281 		case EStateCreated:
  7282 			{
  7283 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneOnceInitializedToPlayAudioTest"), EFsmIncorrectErrorPassed));
  7284 			if (aDevSoundEvent == EEventInitialize)
  7285 				{
  7286 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL for playing audio files"));
  7287 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
  7288 				if (err != KErrNone)
  7289 					{
  7290 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  7291 					StopTest(err);
  7292 					break;
  7293 					}
  7294 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  7295 				iDevSoundState = EStateInitializing;
  7296 				}
  7297 			else
  7298 				{
  7299 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  7300 				StopTest(aError,  EFail);
  7301 				}
  7302 			break;
  7303 			}
  7304 		case EStateInitializing:
  7305 			{
  7306 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  7307 				{
  7308 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs"), iFrequencyTone1, iDuration);
  7309 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  7310 				if (err	== KErrNotSupported)
  7311 					{
  7312 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with KErrNotSupported %d which is the expected error"), err);
  7313 					StopTest();
  7314 					}
  7315 				else
  7316 					{
  7317 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error = %d"), err);
  7318 					ERR_PRINTF2(_L("Expected error = %d"), KErrNotSupported);
  7319 					StopTest(err, EFail);
  7320 					}
  7321 				}
  7322 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  7323 				{
  7324 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  7325 				StopTest(aError);
  7326 				}
  7327 			else
  7328 				{
  7329 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7330 				StopTest(aError, EFail);
  7331 				}
  7332 			break;
  7333 			}
  7334 		default:
  7335 			{
  7336 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  7337 			StopTest(aError, EFail);
  7338 			}
  7339 		}
  7340 	}
  7341 
  7342 /*
  7343  *========================================================================================================
  7344  * MM-A3F-DEVSOUND-CHRTZ-TONE-0052
  7345  */
  7346 RA3FDevSoundTonePlayDualToneOnceInitializedToPlayAudioTest::RA3FDevSoundTonePlayDualToneOnceInitializedToPlayAudioTest(const TDesC& aTestName)
  7347 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  7348 		iFrequencyTone1(0), iFrequencyTone2(0)
  7349 	{
  7350 	}
  7351 
  7352 RA3FDevSoundTonePlayDualToneOnceInitializedToPlayAudioTest* RA3FDevSoundTonePlayDualToneOnceInitializedToPlayAudioTest::NewL(const TDesC& aTestName)
  7353 	{
  7354 	RA3FDevSoundTonePlayDualToneOnceInitializedToPlayAudioTest * self = new(ELeave)RA3FDevSoundTonePlayDualToneOnceInitializedToPlayAudioTest(aTestName);
  7355 	return self;
  7356 	}
  7357 
  7358 void RA3FDevSoundTonePlayDualToneOnceInitializedToPlayAudioTest::DoKickoffTestL()
  7359 	{
  7360 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  7361 		{
  7362 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  7363 		StopTest(KErrNotFound);
  7364 		return;
  7365 		}
  7366 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  7367 		{
  7368 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  7369 		StopTest(KErrNotFound);
  7370 		return;
  7371 		}
  7372 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone2, iFrequencyTone2))
  7373 		{
  7374 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone2);
  7375 		StopTest(KErrNotFound);
  7376 		return;
  7377 		}
  7378 	}
  7379 
  7380 void RA3FDevSoundTonePlayDualToneOnceInitializedToPlayAudioTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  7381 	{
  7382 	switch(iDevSoundState)
  7383 		{
  7384 		case EStateCreated:
  7385 			{
  7386 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayDualToneOnceInitializedToPlayAudioTest"), EFsmIncorrectErrorPassed));
  7387 			if (aDevSoundEvent == EEventInitialize)
  7388 				{
  7389 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL for playing audio files"));
  7390 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
  7391 				if (err != KErrNone)
  7392 					{
  7393 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  7394 					StopTest(err);
  7395 					break;
  7396 					}
  7397 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  7398 				iDevSoundState = EStateInitializing;
  7399 				}
  7400 			else
  7401 				{
  7402 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  7403 				StopTest(aError, EFail);
  7404 				}
  7405 			break;
  7406 			}
  7407 		case EStateInitializing:
  7408 			{
  7409 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  7410 				{
  7411 				INFO_PRINTF4(_L("Calling CMMFDevSound::PlayDualToneL using %d Hz %d Hz during %d secs "), iFrequencyTone1, iFrequencyTone2, iDuration);
  7412 				TRAPD(err, iMMFDevSound->PlayDualToneL(iFrequencyTone1, iFrequencyTone2, iDuration*KMicroSecsInOneSec));
  7413 				if (err	== KErrNotSupported)
  7414 					{
  7415 					ERR_PRINTF2(_L("CMMFDevSound::PlayDualToneL left with KErrNotSupported %d which is the expected error"), err);
  7416 					StopTest(err, EPass);
  7417 					}
  7418 				else
  7419 					{
  7420 					ERR_PRINTF2(_L("CMMFDevSound::PlayDualToneL left with error = %d"), err);
  7421 					ERR_PRINTF2(_L("Expected error = %d"), KErrNotSupported);
  7422 					StopTest(err, EFail);
  7423 					}
  7424 				}
  7425 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  7426 				{
  7427 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  7428 				StopTest(aError);
  7429 				}
  7430 			else
  7431 				{
  7432 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7433 				StopTest(aError, EFail);
  7434 				}
  7435 			break;
  7436 			}
  7437 		default:
  7438 			{
  7439 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  7440 			StopTest(aError, EFail);
  7441 			}
  7442 		}
  7443 	}
  7444 
  7445 /*
  7446  *========================================================================================================
  7447  * MM-A3F-DEVSOUND-CHRTZ-TONE-0053
  7448  */
  7449 RA3FDevSoundTonePlayDTMFStringOnceInitializedToPlayAudioTest::RA3FDevSoundTonePlayDTMFStringOnceInitializedToPlayAudioTest(const TDesC& aTestName)
  7450 	:	RA3FDevSoundTestBase(aTestName), iDTMFString(KNullDesC)
  7451 	{
  7452 	}
  7453 
  7454 RA3FDevSoundTonePlayDTMFStringOnceInitializedToPlayAudioTest* RA3FDevSoundTonePlayDTMFStringOnceInitializedToPlayAudioTest::NewL(const TDesC& aTestName)
  7455 	{
  7456 	RA3FDevSoundTonePlayDTMFStringOnceInitializedToPlayAudioTest * self = new(ELeave)RA3FDevSoundTonePlayDTMFStringOnceInitializedToPlayAudioTest(aTestName);
  7457 	return self;
  7458 	}
  7459 
  7460 void RA3FDevSoundTonePlayDTMFStringOnceInitializedToPlayAudioTest::DoKickoffTestL()
  7461 	{
  7462 	TPtrC DTMF;
  7463 	if (!GetStringFromConfig(iTestStepName, KDTMFString, DTMF))
  7464 		{
  7465 		ERR_PRINTF2(KMsgErrorGetParameter, &KDTMFString);
  7466 		StopTest(KErrNotFound);
  7467 		return;
  7468 		}
  7469 	iDTMFString.Copy(DTMF);
  7470 	}
  7471 
  7472 void RA3FDevSoundTonePlayDTMFStringOnceInitializedToPlayAudioTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  7473 	{
  7474 	switch(iDevSoundState)
  7475 	{
  7476 		case EStateCreated:
  7477 			{
  7478 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayDTMFStringOnceInitializedToPlayAudioTest"), EFsmIncorrectErrorPassed));
  7479 			if (aDevSoundEvent == EEventInitialize)
  7480 				{
  7481 				INFO_PRINTF1(_L("Calling iMMFDevSound::InitializeL for playing audio files"));
  7482 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
  7483 				if (err != KErrNone)
  7484 					{
  7485 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  7486 					StopTest(err);
  7487 					break;
  7488 					}
  7489 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  7490 				iDevSoundState = EStateInitializing;
  7491 				}
  7492 			else
  7493 				{
  7494 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  7495 				StopTest(aError, EFail);
  7496 				}
  7497 			break;
  7498 			}
  7499 		case EStateInitializing:
  7500 			{
  7501 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  7502 				{
  7503 				INFO_PRINTF2(_L("Calling CMMFDevSound::PlayDTMFStringL %S "), &iDTMFString);
  7504 				TRAPD(err, iMMFDevSound->PlayDTMFStringL(iDTMFString));
  7505 				if (err	== KErrNotSupported)
  7506 					{
  7507 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with KErrNotSupported %d which is the expected error"), err);
  7508 					StopTest();
  7509 					}
  7510 				else
  7511 					{
  7512 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error = %d"), err);
  7513 					ERR_PRINTF2(_L("Expected error = %d"), KErrNotSupported);
  7514 					StopTest(err, EFail);
  7515 					}
  7516 				}
  7517 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  7518 				{
  7519 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  7520 				StopTest(aError);
  7521 				}
  7522 			else
  7523 				{
  7524 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7525 				StopTest(aError, EFail);
  7526 				}
  7527 			break;
  7528 			}
  7529 		default:
  7530 			{
  7531 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  7532 			StopTest(aError, EFail);
  7533 			}
  7534 		}
  7535 	}
  7536 
  7537 /*
  7538  *========================================================================================================
  7539  * MM-A3F-DEVSOUND-CHRTZ-TONE-0054
  7540  */
  7541 RA3FDevSoundTonePlayToneSequenceOnceInitializedToPlayAudioTest::RA3FDevSoundTonePlayToneSequenceOnceInitializedToPlayAudioTest(const TDesC& aTestName)
  7542 	:	RA3FDevSoundTestBase(aTestName)
  7543 	{
  7544 	}
  7545 
  7546 RA3FDevSoundTonePlayToneSequenceOnceInitializedToPlayAudioTest* RA3FDevSoundTonePlayToneSequenceOnceInitializedToPlayAudioTest::NewL(const TDesC& aTestName)
  7547 	{
  7548 	RA3FDevSoundTonePlayToneSequenceOnceInitializedToPlayAudioTest * self = new(ELeave)RA3FDevSoundTonePlayToneSequenceOnceInitializedToPlayAudioTest(aTestName);
  7549 	return self;
  7550 	}
  7551 void RA3FDevSoundTonePlayToneSequenceOnceInitializedToPlayAudioTest::DoKickoffTestL()
  7552 	{
  7553 	}
  7554 
  7555 void RA3FDevSoundTonePlayToneSequenceOnceInitializedToPlayAudioTest::Fsm(TMmfDevSoundEvent aDevSoundEvent,  TInt aError)
  7556 	{
  7557 	switch(iDevSoundState)
  7558 		{
  7559 		case EStateCreated:
  7560 			{
  7561 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneSequenceOnceInitializedToPlayAudioTest"), EFsmIncorrectErrorPassed));
  7562 			if (aDevSoundEvent == EEventInitialize)
  7563 				{
  7564 				INFO_PRINTF1(_L("Calling iMMFDevSound::InitializeL for playing audio files"));
  7565 				TRAPD(err, iMMFDevSound->InitializeL(*this,  EMMFStatePlaying));
  7566 				if (err != KErrNone)
  7567 					{
  7568 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  7569 					StopTest(err);
  7570 					break;
  7571 					}
  7572 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  7573 				iDevSoundState = EStateInitializing;
  7574 				}
  7575 			else
  7576 				{
  7577 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  7578 				StopTest(aError, EFail);
  7579 				}
  7580 			break;
  7581 			}
  7582 		case EStateInitializing:
  7583 			{
  7584 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  7585 				{
  7586 				TUint8* tablePointer = const_cast<TUint8*>( &(KFixedSequenceTestSequenceDataX[0] ) );
  7587 				TPtrC8 KFixedSequenceData(tablePointer,  sizeof(KFixedSequenceTestSequenceDataX));
  7588 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneSequenceL"));
  7589 				TRAPD(err,  iMMFDevSound->PlayToneSequenceL(KFixedSequenceData));
  7590 				if (err == KErrNotSupported)
  7591 					{
  7592 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneSequenceL left with KErrNotSupported %d which is the expected error"), err);
  7593 					StopTest(err, EPass);
  7594 					}
  7595 				else
  7596 					{
  7597 					ERR_PRINTF2(_L("Play  dual tone failed with error = %d"),  err);
  7598 					ERR_PRINTF2(_L("Expected error = %d"), KErrNotSupported);
  7599 					StopTest(err, EFail);
  7600 					}
  7601 				}
  7602 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  7603 				{
  7604 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  7605 				StopTest(aError);
  7606 				}
  7607 			else
  7608 				{
  7609 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7610 				StopTest(aError, EFail);
  7611 				}
  7612 			break;
  7613 			}
  7614 		default:
  7615 			{
  7616 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  7617 			StopTest(aError, EFail);
  7618 			}
  7619 		}
  7620 	}
  7621 
  7622 /*
  7623  *========================================================================================================
  7624  * MM-A3F-DEVSOUND-CHRTZ-TONE-0055
  7625  */
  7626 RA3FDevSoundTonePlayToneOnceInitializedToRecordAudioTest::RA3FDevSoundTonePlayToneOnceInitializedToRecordAudioTest(const TDesC& aTestName)
  7627 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  7628 		iFrequencyTone1(0)
  7629 	{
  7630 	}
  7631 
  7632 RA3FDevSoundTonePlayToneOnceInitializedToRecordAudioTest* RA3FDevSoundTonePlayToneOnceInitializedToRecordAudioTest::NewL(const TDesC& aTestName)
  7633 	{
  7634 	RA3FDevSoundTonePlayToneOnceInitializedToRecordAudioTest * self = new(ELeave)RA3FDevSoundTonePlayToneOnceInitializedToRecordAudioTest(aTestName);
  7635 	return self;
  7636 	}
  7637 
  7638 void RA3FDevSoundTonePlayToneOnceInitializedToRecordAudioTest::DoKickoffTestL()
  7639 	{
  7640 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  7641 		{
  7642 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  7643 		StopTest(KErrNotFound);
  7644 		return;
  7645 		}
  7646 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  7647 		{
  7648 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  7649 		StopTest(KErrNotFound);
  7650 		return;
  7651 		}
  7652 	}
  7653 
  7654 void RA3FDevSoundTonePlayToneOnceInitializedToRecordAudioTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  7655 	{
  7656 	switch (iDevSoundState)
  7657 		{
  7658 		case EStateCreated:
  7659 			{
  7660 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneOnceInitializedToRecordAudioTest"), EFsmIncorrectErrorPassed));
  7661 			if (aDevSoundEvent == EEventInitialize)
  7662 				{
  7663 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL for recording audio files"));
  7664 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateRecording));
  7665 				if (err != KErrNone)
  7666 					{
  7667 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  7668 					StopTest(err);
  7669 					break;
  7670 					}
  7671 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  7672 				iDevSoundState = EStateInitializing;
  7673 				}
  7674 			else
  7675 				{
  7676 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  7677 				StopTest(aError,  EFail);
  7678 				}
  7679 			break;
  7680 			}
  7681 		case EStateInitializing:
  7682 			{
  7683 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  7684 				{
  7685 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs"), iFrequencyTone1, iDuration);
  7686 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  7687 				if (err	== KErrNotSupported)
  7688 					{
  7689 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with KErrNotSupported %d which is the expected error"), err);
  7690 					StopTest();
  7691 					}
  7692 				else
  7693 					{
  7694 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error = %d"), err);
  7695 					ERR_PRINTF2(_L("Expected error = %d"), KErrNotSupported);
  7696 					StopTest(err, EFail);
  7697 					}
  7698 				}
  7699 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  7700 				{
  7701 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  7702 				StopTest(aError);
  7703 				}
  7704 			else
  7705 				{
  7706 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7707 				StopTest(aError, EFail);
  7708 				}
  7709 			break;
  7710 			}
  7711 		default:
  7712 			{
  7713 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  7714 			StopTest(aError, EFail);
  7715 			}
  7716 		}
  7717 	}
  7718 
  7719 /*
  7720  *========================================================================================================
  7721  * MM-A3F-DEVSOUND-CHRTZ-TONE-0056
  7722  */
  7723 RA3FDevSoundTonePlayDualToneOnceInitializedToRecordAudioTest::RA3FDevSoundTonePlayDualToneOnceInitializedToRecordAudioTest(const TDesC& aTestName)
  7724 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  7725 		iFrequencyTone1(0), iFrequencyTone2(0)
  7726 	{
  7727 	}
  7728 
  7729 RA3FDevSoundTonePlayDualToneOnceInitializedToRecordAudioTest* RA3FDevSoundTonePlayDualToneOnceInitializedToRecordAudioTest::NewL(const TDesC& aTestName)
  7730 	{
  7731 	RA3FDevSoundTonePlayDualToneOnceInitializedToRecordAudioTest * self = new(ELeave)RA3FDevSoundTonePlayDualToneOnceInitializedToRecordAudioTest(aTestName);
  7732 	return self;
  7733 	}
  7734 
  7735 void RA3FDevSoundTonePlayDualToneOnceInitializedToRecordAudioTest::DoKickoffTestL()
  7736 	{
  7737 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  7738 		{
  7739 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  7740 		StopTest(KErrNotFound);
  7741 		return;
  7742 		}
  7743 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  7744 		{
  7745 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  7746 		StopTest(KErrNotFound);
  7747 		return;
  7748 		}
  7749 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone2, iFrequencyTone2))
  7750 		{
  7751 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone2);
  7752 		StopTest(KErrNotFound);
  7753 		return;
  7754 		}
  7755 	}
  7756 
  7757 void RA3FDevSoundTonePlayDualToneOnceInitializedToRecordAudioTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  7758 	{
  7759 	switch(iDevSoundState)
  7760 		{
  7761 		case EStateCreated:
  7762 			{
  7763 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayDualToneOnceInitializedToRecordAudioTest"), EFsmIncorrectErrorPassed));
  7764 			if (aDevSoundEvent == EEventInitialize)
  7765 				{
  7766 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL for recording audio files"));
  7767 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateRecording));
  7768 				if (err != KErrNone)
  7769 					{
  7770 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  7771 					StopTest(err);
  7772 					break;
  7773 					}
  7774 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  7775 				iDevSoundState = EStateInitializing;
  7776 				}
  7777 			else
  7778 				{
  7779 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  7780 				StopTest(aError, EFail);
  7781 				}
  7782 			break;
  7783 			}
  7784 		case EStateInitializing:
  7785 			{
  7786 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  7787 				{
  7788 				INFO_PRINTF4(_L("Calling CMMFDevSound::PlayDualToneL using %d Hz %d Hz during %d secs "), iFrequencyTone1, iFrequencyTone2, iDuration);
  7789 				TRAPD(err, iMMFDevSound->PlayDualToneL(iFrequencyTone1, iFrequencyTone2, iDuration*KMicroSecsInOneSec));
  7790 				if (err	== KErrNotSupported)
  7791 					{
  7792 					ERR_PRINTF2(_L("CMMFDevSound::PlayDualToneL left with KErrNotSupported %d which is the expected error"), err);
  7793 					StopTest(err, EPass);
  7794 					}
  7795 				else
  7796 					{
  7797 					ERR_PRINTF2(_L("CMMFDevSound::PlayDualToneL left with error = %d"), err);
  7798 					ERR_PRINTF2(_L("Expected error = %d"), KErrNotSupported);
  7799 					StopTest(err, EFail);
  7800 					}
  7801 				}
  7802 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  7803 				{
  7804 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  7805 				StopTest(aError);
  7806 				}
  7807 			else
  7808 				{
  7809 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7810 				StopTest(aError, EFail);
  7811 				}
  7812 			break;
  7813 			}
  7814 		default:
  7815 			{
  7816 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  7817 			StopTest(aError, EFail);
  7818 			}
  7819 		}
  7820 	}
  7821 
  7822 /*
  7823  *========================================================================================================
  7824  * MM-A3F-DEVSOUND-CHRTZ-TONE-0057
  7825  */
  7826 RA3FDevSoundTonePlayDTMFStringOnceInitializedToRecordAudioTest::RA3FDevSoundTonePlayDTMFStringOnceInitializedToRecordAudioTest(const TDesC& aTestName)
  7827 	:	RA3FDevSoundTestBase(aTestName), iDTMFString(KNullDesC)
  7828 	{
  7829 	}
  7830 
  7831 RA3FDevSoundTonePlayDTMFStringOnceInitializedToRecordAudioTest* RA3FDevSoundTonePlayDTMFStringOnceInitializedToRecordAudioTest::NewL(const TDesC& aTestName)
  7832 	{
  7833 	RA3FDevSoundTonePlayDTMFStringOnceInitializedToRecordAudioTest * self = new(ELeave)RA3FDevSoundTonePlayDTMFStringOnceInitializedToRecordAudioTest(aTestName);
  7834 	return self;
  7835 	}
  7836 
  7837 void RA3FDevSoundTonePlayDTMFStringOnceInitializedToRecordAudioTest::DoKickoffTestL()
  7838 	{
  7839 	TPtrC DTMF;
  7840 	if (!GetStringFromConfig(iTestStepName, KDTMFString, DTMF))
  7841 		{
  7842 		ERR_PRINTF2(KMsgErrorGetParameter, &KDTMFString);
  7843 		StopTest(KErrNotFound);
  7844 		return;
  7845 		}
  7846 	iDTMFString.Copy(DTMF);
  7847 	}
  7848 
  7849 void RA3FDevSoundTonePlayDTMFStringOnceInitializedToRecordAudioTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  7850 	{
  7851 	switch(iDevSoundState)
  7852 	{
  7853 		case EStateCreated:
  7854 			{
  7855 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayDTMFStringOnceInitializedToRecordAudioTest"), EFsmIncorrectErrorPassed));
  7856 			if (aDevSoundEvent == EEventInitialize)
  7857 				{
  7858 				INFO_PRINTF1(_L("Calling iMMFDevSound::InitializeL for recording audio files"));
  7859 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateRecording));
  7860 				if (err != KErrNone)
  7861 					{
  7862 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  7863 					StopTest(err);
  7864 					break;
  7865 					}
  7866 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  7867 				iDevSoundState = EStateInitializing;
  7868 				}
  7869 			else
  7870 				{
  7871 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  7872 				StopTest(aError, EFail);
  7873 				}
  7874 			break;
  7875 			}
  7876 		case EStateInitializing:
  7877 			{
  7878 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  7879 				{
  7880 				INFO_PRINTF2(_L("Calling CMMFDevSound::PlayDTMFStringL %S "), &iDTMFString);
  7881 				TRAPD(err, iMMFDevSound->PlayDTMFStringL(iDTMFString));
  7882 				if (err	== KErrNotSupported)
  7883 					{
  7884 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with KErrNotSupported %d which is the expected error"), err);
  7885 					StopTest();
  7886 					}
  7887 				else
  7888 					{
  7889 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error = %d"), err);
  7890 					ERR_PRINTF2(_L("Expected error = %d"), KErrNotSupported);
  7891 					StopTest(err, EFail);
  7892 					}
  7893 				}
  7894 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  7895 				{
  7896 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  7897 				StopTest(aError);
  7898 				}
  7899 			else
  7900 				{
  7901 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7902 				StopTest(aError, EFail);
  7903 				}
  7904 			break;
  7905 			}
  7906 		default:
  7907 			{
  7908 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  7909 			StopTest(aError, EFail);
  7910 			}
  7911 		}
  7912 	}
  7913 
  7914 /*
  7915  *========================================================================================================
  7916  * MM-A3F-DEVSOUND-CHRTZ-TONE-0058
  7917  */
  7918 RA3FDevSoundTonePlayToneSequenceOnceInitializedToRecordAudioTest::RA3FDevSoundTonePlayToneSequenceOnceInitializedToRecordAudioTest(const TDesC& aTestName)
  7919 	:	RA3FDevSoundTestBase(aTestName)
  7920 	{
  7921 	}
  7922 
  7923 RA3FDevSoundTonePlayToneSequenceOnceInitializedToRecordAudioTest* RA3FDevSoundTonePlayToneSequenceOnceInitializedToRecordAudioTest::NewL(const TDesC& aTestName)
  7924 	{
  7925 	RA3FDevSoundTonePlayToneSequenceOnceInitializedToRecordAudioTest * self = new(ELeave)RA3FDevSoundTonePlayToneSequenceOnceInitializedToRecordAudioTest(aTestName);
  7926 	return self;
  7927 	}
  7928 void RA3FDevSoundTonePlayToneSequenceOnceInitializedToRecordAudioTest::DoKickoffTestL()
  7929 	{
  7930 	}
  7931 
  7932 void RA3FDevSoundTonePlayToneSequenceOnceInitializedToRecordAudioTest::Fsm(TMmfDevSoundEvent aDevSoundEvent,  TInt aError)
  7933 	{
  7934 	switch(iDevSoundState)
  7935 		{
  7936 		case EStateCreated:
  7937 			{
  7938 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneSequenceOnceInitializedToRecordAudioTest"), EFsmIncorrectErrorPassed));
  7939 			if (aDevSoundEvent == EEventInitialize)
  7940 				{
  7941 				INFO_PRINTF1(_L("Calling iMMFDevSound::InitializeL for playing audio files"));
  7942 				TRAPD(err, iMMFDevSound->InitializeL(*this,  EMMFStateRecording));
  7943 				if (err != KErrNone)
  7944 					{
  7945 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
  7946 					StopTest(err);
  7947 					break;
  7948 					}
  7949 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  7950 				iDevSoundState = EStateInitializing;
  7951 				}
  7952 			else
  7953 				{
  7954 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  7955 				StopTest(aError, EFail);
  7956 				}
  7957 			break;
  7958 			}
  7959 		case EStateInitializing:
  7960 			{
  7961 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  7962 				{
  7963 				TUint8* tablePointer = const_cast<TUint8*>( &(KFixedSequenceTestSequenceDataX[0] ) );
  7964 				TPtrC8 KFixedSequenceData(tablePointer,  sizeof(KFixedSequenceTestSequenceDataX));
  7965 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneSequenceL"));
  7966 				TRAPD(err,  iMMFDevSound->PlayToneSequenceL(KFixedSequenceData));
  7967 				if (err == KErrNotSupported)
  7968 					{
  7969 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneSequenceL left with KErrNotSupported %d which is the expected error"), err);
  7970 					StopTest(err, EPass);
  7971 					}
  7972 				else
  7973 					{
  7974 					ERR_PRINTF2(_L("Play  dual tone failed with error = %d"),  err);
  7975 					ERR_PRINTF2(_L("Expected error = %d"), KErrNotSupported);
  7976 					StopTest(err, EFail);
  7977 					}
  7978 				}
  7979 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  7980 				{
  7981 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  7982 				StopTest(aError);
  7983 				}
  7984 			else
  7985 				{
  7986 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  7987 				StopTest(aError, EFail);
  7988 				}
  7989 			break;
  7990 			}
  7991 		default:
  7992 			{
  7993 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  7994 			StopTest(aError, EFail);
  7995 			}
  7996 		}
  7997 	}
  7998 
  7999 /*
  8000  *========================================================================================================
  8001  * MM-A3F-DEVSOUND-CHRTZ-TONE-0059
  8002  */
  8003 RA3FDevSoundTonePlayToneWithoutCallingInitializeTest::RA3FDevSoundTonePlayToneWithoutCallingInitializeTest(const TDesC& aTestName)
  8004 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  8005 		iFrequencyTone1(0)
  8006 	{
  8007 	}
  8008 
  8009 RA3FDevSoundTonePlayToneWithoutCallingInitializeTest* RA3FDevSoundTonePlayToneWithoutCallingInitializeTest::NewL(const TDesC& aTestName)
  8010 	{
  8011 	RA3FDevSoundTonePlayToneWithoutCallingInitializeTest * self = new(ELeave)RA3FDevSoundTonePlayToneWithoutCallingInitializeTest(aTestName);
  8012 	return self;
  8013 	}
  8014 
  8015 void RA3FDevSoundTonePlayToneWithoutCallingInitializeTest::DoKickoffTestL()
  8016 	{
  8017 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  8018 		{
  8019 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  8020 		StopTest(KErrNotFound);
  8021 		return;
  8022 		}
  8023 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  8024 		{
  8025 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  8026 		StopTest(KErrNotFound);
  8027 		return;
  8028 		}
  8029 	}
  8030 
  8031 void RA3FDevSoundTonePlayToneWithoutCallingInitializeTest::Fsm(TMmfDevSoundEvent aDevSoundEvent,  TInt aError)
  8032 	{
  8033 	switch (iDevSoundState)
  8034 		{
  8035 		case EStateCreated:
  8036 			{
  8037 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneWithoutCallingInitializeTest"), EFsmIncorrectErrorPassed));
  8038 			if (aDevSoundEvent == EEventInitialize)
  8039 				{
  8040 				INFO_PRINTF3(_L("Calling CMMFDevSound::PlayToneL using %d Hz during %d secs"), iFrequencyTone1, iDuration);
  8041 				TRAPD(err, iMMFDevSound->PlayToneL(iFrequencyTone1, iDuration*KMicroSecsInOneSec));
  8042 				if (err	== KErrNotReady)
  8043 					{
  8044 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with KErrNotReady %d which is the expected error"), err);
  8045 					StopTest();
  8046 					}
  8047 				else
  8048 					{
  8049 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneL left with error = %d"), err);
  8050 					ERR_PRINTF2(_L("Expected error = %d"), KErrNotReady);
  8051 					StopTest(err, EFail);
  8052 					}
  8053 				}
  8054 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  8055 				{
  8056 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  8057 				StopTest(aError);
  8058 				}
  8059 			else
  8060 				{
  8061 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  8062 				StopTest(aError, EFail);
  8063 				}
  8064 			break;
  8065 			}
  8066 		default:
  8067 			{
  8068 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"),  iDevSoundState);
  8069 			StopTest(aError, EFail);
  8070 			}
  8071 		}
  8072 	}
  8073 
  8074 /*
  8075  *========================================================================================================
  8076  * MM-A3F-DEVSOUND-CHRTZ-TONE-0060
  8077  */
  8078 RA3FDevSoundTonePlayDualToneWithoutCallingInitializeTest::RA3FDevSoundTonePlayDualToneWithoutCallingInitializeTest(const TDesC& aTestName)
  8079 	:	RA3FDevSoundTestBase(aTestName), iDuration(0),
  8080 		iFrequencyTone1(0), iFrequencyTone2(0)
  8081 	{
  8082 	}
  8083 
  8084 RA3FDevSoundTonePlayDualToneWithoutCallingInitializeTest* RA3FDevSoundTonePlayDualToneWithoutCallingInitializeTest::NewL(const TDesC& aTestName)
  8085 	{
  8086 	RA3FDevSoundTonePlayDualToneWithoutCallingInitializeTest * self = new(ELeave)RA3FDevSoundTonePlayDualToneWithoutCallingInitializeTest(aTestName);
  8087 	return self;
  8088 	}
  8089 
  8090 void RA3FDevSoundTonePlayDualToneWithoutCallingInitializeTest::DoKickoffTestL()
  8091 	{
  8092 	if (!GetIntFromConfig(iTestStepName, KDuration, iDuration))
  8093 		{
  8094 		ERR_PRINTF2(KMsgErrorGetParameter, &KDuration);
  8095 		StopTest(KErrNotFound);
  8096 		return;
  8097 		}
  8098 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone1, iFrequencyTone1))
  8099 		{
  8100 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone1);
  8101 		StopTest(KErrNotFound);
  8102 		return;
  8103 		}
  8104 	if (!GetIntFromConfig(iTestStepName, KFrequencyTone2, iFrequencyTone2))
  8105 		{
  8106 		ERR_PRINTF2(KMsgErrorGetParameter, &KFrequencyTone2);
  8107 		StopTest(KErrNotFound);
  8108 		return;
  8109 		}
  8110 	}
  8111 
  8112 void RA3FDevSoundTonePlayDualToneWithoutCallingInitializeTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  8113 	{
  8114 	switch (iDevSoundState)
  8115 		{
  8116 		case EStateCreated:
  8117 			{
  8118 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayDualToneWithoutCallingInitializeTest"), EFsmIncorrectErrorPassed));
  8119 			if (aDevSoundEvent == EEventInitialize)
  8120 				{
  8121 				INFO_PRINTF4(_L("Calling CMMFDevSound::PlayDualToneL using %d Hz %d Hz during %d secs "), iFrequencyTone1, iFrequencyTone2, iDuration);
  8122 				TRAPD(err, iMMFDevSound->PlayDualToneL(iFrequencyTone1, iFrequencyTone2, iDuration*KMicroSecsInOneSec));
  8123 				if (err == KErrNotReady)
  8124 					{
  8125 					ERR_PRINTF2(_L("CMMFDevSound::PlayDualToneL left with KErrNotReady %d which is the expected error"), err);
  8126 					StopTest();
  8127 					}
  8128 				else
  8129 					{
  8130 					ERR_PRINTF2(_L("CMMFDevSound::PlayDualToneL left with error = %d"), err);
  8131 					ERR_PRINTF2(_L("Expected error = %d"), KErrNotReady);
  8132 					StopTest(err, EFail);
  8133 					}
  8134 				}
  8135 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  8136 				{
  8137 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  8138 				StopTest(aError);
  8139 				}
  8140 			else
  8141 				{
  8142 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  8143 				StopTest(aError, EFail);
  8144 				}
  8145 			break;
  8146 			}
  8147 		default:
  8148 			{
  8149 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  8150 			StopTest(aError, EFail);
  8151 			}
  8152 		}
  8153 	}
  8154 
  8155 /*
  8156  *========================================================================================================
  8157  * MM-A3F-DEVSOUND-CHRTZ-TONE-0061
  8158  */
  8159 RA3FDevSoundTonePlayDTMFStringWithoutCallingInitializeTest::RA3FDevSoundTonePlayDTMFStringWithoutCallingInitializeTest(const TDesC& aTestName)
  8160 	:	RA3FDevSoundTestBase(aTestName), iDTMFString(KNullDesC)
  8161 	{
  8162 	}
  8163 
  8164 RA3FDevSoundTonePlayDTMFStringWithoutCallingInitializeTest* RA3FDevSoundTonePlayDTMFStringWithoutCallingInitializeTest::NewL(const TDesC& aTestName)
  8165 	{
  8166 	RA3FDevSoundTonePlayDTMFStringWithoutCallingInitializeTest * self = new(ELeave)RA3FDevSoundTonePlayDTMFStringWithoutCallingInitializeTest(aTestName);
  8167 	return self;
  8168 	}
  8169 
  8170 void RA3FDevSoundTonePlayDTMFStringWithoutCallingInitializeTest::DoKickoffTestL()
  8171 	{
  8172 	TPtrC DTMF;
  8173 	if (!GetStringFromConfig(iTestStepName, KDTMFString, DTMF))
  8174 		{
  8175 		ERR_PRINTF2(KMsgErrorGetParameter, &KDTMFString);
  8176 		StopTest(KErrNotFound);
  8177 		return;
  8178 		}
  8179 	iDTMFString.Copy(DTMF);
  8180 	}
  8181 
  8182 void RA3FDevSoundTonePlayDTMFStringWithoutCallingInitializeTest::Fsm(TMmfDevSoundEvent aDevSoundEvent,  TInt aError)
  8183 	{
  8184 	switch (iDevSoundState)
  8185 		{
  8186 		case EStateCreated:
  8187 			{
  8188 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayDTMFStringWithoutCallingInitializeTest"), EFsmIncorrectErrorPassed));
  8189 			if (aDevSoundEvent == EEventInitialize)
  8190 				{
  8191 				INFO_PRINTF2(_L("Calling CMMFDevSound::PlayDTMFStringL %S"), &iDTMFString);
  8192 				TRAPD(err, iMMFDevSound->PlayDTMFStringL(iDTMFString));
  8193 				if (err == KErrNotReady)
  8194 					{
  8195 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with KErrNotReady %d which is the expected error"), err);
  8196 					StopTest();
  8197 					}
  8198 				else
  8199 					{
  8200 					ERR_PRINTF2(_L("CMMFDevSound::PlayDTMFStringL left with error = %d"), err);
  8201 					ERR_PRINTF2(_L("Expected error = %d"), KErrNotReady);
  8202 					StopTest(err, EFail);
  8203 					}
  8204 				}
  8205 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  8206 				{
  8207 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  8208 				StopTest(aError);
  8209 				}
  8210 			else
  8211 				{
  8212 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  8213 				StopTest(aError, EFail);
  8214 				}
  8215 			break;
  8216 			}
  8217 		default:
  8218 			{
  8219 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  8220 			StopTest(aError, EFail);
  8221 			}
  8222 		}
  8223 	}
  8224 
  8225 /*
  8226  *========================================================================================================
  8227  * MM-A3F-DEVSOUND-CHRTZ-TONE-0062
  8228  */
  8229 RA3FDevSoundTonePlayToneSequenceWithoutCallingInitializeTest::RA3FDevSoundTonePlayToneSequenceWithoutCallingInitializeTest(const TDesC& aTestName)
  8230 	:	RA3FDevSoundTestBase(aTestName)
  8231 	{
  8232 	}
  8233 
  8234 RA3FDevSoundTonePlayToneSequenceWithoutCallingInitializeTest* RA3FDevSoundTonePlayToneSequenceWithoutCallingInitializeTest::NewL(const TDesC& aTestName)
  8235 	{
  8236 	RA3FDevSoundTonePlayToneSequenceWithoutCallingInitializeTest * self = new(ELeave)RA3FDevSoundTonePlayToneSequenceWithoutCallingInitializeTest(aTestName);
  8237 	return self;
  8238 	}
  8239 
  8240 void RA3FDevSoundTonePlayToneSequenceWithoutCallingInitializeTest::DoKickoffTestL()
  8241 	{
  8242 	}
  8243 
  8244 void RA3FDevSoundTonePlayToneSequenceWithoutCallingInitializeTest::Fsm(TMmfDevSoundEvent aDevSoundEvent, TInt aError)
  8245 	{
  8246 	switch (iDevSoundState)
  8247 		{
  8248 		case EStateCreated:
  8249 			{
  8250 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneSequenceWithoutCallingInitializeTest"), EFsmIncorrectErrorPassed));
  8251 			if (aDevSoundEvent == EEventInitialize)
  8252 				{
  8253 				TUint8* tablePointer = const_cast<TUint8*>( &(KFixedSequenceTestSequenceDataX[0] ) );
  8254 				TPtrC8 KFixedSequenceData(tablePointer,  sizeof(KFixedSequenceTestSequenceDataX));
  8255 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayToneSequenceL"));
  8256 				TRAPD(err, iMMFDevSound->PlayToneSequenceL(KFixedSequenceData));
  8257 				if (err == KErrNotReady)
  8258 					{
  8259 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneSequenceL left with KErrNotReady %d which is the expected error"), err);
  8260 					StopTest();
  8261 					}
  8262 				else
  8263 					{
  8264 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneSequenceL left with error = %d"), err);
  8265 					ERR_PRINTF2(_L("Expected error = %d"), KErrNotReady);
  8266 					StopTest(err, EFail);
  8267 					}
  8268 				}
  8269 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  8270 				{
  8271 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  8272 				StopTest(aError);
  8273 				}
  8274 			else
  8275 				{
  8276 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  8277 				StopTest(aError, EFail);
  8278 				}
  8279 			break;
  8280 			}
  8281 		default:
  8282 			{
  8283 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  8284 			StopTest(aError, EFail);
  8285 			}
  8286 		}
  8287 	}
  8288 
  8289 /*
  8290  *========================================================================================================
  8291  * MM-A3F-DEVSOUND-CHRTZ-TONE-0063
  8292  */
  8293 RA3FDevSoundTonePlayToneSequenceUsingInvalidDescriptorTest::RA3FDevSoundTonePlayToneSequenceUsingInvalidDescriptorTest(const TDesC& aTestName)
  8294 	:	RA3FDevSoundTestBase(aTestName), iInvalidToneSequence(KNullDesC8)
  8295 	{
  8296 	}
  8297 
  8298 RA3FDevSoundTonePlayToneSequenceUsingInvalidDescriptorTest* RA3FDevSoundTonePlayToneSequenceUsingInvalidDescriptorTest::NewL(const TDesC& aTestName)
  8299 	{
  8300 	RA3FDevSoundTonePlayToneSequenceUsingInvalidDescriptorTest * self = new(ELeave)RA3FDevSoundTonePlayToneSequenceUsingInvalidDescriptorTest(aTestName);
  8301 	return self;
  8302 	}
  8303 
  8304 void RA3FDevSoundTonePlayToneSequenceUsingInvalidDescriptorTest::DoKickoffTestL()
  8305 	{
  8306 	TPtrC TS;
  8307 	if ( !GetStringFromConfig(iTestStepName, KInvalidToneSequence,  TS) )
  8308 		{
  8309 		ERR_PRINTF2(KMsgErrorGetParameter, &KInvalidToneSequence);
  8310 		StopTest(KErrNotFound);
  8311 		return;
  8312 		}
  8313 	iInvalidToneSequence.Copy(TS);
  8314 	}
  8315 
  8316 void RA3FDevSoundTonePlayToneSequenceUsingInvalidDescriptorTest::Fsm(TMmfDevSoundEvent aDevSoundEvent,  TInt aError)
  8317 	{
  8318 	switch (iDevSoundState)
  8319 		{
  8320 		case EStateCreated:
  8321 			{
  8322 			__ASSERT_ALWAYS((aError == KErrNone), Panic(_L("RA3FDevSoundTonePlayToneSequenceUsingInvalidDescriptorTest"), EFsmIncorrectErrorPassed));
  8323 			if (aDevSoundEvent == EEventInitialize)
  8324 				{
  8325 				INFO_PRINTF1(_L("Calling iMMFDevSound::InitializeL"));
  8326 				TRAPD(err, iMMFDevSound->InitializeL(*this, EMMFStateTonePlaying));
  8327 				if (err != KErrNone)
  8328 					{
  8329 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"),  err);
  8330 					StopTest(err);
  8331 					break;
  8332 					}
  8333 				INFO_PRINTF1(_L("DevSound State: EStateInitializing"));
  8334 				iDevSoundState = EStateInitializing;
  8335 				}
  8336 			else
  8337 				{
  8338 				ERR_PRINTF2(_L("DevSound EEventInitialize not received as expected. Received event: %d"), aDevSoundEvent);
  8339 				StopTest(aError, EFail);
  8340 				}
  8341 			break;
  8342 			}
  8343 		case EStateInitializing:
  8344 			{
  8345 			if (aDevSoundEvent == EEventInitComplete && aError == KErrNone)
  8346 				{
  8347 				INFO_PRINTF1(_L("Calling iMMFDevSound->PlayToneSequenceL with an invalid descriptor as argument"));
  8348 				TRAPD(err, iMMFDevSound->PlayToneSequenceL(iInvalidToneSequence));
  8349 				if (err != KErrNone)
  8350 					{
  8351 					ERR_PRINTF2(_L("CMMFDevSound::PlayToneSequenceL left with error = %d and it should not leave"), err);
  8352 					StopTest(err, EFail);
  8353 					}
  8354 				}
  8355 			else if (aDevSoundEvent == EEventInitComplete && aError != KErrNone)
  8356 				{
  8357 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
  8358 				StopTest(aError);
  8359 				}
  8360 			else
  8361 				{
  8362 				ERR_PRINTF2(_L("DevSound EEventInitComplete not received as expected. Received event: %d"), aDevSoundEvent);
  8363 				StopTest(aError, EFail);
  8364 				}
  8365 			break;
  8366 			}
  8367 		default:
  8368 			{
  8369 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iDevSoundState);
  8370 			StopTest(aError, EFail);
  8371 			}
  8372 		}
  8373 	}
  8374 
  8375 void RA3FDevSoundTonePlayToneSequenceUsingInvalidDescriptorTest::ToneFinished(TInt aError)
  8376 	{
  8377 	INFO_PRINTF1(_L("========== DevSound ToneFinished() callback =========="));
  8378 	if (aError == KErrCorrupt)
  8379 		{
  8380 		INFO_PRINTF2(_L("ToneFinished called with KErrCorrupt %d which is the expected error"), aError);
  8381 		StopTest();
  8382 		}
  8383 	else
  8384 		{
  8385 		ERR_PRINTF3(_L("ToneFinished called with error = %d, when the expected error is = %d"), aError, KErrCorrupt);
  8386 		StopTest(aError, EFail);
  8387 		}
  8388 	}
  8389