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