@@ -14,6 +14,7 @@ import org.junit.jupiter.api.extension.ExtendWith
1414import org.testfx.framework.junit5.ApplicationExtension
1515import org.testfx.framework.junit5.Start
1616import org.testfx.util.WaitForAsyncUtils
17+ import java.util.concurrent.atomic.AtomicInteger
1718
1819@ExtendWith(ApplicationExtension ::class )
1920class ArrayTest {
@@ -26,19 +27,24 @@ class ArrayTest {
2627
2728 @Test
2829 fun updateArrayValue () {
30+ val updateCounter = AtomicInteger (0 )
31+
2932 val schema = JSONObject (
3033 """ {"type":"object","properties":{"bar":{"type":"array",
3134 "items":{"type":"string"}
3235 }}}"""
3336 )
3437 val json = JSONObject (""" {"bar":["hello", "world"]}""" )
35- editor.display(" 1" , " 1" , json, schema) { it }
38+ editor.display(" 1" , " 1" , json, schema) { it. also { updateCounter.incrementAndGet() } }
3639 val itemTable = editor.getItemTable()
3740 val arrayEntry = itemTable.root.children[0 ].findChildWithKey(" bar" )!!
3841 val textField = arrayEntry.children.first().value.createControl()!! .control as TextField
3942 assertThat(textField.text, `is `(" hello" ))
4043 textField.text = " bye bye"
44+
45+ WaitForAsyncUtils .waitForFxEvents()
4146 assertThat(json.getJSONArray(" bar" ).getString(0 ), `is `(" bye bye" ))
47+ assertThat(updateCounter.get(), `is `(1 ))
4248 }
4349
4450 @Test
@@ -116,13 +122,15 @@ class ArrayTest {
116122
117123 @Test
118124 fun arrayElementCanBeAddedByButtonPress () {
125+ val updateCounter = AtomicInteger (0 )
126+
119127 val schema = JSONObject (
120128 """ {"type":"object","properties":{"bar":{"type":"array",
121129 "items":{"type":"string"}
122130 }}}"""
123131 )
124132 val data = JSONObject ()
125- editor.display(" 1" , " 1" , data, schema) { it }
133+ editor.display(" 1" , " 1" , data, schema) { it. also { updateCounter.incrementAndGet() } }
126134 val itemTable = editor.getItemTable()
127135 val arrayEntry = itemTable.root.children[0 ].findChildWithKey(" bar" )!!
128136 val addButton = arrayEntry.value.createActions()!! .children[1 ] as Button
@@ -139,6 +147,7 @@ class ArrayTest {
139147 }
140148 WaitForAsyncUtils .waitForFxEvents()
141149 assertThat(data.getJSONArray(" bar" ).toList(), contains(null , null , null ))
150+ assertThat(updateCounter.get(), `is `(3 ))
142151 }
143152
144153 @Test
0 commit comments