void ut_cphoneringingtonecontroller::T_PlayRingingtoneTTS()
{
    // Expected data
    _LIT(KTextToSay, "Mr. Brownstone");
    TBuf<30> texttosay (KTextToSay);
    TBuf<50> ringingtone(KNokiatune);
    CPhoneRingingTone* aAudioVideoRingingTone = CPhoneRingingTone::NewL(ringingtone);
    aAudioVideoRingingTone->SetRingingType(EProfileRingingTypeRinging);
    aAudioVideoRingingTone->SetTtsToneToBePlayed(ETrue);
    aAudioVideoRingingTone->SetVolume(5);
    _LIT8( KMethod, "CPhoneTTSPlayer::NewL" );
    iMockContext->ExpectCallL( KMethod() );
    _LIT8( KMethod2, "CPhoneTTSPlayer::PlayTtsTone" );
    iMockContext->ExpectCallL( KMethod2() ).WithL(KTextToSay(), aAudioVideoRingingTone);   
    _LIT8( KMethod3, "CPhoneRingingtonePlayer::PlayProfileBasedTone" );
    iMockContext->ExpectCallL( KMethod3() ).WithL(aAudioVideoRingingTone);

    TPhoneCmdParamRingTone ringToneParam;
    ringToneParam.SetVolume(5);
    ringToneParam.SetRingingType(EProfileRingingTypeRinging);
    ringToneParam.SetTextToSay(texttosay);
    // Set the profile ring tone
    ringToneParam.SetRingTone( ringingtone);
    ringToneParam.SetType( EPhoneRingToneProfile );

    iRingingtoneplayer->PlayRingToneL( &ringToneParam );
    
    EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
    delete aAudioVideoRingingTone;
}
void ut_cphoneringingtonecontroller::T_StopRingingtone()
{
    _LIT8( KMethod, "CPhoneRingingtonePlayer::StopPlaying" );
    iMockContext->ExpectCallL( KMethod() );

    iRingingtoneplayer->StopPlaying();
    EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
}
void ut_cphoneringingtonecontroller::T_PlayRingingtoneBeepOnce(  )
    {
    _LIT8( KMethod, "CPhoneRingingtonePlayer::PlayBeepOnce" );
    iMockContext->ExpectCallL( KMethod() ).WithL(5);    
    
    TPhoneCmdParamRingTone ringToneParam;
    ringToneParam.SetVolume(5);
    ringToneParam.SetRingingType(EProfileRingingTypeBeepOnce);
    // Set the profile ring tone
    TBuf<50> ringingtone(KNokiatune);
    ringToneParam.SetRingTone( ringingtone );
    ringToneParam.SetType( EPhoneRingToneProfile );

    iRingingtoneplayer->PlayRingToneL( &ringToneParam );
    
    EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
    }
void ut_cphoneringingtonecontroller::T_PlayRingingtoneRingingOnce(  )
    {
    TBuf<50> ringingtone(KNokiatune);
    _LIT8( KMethod, "CPhoneRingingtonePlayer::PlayProfileBasedTone" );
    CPhoneRingingTone* aAudioVideoRingingTone = CPhoneRingingTone::NewL(ringingtone);
    aAudioVideoRingingTone->SetRingingType(EProfileRingingTypeRingingOnce);
    aAudioVideoRingingTone->SetTtsToneToBePlayed(EFalse);
    aAudioVideoRingingTone->SetVolume(5);
    iMockContext->ExpectCallL( KMethod() ).WithL(aAudioVideoRingingTone);
    
    TPhoneCmdParamRingTone ringToneParam;
    ringToneParam.SetVolume(5);
    ringToneParam.SetRingingType(EProfileRingingTypeRingingOnce);
    // Set the profile ring tone
    ringToneParam.SetRingTone( ringingtone );
    ringToneParam.SetType( EPhoneRingToneProfile );

    iRingingtoneplayer->PlayRingToneL( &ringToneParam );
    
    EUNIT_ASSERT_EQUALS( KErrNone, iMockContext->VerifyExpectations() );
    delete aAudioVideoRingingTone;
    }
/**
	Checks whether ParamSegment contains valid characters in 
	Parameter name and Parameter value as specified in RFC 3261.
							
	@param		aName	The descriptor for parameter name to be checked as per RFC 3261.
	@param		aValue	The descriptor for value to be checked as per RFC 3261.
	@return		A boolean value of ETrue if uri contains valid parameters and values,
				EFalse if it does not.
*/
TBool TValidatorSip::IsValidParamSegment(const TDesC8& aName, const TDesC8& aValue) const
	{
	if (!aName.Length() || !IsValidParam(aName) ) 
		{
		return EFalse;	
		}
	
	/**************************************************************************************************************
	* As per RFC 3261 if the uri-parameter contains name as Tranport or User or Method then its Value must be     *
	* the characters as specified in Token. else if the name is Ttl then its value must lie in between 0 - 255.   *
	* else if the name is Maddr then its value must be a host, else if the name is lr then it must not conatin    *
	* any value, else it must be a other-parameter whose value must conatin the characters specified in paramchar.*
	* As per INC 115503 and due to IOP issue Validation of lr paramater is not performed.						  *
	***************************************************************************************************************/
	if ( ( (aName.CompareF(KTransport()) == 0 || aName.CompareF(KUser()) == 0 || aName.CompareF(KMethod()) == 0 ) 	
	   	   	  && !IsValidParamToken(aValue) )
		|| ( aName.CompareF(KTtl()) == 0 && !IsValidParamTtl(aValue) )
		|| ( aName.CompareF(KMaddr()) == 0  && !IsValidParamMaddr(aValue) )
		|| ( aName.CompareF(KTransport()) != 0 && aName.CompareF(KUser()) != 0 && aName.CompareF(KMethod()) != 0 && aName.CompareF(KTtl()) != 0 
			&& aName.CompareF(KMaddr()) != 0 && aName.CompareF(KLr()) != 0 && !IsValidParam(aValue))
		)
		{
		return EFalse;	
		}

	return ETrue;
	}
void CHttpClientTestParams::ConstructL(CTestStep& aTestCase)
    {
    TPtrC method;
    TPtrC uri;
    TPtrC rawRequest;
    TPtrC rawResponse;
    TPtrC rawEncodedAuthenticationRequest;
    TPtrC rawFinalResponse;
    if(!aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KMethod(), method) || 
            !aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KUri(), uri) ||
             !aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), KStatusCode(), iStatusCode))
        {
        User::Leave(KErrCorrupt);
        }
    aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawRequest(), rawRequest);
    aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawResponse(), rawResponse);
    aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawEncodedAuthenticationRequest(), rawEncodedAuthenticationRequest);
    aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRawFinalResponse(), rawFinalResponse);
    
    iMethod = EscapeUtils::ConvertFromUnicodeToUtf8L(method);
    iUri = EscapeUtils::ConvertFromUnicodeToUtf8L(uri);
    iRawRequest = EscapeUtils::ConvertFromUnicodeToUtf8L(rawRequest);
    iRawResponse = EscapeUtils::ConvertFromUnicodeToUtf8L(rawResponse);
    iEncodedAuthenticationRequest = EscapeUtils::ConvertFromUnicodeToUtf8L(rawEncodedAuthenticationRequest);
    iFinalResponse = EscapeUtils::ConvertFromUnicodeToUtf8L(rawFinalResponse);
       
    ParseAndReplaceCRLF(iRawRequest);
    ParseAndReplaceCRLF(iRawResponse);
    ParseAndReplaceCRLF(iEncodedAuthenticationRequest);
    ParseAndReplaceCRLF(iFinalResponse);

    
    
    TPtrC responseBody;
    if(aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KResponseBody(), responseBody))
        {
        iResponseBody = EscapeUtils::ConvertFromUnicodeToUtf8L(responseBody);
        }
    
    TPtrC requestBody;
    if(aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRequestBody(), requestBody))
        {
        iRequestBody = EscapeUtils::ConvertFromUnicodeToUtf8L(requestBody);
        }
    
    
    // Now read the headers
    // Read the number of headers
    TInt responseHeaderCount = 0;
    aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), KResponseFieldCount(), responseHeaderCount);
    for(TInt i = 0; i < responseHeaderCount; ++i)
        {
        CHeaderInfo* headerInfo = new(ELeave) CHeaderInfo;
        CleanupStack::PushL(headerInfo);
        TBuf<32> headerFormat;
        headerFormat.Format(KHeader(), i + 1);
        TPtrC headerName;
        aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), headerFormat, headerName);
        headerInfo->iFieldName = EscapeUtils::ConvertFromUnicodeToUtf8L(headerName);
        TInt headerValueCount = 0;        
        TBuf<32> headerValueCountStr;
        headerValueCountStr.Format(KHeaderValueCount(), i + 1);        
        aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), headerValueCountStr, headerValueCount);        
        for(TInt j = 0; j < headerValueCount; ++j)
            {
            TBuf<32> headerValueFormat;
            headerValueFormat.Format(KHeaderValue(), i + 1, j+ 1);
            TPtrC headerValue;
            aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), headerValueFormat, headerValue);
            CHeaderFieldInfo* fieldInfo = new(ELeave) CHeaderFieldInfo;
            CleanupStack::PushL(fieldInfo);
            fieldInfo->iFieldValue = EscapeUtils::ConvertFromUnicodeToUtf8L(headerValue);
            
            // Check this field has params.
            TBuf<32> headerFieldParamCount;
            headerFieldParamCount.Format(KFieldParamCount(), i + 1, j + 1);
            TInt paramCount = 0;
            aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), headerFieldParamCount, paramCount);
            for(TInt k = 0; k < paramCount; ++k)
                {
                TBuf<48> fieldParamName;
                TBuf<48> fieldParamValue;
                fieldParamName.Format(KFieldParamName, i + 1, j + 1, k + 1);
                fieldParamValue.Format(KFieldParamValue, i + 1, j + 1, k + 1);             
                TPtrC paramName;
                TPtrC paramValue;
                aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), fieldParamName, paramName);
                aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), fieldParamValue, paramValue);
                CHeaderFieldParamInfo* paramInfo = new(ELeave) CHeaderFieldParamInfo;
                CleanupStack::PushL(paramInfo);
                paramInfo->iParamName = EscapeUtils::ConvertFromUnicodeToUtf8L(paramName);
                paramInfo->iParamValue = EscapeUtils::ConvertFromUnicodeToUtf8L(paramValue);                
                fieldInfo->iFieldParamInfos.AppendL(paramInfo);
                CleanupStack::Pop(); // paramInfo                
                }
            
            headerInfo->iFieldInfos.AppendL(fieldInfo); 
            CleanupStack::Pop(); // fieldInfo
            }        
        // Check if the header has some params
        TBuf<48> headerParamCount;
        headerParamCount.Format(KHeaderParamCount(), i + 1);
        TInt hdrParamCount = 0;
        aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), headerParamCount, hdrParamCount);   
        for(TInt x = 0; x < hdrParamCount; ++x)
            {
            TBuf<48> headerParamName;
            TBuf<48> headerParamValue;
            headerParamName.Format(KHeaderParamName(), i + 1, x + 1);
            headerParamValue.Format(KHeaderParamValue(), i + 1, x + 1);
            TPtrC paramName;
            TPtrC paramValue;
            aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), headerParamName, paramName);
            aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), headerParamValue, paramValue);
            CHeaderFieldParamInfo* paramInfo = new (ELeave) CHeaderFieldParamInfo;
            CleanupStack::PushL(paramInfo);
            paramInfo->iParamName = EscapeUtils::ConvertFromUnicodeToUtf8L(paramName);
            paramInfo->iParamValue = EscapeUtils::ConvertFromUnicodeToUtf8L(paramValue);
            headerInfo->iParamInfos.AppendL(paramInfo);
            CleanupStack::Pop(); // paramInfo
            }
        iResponseHeaderInfos.AppendL(headerInfo);
        CleanupStack::Pop(); // headerInfo
        }

    TPtrC fileName;
    aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KResponseFileName(), fileName);
    if(fileName.Length() > 0)
        {
        iFileSender = CFileSender::NewL(fileName);        
        aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KResponseFileNameStore(), fileName);
        if(fileName.Length() == 0)
            {
            User::Leave(KErrCorrupt);
            }
        iFileReceiver = CFileReceiver::NewL(fileName);
        }

    
    TPtrC ulFileName;
    aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRequestFileName(), ulFileName);
    if(ulFileName.Length() > 0)
        {
        iFileSender = CFileSender::NewL(ulFileName);
        aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KRequestFileNameStore(), ulFileName);
        if(ulFileName.Length() == 0)
             {
             User::Leave(KErrCorrupt);
             }
         iFileReceiver = CFileReceiver::NewL(ulFileName);        
        }
    
    // Read request headers 
     TInt reqFieldCount = 0;
    aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), KRequestFieldCount(), reqFieldCount);
    
    for(TInt ii = 0; ii < reqFieldCount; ++ii)
        {
        // Read the request header
        TBuf<64> reqHeaderStr;
        reqHeaderStr.Format(KRequestHeader(), ii + 1);
        TPtrC reqHeaderName;
        aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), reqHeaderStr, reqHeaderName);
        CHeaderInfo* headerInfo = new(ELeave) CHeaderInfo;
        CleanupStack::PushL(headerInfo);
        headerInfo->iFieldName = EscapeUtils::ConvertFromUnicodeToUtf8L(reqHeaderName);
        
        // Now read how many fields are present
        reqHeaderStr.Format(KRequestHeaderValueCount(), ii + 1);
        TInt reqHdrValueCount = 0;
        aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), reqHeaderStr, reqHdrValueCount);
        for(TInt jj = 0; jj < reqHdrValueCount; ++jj)
            {
            TPtrC reqHeaderVal;
            reqHeaderStr.Format(KRequestHeaderValue(), ii + 1, jj + 1);
            aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), reqHeaderStr, reqHeaderVal);
            CHeaderFieldInfo* info = new (ELeave) CHeaderFieldInfo;
            CleanupStack::PushL(info);
            info->iFieldValue = EscapeUtils::ConvertFromUnicodeToUtf8L(reqHeaderVal);
            reqHeaderStr.Format(KRequestHeaderValueParamCount, ii + 1, jj + 1);
            TInt paramCount = 0;
            aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), reqHeaderStr, paramCount);
            for(TInt kk = 0; kk < paramCount; ++kk)
                {
                reqHeaderStr.Format(KRequestHeaderValueParamName(), ii + 1, jj + 1, kk + 1);
                TPtrC name;
                TPtrC value;
                aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), reqHeaderStr, name);
                reqHeaderStr.Format(KRequestHeaderValueParamValue(), ii + 1, jj + 1, kk + 1);
                aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), reqHeaderStr, value);
                
                CHeaderFieldParamInfo* paramInfo = new (ELeave) CHeaderFieldParamInfo;
                CleanupStack::PushL(paramInfo);
                paramInfo->iParamName = EscapeUtils::ConvertFromUnicodeToUtf8L(name);
                paramInfo->iParamValue = EscapeUtils::ConvertFromUnicodeToUtf8L(value);
                info->iFieldParamInfos.AppendL(paramInfo);
                CleanupStack::Pop(); // CHeaderFieldParamInfo
                }
            headerInfo->iFieldInfos.AppendL(info);
            CleanupStack::Pop(); // info
            }
        
        iRequestHeaderInfos.AppendL(headerInfo);
        CleanupStack::Pop();      
        }         
    
    iConnDisconnect = EFalse;
    aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KConnDisconnect(), iConnDisconnect);
    
    iExpectedError = KErrNone;    
    aTestCase.GetIntFromConfig(aTestCase.ConfigSection(), KExpectedError(), iExpectedError);
    
    iNoRetryOnDisconnect = EFalse;
    aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KNoRetryOnDisconnect(), iNoRetryOnDisconnect);
    
    iResponseDynamicAndStatic = EFalse;
    aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KResponseDynamicAndStatic(), iResponseDynamicAndStatic);
    
    iOnlineTest = EFalse;
    aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KOnlineTest(), iOnlineTest);
        
    iRedirection = EFalse;
    aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KRedirection(), iRedirection);
   
    iResponseTimeout = EFalse;
    aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KResponseTimeout(), iResponseTimeout);
    
    iNotifyTransferProgress = EFalse;
    aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KNotifyTransferProgress(), iNotifyTransferProgress);
    
    iSetAuthentication = EFalse;
    aTestCase.GetBoolFromConfig(aTestCase.ConfigSection(), KSetAuthentication(), iSetAuthentication);
    
    TPtrC proxyAddress;
    if(aTestCase.GetStringFromConfig(aTestCase.ConfigSection(), KProxyAddress, proxyAddress))
        {
        iProxyAddress = EscapeUtils::ConvertFromUnicodeToUtf8L(proxyAddress);
        }
    }