Java Code Examples for org.robolectric.shadows.ShadowToast#getLatestToast()
The following examples show how to use
org.robolectric.shadows.ShadowToast#getLatestToast() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestActivityTest.java From Awesome-WanAndroid with Apache License 2.0 | 6 votes |
@Test public void showToast() { Toast latestToast = ShadowToast.getLatestToast(); Assert.assertNull(latestToast); Button button = (Button) mTestActivity.findViewById(R.id.button2); button.performClick(); latestToast = ShadowToast.getLatestToast(); Assert.assertNotNull(latestToast); ShadowToast shadowToast = Shadows.shadowOf(latestToast); ShadowLog.d("toast_time", shadowToast.getDuration() + ""); Assert.assertEquals(Toast.LENGTH_SHORT, shadowToast.getDuration()); Assert.assertEquals("hahaha", ShadowToast.getTextOfLatestToast()); }
Example 2
Source File: ToastFrameworkImplTest.java From Taskbar with Apache License 2.0 | 5 votes |
@Test public void testShow() { impl.show(); assertEquals(message, ShadowToast.getTextOfLatestToast()); Toast toast = ShadowToast.getLatestToast(); assertEquals(length, toast.getDuration()); assertEquals(Gravity.BOTTOM | Gravity.CENTER_VERTICAL, toast.getGravity()); assertEquals(0, toast.getXOffset()); assertEquals( context.getResources().getDimensionPixelSize(R.dimen.tb_toast_y_offset), toast.getYOffset() ); }
Example 3
Source File: UTest.java From Taskbar with Apache License 2.0 | 5 votes |
@Test public void testShowToast() { U.showToast(context, R.string.tb_pin_shortcut_not_supported); Toast toast = ShadowToast.getLatestToast(); assertEquals(Toast.LENGTH_SHORT, toast.getDuration()); assertEquals( context.getResources().getString(R.string.tb_pin_shortcut_not_supported), ShadowToast.getTextOfLatestToast() ); }
Example 4
Source File: UTest.java From Taskbar with Apache License 2.0 | 5 votes |
@Test public void testShowLongToast() { U.showToastLong(context, R.string.tb_pin_shortcut_not_supported); Toast toast = ShadowToast.getLatestToast(); assertEquals(Toast.LENGTH_LONG, toast.getDuration()); assertEquals( context.getResources().getString(R.string.tb_pin_shortcut_not_supported), ShadowToast.getTextOfLatestToast() ); }