Package org.robolectric.shadows
Class ShadowView
java.lang.Object
org.robolectric.shadows.ShadowView
- Direct Known Subclasses:
ShadowSeekBar,ShadowSurfaceView,ShadowTextView,ShadowViewGroup
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AttributeSetprotected Viewprotected org.robolectric.shadows.ShadowView._View_ -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void__constructor__(Context context, AttributeSet attributeSet, int defStyleAttr, int defStyleRes) static voidRegisters anView.OnClickListenerto theShadowView.static voidRegisters anView.OnLongClickListenerto theShadowView.protected voidaddOnAttachStateChangeListener(View.OnAttachStateChangeListener onAttachStateChangeListener) protected voidaddOnLayoutChangeListener(View.OnLayoutChangeListener onLayoutChangeListener) voidvoidbooleanDeprecated.- Please use Espresso for View interactions.protected voidvoidResets the list returned bygetAnimations()to an empty list.voidClears the wasInvalidated flagstatic booleanDeprecated.Please use Espresso for view interactionsbooleanprotected voidvoiddump()Deprecated.- Please useandroidx.test.espresso.util.HumanReadables#describe(View)static voidDeprecated.- Please useandroidx.test.espresso.util.HumanReadables#describe(View)voiddump(PrintStream out, int indent) Deprecated.- Please useandroidx.test.espresso.util.HumanReadables#describe(View)protected voiddumpAttribute(PrintStream out, String name, String value) Deprecated.protected voidDeprecated.protected voiddumpFirstPart(PrintStream out, int indent) Deprecated.protected voiddumpIndent(PrintStream out, int indent) Deprecated.com.google.common.collect.ImmutableList<Animation>Returns a list of all animations that have been set on this view.protected booleangetGlobalVisibleRect(Rect rect, Point globalOffset) protected intprotected voidgetLocationOnScreen(int[] outLocation) protected intprotected intintReturns the layout resource id this view was inflated from.protected voidgetWindowDisplayFrame(Rect outRect) protected WindowIdprotected voidgetWindowVisibleDisplayFrame(Rect outRect) protected booleanReturns a string representation of thisView.static StringReturns the text contained within this view.protected voidprotected booleanintprotected voidmapRectFromViewToScreenCoords(RectF rect, boolean clipToParent) protected voidonLayout(boolean changed, int left, int top, int right, int bottom) booleanprotected booleanonTouchEvent(MotionEvent event) protected booleanprotected booleanperformHapticFeedback(int hapticFeedbackType) protected booleanprotected booleanprotected booleanpostDelayed(Runnable action, long delayMills) protected voidpostInvalidateDelayed(long delayMilliseconds) protected booleanremoveCallbacks(Runnable callback) static voidRemoves anView.OnClickListenerfrom theShadowView.static voidRemoves anView.OnLongClickListenerfrom theShadowView.protected voidremoveOnAttachStateChangeListener(View.OnAttachStateChangeListener onAttachStateChangeListener) protected voidremoveOnLayoutChangeListener(View.OnLayoutChangeListener onLayoutChangeListener) protected voidstatic voidreset()protected voidscrollBy(int x, int y) protected voidscrollTo(int x, int y) protected voidsetAnimation(Animation animation) voidsetDidRequestLayout(boolean didRequestLayout) voidsetGlobalVisibleRect(Rect rect) protected voidsetLayerType(int layerType, Paint paint) voidsetMyParent(ViewParent viewParent) protected voidsetOnClickListener(View.OnClickListener onClickListener) protected voidsetOnCreateContextMenuListener(View.OnCreateContextMenuListener onCreateContextMenuListener) protected voidprotected voidsetOnLongClickListener(View.OnLongClickListener onLongClickListener) protected voidsetOnSystemUiVisibilityChangeListener(View.OnSystemUiVisibilityChangeListener onSystemUiVisibilityChangeListener) protected voidsetOnTouchListener(View.OnTouchListener onTouchListener) protected voidsetScrollX(int scrollX) protected voidsetScrollY(int scrollY) voidsetViewFocus(boolean hasFocus) static booleanInternal API to determine if native graphics is enabled.static StringReturns a textual representation of the appearance of the object.boolean
-
Field Details
-
realView
-
viewReflector
-
attributeSet
-
scrollToCoordinates
-
-
Constructor Details
-
ShadowView
public ShadowView()
-
-
Method Details
-
clickOn
Deprecated.Please use Espresso for view interactionsCallsperformClick()on aViewafter 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
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.- Please useandroidx.test.espresso.util.HumanReadables#describe(View)Emits an xml-like representation of the view to System.out.- Parameters:
view- the view to dump.
-
innerText
Returns the text contained within this view.- Parameters:
view- the view to scan for text- Returns:
- Text contained within this view.
-
__constructor__
@Implementation(maxSdk=30) protected void __constructor__(Context context, AttributeSet attributeSet, int defStyleAttr, int defStyleRes) -
setLayerType
-
setOnFocusChangeListener
-
setOnClickListener
-
setOnLongClickListener
-
setOnSystemUiVisibilityChangeListener
@Implementation protected void setOnSystemUiVisibilityChangeListener(View.OnSystemUiVisibilityChangeListener onSystemUiVisibilityChangeListener) -
setOnCreateContextMenuListener
@Implementation protected void setOnCreateContextMenuListener(View.OnCreateContextMenuListener onCreateContextMenuListener) -
addOnAttachStateChangeListener
@Implementation protected void addOnAttachStateChangeListener(View.OnAttachStateChangeListener onAttachStateChangeListener) -
removeOnAttachStateChangeListener
@Implementation protected void removeOnAttachStateChangeListener(View.OnAttachStateChangeListener onAttachStateChangeListener) -
addOnLayoutChangeListener
@Implementation protected void addOnLayoutChangeListener(View.OnLayoutChangeListener onLayoutChangeListener) -
removeOnLayoutChangeListener
@Implementation protected void removeOnLayoutChangeListener(View.OnLayoutChangeListener onLayoutChangeListener) -
draw
-
onLayout
-
onLayoutWasCalled
public boolean onLayoutWasCalled() -
requestLayout
-
performClick
-
addGlobalPerformClickListener
Registers anView.OnClickListenerto theShadowView.- Parameters:
listener- TheView.OnClickListenerto be registered.
-
removeGlobalPerformClickListener
Removes anView.OnClickListenerfrom theShadowView.- Parameters:
listener- TheView.OnClickListenerto be removed.
-
performLongClick
-
addGlobalPerformLongClickListener
Registers anView.OnLongClickListenerto theShadowView.- Parameters:
listener- TheView.OnLongClickListenerto be registered.
-
removeGlobalPerformLongClickListener
Removes anView.OnLongClickListenerfrom theShadowView.- Parameters:
listener- TheView.OnLongClickListenerto be removed.
-
reset
-
didRequestLayout
public boolean didRequestLayout() -
setDidRequestLayout
public void setDidRequestLayout(boolean didRequestLayout) -
setViewFocus
public void setViewFocus(boolean hasFocus) -
invalidate
-
onTouchEvent
-
setOnTouchListener
-
getLastTouchEvent
-
innerText
Returns a string representation of thisView. Unless overridden, it will be an empty string.Robolectric extension.
- Returns:
- String representation of this view.
-
dump
Deprecated.- Please useandroidx.test.espresso.util.HumanReadables#describe(View)Dumps the status of thisViewtoSystem.out -
dump
Deprecated.- Please useandroidx.test.espresso.util.HumanReadables#describe(View)Dumps the status of thisViewtoSystem.outat the given indentation level- Parameters:
out- Output stream.indent- Indentation level.
-
dumpFirstPart
Deprecated. -
dumpAttributes
Deprecated. -
dumpAttribute
Deprecated. -
dumpIndent
Deprecated. -
wasInvalidated
public boolean wasInvalidated()- Returns:
- whether or not
invalidate()has been called
-
clearWasInvalidated
public void clearWasInvalidated()Clears the wasInvalidated flag -
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
- Returns:
- Touch listener, if set.
-
getOnClickListener
- Returns:
- Returns click listener, if set.
-
getOnLongClickListener
- Returns:
- Returns long click listener, if set.
-
getOnSystemUiVisibilityChangeListener
- Returns:
- Returns system ui visibility change listener.
-
getOnCreateContextMenuListener
- Returns:
- Returns create ContextMenu listener, if set.
-
getOnAttachStateChangeListeners
- Returns:
- Returns the attached listeners, or the empty set if none are present.
-
getOnLayoutChangeListeners
- Returns:
- Returns the layout change listeners, or the empty set if none are present.
-
post
-
postDelayed
-
postInvalidateDelayed
-
removeCallbacks
-
scrollTo
-
scrollBy
-
getScrollX
-
getScrollY
-
setScrollX
-
setScrollY
-
getLocationOnScreen
-
mapRectFromViewToScreenCoords
@Implementation(minSdk=26) protected void mapRectFromViewToScreenCoords(RectF rect, boolean clipToParent) -
getLayerType
-
getAnimations
Returns a list of all animations that have been set on this view. -
clearAnimations
public void clearAnimations()Resets the list returned bygetAnimations()to an empty list. -
setAnimation
-
clearAnimation
-
initialAwakenScrollBars
-
isAttachedToWindow
-
callOnAttachedToWindow
public void callOnAttachedToWindow() -
callOnDetachedFromWindow
public void callOnDetachedFromWindow() -
getWindowId
-
performHapticFeedback
-
getGlobalVisibleRect
-
setGlobalVisibleRect
-
lastHapticFeedbackPerformed
public int lastHapticFeedbackPerformed() -
setMyParent
-
getWindowVisibleDisplayFrame
-
getWindowDisplayFrame
-
getSourceLayoutResId
Returns the layout resource id this view was inflated from. Backwards compatible version ofView.getSourceLayoutResId(), passes through to the underlying implementation on API levels where it is supported. -
useRealGraphics
@Beta public static boolean useRealGraphics()Internal API to determine if native graphics is enabled.This is currently public because it has to be accessed from multiple packages, but it is not recommended to depend on this API.
-