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
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
470
Kotlin Symbol Processing API (KSP) を使って Kotlin ア プリケーションの開発を効率化する
takuji31
1
3.2k
kotlinx.serialization
takuji31
0
690
kanmoba-returns-02.pdf
takuji31
0
290
Other Decks in Technology
See All in Technology
【FinOps】データドリブンな意思決定を目指して
z63d
0
310
AIのReact習熟度を測る
uhyo
2
680
MySQL & MySQL HeatWave Report - June 2026
freshdaz
0
100
AIAU_UMEMOGU_ninomiya_slide
ninomiya_ii
0
260
いまさら聞けない「仕様駆動開発入門」 〜AI活用時代の開発プロセスを考える〜
findy_eventslides
2
200
2026 AI Memory Architecture
nagatsu
0
100
AIチャット検索改善の3週間
kworkdev
PRO
2
170
入門!AWS Blocks
ysuzuki
1
190
Comment regagner la souveraineté de vos données tout en étant payé grâce à Nostr !
rlifchitz
0
200
「ビジネスがわかるエンジニア」とは何か?
ryooob
0
290
AIをフル活用してオンコール機能のプロトタイプを2日で作った話 / Building an AI-Powered On-Call Prototype in Just Two Days
nari_ex
0
120
時期が悪い!それでもRaspberry Piを買って遊んで活用するには / 20260627-osc26do-rpi-jikigawarui
akkiesoft
0
790
Featured
See All Featured
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
133
19k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
540
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
170
Optimising Largest Contentful Paint
csswizardry
37
3.7k
How to build an LLM SEO readiness audit: a practical framework
nmsamuel
1
780
WENDY [Excerpt]
tessaabrams
11
38k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
200
What's in a price? How to price your products and services
michaelherold
247
13k
Code Review Best Practice
trishagee
74
20k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
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 !