Skip to content

Commit 9ab496e

Browse files
committed
Re-enable Display.post tests
These tests have been disabled overtime because making sure they pass consistently on Jenkins is difficult (See [407862](https://bugs.eclipse.org/bugs/show_bug.cgi?id=407862) and [553754](https://bugs.eclipse.org/bugs/show_bug.cgi?id=553754)) With GitHub actions these problems seem to be less of an issue, so we should enable these tests again, at least on GHA. This first commit is a test to see if they pass on GHA consistently, if so adding a new check so that tests can be skipped on Jenkins releng infra can be added. Part of #2571
1 parent 1ba148d commit 9ab496e

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Display.java

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,14 +1065,6 @@ public void test_mapLorg_eclipse_swt_widgets_ControlLorg_eclipse_swt_widgets_Con
10651065

10661066
@Test
10671067
public void test_postLorg_eclipse_swt_widgets_Event() {
1068-
if (SwtTestUtil.isGTK || SwtTestUtil.isCocoa || SwtTestUtil.isWindows ) {
1069-
//TODO Fix/revisit GTK, Cocoa and Win10 failure test-case via bug 553754
1070-
if (SwtTestUtil.verbose) {
1071-
System.out.println("Excluded test_postLorg_eclipse_swt_widgets_Event(org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Display)");
1072-
}
1073-
return;
1074-
}
1075-
10761068
final int KEYCODE = SWT.SHIFT;
10771069

10781070
Display display = new Display();
@@ -1088,13 +1080,19 @@ public void test_postLorg_eclipse_swt_widgets_Event() {
10881080
shell.setBounds(display.getBounds());
10891081
shell.open();
10901082

1083+
// The display.post needs to successfully obtain the focused window (at least on GTK3)
1084+
// so we can send events to it. This processEvents gives SWT/GTK time to draw/focus/etc
1085+
// the window so that org.eclipse.swt.widgets.Display.findFocusedWindow()
1086+
// returns non-zero
1087+
SwtTestUtil.processEvents();
1088+
10911089
Event event;
10921090

10931091
// Test key events (down/up)
10941092
event = new Event();
10951093
event.type = SWT.KeyDown;
10961094
event.keyCode = -1; // bogus key code; default 0 character
1097-
assertTrue(display.post(event), "Display#post failed, probably because screen is not rendered (bug 407862)"); //$NON-NLS-1$
1095+
assertTrue(display.post(event), "Display#post failed, probably because screen is not rendered (bug 407862) or because Shell is not focussed"); //$NON-NLS-1$
10981096
// don't test KeyDown/KeyUp with a character to avoid sending to
10991097
// random window if test shell looses focus
11001098

@@ -1121,14 +1119,22 @@ public void test_postLorg_eclipse_swt_widgets_Event() {
11211119

11221120
event = new Event();
11231121
event.type = SWT.MouseDown;
1124-
assertFalse(display.post(event)); // missing button
1122+
if (!SwtTestUtil.isGTK) {
1123+
// GTK's post implementation has long allowed a button value of 0, the
1124+
// behavior of posting an event with button == 0 is undefined on GTK
1125+
assertFalse(display.post(event)); // missing button
1126+
}
11251127
event.button = 1;
11261128
shell.setFocus();
11271129
assertTrue(display.post(event));
11281130

11291131
event = new Event();
11301132
event.type = SWT.MouseUp;
1131-
assertFalse(display.post(event)); // missing button
1133+
if (!SwtTestUtil.isGTK) {
1134+
// GTK's post implementation has long allowed a button value of 0, the
1135+
// behavior of posting an event with button == 0 is undefined on GTK
1136+
assertFalse(display.post(event)); // missing button
1137+
}
11321138
event.button = 1;
11331139
shell.setFocus();
11341140
assertTrue(display.post(event));

0 commit comments

Comments
 (0)