Testing projects with SWT at different zoom levels #2977
-
|
This is a problem I ran into while investigating eclipse-gef/gef-classic#945. The height of a font (obviously) depends on the native monitor zoom. But the GitHub tests all run at 100% monitor zoom, so it's difficult to write regression tests for such behavior. Is there any way to tell SWT to execute tests as if at e.g. 125% monitor zoom? I tried a similar approach to #2967 and am currently stuck setting |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Unfortunately, there is no good way to test with different monitor zoom yet. We have also discussed this quite often as we desperately need it to avoid regressions, but it's not that simple. So that is only possible in Win32-specific tests with a utility class in the And even with such a utility, what you can test with it is really limited. The scaling capabilities are rather tighly coupled to what the OS is doing underneath (DPI information and events, font scaling etc.), which is almost impossible to adapt or mock. So as long as we rely on the adoption of the Win32 library/controls, I currently don't see any way of properly testing with other zooms than actually changing the environment settings (i.e., change the zoom of your primary monitor, the Jenkins agent or whatever the test is running on). |
Beta Was this translation helpful? Give feedback.
-
|
Unfortunately, there is no good way to test with different monitor zoom yet. We have also discussed this quite often as we desperately need it to avoid regressions, but it's not that simple. So that is only possible in Win32-specific tests with a utility class in the
Using And even with such a utility as mentioned above, what you can test with it is really limited. The scaling capabilities are rather tighly coupled to what the OS is doing underneath (DPI information and events, font scaling etc.), which is almost impossible to adapt or mock. So as long as we rely on the adoption of the Win32 library/controls, I currently don't see any way of properly testing with other zooms than actually changing the environment settings (i.e., change the zoom of your primary monitor, the Jenkins agent or whatever the test is running on). |
Beta Was this translation helpful? Give feedback.
Unfortunately, there is no good way to test with different monitor zoom yet. We have also discussed this quite often as we desperately need it to avoid regressions, but it's not that simple.
There is a test utility which does something in the direction you want, but it is Windows-only and requries access to package-protected methods:
eclipse.platform.swt/bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/widgets/DPITestUtil.java
Lines 29 to 35 in e640660