Skip to content

[Win32] Add test case to check auto-scaling mode calculation#3040

Merged
HeikoKlare merged 1 commit intoeclipse-platform:masterfrom
ptziegler:fix-auto-scaling-mode
Feb 6, 2026
Merged

[Win32] Add test case to check auto-scaling mode calculation#3040
HeikoKlare merged 1 commit intoeclipse-platform:masterfrom
ptziegler:fix-auto-scaling-mode

Conversation

@ptziegler
Copy link
Contributor

@ptziegler ptziegler commented Jan 31, 2026

This adds test cases to check that the auto-scaling mode is correctly read from the widget data and correctly propagated to child widgets.

@ptziegler ptziegler force-pushed the fix-auto-scaling-mode branch from 08a0b17 to 0bf9106 Compare January 31, 2026 10:01
@ptziegler ptziegler marked this pull request as draft January 31, 2026 10:09
@github-actions
Copy link
Contributor

github-actions bot commented Jan 31, 2026

Test Results (win32)

   34 files  ±0     34 suites  ±0   4m 46s ⏱️ -42s
4 644 tests +4  4 571 ✅ +4  73 💤 ±0  0 ❌ ±0 
  174 runs  +4    171 ✅ +4   3 💤 ±0  0 ❌ ±0 

Results for commit e9bfbfb. ± Comparison against base commit 8dcdeab.

♻️ This comment has been updated with latest results.

@ptziegler ptziegler force-pushed the fix-auto-scaling-mode branch from 0bf9106 to 997d81f Compare January 31, 2026 10:18
@ptziegler ptziegler changed the title [Win32] Fix incorrect calculation of auto-scaling mode [Win32] Add test case to check auto-scaling mode calculation Jan 31, 2026
@ptziegler ptziegler marked this pull request as ready for review January 31, 2026 10:19
Comment on lines 41 to 44
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 think this is what really confused me when debugging a related problem. I've double-checked this with how things used to behave prior to 2166ca6 and that's it. It probably still makes sense to keep those tests, just to avoid any further confusion.

@Phillipus
Copy link
Contributor

Phillipus commented Feb 1, 2026

If there is a Control.setAutoscalingMode(mode)then a corresponding Control.getAutoscalingMode() method would be useful. Was this a design decision? As you found, this would be a handy thing.

@HeikoKlare
Copy link
Contributor

If there is a Control.setAutoscalingMode(mode)then a corresponding Control.getAutoscalingMode() method would be useful. Was this a design decision? As you found, this would be a handy thing.

When the autoscale disablement API was introduced, the existing isAutoScalable() method has been overwritten. Due to several side effects we found in the last few weeks, we reverted that change:

We though about providing a replacement method, next to the existing one, but that may obviously lead to confusion as there are two independent methods to retrieve some auto-scale-related state. For that reason, we chose to not provide such a method unless there is an actual use case for it. Do you have such?

@Phillipus
Copy link
Contributor

unless there is an actual use case for it. Do you have such?

At the moment just to see what's going on to implement a workaround for eclipse-gef/gef-classic#977

@ptziegler ptziegler force-pushed the fix-auto-scaling-mode branch from 997d81f to 0824bc5 Compare February 2, 2026 10:00
@ptziegler
Copy link
Contributor Author

To be honest, I don't see any benefit to adding a public getter method. And the only reason I haven't closed this one is because I think unit-tests for the propagation of the auto-scaling mode are useful.

Regarding eclipse-gef/gef-classic#977, I don't think that a getter is of any use. The interesting part is the nativeZoom field of the GC object. But that, one can already get via getGCData().nativeZoom, at least for the sake of debugging.

@ptziegler ptziegler force-pushed the fix-auto-scaling-mode branch 3 times, most recently from 611368c to 69c48ca Compare February 5, 2026 07:56
@HeikoKlare
Copy link
Contributor

To be honest, I don't see any benefit to adding a public getter method. And the only reason I haven't closed this one is because I think unit-tests for the propagation of the auto-scaling mode are useful.

Thank you for the feedback. If you come along a use case that requries a getter, we can still add it. I also consider the tests added here as useful though.

One possibility to avoid that reflective access is to make unit tests out of the added API-level tests: for Windows we have unit tests embedded in the SWT bundle/fragment itself, which can then access state and functionality that is not public API (such as the autoscalingMode field). @ptziegler do think the tests should stay API-level tests as they currently are (then we can merge this one as is) or should we transform them to unit tests without reflective access (I can do that and update the PR if you want).

@ptziegler ptziegler force-pushed the fix-auto-scaling-mode branch from 69c48ca to 3bab419 Compare February 6, 2026 10:12
@ptziegler
Copy link
Contributor Author

One possibility to avoid that reflective access is to make unit tests out of the added API-level tests: for Windows we have unit tests embedded in the SWT bundle/fragment itself, which can then access state and functionality that is not public API (such as the autoscalingMode field).

Moving them to the bundle sounds like the cleaner approach. I've updated the PR and now they are part of the ControlWin32Tests.

This adds test cases to check that the auto-scaling mode is correctly
read from the widget data and correctly propagated to child widgets.
@ptziegler ptziegler force-pushed the fix-auto-scaling-mode branch from 3bab419 to e9bfbfb Compare February 6, 2026 10:16
@Test
public void testAutoScaleDisabledProperty() {
Display display = Display.getDefault();
Shell shell = new Shell(display);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I understand this test case correctly then the Shell is automatically disposed after the test run, due to the ResetMonitorSpecificScalingExtension?

Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed. The extension disposes the display and with it the shell.

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.

Thank you for the update. Great to have those tests, and even in such a clean way now.

@HeikoKlare HeikoKlare merged commit 7a03c60 into eclipse-platform:master Feb 6, 2026
17 checks passed
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.

3 participants

Comments