OSDN Git Service

Update broadcastradio HAL 1.0 VTS tests.
authorTomasz Wasilczyk <twasilczyk@google.com>
Tue, 8 Aug 2017 01:00:28 +0000 (18:00 -0700)
committerTomasz Wasilczyk <twasilczyk@google.com>
Fri, 11 Aug 2017 03:28:18 +0000 (20:28 -0700)
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

broadcastradio/1.0/vts/functional/VtsHalBroadcastradioV1_0TargetTest.cpp

index fa0f030..fd048db 100644 (file)
@@ -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,8 +430,12 @@ 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) {
-        EXPECT_TRUE(waitForCallback(kConfigCallbacktimeoutNs));
+    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;