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 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,