Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // TSIMmfCtlfrmNeg.cpp
15 // Negative integration testing for MMF CTLFRM
22 // Test system includes
23 #include <testframework.h>
24 #include "TSI_MmfCtlfrmNeg.h"
25 #include "TSI_MmfCtlfrmStep.h"
26 #include "TSI_MmfCtlfrmSuite.h"
27 #include "TSI_MmfCodes.h"
28 #include "TSI_MmfEventIds.h"
29 #include "ActrlTestUids.h"
31 #include <mmf/common/mmfcontroller.h>
32 #include <mmf/plugin/mmfcontrollerimplementationuids.hrh>
34 //const TUid KTestControllerUid = {KTSIMmfControllerUid}; // EABI warning removal
35 //const TUid KTestController2Uid = {KTSIMmfController2Uid}; // EABI warning removal
36 const TUid KTestDataSourceUid = {KTSIMmfDataSourceUid};
37 //const TUid KTestDataSinkUid = {KTSIMmfDataSinkUid}; // EABI warning removal
39 // audio controller, from mmfControllerImplementationUIDs.hrh
40 //const TUid KTestAudioControllerUid = {KMmfUidControllerAudio}; // EABI warning removal
41 // ---------------------------
42 // RTestMmfCtlfrmI0502
44 // Load controller plugin for unsupported file format
48 RTestMmfCtlfrmI0502* RTestMmfCtlfrmI0502::NewL()
50 RTestMmfCtlfrmI0502* self = new(ELeave) RTestMmfCtlfrmI0502;
54 RTestMmfCtlfrmI0502::RTestMmfCtlfrmI0502()
56 iTestStepName = _L("MM-MMF-CTLFRM-I-0502");
60 TVerdict RTestMmfCtlfrmI0502::DoTestStepL()
62 INFO_PRINTF1(_L("open controller by unsupported extension"));
65 // This test needs to be looked at to clarify if we need TMMFPrioritySettings
67 // TMMFPrioritySettings settings;
69 // settings.iPriority = ETSIMmfPriorityLow;
70 // settings.iPref = EMdaPriorityPreferenceTime;
71 // settings.iState = EMMFStateIdle;
73 CMMFControllerPluginSelectionParameters* cSelect = CMMFControllerPluginSelectionParameters::NewLC();
74 CMMFFormatSelectionParameters* fSelect = CMMFFormatSelectionParameters::NewLC();
76 // Set the format match data
77 fSelect->SetMatchToFileNameL(_L("test.xls"));
78 // Set the controller plugin play format match data
79 cSelect->SetRequiredPlayFormatSupportL(*fSelect);
81 RMMFControllerImplInfoArray controllers; // Array to hold all the controllers support the match data
82 CleanupResetAndDestroyPushL(controllers);
83 cSelect->ListImplementationsL(controllers); // Populates the array with all the suitable controllers
84 TInt numControllers = controllers.Count();
87 ERR_PRINTF1(_L("Error : found a suitable controller"));
88 CleanupStack::PopAndDestroy(3);//controllers, fSelect, cSelect
89 return iTestStepResult = EFail;
92 INFO_PRINTF1(_L("Success : found no suitable controllers"));
93 CleanupStack::PopAndDestroy(3);//controllers, fSelect, cSelect
94 return iTestStepResult = EPass;
97 // ---------------------------
98 // RTestMmfCtlfrmI0504
100 // Load a controller by preferred supplier where only compatible controller
101 // available is from a rival
105 RTestMmfCtlfrmI0504* RTestMmfCtlfrmI0504::NewL()
107 RTestMmfCtlfrmI0504* self = new(ELeave) RTestMmfCtlfrmI0504;
111 RTestMmfCtlfrmI0504::RTestMmfCtlfrmI0504()
113 iTestStepName = _L("MM-MMF-CTLFRM-I-0504");
117 TVerdict RTestMmfCtlfrmI0504::DoTestStepL()
119 // try to open a controller by preferred supplier
120 // where only a rival's is available
122 INFO_PRINTF1(_L("open controller by preferred supplier"));
124 CMMFControllerPluginSelectionParameters* cSelect = CMMFControllerPluginSelectionParameters::NewLC();
125 CMMFFormatSelectionParameters* fSelect = CMMFFormatSelectionParameters::NewLC();
127 // Set the format match data
128 fSelect->SetMatchToFileNameL(_L("test.wav"));
129 // Set the controller plugin play format match data
130 cSelect->SetRequiredPlayFormatSupportL(*fSelect);
132 // Set for only those plugins supplied by "ACME Industries"
133 _LIT(KPrefSupplierAcme, "ACME Industries");
134 cSelect->SetPreferredSupplierL(KPrefSupplierAcme, CMMFPluginSelectionParameters::EOnlyPreferredSupplierPluginsReturned);
136 RMMFControllerImplInfoArray controllers; // Array to hold all the controllers support the match data
137 CleanupResetAndDestroyPushL(controllers);
138 cSelect->ListImplementationsL(controllers); // Populates the array with all the suitable controllers
139 TInt numControllers = controllers.Count();
142 ERR_PRINTF1(_L("Error : found a suitable controller"));
143 CleanupStack::PopAndDestroy(3);//controllers, fSelect, cSelect
144 return iTestStepResult = EFail;
147 INFO_PRINTF1(_L("Success : found no suitable controllers"));
148 CleanupStack::PopAndDestroy(3);//controllers, fSelect, cSelect
149 return iTestStepResult = EPass;
152 // ---------------------------
153 // RTestMmfCtlfrmI0511
155 // Add a data source to a controller which does not support dynamic addition of sources / sinks
159 RTestMmfCtlfrmI0511* RTestMmfCtlfrmI0511::NewL()
161 RTestMmfCtlfrmI0511* self = new(ELeave) RTestMmfCtlfrmI0511;
165 RTestMmfCtlfrmI0511::RTestMmfCtlfrmI0511()
167 iTestStepName = _L("MM-MMF-CTLFRM-I-0511");
171 TVerdict RTestMmfCtlfrmI0511::DoTestStepL()
173 INFO_PRINTF1(_L("add data source where not supported"));
175 // TSI_MmfController2 does not support adding source / sink
178 // first : add a data source without a handle
179 _LIT8(KInitData,"TEST");
181 TInt error = KErrNone;
182 error = iController.AddDataSource(KTestDataSourceUid, KInitData);
185 ERR_PRINTF1(_L("Error : AddDataSource succeeded"));
186 return iTestStepResult = EFail;
188 else if (error != KErrNotSupported)
190 ERR_PRINTF2(_L("AddDataSource failed with unexpected error %d"), error);
191 return iTestStepResult = EFail;
194 INFO_PRINTF1(_L("AddDataSource failed, error KErrNotSupported"));
196 // next : add a data source with a handle
197 TMMFMessageDestination* sourceHandlePtr = new (ELeave) TMMFMessageDestination();
198 TMMFMessageDestination& sourceHandle = *sourceHandlePtr;
199 error = iController.AddDataSource(KTestDataSourceUid, KInitData, sourceHandle);
202 ERR_PRINTF1(_L("Error : AddDataSource (with handle) succeeded"));
203 delete sourceHandlePtr;
204 return iTestStepResult = EFail;
206 else if (error != KErrNotSupported)
208 ERR_PRINTF2(_L("AddDataSource (with handle) failed with unexpected error %d"), error);
209 delete sourceHandlePtr;
210 return iTestStepResult = EFail;
213 INFO_PRINTF1(_L("AddDataSource (with handle) failed, error KErrNotSupported"));
214 delete sourceHandlePtr;
215 return iTestStepResult = EPass;
218 // ---------------------------
219 // RTestMmfCtlfrmI0512
221 // Add a data source which has already been added to a controller
225 RTestMmfCtlfrmI0512* RTestMmfCtlfrmI0512::NewL()
227 RTestMmfCtlfrmI0512* self = new(ELeave) RTestMmfCtlfrmI0512;
231 RTestMmfCtlfrmI0512::RTestMmfCtlfrmI0512()
233 iTestStepName = _L("MM-MMF-CTLFRM-I-0512");
237 TVerdict RTestMmfCtlfrmI0512::DoTestStepL()
239 INFO_PRINTF1(_L("add data source where already added"));
240 TInt error = KErrNone;
242 // this source already exists in the controller
243 _LIT(KTestWavFile, "c:\\TsiMmfCtlfrmData\\test.wav");
244 iFileConfig().iPath = KTestWavFile;
245 error = iController.AddDataSource(KUidMmfFileSource, iFileConfig);
248 ERR_PRINTF1(_L("Error : AddDataSource succeeded"));
249 return iTestStepResult = EFail;
251 else if (error != KErrAlreadyExists)
253 ERR_PRINTF2(_L("AddDataSource failed with unexpected error %d"), error);
254 return iTestStepResult = EFail;
257 INFO_PRINTF1(_L("AddDataSource failed, error KErrAlreadyExists"));
258 return iTestStepResult = EPass;
261 // ---------------------------
262 // RTestMmfCtlfrmI0513
264 // Remove a source or sink which is currently in use (track playing)
268 RTestMmfCtlfrmI0513* RTestMmfCtlfrmI0513::NewL()
270 RTestMmfCtlfrmI0513* self = new(ELeave) RTestMmfCtlfrmI0513;
274 RTestMmfCtlfrmI0513::RTestMmfCtlfrmI0513()
276 iTestStepName = _L("MM-MMF-CTLFRM-I-0513");
279 TVerdict RTestMmfCtlfrmI0513::DoTestStepL()
281 //XXX : we may have problems here. the only controller we have is the
282 // Audio Controller and this does not yet support removal of sources/sinks,
283 // whether it's playing or not...
285 INFO_PRINTF1(_L("remove a source / sink when track playing"));
287 TInt error = KErrNone;
290 error = iController.Play();
293 ERR_PRINTF2(_L("Play failed, error %d"), error);
294 return iTestStepResult = EInconclusive;
298 const TTimeIntervalMicroSeconds32 KPlayPosition32 = 500000L;
299 INFO_PRINTF2(_L("Waiting %d mcs..."), KPlayPosition32.Int());
300 User::After(KPlayPosition32);
302 // try and remove the data source
303 TMMFMessageDestination& sourceHandle = *iSourceHandlePtr;
304 error = iController.RemoveDataSource(sourceHandle);
305 if (error != KErrNotReady)
307 ERR_PRINTF2(_L("Error : RemoveDataSource returned error %d"), error);
308 return iTestStepResult = EFail;
311 INFO_PRINTF1(_L("RemoveDataSource returned KErrNotReady"));
312 return iTestStepResult = EPass;
315 // ---------------------------
316 // RTestMmfCtlfrmI0514
318 // Remove a source or sink which is not present in controller
322 RTestMmfCtlfrmI0514* RTestMmfCtlfrmI0514::NewL()
324 RTestMmfCtlfrmI0514* self = new(ELeave) RTestMmfCtlfrmI0514;
328 RTestMmfCtlfrmI0514::RTestMmfCtlfrmI0514()
330 iTestStepName = _L("MM-MMF-CTLFRM-I-0514");
334 TVerdict RTestMmfCtlfrmI0514::DoTestStepL()
336 INFO_PRINTF1(_L("remove a nonexistent source / sink"));
338 TInt error = KErrNone;
340 // reset will remove the sources/sinks we added in the preamble
341 error = iController.Reset();
344 ERR_PRINTF2(_L("Error : Reset failed, error %d"), error);
345 return iTestStepResult = EFail;
348 // try and remove the data source
349 TMMFMessageDestination& sourceHandle = *iSourceHandlePtr;
350 error = iController.RemoveDataSource(sourceHandle);
353 ERR_PRINTF1(_L("Error : RemoveDataSource succeeded"));
354 return iTestStepResult = EInconclusive;
356 else if (error != KErrNotFound)
358 ERR_PRINTF2(_L("RemoveDataSource failed with unexpected error %d"), error);
359 return iTestStepResult = EInconclusive;
362 INFO_PRINTF1(_L("RemoveDataSource failed with error KErrNotFound"));
363 return iTestStepResult = EPass;
366 // ---------------------------
367 // RTestMmfCtlfrmI0515
369 // Add a data source by UID, but with source info incompatible with the plugin
373 RTestMmfCtlfrmI0515* RTestMmfCtlfrmI0515::NewL()
375 RTestMmfCtlfrmI0515* self = new(ELeave) RTestMmfCtlfrmI0515;
379 RTestMmfCtlfrmI0515::RTestMmfCtlfrmI0515()
381 iTestStepName = _L("MM-MMF-CTLFRM-I-0515");
384 TVerdict RTestMmfCtlfrmI0515::OpenL()
386 return iTestStepResult = EPass;
387 // so we don't run the parent preamble
390 void RTestMmfCtlfrmI0515::Close()
392 // so we don't run the parent postamble
395 TVerdict RTestMmfCtlfrmI0515::DoTestStepL()
397 // NB : this test is no longer valid - see DEF001550 in TeamTrack.
400 // This is 'as designed' behaviour. The CMMFAudioController::AddDataSourceL function traps
401 // the call to CMMFFormatDecode::NewL, which leaves in this instance with error KErrNotSupported.
402 // However it completes silently if KErrNotSupported is the error (see the comment on line 182
403 // of MmfAudioController.cpp)
405 INFO_PRINTF1(_L("add incompatible data source by UID"));
406 INFO_PRINTF1(_L("test no longer valid - see DEF001550 in TeamTrack"));
408 TInt error = KErrNone;
410 iSettings.iPriority = ETSIMmfPriorityHigh;
411 iSettings.iPref = EMdaPriorityPreferenceQuality;
412 iSettings.iState = EMMFStateIdle;
415 error = iController.Open(KTestAudioControllerUid, iSettings);
418 ERR_PRINTF2(_L("controller failed to open, error %d"), error);
419 return iTestStepResult = EInconclusive;
422 // Attempt to add an incompatible source and sink
423 _LIT(KTestXlsFile, "c:\\TsiMmfCtlfrmData\\test.xls");
424 iFileConfig().iPath = KTestXlsFile;
425 error = iController.AddDataSource(KUidMmfFileSource, iFileConfig);
428 ERR_PRINTF1(_L("Error : AddDataSource succeeded"));
429 return iTestStepResult = EFail;
431 else if (error != KErrNotSupported)
433 ERR_PRINTF2(_L("AddDataSource failed with unexpected error %d"), error);
434 return iTestStepResult = EFail;
437 INFO_PRINTF1(_L("AddDataSource failed, error KErrNotSupported"));
439 error = iController.AddDataSink(KUidMmfFileSource, iFileConfig);
442 ERR_PRINTF1(_L("Error : AddDataSink succeeded"));
443 return iTestStepResult = EFail;
445 else if (error != KErrNotSupported)
447 ERR_PRINTF2(_L("AddDataSink failed with unexpected error %d"), error);
448 return iTestStepResult = EFail;
451 INFO_PRINTF1(_L("AddDataSink failed, error KErrNotSupported"));
453 return iTestStepResult = EPass;
456 // ---------------------------
457 // RTestMmfCtlfrmI0521
459 // Play an unprimed controller
463 RTestMmfCtlfrmI0521* RTestMmfCtlfrmI0521::NewL()
465 RTestMmfCtlfrmI0521* self = new(ELeave) RTestMmfCtlfrmI0521;
469 RTestMmfCtlfrmI0521::RTestMmfCtlfrmI0521()
471 iTestStepName = _L("MM-MMF-CTLFRM-I-0521");
475 TVerdict RTestMmfCtlfrmI0521::DoTestStepL()
477 INFO_PRINTF1(_L("play an unprimed controller"));
478 TInt error = KErrNone;
480 // controller is fully setup in the preamble, but not primed
481 // try to set it playing
482 error = iController.Play();
483 if(error != KErrNotReady)
485 ERR_PRINTF2(_L("Error : play returned error %d"), error);
486 return iTestStepResult = EFail;
488 INFO_PRINTF1(_L("Play failed with error KErrNotReady"));
489 return iTestStepResult = EPass;
492 // ---------------------------
493 // RTestMmfCtlfrmI0522
495 // Prime a controller which is already primed
499 RTestMmfCtlfrmI0522* RTestMmfCtlfrmI0522::NewL()
501 RTestMmfCtlfrmI0522* self = new(ELeave) RTestMmfCtlfrmI0522;
505 RTestMmfCtlfrmI0522::RTestMmfCtlfrmI0522()
507 iTestStepName = _L("MM-MMF-CTLFRM-I-0522");
511 TVerdict RTestMmfCtlfrmI0522::DoTestStepL()
513 INFO_PRINTF1(_L("prime an already primed controller"));
514 TInt error = KErrNone;
516 // controller is fully setup in the preamble, but not primed
517 // prime it, then prime it again
518 error = iController.Prime();
521 ERR_PRINTF2(_L("Error : first prime returned error %d"), error);
522 return iTestStepResult = EInconclusive;
525 // wait a while, to give it chance to prime
526 const TTimeIntervalMicroSeconds32 KPlayPosition32 = 500000L;
527 INFO_PRINTF2(_L("Waiting %d mcs..."), KPlayPosition32.Int());
528 User::After(KPlayPosition32);
530 // prime a second time. this should succeed (KErrNone)
531 // (defined in Audio Controller)
532 error = iController.Prime();
535 ERR_PRINTF2(_L("Error : second prime returned error %d"), error);
536 return iTestStepResult = EFail;
538 INFO_PRINTF1(_L("Second prime returned success"));
540 return iTestStepResult = EPass;
543 // ---------------------------
544 // RTestMmfCtlfrmI0523
546 // Play a controller where there is no defined source
550 RTestMmfCtlfrmI0523* RTestMmfCtlfrmI0523::NewL()
552 RTestMmfCtlfrmI0523* self = new(ELeave) RTestMmfCtlfrmI0523;
556 RTestMmfCtlfrmI0523::RTestMmfCtlfrmI0523()
558 iTestStepName = _L("MM-MMF-CTLFRM-I-0523");
561 TVerdict RTestMmfCtlfrmI0523::DoTestStepL()
563 INFO_PRINTF1(_L("play a controller with no defined source"));
564 TInt error = KErrNone;
566 // controller is setup in the preamble, but has no source
567 // try to set it playing
568 error = iController.Play();
569 if(error != KErrNotReady)
571 ERR_PRINTF2(_L("Error : play returned error %d"), error);
572 return iTestStepResult = EFail;
574 INFO_PRINTF1(_L("Play failed with error KErrNotReady"));
575 return iTestStepResult = EPass;
578 // ---------------------------
579 // RTestMmfCtlfrmI0524
581 // Play a controller which is already playing
585 RTestMmfCtlfrmI0524* RTestMmfCtlfrmI0524::NewL()
587 RTestMmfCtlfrmI0524* self = new(ELeave) RTestMmfCtlfrmI0524;
591 RTestMmfCtlfrmI0524::RTestMmfCtlfrmI0524()
593 iTestStepName = _L("MM-MMF-CTLFRM-I-0524");
597 TVerdict RTestMmfCtlfrmI0524::DoTestStepL()
599 INFO_PRINTF1(_L("play a controller which is already playing"));
600 TInt error = KErrNone;
602 // controller is fully setup in the preamble, and primed
604 error = iController.Play();
607 ERR_PRINTF2(_L("Error : play returned error %d"), error);
608 return iTestStepResult = EInconclusive;
611 // wait a while, to give it chance to start playing
612 const TTimeIntervalMicroSeconds32 KPlayPosition32 = 500000L;
613 INFO_PRINTF2(_L("Waiting %d mcs..."), KPlayPosition32.Int());
614 User::After(KPlayPosition32);
616 // do it again :- should return KErrNotReady (this is defined in the
618 error = iController.Play();
619 if(error != KErrNotReady)
621 ERR_PRINTF2(_L("Error : second play returned error %d"), error);
622 return iTestStepResult = EFail;
625 INFO_PRINTF1(_L("Second play returned KErrNotReady"));
626 return iTestStepResult = EPass;
629 // ---------------------------
630 // RTestMmfCtlfrmI0525
632 // Stop a controller which is not playing
636 RTestMmfCtlfrmI0525* RTestMmfCtlfrmI0525::NewL()
638 RTestMmfCtlfrmI0525* self = new(ELeave) RTestMmfCtlfrmI0525;
642 RTestMmfCtlfrmI0525::RTestMmfCtlfrmI0525()
644 iTestStepName = _L("MM-MMF-CTLFRM-I-0525");
648 TVerdict RTestMmfCtlfrmI0525::DoTestStepL()
650 INFO_PRINTF1(_L("stop a controller which is not playing"));
651 TInt error = KErrNone;
653 // controller is fully setup in the preamble, and primed
654 // play it, stop, try and stop again
655 error = iController.Play();
658 ERR_PRINTF2(_L("Error : play returned error %d"), error);
659 return iTestStepResult = EInconclusive;
661 // wait a while, to give it chance to start playing
662 const TTimeIntervalMicroSeconds32 KPlayPosition32 = 500000L;
663 INFO_PRINTF2(_L("Waiting %d mcs..."), KPlayPosition32.Int());
664 User::After(KPlayPosition32);
666 error = iController.Stop();
669 ERR_PRINTF2(_L("Error : stop returned error %d"), error);
670 return iTestStepResult = EInconclusive;
673 // wait a while, to give it chance to stop
674 INFO_PRINTF2(_L("Waiting %d mcs..."), KPlayPosition32.Int());
675 User::After(KPlayPosition32);
677 // now try and stop it a second time - should return KErrNone
678 // (this is defined in Audio Controller)
679 error = iController.Stop();
682 ERR_PRINTF2(_L("Error : stop returned error %d"), error);
683 return iTestStepResult = EFail;
685 INFO_PRINTF1(_L("Stop returned KErrNone"));
687 return iTestStepResult = EPass;
690 // ---------------------------
691 // RTestMmfCtlfrmI0526
693 // Stop a controller where there is no defined source
697 RTestMmfCtlfrmI0526* RTestMmfCtlfrmI0526::NewL()
699 RTestMmfCtlfrmI0526* self = new(ELeave) RTestMmfCtlfrmI0526;
703 RTestMmfCtlfrmI0526::RTestMmfCtlfrmI0526()
705 iTestStepName = _L("MM-MMF-CTLFRM-I-0526");
709 TVerdict RTestMmfCtlfrmI0526::DoTestStepL()
711 INFO_PRINTF1(_L("stop a controller with no defined source"));
712 TInt error = KErrNone;
714 // controller is setup in the preamble, but has no source
716 error = iController.Stop();
719 ERR_PRINTF2(_L("Error : stop returned error %d"), error);
720 return iTestStepResult = EFail;
722 INFO_PRINTF1(_L("Stop returned KErrNone"));
723 return iTestStepResult = EPass;
726 // ---------------------------
727 // RTestMmfCtlfrmI0527
729 // Pause a controller which is stopped
733 RTestMmfCtlfrmI0527* RTestMmfCtlfrmI0527::NewL()
735 RTestMmfCtlfrmI0527* self = new(ELeave) RTestMmfCtlfrmI0527;
739 RTestMmfCtlfrmI0527::RTestMmfCtlfrmI0527()
741 iTestStepName = _L("MM-MMF-CTLFRM-I-0527");
745 TVerdict RTestMmfCtlfrmI0527::DoTestStepL()
747 INFO_PRINTF1(_L("pause a controller which is stopped"));
748 TInt error = KErrNone;
750 // controller is fully setup in the preamble, and primed
751 // play it, stop, try and pause
752 error = iController.Play();
755 ERR_PRINTF2(_L("Error : play returned error %d"), error);
756 return iTestStepResult = EInconclusive;
758 // wait a while, to give it chance to start playing
759 const TTimeIntervalMicroSeconds32 KPlayPosition32 = 500000L;
760 INFO_PRINTF2(_L("Waiting %d mcs..."), KPlayPosition32.Int());
761 User::After(KPlayPosition32);
763 error = iController.Stop();
766 ERR_PRINTF2(_L("Error : stop returned error %d"), error);
767 return iTestStepResult = EInconclusive;
769 // wait a while, to give it chance to stop
770 INFO_PRINTF2(_L("Waiting %d mcs..."), KPlayPosition32.Int());
771 User::After(KPlayPosition32);
773 // now try and pause. this should return KErrNotReady
774 error = iController.Pause();
775 if(error != KErrNotReady)
777 ERR_PRINTF2(_L("Error : pause returned error %d"), error);
778 return iTestStepResult = EFail;
780 INFO_PRINTF1(_L("Pause returned KErrNotReady"));
782 return iTestStepResult = EPass;
785 // ---------------------------
786 // RTestMmfCtlfrmI0531
788 // Assign a priority to a controller where it is the only controller loaded
792 RTestMmfCtlfrmI0531* RTestMmfCtlfrmI0531::NewL()
794 RTestMmfCtlfrmI0531* self = new(ELeave) RTestMmfCtlfrmI0531;
798 RTestMmfCtlfrmI0531::RTestMmfCtlfrmI0531()
800 iTestStepName = _L("MM-MMF-CTLFRM-I-0531");
803 TVerdict RTestMmfCtlfrmI0531::DoTestStepL()
805 INFO_PRINTF1(_L("Assign priority to lone controller"));
806 TInt error = KErrNone;
808 // this will succeed - priorities are relative, not absolute
809 iSettings.iPriority = ETSIMmfPriorityLow;
810 iSettings.iPref = EMdaPriorityPreferenceTime;
811 iSettings.iState = EMMFStateIdle;
813 // NB controller should be Stopped (not Primed) to do this)
814 error = iController.SetPrioritySettings(iSettings);
817 ERR_PRINTF2(_L("Error : SetPrioritySettings returned %d"), error);
818 return iTestStepResult = EFail;
821 INFO_PRINTF1(_L("SetPrioritySettings succeeded"));
823 return iTestStepResult = EPass;
826 // ---------------------------
827 // RTestMmfCtlfrmI0532
829 // Assign identical or conflicting priorities to two controllers
833 RTestMmfCtlfrmI0532* RTestMmfCtlfrmI0532::NewL()
835 RTestMmfCtlfrmI0532* self = new(ELeave) RTestMmfCtlfrmI0532;
839 RTestMmfCtlfrmI0532::RTestMmfCtlfrmI0532()
841 iTestStepName = _L("MM-MMF-CTLFRM-I-0532");
844 TVerdict RTestMmfCtlfrmI0532::DoTestStepL()
846 INFO_PRINTF1(_L("Assign identical priority to two controllers"));
847 TInt error = KErrNone;
849 // NB : the preamble for this class sets the controllers with identical settings
850 // including priority
853 error = iController1.Prime();
856 ERR_PRINTF2(_L("controller1 prime failed, error %d"), error);
857 return iTestStepResult = EInconclusive;
859 error = iController2.Prime();
862 ERR_PRINTF2(_L("controller2 prime failed, error %d"), error);
863 return iTestStepResult = EInconclusive;
866 // at last we are ready to do the test...
867 // play both controllers. give the first time to start before playing the second.
868 // we should get an error.
869 error = iController1.Play();
872 ERR_PRINTF2(_L("iController1 play failed, error %d"), error);
873 return iTestStepResult = EInconclusive;
875 // wait a while, to give it chance to play
876 const TTimeIntervalMicroSeconds32 KPlayPosition32 = 500000L;
877 INFO_PRINTF2(_L("Waiting %d mcs..."), KPlayPosition32.Int());
878 User::After(KPlayPosition32);
879 error = iController2.Play();
882 ERR_PRINTF2(_L("iController2 play failed, error %d"), error);
883 return iTestStepResult = EInconclusive;
886 // search for a KErrInUse event from the MMF controller framework on controller 2
887 TMMFEvent inUseEvent( KMMFEventCategoryPlaybackComplete, KErrInUse );
889 result = SearchForEvent( inUseEvent, 2 );
890 if( result == EFail )
892 ERR_PRINTF1(_L("MMF controller framework did not return a KErrInUse event"));
893 return iTestStepResult = EFail;
896 ERR_PRINTF1(_L("MMF controller framework returned a KErrInUse event"));
897 return iTestStepResult = EPass;
900 // ---------------------------
901 // RTestMmfCtlfrmI0541
903 // Get position of a source where there is no defined source
907 RTestMmfCtlfrmI0541* RTestMmfCtlfrmI0541::NewL()
909 RTestMmfCtlfrmI0541* self = new(ELeave) RTestMmfCtlfrmI0541;
913 RTestMmfCtlfrmI0541::RTestMmfCtlfrmI0541()
915 iTestStepName = _L("MM-MMF-CTLFRM-I-0541");
918 TVerdict RTestMmfCtlfrmI0541::DoTestStepL()
920 INFO_PRINTF1(_L("Get position of undefined source"));
921 TInt error = KErrNone;
923 // controller is setup in the preamble, but has no source
924 // try to get a clip position
925 TTimeIntervalMicroSeconds clipPos;
926 error = iController.GetPosition(clipPos);
927 if(error != KErrNotReady)
929 ERR_PRINTF2(_L("Error : GetPosition returned error %d"), error);
930 return iTestStepResult = EFail;
933 INFO_PRINTF1(_L("GetPosition returned KErrNotReady"));
934 return iTestStepResult = EPass;
937 // ---------------------------
938 // RTestMmfCtlfrmI0542
940 // Set position of a source to beyond the end of the data
944 RTestMmfCtlfrmI0542* RTestMmfCtlfrmI0542::NewL()
946 RTestMmfCtlfrmI0542* self = new(ELeave) RTestMmfCtlfrmI0542;
950 RTestMmfCtlfrmI0542::RTestMmfCtlfrmI0542()
952 iTestStepName = _L("MM-MMF-CTLFRM-I-0542");
955 TVerdict RTestMmfCtlfrmI0542::DoTestStepL()
957 // NB this test has changed
958 // originally we expected the position to set to the end of the clip.
959 // the Audio Controller is now in fact returning KErrArgument
960 INFO_PRINTF1(_L("Set position to beyond end of source data"));
961 TInt error = KErrNone;
963 // we know our clip is 5.33 sec :- set to way past the end
964 const TTimeIntervalMicroSeconds KPastEndPosition(20000000); // 20 sec
965 const TTimeIntervalMicroSeconds KPlayPosition(5330000);
966 // NB allow for resolution of the controller itself
967 const TTimeIntervalMicroSeconds KPlayPositionPlusError(5830000);
968 const TTimeIntervalMicroSeconds KPlayPositionMinusError(4830000); // allow +/-0.5 sec
969 error = iController.SetPosition(KPastEndPosition);
970 if(error != KErrArgument)
972 ERR_PRINTF3(_L("SetPosition returned error %d (expected %d)"), error, KErrArgument);
973 return iTestStepResult = EFail;
976 INFO_PRINTF1(_L("SetPosition returned KErrArgument"));
977 // now set it to the actual end of the clip, and try again
978 error = iController.SetPosition(KPlayPosition);
981 ERR_PRINTF3(_L("SetPosition returned error %d (expected %d)"), error, KErrNone);
982 return iTestStepResult = EFail;
985 TTimeIntervalMicroSeconds clipPos;
986 error = iController.GetPosition(clipPos);
989 ERR_PRINTF2(_L("Error : GetPosition failed, error %d"), error);
990 return iTestStepResult = EInconclusive;
993 INFO_PRINTF3(_L("Clip position : %ld Expected : %ld"), I64LOW(clipPos.Int64()), I64LOW(KPlayPosition.Int64()));
994 if( (clipPos < (KPlayPositionMinusError)) || (clipPos > (KPlayPositionPlusError)) )
996 ERR_PRINTF1(_L("Error : clip position not set correctly"));
997 return iTestStepResult = EFail;
1000 // EPass if we got here
1001 return iTestStepResult = EPass;
1004 // ---------------------------
1005 // RTestMmfCtlfrmI0551
1007 // Close a controller when source is still playing
1011 RTestMmfCtlfrmI0551* RTestMmfCtlfrmI0551::NewL()
1013 RTestMmfCtlfrmI0551* self = new(ELeave) RTestMmfCtlfrmI0551;
1017 RTestMmfCtlfrmI0551::RTestMmfCtlfrmI0551()
1019 iTestStepName = _L("MM-MMF-CTLFRM-I-0551");
1022 TVerdict RTestMmfCtlfrmI0551::DoTestStepL()
1024 INFO_PRINTF1(_L("Close controller while still playing"));
1025 TInt error = KErrNone;
1027 // controller is fully setup in the preamble, and primed
1028 // play it, then close
1029 error = iController.Play();
1032 ERR_PRINTF2(_L("Error : play returned error %d"), error);
1033 return iTestStepResult = EInconclusive;
1036 // wait a while, to give it chance to start playing
1037 const TTimeIntervalMicroSeconds32 KPlayPosition32 = 500000L;
1038 INFO_PRINTF2(_L("Waiting %d mcs..."), I64LOW(KPlayPosition32.Int()));
1039 User::After(KPlayPosition32);
1041 iController.Close();
1043 // Close() returns void - so instead demonstrate that the controller
1044 // has been closed - Reset will return KErrNotReady on a closed controller;
1045 // on an open controller it will succeed in any state.
1047 error = iController.Reset();
1048 if(error != KErrNotReady)
1050 ERR_PRINTF2(_L("Error : reset returned error %d"), error);
1051 return iTestStepResult = EFail;
1054 INFO_PRINTF1(_L("Reset returned KErrNotReady; close succeeded"));
1055 return iTestStepResult = EPass;
1058 // ---------------------------
1059 // RTestMmfCtlfrmI0552
1061 // Reset a controller when source is still playing
1065 RTestMmfCtlfrmI0552* RTestMmfCtlfrmI0552::NewL()
1067 RTestMmfCtlfrmI0552* self = new(ELeave) RTestMmfCtlfrmI0552;
1071 RTestMmfCtlfrmI0552::RTestMmfCtlfrmI0552()
1073 iTestStepName = _L("MM-MMF-CTLFRM-I-0552");
1076 TVerdict RTestMmfCtlfrmI0552::DoTestStepL()
1078 INFO_PRINTF1(_L("Reset controller while still playing"));
1079 TInt error = KErrNone;
1081 // controller is fully setup in the preamble, and primed
1082 // play it, then reset
1083 error = iController.Play();
1086 ERR_PRINTF2(_L("Error : play returned error %d"), error);
1087 return iTestStepResult = EInconclusive;
1090 // wait a while, to give it chance to start playing
1091 const TTimeIntervalMicroSeconds32 KPlayPosition32 = 500000L;
1092 INFO_PRINTF2(_L("Waiting %d mcs..."), I64LOW(KPlayPosition32.Int()));
1093 User::After(KPlayPosition32);
1095 error = iController.Reset();
1098 ERR_PRINTF2(_L("Error : Reset failed, error %d"), error);
1099 return iTestStepResult = EFail;
1102 INFO_PRINTF1(_L("Reset succeeded"));
1103 return iTestStepResult = EPass;
1106 // ---------------------------
1107 // RTestMmfCtlfrmI0553
1109 // Close an already closed controller
1113 RTestMmfCtlfrmI0553* RTestMmfCtlfrmI0553::NewL()
1115 RTestMmfCtlfrmI0553* self = new(ELeave) RTestMmfCtlfrmI0553;
1119 RTestMmfCtlfrmI0553::RTestMmfCtlfrmI0553()
1121 iTestStepName = _L("MM-MMF-CTLFRM-I-0553");
1124 TVerdict RTestMmfCtlfrmI0553::DoTestStepL()
1126 INFO_PRINTF1(_L("Close an already closed controller"));
1127 TInt error = KErrNone;
1129 // controller is fully setup in the preamble, and primed
1130 // close it, check that code on reset is KErrNotReady,
1131 // then close it again
1133 iController.Close();
1134 error = iController.Reset();
1135 if(error != KErrNotReady)
1137 ERR_PRINTF2(_L("Error : reset returned error %d"), error);
1138 return iTestStepResult = EFail;
1140 INFO_PRINTF1(_L("Reset (1) returned KErrNotReady; close succeeded"));
1142 // if the second close caused problems, we will leave or get an error from Reset
1143 iController.Close();
1144 error = iController.Reset();
1145 if(error != KErrNotReady)
1147 ERR_PRINTF2(_L("Error : reset returned error %d"), error);
1148 return iTestStepResult = EFail;
1151 INFO_PRINTF1(_L("Reset (2) returned KErrNotReady; close succeeded"));
1153 return iTestStepResult = EPass;
1156 // ---------------------------
1157 // RTestMmfCtlfrmI0554
1159 // Reset an already closed controller
1163 RTestMmfCtlfrmI0554* RTestMmfCtlfrmI0554::NewL()
1165 RTestMmfCtlfrmI0554* self = new(ELeave) RTestMmfCtlfrmI0554;
1169 RTestMmfCtlfrmI0554::RTestMmfCtlfrmI0554()
1171 iTestStepName = _L("MM-MMF-CTLFRM-I-0554");
1174 TVerdict RTestMmfCtlfrmI0554::DoTestStepL()
1176 INFO_PRINTF1(_L("Reset an already closed controller"));
1177 TInt error = KErrNone;
1179 // controller is fully setup in the preamble, and primed
1180 // close it, then attempt a reset
1182 iController.Close();
1183 // Close() returns void
1184 // wait a while, to give it a chance to complete
1185 const TTimeIntervalMicroSeconds32 KPlayPosition32 = 500000L;
1186 INFO_PRINTF2(_L("Waiting %d mcs..."), I64LOW(KPlayPosition32.Int()));
1187 User::After(KPlayPosition32);
1189 error = iController.Reset();
1190 if(error != KErrNotReady)
1192 // this will fail if the controller hasn't been closed
1193 ERR_PRINTF2(_L("Error : reset returned error %d"), error);
1194 return iTestStepResult = EFail;
1197 INFO_PRINTF1(_L("Reset returned KErrNotReady"));
1198 return iTestStepResult = EPass;