78
|
1 |
|
|
2 |
#include <eunitmacros.h>
|
|
3 |
#include <eunitdecorators.h>
|
|
4 |
|
|
5 |
#include "tphonecmdparamringtone.h"
|
|
6 |
#include <phoneui.pan>
|
|
7 |
#include "mt_phoneringingtoneplayer.h"
|
|
8 |
#include <profile.hrh>
|
|
9 |
|
|
10 |
|
|
11 |
const TTimeIntervalMicroSeconds32 KInitDelay( 7000000 );
|
|
12 |
|
|
13 |
const TTimeIntervalMicroSeconds32 KPlayDelay( 1000000 );
|
|
14 |
|
|
15 |
const TTimeIntervalMicroSeconds32 KDelayToPlaybackInitPhase( 1000000 );
|
|
16 |
|
|
17 |
const TInt KPhoneRingingRepeatsTrailPause = 1000000;
|
|
18 |
const TInt KPhoneMdaAudioToneRepeatForever = -2;
|
|
19 |
|
|
20 |
|
|
21 |
_LIT( KTestDefaultTone, "z:\\data\\sounds\\digital\\Nokia tune.aac" );
|
|
22 |
|
|
23 |
_LIT( KRandomSample, "z:\\data\\sounds\\gee.mp3" );
|
|
24 |
|
|
25 |
_LIT( KRandomTone, "z:\\data\\sounds\\ring.rng" );
|
|
26 |
|
|
27 |
|
|
28 |
_LIT8( KPhoneNoSoundSequence, "\x00\x11\x06\x05\xFC\x0A\x08\x40\x32\x0A\xF7\x40\x64\x06\x0B" );
|
|
29 |
//_LIT8( KPhoneBeepSequence, "\x00\x11\x0A\x0A\x08\x73\x0A\x40\x28\x0A\xF7\x05\xFC\x40\x64\x0A\x08\x40\x32\x0A\xF7\x06\x0B" );
|
|
30 |
|
|
31 |
|
|
32 |
MT_PhoneRingingTonePlayer* MT_PhoneRingingTonePlayer::NewL()
|
|
33 |
{
|
|
34 |
MT_PhoneRingingTonePlayer* self = MT_PhoneRingingTonePlayer::NewLC();
|
|
35 |
CleanupStack::Pop();
|
|
36 |
return self;
|
|
37 |
}
|
|
38 |
|
|
39 |
MT_PhoneRingingTonePlayer* MT_PhoneRingingTonePlayer::NewLC()
|
|
40 |
{
|
|
41 |
MT_PhoneRingingTonePlayer* self = new( ELeave ) MT_PhoneRingingTonePlayer();
|
|
42 |
CleanupStack::PushL( self );
|
|
43 |
self->ConstructL();
|
|
44 |
return self;
|
|
45 |
}
|
|
46 |
|
|
47 |
|
|
48 |
MT_PhoneRingingTonePlayer::~MT_PhoneRingingTonePlayer()
|
|
49 |
{
|
|
50 |
Teardown();
|
|
51 |
}
|
|
52 |
|
|
53 |
|
|
54 |
MT_PhoneRingingTonePlayer::MT_PhoneRingingTonePlayer()
|
|
55 |
{
|
|
56 |
|
|
57 |
}
|
|
58 |
|
|
59 |
void MT_PhoneRingingTonePlayer::ConstructL()
|
|
60 |
{
|
|
61 |
CEUnitTestSuiteClass::ConstructL();
|
|
62 |
}
|
|
63 |
|
|
64 |
|
|
65 |
void MT_PhoneRingingTonePlayer::SetupL()
|
|
66 |
{
|
|
67 |
iClient.Connect();
|
|
68 |
}
|
|
69 |
|
|
70 |
|
|
71 |
void MT_PhoneRingingTonePlayer::Teardown()
|
|
72 |
{
|
|
73 |
CMdaAudioPlayerUtility::ResetTestData();
|
|
74 |
CMdaAudioToneUtility::ResetTestData();
|
|
75 |
iClient.Close();
|
|
76 |
User::After( KInitDelay );
|
|
77 |
}
|
|
78 |
|
|
79 |
void MT_PhoneRingingTonePlayer::EmptySetupL()
|
|
80 |
{
|
|
81 |
|
|
82 |
}
|
|
83 |
|
|
84 |
void MT_PhoneRingingTonePlayer::EmptyTeardown()
|
|
85 |
{
|
|
86 |
|
|
87 |
}
|
|
88 |
|
|
89 |
void MT_PhoneRingingTonePlayer::MT_Empty()
|
|
90 |
{
|
|
91 |
|
|
92 |
}
|
|
93 |
void MT_PhoneRingingTonePlayer::MT_CreateServerInstanceAndConnectL()
|
|
94 |
{
|
|
95 |
RPhoneToneClient client;
|
|
96 |
TInt error = client.Connect();
|
|
97 |
User::After( KInitDelay );
|
|
98 |
EUNIT_ASSERT_EQUALS( KErrNone, error );
|
|
99 |
CMdaAudioPlayerUtility::ResetTestData();
|
|
100 |
CMdaAudioToneUtility::ResetTestData();
|
|
101 |
client.Close();
|
|
102 |
|
|
103 |
}
|
|
104 |
|
|
105 |
void MT_PhoneRingingTonePlayer::MT_CreateServerInstanceAndConnectTwiceL() // Inter-process communication fuzzing ( IPC - fuzz )
|
|
106 |
{
|
|
107 |
// SetupL creates a server instance and connects to it.
|
|
108 |
RPhoneToneClient client;
|
|
109 |
TInt error = client.Connect();
|
|
110 |
User::After( KInitDelay );
|
|
111 |
// Assert if server accepts multiple connections.
|
|
112 |
// Server should be uniquely connectable.
|
|
113 |
EUNIT_ASSERT_EQUALS( KErrNone != error, ETrue );
|
|
114 |
|
|
115 |
if ( !error )
|
|
116 |
{
|
|
117 |
client.Close();
|
|
118 |
}
|
|
119 |
}
|
|
120 |
|
|
121 |
void MT_PhoneRingingTonePlayer::MT_PlayDefaultL()
|
|
122 |
{
|
|
123 |
User::After( KInitDelay );
|
|
124 |
TInt randomVolume( 8 );
|
|
125 |
TPhoneCmdParamRingTone ringToneParam;
|
|
126 |
ringToneParam.SetVolume( randomVolume );
|
|
127 |
ringToneParam.SetRingingType( EProfileRingingTypeRinging );
|
|
128 |
iClient.PlayRingingToneL( &ringToneParam );
|
|
129 |
User::After( KInitDelay );
|
|
130 |
HBufC* tonePath = HBufC::NewL( KTestDefaultTone().Length() );
|
|
131 |
*tonePath = KTestDefaultTone();
|
|
132 |
CleanupStack::PushL( tonePath );
|
|
133 |
CTestFunctionCallData* data1 = CTestFunctionCallData::NewL(
|
|
134 |
CMdaAudioPlayerUtility::EPlay,
|
|
135 |
tonePath, 0, 0 ); // Transfer tonePath ownership
|
|
136 |
CleanupStack::Pop( tonePath );
|
|
137 |
CleanupStack::PushL( data1 );
|
|
138 |
CTestFunctionCallData* data2 = CTestFunctionCallData::NewL(
|
|
139 |
CMdaAudioPlayerUtility::ESetVolume , randomVolume );
|
|
140 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data1 ) , ETrue );
|
|
141 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data2 ) , ETrue );
|
|
142 |
delete data2;
|
|
143 |
CleanupStack::PopAndDestroy( data1 );
|
|
144 |
}
|
|
145 |
|
|
146 |
void MT_PhoneRingingTonePlayer::MT_PlayCustomSampleL()
|
|
147 |
{
|
|
148 |
User::After( KInitDelay );
|
|
149 |
TInt randomVolume( 8 );
|
|
150 |
TPhoneCmdParamRingTone ringToneParam;
|
|
151 |
ringToneParam.SetVolume( randomVolume );
|
|
152 |
ringToneParam.SetRingingType( EProfileRingingTypeRinging );
|
|
153 |
ringToneParam.SetRingTone( KRandomSample() );
|
|
154 |
iClient.PlayRingingToneL( &ringToneParam );
|
|
155 |
//Wait that ringingtone is prepared.
|
|
156 |
User::After( KInitDelay );
|
|
157 |
HBufC* tonePath = HBufC::NewL( KRandomSample().Length() );
|
|
158 |
*tonePath = KRandomSample();
|
|
159 |
CleanupStack::PushL( tonePath );
|
|
160 |
CTestFunctionCallData* data1 = CTestFunctionCallData::NewL(
|
|
161 |
CMdaAudioPlayerUtility::EPlay,
|
|
162 |
tonePath, 0, 0 ); // Transfer tonePath ownership
|
|
163 |
CleanupStack::Pop( tonePath );
|
|
164 |
CleanupStack::PushL( data1 );
|
|
165 |
CTestFunctionCallData* data2 = CTestFunctionCallData::NewL(
|
|
166 |
CMdaAudioPlayerUtility::ESetVolume ,
|
|
167 |
randomVolume );
|
|
168 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data1 ) , ETrue );
|
|
169 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data2 ) , ETrue );
|
|
170 |
delete data2;
|
|
171 |
CleanupStack::PopAndDestroy( data1 );
|
|
172 |
}
|
|
173 |
|
|
174 |
void MT_PhoneRingingTonePlayer::MT_PlayCustomSampleWithDelayL()
|
|
175 |
{
|
|
176 |
User::After( KInitDelay );
|
|
177 |
|
|
178 |
CMdaAudioPlayerUtility::DelayAudioLoading();
|
|
179 |
|
|
180 |
TInt randomVolume( 10 );
|
|
181 |
TPhoneCmdParamRingTone ringToneParam;
|
|
182 |
ringToneParam.SetVolume( randomVolume );
|
|
183 |
ringToneParam.SetRingingType( EProfileRingingTypeRinging );
|
|
184 |
ringToneParam.SetRingTone( KRandomSample() );
|
|
185 |
iClient.PlayRingingToneL( &ringToneParam );
|
|
186 |
User::After( KInitDelay );
|
|
187 |
HBufC* tonePath = HBufC::NewL( KTestDefaultTone().Length() );
|
|
188 |
*tonePath = KTestDefaultTone();
|
|
189 |
CleanupStack::PushL( tonePath );
|
|
190 |
CTestFunctionCallData* data1 = CTestFunctionCallData::NewL(
|
|
191 |
CMdaAudioPlayerUtility::EPlay,
|
|
192 |
tonePath, 0, 0 ); // Transfer tonePath ownership
|
|
193 |
CleanupStack::Pop( tonePath );
|
|
194 |
CleanupStack::PushL( data1 );
|
|
195 |
CTestFunctionCallData* data2 = CTestFunctionCallData::NewL(
|
|
196 |
CMdaAudioPlayerUtility::ESetVolume , randomVolume );
|
|
197 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data1 ) , ETrue );
|
|
198 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data2 ) , ETrue );
|
|
199 |
delete data2;
|
|
200 |
CleanupStack::PopAndDestroy( data1 );
|
|
201 |
}
|
|
202 |
|
|
203 |
// Switch to default playback
|
|
204 |
void MT_PhoneRingingTonePlayer::MT_PlayCustomSampleWithErrorL()
|
|
205 |
{
|
|
206 |
User::After( KInitDelay );
|
|
207 |
|
|
208 |
CMdaAudioPlayerUtility::SimulateErrorInAudioLoading();
|
|
209 |
|
|
210 |
TInt randomVolume( 8 );
|
|
211 |
TPhoneCmdParamRingTone ringToneParam;
|
|
212 |
ringToneParam.SetVolume( randomVolume );
|
|
213 |
ringToneParam.SetRingingType( EProfileRingingTypeRinging );
|
|
214 |
ringToneParam.SetRingTone( KRandomSample() );
|
|
215 |
iClient.PlayRingingToneL( &ringToneParam );
|
|
216 |
User::After( KInitDelay );
|
|
217 |
|
|
218 |
//Error will occur in initialization. Thus default tone should be played.
|
|
219 |
HBufC* tonePath = HBufC::NewL( KTestDefaultTone().Length() );
|
|
220 |
*tonePath = KTestDefaultTone();
|
|
221 |
CleanupStack::PushL( tonePath );
|
|
222 |
CTestFunctionCallData* data1 = CTestFunctionCallData::NewL(
|
|
223 |
CMdaAudioPlayerUtility::EPlay,
|
|
224 |
tonePath, 0, 0 ); // Transfer tonePath ownership
|
|
225 |
CleanupStack::Pop( tonePath );
|
|
226 |
CleanupStack::PushL( data1 );
|
|
227 |
CTestFunctionCallData* data2 = CTestFunctionCallData::NewL(
|
|
228 |
CMdaAudioPlayerUtility::ESetVolume ,
|
|
229 |
randomVolume );
|
|
230 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data1 ) , ETrue );
|
|
231 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data2 ) , ETrue );
|
|
232 |
delete data2;
|
|
233 |
CleanupStack::PopAndDestroy( data1 );
|
|
234 |
}
|
|
235 |
|
|
236 |
// backup timer callback
|
|
237 |
void MT_PhoneRingingTonePlayer::MT_PlayCustomSampleWithDelayAndErrorL()
|
|
238 |
{
|
|
239 |
User::After( KInitDelay );
|
|
240 |
|
|
241 |
CMdaAudioPlayerUtility::DelayAudioLoading();
|
|
242 |
CMdaAudioPlayerUtility::SimulateErrorInAudioLoading();
|
|
243 |
|
|
244 |
TInt randomVolume( 8 );
|
|
245 |
TPhoneCmdParamRingTone ringToneParam;
|
|
246 |
ringToneParam.SetVolume( randomVolume );
|
|
247 |
ringToneParam.SetRingingType( EProfileRingingTypeRinging );
|
|
248 |
ringToneParam.SetRingTone( KRandomSample() );
|
|
249 |
iClient.PlayRingingToneL( &ringToneParam );
|
|
250 |
User::After( KInitDelay );
|
|
251 |
HBufC* tonePath = HBufC::NewL( KTestDefaultTone().Length() );
|
|
252 |
*tonePath = KTestDefaultTone();
|
|
253 |
CleanupStack::PushL( tonePath );
|
|
254 |
CTestFunctionCallData* data1 = CTestFunctionCallData::NewL(
|
|
255 |
CMdaAudioPlayerUtility::EPlay,
|
|
256 |
tonePath, 0, 0 ); // Transfer tonePath ownership
|
|
257 |
CleanupStack::Pop( tonePath );
|
|
258 |
CleanupStack::PushL( data1 );
|
|
259 |
CTestFunctionCallData* data2 = CTestFunctionCallData::NewL(
|
|
260 |
CMdaAudioPlayerUtility::ESetVolume,
|
|
261 |
randomVolume );
|
|
262 |
|
|
263 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data1 ) , ETrue );
|
|
264 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data2 ) , ETrue );
|
|
265 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsOnlyOneCall( CMdaAudioPlayerUtility::EPlay ) , ETrue );
|
|
266 |
delete data2;
|
|
267 |
CleanupStack::PopAndDestroy( data1 );
|
|
268 |
}
|
|
269 |
|
|
270 |
|
|
271 |
/*******************************
|
|
272 |
/ Next tests for rng file type
|
|
273 |
/*******************************/
|
|
274 |
|
|
275 |
void MT_PhoneRingingTonePlayer::MT_PlayCustomToneL()
|
|
276 |
{
|
|
277 |
User::After( KInitDelay );
|
|
278 |
TInt randomVolume( 1 );
|
|
279 |
TPhoneCmdParamRingTone ringToneParam;
|
|
280 |
ringToneParam.SetVolume( randomVolume );
|
|
281 |
ringToneParam.SetRingingType( EProfileRingingTypeRinging );
|
|
282 |
ringToneParam.SetRingTone( KRandomTone() );
|
|
283 |
iClient.PlayRingingToneL( &ringToneParam );
|
|
284 |
User::After( KInitDelay );
|
|
285 |
HBufC* tonePath = HBufC::NewL( KRandomTone().Length() );
|
|
286 |
*tonePath = KRandomTone();
|
|
287 |
CleanupStack::PushL( tonePath );
|
|
288 |
|
|
289 |
CTestFunctionCallData* data1 = CTestFunctionCallData::NewL(
|
|
290 |
CMdaAudioToneUtility::EPrepareToPlayFileSequence, tonePath,0,0 ); // Transfer tonePath ownership
|
|
291 |
|
|
292 |
CleanupStack::Pop( tonePath );
|
|
293 |
|
|
294 |
CleanupStack::PushL( data1 );
|
|
295 |
CTestFunctionCallData* data2 = CTestFunctionCallData::NewL(
|
|
296 |
CMdaAudioToneUtility::EPlay );
|
|
297 |
|
|
298 |
CleanupStack::PushL( data2 );
|
|
299 |
CTestFunctionCallData* data3 = CTestFunctionCallData::NewL(
|
|
300 |
CMdaAudioToneUtility::ESetVolume, randomVolume );
|
|
301 |
/* do repeat check */
|
|
302 |
// KPhoneMdaAudioToneRepeatForever,
|
|
303 |
// TTimeIntervalMicroSeconds( KPhoneRingingRepeatsTrailPause )
|
|
304 |
|
|
305 |
EUNIT_ASSERT_EQUALS( TonePlayerContainsCallData( data1 ) , ETrue );
|
|
306 |
EUNIT_ASSERT_EQUALS( TonePlayerContainsCallData( data2 ) , ETrue );
|
|
307 |
EUNIT_ASSERT_EQUALS( TonePlayerContainsCallData( data3 ) , ETrue );
|
|
308 |
delete data3;
|
|
309 |
CleanupStack::PopAndDestroy( data2 );
|
|
310 |
CleanupStack::PopAndDestroy( data1 );
|
|
311 |
}
|
|
312 |
|
|
313 |
void MT_PhoneRingingTonePlayer::MT_PlayCustomToneWithDelayL()
|
|
314 |
{
|
|
315 |
User::After( KInitDelay );
|
|
316 |
|
|
317 |
CMdaAudioToneUtility::DelayAudioLoading();
|
|
318 |
|
|
319 |
TInt randomVolume( 8 );
|
|
320 |
TPhoneCmdParamRingTone ringToneParam;
|
|
321 |
ringToneParam.SetVolume( randomVolume );
|
|
322 |
ringToneParam.SetRingingType( EProfileRingingTypeRinging );
|
|
323 |
ringToneParam.SetRingTone( KRandomTone() );
|
|
324 |
iClient.PlayRingingToneL( &ringToneParam );
|
|
325 |
User::After( KInitDelay );
|
|
326 |
HBufC* tonePath = HBufC::NewL( KTestDefaultTone().Length() );
|
|
327 |
*tonePath = KTestDefaultTone();
|
|
328 |
CleanupStack::PushL( tonePath );
|
|
329 |
CTestFunctionCallData* data1 = CTestFunctionCallData::NewL(
|
|
330 |
CMdaAudioPlayerUtility::EPlay,
|
|
331 |
tonePath, 0, 0 ); // Transfer tonePath ownership
|
|
332 |
CleanupStack::Pop( tonePath );
|
|
333 |
CleanupStack::PushL( data1 );
|
|
334 |
CTestFunctionCallData* data2 = CTestFunctionCallData::NewL(
|
|
335 |
CMdaAudioPlayerUtility::ESetVolume , randomVolume );
|
|
336 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data1 ) , ETrue );
|
|
337 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data2 ) , ETrue );
|
|
338 |
delete data2;
|
|
339 |
CleanupStack::PopAndDestroy( data1 );
|
|
340 |
}
|
|
341 |
|
|
342 |
void MT_PhoneRingingTonePlayer::MT_PlayCustomToneWithErrorL()
|
|
343 |
{
|
|
344 |
User::After( KInitDelay );
|
|
345 |
|
|
346 |
CMdaAudioToneUtility::SimulateErrorInAudioLoading();
|
|
347 |
|
|
348 |
TInt randomVolume( 4 );
|
|
349 |
TPhoneCmdParamRingTone ringToneParam;
|
|
350 |
ringToneParam.SetVolume( randomVolume );
|
|
351 |
ringToneParam.SetRingingType( EProfileRingingTypeRinging );
|
|
352 |
ringToneParam.SetRingTone( KRandomTone() );
|
|
353 |
iClient.PlayRingingToneL( &ringToneParam );
|
|
354 |
User::After( KInitDelay );
|
|
355 |
HBufC* tonePath = HBufC::NewL( KTestDefaultTone().Length() );
|
|
356 |
*tonePath = KTestDefaultTone();
|
|
357 |
CleanupStack::PushL( tonePath );
|
|
358 |
CTestFunctionCallData* data1 = CTestFunctionCallData::NewL(
|
|
359 |
CMdaAudioPlayerUtility::EPlay, tonePath, 0, 0 ); // Transfer tonePath ownership
|
|
360 |
CleanupStack::Pop( tonePath );
|
|
361 |
CleanupStack::PushL( data1 );
|
|
362 |
CTestFunctionCallData* data2 = CTestFunctionCallData::NewL(
|
|
363 |
CMdaAudioPlayerUtility::ESetVolume, randomVolume );
|
|
364 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data1 ) , ETrue );
|
|
365 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data2 ) , ETrue );
|
|
366 |
delete data2;
|
|
367 |
CleanupStack::PopAndDestroy( data1 );
|
|
368 |
}
|
|
369 |
|
|
370 |
void MT_PhoneRingingTonePlayer::MT_PlayCustomToneWithDelayAndErrorL()
|
|
371 |
{
|
|
372 |
User::After( KInitDelay );
|
|
373 |
|
|
374 |
CMdaAudioToneUtility::DelayAudioLoading();
|
|
375 |
CMdaAudioToneUtility::SimulateErrorInAudioLoading();
|
|
376 |
|
|
377 |
TInt randomVolume( 2 );
|
|
378 |
TPhoneCmdParamRingTone ringToneParam;
|
|
379 |
ringToneParam.SetVolume( randomVolume );
|
|
380 |
ringToneParam.SetRingingType( EProfileRingingTypeRinging );
|
|
381 |
ringToneParam.SetRingTone( KRandomTone() );
|
|
382 |
iClient.PlayRingingToneL( &ringToneParam );
|
|
383 |
User::After( KInitDelay );
|
|
384 |
HBufC* tonePath = HBufC::NewL( KTestDefaultTone().Length() );
|
|
385 |
*tonePath = KTestDefaultTone();
|
|
386 |
|
|
387 |
CleanupStack::PushL( tonePath );
|
|
388 |
CTestFunctionCallData* data1 = CTestFunctionCallData::NewL(
|
|
389 |
CMdaAudioPlayerUtility::EPlay,
|
|
390 |
tonePath, 0, 0 ); // Transfer tonePath ownership
|
|
391 |
CleanupStack::Pop( tonePath );
|
|
392 |
|
|
393 |
CleanupStack::PushL( data1 );
|
|
394 |
CTestFunctionCallData* data2 = CTestFunctionCallData::NewL(
|
|
395 |
CMdaAudioPlayerUtility::ESetVolume , randomVolume );
|
|
396 |
|
|
397 |
CleanupStack::PushL( data2 );
|
|
398 |
|
|
399 |
CTestFunctionCallData* data3 = CTestFunctionCallData::NewL(
|
|
400 |
CMdaAudioToneUtility::ECancelPrepare );
|
|
401 |
|
|
402 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data1 ) , ETrue );
|
|
403 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data2 ) , ETrue );
|
|
404 |
EUNIT_ASSERT_EQUALS( TonePlayerContainsCallData( data3 ) , ETrue );
|
|
405 |
delete data3;
|
|
406 |
CleanupStack::PopAndDestroy( data2 );
|
|
407 |
CleanupStack::PopAndDestroy( data1 );
|
|
408 |
}
|
|
409 |
|
|
410 |
void MT_PhoneRingingTonePlayer::MT_PlayAndStopL()
|
|
411 |
{
|
|
412 |
User::After( KInitDelay );
|
|
413 |
TInt randomVolume( 8 );
|
|
414 |
TPhoneCmdParamRingTone ringToneParam;
|
|
415 |
ringToneParam.SetVolume( randomVolume );
|
|
416 |
ringToneParam.SetRingingType( EProfileRingingTypeRinging );
|
|
417 |
iClient.PlayRingingToneL( &ringToneParam );
|
|
418 |
|
|
419 |
User::After( KInitDelay );
|
|
420 |
|
|
421 |
iClient.StopPlayingL();
|
|
422 |
|
|
423 |
HBufC* tonePath = HBufC::NewL( KTestDefaultTone().Length() );
|
|
424 |
*tonePath = KTestDefaultTone();
|
|
425 |
CleanupStack::PushL( tonePath );
|
|
426 |
CTestFunctionCallData* data1 = CTestFunctionCallData::NewL(
|
|
427 |
CMdaAudioPlayerUtility::EPlay,
|
|
428 |
tonePath, 0, 0 ); // Transfer tonePath ownership
|
|
429 |
CleanupStack::Pop( tonePath );
|
|
430 |
CleanupStack::PushL( data1 );
|
|
431 |
CTestFunctionCallData* data2 = CTestFunctionCallData::NewL(
|
|
432 |
CMdaAudioPlayerUtility::ESetVolume , randomVolume );
|
|
433 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data1 ) , ETrue );
|
|
434 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCallData( data2 ) , ETrue );
|
|
435 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCall( CMdaAudioPlayerUtility::EStop ) , ETrue );
|
|
436 |
delete data2;
|
|
437 |
CleanupStack::PopAndDestroy( data1 );
|
|
438 |
}
|
|
439 |
|
|
440 |
void MT_PhoneRingingTonePlayer::MT_PlayAndStopDuringInitL()
|
|
441 |
{
|
|
442 |
User::After( KInitDelay );
|
|
443 |
|
|
444 |
CMdaAudioToneUtility::DelayAudioLoading();
|
|
445 |
|
|
446 |
TInt randomVolume( 8 );
|
|
447 |
TPhoneCmdParamRingTone ringToneParam;
|
|
448 |
ringToneParam.SetVolume( randomVolume );
|
|
449 |
ringToneParam.SetRingTone( KRandomSample() );
|
|
450 |
iClient.PlayRingingToneL( &ringToneParam );
|
|
451 |
User::After( KDelayToPlaybackInitPhase );
|
|
452 |
|
|
453 |
iClient.StopPlayingL();
|
|
454 |
|
|
455 |
User::After( KPlayDelay );
|
|
456 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCall(
|
|
457 |
CMdaAudioPlayerUtility::ENewFilePlayerL ) , ETrue );
|
|
458 |
|
|
459 |
// Shouldn't contain 'Play' call.
|
|
460 |
EUNIT_ASSERT_EQUALS( SamplePlayerContainsCall(
|
|
461 |
CMdaAudioPlayerUtility::EPlay ) , EFalse );
|
|
462 |
}
|
|
463 |
|
|
464 |
void MT_PhoneRingingTonePlayer::MT_PlaySilentL()
|
|
465 |
{
|
|
466 |
User::After( KInitDelay );
|
|
467 |
TPhoneCmdParamRingTone ringToneParam;
|
|
468 |
ringToneParam.SetRingingType( EProfileRingingTypeSilent );
|
|
469 |
iClient.PlayRingingToneL( &ringToneParam );
|
|
470 |
User::After( KPlayDelay );
|
|
471 |
|
|
472 |
HBufC8* sequence( NULL );
|
|
473 |
TRAP_IGNORE( sequence = HBufC8::NewL( KPhoneNoSoundSequence().Length() ) );
|
|
474 |
if ( sequence )
|
|
475 |
{
|
|
476 |
*sequence = KPhoneNoSoundSequence();
|
|
477 |
}
|
|
478 |
|
|
479 |
CTestFunctionCallData* data( NULL );
|
|
480 |
data = CTestFunctionCallData::NewL(
|
|
481 |
CMdaAudioToneUtility::EPrepareToPlayDesSequence, sequence );
|
|
482 |
|
|
483 |
CleanupStack::PushL( data );
|
|
484 |
CTestFunctionCallData* data1( NULL );
|
|
485 |
data1 = CTestFunctionCallData::NewL( CMdaAudioToneUtility::EPlay );
|
|
486 |
|
|
487 |
EUNIT_ASSERT_EQUALS( TonePlayerContainsCallData( data1 ) , ETrue );
|
|
488 |
EUNIT_ASSERT_EQUALS( TonePlayerContainsCallData( data ), ETrue );
|
|
489 |
delete data1;
|
|
490 |
CleanupStack::PopAndDestroy( data );
|
|
491 |
}
|
|
492 |
|
|
493 |
//*******************
|
|
494 |
/* End of test cases
|
|
495 |
********************/
|
|
496 |
|
|
497 |
|
|
498 |
|
|
499 |
TBool MT_PhoneRingingTonePlayer::SamplePlayerContainsCall( CMdaAudioPlayerUtility::TFunctionCall aCall )
|
|
500 |
{
|
|
501 |
RPointerArray< CTestFunctionCallData >& array = CMdaAudioPlayerUtility::TestData();
|
|
502 |
TBool found( EFalse );
|
|
503 |
for( TInt i( 0 ); i < array.Count(); i++ )
|
|
504 |
{
|
|
505 |
CTestFunctionCallData* ptr = array[ i ];
|
|
506 |
if ( ptr->FunctionIndex() == aCall )
|
|
507 |
{
|
|
508 |
found = ETrue;
|
|
509 |
i = array.Count();
|
|
510 |
}
|
|
511 |
}
|
|
512 |
return found;
|
|
513 |
}
|
|
514 |
|
|
515 |
TBool MT_PhoneRingingTonePlayer::SamplePlayerContainsCallData(
|
|
516 |
CTestFunctionCallData* aData )
|
|
517 |
{
|
|
518 |
if ( !aData )
|
|
519 |
{
|
|
520 |
return EFalse;
|
|
521 |
}
|
|
522 |
|
|
523 |
RPointerArray< CTestFunctionCallData >& array = CMdaAudioPlayerUtility::TestData();
|
|
524 |
TBool found( EFalse );
|
|
525 |
for( TInt i( 0 ); i < array.Count(); i++ )
|
|
526 |
{
|
|
527 |
CTestFunctionCallData* ptr = array[ i ];
|
|
528 |
if ( ( *ptr ) == *aData )
|
|
529 |
{
|
|
530 |
found = ETrue;
|
|
531 |
i = array.Count();
|
|
532 |
}
|
|
533 |
}
|
|
534 |
return found;
|
|
535 |
}
|
|
536 |
|
|
537 |
TBool MT_PhoneRingingTonePlayer::SamplePlayerContainsOnlyOneCall(
|
|
538 |
CMdaAudioPlayerUtility::TFunctionCall aCall )
|
|
539 |
{
|
|
540 |
TInt count( 0 );
|
|
541 |
for( TInt i( 0 ); i < CMdaAudioPlayerUtility::TestData().Count(); i++ )
|
|
542 |
{
|
|
543 |
if ( CMdaAudioPlayerUtility::TestData()[ i ]->FunctionIndex() == aCall )
|
|
544 |
{
|
|
545 |
count++;
|
|
546 |
}
|
|
547 |
}
|
|
548 |
return ( 1 == count );
|
|
549 |
}
|
|
550 |
|
|
551 |
TBool MT_PhoneRingingTonePlayer::TonePlayerContainsOnlyOneCall( CMdaAudioToneUtility::TFunctionCall aCall )
|
|
552 |
{
|
|
553 |
TInt count( 0 );
|
|
554 |
for( TInt i( 0 ); i < CMdaAudioToneUtility::TestData().Count(); i++ )
|
|
555 |
{
|
|
556 |
if ( CMdaAudioToneUtility::TestData()[ i ]->FunctionIndex() == aCall )
|
|
557 |
{
|
|
558 |
count++;
|
|
559 |
}
|
|
560 |
}
|
|
561 |
return ( 1 == count );
|
|
562 |
}
|
|
563 |
|
|
564 |
TBool MT_PhoneRingingTonePlayer::TonePlayerContainsCall(
|
|
565 |
CMdaAudioToneUtility::TFunctionCall aCall )
|
|
566 |
{
|
|
567 |
RPointerArray< CTestFunctionCallData >& array = CMdaAudioToneUtility::TestData();
|
|
568 |
TBool found( EFalse );
|
|
569 |
for( TInt i( 0 ); i < array.Count(); i++ )
|
|
570 |
{
|
|
571 |
CTestFunctionCallData* ptr = array[ i ];
|
|
572 |
if ( ptr->FunctionIndex() == aCall )
|
|
573 |
{
|
|
574 |
found = ETrue;
|
|
575 |
i = array.Count();
|
|
576 |
}
|
|
577 |
}
|
|
578 |
return found;
|
|
579 |
}
|
|
580 |
|
|
581 |
TBool MT_PhoneRingingTonePlayer::TonePlayerContainsCallData(
|
|
582 |
CTestFunctionCallData* aData )
|
|
583 |
{
|
|
584 |
if ( !aData )
|
|
585 |
{
|
|
586 |
return EFalse;
|
|
587 |
}
|
|
588 |
RPointerArray< CTestFunctionCallData >& array = CMdaAudioToneUtility::TestData();
|
|
589 |
TBool found( EFalse );
|
|
590 |
for( TInt i( 0 ); i < array.Count(); i++ )
|
|
591 |
{
|
|
592 |
CTestFunctionCallData* ptr = array[ i ];
|
|
593 |
if ( ( *ptr ) == *aData )
|
|
594 |
{
|
|
595 |
found = ETrue;
|
|
596 |
i = array.Count();
|
|
597 |
}
|
|
598 |
}
|
|
599 |
return found;
|
|
600 |
}
|
|
601 |
|
|
602 |
|
|
603 |
|
|
604 |
///////////////////////////////////////////////////////////////////////////////////
|
|
605 |
//// TEST TABLE
|
|
606 |
///////////////////////////////////////////////////////////////////////////////////
|
|
607 |
EUNIT_BEGIN_TEST_TABLE(
|
|
608 |
MT_PhoneRingingTonePlayer,
|
|
609 |
"Add test suite description here.",
|
|
610 |
"MODULE" )
|
|
611 |
|
|
612 |
|
|
613 |
// EUNIT_TEST(
|
|
614 |
// "PTP:Init and connect",
|
|
615 |
// "RPhoneToneClient",
|
|
616 |
// "Connect",
|
|
617 |
// "FUNCTIONALITY",
|
|
618 |
// EmptySetupL, MT_Empty, EmptyTeardown )
|
|
619 |
|
|
620 |
EUNIT_TEST(
|
|
621 |
"PTP:Init and connect",
|
|
622 |
"RPhoneToneClient",
|
|
623 |
"Connect",
|
|
624 |
"FUNCTIONALITY",
|
|
625 |
EmptySetupL, MT_CreateServerInstanceAndConnectL, EmptyTeardown )
|
|
626 |
|
|
627 |
|
|
628 |
EUNIT_TEST(
|
|
629 |
"PTP:Init and connect twice",
|
|
630 |
"RPhoneToneClient",
|
|
631 |
"ConnectTwice",
|
|
632 |
"FUNCTIONALITY",
|
|
633 |
SetupL, MT_CreateServerInstanceAndConnectTwiceL, Teardown )
|
|
634 |
|
|
635 |
|
|
636 |
EUNIT_TEST(
|
|
637 |
"PTP:Play default",
|
|
638 |
"RPhoneToneClient",
|
|
639 |
"Play",
|
|
640 |
"FUNCTIONALITY",
|
|
641 |
SetupL, MT_PlayDefaultL, Teardown )
|
|
642 |
|
|
643 |
|
|
644 |
EUNIT_TEST(
|
|
645 |
"PTP:Play custom sample",
|
|
646 |
"RPhoneToneClient",
|
|
647 |
"Play",
|
|
648 |
"FUNCTIONALITY",
|
|
649 |
SetupL, MT_PlayCustomSampleL, Teardown )
|
|
650 |
|
|
651 |
|
|
652 |
EUNIT_TEST(
|
|
653 |
"PTP:Play custom sample with delay",
|
|
654 |
"RPhoneToneClient",
|
|
655 |
"Play",
|
|
656 |
"FUNCTIONALITY",
|
|
657 |
SetupL, MT_PlayCustomSampleWithDelayL, Teardown )
|
|
658 |
|
|
659 |
|
|
660 |
EUNIT_TEST(
|
|
661 |
"PTP:Play tone with error init",
|
|
662 |
"RPhoneToneClient",
|
|
663 |
"PlayWithError",
|
|
664 |
"FUNCTIONALITY",
|
|
665 |
SetupL, MT_PlayCustomSampleWithErrorL, Teardown )
|
|
666 |
|
|
667 |
|
|
668 |
EUNIT_TEST(
|
|
669 |
"PTP:Play tone with delayed init and error",
|
|
670 |
"RPhoneToneClient",
|
|
671 |
"PlayWithDelay",
|
|
672 |
"FUNCTIONALITY",
|
|
673 |
SetupL, MT_PlayCustomSampleWithDelayAndErrorL, Teardown )
|
|
674 |
|
|
675 |
|
|
676 |
EUNIT_TEST(
|
|
677 |
"PTP:Play custom tone",
|
|
678 |
"RPhoneToneClient",
|
|
679 |
"PlayCustomTone",
|
|
680 |
"FUNCTIONALITY",
|
|
681 |
SetupL, MT_PlayCustomToneL, Teardown )
|
|
682 |
|
|
683 |
|
|
684 |
EUNIT_TEST(
|
|
685 |
"PTP:Play custom tone with delayed init",
|
|
686 |
"RPhoneToneClient",
|
|
687 |
"PlayCustomToneWithDelay",
|
|
688 |
"FUNCTIONALITY",
|
|
689 |
SetupL, MT_PlayCustomToneWithDelayL, Teardown )
|
|
690 |
|
|
691 |
|
|
692 |
EUNIT_TEST(
|
|
693 |
"PTP:Play tone with error",
|
|
694 |
"RPhoneToneClient",
|
|
695 |
"PlayCustomToneWithError",
|
|
696 |
"FUNCTIONALITY",
|
|
697 |
SetupL, MT_PlayCustomToneWithErrorL, Teardown )
|
|
698 |
|
|
699 |
|
|
700 |
EUNIT_TEST(
|
|
701 |
"PTP:Play custom tone with delay and error",
|
|
702 |
"RPhoneToneClient",
|
|
703 |
"PlayCustomToneWithDelayAndError",
|
|
704 |
"FUNCTIONALITY",
|
|
705 |
SetupL, MT_PlayCustomToneWithDelayAndErrorL, Teardown )
|
|
706 |
|
|
707 |
|
|
708 |
EUNIT_TEST(
|
|
709 |
"PTP:Play tone and stop",
|
|
710 |
"RPhoneToneClient",
|
|
711 |
"PlayAndStop",
|
|
712 |
"FUNCTIONALITY",
|
|
713 |
SetupL, MT_PlayAndStopL, Teardown )
|
|
714 |
|
|
715 |
|
|
716 |
EUNIT_TEST(
|
|
717 |
"PTP:Play tone and stop during playback init",
|
|
718 |
"RPhoneToneClient",
|
|
719 |
"PlayAndStop",
|
|
720 |
"FUNCTIONALITY",
|
|
721 |
SetupL, MT_PlayAndStopDuringInitL, Teardown )
|
|
722 |
|
|
723 |
|
|
724 |
EUNIT_TEST(
|
|
725 |
"PTP:Play silent tone",
|
|
726 |
"RPhoneToneClient",
|
|
727 |
"PlaySilent",
|
|
728 |
"FUNCTIONALITY",
|
|
729 |
SetupL, MT_PlaySilentL, Teardown )
|
|
730 |
|
|
731 |
|
|
732 |
EUNIT_END_TEST_TABLE
|
|
733 |
|
|
734 |
// End of file
|