-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
288 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,5 @@ | |
|
||
package com.tinder.scarlet.internal.coordinator | ||
|
||
// TODO | ||
class CoordinatorTest |
100 changes: 100 additions & 0 deletions
100
scarlet/src/test/java/com/tinder/scarlet/internal/coordinator/LifecycleEventSourceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
/* | ||
* © 2019 Match Group, LLC. | ||
*/ | ||
|
||
package com.tinder.scarlet.internal.coordinator | ||
|
||
import com.nhaarman.mockito_kotlin.mock | ||
import com.nhaarman.mockito_kotlin.only | ||
import com.nhaarman.mockito_kotlin.then | ||
import com.tinder.scarlet.Event | ||
import com.tinder.scarlet.LifecycleState | ||
import com.tinder.scarlet.lifecycle.LifecycleRegistry | ||
import io.reactivex.schedulers.TestScheduler | ||
import org.junit.Test | ||
|
||
class LifecycleEventSourceTest { | ||
|
||
private val testScheduler = TestScheduler() | ||
private val lifecycleRegistry = LifecycleRegistry() | ||
private val lifecycleEventSource = LifecycleEventSource(testScheduler, lifecycleRegistry) | ||
|
||
private val eventCallback = mock<EventCallback>() | ||
|
||
@Test | ||
fun start_givenLifecycleState_shouldNotify() { | ||
// Given | ||
lifecycleRegistry.onNext(LifecycleState.Started) | ||
|
||
// When | ||
lifecycleEventSource.start(eventCallback) | ||
testScheduler.triggerActions() | ||
|
||
// Then | ||
then(eventCallback).should().onEvent(Event.OnLifecycleStateChange(LifecycleState.Started)) | ||
} | ||
|
||
@Test | ||
fun start_givenNoLifecycleState_shouldNotNotify() { | ||
// When | ||
lifecycleEventSource.start(eventCallback) | ||
testScheduler.triggerActions() | ||
|
||
// Then | ||
then(eventCallback).shouldHaveZeroInteractions() | ||
} | ||
|
||
@Test | ||
fun stop_givenLifecycleState_shouldNotNotify() { | ||
// Given | ||
lifecycleRegistry.onNext(LifecycleState.Started) | ||
lifecycleEventSource.start(eventCallback) | ||
testScheduler.triggerActions() | ||
|
||
// When | ||
lifecycleEventSource.stop() | ||
lifecycleRegistry.onNext(LifecycleState.Stopped) | ||
testScheduler.triggerActions() | ||
|
||
// Then | ||
then(eventCallback).should(only()) | ||
.onEvent(Event.OnLifecycleStateChange(LifecycleState.Started)) | ||
} | ||
|
||
@Test | ||
fun pause_givenLifecycleState_shouldNotNotify() { | ||
// Given | ||
lifecycleRegistry.onNext(LifecycleState.Started) | ||
lifecycleEventSource.start(eventCallback) | ||
testScheduler.triggerActions() | ||
|
||
// When | ||
lifecycleEventSource.pause() | ||
lifecycleRegistry.onNext(LifecycleState.Stopped) | ||
testScheduler.triggerActions() | ||
|
||
// Then | ||
then(eventCallback).should(only()) | ||
.onEvent(Event.OnLifecycleStateChange(LifecycleState.Started)) | ||
} | ||
|
||
@Test | ||
fun resume_givenLifecycleState_shouldNotify() { | ||
// Given | ||
lifecycleRegistry.onNext(LifecycleState.Started) | ||
lifecycleEventSource.start(eventCallback) | ||
testScheduler.triggerActions() | ||
|
||
lifecycleEventSource.pause() | ||
lifecycleRegistry.onNext(LifecycleState.Stopped) | ||
|
||
// When | ||
lifecycleEventSource.resume() | ||
testScheduler.triggerActions() | ||
|
||
// Then | ||
then(eventCallback).should().onEvent(Event.OnLifecycleStateChange(LifecycleState.Started)) | ||
then(eventCallback).should().onEvent(Event.OnLifecycleStateChange(LifecycleState.Stopped)) | ||
} | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
scarlet/src/test/java/com/tinder/scarlet/internal/coordinator/SessionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* © 2019 Match Group, LLC. | ||
*/ | ||
|
||
package com.tinder.scarlet.internal.coordinator | ||
|
||
// TODO | ||
class SessionTest |
Oops, something went wrong.