@Override public final void check(View view, NoMatchingViewException e) { RecyclerView recyclerView = (RecyclerView) view; RecyclerView.ViewHolder viewHolderForPosition = recyclerView.findViewHolderForLayoutPosition(position); if (viewHolderForPosition == null) { throw (new PerformException.Builder()).withActionDescription(toString()) .withViewDescription(HumanReadables.describe(view)) .withCause(new IllegalStateException("No view holder at position: " + position)) .build(); } else { View viewAtPosition = viewHolderForPosition.itemView; itemViewAssertion.check(item, viewAtPosition, e); } } }
@Override public void perform(UiController uiController, View view) { if (isDisplayingAtLeast(90).matches(view)) { LogUtils.LOGI(TAG, "View is already displayed. Returning."); return; } Rect rect = new Rect(); view.getDrawingRect(rect); if (!view.requestRectangleOnScreen(rect, true /* immediate */)) { LogUtils.LOGW(TAG, "Scrolling to view was requested, but none of the parents scrolled."); } uiController.loopMainThreadUntilIdle(); if (!isDisplayingAtLeast(90).matches(view)) { throw new PerformException.Builder() .withActionDescription(this.getDescription()) .withViewDescription(HumanReadables.describe(view)) .withCause(new RuntimeException( "Scrolling to view was attempted, but the view is not displayed")) .build(); } } }
@Override public void perform(UiController uiController, View view) { if (isDisplayingAtLeast(90).matches(view)) { Log.i(TAG, "View is already displayed. Returning."); return; } Rect rect = new Rect(); view.getDrawingRect(rect); if (!view.requestRectangleOnScreen(rect, true /* immediate */)) { Log.w(TAG, "Scrolling to view was requested, but none of the parents scrolled."); } uiController.loopMainThreadUntilIdle(); if (!isDisplayingAtLeast(90).matches(view)) { throw new PerformException.Builder() .withActionDescription(this.getDescription()) .withViewDescription(HumanReadables.describe(view)) .withCause(new RuntimeException( "Scrolling to view was attempted, but the view is not displayed")) .build(); } }
@Override public void perform(UiController uiController, View view) { uiController.loopMainThreadUntilIdle(); final long endTime = System.currentTimeMillis() + millis; do { for (View child : TreeIterables.breadthFirstViewTraversal(view)) { if (child.getId() == viewId) { if (checkStatus.check(child)) { return; } } } uiController.loopMainThreadForAtLeast(50); } while (System.currentTimeMillis() < endTime); throw new PerformException.Builder() .withActionDescription(this.getDescription()) .withViewDescription(HumanReadables.describe(view)) .withCause(new TimeoutException()) .build(); } };