From af3910289f26c6e8c2818bed9da7a192d500d1ee Mon Sep 17 00:00:00 2001 From: Simeon Andreev Date: Thu, 17 Sep 2026 11:43:11 +0300 Subject: [PATCH] Check also device native zoom in Test_org_eclipse_swt_widgets_Shell Some test methods in Test_org_eclipse_swt_widgets_Shell fail on Windows with an unexpected Shell size, where the difference is one less pixel for the Shell height. This change broadens the tolerance of 1 pixel on Shell zoom levels different than 100 to apply also if DPIUtil.getNativeDeviceZoom() returns a value which is not 100. The actual zoom value used for size computations is taken from Control.computeBoundsZoom(), which delegates to DPIUtil.getNativeDeviceZoom(). Fixes: https://github.com/eclipse-platform/eclipse.platform.swt/issues/3597 --- .../tests/junit/Test_org_eclipse_swt_widgets_Shell.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Shell.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Shell.java index bebbe450e8d..02c78a24690 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Shell.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Shell.java @@ -38,6 +38,7 @@ import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.graphics.Region; +import org.eclipse.swt.internal.DPIUtil; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -766,14 +767,14 @@ public void test_setSizeII() { Point newSize = new Point(112, 27); for (int i = 0; i < 10; i++) { testShell.setSize(newSize.x, newSize.y); - assertEquals(newSize, testShell.getSize()); + assertShellProperlySized(testShell, newSize); newSize.x += 100; newSize.y += 100; } newSize = new Point(1292, 1036); for (int i = 0; i < 10; i++) { testShell.setSize(newSize.x, newSize.y); - assertEquals(newSize, testShell.getSize()); + assertShellProperlySized(testShell, newSize); newSize.x -= 100; newSize.y -= 100; } @@ -821,8 +822,9 @@ public void test_setSizeLorg_eclipse_swt_graphics_Point() { } } +@SuppressWarnings("restriction") private void assertShellProperlySized(Shell shell, Point expectedSize) { - int tolerance = shell.getZoom() != 100 ? 1 : 0; + int tolerance = shell.getZoom() != 100 || DPIUtil.getNativeDeviceZoom() != 100 ? 1 : 0; Point actualSize = shell.getSize(); assertTrue( Math.abs(expectedSize.x - actualSize.x) <= tolerance