aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/.settings/org.eclipse.jdt.ui.prefs22
-rw-r--r--tests/res/layout/cgeo_tests_activity.xml3
-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
5 files changed, 44 insertions, 27 deletions
diff --git a/tests/.settings/org.eclipse.jdt.ui.prefs b/tests/.settings/org.eclipse.jdt.ui.prefs
index 1fda530..06e562c 100644
--- a/tests/.settings/org.eclipse.jdt.ui.prefs
+++ b/tests/.settings/org.eclipse.jdt.ui.prefs
@@ -8,7 +8,7 @@ org.eclipse.jdt.ui.ondemandthreshold=99
org.eclipse.jdt.ui.staticondemandthreshold=99
sp_cleanup.add_default_serial_version_id=true
sp_cleanup.add_generated_serial_version_id=false
-sp_cleanup.add_missing_annotations=false
+sp_cleanup.add_missing_annotations=true
sp_cleanup.add_missing_deprecated_annotations=true
sp_cleanup.add_missing_methods=false
sp_cleanup.add_missing_nls_tags=false
@@ -20,16 +20,16 @@ sp_cleanup.always_use_parentheses_in_expressions=false
sp_cleanup.always_use_this_for_non_static_field_access=false
sp_cleanup.always_use_this_for_non_static_method_access=false
sp_cleanup.convert_functional_interfaces=false
-sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.convert_to_enhanced_for_loop=true
sp_cleanup.correct_indentation=false
sp_cleanup.format_source_code=true
sp_cleanup.format_source_code_changes_only=true
sp_cleanup.insert_inferred_type_arguments=false
-sp_cleanup.make_local_variable_final=false
-sp_cleanup.make_parameters_final=false
-sp_cleanup.make_private_fields_final=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=true
+sp_cleanup.make_private_fields_final=true
sp_cleanup.make_type_abstract_if_missing_method=false
-sp_cleanup.make_variable_declarations_final=false
+sp_cleanup.make_variable_declarations_final=true
sp_cleanup.never_use_blocks=false
sp_cleanup.never_use_parentheses_in_expressions=true
sp_cleanup.on_save_use_additional_actions=true
@@ -37,16 +37,16 @@ sp_cleanup.organize_imports=true
sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
sp_cleanup.remove_private_constructors=true
sp_cleanup.remove_redundant_type_arguments=false
sp_cleanup.remove_trailing_whitespaces=true
sp_cleanup.remove_trailing_whitespaces_all=true
sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
-sp_cleanup.remove_unnecessary_casts=false
-sp_cleanup.remove_unnecessary_nls_tags=false
-sp_cleanup.remove_unused_imports=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=true
sp_cleanup.remove_unused_local_variables=false
sp_cleanup.remove_unused_private_fields=true
sp_cleanup.remove_unused_private_members=false
@@ -55,7 +55,7 @@ sp_cleanup.remove_unused_private_types=true
sp_cleanup.sort_members=false
sp_cleanup.sort_members_all=false
sp_cleanup.use_anonymous_class_creation=false
-sp_cleanup.use_blocks=false
+sp_cleanup.use_blocks=true
sp_cleanup.use_blocks_only_for_return_and_throw=false
sp_cleanup.use_lambda=false
sp_cleanup.use_parentheses_in_expressions=false
diff --git a/tests/res/layout/cgeo_tests_activity.xml b/tests/res/layout/cgeo_tests_activity.xml
index 43225ac..d035210 100644
--- a/tests/res/layout/cgeo_tests_activity.xml
+++ b/tests/res/layout/cgeo_tests_activity.xml
@@ -13,6 +13,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
@@ -27,6 +28,7 @@
android:layout_height="fill_parent"
android:layout_above="@+id/buttonRun"
android:layout_alignParentLeft="true"
+ android:layout_alignParentStart="true"
android:layout_below="@+id/headline" >
<TextView
@@ -43,6 +45,7 @@
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="false"
+ android:layout_alignParentStart="false"
android:onClick="runTests"
android:text="@string/run_tests" />
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) {