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

Commit 81dcde82 authored by Frankie Lizcano's avatar Frankie Lizcano Committed by Android (Google) Code Review
Browse files

Merge changes Ic1b9dae6,I470d5931,Ic6756e28,Iba526237,I8e8be258

* changes:
  Improve Tuner VTS: Generate Descrambling Combos
  Improve Tuner VTS: Generate LnbRecord Combos
  Improve Tuner VTS: Generate Scan Combos
  Improve Tuner VTS: Generate LnbLive Combos
  Improve Tuner VTS: Generate DVR Playback Combos
parents 71c423fb f4e0796e
Loading
Loading
Loading
Loading
+117 −48
Original line number Diff line number Diff line
@@ -494,6 +494,14 @@ TEST_P(TunerLnbAidlTest, SendDiseqcMessageToLnb) {
    if (!lnbLive.support) {
        return;
    }
    vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations();
    if (lnbLive_configs.empty()) {
        ALOGD("No frontends that support satellites.");
        return;
    }
    for (auto& combination : lnbLive_configs) {
        lnbLive = combination;

        if (lnbMap[lnbLive.lnbId].name.compare(emptyHardwareId) == 0) {
            vector<int32_t> ids;
            ASSERT_TRUE(mLnbTests.getLnbIds(ids));
@@ -512,6 +520,7 @@ TEST_P(TunerLnbAidlTest, SendDiseqcMessageToLnb) {
        }
        ASSERT_TRUE(mLnbTests.closeLnb());
    }
}

TEST_P(TunerDemuxAidlTest, openDemux) {
    description("Open and close a Demux.");
@@ -839,27 +848,41 @@ TEST_P(TunerFilterAidlTest, FilterDelayHintTest) {

TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsSectionFilterTest) {
    description("Feed ts data from playback and configure Ts section filter to get output");
    if (!playback.support || playback.sectionFilterId.compare(emptyHardwareId) == 0) {
    if (!playback.support) {
        return;
    }
    vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
    for (auto& configuration : playback_configs) {
        if (configuration.sectionFilterId.compare(emptyHardwareId) != 0) {
            playback = configuration;
            playbackSingleFilterTest(filterMap[playback.sectionFilterId], dvrMap[playback.dvrId]);
        }
    }
}

TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsAudioFilterTest) {
    description("Feed ts data from playback and configure Ts audio filter to get output");
    if (!playback.support) {
        return;
    }
    vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
    for (auto& configuration : playback_configs) {
        playback = configuration;
        playbackSingleFilterTest(filterMap[playback.audioFilterId], dvrMap[playback.dvrId]);
    }
}

TEST_P(TunerPlaybackAidlTest, PlaybackDataFlowWithTsVideoFilterTest) {
    description("Feed ts data from playback and configure Ts video filter to get output");
    if (!playback.support) {
        return;
    }
    vector<DvrPlaybackHardwareConnections> playback_configs = generatePlaybackConfigs();
    for (auto& configuration : playback_configs) {
        playback = configuration;
        playbackSingleFilterTest(filterMap[playback.videoFilterId], dvrMap[playback.dvrId]);
    }
}

TEST_P(TunerRecordAidlTest, RecordDataFlowWithTsRecordFilterTest) {
    description("Feed ts data from frontend to recording and test with ts record filter");
@@ -885,9 +908,17 @@ TEST_P(TunerRecordAidlTest, LnbRecordDataFlowWithTsRecordFilterTest) {
    if (!lnbRecord.support) {
        return;
    }
    vector<LnbRecordHardwareConnections> lnbRecord_configs = generateLnbRecordConfigurations();
    if (lnbRecord_configs.empty()) {
        ALOGD("No frontends that support satellites.");
        return;
    }
    for (auto& configuration : lnbRecord_configs) {
        lnbRecord = configuration;
        recordSingleFilterTestWithLnb(filterMap[lnbRecord.recordFilterId],
                                  frontendMap[lnbRecord.frontendId], dvrMap[lnbRecord.dvrRecordId],
                                  lnbMap[lnbRecord.lnbId]);
                                      frontendMap[lnbRecord.frontendId],
                                      dvrMap[lnbRecord.dvrRecordId], lnbMap[lnbRecord.lnbId]);
    }
}

TEST_P(TunerFrontendAidlTest, TuneFrontend) {
@@ -903,16 +934,24 @@ TEST_P(TunerFrontendAidlTest, AutoScanFrontend) {
    if (!scan.hasFrontendConnection) {
        return;
    }
    vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
    for (auto& configuration : scan_configs) {
        scan = configuration;
        mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_AUTO);
    }
}

TEST_P(TunerFrontendAidlTest, BlindScanFrontend) {
    description("Run an blind frontend scan with specific setting and check lock scanMessage");
    if (!scan.hasFrontendConnection) {
        return;
    }
    vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
    for (auto& configuration : scan_configs) {
        scan = configuration;
        mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND);
    }
}

TEST_P(TunerFrontendAidlTest, TuneFrontendWithFrontendSettings) {
    description("Tune one Frontend with setting and check Lock event");
@@ -927,8 +966,12 @@ TEST_P(TunerFrontendAidlTest, BlindScanFrontendWithEndFrequency) {
    if (!scan.hasFrontendConnection) {
        return;
    }
    vector<ScanHardwareConnections> scan_configs = generateScanConfigurations();
    for (auto& configuration : scan_configs) {
        scan = configuration;
        mFrontendTests.scanTest(frontendMap[scan.frontendId], FrontendScanType::SCAN_BLIND);
    }
}

TEST_P(TunerFrontendAidlTest, LinkToCiCam) {
    description("Test Frontend link to CiCam");
@@ -1005,9 +1048,17 @@ TEST_P(TunerBroadcastAidlTest, LnbBroadcastDataFlowVideoFilterTest) {
    if (!lnbLive.support) {
        return;
    }
    vector<LnbLiveHardwareConnections> lnbLive_configs = generateLnbLiveConfigurations();
    if (lnbLive_configs.empty()) {
        ALOGD("No frontends that support satellites.");
        return;
    }
    for (auto& combination : lnbLive_configs) {
        lnbLive = combination;
        broadcastSingleFilterTestWithLnb(filterMap[lnbLive.videoFilterId],
                                         frontendMap[lnbLive.frontendId], lnbMap[lnbLive.lnbId]);
    }
}

TEST_P(TunerBroadcastAidlTest, MediaFilterWithSharedMemoryHandle) {
    description("Test the Media Filter with shared memory handle");
@@ -1022,6 +1073,14 @@ TEST_P(TunerDescramblerAidlTest, CreateDescrambler) {
    if (!descrambling.support) {
        return;
    }
    vector<DescramblingHardwareConnections> descrambling_configs =
            generateDescramblingConfigurations();
    if (descrambling_configs.empty()) {
        ALOGD("No valid descrambling combinations in the configuration file.");
        return;
    }
    for (auto& combination : descrambling_configs) {
        descrambling = combination;
        int32_t demuxId;
        std::shared_ptr<IDemux> demux;
        ASSERT_TRUE(mDemuxTests.openDemux(demux, demuxId));
@@ -1043,18 +1102,28 @@ TEST_P(TunerDescramblerAidlTest, CreateDescrambler) {
            ASSERT_TRUE(mFrontendTests.closeFrontend());
        }
    }
}

TEST_P(TunerDescramblerAidlTest, ScrambledBroadcastDataFlowMediaFiltersTest) {
    description("Test ts audio filter in scrambled broadcast use case");
    if (!descrambling.support) {
        return;
    }
    vector<DescramblingHardwareConnections> descrambling_configs =
            generateDescramblingConfigurations();
    if (descrambling_configs.empty()) {
        ALOGD("No valid descrambling combinations in the configuration file.");
        return;
    }
    for (auto& combination : descrambling_configs) {
        descrambling = combination;
        set<FilterConfig> filterConfs;
        filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.audioFilterId]));
        filterConfs.insert(static_cast<FilterConfig>(filterMap[descrambling.videoFilterId]));
        scrambledBroadcastTest(filterConfs, frontendMap[descrambling.frontendId],
                               descramblerMap[descrambling.descramblerId]);
    }
}

INSTANTIATE_TEST_SUITE_P(PerInstance, TunerBroadcastAidlTest,
                         testing::ValuesIn(android::getAidlHalInstanceNames(ITuner::descriptor)),
+5 −0
Original line number Diff line number Diff line
@@ -65,11 +65,16 @@ AssertionResult filterDataOutputTestBase(FilterTests& tests) {
}

void clearIds() {
    lnbIds.clear();
    diseqcMsgs.clear();
    frontendIds.clear();
    recordDvrIds.clear();
    descramblerIds.clear();
    audioFilterIds.clear();
    videoFilterIds.clear();
    playbackDvrIds.clear();
    recordFilterIds.clear();
    sectionFilterIds.clear();
}

class TunerLnbAidlTest : public testing::TestWithParam<std::string> {
+304 −1
Original line number Diff line number Diff line
@@ -75,6 +75,309 @@ static LnbLiveHardwareConnections lnbLive;
static LnbRecordHardwareConnections lnbRecord;
static TimeFilterHardwareConnections timeFilter;

/*
 * This function takes in a 2d vector of device Id's
 * The n vectors correlate to the ids for n different devices (eg frontends, filters)
 * The resultant 2d vector is every combination of id's with 1 id from each vector
 */
inline vector<vector<string>> generateIdCombinations(vector<vector<string>>& ids) {
    vector<vector<string>> combinations;

    // The index of each vector in ids that will be used in the next combination
    // EG {0, 2} means combo {ids[0][0] ids[1][2]} will be next
    const int size = static_cast<int>(ids.size());
    vector<int> indexes_used_in_combination(size, 0);

    // The vector number from ids whose elements we will cycle through to make combinations.
    // First, start at the right most vector
    int cycled_vector = size - 1;

    while (cycled_vector >= 0) {
        // Make a combination (one at a time)
        vector<string> combo;
        for (size_t i = 0; i < indexes_used_in_combination.size(); ++i) {
            const int combo_index = indexes_used_in_combination[i];
            combo.push_back(ids[i][combo_index]);
        }
        combinations.push_back(combo);

        // Find the right most vector that still has space [elements left] to cycle through and
        // create a combination
        while (cycled_vector >= 0 &&
               indexes_used_in_combination[cycled_vector] == ids[cycled_vector].size() - 1) {
            cycled_vector--;
        }

        // Use this check to avoid segmentation faults
        if (cycled_vector >= 0) {
            // Once found, we have a vector we can cycle through, so increase to its next element
            indexes_used_in_combination[cycled_vector]++;

            // Reset the other vectors to the right to their first element so we can cycle through
            // them again with the new element from cycled vector
            for (size_t i = cycled_vector + 1; i < indexes_used_in_combination.size(); ++i) {
                indexes_used_in_combination[i] = 0;
            }

            // all the vectors to the right were reset, so we can cycle through them again
            // Start at the furthest right vector
            cycled_vector = size - 1;
        }
    }

    return combinations;
}

/*
 * index 0 - playback dvr
 * index 1 - audio filters
 * index 2 - video filters
 * index 3 - optional section filters
 */
static inline vector<DvrPlaybackHardwareConnections> generatePlaybackCombinations() {
    vector<DvrPlaybackHardwareConnections> combinations;
    vector<string> sectionFilterIds_optional = sectionFilterIds;
    sectionFilterIds_optional.push_back(emptyHardwareId);
    vector<vector<string>> deviceIds{playbackDvrIds, audioFilterIds, videoFilterIds,
                                     sectionFilterIds_optional};

    const int dvrIndex = 0;
    const int audioFilterIndex = 1;
    const int videoFilterIndex = 2;
    const int sectionFilterIndex = 3;

    auto idCombinations = generateIdCombinations(deviceIds);
    for (auto& combo : idCombinations) {
        DvrPlaybackHardwareConnections mPlayback;
        mPlayback.dvrId = combo[dvrIndex];
        mPlayback.audioFilterId = combo[audioFilterIndex];
        mPlayback.videoFilterId = combo[videoFilterIndex];
        mPlayback.sectionFilterId = combo[sectionFilterIndex];
        combinations.push_back(mPlayback);
    }

    return combinations;
}

static inline vector<DvrPlaybackHardwareConnections> generatePlaybackConfigs() {
    vector<DvrPlaybackHardwareConnections> playback_configs;
    if (configuredPlayback) {
        ALOGD("Using DVR playback configuration provided.");
        playback_configs = {playback};
    } else {
        ALOGD("Dvr playback not provided. Generating possible combinations. Consider adding it to "
              "the configuration file.");
        playback_configs = generatePlaybackCombinations();
    }

    return playback_configs;
}

/*
 * index 0 - frontends
 * index 1 - audio filters
 * index 2 - video filters
 * index 3 - lnbs
 */
static inline vector<LnbLiveHardwareConnections> generateLnbLiveCombinations() {
    vector<LnbLiveHardwareConnections> combinations;
    vector<vector<string>> deviceIds{frontendIds, audioFilterIds, videoFilterIds, lnbIds};

    const int frontendIndex = 0;
    const int audioFilterIndex = 1;
    const int videoFilterIndex = 2;
    const int lnbIndex = 3;

    // TODO: Find a better way to vary diseqcMsgs, if at all
    auto idCombinations = generateIdCombinations(deviceIds);
    for (auto& combo : idCombinations) {
        const string feId = combo[frontendIndex];
        auto type = frontendMap[feId].type;
        if (type == FrontendType::DVBS || type == FrontendType::ISDBS ||
            type == FrontendType::ISDBS3) {
            LnbLiveHardwareConnections mLnbLive;
            mLnbLive.frontendId = feId;
            mLnbLive.audioFilterId = combo[audioFilterIndex];
            mLnbLive.videoFilterId = combo[videoFilterIndex];
            mLnbLive.lnbId = combo[lnbIndex];
            mLnbLive.diseqcMsgs = diseqcMsgs;
            combinations.push_back(mLnbLive);
        }
    }

    return combinations;
}

static inline vector<LnbLiveHardwareConnections> generateLnbLiveConfigurations() {
    vector<LnbLiveHardwareConnections> lnbLive_configs;
    if (configuredLnbLive) {
        ALOGD("Using LnbLive configuration provided.");
        lnbLive_configs = {lnbLive};
    } else {
        ALOGD("LnbLive not provided. Generating possible combinations. Consider adding it to the "
              "configuration file.");
        lnbLive_configs = generateLnbLiveCombinations();
    }

    return lnbLive_configs;
}

static inline vector<ScanHardwareConnections> generateScanCombinations() {
    vector<ScanHardwareConnections> combinations;

    for (auto& id : frontendIds) {
        ScanHardwareConnections mScan;
        mScan.frontendId = id;
        combinations.push_back(mScan);
    }

    return combinations;
}

static inline vector<ScanHardwareConnections> generateScanConfigurations() {
    vector<ScanHardwareConnections> scan_configs;
    if (configuredScan) {
        ALOGD("Using scan configuration provided.");
        scan_configs = {scan};
    } else {
        ALOGD("Scan not provided. Generating possible combinations. Consider adding it to "
              "the configuration file.");
        scan_configs = generateScanCombinations();
    }

    return scan_configs;
}

/*
 * index 0 - frontends
 * index 1 - record filter
 * index 2 - Record Dvr
 * index 3 - Lnb
 */
static inline vector<LnbRecordHardwareConnections> generateLnbRecordCombinations() {
    vector<LnbRecordHardwareConnections> combinations;
    vector<vector<string>> deviceIds{frontendIds, recordFilterIds, recordDvrIds, lnbIds};

    const int frontendIndex = 0;
    const int recordFilterIndex = 1;
    const int dvrIndex = 2;
    const int lnbIndex = 3;

    auto idCombinations = generateIdCombinations(deviceIds);
    // TODO : Find a better way to vary diseqcMsgs, if at all
    for (auto& combo : idCombinations) {
        const string feId = combo[frontendIndex];
        auto type = frontendMap[feId].type;
        if (type == FrontendType::DVBS || type == FrontendType::ISDBS ||
            type == FrontendType::ISDBS3) {
            LnbRecordHardwareConnections mLnbRecord;
            mLnbRecord.frontendId = feId;
            mLnbRecord.recordFilterId = combo[recordFilterIndex];
            mLnbRecord.dvrRecordId = combo[dvrIndex];
            mLnbRecord.lnbId = combo[lnbIndex];
            mLnbRecord.diseqcMsgs = diseqcMsgs;
            combinations.push_back(mLnbRecord);
        }
    }

    return combinations;
}

static inline vector<LnbRecordHardwareConnections> generateLnbRecordConfigurations() {
    vector<LnbRecordHardwareConnections> lnbRecord_configs;
    if (configuredLnbRecord) {
        ALOGD("Using LnbRecord configuration provided.");
        lnbRecord_configs = {lnbRecord};
    } else {
        ALOGD("LnbRecord not provided. Generating possible combinations. Consider adding it to "
              "the configuration file.");
        lnbRecord_configs = generateLnbRecordCombinations();
    }

    return lnbRecord_configs;
}

/*
 * index 0 - decramblers
 * index 1 - frontends
 * index 2 - audio filters
 * index 3 - video filters
 * index 4 - Dvr SW Fe Connections
 * index 5 - DVR Source Connections
 */
static inline vector<DescramblingHardwareConnections> generateDescramblingCombinations() {
    vector<DescramblingHardwareConnections> combinations;
    vector<string> mfrontendIds = frontendIds;
    vector<string> mDvrFeConnectionIds = playbackDvrIds;
    vector<string> mDvrSourceConnectionIds = playbackDvrIds;

    // Add the empty hardware id to each vector to include combinations where these 3 fields might
    // be optional
    mfrontendIds.push_back(emptyHardwareId);
    mDvrFeConnectionIds.push_back(emptyHardwareId);
    mDvrSourceConnectionIds.push_back(emptyHardwareId);

    const int descramblerIndex = 0;
    const int frontendIndex = 1;
    const int audioFilterIndex = 2;
    const int videoFilterIndex = 3;
    const int dvrFeIdIndex = 4;
    const int dvrSourceIdIndex = 5;

    vector<vector<string>> deviceIds{descramblerIds, mfrontendIds,        audioFilterIds,
                                     videoFilterIds, mDvrFeConnectionIds, mDvrSourceConnectionIds};
    auto idCombinations = generateIdCombinations(deviceIds);
    for (auto& combo : idCombinations) {
        DescramblingHardwareConnections mDescrambling;
        const string feId = combo[frontendIndex];
        const string dvrSwFeId = combo[dvrFeIdIndex];
        const string dvrSourceId = combo[dvrSourceIdIndex];
        mDescrambling.hasFrontendConnection = feId.compare(emptyHardwareId) == 0 ? false : true;
        if (!mDescrambling.hasFrontendConnection) {
            if (dvrSourceId.compare(emptyHardwareId) == 0) {
                // If combination does not have a frontend or dvr source connection, do not include
                // it
                continue;
            }
        } else {
            if (frontendMap[feId].isSoftwareFe && dvrSwFeId.compare(emptyHardwareId) == 0) {
                // If combination has a software frontend and no dvr->software frontend connection,
                // do not include it
                continue;
            }
        }
        if (dvrSwFeId.compare(dvrSourceId) == 0) {
            // If dvr->software frontend connection is the same as dvr source input to tuner, do not
            // include it.
            continue;
        }
        mDescrambling.frontendId = feId;
        mDescrambling.audioFilterId = combo[audioFilterIndex];
        mDescrambling.videoFilterId = combo[videoFilterIndex];
        mDescrambling.dvrSoftwareFeId = dvrSwFeId;
        mDescrambling.dvrSourceId = dvrSourceId;
        mDescrambling.descramblerId = combo[descramblerIndex];
        combinations.push_back(mDescrambling);
    }

    return combinations;
}

static inline vector<DescramblingHardwareConnections> generateDescramblingConfigurations() {
    vector<DescramblingHardwareConnections> descrambling_configs;
    if (configuredDescrambling) {
        ALOGD("Using Descrambling configuration provided.");
        descrambling_configs = {descrambling};
    } else {
        ALOGD("Descrambling not provided. Generating possible combinations. Consider adding it to "
              "the "
              "configuration file.");
        descrambling_configs = generateDescramblingCombinations();
    }

    return descrambling_configs;
}

/** Config all the frontends that would be used in the tests */
inline void initFrontendConfig() {
    // The test will use the internal default fe when default fe is connected to any data flow
+11 −0
Original line number Diff line number Diff line
@@ -83,6 +83,11 @@ static vector<string> recordDvrIds;
static vector<string> audioFilterIds;
static vector<string> videoFilterIds;
static vector<string> recordFilterIds;
static vector<string> sectionFilterIds;
static vector<string> frontendIds;
static vector<string> lnbIds;
static vector<string> diseqcMsgs;
static vector<string> descramblerIds;

#define PROVISION_STR                                      \
    "{                                                   " \
@@ -268,6 +273,7 @@ struct TunerTestingConfigAidlReader1_0 {
            auto frontends = *hardwareConfig.getFirstFrontends();
            for (auto feConfig : frontends.getFrontend()) {
                string id = feConfig.getId();
                frontendIds.push_back(id);
                if (id.compare(string("FE_DEFAULT")) == 0) {
                    // overrid default
                    frontendMap.erase(string("FE_DEFAULT"));
@@ -438,6 +444,7 @@ struct TunerTestingConfigAidlReader1_0 {
            auto lnbs = *hardwareConfig.getFirstLnbs();
            for (auto lnbConfig : lnbs.getLnb()) {
                string id = lnbConfig.getId();
                lnbIds.push_back(id);
                if (lnbConfig.hasName()) {
                    lnbMap[id].name = lnbConfig.getName();
                } else {
@@ -456,6 +463,7 @@ struct TunerTestingConfigAidlReader1_0 {
            auto descramblers = *hardwareConfig.getFirstDescramblers();
            for (auto descramblerConfig : descramblers.getDescrambler()) {
                string id = descramblerConfig.getId();
                descramblerIds.push_back(id);
                descramblerMap[id].casSystemId =
                        static_cast<int32_t>(descramblerConfig.getCasSystemId());
                if (descramblerConfig.hasProvisionStr()) {
@@ -481,6 +489,7 @@ struct TunerTestingConfigAidlReader1_0 {
            auto msgs = *hardwareConfig.getFirstDiseqcMessages();
            for (auto msgConfig : msgs.getDiseqcMessage()) {
                string name = msgConfig.getMsgName();
                diseqcMsgs.push_back(name);
                for (uint8_t atom : msgConfig.getMsgBody()) {
                    diseqcMsgMap[name].push_back(atom);
                }
@@ -840,6 +849,8 @@ struct TunerTestingConfigAidlReader1_0 {
            videoFilterIds.push_back(filterConfig.getId());
        } else if (subType == FilterSubTypeEnum::RECORD) {
            recordFilterIds.push_back(filterConfig.getId());
        } else if (subType == FilterSubTypeEnum::SECTION) {
            sectionFilterIds.push_back(filterConfig.getId());
        }

        switch (mainType) {