From 5f0bbe9324ce77da80e5952daace59451b379333 Mon Sep 17 00:00:00 2001 From: Yu-Han Yang Date: Wed, 26 Feb 2020 15:55:03 -0800 Subject: [PATCH] Make GetLocationLowPower test warning instead of failing Bug: 150222509 Bug: 152434001 Test: passing on device with GSI build Change-Id: I8af0a992d1cf4af9ef1e78095f7352534c711549 --- gnss/1.1/vts/functional/gnss_hal_test.cpp | 15 +++++++++------ gnss/1.1/vts/functional/gnss_hal_test.h | 4 +++- gnss/1.1/vts/functional/gnss_hal_test_cases.cpp | 2 +- gnss/2.0/vts/functional/gnss_hal_test.cpp | 16 +++++++++------- gnss/2.0/vts/functional/gnss_hal_test.h | 4 +++- gnss/2.0/vts/functional/gnss_hal_test_cases.cpp | 8 ++++---- 6 files changed, 29 insertions(+), 20 deletions(-) diff --git a/gnss/1.1/vts/functional/gnss_hal_test.cpp b/gnss/1.1/vts/functional/gnss_hal_test.cpp index 88fbff8164..52aaa69753 100644 --- a/gnss/1.1/vts/functional/gnss_hal_test.cpp +++ b/gnss/1.1/vts/functional/gnss_hal_test.cpp @@ -99,7 +99,7 @@ void GnssHalTest::SetPositionMode(const int min_interval_msec, const bool low_po EXPECT_TRUE(result); } -bool GnssHalTest::StartAndCheckFirstLocation() { +bool GnssHalTest::StartAndCheckFirstLocation(bool strict) { auto result = gnss_hal_->start(); EXPECT_TRUE(result.isOk()); @@ -110,11 +110,14 @@ bool GnssHalTest::StartAndCheckFirstLocation() { * so allow time to demodulate ephemeris over the air. */ const int kFirstGnssLocationTimeoutSeconds = 75; + int locationCalledCount = 0; - EXPECT_TRUE(gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, - kFirstGnssLocationTimeoutSeconds)); - int locationCalledCount = gnss_cb_->location_cbq_.calledCount(); - EXPECT_EQ(locationCalledCount, 1); + if (strict) { + EXPECT_TRUE(gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, + kFirstGnssLocationTimeoutSeconds)); + locationCalledCount = gnss_cb_->location_cbq_.calledCount(); + EXPECT_EQ(locationCalledCount, 1); + } if (locationCalledCount > 0) { // don't require speed on first fix @@ -138,7 +141,7 @@ void GnssHalTest::StartAndCheckLocations(int count) { SetPositionMode(kMinIntervalMsec, kLowPowerMode); - EXPECT_TRUE(StartAndCheckFirstLocation()); + EXPECT_TRUE(StartAndCheckFirstLocation(/* strict= */ true)); for (int i = 1; i < count; i++) { EXPECT_TRUE(gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, diff --git a/gnss/1.1/vts/functional/gnss_hal_test.h b/gnss/1.1/vts/functional/gnss_hal_test.h index 88b77236ae..75c4216e4a 100644 --- a/gnss/1.1/vts/functional/gnss_hal_test.h +++ b/gnss/1.1/vts/functional/gnss_hal_test.h @@ -102,9 +102,11 @@ class GnssHalTest : public testing::TestWithParam { *

Note this leaves the Location request active, to enable Stop call vs. other call * reordering tests. * + *

if 'strict' is true, the test will fail if no location is generated. + * * returns true if a location was successfully generated */ - bool StartAndCheckFirstLocation(); + bool StartAndCheckFirstLocation(bool strict); /* * CheckLocation: 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 8530ffb08e..e6a51eb731 100644 --- a/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp +++ b/gnss/1.1/vts/functional/gnss_hal_test_cases.cpp @@ -93,7 +93,7 @@ TEST_P(GnssHalTest, GetLocationLowPower) { SetPositionMode(kMinIntervalMsec, kLowPowerMode); // Don't expect true - as without AGPS access - if (!StartAndCheckFirstLocation()) { + if (!StartAndCheckFirstLocation(/* strict= */ false)) { ALOGW("GetLocationLowPower test - no first low power location received."); } diff --git a/gnss/2.0/vts/functional/gnss_hal_test.cpp b/gnss/2.0/vts/functional/gnss_hal_test.cpp index b3a3203214..59e18f3642 100644 --- a/gnss/2.0/vts/functional/gnss_hal_test.cpp +++ b/gnss/2.0/vts/functional/gnss_hal_test.cpp @@ -97,7 +97,7 @@ void GnssHalTest::SetPositionMode(const int min_interval_msec, const bool low_po EXPECT_TRUE(result); } -bool GnssHalTest::StartAndCheckFirstLocation() { +bool GnssHalTest::StartAndCheckFirstLocation(bool strict) { const auto result = gnss_hal_->start(); EXPECT_TRUE(result.isOk()); @@ -107,12 +107,14 @@ bool GnssHalTest::StartAndCheckFirstLocation() { * so allow time to demodulate ephemeris over the air. */ const int kFirstGnssLocationTimeoutSeconds = 75; + int locationCalledCount = 0; - EXPECT_TRUE(gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, - kFirstGnssLocationTimeoutSeconds)); - int locationCalledCount = gnss_cb_->location_cbq_.calledCount(); - EXPECT_EQ(locationCalledCount, 1); - + if (strict) { + EXPECT_TRUE(gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, + kFirstGnssLocationTimeoutSeconds)); + locationCalledCount = gnss_cb_->location_cbq_.calledCount(); + EXPECT_EQ(locationCalledCount, 1); + } if (locationCalledCount > 0) { // don't require speed on first fix CheckLocation(gnss_cb_->last_location_, false); @@ -135,7 +137,7 @@ void GnssHalTest::StartAndCheckLocations(int count) { SetPositionMode(kMinIntervalMsec, kLowPowerMode); - EXPECT_TRUE(StartAndCheckFirstLocation()); + EXPECT_TRUE(StartAndCheckFirstLocation(/* strict= */ true)); for (int i = 1; i < count; i++) { EXPECT_TRUE(gnss_cb_->location_cbq_.retrieve(gnss_cb_->last_location_, diff --git a/gnss/2.0/vts/functional/gnss_hal_test.h b/gnss/2.0/vts/functional/gnss_hal_test.h index 55dc1bc4f6..a02a9ff4a7 100644 --- a/gnss/2.0/vts/functional/gnss_hal_test.h +++ b/gnss/2.0/vts/functional/gnss_hal_test.h @@ -152,9 +152,11 @@ class GnssHalTest : public testing::TestWithParam { *

Note this leaves the Location request active, to enable Stop call vs. other call * reordering tests. * + *

if 'strict' is true, the test will fail if no location is generated. + * * returns true if a location was successfully generated */ - bool StartAndCheckFirstLocation(); + bool StartAndCheckFirstLocation(bool strict); /* * CheckLocation: 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 53f5b9e283..c93e89b843 100644 --- a/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp +++ b/gnss/2.0/vts/functional/gnss_hal_test_cases.cpp @@ -395,7 +395,7 @@ TEST_P(GnssHalTest, TestGnssDataElapsedRealtimeFlags) { } TEST_P(GnssHalTest, TestGnssLocationElapsedRealtime) { - StartAndCheckFirstLocation(); + StartAndCheckFirstLocation(/* strict= */ true); ASSERT_TRUE((int)gnss_cb_->last_location_.elapsedRealtime.flags <= (int)(ElapsedRealtimeFlags::HAS_TIMESTAMP_NS | @@ -411,7 +411,7 @@ TEST_P(GnssHalTest, TestGnssLocationElapsedRealtime) { // This test only verify that injectBestLocation_2_0 does not crash. TEST_P(GnssHalTest, TestInjectBestLocation_2_0) { - StartAndCheckFirstLocation(); + StartAndCheckFirstLocation(/* strict= */ true); gnss_hal_->injectBestLocation_2_0(gnss_cb_->last_location_); StopAndClearLocations(); } @@ -455,7 +455,7 @@ TEST_P(GnssHalTest, GetLocationLowPower) { SetPositionMode(kMinIntervalMsec, kLowPowerMode); // Don't expect true - as without AGPS access - if (!StartAndCheckFirstLocation()) { + if (!StartAndCheckFirstLocation(/* strict= */ false)) { ALOGW("GetLocationLowPower test - no first low power location received."); } @@ -854,4 +854,4 @@ TEST_P(GnssHalTest, BlacklistConstellation) { result = gnss_configuration_hal->setBlacklist(sources); ASSERT_TRUE(result.isOk()); EXPECT_TRUE(result); -} \ No newline at end of file +}