os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/mmddteststep0036.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     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 "mmddteststep0036.h"
    17 
    18 CSecDevSndTS0036* CSecDevSndTS0036::NewL(TThreadId aClientTid)
    19 	{
    20 	CSecDevSndTS0036* self = new (ELeave) CSecDevSndTS0036(aClientTid);
    21 	CleanupStack::PushL(self);
    22 	self->ConstructL();
    23 	CleanupStack::Pop();
    24 	return self;
    25 	}
    26 
    27 CSecDevSndTS0036::CSecDevSndTS0036(TThreadId aClientTid)
    28 	{
    29 	iClientTid = aClientTid;
    30 	}
    31 
    32 void CSecDevSndTS0036::ConstructL()
    33 	{
    34 	}
    35 	
    36 void CSecDevSndTS0036::StartProcessing(TRequestStatus& aStatus)
    37 	{
    38 	iStatus = &aStatus;
    39 	
    40 	User::After(3000000);	// allow client side devsound to play for 3sec
    41 	if( (iVerdict = DoTestStepPreambleL() ) == EPass )
    42 		{
    43 		iVerdict = DoPlaySimpleTone();
    44 		}
    45 	}
    46 
    47 CSecDevSndTS0036::~CSecDevSndTS0036()
    48 	{
    49 	}
    50 
    51 /******************************************************************************
    52  *
    53  * DevSound methods
    54  *
    55  *****************************************************************************/
    56  
    57 TVerdict CSecDevSndTS0036::DoPlaySimpleTone()
    58 	{
    59 	TInt freq = 100;	// arbitrary freq
    60 	TTimeIntervalMicroSeconds dur(2000000);	//play for 2sec
    61 	TVerdict verdict;
    62 	
    63 	TInt err = iMMFDevSound->SetClientThreadInfo(iClientTid);
    64 	if (err != KErrNone)
    65 		{
    66 		verdict = EInconclusive;
    67 		}
    68 	else
    69 		{
    70 		verdict = TestInitialize(EMMFStateTonePlaying);
    71 		if (verdict != EPass)
    72 			{
    73 			verdict = EInconclusive;
    74 			}
    75 		else
    76 			{
    77 			TestSetPriority(KDevSoundPriorityLow);
    78 			TestSetVolume(iMMFDevSound->MaxVolume());
    79 			iExpectedValue = KErrUnderflow;
    80 			verdict = TestPlayTone(freq, dur);
    81 			}
    82 		}
    83 	if (verdict == EInconclusive)
    84 		{
    85 		User::RequestComplete(iStatus, KErrGeneral);
    86 		}
    87 	return verdict;	
    88 	}
    89 
    90 /**
    91  *
    92  * TestPlayTone
    93  * @param aFreq
    94  * @param aDur
    95  * @result TVerdict
    96  *
    97  */
    98 TVerdict CSecDevSndTS0036::TestPlayTone(TInt aFreq, TTimeIntervalMicroSeconds aDur)
    99 	{
   100 	iCallbackError = KErrNone;
   101 
   102 	ResetCallbacks();
   103 
   104 	TRAPD(err, iMMFDevSound->PlayToneL(aFreq, 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 CSecDevSndTS0036::ToneFinished (TInt aError)
   144 	{
   145 	User::RequestComplete(iStatus, aError);
   146 	iCallbackArray[EToneFinished] ++;
   147 	iCallbackError = aError;
   148 	CActiveScheduler::Stop();
   149 	}