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