Unbundled build fixes for tests
Build tests against current SDK. Use internal copy of LaunchPerformanceBase.
Use android-support-test instead of android.test.runner. Use reflection
to call AsyncTaskLoader.waitForLoader. Use public PhoneNumberUtil APIs.
Bug:23642167
Change-Id: I66841fe9429e374a931a5c6eada5afce932c5bef
(cherry picked from commit 2f8ebf44226b979a214b68189b832429aec04aed)
diff --git a/tests/Android.mk b/tests/Android.mk
index 880f62f..fe4c9b2 100644
--- a/tests/Android.mk
+++ b/tests/Android.mk
@@ -5,10 +5,10 @@
LOCAL_MODULE_TAGS := tests
LOCAL_CERTIFICATE := shared
-LOCAL_JAVA_LIBRARIES := android.test.runner
+LOCAL_STATIC_JAVA_LIBRARIES := android-support-test
src_dirs := src \
- ../../ContactsCommon/TestCommon/src
+ ../../ContactsCommon/TestCommon/src
# Include all test java files.
LOCAL_SRC_FILES := $(call all-java-files-under, $(src_dirs))
@@ -17,4 +17,6 @@
LOCAL_INSTRUMENTATION_FOR := Contacts
+LOCAL_SDK_VERSION := current
+
include $(BUILD_PACKAGE)
diff --git a/tests/src/com/android/contacts/ContactsLaunchPerformance.java b/tests/src/com/android/contacts/ContactsLaunchPerformance.java
index 411ba4e..894ae2c 100644
--- a/tests/src/com/android/contacts/ContactsLaunchPerformance.java
+++ b/tests/src/com/android/contacts/ContactsLaunchPerformance.java
@@ -20,7 +20,8 @@
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
-import android.test.LaunchPerformanceBase;
+
+import com.android.contacts.common.test.LaunchPerformanceBase;
/**
* Instrumentation class for Address Book launch performance testing.
diff --git a/tests/src/com/android/contacts/interactions/TestLoaderManager.java b/tests/src/com/android/contacts/interactions/TestLoaderManager.java
index 3e0db63..dacf616 100644
--- a/tests/src/com/android/contacts/interactions/TestLoaderManager.java
+++ b/tests/src/com/android/contacts/interactions/TestLoaderManager.java
@@ -111,7 +111,7 @@
@Override
public void run() {
try {
- loader.waitForLoader();
+ AsyncTaskLoader.class.getMethod("waitForLoader").invoke(loader, null);
} catch (Throwable e) {
Log.e(TAG, "Exception while waiting for loader: " + loader.getId(), e);
Assert.fail("Exception while waiting for loader: " + loader.getId());
diff --git a/tests/src/com/android/contacts/tests/PhoneNumberTestService.java b/tests/src/com/android/contacts/tests/PhoneNumberTestService.java
index a38ef2a..d5fee92 100644
--- a/tests/src/com/android/contacts/tests/PhoneNumberTestService.java
+++ b/tests/src/com/android/contacts/tests/PhoneNumberTestService.java
@@ -19,14 +19,14 @@
import android.app.IntentService;
import android.content.Context;
import android.content.Intent;
-import android.location.CountryDetector;
import android.telephony.PhoneNumberUtils;
import android.util.Log;
-import com.android.i18n.phonenumbers.NumberParseException;
-import com.android.i18n.phonenumbers.PhoneNumberUtil;
-import com.android.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat;
-import com.android.i18n.phonenumbers.Phonenumber.PhoneNumber;
+import com.android.contacts.common.GeoUtil;
+import com.google.i18n.phonenumbers.NumberParseException;
+import com.google.i18n.phonenumbers.PhoneNumberUtil;
+import com.google.i18n.phonenumbers.PhoneNumberUtil.PhoneNumberFormat;
+import com.google.i18n.phonenumbers.Phonenumber.PhoneNumber;
import java.util.LinkedHashSet;
import java.util.Set;
@@ -112,9 +112,6 @@
}
private String getCurrentCountryCode() {
- final CountryDetector countryDetector =
- (CountryDetector) getSystemService(Context.COUNTRY_DETECTOR);
- return countryDetector.detectCountry().getCountryIso();
+ return GeoUtil.getCurrentCountryIso(getApplicationContext());
}
}
-