From 4a93c03793808db491ee8bd1e9772cc55641b601 Mon Sep 17 00:00:00 2001 From: Amy Date: Mon, 19 Aug 2019 13:12:17 -0700 Subject: [PATCH] Tuner HAL VTS for Demux and Descrambler Interface. Bug: 135708935 Test: Manual Change-Id: I1f2c9bfe6036dc6070dbf88d9728645f2568dcde Merged-In: I1f2c9bfe6036dc6070dbf88d9728645f2568dcde --- .../VtsHalTvTunerV1_0TargetTest.cpp | 130 ++++++++++++++++++ 1 file changed, 130 insertions(+) diff --git a/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TargetTest.cpp b/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TargetTest.cpp index 4840a02e25..c652944fee 100644 --- a/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TargetTest.cpp +++ b/tv/tuner/1.0/vts/functional/VtsHalTvTunerV1_0TargetTest.cpp @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -52,6 +55,9 @@ using android::hardware::tv::tuner::V1_0::FrontendEventType; using android::hardware::tv::tuner::V1_0::FrontendId; using android::hardware::tv::tuner::V1_0::FrontendInnerFec; using android::hardware::tv::tuner::V1_0::FrontendSettings; +using android::hardware::tv::tuner::V1_0::IDemux; +using android::hardware::tv::tuner::V1_0::IDemuxCallback; +using android::hardware::tv::tuner::V1_0::IDescrambler; using android::hardware::tv::tuner::V1_0::IFrontend; using android::hardware::tv::tuner::V1_0::IFrontendCallback; using android::hardware::tv::tuner::V1_0::ITuner; @@ -146,11 +152,19 @@ class TunerHidlTest : public ::testing::VtsHalHidlTargetTestBase { sp mFrontend; sp mFrontendCallback; + sp mDescrambler; + sp mDemux; + uint32_t mDemuxId; ::testing::AssertionResult createFrontend(int32_t frontendId); ::testing::AssertionResult tuneFrontend(int32_t frontendId); ::testing::AssertionResult stopTuneFrontend(int32_t frontendId); ::testing::AssertionResult closeFrontend(int32_t frontendId); + ::testing::AssertionResult createDemux(); + ::testing::AssertionResult createDemuxWithFrontend(int32_t frontendId); + ::testing::AssertionResult closeDemux(); + ::testing::AssertionResult createDescrambler(); + ::testing::AssertionResult closeDescrambler(); }; ::testing::AssertionResult TunerHidlTest::createFrontend(int32_t frontendId) { @@ -215,6 +229,78 @@ class TunerHidlTest : public ::testing::VtsHalHidlTargetTestBase { return ::testing::AssertionResult(status == Result::SUCCESS); } +::testing::AssertionResult TunerHidlTest::createDemux() { + Result status; + + mService->openDemux([&](Result result, uint32_t demuxId, const sp& demux) { + mDemux = demux; + mDemuxId = demuxId; + status = result; + }); + return ::testing::AssertionResult(status == Result::SUCCESS); +} + +::testing::AssertionResult TunerHidlTest::createDemuxWithFrontend(int32_t frontendId) { + Result status; + + if (createDemux() == ::testing::AssertionFailure()) { + return ::testing::AssertionFailure(); + } + + if (createFrontend(frontendId) == ::testing::AssertionFailure()) { + return ::testing::AssertionFailure(); + } + + status = mDemux->setFrontendDataSource(frontendId); + + return ::testing::AssertionResult(status == Result::SUCCESS); +} + +::testing::AssertionResult TunerHidlTest::closeDemux() { + Result status; + if (createDemux() == ::testing::AssertionFailure()) { + return ::testing::AssertionFailure(); + } + + status = mDemux->close(); + return ::testing::AssertionResult(status == Result::SUCCESS); +} + +::testing::AssertionResult TunerHidlTest::createDescrambler() { + Result status; + + mService->openDescrambler([&](Result result, const sp& descrambler) { + mDescrambler = descrambler; + status = result; + }); + if (status != Result::SUCCESS) { + return ::testing::AssertionFailure(); + } + + if (createDemux() == ::testing::AssertionFailure()) { + return ::testing::AssertionFailure(); + } + + status = mDescrambler->setDemuxSource(mDemuxId); + if (status != Result::SUCCESS) { + return ::testing::AssertionFailure(); + } + + // Test if demux source can be set more than once. + status = mDescrambler->setDemuxSource(mDemuxId); + return ::testing::AssertionResult(status == Result::INVALID_STATE); +} + +::testing::AssertionResult TunerHidlTest::closeDescrambler() { + Result status; + if (createDescrambler() == ::testing::AssertionFailure()) { + return ::testing::AssertionFailure(); + } + + status = mDescrambler->close(); + return ::testing::AssertionResult(status == Result::SUCCESS); +} + TEST_F(TunerHidlTest, CreateFrontend) { Result status; hidl_vec feIds; @@ -295,6 +381,50 @@ TEST_F(TunerHidlTest, CloseFrontend) { } } +TEST_F(TunerHidlTest, CreateDemux) { + description("Create Demux"); + + ASSERT_TRUE(createDemux()); +} + +TEST_F(TunerHidlTest, CreateDemuxWithFrontend) { + Result status; + hidl_vec feIds; + + description("Create Demux with Frontend"); + mService->getFrontendIds([&](Result result, const hidl_vec& frontendIds) { + status = result; + feIds = frontendIds; + }); + + if (feIds.size() == 0) { + ALOGW("[ WARN ] Frontend isn't available"); + return; + } + + for (size_t i = 0; i < feIds.size(); i++) { + ASSERT_TRUE(createDemuxWithFrontend(feIds[i])); + } +} + +TEST_F(TunerHidlTest, CloseDemux) { + description("Close Demux"); + + ASSERT_TRUE(closeDemux()); +} + +TEST_F(TunerHidlTest, CreateDescrambler) { + description("Create Descrambler"); + + ASSERT_TRUE(createDescrambler()); +} + +TEST_F(TunerHidlTest, CloseDescrambler) { + description("Close Descrambler"); + + ASSERT_TRUE(closeDescrambler()); +} + } // namespace int main(int argc, char** argv) {