Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
alexacm2
architecture-components-samples
提交
211259c4
A
architecture-components-samples
项目概览
alexacm2
/
architecture-components-samples
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
architecture-components-samples
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
211259c4
编写于
2月 23, 2021
作者:
D
Dustin Lam
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use Espresso to wait for idle UI
上级
07714e6d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
9 deletion
+23
-9
PagingSample/app/build.gradle
PagingSample/app/build.gradle
+1
-0
PagingSample/app/src/androidTest/java/paging/android/example/com/pagingsample/MainActivityTest.kt
...ging/android/example/com/pagingsample/MainActivityTest.kt
+10
-4
PagingWithNetworkSample/app/build.gradle
PagingWithNetworkSample/app/build.gradle
+1
-0
PagingWithNetworkSample/app/src/androidTest/java/com/android/example/paging/pagingwithnetwork/reddit/ui/RedditActivityTest.kt
.../paging/pagingwithnetwork/reddit/ui/RedditActivityTest.kt
+11
-5
未找到文件。
PagingSample/app/build.gradle
浏览文件 @
211259c4
...
...
@@ -75,4 +75,5 @@ dependencies {
androidTestImplementation
deps
.
atsl
.
runner
androidTestImplementation
deps
.
coroutines
.
test
androidTestImplementation
deps
.
truth
androidTestImplementation
deps
.
espresso
.
contrib
}
PagingSample/app/src/androidTest/java/paging/android/example/com/pagingsample/MainActivityTest.kt
浏览文件 @
211259c4
...
...
@@ -20,6 +20,8 @@ import androidx.annotation.UiThread
import
androidx.recyclerview.widget.RecyclerView
import
androidx.test.core.app.ActivityScenario
import
androidx.test.core.app.ApplicationProvider
import
androidx.test.espresso.Espresso.onView
import
androidx.test.espresso.matcher.ViewMatchers.withId
import
androidx.test.ext.junit.runners.AndroidJUnit4
import
com.google.common.truth.Truth.assertThat
import
org.junit.Test
...
...
@@ -36,11 +38,15 @@ class MainActivityTest {
fun
showSomeResults
()
{
val
intent
=
Intent
(
ApplicationProvider
.
getApplicationContext
(),
MainActivity
::
class
.
java
)
intent
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
)
val
scenario
=
ActivityScenario
.
launch
<
MainActivity
>(
intent
)
scenario
.
onActivity
{
activity
->
val
recyclerView
:
RecyclerView
=
activity
.
binding
.
cheeseList
ActivityScenario
.
launch
<
MainActivity
>(
intent
)
onView
(
withId
(
R
.
id
.
cheeseList
)).
check
{
view
,
noViewFoundException
->
if
(
noViewFoundException
!=
null
)
{
throw
noViewFoundException
}
val
recyclerView
=
view
as
RecyclerView
assertThat
(
recyclerView
.
adapter
).
isNotNull
()
assertThat
(
recyclerView
.
adapter
!!
.
itemCount
).
isGreaterThan
(
0
)
}
}
}
\ No newline at end of file
}
PagingWithNetworkSample/app/build.gradle
浏览文件 @
211259c4
...
...
@@ -87,6 +87,7 @@ dependencies {
androidTestImplementation
deps
.
atsl
.
runner
androidTestImplementation
deps
.
atsl
.
rules
androidTestImplementation
deps
.
arch_core
.
testing
androidTestImplementation
deps
.
espresso
.
contrib
testImplementation
deps
.
junit
testImplementation
deps
.
coroutines
.
test
...
...
PagingWithNetworkSample/app/src/androidTest/java/com/android/example/paging/pagingwithnetwork/reddit/ui/RedditActivityTest.kt
浏览文件 @
211259c4
...
...
@@ -18,9 +18,12 @@ package com.android.example.paging.pagingwithnetwork.reddit.ui
import
android.app.Application
import
android.content.Intent
import
androidx.
test.annotation.UiThreadTest
import
androidx.
recyclerview.widget.RecyclerView
import
androidx.test.core.app.ActivityScenario
import
androidx.test.core.app.ApplicationProvider
import
androidx.test.espresso.Espresso.onView
import
androidx.test.espresso.matcher.ViewMatchers.withId
import
com.android.example.paging.pagingwithnetwork.R
import
com.android.example.paging.pagingwithnetwork.reddit.DefaultServiceLocator
import
com.android.example.paging.pagingwithnetwork.reddit.ServiceLocator
import
com.android.example.paging.pagingwithnetwork.reddit.api.RedditApi
...
...
@@ -65,9 +68,8 @@ class RedditActivityTest(private val type: RedditPostRepository.Type) {
}
@Test
@UiThreadTest
fun
showSomeResults
()
{
val
scenario
=
ActivityScenario
.
launch
<
RedditActivity
>(
ActivityScenario
.
launch
<
RedditActivity
>(
RedditActivity
.
intentFor
(
context
=
ApplicationProvider
.
getApplicationContext
(),
type
=
type
...
...
@@ -76,8 +78,12 @@ class RedditActivityTest(private val type: RedditPostRepository.Type) {
}
)
scenario
.
onActivity
{
activity
->
val
recyclerView
=
activity
.
binding
.
list
onView
(
withId
(
R
.
id
.
list
)).
check
{
view
,
noViewFoundException
->
if
(
noViewFoundException
!=
null
)
{
throw
noViewFoundException
}
val
recyclerView
=
view
as
RecyclerView
assertEquals
(
3
,
recyclerView
.
adapter
?.
itemCount
)
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录