Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Espresso Idling Resource
Takuji Nishibayashi
August 29, 2017
Technology
0
130
Espresso Idling Resource
Takuji Nishibayashi
August 29, 2017
Tweet
Share
More Decks by Takuji Nishibayashi
See All by Takuji Nishibayashi
kotlinx.serialization
takuji31
0
260
kanmoba-returns-02.pdf
takuji31
0
76
AndroidXとKotlin Coroutines
takuji31
0
150
AndroidXに潜む便利なヤツら
takuji31
0
57
Kotlin Inline Class
takuji31
0
43
No more Adapter with Epoxy and Data Binding
takuji31
0
560
クロスプラットフォーム開発3種の神器 React Native / TypeScript / GraphQL
takuji31
7
5.5k
KanmobaInKanto
takuji31
1
73
Kotlinの言語機能をフル活用したAndroidアプリの開発
takuji31
6
7.6k
Other Decks in Technology
See All in Technology
Dangerous attack paths: Modern Development Environment Security - Devices and CI/CD pipelines
rung
PRO
0
140
脆弱性スキャナのOWASP ZAPを コードベースで扱ってみる / OWASP ZAP on a code base
task4233
1
250
年700万円損するサーバレスの 認可システムをご紹介します!!
higuuu
3
340
Learning to Solve Hard Minimal Problems
takmin
1
470
EKS AnywhereとIAM Anywhereを組み合わせてみた
regmarmcem
0
380
私のAWS愛を聞け! ~ここが好きだよStep Functions~ #devio2022
kongmingstrap
0
290
Continuous Architecture Design for Modernization
humank
2
490
cobra は便利になっている
nwiizo
0
140
DMMプラットフォーム ゼロから始めるKubernetes運用 課題と改善
pospome
0
410
PMMやプロダクト関係者と協働するために役割を整理した話 / 20220810_pdmtipslt
rakus_dev
0
120
Simplify Cloud Native Security with Trivy
knqyf263
0
690
Microsoft Data Analytics trends : ”Lakehouse” , ”Data Mesh"
ryomaru0825
2
130
Featured
See All Featured
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
119
28k
Code Review Best Practice
trishagee
44
9.7k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
316
19k
The Cult of Friendly URLs
andyhume
68
4.8k
Web Components: a chance to create the future
zenorocha
303
40k
Designing for humans not robots
tammielis
242
24k
Gamification - CAS2011
davidbonilla
75
3.9k
The Language of Interfaces
destraynor
148
21k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
236
1.1M
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
6
570
Bash Introduction
62gerente
598
210k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
498
130k
Transcript
Espresso Idling Resource ☕ @takuji31
@takuji31 (Takuji Nishibayashi) Applica7on Engineer at Hatena
Loves • ! (AVG 175) • " # • h,p:/
/photo.takuji31.jp • $ • h,p:/ /nazuna.takuji31.jp • Android • Kotlin
AGENDA • UIςετΛॻ࣌͘ͷΈ • ղܾํ๏ • Espresso Idling Resource •
ϋϚΓͲ͜Ζ
UIςετΛॻ࣌͘ͷΈ
ඇಉظͷςετ
ςετ͕ՄೳʹͳΔ·Ͱͭ
ࡶͳղܾํ๏
Thread.sleep(1000)
ωοτϫʔΫ͕͍
ͨ·ʹίέΔ !
Jenkins͕ॏ͍
ͨ·ʹίέΔ !
ͪΐͬͱݡ͍ํ๏
खͰؤுΔ
RxJava
Թ͔Έͷ͋Δख࣮
ෳίϯϙʔωϯτΛͭͷ͕େม Ac#vity + ViewModelͱ͔
ຊ࣭తͰͳ͍ͱ͜Ζʹίετ͕͔͔ Γ͗͢Δ
ઈରΓͨ͘ͳ͍ !
Espresso Idling Resource
Espresso plugin?
ΞΠυϦϯάͷΈΛఏڙ
IdlingResource
Ϧιʔε
IdlingRegistry
ΞΠυϦϯάΛࢹ͢ΔϨδετϦ ʔ
͍ํ
build.gradle compile 'com.android.support.test.espresso:espresso-idling-resource:3.0.0'
IdlingResource
SimpleIdlingResource class SimpleIdlingResource(private val name: String) : IdlingResource { private
var callback: IdlingResource.ResourceCallback? = null var isIdle: Boolean = false set(value) { field = value if (value) { callback?.run { onTransitionToIdle() } } } override fun getName(): String = this.name override fun isIdleNow(): Boolean = isIdle override fun registerIdleTransitionCallback(callback: IdlingResource.ResourceCallback?) { this.callback = callback } }
͏
ΞϓϦ
ViewModel class ViewModel { var artists: List<Artist> = emptyList() var
loadingDisposable: Disposable? = null @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) val loadingIdlingResource : SimpleIdlingResource = SimpleIdlingResource("IdlingResourceViewModelLoading") }
ViewModel class ViewModel { fun onCreate() { // fake API
request fakeReload() } private fun fakeReload() { loadingDisposable = Single .timer(3, TimeUnit.SECONDS) .doOnSubscribe { loadingIdlingResource.isIdle = false } .doFinally { loadingIdlingResource.isIdle = true } .subscribe { _, _ -> artists = Artist.list } } }
ςετ
test class IdlingResourceActivityTest { @JvmField @Rule val rule : IntentsTestRule<IdlingResourceActivity>
= IntentsTestRule(IdlingResourceActivity::class.java, true, true) var initializeIdlingResource : IdlingResource? = null }
test class IdlingResourceActivityTest { @Before fun setUp() { initializeIdlingResource =
rule.activity.viewModel.loadingIdlingResource IdlingRegistry.getInstance().register(initializeIdlingResource) } @After fun tearDown() { initializeIdlingResource?.run { IdlingRegistry.getInstance().unregister(this) initializeIdlingResource = null } } }
test class IdlingResourceActivityTest { @Test fun testReload() { // remove
3 items repeat(3) { openActionBarOverflowOrOptionsMenu(rule.activity) onView(withText("Remove first")).perform(click()) } onView(withId(R.id.swipeRefreshLayout)).perform(swipeDown()) onView(withId(R.id.recyclerView)).check { view, _ -> val recyclerView = view as RecyclerView assertEquals(recyclerView.childCount, Artist.list.size) assertEquals(recyclerView.adapter.itemCount, Artist.list.size) } } }
EspressoͷػೳΛΘͳ͍͚Ͳͪ ͍ͨ
ex) GAͷΠϕϯτૹ৴Λςετ
Espresso.onIdle()
༻ҙ͞Ε͍ͯΔIdlingResource
CountingIdlingResource
ηϚϑΥͬΆ͍ͭ
increment()/decrement()
IdlingScheduledThreadPoolExecutor / IdlingThreadPoolExecutor
ThreadPoolExecutor
UriIdlingResource
UriΛΩʔʹͰ͖ΔIdlingResource
ϋϚΓͲ͜Ζ
Test with Proguard
None
!
Proguard rule -keep class android.support.test.espresso.** { public *; }
takuji31/KanmobaAndroid
Enjoy Espresso life !