首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SwipeRefreshLayout blocks中的Espresso测试

SwipeRefreshLayout blocks中的Espresso测试
EN

Stack Overflow用户
提问于 2017-03-07 22:10:50
回答 1查看 600关注 0票数 1

我有RecyclerView

代码语言:javascript
复制
   <android.support.v4.widget.SwipeRefreshLayout
    android:id="@+id/dashboard_swiperefreshlayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:scrollbars="vertical">

    <android.support.v7.widget.RecyclerView
        android:id="@+id/events_dashboard_listview"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:scrollbars="none"/>

</android.support.v4.widget.SwipeRefreshLayout>

Viewpager在Viewpager中是片段。我使用volley进行带有自定义IdleResurs的服务器调用。

我想打开抽屉:

代码语言:javascript
复制
openDrawer(R.id.drawer_layout);
isOpen();

但测试挂起时出现错误:

代码语言:javascript
复制
Could not launch intent Intent within 45 seconds

如果我手动滚动RecycleView或更改适配器中的可见页面,测试将继续并打开抽屉。

EN

回答 1

Stack Overflow用户

发布于 2017-07-12 18:44:25

可能会显示SwipeRefreshLayout的加载指示符,并且因此阻塞UI,因为它是动画的。避免显示动画的布局的一个快速解决方案是使用如下所示的内容:

代码语言:javascript
复制
class TestableSwipeRefreshLayout : SwipeRefreshLayout {

    constructor(context: Context) : super(context)

    constructor(context: Context, attrs: AttributeSet) : super(context, attrs)

    companion object {

        var isTestRunning = false

    }

    override fun setRefreshing(refreshing: Boolean) {
        if (!isTestRunning) {
            super.setRefreshing(refreshing)
        }
    }

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42650483

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档