mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Change TestScaleHelper.setState/restoreState to @BeforeClass/@AfterClass
This commit is contained in:
@@ -32,14 +32,12 @@ import javax.swing.plaf.metal.MetalLookAndFeel
|
||||
internal val isUpdateSnapshotsGlobal by lazy { SystemPropertyUtil.getBoolean("test.update.snapshots", false) }
|
||||
|
||||
class NoScaleRule : ExternalResource() {
|
||||
private var scaleHelper = TestScaleHelper()
|
||||
|
||||
override fun before() {
|
||||
scaleHelper.setState()
|
||||
TestScaleHelper.setState()
|
||||
}
|
||||
|
||||
override fun after() {
|
||||
scaleHelper.restoreState()
|
||||
TestScaleHelper.restoreState()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.intellij.testFramework.PlatformTestUtil;
|
||||
import com.intellij.util.IconUtil;
|
||||
import com.intellij.util.ui.JBUI.ScaleContext;
|
||||
import junit.framework.TestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -22,11 +22,11 @@ import static com.intellij.util.ui.JBUI.ScaleType.USR_SCALE;
|
||||
*
|
||||
* @author tav
|
||||
*/
|
||||
@SuppressWarnings("MethodOverridesStaticMethodOfSuperclass")
|
||||
public class IconScaleTest extends TestScaleHelper {
|
||||
@Before
|
||||
@Override
|
||||
public void setState() {
|
||||
super.setState();
|
||||
@BeforeClass
|
||||
public static void setState() {
|
||||
TestScaleHelper.setState();
|
||||
setRegistryProperty("ide.svg.icon", "true");
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ public class IconScaleTest extends TestScaleHelper {
|
||||
TestCase.assertEquals("unexpected scaled icon real height", ICON_SCALED_REAL_SIZE, ImageUtil.getRealHeight(IconUtil.toImage(scaledIcon)));
|
||||
}
|
||||
|
||||
private String getIconPath() {
|
||||
private static String getIconPath() {
|
||||
return PlatformTestUtil.getPlatformTestDataPath() + "ui/abstractClass.svg";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.intellij.util.IconUtil;
|
||||
import com.intellij.util.ui.JBUI.ScaleContext;
|
||||
import com.intellij.util.ui.paint.ImageComparator;
|
||||
import com.intellij.util.ui.paint.ImageComparator.AASmootherComparator;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.awt.*;
|
||||
@@ -22,11 +22,11 @@ import static com.intellij.util.ui.JBUI.ScaleType.SYS_SCALE;
|
||||
*
|
||||
* @author tav
|
||||
*/
|
||||
@SuppressWarnings("MethodOverridesStaticMethodOfSuperclass")
|
||||
public class SvgIconPaintTest extends TestScaleHelper {
|
||||
@Before
|
||||
@Override
|
||||
public void setState() {
|
||||
super.setState();
|
||||
@BeforeClass
|
||||
public static void setState() {
|
||||
TestScaleHelper.setState();
|
||||
setRegistryProperty("ide.svg.icon", "true");
|
||||
}
|
||||
|
||||
|
||||
@@ -9,9 +9,7 @@ import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.ui.JBUI.ScaleContext;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.junit.After;
|
||||
import org.junit.Assume;
|
||||
import org.junit.Before;
|
||||
import org.junit.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
@@ -30,17 +28,17 @@ public class TestScaleHelper {
|
||||
private static final Map<String, String> originalSysProps = new HashMap<>();
|
||||
private static final Map<String, String> originalRegProps = new HashMap<>();
|
||||
|
||||
private float originalUserScale;
|
||||
private boolean originalJreHiDPIEnabled;
|
||||
private static float originalUserScale;
|
||||
private static boolean originalJreHiDPIEnabled;
|
||||
|
||||
@Before
|
||||
public void setState() {
|
||||
@BeforeClass
|
||||
public static void setState() {
|
||||
originalUserScale = JBUI.scale(1f);
|
||||
originalJreHiDPIEnabled = UIUtil.isJreHiDPIEnabled();
|
||||
}
|
||||
|
||||
@After
|
||||
public void restoreState() {
|
||||
@AfterClass
|
||||
public static void restoreState() {
|
||||
JBUI.setUserScaleFactor(originalUserScale);
|
||||
overrideJreHiDPIEnabled(originalJreHiDPIEnabled);
|
||||
restoreRegistryProperties();
|
||||
|
||||
Reference in New Issue
Block a user