Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
if: ${{ matrix.config.native == 'gtk.linux.x86_64'}}
run: |
sudo apt-get update -qq
WEBKIT_VERSION=2.44.0-2 && sudo apt-get install -qq -y libgtk-3-dev libgtk-4-dev freeglut3-dev webkit2gtk-driver=${WEBKIT_VERSION} libwebkit2gtk-4.1-0=${WEBKIT_VERSION} libjavascriptcoregtk-4.1-0=${WEBKIT_VERSION}
sudo apt-get install -qq -y libgtk-3-dev libgtk-4-dev freeglut3-dev webkit2gtk-driver
- name: Pull large static Windows binaries
if: ${{ matrix.config.native == 'win32.win32.x86_64'}}
run: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map.Entry;
Expand Down Expand Up @@ -824,8 +825,8 @@ public void test_OpenWindowListener_addAndRemove() {
@Test
public void test_OpenWindowListener_openHasValidEventDetails() {
AtomicBoolean openFiredCorrectly = new AtomicBoolean(false);
final Browser browserChild = createBrowser(shell, swtBrowserSettings);
browser.addOpenWindowListener(event -> {
final Browser browserChild = createBrowser(shell, swtBrowserSettings);
assertSame("Expected Browser1 instance, but have another instance", browser, event.widget);
assertNull("Expected event.browser to be null", event.browser);
openFiredCorrectly.set(true);
Expand All @@ -845,24 +846,23 @@ public void test_OpenWindowListener_openHasValidEventDetails() {
/** Test that a script 'window.open()' opens a child popup shell. */
@Test
public void test_OpenWindowListener_open_ChildPopup() {
assumeFalse("Not currently working on Linux, see https://github.com/eclipse-platform/eclipse.platform.swt/issues/1564", SwtTestUtil.isGTK);
AtomicBoolean childCompleted = new AtomicBoolean(false);

Shell childShell = new Shell(shell, SWT.None);
childShell.setText("Child shell");
childShell.setLayout(new FillLayout());
final Browser browserChild = createBrowser(childShell, swtBrowserSettings);

browser.addOpenWindowListener(event -> {
Browser browserChild = createBrowser(childShell, swtBrowserSettings);
browserChild.addVisibilityWindowListener(showAdapter(event2 -> {
childShell.open();
browserChild.setText("Child Browser");
}));
//Triggers test to finish.
browserChild.addProgressListener(completedAdapter(event2 -> childCompleted.set(true)));
event.browser = browserChild;
});

browserChild.addVisibilityWindowListener(showAdapter(event -> {
childShell.open();
browserChild.setText("Child Browser");
}));
//Triggers test to finish.
browserChild.addProgressListener(completedAdapter(event -> childCompleted.set(true)));

shell.open();

Expand All @@ -883,37 +883,32 @@ public void test_OpenWindowListener_open_ChildPopup() {
/** Validate event order : Child's visibility should come before progress completed event */
@Test
public void test_OpenWindow_Progress_Listener_ValidateEventOrder() {
assumeFalse("Not currently working on Linux, see https://github.com/eclipse-platform/eclipse.platform.swt/issues/1564", SwtTestUtil.isGTK);

AtomicBoolean windowOpenFired = new AtomicBoolean(false);
AtomicBoolean childCompleted = new AtomicBoolean(false);
AtomicBoolean visibilityShowed = new AtomicBoolean(false);
// there might be more than one progress event, use a linked hash set to keep the order but only track unique events
Set<String> eventOrder = Collections.synchronizedSet(new LinkedHashSet<String>());

Shell childShell = new Shell(shell, SWT.None);
childShell.setText("Child shell");
childShell.setLayout(new FillLayout());
final Browser browserChild = createBrowser(childShell, swtBrowserSettings);

browser.addOpenWindowListener(event -> {
final Browser browserChild = createBrowser(childShell, swtBrowserSettings);
event.browser = browserChild;
assertFalse("OpenWindowListener should have been fired first",
visibilityShowed.get() || childCompleted.get()); // Validate event order.
windowOpenFired.set(true);
});

browserChild.addVisibilityWindowListener(showAdapter(event -> {
childShell.open();
assertTrue("Child Visibility.show should have fired before progress completed",
windowOpenFired.get() && !childCompleted.get()); // Validate event order.
visibilityShowed.set(true);
}));
browserChild.addVisibilityWindowListener(showAdapter(event2 -> {
eventOrder.add("Visibility.show");
visibilityShowed.set(true);
childShell.open();
}));

browserChild.addProgressListener(completedAdapter(event -> {
assertTrue("Child's Progress Completed before parent's expected events",
windowOpenFired.get() && visibilityShowed.get()); // Validate event order.
childCompleted.set(true); // Triggers test to finish.
browserChild.setText("Child Browser!");
}));
browserChild.addProgressListener(completedAdapter(event2 -> {
eventOrder.add("Progress.completed");
childCompleted.set(true); // Triggers test to finish.
browserChild.setText("Child Browser!");
}));
});

shell.open();

Expand All @@ -925,14 +920,16 @@ public void test_OpenWindow_Progress_Listener_ValidateEventOrder() {
<body>This test uses javascript to open a new window.</body>
</html>""");

boolean passed = waitForPassCondition(() -> windowOpenFired.get() && visibilityShowed.get() && childCompleted.get());
boolean passed = waitForPassCondition(() -> visibilityShowed.get() && childCompleted.get());

String errMsg = "\nTest timed out."
+"\nExpected true for the below, but have:"
+"\nWindoOpenFired:" + windowOpenFired.get()
+"\nVisibilityShowed:" + visibilityShowed.get()
+"\nChildCompleted:" + childCompleted.get();
assertTrue(errMsg, passed);

assertEquals("Child Visibility.show should have fired before progress completed",
List.of("Visibility.show", "Progress.completed"), List.copyOf(eventOrder));
}

@Test
Expand Down Expand Up @@ -1384,7 +1381,6 @@ public void completed(ProgressEvent event) {
*/
@Test
public void test_VisibilityWindowListener_eventSize() {
assumeFalse("Not currently working on Linux, see https://github.com/eclipse-platform/eclipse.platform.swt/issues/1564", SwtTestUtil.isGTK);

shell.setSize(200,300);
AtomicBoolean childCompleted = new AtomicBoolean(false);
Expand All @@ -1394,20 +1390,19 @@ public void test_VisibilityWindowListener_eventSize() {
childShell.setSize(250, 350);
childShell.setText("Child shell");
childShell.setLayout(new FillLayout());
final Browser browserChild = createBrowser(childShell, swtBrowserSettings);

browser.addOpenWindowListener(event -> {
final Browser browserChild = createBrowser(childShell, swtBrowserSettings);
browserChild.addVisibilityWindowListener(showAdapter(event2 -> {
testLog.append("Visibilty show eventfired.\nEvent size: " + event2.size);
result.set(event2.size);
childShell.open();
childCompleted.set(true);
}));
event.browser = browserChild;
testLog.append("openWindowListener fired");
});

browserChild.addVisibilityWindowListener(showAdapter(event -> {
testLog.append("Visibilty show eventfired.\nEvent size: " + event.size);
result.set(event.size);
childShell.open();
childCompleted.set(true);
}));

shell.open();
browser.setText("""
<html>
Expand All @@ -1418,7 +1413,7 @@ public void test_VisibilityWindowListener_eventSize() {
</html>""");

boolean finishedWithoutTimeout = waitForPassCondition(childCompleted::get);
browserChild.dispose();
childShell.dispose();

boolean passed = false;
if (!SwtTestUtil.isWindows) {
Expand Down
Loading