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
200
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
390
java.timeをAndroidで使う
takuji31
0
210
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
Invisible to AI? Making TYPO3 Sites Quotable by AI Search Systems
wolfgangwagner
0
170
[しろおび夏祭り2026] チャットするAIから、作業するAIへ - 使われ方の変化と、その裏側で起きていること
kk0n
0
1.7k
名古屋の市バスGTFS-JPデータ×スガキヤ 最寄りバス停検索をAmazon ElastiCache Serverless for Valkeyで最適化する
usanchuu
1
510
Bill One 開発エンジニア 紹介資料
sansan33
PRO
7
19k
[ChatGPT Work LT]事務作業が苦手な人のための バックオフィスの「半」自動化
chimaki_iot
0
250
【Google Cloud Next Tokyo'26】Gemini Enterprise と Oracle AI Database で実現する、業務データ活用を実現する AI エージェント実装
shisyu_gaku
0
230
事業価値と Engineering 2026年度版
recruitengineers
PRO
45
22k
グローバル基準のSREは、運用現場でどう機能したか:成熟度アセスメントの実践 / SRE NEXT 2026
sorawatanabe
0
140
モノリス Rails でも日中に rails db:migrate を走らせたい! / Daytime rails db:migrate on Monolithic Rails!
euglena1215
4
550
AI駆動開発は個人技からチーム戦へ:組織でAIを使いこなすための実践設計
moongift
PRO
0
480
トヨタ⽣産⽅式(TPS)⼊⾨
recruitengineers
PRO
3
650
Digitization部 紹介資料
sansan33
PRO
2
7.7k
Featured
See All Featured
VelocityConf: Rendering Performance Case Studies
addyosmani
333
25k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
790
First, design no harm
axbom
PRO
2
1.2k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
330
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
280
Navigating Weather and Climate Data
rabernat
0
460
The Language of Interfaces
destraynor
162
27k
SEO Brein meetup: CTRL+C is not how to scale international SEO
lindahogenes
1
2.8k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
73
41k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
200
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
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 !