Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #define LOG_TAG "BroadcastRadioHidlHalTest" |
Yuexi Ma | ed2bb4e | 2017-03-10 00:44:45 -0800 | [diff] [blame] | 18 | #include <VtsHalHidlTargetTestBase.h> |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 19 | #include <android-base/logging.h> |
| 20 | #include <cutils/native_handle.h> |
| 21 | #include <cutils/properties.h> |
Martijn Coenen | 0282237 | 2016-12-29 14:03:41 +0100 | [diff] [blame] | 22 | #include <hidl/HidlTransportSupport.h> |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 23 | #include <utils/threads.h> |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 24 | |
| 25 | #include <android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h> |
| 26 | #include <android/hardware/broadcastradio/1.0/IBroadcastRadio.h> |
| 27 | #include <android/hardware/broadcastradio/1.0/ITuner.h> |
| 28 | #include <android/hardware/broadcastradio/1.0/ITunerCallback.h> |
| 29 | #include <android/hardware/broadcastradio/1.0/types.h> |
| 30 | |
| 31 | |
| 32 | using ::android::sp; |
| 33 | using ::android::Mutex; |
| 34 | using ::android::Condition; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 35 | using ::android::hardware::Return; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 36 | using ::android::hardware::Void; |
| 37 | using ::android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory; |
| 38 | using ::android::hardware::broadcastradio::V1_0::IBroadcastRadio; |
| 39 | using ::android::hardware::broadcastradio::V1_0::ITuner; |
| 40 | using ::android::hardware::broadcastradio::V1_0::ITunerCallback; |
| 41 | using ::android::hardware::broadcastradio::V1_0::Result; |
| 42 | using ::android::hardware::broadcastradio::V1_0::Class; |
| 43 | using ::android::hardware::broadcastradio::V1_0::Properties; |
Tomasz Wasilczyk | f3c036d | 2017-03-03 15:07:50 -0800 | [diff] [blame] | 44 | using ::android::hardware::broadcastradio::V1_0::Band; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 45 | using ::android::hardware::broadcastradio::V1_0::BandConfig; |
| 46 | using ::android::hardware::broadcastradio::V1_0::Direction; |
| 47 | using ::android::hardware::broadcastradio::V1_0::ProgramInfo; |
| 48 | using ::android::hardware::broadcastradio::V1_0::MetaData; |
Tomasz Wasilczyk | ba3e254 | 2017-07-17 13:59:21 -0700 | [diff] [blame] | 49 | using ::android::hardware::broadcastradio::V1_0::MetadataKey; |
| 50 | using ::android::hardware::broadcastradio::V1_0::MetadataType; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 51 | |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 52 | #define RETURN_IF_SKIPPED \ |
| 53 | if (skipped) { \ |
| 54 | std::cout << "[ SKIPPED ] This device class is not supported. " << std::endl; \ |
| 55 | return; \ |
| 56 | } |
| 57 | |
Tomasz Wasilczyk | 213170b | 2017-02-07 17:38:21 -0800 | [diff] [blame] | 58 | // The main test class for Broadcast Radio HIDL HAL. |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 59 | |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 60 | class BroadcastRadioHidlTest : public ::testing::VtsHalHidlTargetTestBase, |
| 61 | public ::testing::WithParamInterface<Class> { |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 62 | protected: |
| 63 | virtual void SetUp() override { |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 64 | ASSERT_EQ(nullptr, mRadio.get()); |
| 65 | |
| 66 | radioClass = GetParam(); |
| 67 | skipped = false; |
| 68 | |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 69 | sp<IBroadcastRadioFactory> factory = |
Yuexi Ma | ed2bb4e | 2017-03-10 00:44:45 -0800 | [diff] [blame] | 70 | ::testing::VtsHalHidlTargetTestBase::getService<IBroadcastRadioFactory>(); |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 71 | ASSERT_NE(nullptr, factory.get()); |
| 72 | |
| 73 | Result connectResult; |
| 74 | factory->connectModule(radioClass, [&](Result ret, const sp<IBroadcastRadio>& radio) { |
| 75 | connectResult = ret; |
| 76 | mRadio = radio; |
| 77 | onCallback_l(); |
| 78 | }); |
| 79 | EXPECT_EQ(true, waitForCallback(kConnectCallbacktimeoutNs)); |
| 80 | mCallbackCalled = false; |
| 81 | |
| 82 | if (connectResult == Result::INVALID_ARGUMENTS) { |
| 83 | skipped = true; |
| 84 | return; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 85 | } |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 86 | ASSERT_EQ(connectResult, Result::OK); |
| 87 | |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 88 | mTunerCallback = new MyCallback(this); |
| 89 | ASSERT_NE(nullptr, mRadio.get()); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 90 | ASSERT_NE(nullptr, mTunerCallback.get()); |
| 91 | } |
| 92 | |
| 93 | virtual void TearDown() override { |
| 94 | mTuner.clear(); |
| 95 | mRadio.clear(); |
| 96 | } |
| 97 | |
| 98 | class MyCallback : public ITunerCallback { |
| 99 | public: |
| 100 | |
| 101 | // ITunerCallback methods (see doc in ITunerCallback.hal) |
| 102 | virtual Return<void> hardwareFailure() { |
| 103 | ALOGI("%s", __FUNCTION__); |
| 104 | mParentTest->onHwFailureCallback(); |
| 105 | return Void(); |
| 106 | } |
| 107 | |
Tomasz Wasilczyk | f3c036d | 2017-03-03 15:07:50 -0800 | [diff] [blame] | 108 | virtual Return<void> configChange(Result result, const BandConfig& config) { |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 109 | ALOGI("%s result %d", __FUNCTION__, result); |
Tomasz Wasilczyk | f3c036d | 2017-03-03 15:07:50 -0800 | [diff] [blame] | 110 | mParentTest->onConfigChangeCallback(result, config); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 111 | return Void(); |
| 112 | } |
| 113 | |
Tomasz Wasilczyk | f3c036d | 2017-03-03 15:07:50 -0800 | [diff] [blame] | 114 | virtual Return<void> tuneComplete(Result result, const ProgramInfo& info) { |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 115 | ALOGI("%s result %d", __FUNCTION__, result); |
Tomasz Wasilczyk | f3c036d | 2017-03-03 15:07:50 -0800 | [diff] [blame] | 116 | mParentTest->onTuneCompleteCallback(result, info); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 117 | return Void(); |
| 118 | } |
| 119 | |
| 120 | virtual Return<void> afSwitch(const ProgramInfo& info __unused) { |
| 121 | return Void(); |
| 122 | } |
| 123 | |
| 124 | virtual Return<void> antennaStateChange(bool connected) { |
| 125 | ALOGI("%s connected %d", __FUNCTION__, connected); |
| 126 | return Void(); |
| 127 | } |
| 128 | |
| 129 | virtual Return<void> trafficAnnouncement(bool active) { |
| 130 | ALOGI("%s active %d", __FUNCTION__, active); |
| 131 | return Void(); |
| 132 | } |
| 133 | |
| 134 | virtual Return<void> emergencyAnnouncement(bool active) { |
| 135 | ALOGI("%s active %d", __FUNCTION__, active); |
| 136 | return Void(); |
| 137 | } |
| 138 | |
| 139 | virtual Return<void> newMetadata(uint32_t channel __unused, uint32_t subChannel __unused, |
| 140 | const ::android::hardware::hidl_vec<MetaData>& metadata __unused) { |
| 141 | ALOGI("%s", __FUNCTION__); |
| 142 | return Void(); |
| 143 | } |
| 144 | |
| 145 | MyCallback(BroadcastRadioHidlTest *parentTest) : mParentTest(parentTest) {} |
| 146 | |
| 147 | private: |
| 148 | // BroadcastRadioHidlTest instance to which callbacks will be notified. |
| 149 | BroadcastRadioHidlTest *mParentTest; |
| 150 | }; |
| 151 | |
| 152 | |
| 153 | /** |
| 154 | * Method called by MyCallback when a callback with no status or boolean value is received |
| 155 | */ |
| 156 | void onCallback() { |
| 157 | Mutex::Autolock _l(mLock); |
| 158 | onCallback_l(); |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Method called by MyCallback when hardwareFailure() callback is received |
| 163 | */ |
| 164 | void onHwFailureCallback() { |
| 165 | Mutex::Autolock _l(mLock); |
| 166 | mHwFailure = true; |
| 167 | onCallback_l(); |
| 168 | } |
| 169 | |
| 170 | /** |
Tomasz Wasilczyk | f3c036d | 2017-03-03 15:07:50 -0800 | [diff] [blame] | 171 | * Method called by MyCallback when configChange() callback is received. |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 172 | */ |
Tomasz Wasilczyk | f3c036d | 2017-03-03 15:07:50 -0800 | [diff] [blame] | 173 | void onConfigChangeCallback(Result result, const BandConfig& config) { |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 174 | Mutex::Autolock _l(mLock); |
| 175 | mResultCallbackData = result; |
Tomasz Wasilczyk | f3c036d | 2017-03-03 15:07:50 -0800 | [diff] [blame] | 176 | mBandConfigCallbackData = config; |
| 177 | onCallback_l(); |
| 178 | } |
| 179 | |
| 180 | /** |
| 181 | * Method called by MyCallback when tuneComplete() callback is received. |
| 182 | */ |
| 183 | void onTuneCompleteCallback(Result result, const ProgramInfo& info) { |
| 184 | Mutex::Autolock _l(mLock); |
| 185 | mResultCallbackData = result; |
| 186 | mProgramInfoCallbackData = info; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 187 | onCallback_l(); |
| 188 | } |
| 189 | |
| 190 | /** |
| 191 | * Method called by MyCallback when a boolean indication is received |
| 192 | */ |
| 193 | void onBoolCallback(bool result) { |
| 194 | Mutex::Autolock _l(mLock); |
| 195 | mBoolCallbackData = result; |
| 196 | onCallback_l(); |
| 197 | } |
| 198 | |
| 199 | |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 200 | BroadcastRadioHidlTest() |
| 201 | : mCallbackCalled(false), mBoolCallbackData(false), mResultCallbackData(Result::OK), |
| 202 | mHwFailure(false) {} |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 203 | |
| 204 | void onCallback_l() { |
| 205 | if (!mCallbackCalled) { |
| 206 | mCallbackCalled = true; |
| 207 | mCallbackCond.broadcast(); |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | |
| 212 | bool waitForCallback(nsecs_t reltime = 0) { |
| 213 | Mutex::Autolock _l(mLock); |
| 214 | nsecs_t endTime = systemTime() + reltime; |
| 215 | while (!mCallbackCalled) { |
| 216 | if (reltime == 0) { |
| 217 | mCallbackCond.wait(mLock); |
| 218 | } else { |
| 219 | nsecs_t now = systemTime(); |
| 220 | if (now > endTime) { |
| 221 | return false; |
| 222 | } |
| 223 | mCallbackCond.waitRelative(mLock, endTime - now); |
| 224 | } |
| 225 | } |
| 226 | return true; |
| 227 | } |
| 228 | |
| 229 | bool getProperties(); |
| 230 | bool openTuner(); |
| 231 | bool checkAntenna(); |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 232 | BandConfig& getBand(unsigned idx); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 233 | |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 234 | static const nsecs_t kConnectCallbacktimeoutNs = seconds_to_nanoseconds(1); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 235 | static const nsecs_t kConfigCallbacktimeoutNs = seconds_to_nanoseconds(10); |
| 236 | static const nsecs_t kTuneCallbacktimeoutNs = seconds_to_nanoseconds(30); |
| 237 | |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 238 | Class radioClass; |
| 239 | bool skipped; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 240 | sp<IBroadcastRadio> mRadio; |
| 241 | Properties mHalProperties; |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 242 | bool mHalPropertiesInitialized = false; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 243 | sp<ITuner> mTuner; |
| 244 | sp<MyCallback> mTunerCallback; |
| 245 | Mutex mLock; |
| 246 | Condition mCallbackCond; |
| 247 | bool mCallbackCalled; |
| 248 | bool mBoolCallbackData; |
| 249 | Result mResultCallbackData; |
Tomasz Wasilczyk | f3c036d | 2017-03-03 15:07:50 -0800 | [diff] [blame] | 250 | ProgramInfo mProgramInfoCallbackData; |
| 251 | BandConfig mBandConfigCallbackData; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 252 | bool mHwFailure; |
| 253 | }; |
| 254 | |
Tomasz Wasilczyk | f3c036d | 2017-03-03 15:07:50 -0800 | [diff] [blame] | 255 | namespace android { |
| 256 | namespace hardware { |
| 257 | namespace broadcastradio { |
| 258 | namespace V1_0 { |
| 259 | |
| 260 | /** |
| 261 | * Compares two BandConfig objects for testing purposes. |
| 262 | */ |
| 263 | static bool operator==(const BandConfig& l, const BandConfig& r) { |
| 264 | if (l.type != r.type) return false; |
| 265 | if (l.antennaConnected != r.antennaConnected) return false; |
| 266 | if (l.lowerLimit != r.lowerLimit) return false; |
| 267 | if (l.upperLimit != r.upperLimit) return false; |
| 268 | if (l.spacings != r.spacings) return false; |
| 269 | if (l.type == Band::AM || l.type == Band::AM_HD) { |
| 270 | return l.ext.am == r.ext.am; |
| 271 | } else if (l.type == Band::FM || l.type == Band::FM_HD) { |
| 272 | return l.ext.fm == r.ext.fm; |
| 273 | } else { |
| 274 | // unsupported type |
| 275 | return false; |
| 276 | } |
| 277 | } |
| 278 | |
| 279 | } // V1_0 |
| 280 | } // broadcastradio |
| 281 | } // hardware |
| 282 | } // android |
| 283 | |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 284 | bool BroadcastRadioHidlTest::getProperties() |
| 285 | { |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 286 | if (mHalPropertiesInitialized) return true; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 287 | |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 288 | Result halResult = Result::NOT_INITIALIZED; |
| 289 | auto hidlReturn = mRadio->getProperties([&](Result result, const Properties& properties) { |
| 290 | halResult = result; |
| 291 | if (result == Result::OK) { |
| 292 | mHalProperties = properties; |
| 293 | } |
| 294 | }); |
| 295 | |
| 296 | EXPECT_TRUE(hidlReturn.isOk()); |
| 297 | EXPECT_EQ(Result::OK, halResult); |
| 298 | EXPECT_EQ(radioClass, mHalProperties.classId); |
| 299 | EXPECT_GT(mHalProperties.numTuners, 0u); |
| 300 | if (radioClass == Class::AM_FM) { |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 301 | EXPECT_GT(mHalProperties.bands.size(), 0u); |
| 302 | } |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 303 | |
| 304 | if (hidlReturn.isOk() && halResult == Result::OK) { |
| 305 | mHalPropertiesInitialized = true; |
| 306 | return true; |
| 307 | } |
| 308 | return false; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | bool BroadcastRadioHidlTest::openTuner() |
| 312 | { |
| 313 | if (!getProperties()) { |
| 314 | return false; |
| 315 | } |
| 316 | if (mTuner.get() == nullptr) { |
| 317 | Result halResult = Result::NOT_INITIALIZED; |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 318 | auto openCb = [&](Result result, const sp<ITuner>& tuner) { |
| 319 | halResult = result; |
| 320 | if (result == Result::OK) { |
| 321 | mTuner = tuner; |
| 322 | } |
| 323 | }; |
| 324 | auto hidlReturn = mRadio->openTuner(getBand(0), true, mTunerCallback, openCb); |
Steven Moreland | b643842 | 2017-01-03 17:06:57 -0800 | [diff] [blame] | 325 | EXPECT_TRUE(hidlReturn.isOk()); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 326 | EXPECT_EQ(Result::OK, halResult); |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 327 | if (radioClass == Class::AM_FM) { |
| 328 | EXPECT_EQ(true, waitForCallback(kConfigCallbacktimeoutNs)); |
| 329 | } |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 330 | } |
| 331 | EXPECT_NE(nullptr, mTuner.get()); |
| 332 | return nullptr != mTuner.get(); |
| 333 | } |
| 334 | |
| 335 | bool BroadcastRadioHidlTest::checkAntenna() |
| 336 | { |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 337 | if (radioClass != Class::AM_FM) return true; |
| 338 | |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 339 | BandConfig halConfig; |
| 340 | Result halResult = Result::NOT_INITIALIZED; |
| 341 | Return<void> hidlReturn = |
| 342 | mTuner->getConfiguration([&](Result result, const BandConfig& config) { |
| 343 | halResult = result; |
| 344 | if (result == Result::OK) { |
| 345 | halConfig = config; |
| 346 | } |
| 347 | }); |
| 348 | |
| 349 | return ((halResult == Result::OK) && (halConfig.antennaConnected == true)); |
| 350 | } |
| 351 | |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 352 | BandConfig& BroadcastRadioHidlTest::getBand(unsigned idx) { |
| 353 | static BandConfig dummyBandConfig = {}; |
| 354 | if (radioClass == Class::AM_FM) { |
| 355 | EXPECT_GT(mHalProperties.bands.size(), idx); |
| 356 | if (mHalProperties.bands.size() > idx) { |
| 357 | return mHalProperties.bands[idx]; |
| 358 | } else { |
| 359 | return dummyBandConfig; |
| 360 | } |
| 361 | } else { |
| 362 | return dummyBandConfig; |
| 363 | } |
| 364 | } |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 365 | |
| 366 | /** |
| 367 | * Test IBroadcastRadio::getProperties() method |
| 368 | * |
| 369 | * Verifies that: |
| 370 | * - the HAL implements the method |
| 371 | * - the method returns 0 (no error) |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 372 | * - the implementation class is radioClass |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 373 | * - the implementation supports at least one tuner |
| 374 | * - the implementation supports at one band |
| 375 | */ |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 376 | TEST_P(BroadcastRadioHidlTest, GetProperties) { |
| 377 | RETURN_IF_SKIPPED; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 378 | EXPECT_EQ(true, getProperties()); |
| 379 | } |
| 380 | |
| 381 | /** |
| 382 | * Test IBroadcastRadio::openTuner() method |
| 383 | * |
| 384 | * Verifies that: |
| 385 | * - the HAL implements the method |
| 386 | * - the method returns 0 (no error) and a valid ITuner interface |
| 387 | */ |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 388 | TEST_P(BroadcastRadioHidlTest, OpenTuner) { |
| 389 | RETURN_IF_SKIPPED; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 390 | EXPECT_EQ(true, openTuner()); |
| 391 | } |
| 392 | |
| 393 | /** |
Tomasz Wasilczyk | be71e9c | 2016-12-22 11:49:17 -0800 | [diff] [blame] | 394 | * Test IBroadcastRadio::openTuner() after ITuner disposal. |
| 395 | * |
| 396 | * Verifies that: |
| 397 | * - ITuner destruction gets propagated through HAL |
| 398 | * - the openTuner method works well when called for the second time |
| 399 | */ |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 400 | TEST_P(BroadcastRadioHidlTest, ReopenTuner) { |
| 401 | RETURN_IF_SKIPPED; |
Tomasz Wasilczyk | be71e9c | 2016-12-22 11:49:17 -0800 | [diff] [blame] | 402 | EXPECT_TRUE(openTuner()); |
| 403 | mTuner.clear(); |
| 404 | EXPECT_TRUE(openTuner()); |
| 405 | } |
| 406 | |
| 407 | /** |
| 408 | * Test IBroadcastRadio::openTuner() method called twice. |
| 409 | * |
| 410 | * Verifies that: |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 411 | * - the openTuner method fails with INVALID_STATE or succeeds when called for the second time |
| 412 | * without deleting previous ITuner instance |
Tomasz Wasilczyk | be71e9c | 2016-12-22 11:49:17 -0800 | [diff] [blame] | 413 | */ |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 414 | TEST_P(BroadcastRadioHidlTest, OpenTunerTwice) { |
| 415 | RETURN_IF_SKIPPED; |
Tomasz Wasilczyk | be71e9c | 2016-12-22 11:49:17 -0800 | [diff] [blame] | 416 | EXPECT_TRUE(openTuner()); |
| 417 | |
| 418 | Result halResult = Result::NOT_INITIALIZED; |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 419 | auto openCb = [&](Result result, const sp<ITuner>&) { halResult = result; }; |
| 420 | auto hidlReturn = mRadio->openTuner(getBand(0), true, mTunerCallback, openCb); |
Tomasz Wasilczyk | be71e9c | 2016-12-22 11:49:17 -0800 | [diff] [blame] | 421 | EXPECT_TRUE(hidlReturn.isOk()); |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 422 | if (halResult == Result::INVALID_STATE) { |
| 423 | EXPECT_TRUE(waitForCallback(kConfigCallbacktimeoutNs)); |
| 424 | } |
Tomasz Wasilczyk | be71e9c | 2016-12-22 11:49:17 -0800 | [diff] [blame] | 425 | } |
| 426 | |
| 427 | /** |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 428 | * Test ITuner::setConfiguration() and getConfiguration methods |
| 429 | * |
| 430 | * Verifies that: |
| 431 | * - the HAL implements both methods |
| 432 | * - the methods return 0 (no error) |
| 433 | * - the configuration callback is received within kConfigCallbacktimeoutNs ns |
| 434 | * - the configuration read back from HAl has the same class Id |
| 435 | */ |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 436 | TEST_P(BroadcastRadioHidlTest, SetAndGetConfiguration) { |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 437 | if (radioClass != Class::AM_FM) skipped = true; |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 438 | RETURN_IF_SKIPPED; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 439 | ASSERT_EQ(true, openTuner()); |
| 440 | // test setConfiguration |
| 441 | mCallbackCalled = false; |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 442 | Return<Result> hidlResult = mTuner->setConfiguration(getBand(1)); |
Steven Moreland | b643842 | 2017-01-03 17:06:57 -0800 | [diff] [blame] | 443 | EXPECT_TRUE(hidlResult.isOk()); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 444 | EXPECT_EQ(Result::OK, hidlResult); |
| 445 | EXPECT_EQ(true, waitForCallback(kConfigCallbacktimeoutNs)); |
| 446 | EXPECT_EQ(Result::OK, mResultCallbackData); |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 447 | EXPECT_EQ(getBand(1), mBandConfigCallbackData); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 448 | |
| 449 | // test getConfiguration |
| 450 | BandConfig halConfig; |
| 451 | Result halResult; |
| 452 | Return<void> hidlReturn = |
| 453 | mTuner->getConfiguration([&](Result result, const BandConfig& config) { |
| 454 | halResult = result; |
| 455 | if (result == Result::OK) { |
| 456 | halConfig = config; |
| 457 | } |
| 458 | }); |
Steven Moreland | b643842 | 2017-01-03 17:06:57 -0800 | [diff] [blame] | 459 | EXPECT_TRUE(hidlReturn.isOk()); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 460 | EXPECT_EQ(Result::OK, halResult); |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 461 | EXPECT_EQ(getBand(1), halConfig); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | /** |
Tomasz Wasilczyk | 10877cd | 2017-03-07 17:04:26 -0800 | [diff] [blame] | 465 | * Test ITuner::setConfiguration() with invalid arguments. |
| 466 | * |
| 467 | * Verifies that: |
| 468 | * - the methods returns INVALID_ARGUMENTS on invalid arguments |
| 469 | * - the method recovers and succeeds after passing correct arguments |
| 470 | */ |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 471 | TEST_P(BroadcastRadioHidlTest, SetConfigurationFails) { |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 472 | if (radioClass != Class::AM_FM) skipped = true; |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 473 | RETURN_IF_SKIPPED; |
Tomasz Wasilczyk | 10877cd | 2017-03-07 17:04:26 -0800 | [diff] [blame] | 474 | ASSERT_EQ(true, openTuner()); |
| 475 | |
| 476 | // Let's define a config that's bad for sure. |
| 477 | BandConfig badConfig = {}; |
| 478 | badConfig.type = Band::FM; |
| 479 | badConfig.lowerLimit = 0xFFFFFFFF; |
| 480 | badConfig.upperLimit = 0; |
| 481 | badConfig.spacings = (std::vector<uint32_t>){ 0 }; |
| 482 | |
| 483 | // Test setConfiguration failing on bad data. |
| 484 | mCallbackCalled = false; |
| 485 | auto setResult = mTuner->setConfiguration(badConfig); |
| 486 | EXPECT_TRUE(setResult.isOk()); |
| 487 | EXPECT_EQ(Result::INVALID_ARGUMENTS, setResult); |
| 488 | |
| 489 | // Test setConfiguration recovering after passing good data. |
| 490 | mCallbackCalled = false; |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 491 | setResult = mTuner->setConfiguration(getBand(0)); |
Tomasz Wasilczyk | 10877cd | 2017-03-07 17:04:26 -0800 | [diff] [blame] | 492 | EXPECT_TRUE(setResult.isOk()); |
| 493 | EXPECT_EQ(Result::OK, setResult); |
| 494 | EXPECT_EQ(true, waitForCallback(kConfigCallbacktimeoutNs)); |
| 495 | EXPECT_EQ(Result::OK, mResultCallbackData); |
| 496 | } |
| 497 | |
| 498 | /** |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 499 | * Test ITuner::scan |
| 500 | * |
| 501 | * Verifies that: |
| 502 | * - the HAL implements the method |
| 503 | * - the method returns 0 (no error) |
| 504 | * - the tuned callback is received within kTuneCallbacktimeoutNs ns |
Tomasz Wasilczyk | a8dec0f | 2017-03-14 10:20:53 -0700 | [diff] [blame] | 505 | * - skipping sub-channel or not does not fail the call |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 506 | */ |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 507 | TEST_P(BroadcastRadioHidlTest, Scan) { |
| 508 | RETURN_IF_SKIPPED; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 509 | ASSERT_EQ(true, openTuner()); |
| 510 | ASSERT_TRUE(checkAntenna()); |
| 511 | // test scan UP |
| 512 | mCallbackCalled = false; |
| 513 | Return<Result> hidlResult = mTuner->scan(Direction::UP, true); |
Steven Moreland | b643842 | 2017-01-03 17:06:57 -0800 | [diff] [blame] | 514 | EXPECT_TRUE(hidlResult.isOk()); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 515 | EXPECT_EQ(Result::OK, hidlResult); |
| 516 | EXPECT_EQ(true, waitForCallback(kTuneCallbacktimeoutNs)); |
| 517 | |
| 518 | // test scan DOWN |
| 519 | mCallbackCalled = false; |
Tomasz Wasilczyk | a8dec0f | 2017-03-14 10:20:53 -0700 | [diff] [blame] | 520 | hidlResult = mTuner->scan(Direction::DOWN, false); |
Steven Moreland | b643842 | 2017-01-03 17:06:57 -0800 | [diff] [blame] | 521 | EXPECT_TRUE(hidlResult.isOk()); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 522 | EXPECT_EQ(Result::OK, hidlResult); |
| 523 | EXPECT_EQ(true, waitForCallback(kTuneCallbacktimeoutNs)); |
| 524 | } |
| 525 | |
| 526 | /** |
| 527 | * Test ITuner::step |
| 528 | * |
| 529 | * Verifies that: |
| 530 | * - the HAL implements the method |
| 531 | * - the method returns 0 (no error) |
| 532 | * - the tuned callback is received within kTuneCallbacktimeoutNs ns |
Tomasz Wasilczyk | a8dec0f | 2017-03-14 10:20:53 -0700 | [diff] [blame] | 533 | * - skipping sub-channel or not does not fail the call |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 534 | */ |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 535 | TEST_P(BroadcastRadioHidlTest, Step) { |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 536 | if (radioClass != Class::AM_FM) skipped = true; |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 537 | RETURN_IF_SKIPPED; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 538 | ASSERT_EQ(true, openTuner()); |
| 539 | ASSERT_TRUE(checkAntenna()); |
| 540 | // test step UP |
| 541 | mCallbackCalled = false; |
Tomasz Wasilczyk | a8dec0f | 2017-03-14 10:20:53 -0700 | [diff] [blame] | 542 | Return<Result> hidlResult = mTuner->step(Direction::UP, false); |
Steven Moreland | b643842 | 2017-01-03 17:06:57 -0800 | [diff] [blame] | 543 | EXPECT_TRUE(hidlResult.isOk()); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 544 | EXPECT_EQ(Result::OK, hidlResult); |
| 545 | EXPECT_EQ(true, waitForCallback(kTuneCallbacktimeoutNs)); |
| 546 | |
| 547 | // test step DOWN |
| 548 | mCallbackCalled = false; |
| 549 | hidlResult = mTuner->step(Direction::DOWN, true); |
Steven Moreland | b643842 | 2017-01-03 17:06:57 -0800 | [diff] [blame] | 550 | EXPECT_TRUE(hidlResult.isOk()); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 551 | EXPECT_EQ(Result::OK, hidlResult); |
| 552 | EXPECT_EQ(true, waitForCallback(kTuneCallbacktimeoutNs)); |
| 553 | } |
| 554 | |
| 555 | /** |
| 556 | * Test ITuner::tune, getProgramInformation and cancel methods |
| 557 | * |
| 558 | * Verifies that: |
| 559 | * - the HAL implements the methods |
| 560 | * - the methods return 0 (no error) |
| 561 | * - the tuned callback is received within kTuneCallbacktimeoutNs ns after tune() |
| 562 | */ |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 563 | TEST_P(BroadcastRadioHidlTest, TuneAndGetProgramInformationAndCancel) { |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 564 | if (radioClass != Class::AM_FM) skipped = true; |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 565 | RETURN_IF_SKIPPED; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 566 | ASSERT_EQ(true, openTuner()); |
| 567 | ASSERT_TRUE(checkAntenna()); |
| 568 | |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 569 | auto& band = getBand(0); |
| 570 | |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 571 | // test tune |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 572 | ASSERT_GT(band.spacings.size(), 0u); |
| 573 | ASSERT_GT(band.upperLimit, band.lowerLimit); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 574 | |
| 575 | // test scan UP |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 576 | uint32_t lowerLimit = band.lowerLimit; |
| 577 | uint32_t upperLimit = band.upperLimit; |
| 578 | uint32_t spacing = band.spacings[0]; |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 579 | |
| 580 | uint32_t channel = |
| 581 | lowerLimit + (((upperLimit - lowerLimit) / 2 + spacing - 1) / spacing) * spacing; |
| 582 | mCallbackCalled = false; |
| 583 | mResultCallbackData = Result::NOT_INITIALIZED; |
| 584 | Return<Result> hidlResult = mTuner->tune(channel, 0); |
Steven Moreland | b643842 | 2017-01-03 17:06:57 -0800 | [diff] [blame] | 585 | EXPECT_TRUE(hidlResult.isOk()); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 586 | EXPECT_EQ(Result::OK, hidlResult); |
| 587 | EXPECT_EQ(true, waitForCallback(kTuneCallbacktimeoutNs)); |
Tomasz Wasilczyk | f3c036d | 2017-03-03 15:07:50 -0800 | [diff] [blame] | 588 | EXPECT_EQ(channel, mProgramInfoCallbackData.channel); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 589 | |
| 590 | // test getProgramInformation |
| 591 | ProgramInfo halInfo; |
| 592 | Result halResult = Result::NOT_INITIALIZED; |
| 593 | Return<void> hidlReturn = mTuner->getProgramInformation( |
Tomasz Wasilczyk | 5cc9d86 | 2017-01-06 14:19:11 -0800 | [diff] [blame] | 594 | [&](Result result, const ProgramInfo& info) { |
| 595 | halResult = result; |
| 596 | if (result == Result::OK) { |
| 597 | halInfo = info; |
| 598 | } |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 599 | }); |
Steven Moreland | b643842 | 2017-01-03 17:06:57 -0800 | [diff] [blame] | 600 | EXPECT_TRUE(hidlReturn.isOk()); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 601 | EXPECT_EQ(Result::OK, halResult); |
| 602 | if (mResultCallbackData == Result::OK) { |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 603 | EXPECT_LE(halInfo.channel, upperLimit); |
| 604 | EXPECT_GE(halInfo.channel, lowerLimit); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 605 | } |
| 606 | |
| 607 | // test cancel |
| 608 | mTuner->tune(lowerLimit, 0); |
| 609 | hidlResult = mTuner->cancel(); |
Steven Moreland | b643842 | 2017-01-03 17:06:57 -0800 | [diff] [blame] | 610 | EXPECT_TRUE(hidlResult.isOk()); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 611 | EXPECT_EQ(Result::OK, hidlResult); |
| 612 | } |
| 613 | |
Tomasz Wasilczyk | 59d985d | 2017-03-03 13:02:15 -0800 | [diff] [blame] | 614 | /** |
| 615 | * Test ITuner::tune failing when channel out of the range is provided. |
| 616 | * |
| 617 | * Verifies that: |
| 618 | * - the method returns INVALID_ARGUMENTS when applicable |
| 619 | * - the method recovers and succeeds after passing correct arguments |
| 620 | */ |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 621 | TEST_P(BroadcastRadioHidlTest, TuneFailsOutOfBounds) { |
Tomasz Wasilczyk | da72d37 | 2017-06-26 16:08:51 -0700 | [diff] [blame] | 622 | if (radioClass != Class::AM_FM) skipped = true; |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 623 | RETURN_IF_SKIPPED; |
Tomasz Wasilczyk | 59d985d | 2017-03-03 13:02:15 -0800 | [diff] [blame] | 624 | ASSERT_TRUE(openTuner()); |
| 625 | ASSERT_TRUE(checkAntenna()); |
| 626 | |
| 627 | // get current channel bounds |
| 628 | BandConfig halConfig; |
| 629 | Result halResult; |
| 630 | auto configResult = mTuner->getConfiguration([&](Result result, const BandConfig& config) { |
| 631 | halResult = result; |
| 632 | halConfig = config; |
| 633 | }); |
| 634 | ASSERT_TRUE(configResult.isOk()); |
| 635 | ASSERT_EQ(Result::OK, halResult); |
| 636 | |
| 637 | // try to tune slightly above the limit and expect to fail |
| 638 | auto badChannel = halConfig.upperLimit + halConfig.spacings[0]; |
| 639 | auto tuneResult = mTuner->tune(badChannel, 0); |
| 640 | EXPECT_TRUE(tuneResult.isOk()); |
| 641 | EXPECT_EQ(Result::INVALID_ARGUMENTS, tuneResult); |
| 642 | EXPECT_TRUE(waitForCallback(kTuneCallbacktimeoutNs)); |
| 643 | |
| 644 | // tuning exactly at the limit should succeed |
| 645 | auto goodChannel = halConfig.upperLimit; |
| 646 | tuneResult = mTuner->tune(goodChannel, 0); |
| 647 | EXPECT_TRUE(tuneResult.isOk()); |
| 648 | EXPECT_EQ(Result::OK, tuneResult); |
| 649 | EXPECT_TRUE(waitForCallback(kTuneCallbacktimeoutNs)); |
| 650 | } |
| 651 | |
Tomasz Wasilczyk | ba3e254 | 2017-07-17 13:59:21 -0700 | [diff] [blame] | 652 | /** |
| 653 | * Test proper image format in metadata. |
| 654 | * |
| 655 | * Verifies that: |
| 656 | * - all images in metadata are provided in-band (as a binary blob, not by id) |
| 657 | * |
| 658 | * This is a counter-test for OobImagesOnly from 1.1 VTS. |
| 659 | */ |
| 660 | TEST_P(BroadcastRadioHidlTest, IbImagesOnly) { |
| 661 | RETURN_IF_SKIPPED; |
| 662 | ASSERT_TRUE(openTuner()); |
| 663 | ASSERT_TRUE(checkAntenna()); |
| 664 | |
| 665 | bool firstScan = true; |
| 666 | uint32_t firstChannel, prevChannel; |
| 667 | while (true) { |
| 668 | mCallbackCalled = false; |
| 669 | auto hidlResult = mTuner->scan(Direction::UP, true); |
| 670 | ASSERT_TRUE(hidlResult.isOk()); |
| 671 | if (hidlResult == Result::TIMEOUT) { |
| 672 | ALOGI("Got timeout on scan operation"); |
| 673 | break; |
| 674 | } |
| 675 | ASSERT_EQ(Result::OK, hidlResult); |
| 676 | ASSERT_EQ(true, waitForCallback(kTuneCallbacktimeoutNs)); |
| 677 | |
| 678 | if (firstScan) { |
| 679 | firstScan = false; |
| 680 | firstChannel = mProgramInfoCallbackData.channel; |
| 681 | } else { |
| 682 | // scanned the whole band |
| 683 | if (mProgramInfoCallbackData.channel >= firstChannel && prevChannel <= firstChannel) { |
| 684 | break; |
| 685 | } |
| 686 | } |
| 687 | prevChannel = mProgramInfoCallbackData.channel; |
| 688 | |
| 689 | for (auto&& entry : mProgramInfoCallbackData.metadata) { |
| 690 | if (entry.key != MetadataKey::ICON && entry.key != MetadataKey::ART) continue; |
| 691 | EXPECT_EQ(MetadataType::RAW, entry.type); |
| 692 | EXPECT_EQ(0, entry.intValue); |
| 693 | EXPECT_GT(entry.rawValue.size(), 0u); |
| 694 | } |
| 695 | } |
| 696 | } |
| 697 | |
Tomasz Wasilczyk | 2f46101 | 2017-03-14 11:19:15 -0700 | [diff] [blame] | 698 | INSTANTIATE_TEST_CASE_P( |
| 699 | BroadcastRadioHidlTestCases, |
| 700 | BroadcastRadioHidlTest, |
| 701 | ::testing::Values(Class::AM_FM, Class::SAT, Class::DT)); |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 702 | |
| 703 | int main(int argc, char** argv) { |
Eric Laurent | 566fcda | 2016-11-23 10:36:36 -0800 | [diff] [blame] | 704 | ::testing::InitGoogleTest(&argc, argv); |
| 705 | int status = RUN_ALL_TESTS(); |
| 706 | ALOGI("Test result = %d", status); |
| 707 | return status; |
| 708 | } |