@Implements(value=android.widget.Toast.class) public class ShadowToast extends java.lang.Object
Constructor and Description |
---|
ShadowToast() |
Modifier and Type | Method and Description |
---|---|
void |
__constructor__(android.content.Context context) |
void |
cancel() |
int |
getDuration() |
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 . |
android.view.View |
getView() |
int |
getXOffset() |
int |
getYOffset() |
boolean |
isCancelled() |
static android.widget.Toast |
makeText(android.content.Context context,
java.lang.CharSequence text,
int duration) |
static android.widget.Toast |
makeText(android.content.Context context,
int resId,
int duration) |
static void |
reset()
Discards the recorded
Toast s. |
void |
setDuration(int duration) |
void |
setGravity(int gravity,
int xOffset,
int yOffset) |
void |
setText(java.lang.CharSequence text) |
void |
setText(int resId) |
void |
setView(android.view.View view) |
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 public void __constructor__(android.content.Context context)
@Implementation public static android.widget.Toast makeText(android.content.Context context, int resId, int duration)
@Implementation public static android.widget.Toast makeText(android.content.Context context, java.lang.CharSequence text, int duration)
@Implementation public void show()
@Implementation public void setText(int resId)
@Implementation public void setText(java.lang.CharSequence text)
@Implementation public void setView(android.view.View view)
@Implementation public android.view.View getView()
@Implementation public void setGravity(int gravity, int xOffset, int yOffset)
@Implementation public int getGravity()
@Implementation public int getXOffset()
@Implementation public int getYOffset()
@Implementation public void setDuration(int duration)
@Implementation public int getDuration()
@Implementation public 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