mmlibs/mmfw/tsrc/mmfintegrationtest/ACLNT/OpenFileByHandle_PlayTone.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2002-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 // This program is designed the test of the MMF_ACLNT.
       
    15 // 
       
    16 //
       
    17 
       
    18 /**
       
    19  @file OpenFileByHandle_PlayTone.cpp
       
    20 */
       
    21 
       
    22 #include "OpenFileByHandle_PlayTone.h"
       
    23 
       
    24 //const TInt KHeapSizeToneTestEKA2 = 128000; // Heapsize for tone tests on EKA2
       
    25 
       
    26 //------------------------------------------------------------------
       
    27 
       
    28 /**
       
    29  * Constructor
       
    30  */
       
    31 CTestMmfAclntOpenToneFile::CTestMmfAclntOpenToneFile(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
       
    32 	: CTestMmfAclntTone(aTestName)
       
    33 	{
       
    34 	// store the name of this test case
       
    35 	// this is the name that is used by the script file
       
    36 	// Each test step initialises it's own name
       
    37 	iSectName = aSectName;
       
    38 	iKeyName= aKeyName;
       
    39 	}
       
    40 
       
    41 CTestMmfAclntOpenToneFile* CTestMmfAclntOpenToneFile::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
       
    42 	{
       
    43 	CTestMmfAclntOpenToneFile* self = new (ELeave) CTestMmfAclntOpenToneFile(aTestName,aSectName,aKeyName);
       
    44 	return self;
       
    45 	}
       
    46 
       
    47 TVerdict CTestMmfAclntOpenToneFile::DoTestStepPreambleL()
       
    48 	{
       
    49 	TPtrC filename;
       
    50 	if(!GetStringFromConfig(iSectName, iKeyName, filename))
       
    51 		{
       
    52 		return EInconclusive;
       
    53 		}
       
    54 
       
    55 	// Create a sequence file
       
    56 	TInt length;
       
    57 	RFs fs;
       
    58 
       
    59 	fs.Connect();
       
    60 	CleanupClosePushL(fs);
       
    61 #ifdef __IPC_V2_PRESENT__
       
    62 	User::LeaveIfError(fs.ShareAuto());
       
    63 #else
       
    64 	User::LeaveIfError(fs.Share(RSessionBase::EExplicitAttach));
       
    65 #endif
       
    66 	RFile file;
       
    67 	User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
       
    68 	CleanupClosePushL(file);
       
    69 	User::LeaveIfError(file.Write(KFixedSequenceData()));
       
    70 	User::LeaveIfError(file.Size(length));
       
    71 	CleanupStack::PopAndDestroy(2, &fs);
       
    72 
       
    73 	return CTestMmfAclntStep::DoTestStepPreambleL();
       
    74 	}
       
    75 
       
    76 /**
       
    77  * Play a tone file
       
    78  */
       
    79 TVerdict CTestMmfAclntOpenToneFile::DoTestStepL( void )
       
    80 	{
       
    81 	INFO_PRINTF1( _L("TestTone : Play File"));
       
    82 
       
    83 	TVerdict ret = EFail;
       
    84 
       
    85 	RFs fs;
       
    86 
       
    87 	User::LeaveIfError(fs.Connect());
       
    88 	CleanupClosePushL(fs);
       
    89 	User::LeaveIfError(fs.ShareProtected());
       
    90 
       
    91 	TPtrC filename;
       
    92 	if(!GetStringFromConfig(iSectName, iKeyName, filename))
       
    93 		{
       
    94 		return EInconclusive;
       
    95 		}
       
    96 
       
    97 	iError = KErrTimedOut;
       
    98 	// perform test using this file
       
    99 	CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
       
   100 	CleanupStack::PushL(toneUtil);
       
   101 
       
   102 	RFile file;
       
   103 	User::LeaveIfError( file.Open( fs, filename, EFileRead | EFileShareAny ) );
       
   104 	CleanupClosePushL(file);
       
   105 
       
   106 	toneUtil->PrepareToPlayFileSequence(file);
       
   107 	CleanupStack::PopAndDestroy(&file);
       
   108 
       
   109 	// Wait for prepare
       
   110 	INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
       
   111 	CActiveScheduler::Start();
       
   112 
       
   113 	User::LeaveIfError( file.Open( fs, filename, EFileRead | EFileShareAny ) );
       
   114 	CleanupClosePushL(file);
       
   115 
       
   116 	toneUtil->PrepareToPlayFileSequence(file);
       
   117 	// Wait for prepare
       
   118 	INFO_PRINTF1( _L("re-initialise CMdaAudioToneUtility"));
       
   119 	CActiveScheduler::Start();
       
   120 
       
   121 	if(iError == KErrNone)
       
   122 		{
       
   123 		ret = DoTestL(toneUtil);
       
   124 		}
       
   125 
       
   126 	if(ret == EFail)
       
   127 		{
       
   128 		ERR_PRINTF2( _L("CMdaAudioToneUtility failed with error %d"),iError );
       
   129 		}
       
   130 
       
   131 	CleanupStack::PopAndDestroy(3, &fs);
       
   132 
       
   133 	return ret;
       
   134 	}