|
21 | 21 | import java.util.concurrent.CountDownLatch; |
22 | 22 | import java.util.concurrent.Executors; |
23 | 23 | import java.util.concurrent.TimeUnit; |
24 | | -import javafx.beans.value.ChangeListener; |
25 | 24 | import javafx.beans.value.ObservableValue; |
26 | 25 | import javafx.scene.web.WebView; |
27 | 26 | import javafx.stage.Stage; |
28 | 27 | import net.java.html.BrwsrCtx; |
29 | 28 | import net.java.html.boot.BrowserBuilder; |
30 | 29 | import net.java.html.js.JavaScriptBody; |
| 30 | +import static org.netbeans.html.boot.fx.KOFx.assertTitle; |
31 | 31 | import org.netbeans.html.boot.spi.Fn; |
32 | 32 | import static org.testng.Assert.*; |
33 | 33 | import org.testng.annotations.Test; |
@@ -88,25 +88,19 @@ public void run() { |
88 | 88 |
|
89 | 89 | assertNotNull(lastWebView[0], "A WebView created"); |
90 | 90 | Stage s = (Stage) lastWebView[0].getScene().getWindow(); |
91 | | - assertEquals(s.getTitle(), "FX Presenter Harness"); |
| 91 | + assertTitle(s, "FX Presenter Harness", "Initial title is read from HTML page"); |
92 | 92 |
|
93 | 93 | final CountDownLatch propChange = new CountDownLatch(1); |
94 | | - s.titleProperty().addListener(new ChangeListener<String>() { |
95 | | - @Override |
96 | | - public void changed(ObservableValue<? extends String> ov, String t, String t1) { |
97 | | - propChange.countDown(); |
98 | | - } |
| 94 | + s.titleProperty().addListener((ObservableValue<? extends String> ov, String t, String t1) -> { |
| 95 | + propChange.countDown(); |
99 | 96 | }); |
100 | 97 |
|
101 | | - when.ctx.execute(new Runnable() { |
102 | | - @Override |
103 | | - public void run() { |
104 | | - changeTitle("New title"); |
105 | | - } |
| 98 | + when.ctx.execute(() -> { |
| 99 | + changeTitle("New title"); |
106 | 100 | }); |
107 | 101 |
|
108 | 102 | propChange.await(5, TimeUnit.SECONDS); |
109 | | - assertEquals(s.getTitle(), "New title"); |
| 103 | + assertTitle(s, "New title", "Title is dynamically updated"); |
110 | 104 | } |
111 | 105 |
|
112 | 106 | final void doCheckReload() throws Exception { |
|
0 commit comments