Created
June 21, 2017 17:36
-
-
Save damien5314/038f441de825575ad1f6ce9c7b9bf0a1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import com.quizlet.android.logging.ConsoleLogger | |
| import com.quizlet.android.logging.ConsoleLoggingTree | |
| import io.reactivex.Completable | |
| import io.reactivex.Scheduler | |
| import io.reactivex.schedulers.Schedulers | |
| import io.reactivex.schedulers.TestScheduler | |
| import org.junit.After | |
| import org.junit.Before | |
| import org.junit.Test | |
| import timber.log.Timber | |
| class SchedulerTests { | |
| @Before | |
| fun setUp() { | |
| Timber.plant(ConsoleLoggingTree(ConsoleLogger())) | |
| } | |
| @After | |
| fun tearDown() { | |
| Timber.uprootAll() | |
| } | |
| @Test | |
| fun trampoline() { | |
| test(Schedulers.trampoline()) | |
| } | |
| @Test | |
| fun io() { | |
| test(Schedulers.io()) | |
| } | |
| @Test | |
| fun testScheduler() { | |
| test(TestScheduler()) | |
| } | |
| private fun test(scheduler: Scheduler) { | |
| Completable.defer { | |
| Timber.d("[1]") | |
| Thread.sleep(1000) | |
| Timber.d("[2]") | |
| Completable.complete() | |
| } | |
| .doOnComplete { Timber.d("[3]") } | |
| .subscribeOn(scheduler) | |
| .observeOn(scheduler) | |
| .test() | |
| Timber.d("[4]") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment