summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2021-01-09 05:07:17 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2021-01-09 05:07:17 +0000
commit4482ca442b4d5db1485c1185bd3d190d1f3c7035 (patch)
tree644117a65b743a7aa2569467ea0fa0b918617491
parenteaa8fc0874ec12604a438c30866db6086b7af5d2 (diff)
parent11e3c32499e67fa3a386669df7abb2283e78d3da (diff)
downloadcts-4482ca442b4d5db1485c1185bd3d190d1f3c7035.tar.gz
Merge "Snap for 7071652 from 1bd0d1649244a455f5f2082fbd369147842cd90e to android11-tests-release" into android11-tests-release
-rw-r--r--tests/location/location_privileged/src/android/location/cts/privileged/GnssLocationValuesTest.java35
1 files changed, 30 insertions, 5 deletions
diff --git a/tests/location/location_privileged/src/android/location/cts/privileged/GnssLocationValuesTest.java b/tests/location/location_privileged/src/android/location/cts/privileged/GnssLocationValuesTest.java
index fc5481e9f04..e750e03feca 100644
--- a/tests/location/location_privileged/src/android/location/cts/privileged/GnssLocationValuesTest.java
+++ b/tests/location/location_privileged/src/android/location/cts/privileged/GnssLocationValuesTest.java
@@ -24,9 +24,12 @@ import android.location.cts.common.TestLocationListener;
import android.location.cts.common.TestLocationManager;
import android.location.cts.common.TestMeasurementUtil;
import android.os.Build;
+import android.util.Log;
import androidx.test.InstrumentationRegistry;
+import org.junit.Assert;
+
/**
* Test the {@link Location} values.
*
@@ -67,8 +70,9 @@ public class GnssLocationValuesTest extends GnssTestCase {
}
/**
- * 1. Get GNSS locations in low power mode.
- * 2. Check whether all fields' value make sense.
+ * 1. Get regular GNSS locations to warm up the engine.
+ * 2. Get low-power GNSS locations.
+ * 3. Check whether all fields' value make sense.
*/
public void testLowPowerModeGnssLocation() throws Exception {
// Checks if GPS hardware feature is present, skips test (pass) if not,
@@ -77,16 +81,37 @@ public class GnssLocationValuesTest extends GnssTestCase {
mTestLocationManager, TAG)) {
return;
}
+
+ // Get regular GNSS locations to warm up the engine.
+ waitForRegularGnssLocations();
+
mTestLocationManager.requestLowPowerModeGnssLocationUpdates(5000, mLocationListener);
- waitAndValidateLocation();
+ waitAndValidateLowPowerLocations();
+ }
+
+
+ private void waitForRegularGnssLocations() throws InterruptedException {
+ TestLocationListener locationListener = new TestLocationListener(LOCATION_TO_COLLECT_COUNT);
+ mTestLocationManager.requestLocationUpdates(locationListener);
+ boolean success = locationListener.await();
+ mTestLocationManager.removeLocationUpdates(locationListener);
+
+ if (success) {
+ Log.i(TAG, "Successfully received " + LOCATION_TO_COLLECT_COUNT
+ + " regular GNSS locations.");
+ }
+
+ Assert.assertTrue("Time elapsed without getting enough regular GNSS locations."
+ + " Possibly, the test has been run deep indoors."
+ + " Consider retrying test outdoors.", success);
}
- private void waitAndValidateLocation() throws InterruptedException {
+ private void waitAndValidateLowPowerLocations() throws InterruptedException {
boolean success = mLocationListener.await();
SoftAssert softAssert = new SoftAssert(TAG);
softAssert.assertTrue(
- "Time elapsed without getting the GNSS locations."
+ "Time elapsed without getting the low-power GNSS locations."
+ " Possibly, the test has been run deep indoors."
+ " Consider retrying test outdoors.",
success);