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

Commit 394b343a authored by Tomasz Wasilczyk's avatar Tomasz Wasilczyk
Browse files

Update broadcastradio HAL 1.0 VTS tests.

This is a cherry-pick of the following VTS changes from O MR1 to O:
 - ag/2462390: Fix Broadcast radio 1.0 VTS to not fail on
   other radio types than AM/FM.
 - ag/2477726: Make tuned field description more precise and
   fix VTS tests to obey it.
 - ag/2549733: Implement out-of-band metadata images (a test for in-band).

Additionally, it fixes config callback handling in OpenTunerTwice test.

Bug: b/64324703
Test: VTS
Change-Id: I590b9b4d927fb0cd41f92e919343b5b94ad0e246
parent cc1007af
Loading
Loading
Loading
Loading
+34 −4
Original line number Diff line number Diff line
@@ -229,7 +229,18 @@ class BroadcastRadioHidlTest : public ::testing::VtsHalHidlTargetTestBase,
    bool getProperties();
    bool openTuner();
    bool checkAntenna();
    BandConfig& getBand(unsigned idx);

    /**
     * Retrieves AM/FM band configuration from module properties.
     *
     * The configuration may not exist: if radio type is other than AM/FM
     * or provided index is out of bounds.
     * In such case, empty configuration is returned.
     *
     * @param idx Band index to retrieve.
     * @return Band configuration reference.
     */
    const BandConfig& getBand(unsigned idx);

    static const nsecs_t kConnectCallbacktimeoutNs = seconds_to_nanoseconds(1);
    static const nsecs_t kConfigCallbacktimeoutNs = seconds_to_nanoseconds(10);
@@ -349,7 +360,7 @@ bool BroadcastRadioHidlTest::checkAntenna()
    return ((halResult == Result::OK) && (halConfig.antennaConnected == true));
}

BandConfig& BroadcastRadioHidlTest::getBand(unsigned idx) {
const BandConfig& BroadcastRadioHidlTest::getBand(unsigned idx) {
    static BandConfig dummyBandConfig = {};
    if (radioClass == Class::AM_FM) {
        EXPECT_GT(mHalProperties.bands.size(), idx);
@@ -419,9 +430,13 @@ TEST_P(BroadcastRadioHidlTest, OpenTunerTwice) {
    auto openCb = [&](Result result, const sp<ITuner>&) { halResult = result; };
    auto hidlReturn = mRadio->openTuner(getBand(0), true, mTunerCallback, openCb);
    EXPECT_TRUE(hidlReturn.isOk());
    if (halResult == Result::INVALID_STATE) {
    if (halResult == Result::OK) {
        if (radioClass == Class::AM_FM) {
            EXPECT_TRUE(waitForCallback(kConfigCallbacktimeoutNs));
        }
    } else {
        EXPECT_EQ(Result::INVALID_STATE, halResult);
    }
}

/**
@@ -432,6 +447,9 @@ TEST_P(BroadcastRadioHidlTest, OpenTunerTwice) {
 *  - the methods return 0 (no error)
 *  - the configuration callback is received within kConfigCallbacktimeoutNs ns
 *  - the configuration read back from HAl has the same class Id
 *
 * Skipped for other radio classes than AM/FM, because setConfiguration
 * applies only for these bands.
 */
TEST_P(BroadcastRadioHidlTest, SetAndGetConfiguration) {
    if (radioClass != Class::AM_FM) skipped = true;
@@ -467,6 +485,9 @@ TEST_P(BroadcastRadioHidlTest, SetAndGetConfiguration) {
 * Verifies that:
 *  - the methods returns INVALID_ARGUMENTS on invalid arguments
 *  - the method recovers and succeeds after passing correct arguments
 *
 * Skipped for other radio classes than AM/FM, because setConfiguration
 * applies only for these bands.
 */
TEST_P(BroadcastRadioHidlTest, SetConfigurationFails) {
    if (radioClass != Class::AM_FM) skipped = true;
@@ -531,6 +552,9 @@ TEST_P(BroadcastRadioHidlTest, Scan) {
 *  - the method returns 0 (no error)
 *  - the tuned callback is received within kTuneCallbacktimeoutNs ns
 *  - skipping sub-channel or not does not fail the call
 *
 * Skipped for other radio classes than AM/FM, because step is not possible
 * on DAB nor satellite.
 */
TEST_P(BroadcastRadioHidlTest, Step) {
    if (radioClass != Class::AM_FM) skipped = true;
@@ -559,6 +583,9 @@ TEST_P(BroadcastRadioHidlTest, Step) {
 *  - the HAL implements the methods
 *  - the methods return 0 (no error)
 *  - the tuned callback is received within kTuneCallbacktimeoutNs ns after tune()
 *
 * Skipped for other radio classes than AM/FM, because tune to frequency
 * is not possible on DAB nor satellite.
 */
TEST_P(BroadcastRadioHidlTest, TuneAndGetProgramInformationAndCancel) {
    if (radioClass != Class::AM_FM) skipped = true;
@@ -617,6 +644,9 @@ TEST_P(BroadcastRadioHidlTest, TuneAndGetProgramInformationAndCancel) {
 * Verifies that:
 *  - the method returns INVALID_ARGUMENTS when applicable
 *  - the method recovers and succeeds after passing correct arguments
 *
 * Skipped for other radio classes than AM/FM, because tune to frequency
 * is not possible on DAB nor satellite.
 */
TEST_P(BroadcastRadioHidlTest, TuneFailsOutOfBounds) {
    if (radioClass != Class::AM_FM) skipped = true;