Testing Snackbar show with Espresso

前端 未结 3 1566
陌清茗
陌清茗 2021-02-05 00:28

Is there a way to test using Espresso that the snackbar shows up with the right text?

I have a simple call to create a snackbar

Snackbar.make(mView, \"My         


        
3条回答
  •  独厮守ぢ
    2021-02-05 01:19

    An alternative

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

提交回复
热议问题