Roman Elizarov | db89a7c | 2017-09-06 12:16:58 +0300 | [diff] [blame] | 1 | /* |
Roman Elizarov | 1f74a2d | 2018-06-29 19:19:45 +0300 | [diff] [blame^] | 2 | * Copyright 2016-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. |
Roman Elizarov | db89a7c | 2017-09-06 12:16:58 +0300 | [diff] [blame] | 3 | */ |
| 4 | |
| 5 | package kotlinx.coroutines.experimental.javafx |
| 6 | |
Roman Elizarov | db89a7c | 2017-09-06 12:16:58 +0300 | [diff] [blame] | 7 | import javafx.application.Platform |
Roman Elizarov | ffc61ae | 2017-10-26 19:29:52 +0300 | [diff] [blame] | 8 | import kotlinx.coroutines.experimental.* |
Roman Elizarov | db89a7c | 2017-09-06 12:16:58 +0300 | [diff] [blame] | 9 | import org.junit.Before |
| 10 | import org.junit.Test |
| 11 | |
| 12 | class JavaFxTest : TestBase() { |
| 13 | @Before |
| 14 | fun setup() { |
| 15 | ignoreLostThreads("JavaFX Application Thread", "Thread-", "QuantumRenderer-") |
| 16 | } |
| 17 | |
| 18 | @Test |
Roman Elizarov | 9c446c0 | 2017-09-06 19:13:26 +0300 | [diff] [blame] | 19 | 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 Elizarov | db89a7c | 2017-09-06 12:16:58 +0300 | [diff] [blame] | 25 | } |
Roman Elizarov | 9c446c0 | 2017-09-06 19:13:26 +0300 | [diff] [blame] | 26 | |
| 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 Elizarov | db89a7c | 2017-09-06 12:16:58 +0300 | [diff] [blame] | 39 | } |
| 40 | } |