@Implements(value=android.widget.Toast.class) public class ShadowToast extends java.lang.Object
Constructor and Description |
---|
ShadowToast() |
Modifier and Type | Method and Description |
---|---|
protected void |
__constructor__(android.content.Context context) |
protected void |
cancel() |
protected int |
getDuration() |
protected int |
getGravity() |
static android.widget.Toast |
getLatestToast()
Returns the most recently shown
Toast . |
static java.lang.String |
getTextOfLatestToast()
Returns the text of the most recently shown
Toast . |
protected android.view.View |
getView() |
protected int |
getXOffset() |
protected int |
getYOffset() |
boolean |
isCancelled() |
protected static android.widget.Toast |
makeText(android.content.Context context,
java.lang.CharSequence text,
int duration) |
protected static android.widget.Toast |
makeText(android.content.Context context,
int resId,
int duration) |
static void |
reset()
Discards the recorded
Toast s. |
protected void |
setDuration(int duration) |
protected void |
setGravity(int gravity,
int xOffset,
int yOffset) |
protected void |
setText(java.lang.CharSequence text) |
protected void |
setText(int resId) |
protected void |
setView(android.view.View view) |
protected void |
show() |
static boolean |
showedCustomToast(java.lang.CharSequence message,
int layoutResourceIdToCheckForMessage)
Returns whether or not a particular custom
Toast has been shown. |
static boolean |
showedToast(java.lang.CharSequence message)
query method that returns whether or not a particular
Toast has been shown. |
static int |
shownToastCount()
Returns the number of
Toast requests that have been made during this test run or since reset() has been called. |
@Implementation protected void __constructor__(android.content.Context context)
@Implementation protected static android.widget.Toast makeText(android.content.Context context, int resId, int duration)
@Implementation protected static android.widget.Toast makeText(android.content.Context context, java.lang.CharSequence text, int duration)
@Implementation protected void show()
@Implementation protected void setText(int resId)
@Implementation protected void setText(java.lang.CharSequence text)
@Implementation protected void setView(android.view.View view)
@Implementation protected android.view.View getView()
@Implementation protected void setGravity(int gravity, int xOffset, int yOffset)
@Implementation protected int getGravity()
@Implementation protected int getXOffset()
@Implementation protected int getYOffset()
@Implementation protected void setDuration(int duration)
@Implementation protected int getDuration()
@Implementation protected void cancel()
public boolean isCancelled()
public static void reset()
Discards the recorded Toast
s. Shown toasts are automatically cleared between tests. This method allows the user to discard recorded toasts during the test in order to make assertions clearer e.g:
// Show a single toast myClass.showToast(); assertThat(ShadowToast.shownToastCount()).isEqualTo(1); ShadowToast.reset(); // Show another toast myClass.showToast(); assertThat(ShadowToast.shownToastCount()).isEqualTo(1);
public static int shownToastCount()
Returns the number of Toast
requests that have been made during this test run or since reset()
has been called.
Toast
requests that have been made during this test run or since reset()
has been called.public static boolean showedCustomToast(java.lang.CharSequence message, int layoutResourceIdToCheckForMessage)
Returns whether or not a particular custom Toast
has been shown.
message
- the message to search forlayoutResourceIdToCheckForMessage
- the id of the resource that contains the toast messagesToast
was requestedpublic static boolean showedToast(java.lang.CharSequence message)
query method that returns whether or not a particular Toast
has been shown.
message
- the message to search forToast
was requestedpublic static java.lang.String getTextOfLatestToast()
Returns the text of the most recently shown Toast
.
Toast
public static android.widget.Toast getLatestToast()
Returns the most recently shown Toast
.
Toast