Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Espresso Idling Resource
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Takuji Nishibayashi
August 29, 2017
Technology
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Espresso Idling Resource
Takuji Nishibayashi
August 29, 2017
More Decks by Takuji Nishibayashi
See All by Takuji Nishibayashi
compose-hot-reload を試そうとした話
takuji31
0
160
CameraX使ってみた
takuji31
0
310
kotlinx.datetime 使ってみた
takuji31
0
1.1k
HiltのCustom Componentについて
takuji31
0
380
java.timeをAndroidで使う
takuji31
0
200
KSPを使ってコード生成
takuji31
0
480
Kotlin Symbol Processing API (KSP) を使って Kotlin ア プリケーションの開発を効率化する
takuji31
1
3.2k
kotlinx.serialization
takuji31
0
700
kanmoba-returns-02.pdf
takuji31
0
300
Other Decks in Technology
See All in Technology
OPENLOGI Company Profile for engineer
hr01
1
74k
LLMやAIエージェントをソフトウェアに組み込むプラクティス
shibuiwilliam
2
420
CSに"SLO"は要らない、経営層に"99.9%"は伝わらない - SREを全社に"翻訳"する3原則
cscengineer
PRO
1
5.1k
関数型の考えを TypeScript に持ち込んで、テストしやすい純粋関数を増やす / Pure at the Core, Effects at the Edge: Bringing Functional Thinking into TypeScript
kaminashi
2
130
Claude Code公式skillで 自分の仕事を少しずつ手放そう!(Claude Code開発ノウハウ大公開スペシャル by クラスメソッド)
kaym
1
490
AI Driven AI Governance
pict3
0
490
公式ドキュメントの歩き方etc
coco_se
1
120
Kaggleで成長するために意識したこと
prgckwb
2
420
Making sense of Google’s agentic dev tools
glaforge
1
280
しぶいSRE: サーバから見えない障害にどう向き合うか。ラストワンマイルのデバッグ実践 / Shibui SRE
kanny
13
6.5k
Alphaモジュール使っていいのかい!?いけないのかい!?どっちなんだいっ!?
watany
1
280
CDKで書くECSのベストプラクティス、 改めて考え直す2026 #cdkconf2026
makies
3
820
Featured
See All Featured
RailsConf 2023
tenderlove
30
1.5k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Visualization
eitanlees
152
17k
Google's AI Overviews - The New Search
badams
0
1.1k
The Limits of Empathy - UXLibs8
cassininazir
1
500
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
750
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
The browser strikes back
jonoalderson
0
1.4k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
610
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
220
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 !