From cb5d9af5a828b4a74a1c0027b5b81929984b3fa4 Mon Sep 17 00:00:00 2001 From: frankknoll Date: Wed, 18 Dec 2024 17:40:31 +0100 Subject: [PATCH] refining SettingsSearchTest --- .../SettingsSearchParameterizedTest.java | 4 --- .../fragments/search/SettingsSearchTest.java | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/OsmAnd/test/java/net/osmand/plus/settings/fragments/search/SettingsSearchParameterizedTest.java b/OsmAnd/test/java/net/osmand/plus/settings/fragments/search/SettingsSearchParameterizedTest.java index 67efc2a1b48..5bab4a71b31 100644 --- a/OsmAnd/test/java/net/osmand/plus/settings/fragments/search/SettingsSearchParameterizedTest.java +++ b/OsmAnd/test/java/net/osmand/plus/settings/fragments/search/SettingsSearchParameterizedTest.java @@ -74,10 +74,6 @@ public static Iterable data() { {"ResetProfilePrefsBottomSheet: reset_confirmation_descr", searchQuery("Tapping Reset discards all your changes")}, {"GeneralProfileSettingsFragment", searchQuery(R.string.distance_during_navigation)} - - // FK-TODO: enable development plugin for these two test cases - // {"LocationInterpolationBottomSheet: title", Either.ofLeft(R.string.location_interpolation_percent)}, - // {"LocationInterpolationBottomSheet: description", Either.ofLeft(R.string.location_interpolation_percent_desc)} }); } diff --git a/OsmAnd/test/java/net/osmand/plus/settings/fragments/search/SettingsSearchTest.java b/OsmAnd/test/java/net/osmand/plus/settings/fragments/search/SettingsSearchTest.java index 1874e9de80b..50755acd403 100644 --- a/OsmAnd/test/java/net/osmand/plus/settings/fragments/search/SettingsSearchTest.java +++ b/OsmAnd/test/java/net/osmand/plus/settings/fragments/search/SettingsSearchTest.java @@ -26,6 +26,7 @@ import net.osmand.plus.plugins.OsmandPlugin; import net.osmand.plus.plugins.PluginsHelper; import net.osmand.plus.plugins.accessibility.AccessibilityPlugin; +import net.osmand.plus.plugins.development.OsmandDevelopmentPlugin; import net.osmand.test.common.AndroidTest; import org.hamcrest.Matcher; @@ -88,6 +89,29 @@ public void shouldSearchAndFind_ResetProfilePrefsBottomSheet_within_Accessibilit .forEach(path -> onView(searchResultsView()).check(matches(hasSearchResultWithSubstring(path)))); } + @Test + public void shouldSearchAndFind_LocationInterpolationBottomSheet_title() { + enablePlugin(getDevelopmentPlugin()); + shouldSearchAndFind(app.getString(R.string.location_interpolation_percent)); + } + + @Test + public void shouldSearchAndFind_LocationInterpolationBottomSheet_description() { + enablePlugin(getDevelopmentPlugin()); + shouldSearchAndFind(app.getString(R.string.location_interpolation_percent_desc)); + } + + private void shouldSearchAndFind(final String searchQuery) { + // Given + clickSearchButton(app); + + // When + onView(searchView()).perform(replaceText(searchQuery), closeSoftKeyboard()); + + // Then + onView(searchResultsView()).check(matches(hasSearchResultWithSubstring(searchQuery))); + } + public static Matcher searchView() { return allOf( withClassName(is("android.widget.SearchView$SearchAutoComplete")), @@ -115,6 +139,7 @@ private void enablePlugin(final OsmandPlugin osmandPlugin) { PluginsHelper.enablePlugin(null, app, osmandPlugin, true); } + // FK-TODO: DRY with getDevelopmentPlugin() private static AccessibilityPlugin getAccessibilityPlugin() { return PluginsHelper .getAvailablePlugins() @@ -124,4 +149,14 @@ private static AccessibilityPlugin getAccessibilityPlugin() { .findFirst() .orElseThrow(); } + + private OsmandDevelopmentPlugin getDevelopmentPlugin() { + return PluginsHelper + .getAvailablePlugins() + .stream() + .filter(osmandPlugin -> osmandPlugin instanceof OsmandDevelopmentPlugin) + .map(osmandPlugin -> (OsmandDevelopmentPlugin) osmandPlugin) + .findFirst() + .orElseThrow(); + } }