-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove type hierarchy of Win32AutoscaleTestBase
Auto-scale related, Windows-specific tests are currently organized in a class hierarchy based on Win32AutoscaleTestBase. This leads to unnecessarily initialized objects (e.g., shells or displays without any need for a test) and the strict necessity to use activated monitor-specific scaling in actual tests or to revert the setup logic affecting that value by hand. This change removes the Win32AutoscaleTestBase and moves the common test functionality into extensions (PlatformSpecificExecution, ResetMonitorSpecificScaling and WithMonitorSpecificScaling) as well as the utility class DPITestUtil.
- Loading branch information
1 parent
f574463
commit e0b4fe9
Showing
15 changed files
with
205 additions
and
105 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...clipse SWT Tests/win32/org/eclipse/swt/internal/ResetMonitorSpecificScalingExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Vector Informatik GmbH | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.swt.internal; | ||
|
||
import org.eclipse.swt.widgets.*; | ||
import org.junit.jupiter.api.extension.*; | ||
|
||
/** | ||
* Resets the monitor-specific scaling configuration after the test has been executed. | ||
* Disposes the default display before and after test execution. | ||
*/ | ||
public sealed class ResetMonitorSpecificScalingExtension implements BeforeEachCallback, AfterEachCallback permits WithMonitorSpecificScalingExtension { | ||
private boolean wasMonitorSpecificScalingActive; | ||
|
||
protected ResetMonitorSpecificScalingExtension() { | ||
} | ||
|
||
@Override | ||
public void beforeEach(ExtensionContext context) throws Exception { | ||
wasMonitorSpecificScalingActive = DPIUtil.isMonitorSpecificScalingActive(); | ||
Display.getDefault().dispose(); | ||
} | ||
|
||
@Override | ||
public void afterEach(ExtensionContext context) throws Exception { | ||
DPIUtil.setMonitorSpecificScaling(wasMonitorSpecificScalingActive); | ||
Display.getDefault().dispose(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...Eclipse SWT Tests/win32/org/eclipse/swt/internal/WithMonitorSpecificScalingExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2025 Vector Informatik GmbH | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*******************************************************************************/ | ||
package org.eclipse.swt.internal; | ||
|
||
import org.junit.jupiter.api.extension.*; | ||
|
||
/** | ||
* Runs a test with monitor specific scaling. Disposes the default display before and after execution. | ||
*/ | ||
public final class WithMonitorSpecificScalingExtension extends ResetMonitorSpecificScalingExtension { | ||
|
||
private WithMonitorSpecificScalingExtension() { | ||
super(); | ||
} | ||
|
||
@Override | ||
public void beforeEach(ExtensionContext context) throws Exception { | ||
super.beforeEach(context); | ||
DPIUtil.setMonitorSpecificScaling(true); | ||
} | ||
|
||
} |
Oops, something went wrong.