mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 06:42:21 -04:00
#2026 Migrate Zim prefix away from "content://" - allow test to click on either text
This commit is contained in:
parent
0435d73f64
commit
c47b9962e5
@ -18,9 +18,11 @@
|
|||||||
|
|
||||||
package org.kiwix.kiwixmobile.settings;
|
package org.kiwix.kiwixmobile.settings;
|
||||||
|
|
||||||
|
import android.view.View;
|
||||||
import androidx.annotation.StringRes;
|
import androidx.annotation.StringRes;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
import androidx.test.rule.ActivityTestRule;
|
import androidx.test.rule.ActivityTestRule;
|
||||||
|
import org.hamcrest.Matcher;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -33,6 +35,7 @@ import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
|
|||||||
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
|
import static androidx.test.espresso.matcher.ViewMatchers.withClassName;
|
||||||
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
import static androidx.test.espresso.matcher.ViewMatchers.withText;
|
||||||
import static com.schibsted.spain.barista.assertion.BaristaVisibilityAssertions.assertDisplayed;
|
import static com.schibsted.spain.barista.assertion.BaristaVisibilityAssertions.assertDisplayed;
|
||||||
|
import static org.hamcrest.Matchers.anyOf;
|
||||||
import static org.hamcrest.Matchers.is;
|
import static org.hamcrest.Matchers.is;
|
||||||
|
|
||||||
public class KiwixSettingsActivityTest {
|
public class KiwixSettingsActivityTest {
|
||||||
@ -49,9 +52,13 @@ public class KiwixSettingsActivityTest {
|
|||||||
clickOn(R.string.pref_wifi_only);
|
clickOn(R.string.pref_wifi_only);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clickOn(@StringRes int stringId) {
|
private void clickOn(@StringRes int... stringIds) {
|
||||||
|
Matcher<View>[] matchers= new Matcher[stringIds.length];
|
||||||
|
for (int i = 0; i < stringIds.length; i++) {
|
||||||
|
matchers[i]= withText(stringIds[i]);
|
||||||
|
}
|
||||||
onView(withClassName(is(RecyclerView.class.getName())))
|
onView(withClassName(is(RecyclerView.class.getName())))
|
||||||
.perform(actionOnItem(hasDescendant(withText(stringId)), click()));
|
.perform(actionOnItem(hasDescendant(anyOf(matchers)), click()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -62,8 +69,8 @@ public class KiwixSettingsActivityTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testStorageDialog() {
|
public void testStorageDialog() {
|
||||||
clickOn(R.string.pref_storage_summary);
|
clickOn(R.string.internal_storage, R.string.external_storage);
|
||||||
assertDisplayed(R.string.internal_storage);
|
assertDisplayed(R.string.pref_storage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -275,7 +275,6 @@
|
|||||||
<string name="diagnostic_report_message">Please send all the following details so we can diagnose the problem</string>
|
<string name="diagnostic_report_message">Please send all the following details so we can diagnose the problem</string>
|
||||||
<string name="percentage">%d%%</string>
|
<string name="percentage">%d%%</string>
|
||||||
<string name="pref_text_zoom_title">Text Zoom</string>
|
<string name="pref_text_zoom_title">Text Zoom</string>
|
||||||
<string name="pref_storage_summary">Choose where files get saved to</string>
|
|
||||||
<string-array name="pref_night_modes_entries">
|
<string-array name="pref_night_modes_entries">
|
||||||
<item>@string/on</item>
|
<item>@string/on</item>
|
||||||
<item>@string/off</item>
|
<item>@string/off</item>
|
||||||
|
@ -68,8 +68,7 @@
|
|||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
android:key="pref_storage"
|
android:key="pref_storage"
|
||||||
android:title="@string/pref_storage"
|
app:title="@string/pref_storage"
|
||||||
app:summary="@string/pref_storage_summary"
|
|
||||||
app:iconSpaceReserved="false">
|
app:iconSpaceReserved="false">
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
|
Loading…
x
Reference in New Issue
Block a user