sl@0
|
1 |
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// This program is designed the test of the MMF_ACLNT.
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
/**
|
sl@0
|
19 |
@file OpenFileByHandle_PlayTone.cpp
|
sl@0
|
20 |
*/
|
sl@0
|
21 |
|
sl@0
|
22 |
#include "OpenFileByHandle_PlayTone.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
//const TInt KHeapSizeToneTestEKA2 = 128000; // Heapsize for tone tests on EKA2
|
sl@0
|
25 |
|
sl@0
|
26 |
//------------------------------------------------------------------
|
sl@0
|
27 |
|
sl@0
|
28 |
/**
|
sl@0
|
29 |
* Constructor
|
sl@0
|
30 |
*/
|
sl@0
|
31 |
CTestMmfAclntOpenToneFile::CTestMmfAclntOpenToneFile(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
|
sl@0
|
32 |
: CTestMmfAclntTone(aTestName)
|
sl@0
|
33 |
{
|
sl@0
|
34 |
// store the name of this test case
|
sl@0
|
35 |
// this is the name that is used by the script file
|
sl@0
|
36 |
// Each test step initialises it's own name
|
sl@0
|
37 |
iSectName = aSectName;
|
sl@0
|
38 |
iKeyName= aKeyName;
|
sl@0
|
39 |
}
|
sl@0
|
40 |
|
sl@0
|
41 |
CTestMmfAclntOpenToneFile* CTestMmfAclntOpenToneFile::NewL(const TDesC& aTestName, const TDesC& aSectName, const TDesC& aKeyName)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
CTestMmfAclntOpenToneFile* self = new (ELeave) CTestMmfAclntOpenToneFile(aTestName,aSectName,aKeyName);
|
sl@0
|
44 |
return self;
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
TVerdict CTestMmfAclntOpenToneFile::DoTestStepPreambleL()
|
sl@0
|
48 |
{
|
sl@0
|
49 |
TPtrC filename;
|
sl@0
|
50 |
if(!GetStringFromConfig(iSectName, iKeyName, filename))
|
sl@0
|
51 |
{
|
sl@0
|
52 |
return EInconclusive;
|
sl@0
|
53 |
}
|
sl@0
|
54 |
|
sl@0
|
55 |
// Create a sequence file
|
sl@0
|
56 |
TInt length;
|
sl@0
|
57 |
RFs fs;
|
sl@0
|
58 |
|
sl@0
|
59 |
fs.Connect();
|
sl@0
|
60 |
CleanupClosePushL(fs);
|
sl@0
|
61 |
#ifdef __IPC_V2_PRESENT__
|
sl@0
|
62 |
User::LeaveIfError(fs.ShareAuto());
|
sl@0
|
63 |
#else
|
sl@0
|
64 |
User::LeaveIfError(fs.Share(RSessionBase::EExplicitAttach));
|
sl@0
|
65 |
#endif
|
sl@0
|
66 |
RFile file;
|
sl@0
|
67 |
User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
|
sl@0
|
68 |
CleanupClosePushL(file);
|
sl@0
|
69 |
User::LeaveIfError(file.Write(KFixedSequenceData()));
|
sl@0
|
70 |
User::LeaveIfError(file.Size(length));
|
sl@0
|
71 |
CleanupStack::PopAndDestroy(2, &fs);
|
sl@0
|
72 |
|
sl@0
|
73 |
return CTestMmfAclntStep::DoTestStepPreambleL();
|
sl@0
|
74 |
}
|
sl@0
|
75 |
|
sl@0
|
76 |
/**
|
sl@0
|
77 |
* Play a tone file
|
sl@0
|
78 |
*/
|
sl@0
|
79 |
TVerdict CTestMmfAclntOpenToneFile::DoTestStepL( void )
|
sl@0
|
80 |
{
|
sl@0
|
81 |
INFO_PRINTF1( _L("TestTone : Play File"));
|
sl@0
|
82 |
|
sl@0
|
83 |
TVerdict ret = EFail;
|
sl@0
|
84 |
|
sl@0
|
85 |
RFs fs;
|
sl@0
|
86 |
|
sl@0
|
87 |
User::LeaveIfError(fs.Connect());
|
sl@0
|
88 |
CleanupClosePushL(fs);
|
sl@0
|
89 |
User::LeaveIfError(fs.ShareProtected());
|
sl@0
|
90 |
|
sl@0
|
91 |
TPtrC filename;
|
sl@0
|
92 |
if(!GetStringFromConfig(iSectName, iKeyName, filename))
|
sl@0
|
93 |
{
|
sl@0
|
94 |
return EInconclusive;
|
sl@0
|
95 |
}
|
sl@0
|
96 |
|
sl@0
|
97 |
iError = KErrTimedOut;
|
sl@0
|
98 |
// perform test using this file
|
sl@0
|
99 |
CMdaAudioToneUtility* toneUtil = CMdaAudioToneUtility::NewL(*this);
|
sl@0
|
100 |
CleanupStack::PushL(toneUtil);
|
sl@0
|
101 |
|
sl@0
|
102 |
RFile file;
|
sl@0
|
103 |
User::LeaveIfError( file.Open( fs, filename, EFileRead | EFileShareAny ) );
|
sl@0
|
104 |
CleanupClosePushL(file);
|
sl@0
|
105 |
|
sl@0
|
106 |
toneUtil->PrepareToPlayFileSequence(file);
|
sl@0
|
107 |
CleanupStack::PopAndDestroy(&file);
|
sl@0
|
108 |
|
sl@0
|
109 |
// Wait for prepare
|
sl@0
|
110 |
INFO_PRINTF1( _L("Initialise CMdaAudioToneUtility"));
|
sl@0
|
111 |
CActiveScheduler::Start();
|
sl@0
|
112 |
|
sl@0
|
113 |
User::LeaveIfError( file.Open( fs, filename, EFileRead | EFileShareAny ) );
|
sl@0
|
114 |
CleanupClosePushL(file);
|
sl@0
|
115 |
|
sl@0
|
116 |
toneUtil->PrepareToPlayFileSequence(file);
|
sl@0
|
117 |
// Wait for prepare
|
sl@0
|
118 |
INFO_PRINTF1( _L("re-initialise CMdaAudioToneUtility"));
|
sl@0
|
119 |
CActiveScheduler::Start();
|
sl@0
|
120 |
|
sl@0
|
121 |
if(iError == KErrNone)
|
sl@0
|
122 |
{
|
sl@0
|
123 |
ret = DoTestL(toneUtil);
|
sl@0
|
124 |
}
|
sl@0
|
125 |
|
sl@0
|
126 |
if(ret == EFail)
|
sl@0
|
127 |
{
|
sl@0
|
128 |
ERR_PRINTF2( _L("CMdaAudioToneUtility failed with error %d"),iError );
|
sl@0
|
129 |
}
|
sl@0
|
130 |
|
sl@0
|
131 |
CleanupStack::PopAndDestroy(3, &fs);
|
sl@0
|
132 |
|
sl@0
|
133 |
return ret;
|
sl@0
|
134 |
}
|