os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/CapTestStep0006.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2004-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 "CapTestStep0006.h"
    17 
    18 CSecDevSndTS0006* CSecDevSndTS0006::NewL()
    19 	{
    20 	CSecDevSndTS0006* self = new (ELeave) CSecDevSndTS0006;
    21 	CleanupStack::PushL(self);
    22 	self->ConstructL();
    23 	CleanupStack::Pop();
    24 	return self;
    25 	}
    26 	
    27 void CSecDevSndTS0006::ConstructL()
    28 	{
    29 	iIsFirstPlayed = EFalse;
    30 	}
    31 	
    32 
    33 void CSecDevSndTS0006::StartProcessing(TRequestStatus& aStatus)
    34 	{
    35 	iStatus = &aStatus;
    36 
    37 	iVerdict = EFail;
    38 	if( (iVerdict = DoTestStepPreambleL() ) == EPass )
    39 		{
    40 		iVerdict = DoPlayDualTone();
    41 		}
    42 	}
    43 		
    44 		
    45 CSecDevSndTS0006::~CSecDevSndTS0006()
    46 	{
    47 	}
    48 
    49 /******************************************************************************
    50  *
    51  * DevSound methods
    52  *
    53  *****************************************************************************/
    54  
    55 /**
    56  *
    57  * DoTestStepL
    58  * @result TVerdict
    59  *
    60  */
    61 
    62 const TInt	KShortTimeInterval = 1000000;
    63 const TInt	KLongTimeInterval = 10000000;
    64 
    65 TVerdict CSecDevSndTS0006::DoPlayDualTone()
    66 	{
    67 	TInt freq1a = 1000;
    68 	TInt freq1b = 500;
    69 	TTimeIntervalMicroSeconds dur1(KShortTimeInterval);
    70 	TInt freq2a = 2000;
    71 	TInt freq2b = 750;
    72 	TTimeIntervalMicroSeconds dur2(KLongTimeInterval);
    73 
    74 	//Initialize
    75 	TVerdict initOK = TestInitialize(EMMFStateTonePlaying);
    76 	if (initOK != EPass)
    77 		{
    78 		return EInconclusive;
    79 		}
    80 
    81 	TestSetPriority(KDevSoundPriorityHigh);
    82 	TestSetVolume(iMMFDevSound->MaxVolume());
    83 
    84 	iExpectedValue = KErrUnderflow;
    85 	TestPlayTone(freq1a, freq1b, dur1);
    86 	iExpectedValue = KErrInUse;
    87 	return TestPlayTone(freq2a, freq2b, dur2);
    88 	}
    89 
    90 /**
    91  *
    92  * TestPlayTone
    93  * @param aFreq
    94  * @param aDur
    95  * @result TVerdict
    96  *
    97  */
    98 TVerdict CSecDevSndTS0006::TestPlayTone(TInt aFreq1, TInt aFreq2, TTimeIntervalMicroSeconds aDur)
    99 	{
   100 	iCallbackError = KErrNone;
   101 
   102 	ResetCallbacks();
   103 
   104 	TRAPD(err, iMMFDevSound->PlayDualToneL(aFreq1, aFreq2, aDur));
   105 	if (err)
   106 		{
   107 		iCallbackError = err;
   108 		return EFail;
   109 		}
   110 	else
   111 		{
   112 		// Start the active scheduler and catch the callback
   113  		CActiveScheduler::Start();
   114 		if (iCallbackError != iExpectedValue)
   115 			{
   116 			return EFail;
   117 			}
   118 		if (iCallbackArray[EToneFinished] != 1)
   119 			{
   120 			return EFail;
   121 			}
   122 		TInt tot = GetCallbackTotal();
   123 		if (tot > 1)
   124 			{
   125 			return EFail;
   126 			}
   127 		}
   128 	return EPass;
   129 	}
   130 
   131 /******************************************************************************
   132  *
   133  * DevSound mixin methods
   134  *
   135  *****************************************************************************/
   136  
   137 /**
   138  *
   139  * ToneFinished
   140  * @param aError
   141  *
   142  */
   143 void CSecDevSndTS0006::ToneFinished (TInt aError)
   144 	{
   145 	if( !iIsFirstPlayed )
   146 		{
   147 		// after first tone played inform client so we can be interrupted during second play
   148 		iIsFirstPlayed = ETrue;
   149 		User::RequestComplete(iStatus, aError);
   150 		}
   151 	iCallbackArray[EToneFinished] ++;
   152 	iCallbackError = aError;
   153 	CActiveScheduler::Stop();
   154 	}