Update contrib.
1 // Copyright (c) 2007-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.
22 #include "dvbhhaiasynctest.h"
23 #include <mobiletv/hai/dvbh/dvbhtypes.h>
27 * DVB-H HAI Asynchronous Unit Tests on stub implementations
31 RDvbhHaiAsyncTest* RDvbhHaiAsyncTest::NewL(TBool aRequireReceiverInfo, const TDesC& aTestName)
33 RDvbhHaiAsyncTest* self = new (ELeave) RDvbhHaiAsyncTest(aRequireReceiverInfo, aTestName);
37 RDvbhHaiAsyncTest::RDvbhHaiAsyncTest(TBool aRequireReceiverInfo, const TDesC& aTestName)
38 : RAsyncTestStep(), iExpectedNetworkTime(TDateTime(2007, EJuly, 30, 16, 35, 22, 18)),
39 iInitialNetworkTime(TDateTime(1997, EMay, 10, 10, 00, 34, 02)), iInitialPlatform(),
40 iExpectedPlatform(), iPreTestRun(EFalse), iRequireReceiverInfo(aRequireReceiverInfo),
41 iRxInfo(NULL), i2ndRxInfo(NULL), iTestUtils(NULL), i2ndStateObserver(NULL)
43 iStateCallbackVerdicts[E1stStateObserver] = KNoVerdict;
44 iStateCallbackVerdicts[E2ndStateObserver] = KNoVerdict;
45 iTestStepName.Copy(aTestName);
49 void RDvbhHaiAsyncTest::SetupParameterData()
51 iInitialPlatform.iPlatform.iId = KInitialPlatformId;
52 iInitialPlatform.iPlatform.iName = KInitialPlatformName;
53 iInitialPlatform.iEsgRoot = KInet6AddrLinkLocal;
55 iExpectedPlatform.iPlatform.iId = KExpectedPlatformId;
56 iExpectedPlatform.iPlatform.iName = KExpectedPlatformName;
57 iExpectedPlatform.iEsgRoot = KDvbhTestIpV6Addr;
60 void RDvbhHaiAsyncTest::InfoPrintf3(const TDesC16& aString, TInt aInt1, TInt aInt2)
62 INFO_PRINTF3(aString, aInt1, aInt2);
65 void RDvbhHaiAsyncTest::InfoPrintf4(const TDesC16& aString, TInt aInt1, TInt aInt2, TInt aInt3)
67 INFO_PRINTF4(aString, aInt1, aInt2, aInt3);
71 * Allocs objects, defines properties, etc. as needed for each test step.
72 * Takes the role of the Preamble in synchornous tests. It is called once
73 * when a test step is first kicked off.
75 TVerdict RDvbhHaiAsyncTest::DoPreTest()
77 TRAPD(result, iTestUtils = CDvbhTestUtil::NewL(*this));
78 if (result != KErrNone)
80 INFO_PRINTF2(_L("Error %d creating CDvbhTestUtil"), result);
84 if (iRequireReceiverInfo)
86 TRAP(result, iRxInfo = CDvbhReceiverInfo::NewL())
87 if (result != KErrNone)
89 INFO_PRINTF2(_L("Error %d creating CDvbhReceiverInfo"), result);
94 if (iTestStepName.Compare(_L("MM-TV-DVBH-U-111")) == 0)
96 result = iTestUtils->DefineDvbhStateProperty(KInitialState);
98 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-112")) == 0)
100 // Receiver state must be EDvbhStateReceiving before we can do this test.
101 result = iTestUtils->DefineDvbhStateProperty(EDvbhStateReceiving);
102 if (result == KErrNone)
104 result = iTestUtils->DefineDvbhIntegerProperty(EDvbhPropertyKeySignalQuality, KInitialSignalQuality);
107 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-113")) == 0)
109 // Receiver state must be EDvbhStateReady or EDvbhStateReceiving before we can do this test.
110 result = iTestUtils->DefineDvbhStateProperty(EDvbhStateReady);
111 if (result == KErrNone)
113 TPckg<TDvbhPlatformProperty> initialPlatformPckg(iInitialPlatform);
114 result = iTestUtils->DefineDvbhProperty(EDvbhPropertyKeyPlatform, CDvbhTestUtil::GetType(EDvbhPropertyKeyPlatform), initialPlatformPckg);
117 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-114")) == 0)
119 // Receiver state must be EDvbhStateReady or EDvbhStateReceiving before we can do this test.
120 result = iTestUtils->DefineDvbhStateProperty(EDvbhStateReady);
121 if (result == KErrNone)
123 TPckg<TTime> initialTimePckg(iInitialNetworkTime);
124 result = iTestUtils->DefineDvbhProperty(EDvbhPropertyKeyNetworkTime, CDvbhTestUtil::GetType(EDvbhPropertyKeyNetworkTime), initialTimePckg);
127 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-115")) == 0)
129 // Receiver state must be EDvbhStateReady or EDvbhStateReceiving before we can do this test.
130 result = iTestUtils->DefineDvbhStateProperty(EDvbhStateReady);
131 if (result == KErrNone)
133 result = iTestUtils->DefineDvbhIntegerProperty(EDvbhPropertyKeyFrequency, KInitialFrequency);
136 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-116")) == 0)
138 // Receiver state must be EDvbhStateReady or EDvbhStateReceiving before we can do this test.
139 result = iTestUtils->DefineDvbhStateProperty(EDvbhStateReady);
140 if (result == KErrNone)
142 result = iTestUtils->DefineDvbhIntegerProperty(EDvbhPropertyKeyCellId, KInitialCellId);
145 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-117")) == 0)
147 // Receiver state must be EDvbhStateReady or EDvbhStateReceiving before we can do this test.
148 result = iTestUtils->DefineDvbhStateProperty(EDvbhStateReady);
149 if (result == KErrNone)
151 result = iTestUtils->DefineDvbhIntegerProperty(EDvbhPropertyKeyNetworkId, KInitialNetworkId);
154 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-125")) == 0)
156 result = iTestUtils->DefineDvbhStateProperty(KInitialState);
157 if (result == KErrNone)
159 TRAP(result, i2ndStateObserver = CAlternativeStateObserver::NewL(*this));
162 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-126")) == 0)
164 TRAP(result, i2ndStateObserver = CAlternativeStateObserver::NewL(*this));
166 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-127")) == 0)
168 result = iTestUtils->DefineDvbhStateProperty(KInitialState);
169 if (result == KErrNone)
171 TRAP(result, i2ndRxInfo = CDvbhReceiverInfo::NewL());
172 if (result == KErrNone)
174 TRAP(result, i2ndStateObserver = CAlternativeStateObserver::NewL(*this));
178 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-128")) == 0)
180 TRAP(result, i2ndRxInfo = CDvbhReceiverInfo::NewL());
181 if (result == KErrNone)
183 TRAP(result, i2ndStateObserver = CAlternativeStateObserver::NewL(*this));
186 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-401")) == 0)
188 result = iTestUtils->DefineAllDvbhProperties();
192 return (result == KErrNone ? EPass : EInconclusive);
195 void RDvbhHaiAsyncTest::CloseTest()
199 delete i2ndStateObserver;
200 i2ndStateObserver = NULL;
204 TInt result = KErrNone;
206 if (iTestStepName.Compare(_L("MM-TV-DVBH-U-111")) == 0)
208 result = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyState);
210 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-112")) == 0)
212 result = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyState);
213 TInt result2 = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeySignalQuality);
214 result = result2 != KErrNone ? result2 : result;
216 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-113")) == 0)
218 result = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyState);
219 TInt result2 = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyPlatform);
220 result = result2 != KErrNone ? result2 : result;
222 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-114")) == 0)
224 result = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyState);
225 TInt result2 = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyNetworkTime);
226 result = result2 != KErrNone ? result2 : result;
228 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-115")) == 0)
230 result = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyState);
231 TInt result2 = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyFrequency);
232 result = result2 != KErrNone ? result2 : result;
234 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-116")) == 0)
236 result = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyState);
237 TInt result2 = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyCellId);
238 result = result2 != KErrNone ? result2 : result;
240 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-117")) == 0)
242 result = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyState);
243 TInt result2 = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyNetworkId);
244 result = result2 != KErrNone ? result2 : result;
246 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-125")) == 0)
248 result = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyState);
250 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-127")) == 0)
252 result = iTestUtils->DeleteDvbhProperty(EDvbhPropertyKeyState);
254 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-401")) == 0)
256 result = iTestUtils->DeleteAllDvbhProperties();
262 //Make sure we are not leaving anything laying around. This is
263 //to verify the integrity of the test code more than anything else.
264 ASSERT(result == KErrNone);
267 void RDvbhHaiAsyncTest::KickoffTestL()
269 //Run the pre-test set-up if it has not been run already
272 TVerdict preTestResult = DoPreTest();
273 if (preTestResult != EPass)
275 INFO_PRINTF2(_L("DoPreTest failed with error %d."), preTestResult);
276 StopTest(preTestResult);
281 if (iTestStepName.Compare(_L("MM-TV-DVBH-U-111")) == 0)
283 DoSetStateObserverTestStep(ETrue);
285 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-112")) == 0)
287 DoSetSignalQualityObserverTestStep(ETrue);
289 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-113")) == 0)
291 DoSetPlatformObserverTestStep(ETrue);
293 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-114")) == 0)
295 DoSetNetworkTimeObserverTestStep(ETrue);
297 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-115")) == 0)
299 DoSetFrequencyObserverTestStep(ETrue);
301 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-116")) == 0)
303 DoSetCellIdObserverTestStep(ETrue);
305 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-117")) == 0)
307 DoSetNetworkIdObserverTestStep(ETrue);
309 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-118")) == 0)
311 DoSetStateObserverTestStep(EFalse);
313 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-119")) == 0)
315 DoSetSignalQualityObserverTestStep(EFalse);
317 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-120")) == 0)
319 DoSetPlatformObserverTestStep(EFalse);
321 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-121")) == 0)
323 DoSetNetworkTimeObserverTestStep(EFalse);
325 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-122")) == 0)
327 DoSetFrequencyObserverTestStep(EFalse);
329 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-123")) == 0)
331 DoSetCellIdObserverTestStep(EFalse);
333 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-124")) == 0)
335 DoSetNetworkIdObserverTestStep(EFalse);
337 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-125")) == 0)
339 DoSetMultipleStateObserversTestStep(ETrue);
341 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-126")) == 0)
343 DoSetMultipleStateObserversTestStep(EFalse);
345 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-127")) == 0)
347 DoCreateMultipleReceiverInfoTestStep(ETrue);
349 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-128")) == 0)
351 DoCreateMultipleReceiverInfoTestStep(EFalse);
353 else if (iTestStepName.Compare(_L("MM-TV-DVBH-U-401")) == 0)
355 DoSetObserversNoMemory();
359 StopTest(EInconclusive);
365 // CDvbhReceiverInfo Positive Async Tests
370 void RDvbhHaiAsyncTest::DoSetStateObserverTestStep(TBool aProperyExists)
372 TInt result = iRxInfo->SetStateObserver(*this);
373 if (result != KErrNone)
375 INFO_PRINTF2(_L("SetStateObserver returned error %d."), result);
382 //DoPreTest will have initialised the state to KInitialState.
383 //Now change it to KExpectedState.
384 if (iTestUtils->SetStateProperty(KExpectedState) != KErrNone)
386 StopTest(EInconclusive);
396 //Called when the state property changes if this state observer has been registerd
397 void RDvbhHaiAsyncTest::DvbhStateChange( TDvbhState aNewState )
399 TVerdict verdict = EPass;
401 // We have to make sure that this observer was not called for the wrong test.
402 if ( iTestStepName.Compare(_L("MM-TV-DVBH-U-125")) == 0 ||
403 iTestStepName.Compare(_L("MM-TV-DVBH-U-126")) == 0 )
405 INFO_PRINTF1(_L("RDvbhHaiAsyncTest::DvbhStateChange called for wrong test."));
410 if (aNewState != KExpectedState)
412 INFO_PRINTF2(_L("DvbhStateChange received unexpected value %d."), aNewState);
417 // Test case MM-TV-DVBH-U-127 is expecting two callbacks on two different observers
418 if (iTestStepName.Compare(_L("MM-TV-DVBH-U-127")) == 0)
420 // Set the verdict for this observer
421 iStateCallbackVerdicts[E1stStateObserver] = verdict;
422 //Check if the 2nd observer has reported back yet. If not then we
423 //do not want to stop the test yet.
424 if (iStateCallbackVerdicts[E2ndStateObserver] == KNoVerdict)
430 verdict = static_cast<TVerdict>(iStateCallbackVerdicts[E2ndStateObserver]);
440 void RDvbhHaiAsyncTest::DoSetSignalQualityObserverTestStep(TBool aProperyExists)
442 TInt result = iRxInfo->SetSignalQualityObserver(*this);
443 if (result != KErrNone)
445 INFO_PRINTF2(_L("SetSignalQualityObserver returned error %d."), result);
452 //DoPreTest will have initialised the signal quality to KInitialSignalQuality.
453 //Now change it to KExpectedSignalQuality.
454 if (iTestUtils->SetIntegerProperty(EDvbhPropertyKeySignalQuality, KExpectedSignalQuality) != KErrNone)
456 StopTest(EInconclusive);
466 //Called when the signal quality property changes this a signal quality observer has been registerd
467 void RDvbhHaiAsyncTest::DvbhSignalQualityChange( const TDvbhSignalQuality& aNewSignalQuality )
469 TVerdict verdict = EPass;
470 if (aNewSignalQuality != KExpectedSignalQuality)
472 INFO_PRINTF2(_L("DvbhSignalQualityChange received unexpected value %d."), aNewSignalQuality);
479 void RDvbhHaiAsyncTest::DoSetPlatformObserverTestStep(TBool aProperyExists)
481 TInt result = iRxInfo->SetPlatformObserver(*this);
482 if (result != KErrNone)
484 INFO_PRINTF2(_L("SetPlatformObserver returned error %d."), result);
491 //DoPreTest will have initialised the platform to iInitialPlatform.
492 //Now change it to iExpectedPlatform.
493 TPckg<TDvbhPlatformProperty> platformPckg(iExpectedPlatform);
494 if (iTestUtils->SetByteArrayProperty(EDvbhPropertyKeyPlatform, platformPckg) != KErrNone)
496 StopTest(EInconclusive);
506 //Called when the platform property changes if this platform observer has been registerd
507 void RDvbhHaiAsyncTest::DvbhPlatformChange( const TDvbhPlatform& aNewPlatform, const TIp6Addr& aESGRoot )
509 TVerdict verdict = EPass;
510 if ( !CDvbhTestUtil::ComparePlatforms(aNewPlatform, iExpectedPlatform.iPlatform))
512 INFO_PRINTF1(_L("DvbhPlatformChangeDvbhPlatformChange received unexpected platform."));
515 if (!aESGRoot.IsEqual(iExpectedPlatform.iEsgRoot))
517 INFO_PRINTF1(_L("DvbhPlatformChangeDvbhPlatformChange received unexpected esgRoot."));
524 void RDvbhHaiAsyncTest::DoSetNetworkTimeObserverTestStep(TBool aProperyExists)
526 TInt result = iRxInfo->SetNetworkTimeObserver(*this);
527 if (result != KErrNone)
529 INFO_PRINTF2(_L("SetNetworkTimeObserver returned error %d."), result);
536 //DoPreTest will have initialised the NetworkTime to iInitialNetworkTime.
537 //Now change it to KExpectedNetworkTime.
538 TPckg<TTime> timePckg(iExpectedNetworkTime);
539 if (iTestUtils->SetByteArrayProperty(EDvbhPropertyKeyNetworkTime, timePckg) != KErrNone)
541 StopTest(EInconclusive);
551 //Called when the network time property changes if this network time observer has been registerd
552 void RDvbhHaiAsyncTest::DvbhNetworkTimeUpdate()
554 // Since this method has no parameters, there are no variables for us to verify.
555 // The fact that this method was called at all means that CDvbhReceiverInfo::SetNetworkTimeObserver()
556 // worked correctly, and thus we can now stop the test as passed.
561 void RDvbhHaiAsyncTest::DoSetFrequencyObserverTestStep(TBool aProperyExists)
563 TInt result = iRxInfo->SetFrequencyObserver(*this);
564 if (result != KErrNone)
566 INFO_PRINTF2(_L("SetFrequencyObserver returned error %d."), result);
573 //DoPreTest will have initialised the frequency to KInitialFrequency.
574 //Now change it to KExpectedFrequency.
575 if (iTestUtils->SetIntegerProperty(EDvbhPropertyKeyFrequency, KExpectedFrequency) != KErrNone)
577 StopTest(EInconclusive);
587 //Called when the frequency property changes if this frequency observer has been registerd
588 void RDvbhHaiAsyncTest::DvbhFrequencyChange( const TDvbhFrequency& aNewFrequency )
590 TVerdict verdict = EPass;
591 if (aNewFrequency != KExpectedFrequency)
593 INFO_PRINTF2(_L("DvbhFrequencyChange received unexpected value %d."), aNewFrequency);
600 void RDvbhHaiAsyncTest::DoSetCellIdObserverTestStep(TBool aProperyExists)
602 TInt result = iRxInfo->SetCellIdObserver(*this);
603 if (result != KErrNone)
605 INFO_PRINTF2(_L("SetCellIdObserver returned error %d."), result);
612 //DoPreTest will have initialised the CellId to KInitialCellId.
613 //Now change it to KExpectedCellId.
614 if (iTestUtils->SetIntegerProperty(EDvbhPropertyKeyCellId, KExpectedCellId) != KErrNone)
616 StopTest(EInconclusive);
626 //Called when the CellId property changes if this CellId observer has been registerd
627 void RDvbhHaiAsyncTest::DvbhCellIdChange( const TDvbhCellId& aNewCellId )
629 TVerdict verdict = EPass;
630 if (aNewCellId != KExpectedCellId)
632 INFO_PRINTF2(_L("DvbhCellIdChange received unexpected value %d."), aNewCellId);
639 void RDvbhHaiAsyncTest::DoSetNetworkIdObserverTestStep(TBool aProperyExists)
641 TInt result = iRxInfo->SetNetworkIdObserver(*this);
642 if (result != KErrNone)
644 INFO_PRINTF2(_L("SetNetworkIdObserver returned error %d."), result);
651 //DoPreTest will have initialised the NetworkId to KInitialNetworkId.
652 //Now change it to KExpectedNetworkId.
653 if (iTestUtils->SetIntegerProperty(EDvbhPropertyKeyNetworkId, KExpectedNetworkId) != KErrNone)
655 StopTest(EInconclusive);
665 //Called when the NetworkId property changes if this NetworkId observer has been registerd
666 void RDvbhHaiAsyncTest::DvbhNetworkIdChange( const TDvbhNetworkId& aNewNetworkId )
668 TVerdict verdict = EPass;
669 if (aNewNetworkId != KExpectedNetworkId)
671 INFO_PRINTF2(_L("DvbhNetworkIdChange received unexpected value %d."), aNewNetworkId);
678 void RDvbhHaiAsyncTest::DoSetMultipleStateObserversTestStep(TBool aProperyExists)
680 // Set a state observer
681 TInt result = iRxInfo->SetStateObserver(*this);
682 if (result != KErrNone)
684 INFO_PRINTF2(_L("1st SetStateObserver returned error %d."), result);
689 // Now try to set another one
690 result = iRxInfo->SetStateObserver(*i2ndStateObserver);
691 if (result != KErrNone)
693 INFO_PRINTF2(_L("2nd SetStateObserver returned error %d."), result);
700 //DoPreTest will have initialised the state to KInitialState.
702 if (iTestUtils->SetStateProperty(KExpectedState) != KErrNone)
704 StopTest(EInconclusive);
715 void RDvbhHaiAsyncTest::DoCreateMultipleReceiverInfoTestStep(TBool aProperyExists)
717 // Set a state observer on the first CDvbhReceiverInfo object
718 TInt result = iRxInfo->SetStateObserver(*this);
719 if (result != KErrNone)
721 INFO_PRINTF2(_L("1st SetStateObserver returned error %d."), result);
726 // Now try to set another one on the 2nd CDvbhReceiverInfo object
727 result = i2ndRxInfo->SetStateObserver(*i2ndStateObserver);
728 if (result != KErrNone)
730 INFO_PRINTF2(_L("2nd SetStateObserver returned error %d."), result);
737 iStateCallbackVerdicts[E1stStateObserver] = KNoVerdict;
738 iStateCallbackVerdicts[E2ndStateObserver] = KNoVerdict;
739 //DoPreTest will have initialised the state to KInitialState.
741 if (iTestUtils->SetStateProperty(KExpectedState) != KErrNone)
743 StopTest(EInconclusive);
755 // RDvbhHaiAsyncTest::CAlternativeStateObserver
759 RDvbhHaiAsyncTest::CAlternativeStateObserver* RDvbhHaiAsyncTest::CAlternativeStateObserver::NewL(RDvbhHaiAsyncTest& aTestStep)
761 CAlternativeStateObserver* self = new (ELeave) CAlternativeStateObserver(aTestStep);
765 RDvbhHaiAsyncTest::CAlternativeStateObserver::CAlternativeStateObserver(RDvbhHaiAsyncTest& aTestStep)
766 : iTestStep(aTestStep)
770 void RDvbhHaiAsyncTest::CAlternativeStateObserver::DvbhStateChange( TDvbhState aNewState )
772 TVerdict verdict = EPass;
773 if (aNewState != KExpectedState)
775 iTestStep.INFO_PRINTF2(_L("CAlternativeStateObserver::DvbhStateChange received unexpected value %d."), aNewState);
780 // Test case MM-TV-DVBH-U-127 is expecting two callbacks on two different observers
781 if (iTestStep.iTestStepName.Compare(_L("MM-TV-DVBH-U-127")) == 0)
783 // Set the verdict for this observer
784 iTestStep.iStateCallbackVerdicts[E2ndStateObserver] = verdict;
785 //Check if the 1st observer has reported back yet. If not then we
786 //do not want to stop the test yet.
787 if (iTestStep.iStateCallbackVerdicts[E1stStateObserver] == KNoVerdict)
793 verdict = static_cast<TVerdict>(iTestStep.iStateCallbackVerdicts[E1stStateObserver]);
798 iTestStep.StopTest(verdict);
804 * Test to improve conditional code coverage. Tests KErrNoMemory failures
805 * with SetObserver methods.
807 void RDvbhHaiAsyncTest::DoSetObserversNoMemory()
810 __UHEAP_SETFAIL(RHeap::EFailNext, 1);
811 TInt result = iRxInfo->SetStateObserver(*this);
812 if (result != KErrNoMemory)
814 INFO_PRINTF2(_L("SetStateObserver returned %d."), result);
815 StopTest(EInconclusive);
816 __UHEAP_SETFAIL(RHeap::ENone, 0);
820 //SetSignalQualityObserver
821 __UHEAP_SETFAIL(RHeap::EFailNext, 1);
822 result = iRxInfo->SetSignalQualityObserver(*this);
823 if (result != KErrNoMemory)
825 INFO_PRINTF2(_L("SetSignalQualityObserver returned %d."), result);
826 StopTest(EInconclusive);
827 __UHEAP_SETFAIL(RHeap::ENone, 0);
831 //SetPlatformObserver
832 __UHEAP_SETFAIL(RHeap::EFailNext, 1);
833 result = iRxInfo->SetPlatformObserver(*this);
834 if (result != KErrNoMemory)
836 INFO_PRINTF2(_L("SetPlatformObserver returned %d."), result);
837 StopTest(EInconclusive);
838 __UHEAP_SETFAIL(RHeap::ENone, 0);
842 //SetNetworkTimeObserver
843 __UHEAP_SETFAIL(RHeap::EFailNext, 1);
844 result = iRxInfo->SetNetworkTimeObserver(*this);
845 if (result != KErrNoMemory)
847 INFO_PRINTF2(_L("SetNetworkTimeObserver returned %d."), result);
848 StopTest(EInconclusive);
849 __UHEAP_SETFAIL(RHeap::ENone, 0);
853 //SetFrequencyObserver
854 __UHEAP_SETFAIL(RHeap::EFailNext, 1);
855 result = iRxInfo->SetFrequencyObserver(*this);
856 if (result != KErrNoMemory)
858 INFO_PRINTF2(_L("SetFrequencyObserver returned %d."), result);
859 StopTest(EInconclusive);
860 __UHEAP_SETFAIL(RHeap::ENone, 0);
865 __UHEAP_SETFAIL(RHeap::EFailNext, 1);
866 result = iRxInfo->SetCellIdObserver(*this);
867 if (result != KErrNoMemory)
869 INFO_PRINTF2(_L("SetCellIdObserver returned %d."), result);
870 StopTest(EInconclusive);
871 __UHEAP_SETFAIL(RHeap::ENone, 0);
875 //SetNetworkIdObserver
876 __UHEAP_SETFAIL(RHeap::EFailNext, 1);
877 result = iRxInfo->SetNetworkIdObserver(*this);
878 if (result != KErrNoMemory)
880 INFO_PRINTF2(_L("SetNetworkIdObserver returned %d."), result);
881 StopTest(EInconclusive);
882 __UHEAP_SETFAIL(RHeap::ENone, 0);
886 __UHEAP_SETFAIL(RHeap::ENone, 0);