summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2023-11-15 20:08:41 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2023-11-15 20:08:41 +0000
commit681960a95b393df2d4bce8ac7844f63fc89a0dd8 (patch)
tree2922f0d7656c8d38d6c22592bb88b509bd9b4a11
parentc1855f52bc1950dd27788e2cfb6577c4980d1e5d (diff)
parent2d7206567fdd53444817ec3d4b4f10cdb839d1e7 (diff)
downloadcts-oreo-cts-dev.tar.gz
Merge "DO NOT MERGE" into oreo-cts-devoreo-cts-dev
-rw-r--r--tests/tests/location/src/android/location/cts/GeocoderTest.java46
1 files changed, 14 insertions, 32 deletions
diff --git a/tests/tests/location/src/android/location/cts/GeocoderTest.java b/tests/tests/location/src/android/location/cts/GeocoderTest.java
index 62d9d251028..d6b425f776a 100644
--- a/tests/tests/location/src/android/location/cts/GeocoderTest.java
+++ b/tests/tests/location/src/android/location/cts/GeocoderTest.java
@@ -22,14 +22,13 @@ import android.content.Intent;
import android.content.pm.PackageManager;
import android.location.Geocoder;
import android.test.AndroidTestCase;
+import android.util.Log;
import java.io.IOException;
import java.util.Locale;
public class GeocoderTest extends AndroidTestCase {
-
- private static final int MAX_NUM_RETRIES = 5;
- private static final int TIME_BETWEEN_RETRIES_MS = 10 * 1000;
+ private static final String TAG = GeocoderTest.class.getSimpleName();
public void testConstructor() {
new Geocoder(getContext());
@@ -70,23 +69,14 @@ public class GeocoderTest extends AndroidTestCase {
// Thus only test that calling the method with valid arguments doesn't produce
// an unexpected exception
// Note: there is a risk this test will fail if device under test does not have
- // a network connection. This is why we try the geocode 5 times if it fails due
- // to a network error.
- int numRetries = 0;
- while (numRetries < MAX_NUM_RETRIES) {
- try {
- geocoder.getFromLocation(60, 30, 5);
- break;
- } catch (IOException e) {
- Thread.sleep(TIME_BETWEEN_RETRIES_MS);
- numRetries++;
- }
- }
- if (numRetries >= MAX_NUM_RETRIES) {
- fail("Failed to geocode location " + MAX_NUM_RETRIES + " times.");
+ // a network connection. This is why we don't fail the test if we get an
+ // IOException.
+ try {
+ geocoder.getFromLocation(60, 30, 5);
+ } catch (IOException e) {
+ Log.e(TAG, "GeoCoder getFromLocation request failed.", e);
}
-
try {
// latitude is less than -90
geocoder.getFromLocation(-91, 30, 5);
@@ -123,20 +113,12 @@ public class GeocoderTest extends AndroidTestCase {
// Thus only test that calling the method with valid arguments doesn't produce
// an unexpected exception
// Note: there is a risk this test will fail if device under test does not have
- // a network connection. This is why we try the geocode 5 times if it fails due
- // to a network error.
- int numRetries = 0;
- while (numRetries < MAX_NUM_RETRIES) {
- try {
- geocoder.getFromLocationName("Dalvik,Iceland", 5);
- break;
- } catch (IOException e) {
- Thread.sleep(TIME_BETWEEN_RETRIES_MS);
- numRetries++;
- }
- }
- if (numRetries >= MAX_NUM_RETRIES) {
- fail("Failed to geocode location name " + MAX_NUM_RETRIES + " times.");
+ // a network connection. This is why we don't fail the test if we get an
+ // IOException.
+ try {
+ geocoder.getFromLocationName("Dalvik,Iceland", 5);
+ } catch (IOException e) {
+ Log.e(TAG, "GeoCoder getFromLocationName request failed.", e);
}
try {