sl@0
|
1 |
// Copyright (c) 2004-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 |
// Integration tests.
|
sl@0
|
15 |
// This program is designed the test of the MMF_ACLNT.
|
sl@0
|
16 |
//
|
sl@0
|
17 |
//
|
sl@0
|
18 |
|
sl@0
|
19 |
/**
|
sl@0
|
20 |
@file TestPlayerFileSource.cpp
|
sl@0
|
21 |
*/
|
sl@0
|
22 |
|
sl@0
|
23 |
#include "TestPlayerUtils.h"
|
sl@0
|
24 |
#include "TestPlayerFileSource.h"
|
sl@0
|
25 |
|
sl@0
|
26 |
//
|
sl@0
|
27 |
// CTestMmfAclntFileSource
|
sl@0
|
28 |
//
|
sl@0
|
29 |
|
sl@0
|
30 |
/**
|
sl@0
|
31 |
* Constructor
|
sl@0
|
32 |
*/
|
sl@0
|
33 |
CTestMmfAclntFileSource::CTestMmfAclntFileSource(const TDesC& aTestName,const TDesC& aSectName,
|
sl@0
|
34 |
const TDesC& aKeyName,const TBool aPlay,
|
sl@0
|
35 |
const TInt aExpectedError)
|
sl@0
|
36 |
:iPlay (aPlay)
|
sl@0
|
37 |
,iExpectedError (aExpectedError)
|
sl@0
|
38 |
{
|
sl@0
|
39 |
// store the name of this test case
|
sl@0
|
40 |
iTestStepName = aTestName;
|
sl@0
|
41 |
// store the section-name of the ini file
|
sl@0
|
42 |
iSectName = aSectName;
|
sl@0
|
43 |
// store the key-name of the ini file
|
sl@0
|
44 |
iKeyName = aKeyName;
|
sl@0
|
45 |
}
|
sl@0
|
46 |
|
sl@0
|
47 |
/**
|
sl@0
|
48 |
* NewL
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
CTestMmfAclntFileSource* CTestMmfAclntFileSource::NewL(const TDesC& aTestName, const TDesC& aSectName,
|
sl@0
|
51 |
const TDesC& aKeyName,const TBool aPlay,
|
sl@0
|
52 |
const TInt aExpectedError = KErrNone)
|
sl@0
|
53 |
{
|
sl@0
|
54 |
CTestMmfAclntFileSource* self = new (ELeave) CTestMmfAclntFileSource(aTestName,aSectName,aKeyName,aPlay,aExpectedError);
|
sl@0
|
55 |
return self;
|
sl@0
|
56 |
}
|
sl@0
|
57 |
|
sl@0
|
58 |
/**
|
sl@0
|
59 |
* NewLC
|
sl@0
|
60 |
*/
|
sl@0
|
61 |
CTestMmfAclntFileSource* CTestMmfAclntFileSource::NewLC(const TDesC& aTestName, const TDesC& aSectName,
|
sl@0
|
62 |
const TDesC& aKeyName,
|
sl@0
|
63 |
const TBool aPlay,
|
sl@0
|
64 |
const TInt aExpectedError)
|
sl@0
|
65 |
{
|
sl@0
|
66 |
CTestMmfAclntFileSource* self = CTestMmfAclntFileSource::NewL(aTestName,aSectName,aKeyName,aPlay,aExpectedError);
|
sl@0
|
67 |
CleanupStack::PushL(self);
|
sl@0
|
68 |
return self;
|
sl@0
|
69 |
}
|
sl@0
|
70 |
|
sl@0
|
71 |
/**
|
sl@0
|
72 |
* MapcInitComplete
|
sl@0
|
73 |
*/
|
sl@0
|
74 |
void CTestMmfAclntFileSource::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
|
sl@0
|
75 |
{
|
sl@0
|
76 |
iError = aError;
|
sl@0
|
77 |
iDuration = aDuration;
|
sl@0
|
78 |
INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
|
sl@0
|
79 |
CActiveScheduler::Stop();
|
sl@0
|
80 |
}
|
sl@0
|
81 |
|
sl@0
|
82 |
/**
|
sl@0
|
83 |
* MapcPlayComplete
|
sl@0
|
84 |
*/
|
sl@0
|
85 |
void CTestMmfAclntFileSource::MapcPlayComplete(TInt aError)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
iError = aError;
|
sl@0
|
88 |
INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
|
sl@0
|
89 |
CActiveScheduler::Stop();
|
sl@0
|
90 |
}
|
sl@0
|
91 |
|
sl@0
|
92 |
/**
|
sl@0
|
93 |
* Load and initialise an audio file.
|
sl@0
|
94 |
*/
|
sl@0
|
95 |
TVerdict CTestMmfAclntFileSource::DoTestStepL( void )
|
sl@0
|
96 |
{
|
sl@0
|
97 |
INFO_PRINTF1( _L("TestPlayerUtils : File"));
|
sl@0
|
98 |
TVerdict ret = EFail;
|
sl@0
|
99 |
|
sl@0
|
100 |
iError = KErrTimedOut;
|
sl@0
|
101 |
|
sl@0
|
102 |
TBuf<KSizeBuf> filename;
|
sl@0
|
103 |
TPtrC filename1;
|
sl@0
|
104 |
|
sl@0
|
105 |
if(!GetStringFromConfig(iSectName,iKeyName,filename1))
|
sl@0
|
106 |
{
|
sl@0
|
107 |
return EInconclusive;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
GetDriveName(filename);
|
sl@0
|
111 |
filename.Append(filename1);
|
sl@0
|
112 |
|
sl@0
|
113 |
// Create CMdaAudioPlayerUtility Object
|
sl@0
|
114 |
CMdaAudioPlayerUtility* player = NULL;
|
sl@0
|
115 |
player = CMdaAudioPlayerUtility::NewL(*this);
|
sl@0
|
116 |
|
sl@0
|
117 |
// Create TMMFileSource Object
|
sl@0
|
118 |
TMMFileSource filesource(filename);
|
sl@0
|
119 |
player->OpenFileL(filesource);
|
sl@0
|
120 |
|
sl@0
|
121 |
// Wait for initialisation callback
|
sl@0
|
122 |
INFO_PRINTF1(_L("Initialise CMdaAudioPlayerUtility"));
|
sl@0
|
123 |
CActiveScheduler::Start();
|
sl@0
|
124 |
|
sl@0
|
125 |
// Check for expected errors.
|
sl@0
|
126 |
if(iError != KErrNone && (iExpectedError == iError))
|
sl@0
|
127 |
{
|
sl@0
|
128 |
ret = EPass; // all other tests pass
|
sl@0
|
129 |
delete player;
|
sl@0
|
130 |
User::After(KOneSecond); // wait for deletion to shut down devsound
|
sl@0
|
131 |
ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with expected error %d"),iError );
|
sl@0
|
132 |
return ret;
|
sl@0
|
133 |
}
|
sl@0
|
134 |
|
sl@0
|
135 |
// Check for errors (after OPEN).
|
sl@0
|
136 |
if (iError == KErrNone && player != NULL)
|
sl@0
|
137 |
{
|
sl@0
|
138 |
if(iPlay)
|
sl@0
|
139 |
{
|
sl@0
|
140 |
iError = KErrTimedOut;
|
sl@0
|
141 |
player->Play();
|
sl@0
|
142 |
|
sl@0
|
143 |
// Wait for play complete callback
|
sl@0
|
144 |
INFO_PRINTF1(_L("Play CMdaAudioPlayerUtility"));
|
sl@0
|
145 |
CActiveScheduler::Start();
|
sl@0
|
146 |
|
sl@0
|
147 |
// Check for Callback errors
|
sl@0
|
148 |
if(iError == KErrNone)
|
sl@0
|
149 |
{
|
sl@0
|
150 |
ret = EPass;
|
sl@0
|
151 |
}
|
sl@0
|
152 |
}
|
sl@0
|
153 |
else
|
sl@0
|
154 |
{
|
sl@0
|
155 |
ret = EPass;
|
sl@0
|
156 |
}
|
sl@0
|
157 |
}
|
sl@0
|
158 |
|
sl@0
|
159 |
// Clean up activities.
|
sl@0
|
160 |
delete player;
|
sl@0
|
161 |
User::After(KOneSecond); // wait for deletion to shut down devsound
|
sl@0
|
162 |
|
sl@0
|
163 |
// Check for errors (final check).
|
sl@0
|
164 |
if(iError != KErrNone)
|
sl@0
|
165 |
{
|
sl@0
|
166 |
ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d"),iError );
|
sl@0
|
167 |
}
|
sl@0
|
168 |
return ret;
|
sl@0
|
169 |
}
|
sl@0
|
170 |
|
sl@0
|
171 |
//
|
sl@0
|
172 |
// CTestMmfAclntFileHandleSource
|
sl@0
|
173 |
//
|
sl@0
|
174 |
|
sl@0
|
175 |
/**
|
sl@0
|
176 |
* Constructor
|
sl@0
|
177 |
*/
|
sl@0
|
178 |
CTestMmfAclntFileHandleSource::CTestMmfAclntFileHandleSource(const TDesC& aTestName,const TDesC& aSectName,
|
sl@0
|
179 |
const TDesC& aKeyName,const TBool aPlay,
|
sl@0
|
180 |
const TInt aExpectedError)
|
sl@0
|
181 |
:iPlay (aPlay)
|
sl@0
|
182 |
,iExpectedError (aExpectedError)
|
sl@0
|
183 |
{
|
sl@0
|
184 |
// store the name of this test case
|
sl@0
|
185 |
iTestStepName = aTestName;
|
sl@0
|
186 |
// store the section-name of the ini file
|
sl@0
|
187 |
iSectName = aSectName;
|
sl@0
|
188 |
// store the key-name of the ini file
|
sl@0
|
189 |
iKeyName = aKeyName;
|
sl@0
|
190 |
}
|
sl@0
|
191 |
|
sl@0
|
192 |
/**
|
sl@0
|
193 |
* NewL
|
sl@0
|
194 |
*/
|
sl@0
|
195 |
CTestMmfAclntFileHandleSource* CTestMmfAclntFileHandleSource::NewL(const TDesC& aTestName, const TDesC& aSectName,
|
sl@0
|
196 |
const TDesC& aKeyName,const TBool aPlay,
|
sl@0
|
197 |
const TInt aExpectedError = KErrNone)
|
sl@0
|
198 |
{
|
sl@0
|
199 |
CTestMmfAclntFileHandleSource* self = new (ELeave) CTestMmfAclntFileHandleSource(aTestName,aSectName,aKeyName,aPlay,aExpectedError);
|
sl@0
|
200 |
return self;
|
sl@0
|
201 |
}
|
sl@0
|
202 |
|
sl@0
|
203 |
/**
|
sl@0
|
204 |
* NewLC
|
sl@0
|
205 |
*/
|
sl@0
|
206 |
CTestMmfAclntFileHandleSource* CTestMmfAclntFileHandleSource::NewLC(const TDesC& aTestName, const TDesC& aSectName,
|
sl@0
|
207 |
const TDesC& aKeyName,
|
sl@0
|
208 |
const TBool aPlay,
|
sl@0
|
209 |
const TInt aExpectedError)
|
sl@0
|
210 |
{
|
sl@0
|
211 |
CTestMmfAclntFileHandleSource* self = CTestMmfAclntFileHandleSource::NewL(aTestName,aSectName,aKeyName,aPlay,aExpectedError);
|
sl@0
|
212 |
CleanupStack::PushL(self);
|
sl@0
|
213 |
return self;
|
sl@0
|
214 |
}
|
sl@0
|
215 |
|
sl@0
|
216 |
/**
|
sl@0
|
217 |
* MapcInitComplete
|
sl@0
|
218 |
*/
|
sl@0
|
219 |
void CTestMmfAclntFileHandleSource::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds &aDuration)
|
sl@0
|
220 |
{
|
sl@0
|
221 |
iError = aError;
|
sl@0
|
222 |
iDuration = aDuration;
|
sl@0
|
223 |
INFO_PRINTF1( _L("MMdaAudioPlayerCallback Init Complete"));
|
sl@0
|
224 |
CActiveScheduler::Stop();
|
sl@0
|
225 |
}
|
sl@0
|
226 |
|
sl@0
|
227 |
/**
|
sl@0
|
228 |
* MapcPlayComplete
|
sl@0
|
229 |
*/
|
sl@0
|
230 |
void CTestMmfAclntFileHandleSource::MapcPlayComplete(TInt aError)
|
sl@0
|
231 |
{
|
sl@0
|
232 |
iError = aError;
|
sl@0
|
233 |
INFO_PRINTF1( _L("MMdaAudioPlayerCallback Play Complete"));
|
sl@0
|
234 |
CActiveScheduler::Stop();
|
sl@0
|
235 |
}
|
sl@0
|
236 |
|
sl@0
|
237 |
/**
|
sl@0
|
238 |
* Load and initialise an audio file.
|
sl@0
|
239 |
*/
|
sl@0
|
240 |
TVerdict CTestMmfAclntFileHandleSource::DoTestStepL( void )
|
sl@0
|
241 |
{
|
sl@0
|
242 |
INFO_PRINTF1( _L("TestPlayerUtils : File"));
|
sl@0
|
243 |
TVerdict ret = EFail;
|
sl@0
|
244 |
|
sl@0
|
245 |
iError = KErrTimedOut;
|
sl@0
|
246 |
|
sl@0
|
247 |
// Get the file name.
|
sl@0
|
248 |
TBuf<KSizeBuf> filename;
|
sl@0
|
249 |
TPtrC filename1;
|
sl@0
|
250 |
if(!GetStringFromConfig(iSectName,iKeyName,filename1))
|
sl@0
|
251 |
{
|
sl@0
|
252 |
return EInconclusive;
|
sl@0
|
253 |
}
|
sl@0
|
254 |
GetDriveName(filename);
|
sl@0
|
255 |
filename.Append(filename1);
|
sl@0
|
256 |
|
sl@0
|
257 |
// Create CMdaAudioPlayerUtility Object
|
sl@0
|
258 |
CMdaAudioPlayerUtility* player = NULL;
|
sl@0
|
259 |
player = CMdaAudioPlayerUtility::NewL(*this);
|
sl@0
|
260 |
|
sl@0
|
261 |
// Create RFs and RFile Objects
|
sl@0
|
262 |
RFs fs;
|
sl@0
|
263 |
User::LeaveIfError(fs.Connect());
|
sl@0
|
264 |
CleanupClosePushL(fs);
|
sl@0
|
265 |
User::LeaveIfError(fs.ShareProtected());
|
sl@0
|
266 |
|
sl@0
|
267 |
RFile file;
|
sl@0
|
268 |
User::LeaveIfError( file.Open( fs, filename, EFileRead ) );
|
sl@0
|
269 |
CleanupClosePushL(file);
|
sl@0
|
270 |
|
sl@0
|
271 |
// Create TMMFileSource Object
|
sl@0
|
272 |
TMMFileHandleSource filehandlesource(file);
|
sl@0
|
273 |
player->OpenFileL(filehandlesource);
|
sl@0
|
274 |
|
sl@0
|
275 |
// Wait for initialisation callback
|
sl@0
|
276 |
INFO_PRINTF1(_L("CMdaAudioPlayerUtility->OpenFileL(TMMFileHandleSource)"));
|
sl@0
|
277 |
CActiveScheduler::Start();
|
sl@0
|
278 |
|
sl@0
|
279 |
// Check for expected errors.
|
sl@0
|
280 |
if((iError != KErrNone) && (iExpectedError == iError))
|
sl@0
|
281 |
{
|
sl@0
|
282 |
ERR_PRINTF2(_L("CMdaAudioPlayerUtility->OpenFileL() Returned the Expected Error : %d"),iError);
|
sl@0
|
283 |
ret=EPass;
|
sl@0
|
284 |
}
|
sl@0
|
285 |
|
sl@0
|
286 |
// Check for errors.
|
sl@0
|
287 |
if(iError != KErrNone)
|
sl@0
|
288 |
{
|
sl@0
|
289 |
ERR_PRINTF2(_L("CMdaAudioPlayerUtility->OpenFileL() Failed with Error : %d"),iError);
|
sl@0
|
290 |
ret=EFail;
|
sl@0
|
291 |
}
|
sl@0
|
292 |
|
sl@0
|
293 |
// Check for No errors, so as to start Playback
|
sl@0
|
294 |
if (iError == KErrNone && player != NULL)
|
sl@0
|
295 |
{
|
sl@0
|
296 |
if(iPlay)
|
sl@0
|
297 |
{
|
sl@0
|
298 |
iError = KErrTimedOut;
|
sl@0
|
299 |
player->Play();
|
sl@0
|
300 |
|
sl@0
|
301 |
// Wait for play complete callback
|
sl@0
|
302 |
INFO_PRINTF1(_L("CMdaAudioPlayerUtility->Play()"));
|
sl@0
|
303 |
CActiveScheduler::Start();
|
sl@0
|
304 |
|
sl@0
|
305 |
// Check for Callback errors
|
sl@0
|
306 |
if(iError == KErrNone)
|
sl@0
|
307 |
{
|
sl@0
|
308 |
ERR_PRINTF2(_L("CMdaAudioPlayerUtility->Play() completed successfully with return code : %d"),iError);
|
sl@0
|
309 |
ret = EPass;
|
sl@0
|
310 |
}
|
sl@0
|
311 |
else
|
sl@0
|
312 |
{
|
sl@0
|
313 |
ERR_PRINTF2(_L("CMdaAudioPlayerUtility->Play() Failed with Error : %d"),iError );
|
sl@0
|
314 |
ret = EFail;
|
sl@0
|
315 |
}
|
sl@0
|
316 |
}
|
sl@0
|
317 |
else
|
sl@0
|
318 |
{
|
sl@0
|
319 |
ret = EPass;
|
sl@0
|
320 |
}
|
sl@0
|
321 |
}
|
sl@0
|
322 |
|
sl@0
|
323 |
// Clean up activities.
|
sl@0
|
324 |
delete player;
|
sl@0
|
325 |
User::After(KOneSecond); // wait for deletion to shut down devsound
|
sl@0
|
326 |
CleanupStack::PopAndDestroy(2);
|
sl@0
|
327 |
|
sl@0
|
328 |
return ret;
|
sl@0
|
329 |
}
|