37
37
public class DPIUtilTests {
38
38
39
39
private int deviceZoom ;
40
+ private static final int ZOOM_200 = 200 ;
40
41
41
42
@ BeforeEach
42
43
public void setup () {
43
44
deviceZoom = DPIUtil .getDeviceZoom ();
44
- DPIUtil .setDeviceZoom (200 );
45
+ DPIUtil .setDeviceZoom (ZOOM_200 );
45
46
}
46
47
47
48
@ AfterEach
@@ -57,10 +58,10 @@ public void scaleDownFloatArray() {
57
58
58
59
float [] scaledValue = DPIUtil .autoScaleDown (valueAt200 );
59
60
assertArrayEquals (valueAt100 , scaledValue , .001f , String .format ("Scaling down float array from device zoom (%d) to 100 failed" ,
60
- DPIUtil . getDeviceZoom () ));
61
+ ZOOM_200 ));
61
62
scaledValue = DPIUtil .autoScaleDown ((Device ) null , valueAt200 );
62
63
assertArrayEquals (valueAt100 , scaledValue , .001f , String .format ("Scaling down float array from device zoom (%d) to 100 with device failed" ,
63
- DPIUtil . getDeviceZoom () ));
64
+ ZOOM_200 ));
64
65
65
66
scaledValue = DPIUtil .scaleDown (valueAt200 , 200 );
66
67
assertArrayEquals (valueAt100 , scaledValue , .001f , "Scaling down float array from 200 failed" );
@@ -84,10 +85,10 @@ public void scaleDownInteger() {
84
85
85
86
int scaledValue = DPIUtil .autoScaleDown (valueAt200 );
86
87
assertEquals (
87
- valueAt100 , scaledValue , String .format ("Scaling down integer from device zoom (%d) to 100 failed" , DPIUtil . getDeviceZoom () ));
88
+ valueAt100 , scaledValue , String .format ("Scaling down integer from device zoom (%d) to 100 failed" , ZOOM_200 ));
88
89
scaledValue = DPIUtil .autoScaleDown ((Device ) null , valueAt200 );
89
90
assertEquals (
90
- valueAt100 , scaledValue , String .format ("Scaling down integer from device zoom (%d) to 100 with device failed" , DPIUtil . getDeviceZoom () ));
91
+ valueAt100 , scaledValue , String .format ("Scaling down integer from device zoom (%d) to 100 with device failed" , ZOOM_200 ));
91
92
92
93
scaledValue = DPIUtil .scaleDown (valueAt200 , 200 );
93
94
assertEquals (valueAt100 , scaledValue , "Scaling down integer from 200 failed" );
@@ -111,10 +112,10 @@ public void scaleDownFloat() {
111
112
112
113
float scaledValue = DPIUtil .autoScaleDown (valueAt200 );
113
114
assertEquals (valueAt100 , scaledValue , .001f ,
114
- String .format ("Scaling down float from device zoom (%d) to 100 failed" , DPIUtil . getDeviceZoom () ));
115
+ String .format ("Scaling down float from device zoom (%d) to 100 failed" , ZOOM_200 ));
115
116
scaledValue = DPIUtil .autoScaleDown ((Device ) null , valueAt200 );
116
117
assertEquals (valueAt100 , scaledValue , .001f , String
117
- .format ("Scaling down float from device zoom (%d) to 100 with device failed" , DPIUtil . getDeviceZoom () ));
118
+ .format ("Scaling down float from device zoom (%d) to 100 with device failed" , ZOOM_200 ));
118
119
119
120
scaledValue = DPIUtil .scaleDown (valueAt200 , 200 );
120
121
assertEquals (valueAt100 , scaledValue , .001f , "Scaling down float from 200 failed" );
@@ -138,10 +139,10 @@ public void scaleDownPoint() {
138
139
139
140
Point scaledValue = DPIUtil .autoScaleDown (valueAt200 );
140
141
assertEquals (valueAt100 , scaledValue ,
141
- String .format ("Scaling down Point from device zoom (%d) to 100 failed" , DPIUtil . getDeviceZoom () ));
142
+ String .format ("Scaling down Point from device zoom (%d) to 100 failed" , ZOOM_200 ));
142
143
scaledValue = DPIUtil .autoScaleDown ((Device ) null , valueAt200 );
143
144
assertEquals (valueAt100 , scaledValue , String
144
- .format ("Scaling down Point from device zoom (%d) to 100 with device failed" , DPIUtil . getDeviceZoom () ));
145
+ .format ("Scaling down Point from device zoom (%d) to 100 with device failed" , ZOOM_200 ));
145
146
146
147
scaledValue = DPIUtil .scaleDown (valueAt200 , 200 );
147
148
assertEquals (valueAt100 , scaledValue , "Scaling down Point from 200 failed" );
@@ -165,10 +166,10 @@ public void scaleDownRectangle() {
165
166
166
167
Rectangle scaledValue = DPIUtil .autoScaleDown (valueAt200 );
167
168
assertEquals (valueAt100 , scaledValue ,
168
- String .format ("Scaling down Rectangle from device zoom (%d) to 100 failed" , DPIUtil . getDeviceZoom () ));
169
+ String .format ("Scaling down Rectangle from device zoom (%d) to 100 failed" , ZOOM_200 ));
169
170
scaledValue = DPIUtil .autoScaleDown ((Device ) null , valueAt200 );
170
171
assertEquals (valueAt100 , scaledValue , String .format (
171
- "Scaling down Rectangle from device zoom (%d) to 100 with device failed" , DPIUtil . getDeviceZoom () ));
172
+ "Scaling down Rectangle from device zoom (%d) to 100 with device failed" , ZOOM_200 ));
172
173
173
174
scaledValue = DPIUtil .scaleDown (valueAt200 , 200 );
174
175
assertEquals (valueAt100 , scaledValue , "Scaling down Rectangle from 200 failed" );
@@ -192,10 +193,10 @@ public void scaleUpIntArray() {
192
193
193
194
int [] scaledValue = DPIUtil .autoScaleUp (valueAt100 );
194
195
assertArrayEquals (valueAt200 , scaledValue ,
195
- String .format ("Scaling up int array to device zoom (%d) to 100 failed" , DPIUtil . getDeviceZoom () ));
196
+ String .format ("Scaling up int array to device zoom (%d) to 100 failed" , ZOOM_200 ));
196
197
scaledValue = DPIUtil .autoScaleUp ((Device ) null , valueAt100 );
197
198
assertArrayEquals (valueAt200 , scaledValue , String
198
- .format ("Scaling up int array to device zoom (%d) to 100 with device failed" , DPIUtil . getDeviceZoom () ));
199
+ .format ("Scaling up int array to device zoom (%d) to 100 with device failed" , ZOOM_200 ));
199
200
200
201
scaledValue = DPIUtil .scaleUp (valueAt100 , 200 );
201
202
assertArrayEquals (valueAt200 , scaledValue , "Scaling up int array to 200 failed" );
@@ -219,10 +220,10 @@ public void scaleUpInteger() {
219
220
220
221
int scaledValue = DPIUtil .autoScaleUp (valueAt100 );
221
222
assertEquals (valueAt200 , scaledValue ,
222
- String .format ("Scaling up integer to device zoom (%d) to 100 failed" , DPIUtil . getDeviceZoom () ));
223
+ String .format ("Scaling up integer to device zoom (%d) to 100 failed" , ZOOM_200 ));
223
224
scaledValue = DPIUtil .autoScaleUp ((Device ) null , valueAt100 );
224
225
assertEquals (valueAt200 , scaledValue , String
225
- .format ("Scaling up integer to device zoom (%d) to 100 with device failed" , DPIUtil . getDeviceZoom () ));
226
+ .format ("Scaling up integer to device zoom (%d) to 100 with device failed" , ZOOM_200 ));
226
227
227
228
scaledValue = DPIUtil .scaleUp (valueAt100 , 200 );
228
229
assertEquals (valueAt200 , scaledValue , "Scaling up integer to 200 failed" );
@@ -246,10 +247,10 @@ public void scaleUpFloat() {
246
247
247
248
float scaledValue = DPIUtil .autoScaleUp (valueAt100 );
248
249
assertEquals (valueAt200 , scaledValue , 0.001f ,
249
- String .format ("Scaling up integer to device zoom (%d) to 100 failed" , DPIUtil . getDeviceZoom () ));
250
+ String .format ("Scaling up integer to device zoom (%d) to 100 failed" , ZOOM_200 ));
250
251
scaledValue = DPIUtil .autoScaleUp ((Device ) null , valueAt100 );
251
252
assertEquals (valueAt200 , scaledValue , 0.001f , String
252
- .format ("Scaling up integer to device zoom (%d) to 100 with device failed" , DPIUtil . getDeviceZoom () ));
253
+ .format ("Scaling up integer to device zoom (%d) to 100 with device failed" , ZOOM_200 ));
253
254
254
255
scaledValue = DPIUtil .scaleUp (valueAt100 , 200 );
255
256
assertEquals (valueAt200 , scaledValue , 0.001f , "Scaling up integer to 200 failed" );
@@ -273,10 +274,10 @@ public void scaleUpPoint() {
273
274
274
275
Point scaledValue = DPIUtil .autoScaleUp (valueAt100 );
275
276
assertEquals (valueAt200 , scaledValue ,
276
- String .format ("Scaling up Point to device zoom (%d) to 100 failed" , DPIUtil . getDeviceZoom () ));
277
+ String .format ("Scaling up Point to device zoom (%d) to 100 failed" , ZOOM_200 ));
277
278
scaledValue = DPIUtil .autoScaleUp ((Device ) null , valueAt100 );
278
279
assertEquals (valueAt200 , scaledValue , String
279
- .format ("Scaling up Point to device zoom (%d) to 100 with device failed" , DPIUtil . getDeviceZoom () ));
280
+ .format ("Scaling up Point to device zoom (%d) to 100 with device failed" , ZOOM_200 ));
280
281
281
282
scaledValue = DPIUtil .scaleUp (valueAt100 , 200 );
282
283
assertEquals (valueAt200 , scaledValue , "Scaling up Point to 200 failed" );
@@ -300,10 +301,10 @@ public void scaleUpRectangle() {
300
301
301
302
Rectangle scaledValue = DPIUtil .autoScaleUp (valueAt100 );
302
303
assertEquals (valueAt200 , scaledValue ,
303
- String .format ("Scaling up Rectangle to device zoom (%d) to 100 failed" , DPIUtil . getDeviceZoom () ));
304
+ String .format ("Scaling up Rectangle to device zoom (%d) to 100 failed" , ZOOM_200 ));
304
305
scaledValue = DPIUtil .autoScaleUp ((Device ) null , valueAt100 );
305
306
assertEquals (valueAt200 , scaledValue , String
306
- .format ("Scaling up Rectangle to device zoom (%d) to 100 with device failed" , DPIUtil . getDeviceZoom () ));
307
+ .format ("Scaling up Rectangle to device zoom (%d) to 100 with device failed" , ZOOM_200 ));
307
308
308
309
scaledValue = DPIUtil .scaleUp (valueAt100 , 200 );
309
310
assertEquals (valueAt200 , scaledValue , "Scaling up Rectangle to 200 failed" );
0 commit comments