@Implements(android.widget.Toast.class) public class ShadowToast extends Object
Constructor | Description |
---|---|
ShadowToast() |
Modifier and Type | Method | Description |
---|---|---|
protected void |
__constructor__(Context context) |
|
protected void |
cancel() |
|
protected int |
getDuration() |
|
protected int |
getGravity() |
|
static Toast |
getLatestToast() |
Returns the most recently shown
Toast . |
static String |
getTextOfLatestToast() |
Returns the text of the most recently shown
Toast . |
protected View |
getView() |
|
protected int |
getXOffset() |
|
protected int |
getYOffset() |
|
boolean |
isCancelled() |
|
protected static Toast |
makeText(Context context,
int resId,
int duration) |
|
protected static Toast |
makeText(Context context,
CharSequence text,
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(int resId) |
|
protected void |
setText(CharSequence text) |
|
protected void |
setView(View view) |
|
protected void |
show() |
|
static boolean |
showedCustomToast(CharSequence message,
int layoutResourceIdToCheckForMessage) |
Returns whether or not a particular custom
Toast has been shown. |
static boolean |
showedToast(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__(Context context)
@Implementation protected static Toast makeText(Context context, int resId, int duration)
@Implementation protected static Toast makeText(Context context, CharSequence text, int duration)
@Implementation protected void show()
@Implementation protected void setText(int resId)
@Implementation protected void setText(CharSequence text)
@Implementation protected void setView(View view)
@Implementation protected 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()
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()
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(CharSequence message, int layoutResourceIdToCheckForMessage)
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(CharSequence message)
Toast
has been shown.message
- the message to search forToast
was requestedpublic static String getTextOfLatestToast()
Toast
.Toast
public static Toast getLatestToast()
Toast
.Toast