Java Code Examples for androidx.test.espresso.matcher.ViewMatchers#isAssignableFrom()
The following examples show how to use
androidx.test.espresso.matcher.ViewMatchers#isAssignableFrom() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TabLayoutActions.java From material-components-android with Apache License 2.0 | 6 votes |
/** * Calls <code>setScrollPosition(position, positionOffset, true)</code> on the <code>TabLayout * </code> */ public static ViewAction setScrollPosition(final int position, final float positionOffset) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return ViewMatchers.isAssignableFrom(TabLayout.class); } @Override public String getDescription() { return "setScrollPosition(" + position + ", " + positionOffset + ", true)"; } @Override public void perform(UiController uiController, View view) { TabLayout tabs = (TabLayout) view; tabs.setScrollPosition(position, positionOffset, true); uiController.loopMainThreadUntilIdle(); } }; }
Example 2
Source File: TextInputLayoutActions.java From material-components-android with Apache License 2.0 | 6 votes |
/** Sets the transformation method. */ public static ViewAction setTransformationMethod( final TransformationMethod transformationMethod) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return ViewMatchers.isAssignableFrom(TextInputLayout.class); } @Override public String getDescription() { return "Sets the transformation method"; } @Override public void perform(UiController uiController, View view) { TextInputLayout item = (TextInputLayout) view; item.getEditText().setTransformationMethod(transformationMethod); } }; }
Example 3
Source File: TextInputLayoutActions.java From material-components-android with Apache License 2.0 | 6 votes |
/** Clicks end or start icon. */ public static ViewAction clickIcon(final boolean isEndIcon) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return ViewMatchers.isAssignableFrom(TextInputLayout.class); } @Override public String getDescription() { return "Clicks the end or start icon"; } @Override public void perform(UiController uiController, View view) { TextInputLayout item = (TextInputLayout) view; // Reach in and find the icon view since we don't have a public API to get a reference to it CheckableImageButton iconView = item.findViewById(isEndIcon ? R.id.text_input_end_icon : R.id.text_input_start_icon); iconView.performClick(); } }; }
Example 4
Source File: TextInputLayoutActions.java From material-components-android with Apache License 2.0 | 6 votes |
/** Long clicks end or start icon. */ public static ViewAction longClickIcon(final boolean isEndIcon) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return ViewMatchers.isAssignableFrom(TextInputLayout.class); } @Override public String getDescription() { return "Long clicks the end or start icon"; } @Override public void perform(UiController uiController, View view) { TextInputLayout item = (TextInputLayout) view; // Reach in and find the icon view since we don't have a public API to get a reference to it CheckableImageButton iconView = item.findViewById(isEndIcon ? R.id.text_input_end_icon : R.id.text_input_start_icon); iconView.performLongClick(); } }; }
Example 5
Source File: TextInputLayoutActions.java From material-components-android with Apache License 2.0 | 6 votes |
/** Skips any animations on the layout. */ public static ViewAction skipAnimations() { return new ViewAction() { @Override public Matcher<View> getConstraints() { return ViewMatchers.isAssignableFrom(TextInputLayout.class); } @Override public String getDescription() { return "Skips any animations."; } @Override public void perform(UiController uiController, View view) { view.jumpDrawablesToCurrentState(); } }; }
Example 6
Source File: TextInputLayoutActions.java From material-components-android with Apache License 2.0 | 6 votes |
/** Sets prefix. */ public static ViewAction setPrefixText(final CharSequence prefixText) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return ViewMatchers.isAssignableFrom(TextInputLayout.class); } @Override public String getDescription() { return "Sets prefix text."; } @Override public void perform(UiController uiController, View view) { TextInputLayout layout = (TextInputLayout) view; layout.setPrefixText(prefixText); } }; }
Example 7
Source File: TextInputLayoutActions.java From material-components-android with Apache License 2.0 | 6 votes |
/** Sets suffix. */ public static ViewAction setSuffixText(final CharSequence suffixText) { return new ViewAction() { @Override public Matcher<View> getConstraints() { return ViewMatchers.isAssignableFrom(TextInputLayout.class); } @Override public String getDescription() { return "Sets suffix text."; } @Override public void perform(UiController uiController, View view) { TextInputLayout layout = (TextInputLayout) view; layout.setSuffixText(suffixText); } }; }
Example 8
Source File: BottomSheetBehaviorTest.java From material-components-android with Apache License 2.0 | 4 votes |
@Override public Matcher<View> getConstraints() { return ViewMatchers.isAssignableFrom(ViewGroup.class); }
Example 9
Source File: ViewFinderImpl.java From android-test with Apache License 2.0 | 4 votes |
@Override public View getView() throws AmbiguousViewMatcherException, NoMatchingViewException { checkMainThread(); final Predicate<View> matcherPredicate = new MatcherPredicateAdapter<View>(checkNotNull(viewMatcher)); View root = rootViewProvider.get(); Iterator<View> matchedViewIterator = Iterables.filter(breadthFirstViewTraversal(root), matcherPredicate).iterator(); View matchedView = null; while (matchedViewIterator.hasNext()) { if (matchedView != null) { // Ambiguous! throw new AmbiguousViewMatcherException.Builder() .withViewMatcher(viewMatcher) .withRootView(root) .withView1(matchedView) .withView2(matchedViewIterator.next()) .withOtherAmbiguousViews(Iterators.toArray(matchedViewIterator, View.class)) .build(); } else { matchedView = matchedViewIterator.next(); } } if (null == matchedView) { final Predicate<View> adapterViewPredicate = new MatcherPredicateAdapter<View>(ViewMatchers.isAssignableFrom(AdapterView.class)); List<View> adapterViews = Lists.newArrayList( Iterables.filter(breadthFirstViewTraversal(root), adapterViewPredicate).iterator()); if (adapterViews.isEmpty()) { throw new NoMatchingViewException.Builder() .withViewMatcher(viewMatcher) .withRootView(root) .build(); } String warning = String.format( Locale.ROOT, "\n" + "If the target view is not part of the view hierarchy, you may need to use" + " Espresso.onData to load it from one of the following AdapterViews:%s", Joiner.on("\n- ").join(adapterViews)); throw new NoMatchingViewException.Builder() .withViewMatcher(viewMatcher) .withRootView(root) .withAdapterViews(adapterViews) .withAdapterViewWarning(EspressoOptional.of(warning)) .build(); } else { return matchedView; } }
Example 10
Source File: SetThumbValueAction.java From MultiSlider with Apache License 2.0 | 4 votes |
@Override public Matcher<View> getConstraints() { return ViewMatchers.isAssignableFrom(MultiSlider.class); }