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

Commit 2b3e7417 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix wrong integer type in AIDL bcradio utils lib" into main

parents ad94b753 4db4b7b6
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -193,7 +193,7 @@ class BroadcastRadioHalTest : public testing::TestWithParam<std::string> {

MATCHER_P(InfoHasId, id,
          std::string(negation ? "does not contain" : "contains") + " " + id.toString()) {
    vector<int> ids = bcutils::getAllIds(arg.selector, id.type);
    vector<int64_t> ids = bcutils::getAllIds(arg.selector, id.type);
    return ids.end() != find(ids.begin(), ids.end(), id.value);
}

@@ -697,7 +697,7 @@ TEST_P(BroadcastRadioHalTest, FmTune) {
    LOG(DEBUG) << "Current program info: " << infoCb.toString();

    // it should tune exactly to what was requested
    vector<int> freqs = bcutils::getAllIds(infoCb.selector, IdentifierType::AMFM_FREQUENCY_KHZ);
    vector<int64_t> freqs = bcutils::getAllIds(infoCb.selector, IdentifierType::AMFM_FREQUENCY_KHZ);
    EXPECT_NE(freqs.end(), find(freqs.begin(), freqs.end(), freq))
            << "FM freq " << freq << " kHz is not sent back by callback.";
}
@@ -829,7 +829,7 @@ TEST_P(BroadcastRadioHalTest, DabTune) {
    LOG(DEBUG) << "Current program info: " << infoCb.toString();

    // it should tune exactly to what was requested
    vector<int> freqs = bcutils::getAllIds(infoCb.selector, IdentifierType::DAB_FREQUENCY_KHZ);
    vector<int64_t> freqs = bcutils::getAllIds(infoCb.selector, IdentifierType::DAB_FREQUENCY_KHZ);
    EXPECT_NE(freqs.end(), find(freqs.begin(), freqs.end(), freq))
            << "DAB freq " << freq << " kHz is not sent back by callback.";
}
@@ -1152,7 +1152,7 @@ TEST_P(BroadcastRadioHalTest, GetProgramListFromAmFmFilter) {
    int expectedResultSize = 0;
    uint64_t expectedFreq = 0;
    for (const auto& program : *completeList) {
        vector<int> amfmIds =
        vector<int64_t> amfmIds =
                bcutils::getAllIds(program.selector, IdentifierType::AMFM_FREQUENCY_KHZ);
        EXPECT_LE(amfmIds.size(), 1u);
        if (amfmIds.size() == 0) {
@@ -1238,7 +1238,8 @@ TEST_P(BroadcastRadioHalTest, HdRadioStationNameId) {
    }

    for (const auto& program : *list) {
        vector<int> nameIds = bcutils::getAllIds(program.selector, IdentifierType::HD_STATION_NAME);
        vector<int64_t> nameIds =
                bcutils::getAllIds(program.selector, IdentifierType::HD_STATION_NAME);
        EXPECT_LE(nameIds.size(), 1u);
        if (nameIds.size() == 0) {
            continue;
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ int64_t getId(const ProgramSelector& sel, const IdentifierType& type, int64_t de
/**
 * Returns all IDs of a given type.
 */
std::vector<int> getAllIds(const ProgramSelector& sel, const IdentifierType& type);
std::vector<int64_t> getAllIds(const ProgramSelector& sel, const IdentifierType& type);

/**
 * Checks, if a given selector is supported by the radio module.
+2 −2
Original line number Diff line number Diff line
@@ -178,8 +178,8 @@ int64_t getId(const ProgramSelector& sel, const IdentifierType& type, int64_t de
    return getId(sel, type);
}

vector<int> getAllIds(const ProgramSelector& sel, const IdentifierType& type) {
    vector<int> ret;
vector<int64_t> getAllIds(const ProgramSelector& sel, const IdentifierType& type) {
    vector<int64_t> ret;

    // iterate through primaryId and secondaryIds
    for (auto it = begin(sel); it != end(sel); it++) {
+10 −1
Original line number Diff line number Diff line
@@ -237,13 +237,22 @@ TEST(BroadcastRadioUtilsTest, GetAllIdsWithAvailableIds) {
    sel.secondaryIds.push_back(
            utils::makeIdentifier(IdentifierType::AMFM_FREQUENCY_KHZ, secondaryFrequencyKHz));

    std::vector<int> allIds = utils::getAllIds(sel, IdentifierType::AMFM_FREQUENCY_KHZ);
    std::vector<int64_t> allIds = utils::getAllIds(sel, IdentifierType::AMFM_FREQUENCY_KHZ);

    ASSERT_EQ(allIds.size(), 2u);
    EXPECT_NE(std::find(allIds.begin(), allIds.end(), kFmFrequencyKHz), allIds.end());
    EXPECT_NE(std::find(allIds.begin(), allIds.end(), secondaryFrequencyKHz), allIds.end());
}

TEST(BroadcastRadioUtilsTest, GetAllIdsWithIdLongerThan32Bit) {
    ProgramSelector sel = utils::makeSelectorDab(kDabSidExt, kDabEnsemble, kDabFrequencyKhz);

    std::vector<int64_t> allIds = utils::getAllIds(sel, IdentifierType::DAB_SID_EXT);

    ASSERT_EQ(allIds.size(), 1u);
    EXPECT_NE(std::find(allIds.begin(), allIds.end(), kDabSidExt), allIds.end());
}

TEST(BroadcastRadioUtilsTest, GetAllIdsWithIdNotFound) {
    ProgramSelector sel = utils::makeSelectorDab(kDabSidExt, kDabEnsemble, kDabFrequencyKhz);