Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82101d2d authored by Frankie Lizcano's avatar Frankie Lizcano
Browse files

Tuner HAL VTS: Testing LnbDescrambling

This CL implements integration tests for LnbDescrambling. The new
testing function ScrambledBroadcastTestWithLnb tests the functionality
of the Lnb and, if the frontend is not software, tests passing a signal
through the tuner and descrambling a broadcast.

Additionally, this CL adds a context variable to the
ScrambledBroadcastTest function to determine which dataflow
(LnbDescrambling or Descrambling) is being tested. It specializes
behavior differently for each datflow to model real world
use cases. Notably, a Descrambler could be tested with no frontend when
playing back a descrambled recording, whereas testing an Lnb broadcast
would require a hardware frontend.

Bug: b/240476983

Test: ts-tradefed run vts --module VtsHalTvTunerTargetTest
Change-Id: Ia35d2d45dca4411b0a15f0585d6ddaecd3f9321a
parent 523e5455
Loading
Loading
Loading
Loading
+100 −26
Original line number Diff line number Diff line
@@ -428,12 +428,14 @@ void TunerRecordAidlTest::recordSingleFilterTest(FilterConfig filterConf,

void TunerDescramblerAidlTest::scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
                                                      FrontendConfig frontendConf,
                                                      DescramblerConfig descConfig) {
                                                      DescramblerConfig descConfig,
                                                      Dataflow_Context context) {
    int32_t demuxId;
    std::shared_ptr<IDemux> demux;
    ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));

    DvrConfig dvrSourceConfig;
    if (context == Dataflow_Context::DESCRAMBLING) {
        if (descrambling.hasFrontendConnection) {
            int32_t feId;
            mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
@@ -451,6 +453,21 @@ void TunerDescramblerAidlTest::scrambledBroadcastTest(set<struct FilterConfig> m
            ASSERT_TRUE(mDvrTests.configDvrPlayback(dvrSourceConfig.settings));
            ASSERT_TRUE(mDvrTests.getDvrPlaybackMQDescriptor());
        }
    } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
        int32_t feId;
        mFrontendTests.getFrontendIdByType(frontendConf.type, feId);
        ASSERT_TRUE(mFrontendTests.openFrontendById(feId));
        ASSERT_TRUE(mFrontendTests.setFrontendCallback());
        if (mLnbId != INVALID_LNB_ID) {
            ASSERT_TRUE(mFrontendTests.setLnb(mLnbId));
        } else {
            // If, for some reason, the test got here without failing. We fail it here.
            ALOGD("mLnbId is null. Something went wrong. Exiting ScrambledBroadcastWithLnbId.");
            FAIL();
        }
        ASSERT_TRUE(mDemuxTests.setDemuxFrontendDataSource(feId));
        mFrontendTests.setDemux(demux);
    }

    set<int64_t> filterIds;
    int64_t filterId;
@@ -480,6 +497,7 @@ void TunerDescramblerAidlTest::scrambledBroadcastTest(set<struct FilterConfig> m
        ASSERT_TRUE(mFilterTests.startFilter(*id));
    }

    if (context == Dataflow_Context::DESCRAMBLING) {
        if (descrambling.hasFrontendConnection) {
            // tune test
            ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
@@ -490,15 +508,22 @@ void TunerDescramblerAidlTest::scrambledBroadcastTest(set<struct FilterConfig> m
                    dvrSourceConfig.settings.get<DvrSettings::Tag::playback>());
            ASSERT_TRUE(mDvrTests.startDvrPlayback());
        }
    } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
        ASSERT_TRUE(mFrontendTests.tuneFrontend(frontendConf, true /*testWithDemux*/));
    }

    ASSERT_TRUE(filterDataOutputTest());

    if (context == Dataflow_Context::DESCRAMBLING) {
        if (descrambling.hasFrontendConnection) {
            ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
        } else {
            mDvrTests.stopPlaybackThread();
            ASSERT_TRUE(mDvrTests.stopDvrPlayback());
        }
    } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
        ASSERT_TRUE(mFrontendTests.stopTuneFrontend(true /*testWithDemux*/));
    }

    for (id = filterIds.begin(); id != filterIds.end(); id++) {
        ASSERT_TRUE(mFilterTests.stopFilter(*id));
@@ -511,15 +536,50 @@ void TunerDescramblerAidlTest::scrambledBroadcastTest(set<struct FilterConfig> m
        ASSERT_TRUE(mFilterTests.closeFilter(*id));
    }

    if (context == Dataflow_Context::DESCRAMBLING) {
        if (descrambling.hasFrontendConnection) {
            ASSERT_TRUE(mFrontendTests.closeFrontend());
        } else {
            mDvrTests.closeDvrPlayback();
        }
    } else if (context == Dataflow_Context::LNBDESCRAMBLING) {
        ASSERT_TRUE(mFrontendTests.closeFrontend());
    }

    ASSERT_TRUE(mDemuxTests.closeDemux());
}

void TunerDescramblerAidlTest::scrambledBroadcastTestWithLnb(
        set<struct FilterConfig>& mediaFilterConfs, FrontendConfig& frontendConf,
        DescramblerConfig& descConfig, LnbConfig& lnbConfig) {
    // We can test the Lnb individually and make sure it functions properly. If the frontend is
    // software, we cannot test the whole dataflow. If the frontend is hardware, we can
    if (lnbConfig.name.compare(emptyHardwareId) == 0) {
        vector<int32_t> ids;
        ASSERT_TRUE(mLnbTests.getLnbIds(ids));
        ASSERT_TRUE(ids.size() > 0);
        ASSERT_TRUE(mLnbTests.openLnbById(ids[0]));
        mLnbId = ids[0];
    } else {
        ASSERT_TRUE(mLnbTests.openLnbByName(lnbConfig.name, mLnbId));
    }
    // Once Lnb is opened, test some of its basic functionality
    ASSERT_TRUE(mLnbTests.setLnbCallback());
    ASSERT_TRUE(mLnbTests.setVoltage(lnbConfig.voltage));
    ASSERT_TRUE(mLnbTests.setTone(lnbConfig.tone));
    ASSERT_TRUE(mLnbTests.setSatellitePosition(lnbConfig.position));
    if (!frontendConf.isSoftwareFe) {
        ALOGD("Frontend is not software, testing entire dataflow.");
        scrambledBroadcastTest(mediaFilterConfs, frontendConf, descConfig,
                               Dataflow_Context::LNBDESCRAMBLING);
    } else {
        ALOGD("Frontend is software, did not test the entire dataflow, but tested the Lnb "
              "individually.");
    }
    ASSERT_TRUE(mLnbTests.closeLnb());
    mLnbId = INVALID_LNB_ID;
}

TEST_P(TunerLnbAidlTest, SendDiseqcMessageToLnb) {
    description("Open and configure an Lnb with specific settings then send a diseqc msg to it.");
    if (!lnbLive.support) {
@@ -1227,8 +1287,22 @@ TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTest) {
        filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.audioFilterId]));
        filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.videoFilterId]));
        scrambledBroadcastTest(filterConfs, frontendMap[descrambling.frontendId],
                               descramblerMap[descrambling.descramblerId]);
                               descramblerMap[descrambling.descramblerId],
                               Dataflow_Context::DESCRAMBLING);
    }
}

TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTestWithLnb) {
    description("Test media filters in scrambled broadcast use case with Lnb");
    if (!lnbDescrambling.support) {
        return;
    }
    set<FilterConfig> filterConfs;
    filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.audioFilterId]));
    filterConfs.insert(static_cast<FilterConfig>(filterMap[lnbDescrambling.videoFilterId]));
    scrambledBroadcastTestWithLnb(filterConfs, frontendMap[lnbDescrambling.frontendId],
                                  descramblerMap[lnbDescrambling.descramblerId],
                                  lnbMap[lnbDescrambling.lnbId]);
}

INSTANTIATE_TEST_SUITE_P(PerInstance, TunerBroadcastAidlTest,
+11 −2
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ void clearIds() {
    sectionFilterIds.clear();
}

enum class Dataflow_Context { LNBRECORD, RECORD };
enum class Dataflow_Context { LNBRECORD, RECORD, DESCRAMBLING, LNBDESCRAMBLING };

class TunerLnbAidlTest : public testing::TestWithParam<std::string> {
  public:
@@ -407,6 +407,7 @@ class TunerDescramblerAidlTest : public testing::TestWithParam<std::string> {
        mDvrTests.setService(mService);
        mDescramblerTests.setService(mService);
        mDescramblerTests.setCasService(mCasService);
        mLnbTests.setService(mService);
    }

    virtual void TearDown() override {
@@ -420,7 +421,11 @@ class TunerDescramblerAidlTest : public testing::TestWithParam<std::string> {
    }

    void scrambledBroadcastTest(set<struct FilterConfig> mediaFilterConfs,
                                FrontendConfig frontendConf, DescramblerConfig descConfig);
                                FrontendConfig frontendConf, DescramblerConfig descConfig,
                                Dataflow_Context context);
    void scrambledBroadcastTestWithLnb(set<struct FilterConfig>& mediaFilterConfs,
                                       FrontendConfig& frontendConf, DescramblerConfig& descConfig,
                                       LnbConfig& lnbConfig);
    AssertionResult filterDataOutputTest();

    std::shared_ptr<ITuner> mService;
@@ -430,6 +435,10 @@ class TunerDescramblerAidlTest : public testing::TestWithParam<std::string> {
    FilterTests mFilterTests;
    DescramblerTests mDescramblerTests;
    DvrTests mDvrTests;
    LnbTests mLnbTests;

  private:
    int32_t mLnbId = INVALID_LNB_ID;
};

GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(TunerDescramblerAidlTest);
+6 −1
Original line number Diff line number Diff line
@@ -196,7 +196,6 @@
                      videoFilterConnection="FILTER_VIDEO_DEFAULT"
                      dvrSoftwareFeConnection="DVR_PLAYBACK_0"
                      dvrSourceConnection="DVR_PLAYBACK_1">
                      <optionalFilters>FILTER_TS_RECORD_0 FILTER_IP_IP_0</optionalFilters>
        </descrambling>
        <timeFilter timeFilterConnection="TIME_FILTER_0"/>
        <lnbLive frontendConnection="FE_DVBS_0"
@@ -209,5 +208,11 @@
                   dvrRecordConnection="DVR_RECORD_0"
                   lnbConnection="LNB_0"
                   diseqcMsgSender="DISEQC_POWER_ON"/>
        <lnbDescrambling frontendConnection="FE_DVBS_0"
                        audioFilterConnection="FILTER_AUDIO_DEFAULT"
                        videoFilterConnection="FILTER_VIDEO_DEFAULT"
                        lnbConnection="LNB_1"
                        descramblerConnection="DESCRAMBLER_0"/>

    </dataFlowConfiguration>
</TunerConfiguration>