kopia lustrzana https://github.com/ryukoposting/Signal-Android
Invoke onTick immediately in onResume.
rodzic
b3041ab6e0
commit
b93568d9c6
|
@ -22,7 +22,7 @@ class ConversationUpdateTick(
|
|||
isResumed = true
|
||||
|
||||
handler.removeCallbacksAndMessages(null)
|
||||
handler.postDelayed(this::onTick, TIMEOUT)
|
||||
onTick()
|
||||
}
|
||||
|
||||
override fun onPause(owner: LifecycleOwner) {
|
||||
|
|
|
@ -30,27 +30,27 @@ class ConversationUpdateTickTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `Given no time has passed after onResume is invoked, then I expect zero invocations of onTick`() {
|
||||
fun `Given no time has passed after onResume is invoked, then I expect one invocations of onTick`() {
|
||||
// GIVEN
|
||||
ShadowLooper.pauseMainLooper()
|
||||
testSubject.onResume(lifecycleOwner)
|
||||
|
||||
// THEN
|
||||
verify(listener, never()).onTick()
|
||||
verify(listener, times(1)).onTick()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given onResume is invoked, when half timeout passes, then I expect zero invocations of onTick`() {
|
||||
fun `Given onResume is invoked, when half timeout passes, then I expect one invocations of onTick`() {
|
||||
// GIVEN
|
||||
testSubject.onResume(lifecycleOwner)
|
||||
ShadowLooper.idleMainLooper(timeoutMillis / 2, TimeUnit.MILLISECONDS)
|
||||
|
||||
// THEN
|
||||
verify(listener, never()).onTick()
|
||||
verify(listener, times(1)).onTick()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given onResume is invoked, when timeout passes, then I expect one invocation of onTick`() {
|
||||
fun `Given onResume is invoked, when timeout passes, then I expect two invocations of onTick`() {
|
||||
// GIVEN
|
||||
testSubject.onResume(lifecycleOwner)
|
||||
|
||||
|
@ -58,11 +58,11 @@ class ConversationUpdateTickTest {
|
|||
ShadowLooper.idleMainLooper(timeoutMillis, TimeUnit.MILLISECONDS)
|
||||
|
||||
// THEN
|
||||
verify(listener, times(1)).onTick()
|
||||
verify(listener, times(2)).onTick()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given onResume is invoked, when timeout passes five times, then I expect five invocations of onTick`() {
|
||||
fun `Given onResume is invoked, when timeout passes five times, then I expect six invocations of onTick`() {
|
||||
// GIVEN
|
||||
testSubject.onResume(lifecycleOwner)
|
||||
|
||||
|
@ -70,11 +70,11 @@ class ConversationUpdateTickTest {
|
|||
ShadowLooper.idleMainLooper(timeoutMillis * 5, TimeUnit.MILLISECONDS)
|
||||
|
||||
// THEN
|
||||
verify(listener, times(5)).onTick()
|
||||
verify(listener, times(6)).onTick()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `Given onResume then onPause is invoked, when timeout passes, then I expect no invocations of onTick`() {
|
||||
fun `Given onResume then onPause is invoked, when timeout passes, then I expect one invocation of onTick`() {
|
||||
// GIVEN
|
||||
testSubject.onResume(lifecycleOwner)
|
||||
testSubject.onPause(lifecycleOwner)
|
||||
|
@ -83,6 +83,6 @@ class ConversationUpdateTickTest {
|
|||
ShadowLooper.idleMainLooper(timeoutMillis, TimeUnit.MILLISECONDS)
|
||||
|
||||
// THEN
|
||||
verify(listener, never()).onTick()
|
||||
verify(listener, times(1)).onTick()
|
||||
}
|
||||
}
|
||||
|
|
Ładowanie…
Reference in New Issue