Skip to content

Commit 19bd2b4

Browse files
committed
[master] - short code update
1 parent c2d7064 commit 19bd2b4

File tree

2 files changed

+27
-34
lines changed

2 files changed

+27
-34
lines changed

src/main/java/util/general/SystemHelper.java

Lines changed: 11 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,34 @@
33
import java.awt.*;
44
import java.io.File;
55
import java.lang.reflect.Field;
6-
import java.util.Arrays;
76

8-
import static environment.EnvironmentFactory.*;
97
import static util.validator.Constants.TARGET_AUTOMOTION_JSON;
108

119
public class SystemHelper {
12-
13-
public final static String[] iOS_RETINA_DEVICES = {
14-
"iPhone 4", "iPhone 4s",
15-
"iPhone 5", "iPhone 5s",
16-
"iPhone 6", "iPhone 6s",
17-
"iPad Mini 2",
18-
"iPad Mini 4",
19-
"iPad Air 2",
20-
"iPad Pro"
21-
};
22-
2310
/**
2411
* Verify is display is retina
2512
*
2613
* @return
2714
*/
2815
public static boolean isRetinaDisplay() {
2916
boolean isRetina = false;
30-
if (isMobile()) {
31-
if (isIOS()) {
32-
if (Arrays.asList(iOS_RETINA_DEVICES).contains(getDevice())) {
33-
isRetina = true;
34-
}
35-
}
36-
} else {
37-
try {
38-
GraphicsDevice graphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
17+
try {
18+
GraphicsDevice graphicsDevice = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
3919

40-
try {
41-
Field field = graphicsDevice.getClass().getDeclaredField("scale");
42-
if (field != null) {
43-
field.setAccessible(true);
44-
Object scale = field.get(graphicsDevice);
45-
if (scale instanceof Integer && (Integer) scale == 2) {
46-
isRetina = true;
47-
}
20+
try {
21+
Field field = graphicsDevice.getClass().getDeclaredField("scale");
22+
if (field != null) {
23+
field.setAccessible(true);
24+
Object scale = field.get(graphicsDevice);
25+
if (scale instanceof Integer && (Integer) scale == 2) {
26+
isRetina = true;
4827
}
49-
} catch (Exception e) {
50-
e.printStackTrace();
5128
}
5229
} catch (Exception e) {
5330
e.printStackTrace();
5431
}
32+
} catch (Exception e) {
33+
e.printStackTrace();
5534
}
5635
return isRetina;
5736
}

src/main/java/util/validator/ResponsiveUIValidator.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.*;
2020
import java.nio.charset.StandardCharsets;
2121
import java.util.ArrayList;
22+
import java.util.Arrays;
2223
import java.util.List;
2324
import java.util.Map;
2425
import java.util.concurrent.ConcurrentHashMap;
@@ -726,15 +727,28 @@ int retinaValue(int value) {
726727
}
727728
} else {
728729
if (isIOS()) {
729-
return 2 * value;
730+
String[] iOS_RETINA_DEVICES = {
731+
"iPhone 4", "iPhone 4s",
732+
"iPhone 5", "iPhone 5s",
733+
"iPhone 6", "iPhone 6s",
734+
"iPad Mini 2",
735+
"iPad Mini 4",
736+
"iPad Air 2",
737+
"iPad Pro"
738+
};
739+
if (Arrays.asList(iOS_RETINA_DEVICES).contains(getDevice())) {
740+
return 2 * value;
741+
} else {
742+
return value;
743+
}
730744
} else {
731745
return value;
732746
}
733747
}
734748
}
735749

736750
int mobileY(int value) {
737-
if (isMobile() && ((AppiumDriver)driver).getContext().startsWith("WEB")) {
751+
if (isMobile() && ((AppiumDriver) driver).getContext().startsWith("WEB")) {
738752
if (isIOS()) {
739753
if (isMobileTopBar) {
740754
return value + 20;

0 commit comments

Comments
 (0)