From a91d32f22af1ae7ee91d834c1a56aebeaa0ba66e Mon Sep 17 00:00:00 2001 From: Paul Hawke Date: Sun, 16 Jul 2017 13:04:24 -0500 Subject: [PATCH 1/2] Pinned the NearbyAdapterFactoryTest to api level 21 for the test. --- .../fr/free/nrw/commons/nearby/NearbyAdapterFactoryTest.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/test/java/fr/free/nrw/commons/nearby/NearbyAdapterFactoryTest.java b/app/src/test/java/fr/free/nrw/commons/nearby/NearbyAdapterFactoryTest.java index 0ef58f873..e54e4d7f2 100644 --- a/app/src/test/java/fr/free/nrw/commons/nearby/NearbyAdapterFactoryTest.java +++ b/app/src/test/java/fr/free/nrw/commons/nearby/NearbyAdapterFactoryTest.java @@ -22,10 +22,11 @@ import fr.free.nrw.commons.BuildConfig; import fr.free.nrw.commons.R; import fr.free.nrw.commons.location.LatLng; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; @RunWith(RobolectricTestRunner.class) -@Config(constants = BuildConfig.class) +@Config(constants = BuildConfig.class, sdk = 21) public class NearbyAdapterFactoryTest { private static final Place PLACE = new Place("name", Place.Description.AIRPORT, From 2e4b25aa99328582e93030b147b1c7dedd33f384 Mon Sep 17 00:00:00 2001 From: Paul Hawke Date: Mon, 17 Jul 2017 19:21:40 -0500 Subject: [PATCH 2/2] Changes pulled in from whym/apps-android-commons. --- .../nrw/commons/SettingsActivityTest.java | 28 ++++++------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/app/src/androidTest/java/fr/free/nrw/commons/SettingsActivityTest.java b/app/src/androidTest/java/fr/free/nrw/commons/SettingsActivityTest.java index 533498a47..5be309252 100644 --- a/app/src/androidTest/java/fr/free/nrw/commons/SettingsActivityTest.java +++ b/app/src/androidTest/java/fr/free/nrw/commons/SettingsActivityTest.java @@ -9,9 +9,8 @@ import android.support.test.espresso.matcher.ViewMatchers; import android.support.test.filters.LargeTest; import android.support.test.rule.ActivityTestRule; import android.support.test.runner.AndroidJUnit4; -import android.view.View; -import org.hamcrest.Matcher; +import org.hamcrest.Matchers; import org.junit.Rule; import org.junit.Test; import org.junit.runner.RunWith; @@ -20,9 +19,6 @@ import java.util.Map; import fr.free.nrw.commons.settings.SettingsActivity; -import static org.hamcrest.Matchers.allOf; -import static org.hamcrest.Matchers.anything; - @LargeTest @RunWith(AndroidJUnit4.class) public class SettingsActivityTest { @@ -65,8 +61,8 @@ public class SettingsActivityTest { @Test public void oneLicenseIsChecked() { // click "License" (the first item) - Espresso.onData(anything()) - .inAdapterView(findPreferenceList()) + Espresso.onData(Matchers.anything()) + .inAdapterView(ViewMatchers.withId(android.R.id.list)) .atPosition(0) .perform(ViewActions.click()); @@ -78,8 +74,8 @@ public class SettingsActivityTest { @Test public void afterClickingCcby4ItWillStay() { // click "License" (the first item) - Espresso.onData(anything()) - .inAdapterView(findPreferenceList()) + Espresso.onData(Matchers.anything()) + .inAdapterView(ViewMatchers.withId(android.R.id.list)) .atPosition(0) .perform(ViewActions.click()); @@ -89,8 +85,8 @@ public class SettingsActivityTest { ).perform(ViewActions.click()); // click "License" (the first item) - Espresso.onData(anything()) - .inAdapterView(findPreferenceList()) + Espresso.onData(Matchers.anything()) + .inAdapterView(ViewMatchers.withId(android.R.id.list)) .atPosition(0) .perform(ViewActions.click()); @@ -100,12 +96,4 @@ public class SettingsActivityTest { ViewMatchers.withText(R.string.license_name_cc_by_four) )); } - - private static Matcher findPreferenceList() { - return allOf( - ViewMatchers.isDescendantOfA(ViewMatchers.withId(R.id.settingsFragment)), - ViewMatchers.withResourceName("list"), - ViewMatchers.hasFocus() - ); - } -} +} \ No newline at end of file