aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/cgeo/geocaching/location/GeocoderTest.java3
-rw-r--r--tests/src/cgeo/geocaching/utils/ProcessUtilsTest.java4
-rw-r--r--tests/src/cgeo/junit/CgeoTestRunner.java39
3 files changed, 30 insertions, 16 deletions
diff --git a/tests/src/cgeo/geocaching/location/GeocoderTest.java b/tests/src/cgeo/geocaching/location/GeocoderTest.java
index 0cc1a79..937c75d 100644
--- a/tests/src/cgeo/geocaching/location/GeocoderTest.java
+++ b/tests/src/cgeo/geocaching/location/GeocoderTest.java
@@ -49,7 +49,8 @@ public class GeocoderTest extends CGeoTestCase {
if (withAddress) {
assertThat(StringUtils.lowerCase(address.getAddressLine(0))).as(describe("street address", geocoder)).startsWith("46 rue barrault");
assertThat(address.getLocality()).as(describe("locality", geocoder)).isEqualTo("Paris");
- assertThat(address.getCountryName()).as(describe("country name", geocoder)).isEqualTo("France");
+ assertThat(address.getCountryCode()).as(describe("country code", geocoder)).isEqualTo("FR");
+ // don't assert on country name, as this can be localized, e.g. with the mapquest geocoder
}
}
diff --git a/tests/src/cgeo/geocaching/utils/ProcessUtilsTest.java b/tests/src/cgeo/geocaching/utils/ProcessUtilsTest.java
index 2c6ed18..b442c8a 100644
--- a/tests/src/cgeo/geocaching/utils/ProcessUtilsTest.java
+++ b/tests/src/cgeo/geocaching/utils/ProcessUtilsTest.java
@@ -6,7 +6,7 @@ import junit.framework.TestCase;
public class ProcessUtilsTest extends TestCase {
public static void testIsInstalled() {
- assertThat(ProcessUtils.isInstalled("com.android.launcher")).isTrue();
+ assertThat(ProcessUtils.isInstalled("com.android.settings")).isTrue();
}
public static void testIsInstalledNotLaunchable() {
@@ -16,7 +16,7 @@ public class ProcessUtilsTest extends TestCase {
}
public static void testIsLaunchable() {
- assertThat(ProcessUtils.isInstalled("com.android.settings")).isTrue();
+ assertThat(ProcessUtils.isLaunchable("com.android.settings")).isTrue();
}
}
diff --git a/tests/src/cgeo/junit/CgeoTestRunner.java b/tests/src/cgeo/junit/CgeoTestRunner.java
index 16a5f12..94803cf 100644
--- a/tests/src/cgeo/junit/CgeoTestRunner.java
+++ b/tests/src/cgeo/junit/CgeoTestRunner.java
@@ -11,10 +11,12 @@ import android.util.Log;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
/**
* Test runner which derives from the newer Google instrumentation test runner used by the Espresso test framework. It
- * adds junit report functionality by cloning the behaviour of the {@link JUnitReportTestRunner}.
+ * adds junit report functionality by cloning the behavior of the {@link JUnitReportTestRunner}.
*
*/
public class CgeoTestRunner extends GoogleInstrumentationTestRunner {
@@ -86,21 +88,32 @@ public class CgeoTestRunner extends GoogleInstrumentationTestRunner {
@Override
public void start() {
- mListener = new JUnitReportListener(getContext(), getTargetContext(), mReportFile, mReportDir, mFilterTraces, mMultiFile);
- try {
- Class<?> c = getClass();
- Field bridgeTestRunner = c.getSuperclass().getDeclaredField("bridgeTestRunner");
- bridgeTestRunner.setAccessible(true);
- Object obj = bridgeTestRunner.get(this);
- Method m = obj.getClass().getDeclaredMethod("getAndroidTestRunner", (Class[]) null);
- AndroidTestRunner androidTestRunner = (AndroidTestRunner) m.invoke(obj);
- androidTestRunner.addTestListener(mListener);
- } catch (NoSuchFieldException | InvocationTargetException | IllegalAccessException | NoSuchMethodException | SecurityException x) {
- Log.e(LOG_TAG, x.toString());
- }
+ makeAndroidTestRunnerAccessible();
super.start();
}
+ private void makeAndroidTestRunnerAccessible() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ @Override
+ public Void run() {
+ mListener = new JUnitReportListener(getContext(), getTargetContext(), mReportFile, mReportDir, mFilterTraces, mMultiFile);
+ try {
+ Class<?> c = getClass();
+ Field bridgeTestRunner = c.getSuperclass().getDeclaredField("bridgeTestRunner");
+ bridgeTestRunner.setAccessible(true);
+ Object obj = bridgeTestRunner.get(this);
+ Method m = obj.getClass().getDeclaredMethod("getAndroidTestRunner", (Class[]) null);
+ AndroidTestRunner androidTestRunner = (AndroidTestRunner) m.invoke(obj);
+ androidTestRunner.addTestListener(mListener);
+ } catch (NoSuchFieldException | InvocationTargetException | IllegalAccessException
+ | NoSuchMethodException | SecurityException x) {
+ Log.e(LOG_TAG, x.toString());
+ }
+ return null;
+ }
+ });
+ }
+
@Override
public void finish(int resultCode, Bundle results) {
if (mListener != null) {