eclipse.platform.swt icon indicating copy to clipboard operation
eclipse.platform.swt copied to clipboard

GTK4: org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell test fails.

Open raghucssit opened this issue 2 months ago • 7 comments

2025-09-08T15:18:08.1580506Z [ERROR] org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell.test_Issue450_NoShellActivateOnSetFocus -- Time elapsed: 7.709 s <<< FAILURE!
2025-09-08T15:18:08.1581519Z java.lang.AssertionError: 
2025-09-08T15:18:08.1581878Z Shell did not activate
2025-09-08T15:18:08.1582828Z Expected: is <Shell {shell2} [layout=GridLayout {marginWidth=5 marginHeight=5 horizontalSpacing=5 verticalSpacing=5}]>
2025-09-08T15:18:08.1583657Z      but: was null
2025-09-08T15:18:08.1584129Z 	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
2025-09-08T15:18:08.1584956Z 	at org.eclipse.swt.tests.junit.SwtTestUtil.waitShellActivate(SwtTestUtil.java:477)
2025-09-08T15:18:08.1586245Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell.test_Issue450_NoShellActivateOnSetFocus(Test_org_eclipse_swt_widgets_Shell.java:971)
2025-09-08T15:18:08.1587397Z 	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
2025-09-08T15:18:08.1588646Z 	Suppressed: java.lang.Throwable: Screenshot written to /tmp/org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell.test_Issue450_NoShellActivateOnSetFocus.png
2025-09-08T15:18:08.1590017Z 		at org.eclipse.test.Screenshots$ScreenshotOnFailure.failed(Screenshots.java:41)
2025-09-08T15:18:08.1590560Z 
2025-09-08T15:18:08.1591146Z [ERROR] org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell.test_getLocation -- Time elapsed: 1.238 s <<< FAILURE!
2025-09-08T15:18:08.1592109Z java.lang.AssertionError: :a: expected:<10> but was:<0>
2025-09-08T15:18:08.1622866Z 	at org.junit.Assert.fail(Assert.java:89)
2025-09-08T15:18:08.1623434Z 	at org.junit.Assert.failNotEquals(Assert.java:835)
2025-09-08T15:18:08.1623996Z 	at org.junit.Assert.assertEquals(Assert.java:647)
2025-09-08T15:18:08.1624936Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell.test_getLocation(Test_org_eclipse_swt_widgets_Shell.java:461)
2025-09-08T15:18:08.1625928Z 	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
2025-09-08T15:18:08.1627047Z 	Suppressed: java.lang.Throwable: Screenshot written to /tmp/org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell.test_getLocation.png
2025-09-08T15:18:08.1628274Z 		at org.eclipse.test.Screenshots$ScreenshotOnFailure.failed(Screenshots.java:41)
2025-09-08T15:18:08.1628798Z 
2025-09-08T15:18:08.1629550Z [ERROR] org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell.test_setLocationLorg_eclipse_swt_graphics_Point -- Time elapsed: 0.956 s <<< FAILURE!
2025-09-08T15:18:08.1630761Z java.lang.AssertionError: expected:<Point {0, 0}> but was:<Point {30, 40}>
2025-09-08T15:18:08.1631422Z 	at org.junit.Assert.fail(Assert.java:89)
2025-09-08T15:18:08.1631943Z 	at org.junit.Assert.failNotEquals(Assert.java:835)
2025-09-08T15:18:08.1632657Z 	at org.junit.Assert.assertEquals(Assert.java:120)
2025-09-08T15:18:08.1633189Z 	at org.junit.Assert.assertEquals(Assert.java:146)
2025-09-08T15:18:08.1634311Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Control.test_setLocationLorg_eclipse_swt_graphics_Point(Test_org_eclipse_swt_widgets_Control.java:802)
2025-09-08T15:18:08.1636392Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Scrollable.test_setLocationLorg_eclipse_swt_graphics_Point(Test_org_eclipse_swt_widgets_Scrollable.java:1)
2025-09-08T15:18:08.1638445Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Composite.test_setLocationLorg_eclipse_swt_graphics_Point(Test_org_eclipse_swt_widgets_Composite.java:1)
2025-09-08T15:18:08.1640162Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Canvas.test_setLocationLorg_eclipse_swt_graphics_Point(Test_org_eclipse_swt_widgets_Canvas.java:1)
2025-09-08T15:18:08.1641911Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Decorations.test_setLocationLorg_eclipse_swt_graphics_Point(Test_org_eclipse_swt_widgets_Decorations.java:1)
2025-09-08T15:18:08.1643792Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell.test_setLocationLorg_eclipse_swt_graphics_Point(Test_org_eclipse_swt_widgets_Shell.java:1)
2025-09-08T15:18:08.1644966Z 	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
2025-09-08T15:18:08.1646234Z 	Suppressed: java.lang.Throwable: Screenshot written to /tmp/org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell.test_setLocationLorg_eclipse_swt_graphics_Point.png
2025-09-08T15:18:08.1647624Z 		at org.eclipse.test.Screenshots$ScreenshotOnFailure.failed(Screenshots.java:41)
2025-09-08T15:18:08.1648151Z 
2025-09-08T15:18:08.1648734Z [ERROR] org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell.test_setLocationII -- Time elapsed: 0.764 s <<< FAILURE!
2025-09-08T15:18:08.1649780Z java.lang.AssertionError: expected:<Point {0, 0}> but was:<Point {11, 22}>
2025-09-08T15:18:08.1650418Z 	at org.junit.Assert.fail(Assert.java:89)
2025-09-08T15:18:08.1650929Z 	at org.junit.Assert.failNotEquals(Assert.java:835)
2025-09-08T15:18:08.1651475Z 	at org.junit.Assert.assertEquals(Assert.java:120)
2025-09-08T15:18:08.1652065Z 	at org.junit.Assert.assertEquals(Assert.java:146)
2025-09-08T15:18:08.1673459Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Control.test_setLocationII(Test_org_eclipse_swt_widgets_Control.java:790)
2025-09-08T15:18:08.1674974Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Scrollable.test_setLocationII(Test_org_eclipse_swt_widgets_Scrollable.java:1)
2025-09-08T15:18:08.1676441Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Composite.test_setLocationII(Test_org_eclipse_swt_widgets_Composite.java:1)
2025-09-08T15:18:08.1677840Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Canvas.test_setLocationII(Test_org_eclipse_swt_widgets_Canvas.java:1)
2025-09-08T15:18:08.1679241Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Decorations.test_setLocationII(Test_org_eclipse_swt_widgets_Decorations.java:1)
2025-09-08T15:18:08.1680634Z 	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell.test_setLocationII(Test_org_eclipse_swt_widgets_Shell.java:1)
2025-09-08T15:18:08.1681636Z 	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
2025-09-08T15:18:08.1682952Z 	Suppressed: java.lang.Throwable: Screenshot written to /tmp/org.eclipse.swt.tests.junit.Test_org_eclipse_swt_widgets_Shell.test_setLocationII.png
2025-09-08T15:18:08.1684204Z 		at org.eclipse.test.Screenshots$ScreenshotOnFailure.failed(Screenshots.java:41)

raghucssit avatar Sep 11 '25 09:09 raghucssit

I will check these test fails.

raghucssit avatar Sep 11 '25 09:09 raghucssit

All the location assertions fails on GTK4 because in GTK4 there is no API to access window location. It is unimplemented in SWT.

	int [] x = new int [1], y = new int [1];
	if (GTK.GTK4) {
		// TODO: GTK4 GtkWindow no longer has the ability to get position
	} else {
		GTK3.gtk_window_get_position (shellHandle, x, y);
	}

Either we need to fix the test to disable assert for gtk4 or fix the Shell class with some work around to fetch the location of window.

raghucssit avatar Sep 15 '25 10:09 raghucssit

@raghucssit can we at laest report the last location that was set by the user?

laeubi avatar Sep 15 '25 10:09 laeubi

Please read https://discourse.gnome.org/t/wayland-gtk4-window-management-positioing-via-app-policy/29088/4 . Long story short - main window location is managed by and only by the compositor, all other windows are supposed to be relative to the main one.

akurtakov avatar Sep 15 '25 10:09 akurtakov

Regarding

@raghucssit can we at laest report the last location that was set by the user?

Yes. I will try this approach..

raghucssit avatar Sep 15 '25 11:09 raghucssit

Regarding failed test_setSizeCustomResize() only when custom resize(SWT.RESIZE | SWT.ON_TOP) GTK.gtk_widget_get_allocation(vboxHandle, allocation); returns incorrect window height. It reports smaller height compared to GTK3 application so it fails. However width is correct. My assumption is it is not reporting the Title Bar height in GTK4. In case of GTK4 we may need to query Title Bar height or assume something similar to fix this incorrect height reported.

raghucssit avatar Sep 15 '25 11:09 raghucssit

However both size and locations are working fine. I have manually verified changing size and location window behaves properly according to set location and dimension.

raghucssit avatar Sep 15 '25 11:09 raghucssit