用Espressotesting小吃店展示

有没有一种方法可以使用Espresso进行testing,快餐栏显示正确的文字?

我有一个简单的电话来创build一个小吃店

Snackbar.make(mView, "My text", Snackbar.LENGTH_LONG).show(); 

我已经尝试过,没有运气

 onView(withText("My text")).inRoot(withDecorView(not(is(mActivityRule.getActivity().getWindow().getDecorView())))).check(matches(isDisplayed())); 

Solutions Collecting From Web of "用Espressotesting小吃店展示"

这对我来说,请尝试。

 onView(allOf(withId(android.support.design.R.id.snackbar_text), withText("My text"))) .check(matches(isDisplayed())); 

替代

 private void checkSnackBarDisplayedByMessage( @StringRes int message) { onView(withText(message)) .check(matches(withEffectiveVisibility( ViewMatchers.Visibility.VISIBLE ))); }