Skip to content

Commit

Permalink
refining SettingsSearchTest
Browse files Browse the repository at this point in the history
  • Loading branch information
KnollFrank committed Dec 18, 2024
1 parent be2ff2c commit cb5d9af
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ public static Iterable<Object[]> 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)}
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<View> searchView() {
return allOf(
withClassName(is("android.widget.SearchView$SearchAutoComplete")),
Expand Down Expand Up @@ -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()
Expand All @@ -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();
}
}

0 comments on commit cb5d9af

Please sign in to comment.