@@ -48,7 +48,7 @@ public void testScaleFontCorrectlyInNoAutoScaleSzenario() {
4848 DPIUtil .setMonitorSpecificScaling (false );
4949 Display display = Display .getDefault ();
5050
51- assertTrue ("Autoscale property is not set to true" , display .isRescalingAtRuntime ());
51+ assertFalse ("Autoscale property is not set to true" , display .isRescalingAtRuntime ());
5252 int scalingFactor = 2 ;
5353 FontComparison fontComparison = updateFont (scalingFactor );
5454 assertEquals ("Font height in pixels is not adjusted according to the scale factor" ,
@@ -58,14 +58,27 @@ public void testScaleFontCorrectlyInNoAutoScaleSzenario() {
5858 @ Test
5959 public void testDoNotScaleFontCorrectlyInNoAutoScaleSzenarioWithLegacyFontRegistry () {
6060 DPIUtil .setMonitorSpecificScaling (false );
61+ String originalValue = System .getProperty ("swt.fontRegistry" );
6162 System .setProperty ("swt.fontRegistry" , "LEGACY" );
62- Display display = Display .getDefault ();
63+ try {
64+ Display display = Display .getDefault ();
65+
66+ assertFalse ("Autoscale property is not set to false" , display .isRescalingAtRuntime ());
67+ int scalingFactor = 2 ;
68+ FontComparison fontComparison = updateFont (scalingFactor );
69+ assertEquals ("Font height in pixels is different when setting the same font again" ,
70+ fontComparison .originalFontHeight , fontComparison .currentFontHeight );
71+
72+
73+ }
74+ finally {
75+ if (originalValue != null ) {
76+ System .setProperty ("swt.fontRegistry" , originalValue );
77+ } else {
78+ System .clearProperty ("swt.fontRegistry" );
79+ }
80+ }
6381
64- assertFalse ("Autoscale property is not set to false" , display .isRescalingAtRuntime ());
65- int scalingFactor = 2 ;
66- FontComparison fontComparison = updateFont (scalingFactor );
67- assertEquals ("Font height in pixels is different when setting the same font again" ,
68- fontComparison .originalFontHeight , fontComparison .currentFontHeight );
6982 }
7083
7184 @ Test
0 commit comments