From 9e3e78bd2cefc0e4a534895548d171711ee28a3a Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Tue, 10 Dec 2024 13:14:41 +0100 Subject: [PATCH] Add some debug output --- .../win32/org/eclipse/swt/browser/Edge.java | 1 + .../Test_org_eclipse_swt_browser_Browser.java | 15 ++++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java index e3b33262f5..2e4d7055b7 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java @@ -596,6 +596,7 @@ void setupBrowser(int hr, long pv) { error(SWT.ERROR_THREAD_INVALID_ACCESS, hr); break; default: + System.err.println("WebView instantiation failed with result: " + hr); containingEnvironment.instances().remove(this); error(SWT.ERROR_NO_HANDLES, hr); } diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java index 7358b3727e..58e42c215b 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_browser_Browser.java @@ -298,6 +298,8 @@ private Browser createBrowser(Shell s, int flags) { long maximumBrowserCreationMilliseconds = 10_000; long createStartTime = System.currentTimeMillis(); Browser b = new Browser(s, flags); + // Wait for asynchronous initialization via getting URL + b.getUrl(); createdBroswers.add(b); long createDuration = System.currentTimeMillis() - createStartTime; assertTrue("creating browser took too long: " + createDuration + "ms", createDuration < maximumBrowserCreationMilliseconds); @@ -735,14 +737,16 @@ public void changed(LocationEvent event) { @Test public void test_LocationListener_LocationListener_ordered_changing () { - List locations = new ArrayList<>(); - browser.addLocationListener(changingAdapter(event -> locations.add(event.location))); + List locations = Collections.synchronizedList(new ArrayList<>()); + browser.addLocationListener(changingAdapter(event -> { + locations.add(event.location); + })); shell.open(); browser.setText("You should not see this message."); String url = getValidUrl(); browser.setUrl(url); - waitForPassCondition(() -> locations.size() == 2); - assertTrue("Change of locations do not fire in order.", locations.get(0).equals("about:blank") && locations.get(1).contains("testWebsiteWithTitle.html")); + assertTrue("Change of locations do not fire in order: " + locations.toString(), waitForPassCondition(() -> locations.size() == 2)); + assertTrue("Change of locations do not fire in order", locations.get(0).equals("about:blank") && locations.get(1).contains("testWebsiteWithTitle.html")); } private String getValidUrl() { @@ -1955,6 +1959,7 @@ public void test_evaluate_null() { // Boolen only used as dummy placeholder so the object is not null. final AtomicReference returnValue = new AtomicReference<>(true); browser.addProgressListener(completedAdapter(event -> { + returnValue.set(false); Object evalResult = browser.evaluate("return null"); returnValue.set(evalResult); if (debug_verbose_output) @@ -1964,7 +1969,7 @@ public void test_evaluate_null() { browser.setText("HelloWorld"); shell.open(); boolean passed = waitForPassCondition(() -> returnValue.get() == null); - assertTrue("Evaluate did not return a null. Timed out.", passed); + assertTrue("Evaluate did not return a null (current value: " + returnValue.get() + "). Timed out.", passed); } /**