blob: 26dbe8f4cffca4bf029375bae1f3d5098d454bb7 [file] [log] [blame]
/*
* Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
*/
package kotlinx.coroutines.rx2
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.*
import org.junit.Before
import org.junit.Test
import kotlin.test.*
class SchedulerTest : TestBase() {
@Before
fun setup() {
ignoreLostThreads("RxCachedThreadScheduler-", "RxCachedWorkerPoolEvictor-", "RxSchedulerPurge-")
}
@Test
fun testIoScheduler(): Unit = runBlocking {
expect(1)
val mainThread = Thread.currentThread()
withContext(Schedulers.io().asCoroutineDispatcher()) {
val t1 = Thread.currentThread()
assertNotSame(t1, mainThread)
expect(2)
delay(100)
val t2 = Thread.currentThread()
assertNotSame(t2, mainThread)
expect(3)
}
finish(4)
}
}