diff options
| author | Tomasz Wasilczyk <twasilczyk@google.com> | 2017-03-07 19:57:49 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2017-03-07 19:57:49 +0000 |
| commit | d5c63c8730f0f3c56242cbc446841d0996e95d24 (patch) | |
| tree | 2a0514480dac81082cb004ec55dfbe0080e52cb6 | |
| parent | 287adc9897e7bb10c80d2bca68630b0691630194 (diff) | |
| parent | f3c036d7d60db0db3e21d6ea3c5cd41b57f259da (diff) | |
| download | android_hardware_interfaces-d5c63c8730f0f3c56242cbc446841d0996e95d24.tar.gz android_hardware_interfaces-d5c63c8730f0f3c56242cbc446841d0996e95d24.tar.bz2 android_hardware_interfaces-d5c63c8730f0f3c56242cbc446841d0996e95d24.zip | |
Merge "Extend configChange and tuneComplete callbacks with checking the carried value."
| -rw-r--r-- | broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp | 61 |
1 files changed, 53 insertions, 8 deletions
diff --git a/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp b/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp index 4268ddd3e..5106e5148 100644 --- a/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp +++ b/broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp @@ -42,6 +42,7 @@ using ::android::hardware::broadcastradio::V1_0::ITunerCallback; using ::android::hardware::broadcastradio::V1_0::Result; using ::android::hardware::broadcastradio::V1_0::Class; using ::android::hardware::broadcastradio::V1_0::Properties; +using ::android::hardware::broadcastradio::V1_0::Band; using ::android::hardware::broadcastradio::V1_0::BandConfig; using ::android::hardware::broadcastradio::V1_0::Direction; using ::android::hardware::broadcastradio::V1_0::ProgramInfo; @@ -83,15 +84,15 @@ class BroadcastRadioHidlTest : public ::testing::VtsHalHidlTargetBaseTest { return Void(); } - virtual Return<void> configChange(Result result, const BandConfig& config __unused) { + virtual Return<void> configChange(Result result, const BandConfig& config) { ALOGI("%s result %d", __FUNCTION__, result); - mParentTest->onResultCallback(result); + mParentTest->onConfigChangeCallback(result, config); return Void(); } - virtual Return<void> tuneComplete(Result result, const ProgramInfo& info __unused) { + virtual Return<void> tuneComplete(Result result, const ProgramInfo& info) { ALOGI("%s result %d", __FUNCTION__, result); - mParentTest->onResultCallback(result); + mParentTest->onTuneCompleteCallback(result, info); return Void(); } @@ -146,11 +147,22 @@ class BroadcastRadioHidlTest : public ::testing::VtsHalHidlTargetBaseTest { } /** - * Method called by MyCallback when a callback with status is received + * Method called by MyCallback when configChange() callback is received. */ - void onResultCallback(Result result) { + void onConfigChangeCallback(Result result, const BandConfig& config) { Mutex::Autolock _l(mLock); mResultCallbackData = result; + mBandConfigCallbackData = config; + onCallback_l(); + } + + /** + * Method called by MyCallback when tuneComplete() callback is received. + */ + void onTuneCompleteCallback(Result result, const ProgramInfo& info) { + Mutex::Autolock _l(mLock); + mResultCallbackData = result; + mProgramInfoCallbackData = info; onCallback_l(); } @@ -209,6 +221,8 @@ class BroadcastRadioHidlTest : public ::testing::VtsHalHidlTargetBaseTest { bool mCallbackCalled; bool mBoolCallbackData; Result mResultCallbackData; + ProgramInfo mProgramInfoCallbackData; + BandConfig mBandConfigCallbackData; bool mHwFailure; }; @@ -219,6 +233,35 @@ class BroadcastRadioHidlEnvironment : public ::testing::Environment { virtual void TearDown() {} }; +namespace android { +namespace hardware { +namespace broadcastradio { +namespace V1_0 { + +/** + * Compares two BandConfig objects for testing purposes. + */ +static bool operator==(const BandConfig& l, const BandConfig& r) { + if (l.type != r.type) return false; + if (l.antennaConnected != r.antennaConnected) return false; + if (l.lowerLimit != r.lowerLimit) return false; + if (l.upperLimit != r.upperLimit) return false; + if (l.spacings != r.spacings) return false; + if (l.type == Band::AM || l.type == Band::AM_HD) { + return l.ext.am == r.ext.am; + } else if (l.type == Band::FM || l.type == Band::FM_HD) { + return l.ext.fm == r.ext.fm; + } else { + // unsupported type + return false; + } +} + +} // V1_0 +} // broadcastradio +} // hardware +} // android + bool BroadcastRadioHidlTest::getProperties() { if (mHalProperties.bands.size() == 0) { @@ -351,11 +394,12 @@ TEST_F(BroadcastRadioHidlTest, SetAndGetConfiguration) { ASSERT_EQ(true, openTuner()); // test setConfiguration mCallbackCalled = false; - Return<Result> hidlResult = mTuner->setConfiguration(mHalProperties.bands[0]); + Return<Result> hidlResult = mTuner->setConfiguration(mHalProperties.bands[1]); EXPECT_TRUE(hidlResult.isOk()); EXPECT_EQ(Result::OK, hidlResult); EXPECT_EQ(true, waitForCallback(kConfigCallbacktimeoutNs)); EXPECT_EQ(Result::OK, mResultCallbackData); + EXPECT_EQ(mHalProperties.bands[1], mBandConfigCallbackData); // test getConfiguration BandConfig halConfig; @@ -369,7 +413,7 @@ TEST_F(BroadcastRadioHidlTest, SetAndGetConfiguration) { }); EXPECT_TRUE(hidlReturn.isOk()); EXPECT_EQ(Result::OK, halResult); - EXPECT_EQ(mHalProperties.bands[0].type, halConfig.type); + EXPECT_EQ(mHalProperties.bands[1], halConfig); } /** @@ -453,6 +497,7 @@ TEST_F(BroadcastRadioHidlTest, TuneAndGetProgramInformationAndCancel) { EXPECT_TRUE(hidlResult.isOk()); EXPECT_EQ(Result::OK, hidlResult); EXPECT_EQ(true, waitForCallback(kTuneCallbacktimeoutNs)); + EXPECT_EQ(channel, mProgramInfoCallbackData.channel); // test getProgramInformation ProgramInfo halInfo; |
