From 03bc98e028d3ebe4ab2d657deb0cb24ed76e3e45 Mon Sep 17 00:00:00 2001 From: Anil Admal Date: Mon, 15 Jul 2019 18:52:00 -0700 Subject: [PATCH] Add GetLocationLowPower VTS 2.0 test - Run test only if LOW_POWER_MODE capability is supported. - Modify the corresponding VTS 1.1 test to run only if the GNSS HAL version is 1.1. Fixes: 127434062 Test: atest VtsHalGnssV2_0Target Change-Id: Icbd18d80468e9e5a542f2eace5bfbe45af08ca47 --- .../vts/functional/gnss_hal_test_cases.cpp | 5 ++ .../vts/functional/gnss_hal_test_cases.cpp | 67 +++++++++++++++++++ 2 files changed, 72 insertions(+) diff --git a/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp b/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp index 4288d0df9c..3a30ceadc6 100644 --- a/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp +++ b/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp @@ -59,6 +59,11 @@ TEST_F(GnssHalTest, TestGnssMeasurementCallback) { * each received location. */ TEST_F(GnssHalTest, GetLocationLowPower) { + if (!IsGnssHalVersion_1_1()) { + ALOGI("Test GetLocationLowPower skipped. GNSS HAL version is greater than 1.1."); + return; + } + const int kMinIntervalMsec = 5000; const int kLocationTimeoutSubsequentSec = (kMinIntervalMsec / 1000) * 2; const int kNoLocationPeriodSec = (kMinIntervalMsec / 1000) / 2; diff --git a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp index 6e0887fd9e..39736cc250 100644 --- a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp +++ b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp @@ -415,6 +415,70 @@ TEST_F(GnssHalTest, TestGnssBatchingExtension) { ASSERT_TRUE(gnssBatching_2_0.isOk()); } +/* + * GetLocationLowPower: + * Turns on location, waits for at least 5 locations allowing max of LOCATION_TIMEOUT_SUBSEQUENT_SEC + * between one location and the next. Also ensure that MIN_INTERVAL_MSEC is respected by waiting + * NO_LOCATION_PERIOD_SEC and verfiy that no location is received. Also perform validity checks on + * each received location. + */ +TEST_F(GnssHalTest, GetLocationLowPower) { + if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::LOW_POWER_MODE)) { + ALOGI("Test GetLocationLowPower skipped. LOW_POWER_MODE capability not supported."); + return; + } + + const int kMinIntervalMsec = 5000; + const int kLocationTimeoutSubsequentSec = (kMinIntervalMsec / 1000) * 2; + const int kNoLocationPeriodSec = (kMinIntervalMsec / 1000) / 2; + const int kLocationsToCheck = 5; + const bool kLowPowerMode = true; + + // Warmup period - VTS doesn't have AGPS access via GnssLocationProvider + gnss_cb_->location_cbq_.reset(); + StartAndCheckLocations(kLocationsToCheck); + StopAndClearLocations(); + gnss_cb_->location_cbq_.reset(); + + // Start of Low Power Mode test + SetPositionMode(kMinIntervalMsec, kLowPowerMode); + + // Don't expect true - as without AGPS access + if (!StartAndCheckFirstLocation()) { + ALOGW("GetLocationLowPower test - no first low power location received."); + } + + for (int i = 1; i < kLocationsToCheck; i++) { + // Verify that kMinIntervalMsec is respected by waiting kNoLocationPeriodSec and + // ensure that no location is received yet + + gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, kNoLocationPeriodSec); + const int locationCalledCount = gnss_cb_->location_cbq_.calledCount(); + + // Tolerate (ignore) one extra location right after the first one + // to handle startup edge case scheduling limitations in some implementations + if ((i == 1) && (locationCalledCount == 2)) { + CheckLocation(gnss_cb_->last_location_, true); + continue; // restart the quiet wait period after this too-fast location + } + EXPECT_LE(locationCalledCount, i); + if (locationCalledCount != i) { + ALOGW("GetLocationLowPower test - not enough locations received. %d vs. %d expected ", + locationCalledCount, i); + } + + if (!gnss_cb_->location_cbq_.retrieve( + gnss_cb_->last_location_, + kLocationTimeoutSubsequentSec - kNoLocationPeriodSec)) { + ALOGW("GetLocationLowPower test - timeout awaiting location %d", i); + } else { + CheckLocation(gnss_cb_->last_location_, true); + } + } + + StopAndClearLocations(); +} + /* * MapConstellationType: * Given a GnssConstellationType_2_0 type constellation, maps to its equivalent @@ -537,6 +601,8 @@ IGnssConfiguration_1_1::BlacklistedSource FindStrongFrequentNonGpsSource( */ TEST_F(GnssHalTest, BlacklistIndividualSatellites) { if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::SATELLITE_BLACKLIST)) { + ALOGI("Test BlacklistIndividualSatellites skipped. SATELLITE_BLACKLIST capability" + " not supported."); return; } @@ -680,6 +746,7 @@ TEST_F(GnssHalTest, BlacklistIndividualSatellites) { */ TEST_F(GnssHalTest, BlacklistConstellation) { if (!(gnss_cb_->last_capabilities_ & IGnssCallback::Capabilities::SATELLITE_BLACKLIST)) { + ALOGI("Test BlacklistConstellation skipped. SATELLITE_BLACKLIST capability not supported."); return; }