os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/CapTestStep0004.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200 (2012-06-15)
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 "CapTestStep0004.h"
    17 
    18 CSecDevSndTS0004* CSecDevSndTS0004::NewL()
    19 	{
    20 	CSecDevSndTS0004* self = new (ELeave) CSecDevSndTS0004;
    21 	CleanupStack::PushL(self);
    22 	self->ConstructL();
    23 	CleanupStack::Pop();
    24 	return self;
    25 	}
    26 	
    27 void CSecDevSndTS0004::ConstructL()
    28 	{
    29 	iIsFirstPlayed = EFalse;
    30 	}
    31 	
    32 void CSecDevSndTS0004::StartProcessing(TRequestStatus& aStatus)
    33 	{
    34 	iStatus = &aStatus;
    35 
    36 	if( (iVerdict = DoTestStepPreambleL() ) == EPass )
    37 		{
    38 		iVerdict = DoPlayDTMFTone();
    39 		}
    40 	}
    41 
    42 CSecDevSndTS0004::~CSecDevSndTS0004()
    43 	{
    44 	}
    45 
    46 /******************************************************************************
    47  *
    48  * DevSound methods
    49  *
    50  *****************************************************************************/
    51  
    52 /**
    53  *
    54  * DoTestStepL
    55  * @result TVerdict
    56  *
    57  */
    58 
    59 TVerdict CSecDevSndTS0004::DoPlayDTMFTone()
    60 	{
    61 	_LIT(KDTMFStringShort,"0");
    62 	_LIT(KDTMFString,"11111, 11111, 11111111");
    63 
    64 	//Initialize
    65 	TVerdict initOK = TestInitialize(EMMFStateTonePlaying);
    66 	if (initOK != EPass)
    67 		{
    68 		return EInconclusive;
    69 		}
    70 
    71 	TestSetPriority(KDevSoundPriorityHigh);
    72 	TestSetVolume(iMMFDevSound->MaxVolume());
    73 
    74 	iExpectedValue = KErrUnderflow;
    75 	TestPlayDTMFString(KDTMFStringShort);
    76 	iExpectedValue = KErrInUse;
    77 	return TestPlayDTMFString(KDTMFString);
    78 	}
    79 
    80 /**
    81  *
    82  * TestPlayDTMFString
    83  * @param aDTMFString
    84  * @result TVerdict
    85  *
    86  */
    87 TVerdict CSecDevSndTS0004::TestPlayDTMFString(const TDesC &aDTMFString)
    88 	{
    89 	iCallbackError = KErrNone;
    90 
    91 	ResetCallbacks();
    92 
    93 	TRAPD(err, iMMFDevSound->PlayDTMFStringL(aDTMFString));
    94 	if (err)
    95 		{
    96 		iCallbackError = err;
    97 		return EFail;
    98 		}
    99 	else
   100 		{
   101 		// Start the active scheduler and catch the callback
   102  		CActiveScheduler::Start();
   103 		if (iCallbackError != iExpectedValue)
   104 			{
   105 			return EFail;
   106 			}
   107 		if (iCallbackArray[EToneFinished] != 1)
   108 			{
   109 			return EFail;
   110 			}
   111 		TInt tot = GetCallbackTotal();
   112 		if (tot > 1)
   113 			{
   114 			return EFail;
   115 			}
   116 		}
   117 	return EPass;
   118 	}
   119 
   120 /******************************************************************************
   121  *
   122  * DevSound mixin methods
   123  *
   124  *****************************************************************************/
   125  
   126 /**
   127  *
   128  * ToneFinished
   129  * @param aError
   130  *
   131  */
   132 void CSecDevSndTS0004::ToneFinished (TInt aError)
   133 	{
   134 	if( !iIsFirstPlayed )
   135 		{
   136 		// after first tone played inform client so we can be interrupted during second play
   137 		iIsFirstPlayed = ETrue;
   138 		User::RequestComplete(iStatus, aError);
   139 		}
   140 	iCallbackArray[EToneFinished] ++;
   141 	iCallbackError = aError;
   142 	CActiveScheduler::Stop();
   143 	}