|
1 |
|
2 // GlobalEffectTest.cpp |
|
3 |
|
4 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
5 // All rights reserved. |
|
6 // This component and the accompanying materials are made available |
|
7 // under the terms of "Eclipse Public License v1.0" |
|
8 // which accompanies this distribution, and is available |
|
9 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
10 // |
|
11 // Initial Contributors: |
|
12 // Nokia Corporation - initial contribution. |
|
13 // |
|
14 // Contributors: |
|
15 // |
|
16 // Description: |
|
17 // |
|
18 |
|
19 #include "GlobalEffectTest.h" |
|
20 #include "TestGlobalEffect.hrh" |
|
21 #include "TestEffect.h" |
|
22 |
|
23 #include <mmfstdglblaudioeffect.h> |
|
24 |
|
25 |
|
26 // |
|
27 // RGlobalEffectPrimitiveTest |
|
28 // |
|
29 |
|
30 RGlobalEffectPrimitiveTest* RGlobalEffectPrimitiveTest::NewL(TBool aAllocTest) |
|
31 { |
|
32 RGlobalEffectPrimitiveTest* self = new (ELeave) RGlobalEffectPrimitiveTest(aAllocTest); |
|
33 return self; |
|
34 } |
|
35 |
|
36 RGlobalEffectPrimitiveTest::RGlobalEffectPrimitiveTest(TBool /*aAllocTest*/) |
|
37 { |
|
38 iTestStepName = _L("MM-MMF-GEF-U-001"); |
|
39 } |
|
40 |
|
41 TVerdict RGlobalEffectPrimitiveTest::DoTestStepL() |
|
42 { |
|
43 INFO_PRINTF1(_L("Check can actually open test GlobalEffect plugin")); |
|
44 TVerdict result = EPass; |
|
45 |
|
46 __MM_HEAP_MARK; |
|
47 |
|
48 CTestGlobalEffect* plugin = NULL; |
|
49 |
|
50 TRAPD(error, plugin = CTestGlobalEffect::NewL(NULL)); |
|
51 |
|
52 if (error==KErrNone) |
|
53 { |
|
54 INFO_PRINTF1(_L("plugin opened as expected")); |
|
55 delete plugin; |
|
56 } |
|
57 else |
|
58 { |
|
59 INFO_PRINTF2(_L("CreateImplementationL() failed - %d"), error); |
|
60 result = EFail; |
|
61 } |
|
62 |
|
63 __MM_HEAP_MARKEND; |
|
64 |
|
65 return result; |
|
66 } |
|
67 |
|
68 // |
|
69 // RGlobalEffectStdTest |
|
70 // |
|
71 |
|
72 RGlobalEffectStdTest* RGlobalEffectStdTest::NewL(TBool aAllocTest) |
|
73 { |
|
74 RGlobalEffectStdTest* self = new (ELeave) RGlobalEffectStdTest(aAllocTest); |
|
75 return self; |
|
76 } |
|
77 |
|
78 RGlobalEffectStdTest::RGlobalEffectStdTest(TBool /*aAllocTest*/) |
|
79 { |
|
80 iTestStepName = _L("MM-MMF-GEF-U-002"); |
|
81 } |
|
82 |
|
83 TVerdict RGlobalEffectStdTest::DoTestStepL() |
|
84 { |
|
85 INFO_PRINTF1(_L("Check standard plugins cleanup return errors")); |
|
86 TVerdict result = EPass; |
|
87 |
|
88 { |
|
89 __MM_HEAP_MARK; |
|
90 |
|
91 CMmfGlobalEqEffect* plugin = NULL; |
|
92 |
|
93 TRAPD(error, plugin = CMmfGlobalEqEffect::NewL(NULL)); |
|
94 |
|
95 if (error==KErrNone) |
|
96 { |
|
97 INFO_PRINTF1(_L("GlobalEq plugin opened managed to open!")); |
|
98 delete plugin; |
|
99 result = EFail; |
|
100 } |
|
101 else if (error==KErrNotSupported) |
|
102 { |
|
103 INFO_PRINTF1(_L("GlobalEq plugin not supported - as expected")); |
|
104 } |
|
105 else |
|
106 { |
|
107 INFO_PRINTF2(_L("GlobalEq CreateImplementationL() failed - %d"), error); |
|
108 result = EFail; |
|
109 } |
|
110 |
|
111 __MM_HEAP_MARKEND; |
|
112 } |
|
113 |
|
114 { |
|
115 __MM_HEAP_MARK; |
|
116 |
|
117 CMmfGlobalMegaEffect* plugin = NULL; |
|
118 |
|
119 TRAPD(error, plugin = CMmfGlobalMegaEffect::NewL(NULL)); |
|
120 |
|
121 if (error==KErrNone) |
|
122 { |
|
123 INFO_PRINTF1(_L("GlobalMega plugin opened managed to open!")); |
|
124 delete plugin; |
|
125 result = EFail; |
|
126 } |
|
127 else if (error==KErrNotSupported) |
|
128 { |
|
129 INFO_PRINTF1(_L("GlobalMega plugin not supported - as expected")); |
|
130 } |
|
131 else |
|
132 { |
|
133 INFO_PRINTF2(_L("GlobalMega CreateImplementationL() failed - %d"), error); |
|
134 result = EFail; |
|
135 } |
|
136 |
|
137 __MM_HEAP_MARKEND; |
|
138 } |
|
139 |
|
140 return result; |
|
141 } |
|
142 |
|
143 // |
|
144 // RGlobalEffectMainTest |
|
145 // |
|
146 |
|
147 RGlobalEffectMainTest* RGlobalEffectMainTest::NewL(TBool aAllocTest) |
|
148 { |
|
149 RGlobalEffectMainTest* self = new (ELeave) RGlobalEffectMainTest(aAllocTest); |
|
150 return self; |
|
151 } |
|
152 |
|
153 RGlobalEffectMainTest::RGlobalEffectMainTest(TBool /*aAllocTest*/) |
|
154 { |
|
155 iTestStepName = _L("MM-MMF-GEF-U-003"); |
|
156 } |
|
157 |
|
158 TVerdict RGlobalEffectMainTest::DoTestStepL() |
|
159 { |
|
160 INFO_PRINTF1(_L("Check basic API calls on TestPlugin")); |
|
161 TVerdict result = EPass; |
|
162 |
|
163 __MM_HEAP_MARK; |
|
164 |
|
165 CTestGlobalEffect* plugin = NULL; |
|
166 |
|
167 TRAPD(error, plugin = CTestGlobalEffect::NewL(NULL)); |
|
168 |
|
169 if (error!=KErrNone) |
|
170 { |
|
171 INFO_PRINTF2(_L("CreateImplementationL() failed - %d"), error); |
|
172 return EFail; |
|
173 } |
|
174 |
|
175 CleanupStack::PushL(plugin); |
|
176 |
|
177 { |
|
178 // check Capability |
|
179 TUint value = plugin->Capability(EFalse); |
|
180 if (value!=0) |
|
181 { |
|
182 INFO_PRINTF2(_L("Capability(EFalse): expected 0 got - %d"), value); |
|
183 result = EFail; |
|
184 } |
|
185 value = plugin->Capability(ETrue); |
|
186 if (value!=0xffff) |
|
187 { |
|
188 INFO_PRINTF2(_L("Capability(ETrue): expected -1 got - %d"), value); |
|
189 result = EFail; |
|
190 } |
|
191 } |
|
192 |
|
193 // check settings by des, uid or value |
|
194 HBufC8* tempDes = NULL; |
|
195 TUid tempUid; |
|
196 TInt tempInt; |
|
197 TPckg<TInt> tempPackage (tempInt); |
|
198 { |
|
199 // initially (stage 1) nothing set, so SettingsByUidL() and ExtractValuesL() |
|
200 // should leave KErrNotSupported, and SettingsByDesL() should return "1234" |
|
201 |
|
202 TRAP(error, tempDes = plugin->SettingsByDesL()); |
|
203 if (error==KErrNone) |
|
204 { |
|
205 CleanupStack::PushL(tempDes); |
|
206 if (*tempDes!=_L8("1234")) |
|
207 { |
|
208 HBufC* tempDes16 = HBufC::NewMaxLC(tempDes->Length()); |
|
209 tempDes16->Des().Copy(*tempDes); |
|
210 INFO_PRINTF2(_L("Stage1: SettingsByDesL() expected \"1234\" got \"%S\""), tempDes16); |
|
211 result = EFail; |
|
212 CleanupStack::PopAndDestroy(tempDes16); |
|
213 } |
|
214 CleanupStack::PopAndDestroy(tempDes); |
|
215 tempDes = NULL; |
|
216 } |
|
217 else |
|
218 { |
|
219 INFO_PRINTF2(_L("Stage1: SettingsByDesL() returned %d"), error); |
|
220 result = EFail; |
|
221 } |
|
222 |
|
223 TRAP(error, tempUid = plugin->SettingsByUidL()); |
|
224 if (error!=KErrNotSupported) |
|
225 { |
|
226 INFO_PRINTF3(_L("Stage1: SettingsByUidL() expected KErrNotSupported got %d(0x%x)"), error, tempUid.iUid); |
|
227 result = EFail; |
|
228 } |
|
229 |
|
230 TRAP(error, plugin->ExtractValuesL(tempPackage)); |
|
231 if (error!=KErrNotSupported) |
|
232 { |
|
233 INFO_PRINTF3(_L("Stage1: ExtractValuesL() expected KErrNotSupported got %d(%d)"), error, tempInt); |
|
234 result = EFail; |
|
235 } |
|
236 |
|
237 } |
|
238 |
|
239 { |
|
240 // at stage 2, we set a value by UID, so now SettingsByUid returns something sensible |
|
241 TUid sampleUid = {0x1234567}; // any silly value will do |
|
242 plugin->SetSettingsByUidL(sampleUid); |
|
243 |
|
244 TRAP(error, tempDes = plugin->SettingsByDesL()); |
|
245 if (error==KErrNone) |
|
246 { |
|
247 CleanupStack::PushL(tempDes); |
|
248 if (*tempDes!=_L8("1234")) |
|
249 { |
|
250 HBufC* tempDes16 = HBufC::NewMaxLC(tempDes->Length()); |
|
251 tempDes16->Des().Copy(*tempDes); |
|
252 INFO_PRINTF2(_L("Stage2: SettingsByDesL() expected \"1234\" got \"%S\""), tempDes16); |
|
253 result = EFail; |
|
254 CleanupStack::PopAndDestroy(tempDes16); |
|
255 } |
|
256 CleanupStack::PopAndDestroy(tempDes); |
|
257 tempDes = NULL; |
|
258 } |
|
259 else |
|
260 { |
|
261 INFO_PRINTF2(_L("Stage2: SettingsByDesL() returned %d"), error); |
|
262 result = EFail; |
|
263 } |
|
264 |
|
265 TRAP(error, tempUid = plugin->SettingsByUidL()); |
|
266 if (error!=KErrNone) |
|
267 { |
|
268 INFO_PRINTF3(_L("Stage2: SettingsByUidL() expected KErrNone got %d(0x%x)"), error, tempUid.iUid); |
|
269 result = EFail; |
|
270 } |
|
271 else if (tempUid != sampleUid) |
|
272 { |
|
273 INFO_PRINTF3(_L("Stage2: SettingsByUidL() expected return of 0x%x got 0x%x"), sampleUid.iUid, tempUid.iUid); |
|
274 } |
|
275 |
|
276 TRAP(error, plugin->ExtractValuesL(tempPackage)); |
|
277 if (error!=KErrNotSupported) |
|
278 { |
|
279 INFO_PRINTF3(_L("Stage2: ExtractValuesL() expected KErrNotSupported got %d(%d)"), error, tempInt); |
|
280 result = EFail; |
|
281 } |
|
282 |
|
283 } |
|
284 |
|
285 { |
|
286 // at stage 3, we set a value by des, so again only SettingsByDesL() gives valid results |
|
287 _LIT8(KSampleDes, "89a"); |
|
288 plugin->SetSettingsByDesL(KSampleDes); |
|
289 |
|
290 TRAP(error, tempDes = plugin->SettingsByDesL()); |
|
291 if (error==KErrNone) |
|
292 { |
|
293 CleanupStack::PushL(tempDes); |
|
294 if (*tempDes!=KSampleDes) |
|
295 { |
|
296 HBufC* tempDes16 = HBufC::NewMaxLC(tempDes->Length()); |
|
297 tempDes16->Des().Copy(*tempDes); |
|
298 INFO_PRINTF2(_L("Stage3: SettingsByDesL() expected \"89a\" got \"%S\""), tempDes16); |
|
299 result = EFail; |
|
300 CleanupStack::PopAndDestroy(tempDes16); |
|
301 } |
|
302 CleanupStack::PopAndDestroy(tempDes); |
|
303 tempDes = NULL; |
|
304 } |
|
305 else |
|
306 { |
|
307 INFO_PRINTF2(_L("Stage3: SettingsByDesL() returned %d"), error); |
|
308 result = EFail; |
|
309 } |
|
310 |
|
311 TRAP(error, tempUid = plugin->SettingsByUidL()); |
|
312 if (error!=KErrNotSupported) |
|
313 { |
|
314 INFO_PRINTF3(_L("Stage3: SettingsByUidL() expected KErrNotSupported got %d(0x%x)"), error, tempUid.iUid); |
|
315 result = EFail; |
|
316 } |
|
317 |
|
318 TRAP(error, plugin->ExtractValuesL(tempPackage)); |
|
319 if (error!=KErrNotSupported) |
|
320 { |
|
321 INFO_PRINTF3(_L("Stage3: ExtractValuesL() expected KErrNotSupported got %d(%d)"), error, tempInt); |
|
322 result = EFail; |
|
323 } |
|
324 } |
|
325 |
|
326 { |
|
327 // at stage 4, we set a value by package buffer, so only that way returns valid value |
|
328 const TInt sampleInt = 10; |
|
329 TPckgC<TInt> sampleBuffer (sampleInt); |
|
330 plugin->SetByValuesL(sampleBuffer); |
|
331 |
|
332 TRAP(error, tempDes = plugin->SettingsByDesL()); |
|
333 if (error==KErrNone) |
|
334 { |
|
335 CleanupStack::PushL(tempDes); |
|
336 HBufC* tempDes16 = HBufC::NewMaxLC(tempDes->Length()); |
|
337 tempDes16->Des().Copy(*tempDes); |
|
338 INFO_PRINTF2(_L("Stage4: SettingsByDesL() expected KErrNotSupported got \"%S\""), tempDes16); |
|
339 result = EFail; |
|
340 CleanupStack::PopAndDestroy(2, tempDes); |
|
341 tempDes = NULL; |
|
342 } |
|
343 else if (error!=KErrNotSupported) |
|
344 { |
|
345 INFO_PRINTF2(_L("Stage4: SettingsByDesL() expected KErrNotSupported returned %d"), error); |
|
346 result = EFail; |
|
347 } |
|
348 |
|
349 TRAP(error, tempUid = plugin->SettingsByUidL()); |
|
350 if (error!=KErrNotSupported) |
|
351 { |
|
352 INFO_PRINTF3(_L("Stage4: SettingsByUidL() expected KErrNotSupported got %d(0x%x)"), error, tempUid.iUid); |
|
353 result = EFail; |
|
354 } |
|
355 |
|
356 TRAP(error, plugin->ExtractValuesL(tempPackage)); |
|
357 if (error!=KErrNone) |
|
358 { |
|
359 INFO_PRINTF3(_L("Stage4: ExtractValuesL() expected KErrNone got %d(%d)"), error, tempInt); |
|
360 result = EFail; |
|
361 } |
|
362 else if (tempInt!=sampleInt) |
|
363 { |
|
364 INFO_PRINTF3(_L("Stage4: ExtractValuesL() expected %d got %d"), sampleInt, tempInt); |
|
365 result = EFail; |
|
366 } |
|
367 } |
|
368 |
|
369 { |
|
370 // Check for Enabled() and IsActive() - should be false to start. poke value and show have |
|
371 // changed. Have to use custom command for SetActive() since not really the way to drive |
|
372 // - this should relate to the underlying implementation |
|
373 TBool enabled = plugin->IsEnabled(); |
|
374 TBool active = plugin->IsActive(); |
|
375 if (enabled!=EFalse || active!=EFalse) |
|
376 { |
|
377 INFO_PRINTF3(_L("Check1: active(%d) and enabled(%d) should have been false"), active, enabled); |
|
378 result = EFail; |
|
379 } |
|
380 plugin->SetEnabledL(ETrue); |
|
381 plugin->SetActive(ETrue); |
|
382 enabled = plugin->IsEnabled(); |
|
383 active = plugin->IsActive(); |
|
384 if (enabled==EFalse || active==EFalse) |
|
385 { |
|
386 INFO_PRINTF3(_L("Check2: active(%d) and enabled(%d) should have been true"), active, enabled); |
|
387 result = EFail; |
|
388 } |
|
389 } |
|
390 |
|
391 { |
|
392 // check preset - for test this ties up with the test plugin |
|
393 const TInt KPresetsCount = 3; |
|
394 MMmfGlobalAudioPresetList* list = plugin->KnownPresetsL(); |
|
395 |
|
396 // reproduce what the plugin will do and check |
|
397 if (list->MdcaCount()!=KPresetsCount) |
|
398 { |
|
399 INFO_PRINTF3(_L("Expected %d presets, got %d"), KPresetsCount, list->MdcaCount()); |
|
400 result = EFail; |
|
401 } |
|
402 else |
|
403 { |
|
404 for (TInt index=0; index<KPresetsCount; index++) |
|
405 { |
|
406 TBuf<10> name; |
|
407 name.Num(index); |
|
408 TUid tempUid={index}; |
|
409 |
|
410 TUid foundUid = list->GAPUidPoint(index); |
|
411 const TPtrC foundName = list->MdcaPoint(index); |
|
412 |
|
413 if (foundUid!=tempUid) |
|
414 { |
|
415 INFO_PRINTF4(_L("Index %d, expected %x found %x"), index, tempUid.iUid, foundUid.iUid); |
|
416 result = EFail; |
|
417 } |
|
418 if (foundName != name) |
|
419 { |
|
420 INFO_PRINTF4(_L("Index %d, expected %S found %S"), index, &name, &foundName); |
|
421 result = EFail; |
|
422 } |
|
423 } |
|
424 |
|
425 } |
|
426 } |
|
427 |
|
428 CleanupStack::PopAndDestroy(plugin); |
|
429 |
|
430 __MM_HEAP_MARKEND; |
|
431 |
|
432 return result; |
|
433 } |
|
434 |
|
435 // |
|
436 // RGlobalEffectCallbackTest |
|
437 // |
|
438 |
|
439 const TUid KUidTestGlbNotification = {KUidTestGlbNotificationDefine}; |
|
440 |
|
441 |
|
442 RGlobalEffectCallbackTest* RGlobalEffectCallbackTest::NewL(TBool aAllocTest) |
|
443 { |
|
444 RGlobalEffectCallbackTest* self = new (ELeave) RGlobalEffectCallbackTest(aAllocTest); |
|
445 return self; |
|
446 } |
|
447 |
|
448 RGlobalEffectCallbackTest::RGlobalEffectCallbackTest(TBool /*aAllocTest*/) |
|
449 { |
|
450 iTestStepName = _L("MM-MMF-GEF-U-004"); |
|
451 } |
|
452 |
|
453 void RGlobalEffectCallbackTest::GAEEventNotificationL(CMmfGlobalAudioEffect* aEffect, |
|
454 TUid aEventUid, |
|
455 const TDesC8& aParam) |
|
456 { |
|
457 INFO_PRINTF1(_L("Callback")); |
|
458 if (aEffect!=iEffect) |
|
459 { |
|
460 INFO_PRINTF3(_L("Effect is %x, expected %d"), aEffect, iEffect); |
|
461 iResult = EFail; |
|
462 } |
|
463 if (KUidTestGlbNotification != aEventUid) |
|
464 { |
|
465 INFO_PRINTF3(_L("Uid is %x, expected %x"), aEventUid.iUid, KUidTestGlbNotification.iUid); |
|
466 iResult = EFail; |
|
467 } |
|
468 if (aParam != KNullDesC8) |
|
469 { |
|
470 INFO_PRINTF2(_L("Param=\"%S\", expected \"\""), &aParam); |
|
471 iResult = EFail; |
|
472 } |
|
473 iCalledBack = ETrue; |
|
474 } |
|
475 |
|
476 |
|
477 TVerdict RGlobalEffectCallbackTest::DoTestStepL() |
|
478 { |
|
479 INFO_PRINTF1(_L("Check notification callback")); |
|
480 iResult = EPass; |
|
481 |
|
482 __MM_HEAP_MARK; |
|
483 |
|
484 iEffect = CTestGlobalEffect::NewL(this); |
|
485 CleanupStack::PushL(iEffect); |
|
486 |
|
487 // for test, just generate test synchronously |
|
488 iEffect->RequestNotificationL(KUidTestGlbNotification); |
|
489 iEffect->GenCallbackL(); |
|
490 |
|
491 if (!iCalledBack) |
|
492 { |
|
493 INFO_PRINTF1(_L("Callback seemingly did not happen")); |
|
494 iResult = EFail; |
|
495 } |
|
496 |
|
497 CleanupStack::PopAndDestroy(iEffect); |
|
498 |
|
499 __MM_HEAP_MARKEND; |
|
500 |
|
501 return iResult; |
|
502 } |
|
503 |