Skip to content

Removing getDeviceZoom from tests #2141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025

Conversation

arunjose696
Copy link
Contributor

@arunjose696 arunjose696 commented May 12, 2025

DPIUtil.get[Native]DeviceZoom() is no longer meaningful when monitor-specific scaling is used, so its usage has been removed from most tests. In some cases , these have been left unchanged for now.

Among the occurrences mentioned in Eclipse Platform Issue #195, most have been addressed. Still the following four cases remain unmodified:

1)org.eclipse.swt.tests.junit.Test_org_eclipse_swt_graphics_GC.executeWithNonDefaultDeviceZoom(Runnable)
2)org.eclipse.swt.tests.junit.DPIUtilTests.setup()
3)org.eclipse.swt.tests.junit.Test_org_eclipse_swt_graphics_Image.test_updateWidthHeightAfterDPIChange()

In these three tests, getDeviceZoom() is used to capture the zoom level before execution and restore it afterward. No suitable replacement has been identified yet.

4)org.eclipse.swt.snippets.Snippet373.main(String[])

The snippet description says it is used to to display/refresh Monitor DPI dynamically. However, it uses incorrect DPI access methods and presents a misleading example. It would be better to either remove or rewrite this snippet.

Copy link
Contributor

github-actions bot commented May 13, 2025

Test Results

   545 files  ±0     545 suites  ±0   32m 44s ⏱️ + 5m 1s
 4 399 tests ±0   4 381 ✅ ±0   18 💤 ±0  0 ❌ ±0 
16 723 runs  ±0  16 583 ✅ ±0  140 💤 ±0  0 ❌ ±0 

Results for commit 05322ef. ± Comparison against base commit d2cb26d.

♻️ This comment has been updated with latest results.

@arunjose696 arunjose696 force-pushed the arunjose696/195 branch 2 times, most recently from 42a81c2 to 93ec625 Compare May 13, 2025 12:29
@arunjose696 arunjose696 marked this pull request as ready for review May 13, 2025 13:50
@arunjose696 arunjose696 changed the title DRAFT: Removing getDeviceZoom from tests Removing getDeviceZoom from tests May 13, 2025
Copy link
Contributor

@HeikoKlare HeikoKlare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general, the changes look sound to me. The removal of the assumptions for deviceZoom being 100 in some of the tests seems not okay to me, as the tests fail on specific zooms, but maybe the assumptions themselves can be improved.

@akoch-yatta would be nice if you could still have another look to ensure that the changes are sound and that we do not degrade the tests

Comment on lines -157 to -163
if (DPIUtil.getDeviceZoom() != 100) {
//TODO Fix non integer scaling factors.
if (SwtTestUtil.verbose) {
System.out.println("Excluded test_copyAreaIIIIII(org.eclipse.swt.tests.junit.Test_org_eclipse_swt_graphics_GC)");
}
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure that this can this safely be removed, i.e, will the test run properly on with deviceZoom != 100 on every OS? When I execute this test on Windows with 175% primary monitor zoom, it fails (probably because of fractional scaling rounding errors). So maybe we should rather replace this with an according JUnit assumption but in general keep the check.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this on Windows 11 with various zoom levels (100%, 125%, 150%, 175%, 200%, and 225%) and observed that the tests passed in all cases, which is why I removed the check.
Could you share the exact error you're encountering at 175%—is it an assertion failure?
Also, are you using any specific arguments in your run configuration?

If we replace the check with a JUnit assumption, don’t we still need to call DPIUtil.getDeviceZoom()? Or is there another way to get the primary monitor’s zoom level that works across platforms?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just found that I cannot reproduce the issue with your exact branch, but when rebasing it on top of the lastest master branch state. I guess we made some adaptations since you last rebased this branch on master that affect these tests.

When executing the tests at 175% primary monitor zoom on that state, I get this error:

java.lang.AssertionError: :b: expected:<RGB {0, 0, 255}> but was:<RGB {255, 255, 255}>
	at org.junit.Assert.fail(Assert.java:89)
	at org.junit.Assert.failNotEquals(Assert.java:835)
	at org.junit.Assert.assertEquals(Assert.java:120)
	at org.eclipse.swt.tests.junit.Test_org_eclipse_swt_graphics_GC.test_copyAreaIIIIII(Test_org_eclipse_swt_graphics_GC.java:160)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)

If we replace the check with a JUnit assumption, don’t we still need to call DPIUtil.getDeviceZoom()? Or is there another way to get the primary monitor’s zoom level that works across platforms?

Yes, we would then still need to use DPIUtil.getDeviceZoom(). But our primary goal it to reevaluate all existing usages whether they can be replaced or whether they are fine and we may consider it fine to be used here as we are not in the situation that the returned value is useless because of potentially having multiple shells placed at different monitors with different zoom values on Windows (which is actually the use case in which the usage of get[Native]DeviceZoom() fails).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we may consider it fine to be used here as we are not in the situation that the returned value is useless because of potentially having multiple shells placed at different monitors with different zoom values on Windows (which is actually the use case in which the usage of get[Native]DeviceZoom() fails).

Yeah makes sense, I will modify this to junit assumptions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced the checks with junit assumption

@arunjose696 arunjose696 force-pushed the arunjose696/195 branch 3 times, most recently from 4df2bb1 to dc189d5 Compare June 4, 2025 09:27
@eclipse-platform-bot
Copy link
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

binaries/org.eclipse.swt.cocoa.macosx.aarch64/META-INF/MANIFEST.MF
binaries/org.eclipse.swt.cocoa.macosx.x86_64/META-INF/MANIFEST.MF
binaries/org.eclipse.swt.gtk.linux.aarch64/META-INF/MANIFEST.MF
binaries/org.eclipse.swt.gtk.linux.ppc64le/META-INF/MANIFEST.MF
binaries/org.eclipse.swt.gtk.linux.riscv64/META-INF/MANIFEST.MF
binaries/org.eclipse.swt.gtk.linux.x86_64/META-INF/MANIFEST.MF
binaries/org.eclipse.swt.win32.win32.aarch64/META-INF/MANIFEST.MF
binaries/org.eclipse.swt.win32.win32.x86_64/META-INF/MANIFEST.MF
bundles/org.eclipse.swt/META-INF/MANIFEST.MF
bundles/org.eclipse.swt/pom.xml
tests/org.eclipse.swt.tests/META-INF/MANIFEST.MF
tests/org.eclipse.swt.tests/pom.xml

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From d06d3dc9415a87ebf810585a6a799badecec0673 Mon Sep 17 00:00:00 2001
From: Eclipse Platform Bot <platform-bot@eclipse.org>
Date: Wed, 4 Jun 2025 09:33:43 +0000
Subject: [PATCH] Version bump(s) for 4.37 stream


diff --git a/binaries/org.eclipse.swt.cocoa.macosx.aarch64/META-INF/MANIFEST.MF b/binaries/org.eclipse.swt.cocoa.macosx.aarch64/META-INF/MANIFEST.MF
index f0c077d7b7..d7f858f9fc 100644
--- a/binaries/org.eclipse.swt.cocoa.macosx.aarch64/META-INF/MANIFEST.MF
+++ b/binaries/org.eclipse.swt.cocoa.macosx.aarch64/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
 Bundle-Name: %fragmentName
 Bundle-Vendor: %providerName
 Bundle-SymbolicName: org.eclipse.swt.cocoa.macosx.aarch64; singleton:=true
-Bundle-Version: 3.130.0.qualifier
+Bundle-Version: 3.130.100.qualifier
 Bundle-ManifestVersion: 2
 Bundle-Localization: fragment
 Export-Package: 
diff --git a/binaries/org.eclipse.swt.cocoa.macosx.x86_64/META-INF/MANIFEST.MF b/binaries/org.eclipse.swt.cocoa.macosx.x86_64/META-INF/MANIFEST.MF
index 419888cf1f..5a17d4680d 100644
--- a/binaries/org.eclipse.swt.cocoa.macosx.x86_64/META-INF/MANIFEST.MF
+++ b/binaries/org.eclipse.swt.cocoa.macosx.x86_64/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
 Bundle-Name: %fragmentName
 Bundle-Vendor: %providerName
 Bundle-SymbolicName: org.eclipse.swt.cocoa.macosx.x86_64; singleton:=true
-Bundle-Version: 3.130.0.qualifier
+Bundle-Version: 3.130.100.qualifier
 Bundle-ManifestVersion: 2
 Bundle-Localization: fragment
 Export-Package: 
diff --git a/binaries/org.eclipse.swt.gtk.linux.aarch64/META-INF/MANIFEST.MF b/binaries/org.eclipse.swt.gtk.linux.aarch64/META-INF/MANIFEST.MF
index 68dc81c489..777a307ca7 100644
--- a/binaries/org.eclipse.swt.gtk.linux.aarch64/META-INF/MANIFEST.MF
+++ b/binaries/org.eclipse.swt.gtk.linux.aarch64/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
 Bundle-Name: %fragmentName
 Bundle-Vendor: %providerName
 Bundle-SymbolicName: org.eclipse.swt.gtk.linux.aarch64; singleton:=true
-Bundle-Version: 3.130.0.qualifier
+Bundle-Version: 3.130.100.qualifier
 Bundle-ManifestVersion: 2
 Bundle-Localization: fragment
 Export-Package: 
diff --git a/binaries/org.eclipse.swt.gtk.linux.ppc64le/META-INF/MANIFEST.MF b/binaries/org.eclipse.swt.gtk.linux.ppc64le/META-INF/MANIFEST.MF
index 11f0c5be90..b88e2ba4d3 100644
--- a/binaries/org.eclipse.swt.gtk.linux.ppc64le/META-INF/MANIFEST.MF
+++ b/binaries/org.eclipse.swt.gtk.linux.ppc64le/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
 Bundle-Name: %fragmentName
 Bundle-Vendor: %providerName
 Bundle-SymbolicName: org.eclipse.swt.gtk.linux.ppc64le;singleton:=true
-Bundle-Version: 3.130.0.qualifier
+Bundle-Version: 3.130.100.qualifier
 Bundle-ManifestVersion: 2
 Bundle-Localization: fragment
 Export-Package: 
diff --git a/binaries/org.eclipse.swt.gtk.linux.riscv64/META-INF/MANIFEST.MF b/binaries/org.eclipse.swt.gtk.linux.riscv64/META-INF/MANIFEST.MF
index 66ace1ae97..2702b8f745 100644
--- a/binaries/org.eclipse.swt.gtk.linux.riscv64/META-INF/MANIFEST.MF
+++ b/binaries/org.eclipse.swt.gtk.linux.riscv64/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
 Bundle-Name: %fragmentName
 Bundle-Vendor: %providerName
 Bundle-SymbolicName: org.eclipse.swt.gtk.linux.riscv64; singleton:=true
-Bundle-Version: 3.130.0.qualifier
+Bundle-Version: 3.130.100.qualifier
 Bundle-ManifestVersion: 2
 Bundle-Localization: fragment
 Export-Package: 
diff --git a/binaries/org.eclipse.swt.gtk.linux.x86_64/META-INF/MANIFEST.MF b/binaries/org.eclipse.swt.gtk.linux.x86_64/META-INF/MANIFEST.MF
index b492e62cfb..748d9b1460 100644
--- a/binaries/org.eclipse.swt.gtk.linux.x86_64/META-INF/MANIFEST.MF
+++ b/binaries/org.eclipse.swt.gtk.linux.x86_64/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
 Bundle-Name: %fragmentName
 Bundle-Vendor: %providerName
 Bundle-SymbolicName: org.eclipse.swt.gtk.linux.x86_64; singleton:=true
-Bundle-Version: 3.130.0.qualifier
+Bundle-Version: 3.130.100.qualifier
 Bundle-ManifestVersion: 2
 Bundle-Localization: fragment
 Export-Package: 
diff --git a/binaries/org.eclipse.swt.win32.win32.aarch64/META-INF/MANIFEST.MF b/binaries/org.eclipse.swt.win32.win32.aarch64/META-INF/MANIFEST.MF
index 3a0115e28e..b7689042cf 100644
--- a/binaries/org.eclipse.swt.win32.win32.aarch64/META-INF/MANIFEST.MF
+++ b/binaries/org.eclipse.swt.win32.win32.aarch64/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
 Bundle-Name: %fragmentName
 Bundle-Vendor: %providerName
 Bundle-SymbolicName: org.eclipse.swt.win32.win32.aarch64; singleton:=true
-Bundle-Version: 3.130.0.qualifier
+Bundle-Version: 3.130.100.qualifier
 Bundle-ManifestVersion: 2
 Bundle-Localization: fragment
 Export-Package: 
diff --git a/binaries/org.eclipse.swt.win32.win32.x86_64/META-INF/MANIFEST.MF b/binaries/org.eclipse.swt.win32.win32.x86_64/META-INF/MANIFEST.MF
index 3cb81ab476..e9aeafceb9 100644
--- a/binaries/org.eclipse.swt.win32.win32.x86_64/META-INF/MANIFEST.MF
+++ b/binaries/org.eclipse.swt.win32.win32.x86_64/META-INF/MANIFEST.MF
@@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
 Bundle-Name: %fragmentName
 Bundle-Vendor: %providerName
 Bundle-SymbolicName: org.eclipse.swt.win32.win32.x86_64; singleton:=true
-Bundle-Version: 3.130.0.qualifier
+Bundle-Version: 3.130.100.qualifier
 Bundle-ManifestVersion: 2
 Bundle-Localization: fragment
 Export-Package: 
diff --git a/bundles/org.eclipse.swt/META-INF/MANIFEST.MF b/bundles/org.eclipse.swt/META-INF/MANIFEST.MF
index 6c6497fbe6..a84fd767e9 100644
--- a/bundles/org.eclipse.swt/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.swt/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-Name: %pluginName
 Bundle-Vendor: %providerName
 Bundle-SymbolicName: org.eclipse.swt; singleton:=true
-Bundle-Version: 3.130.0.qualifier
+Bundle-Version: 3.130.100.qualifier
 Bundle-ManifestVersion: 2
 Bundle-Localization: plugin
 DynamicImport-Package: org.eclipse.swt.accessibility2
diff --git a/bundles/org.eclipse.swt/pom.xml b/bundles/org.eclipse.swt/pom.xml
index 6245a320f4..29756220ef 100644
--- a/bundles/org.eclipse.swt/pom.xml
+++ b/bundles/org.eclipse.swt/pom.xml
@@ -20,7 +20,7 @@
         <relativePath>../../</relativePath>
     </parent>
     <artifactId>org.eclipse.swt</artifactId>
-    <version>3.130.0-SNAPSHOT</version>
+    <version>3.130.100-SNAPSHOT</version>
     <packaging>eclipse-plugin</packaging>
 
     <properties>
diff --git a/tests/org.eclipse.swt.tests/META-INF/MANIFEST.MF b/tests/org.eclipse.swt.tests/META-INF/MANIFEST.MF
index 96ea2c1aad..cf91c273eb 100644
--- a/tests/org.eclipse.swt.tests/META-INF/MANIFEST.MF
+++ b/tests/org.eclipse.swt.tests/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: Eclipse SWT Tests
 Bundle-SymbolicName: org.eclipse.swt.tests
-Bundle-Version: 3.107.800.qualifier
+Bundle-Version: 3.107.900.qualifier
 Bundle-Vendor: Eclipse.org
 Export-Package: org.eclipse.swt.tests.junit,
  org.eclipse.swt.tests.junit.performance
diff --git a/tests/org.eclipse.swt.tests/pom.xml b/tests/org.eclipse.swt.tests/pom.xml
index 26aca88ede..702d75c383 100644
--- a/tests/org.eclipse.swt.tests/pom.xml
+++ b/tests/org.eclipse.swt.tests/pom.xml
@@ -20,7 +20,7 @@
     <relativePath>../../local-build/local-build-parent/</relativePath>
   </parent>
   <artifactId>org.eclipse.swt.tests</artifactId>
-  <version>3.107.800-SNAPSHOT</version>
+  <version>3.107.900-SNAPSHOT</version>
   <packaging>eclipse-test-plugin</packaging>
   <properties>
     <tycho.testArgLine></tycho.testArgLine>
-- 
2.49.0

Further information are available in Common Build Issues - Missing version increments.

…nd tests

The DPIUtil.get[Native]DeviceZoom() has no
proper meaning when using monitor-specific scaling.
@HeikoKlare HeikoKlare merged commit 4862ef8 into eclipse-platform:master Jun 10, 2025
17 checks passed
@HeikoKlare HeikoKlare deleted the arunjose696/195 branch June 10, 2025 08:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Replace DPIUtil::get(Native)DeviceZoom() calls for all the snippets and tests
3 participants