Class ShadowView

    • Constructor Detail

      • ShadowView

        public ShadowView()
    • Method Detail

      • clickOn

        @Deprecated
        public static boolean clickOn​(View view)
        Deprecated.
        Please use Espresso for view interactions
        Calls performClick() on a View after ensuring that it and its ancestors are visible and that it is enabled.
        Parameters:
        view - the view to click on
        Returns:
        true if View.OnClickListeners were found and fired, false otherwise.
        Throws:
        RuntimeException - if the preconditions are not met.
      • visualize

        public static String visualize​(View view)
        Returns a textual representation of the appearance of the object.
        Parameters:
        view - the view to visualize
        Returns:
        Textual representation of the appearance of the object.
      • dump

        @Deprecated
        public static void dump​(View view)
        Deprecated.
        - Please use androidx.test.espresso.util.HumanReadables#describe(View)
        Emits an xml-like representation of the view to System.out.
        Parameters:
        view - the view to dump.
      • innerText

        public static String innerText​(View view)
        Returns the text contained within this view.
        Parameters:
        view - the view to scan for text
        Returns:
        Text contained within this view.
      • onLayout

        @Implementation
        protected void onLayout​(boolean changed,
                                int left,
                                int top,
                                int right,
                                int bottom)
      • onLayoutWasCalled

        public boolean onLayoutWasCalled()
      • reset

        @Resetter
        public static void reset()
      • didRequestLayout

        public boolean didRequestLayout()
      • setDidRequestLayout

        public void setDidRequestLayout​(boolean didRequestLayout)
      • setViewFocus

        public void setViewFocus​(boolean hasFocus)
      • getLastTouchEvent

        public MotionEvent getLastTouchEvent()
      • innerText

        public String innerText()
        Returns a string representation of this View. Unless overridden, it will be an empty string.

        Robolectric extension.

        Returns:
        String representation of this view.
      • dump

        @Deprecated
        public void dump()
        Deprecated.
        - Please use androidx.test.espresso.util.HumanReadables#describe(View)
        Dumps the status of this View to System.out
      • dump

        @Deprecated
        public void dump​(PrintStream out,
                         int indent)
        Deprecated.
        - Please use androidx.test.espresso.util.HumanReadables#describe(View)
        Dumps the status of this View to System.out at the given indentation level
        Parameters:
        out - Output stream.
        indent - Indentation level.
      • wasInvalidated

        public boolean wasInvalidated()
        Returns:
        whether or not invalidate() has been called
      • clearWasInvalidated

        public void clearWasInvalidated()
        Clears the wasInvalidated flag
      • checkedPerformClick

        @Deprecated
        public boolean checkedPerformClick()
        Deprecated.
        - Please use Espresso for View interactions.
        Utility method for clicking on views exposing testing scenarios that are not possible when using the actual app.

        If running with LooperMode PAUSED will also idle the main Looper.

        Returns:
        Return value of the underlying click operation.
        Throws:
        RuntimeException - if the view is disabled or if the view or any of its parents are not visible.
      • getOnTouchListener

        public View.OnTouchListener getOnTouchListener()
        Returns:
        Touch listener, if set.
      • getOnClickListener

        public View.OnClickListener getOnClickListener()
        Returns:
        Returns click listener, if set.
      • getOnCreateContextMenuListener

        public View.OnCreateContextMenuListener getOnCreateContextMenuListener()
        Returns:
        Returns create ContextMenu listener, if set.
      • getOnAttachStateChangeListeners

        public Set<View.OnAttachStateChangeListener> getOnAttachStateChangeListeners()
        Returns:
        Returns the attached listeners, or the empty set if none are present.
      • getOnLayoutChangeListeners

        public Set<View.OnLayoutChangeListener> getOnLayoutChangeListeners()
        Returns:
        Returns the layout change listeners, or the empty set if none are present.
      • postInvalidateDelayed

        @Implementation
        protected void postInvalidateDelayed​(long delayMilliseconds)
      • getLocationOnScreen

        @Implementation
        protected void getLocationOnScreen​(int[] outLocation)
      • mapRectFromViewToScreenCoords

        @Implementation(minSdk=26)
        protected void mapRectFromViewToScreenCoords​(RectF rect,
                                                     boolean clipToParent)
      • initialAwakenScrollBars

        @Implementation
        protected boolean initialAwakenScrollBars()
      • callOnAttachedToWindow

        public void callOnAttachedToWindow()
      • callOnDetachedFromWindow

        public void callOnDetachedFromWindow()
      • performHapticFeedback

        @Implementation
        protected boolean performHapticFeedback​(int hapticFeedbackType)
      • setGlobalVisibleRect

        public void setGlobalVisibleRect​(Rect rect)
      • lastHapticFeedbackPerformed

        public int lastHapticFeedbackPerformed()
      • setMyParent

        public void setMyParent​(ViewParent viewParent)
      • getWindowVisibleDisplayFrame

        @Implementation
        protected void getWindowVisibleDisplayFrame​(Rect outRect)
      • getSourceLayoutResId

        @Implementation(minSdk=29)
        public int getSourceLayoutResId()
        Returns the layout resource id this view was inflated from. Backwards compatible version of View.getSourceLayoutResId(), passes through to the underlying implementation on API levels where it is supported.