1 package kotlinx.coroutines.javafx 2 3 import kotlinx.coroutines.testing.* 4 import javafx.beans.property.SimpleIntegerProperty 5 import kotlinx.coroutines.* 6 import kotlinx.coroutines.flow.first 7 import org.junit.* 8 9 class JavaFxStressTest : TestBase() { 10 11 @Before setupnull12 fun setup() { 13 ignoreLostThreads("JavaFX Application Thread", "Thread-", "QuantumRenderer-", "InvokeLaterDispatcher") 14 } 15 16 @get:Rule 17 val pool = ExecutorRule(1) 18 19 @Test <lambda>null20 fun testCancellationRace() = runTest { 21 if (!initPlatform()) { 22 println("Skipping JavaFxTest in headless environment") 23 return@runTest // ignore test in headless environments 24 } 25 26 val integerProperty = SimpleIntegerProperty(0) 27 val flow = integerProperty.asFlow() 28 var i = 1 29 val n = 1000 * stressTestMultiplier 30 repeat (n) { 31 launch(pool) { 32 flow.first() 33 } 34 withContext(Dispatchers.JavaFx) { 35 integerProperty.set(i) 36 } 37 i += 1 38 } 39 } 40 }