From 7bfe997e13f23d014ff3d4ba05c37ce898a48bff Mon Sep 17 00:00:00 2001 From: Amy Zhang Date: Fri, 15 May 2020 14:56:32 -0700 Subject: [PATCH] Add IFrontend.getStatus VTS test Test: atest VtsHalTvTunerV1_0TargetTest Bug: 150953857 Change-Id: I4979ae41f102dfd1a836c1d3a67bf3b932891e23 --- tv/tuner/1.0/vts/functional/FrontendTests.cpp | 115 ++++++++++++++++++ tv/tuner/1.0/vts/functional/FrontendTests.h | 2 + .../VtsHalTvTunerV1_0TestConfigurations.h | 12 ++ 3 files changed, 129 insertions(+) diff --git a/tv/tuner/1.0/vts/functional/FrontendTests.cpp b/tv/tuner/1.0/vts/functional/FrontendTests.cpp index fc5071ceaa..d54a9591c6 100644 --- a/tv/tuner/1.0/vts/functional/FrontendTests.cpp +++ b/tv/tuner/1.0/vts/functional/FrontendTests.cpp @@ -246,6 +246,120 @@ AssertionResult FrontendTests::stopScanFrontend() { return AssertionResult(status == Result::SUCCESS); } +void FrontendTests::verifyFrontendStatus(vector statusTypes, + vector expectStatuses) { + ASSERT_TRUE(mFrontend) << "Frontend is not opened yet."; + Result status; + vector realStatuses; + + mFrontend->getStatus(statusTypes, [&](Result result, const hidl_vec& statuses) { + status = result; + realStatuses = statuses; + }); + + ASSERT_TRUE(realStatuses.size() == statusTypes.size()); + for (int i = 0; i < statusTypes.size(); i++) { + FrontendStatusType type = statusTypes[i]; + switch (type) { + case FrontendStatusType::DEMOD_LOCK: { + ASSERT_TRUE(realStatuses[i].isDemodLocked() == expectStatuses[i].isDemodLocked()); + break; + } + case FrontendStatusType::SNR: { + ASSERT_TRUE(realStatuses[i].snr() == expectStatuses[i].snr()); + break; + } + case FrontendStatusType::BER: { + ASSERT_TRUE(realStatuses[i].ber() == expectStatuses[i].ber()); + break; + } + case FrontendStatusType::PER: { + ASSERT_TRUE(realStatuses[i].per() == expectStatuses[i].per()); + break; + } + case FrontendStatusType::PRE_BER: { + ASSERT_TRUE(realStatuses[i].preBer() == expectStatuses[i].preBer()); + break; + } + case FrontendStatusType::SIGNAL_QUALITY: { + ASSERT_TRUE(realStatuses[i].signalQuality() == expectStatuses[i].signalQuality()); + break; + } + case FrontendStatusType::SIGNAL_STRENGTH: { + ASSERT_TRUE(realStatuses[i].signalStrength() == expectStatuses[i].signalStrength()); + break; + } + case FrontendStatusType::SYMBOL_RATE: { + ASSERT_TRUE(realStatuses[i].symbolRate() == expectStatuses[i].symbolRate()); + break; + } + case FrontendStatusType::FEC: { + ASSERT_TRUE(realStatuses[i].innerFec() == expectStatuses[i].innerFec()); + break; + } + case FrontendStatusType::MODULATION: { + // TODO: check modulation status + break; + } + case FrontendStatusType::SPECTRAL: { + ASSERT_TRUE(realStatuses[i].inversion() == expectStatuses[i].inversion()); + break; + } + case FrontendStatusType::LNB_VOLTAGE: { + ASSERT_TRUE(realStatuses[i].lnbVoltage() == expectStatuses[i].lnbVoltage()); + break; + } + case FrontendStatusType::PLP_ID: { + ASSERT_TRUE(realStatuses[i].plpId() == expectStatuses[i].plpId()); + break; + } + case FrontendStatusType::EWBS: { + ASSERT_TRUE(realStatuses[i].isEWBS() == expectStatuses[i].isEWBS()); + break; + } + case FrontendStatusType::AGC: { + ASSERT_TRUE(realStatuses[i].agc() == expectStatuses[i].agc()); + break; + } + case FrontendStatusType::LNA: { + ASSERT_TRUE(realStatuses[i].isLnaOn() == expectStatuses[i].isLnaOn()); + break; + } + case FrontendStatusType::LAYER_ERROR: { + vector realLayberError = realStatuses[i].isLayerError(); + vector expectLayerError = expectStatuses[i].isLayerError(); + ASSERT_TRUE(realLayberError.size() == expectLayerError.size()); + for (int i = 0; i < realLayberError.size(); i++) { + ASSERT_TRUE(realLayberError[i] == expectLayerError[i]); + } + break; + } + case FrontendStatusType::MER: { + ASSERT_TRUE(realStatuses[i].mer() == expectStatuses[i].mer()); + break; + } + case FrontendStatusType::FREQ_OFFSET: { + ASSERT_TRUE(realStatuses[i].freqOffset() == expectStatuses[i].freqOffset()); + break; + } + case FrontendStatusType::HIERARCHY: { + ASSERT_TRUE(realStatuses[i].hierarchy() == expectStatuses[i].hierarchy()); + break; + } + case FrontendStatusType::RF_LOCK: { + ASSERT_TRUE(realStatuses[i].isRfLocked() == expectStatuses[i].isRfLocked()); + break; + } + case FrontendStatusType::ATSC3_PLP_INFO: + // TODO: verify plpinfo + break; + default: + continue; + } + } + ASSERT_TRUE(status == Result::SUCCESS); +} + AssertionResult FrontendTests::tuneFrontend(FrontendConfig config) { EXPECT_TRUE(mFrontendCallback) << "test with openFrontendById/setFrontendCallback/getFrontendInfo first."; @@ -294,6 +408,7 @@ void FrontendTests::tuneTest(FrontendConfig frontendConf) { ASSERT_TRUE(openFrontendById(feId)); ASSERT_TRUE(setFrontendCallback()); ASSERT_TRUE(tuneFrontend(frontendConf)); + verifyFrontendStatus(frontendConf.tuneStatusTypes, frontendConf.expectTuneStatuses); ASSERT_TRUE(stopTuneFrontend()); ASSERT_TRUE(closeFrontend()); } diff --git a/tv/tuner/1.0/vts/functional/FrontendTests.h b/tv/tuner/1.0/vts/functional/FrontendTests.h index 1a9bec9627..2bdc8fd3d9 100644 --- a/tv/tuner/1.0/vts/functional/FrontendTests.h +++ b/tv/tuner/1.0/vts/functional/FrontendTests.h @@ -109,6 +109,8 @@ class FrontendTests { AssertionResult scanFrontend(FrontendConfig config, FrontendScanType type); AssertionResult stopScanFrontend(); AssertionResult tuneFrontend(FrontendConfig config); + void verifyFrontendStatus(vector statusTypes, + vector expectStatuses); AssertionResult stopTuneFrontend(); AssertionResult closeFrontend(); diff --git a/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TestConfigurations.h b/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TestConfigurations.h index b84013b665..287f673293 100644 --- a/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TestConfigurations.h +++ b/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TestConfigurations.h @@ -40,6 +40,8 @@ using android::hardware::tv::tuner::V1_0::FrontendDvbtSettings; using android::hardware::tv::tuner::V1_0::FrontendDvbtStandard; using android::hardware::tv::tuner::V1_0::FrontendDvbtTransmissionMode; using android::hardware::tv::tuner::V1_0::FrontendSettings; +using android::hardware::tv::tuner::V1_0::FrontendStatus; +using android::hardware::tv::tuner::V1_0::FrontendStatusType; using android::hardware::tv::tuner::V1_0::FrontendType; using android::hardware::tv::tuner::V1_0::PlaybackSettings; using android::hardware::tv::tuner::V1_0::RecordSettings; @@ -88,6 +90,8 @@ struct FilterConfig { struct FrontendConfig { FrontendType type; FrontendSettings settings; + vector tuneStatusTypes; + vector expectTuneStatuses; }; struct ChannelConfig { @@ -127,6 +131,14 @@ inline void initFrontendConfig() { .standard = FrontendDvbtStandard::T, }; frontendArray[DVBT].type = FrontendType::DVBT, frontendArray[DVBT].settings.dvbt(dvbtSettings); + vector types; + types.push_back(FrontendStatusType::DEMOD_LOCK); + FrontendStatus status; + status.isDemodLocked(true); + vector statuses; + statuses.push_back(status); + frontendArray[DVBT].tuneStatusTypes = types; + frontendArray[DVBT].expectTuneStatuses = statuses; frontendArray[DVBS].type = FrontendType::DVBS; };