blob: 19dc734737268e1cfca5e268cc48b825ee46dcb9 [file] [log] [blame]
Roman Elizarovdb89a7c2017-09-06 12:16:58 +03001/*
Roman Elizarov1f74a2d2018-06-29 19:19:45 +03002 * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license.
Roman Elizarovdb89a7c2017-09-06 12:16:58 +03003 */
4
5package kotlinx.coroutines.experimental.javafx
6
Roman Elizarovdb89a7c2017-09-06 12:16:58 +03007import javafx.application.Platform
Roman Elizarovffc61ae2017-10-26 19:29:52 +03008import kotlinx.coroutines.experimental.*
Roman Elizarovdb89a7c2017-09-06 12:16:58 +03009import org.junit.Before
10import org.junit.Test
11
12class JavaFxTest : TestBase() {
13 @Before
14 fun setup() {
15 ignoreLostThreads("JavaFX Application Thread", "Thread-", "QuantumRenderer-")
16 }
17
18 @Test
Roman Elizarov9c446c02017-09-06 19:13:26 +030019 fun testDelay() {
20 try {
21 initPlatform()
22 } catch (e: UnsupportedOperationException) {
23 println("Skipping JavaFxTest in headless environment")
24 return // ignore test in headless environments
Roman Elizarovdb89a7c2017-09-06 12:16:58 +030025 }
Roman Elizarov9c446c02017-09-06 19:13:26 +030026
27 runBlocking {
28 expect(1)
29 val job = launch(JavaFx) {
30 check(Platform.isFxApplicationThread())
31 expect(2)
32 delay(100)
33 check(Platform.isFxApplicationThread())
34 expect(3)
35 }
36 job.join()
37 finish(4)
38 }
Roman Elizarovdb89a7c2017-09-06 12:16:58 +030039 }
40}