Skip to content
This repository was archived by the owner on Dec 7, 2020. It is now read-only.

Commit 253beec

Browse files
author
Severi Haverila
committed
remove unrelated code
1 parent 433adc7 commit 253beec

File tree

1 file changed

+0
-102
lines changed

1 file changed

+0
-102
lines changed

src/main/java/TestdroidImageRecognition.java

Lines changed: 0 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@
2020
public class TestdroidImageRecognition extends AbstractAppiumTest {
2121

2222
public Logger logger = LoggerFactory.getLogger(TestdroidImageRecognition.class);
23-
24-
AkazeImageFinder imageFinder = new AkazeImageFinder();
25-
2623
private String queryImageSubFolder = "";
27-
public boolean found = false;
2824

2925

3026
//If this method is called inside a test the script will check if the device has a resolution lower than 500x500 and if so will use
@@ -37,14 +33,6 @@ public void setQueryImageFolder() {
3733
}
3834
}
3935

40-
41-
/**
42-
* ======================================================================================
43-
* FINDING AN IMAGE ON SCREEN
44-
* ======================================================================================
45-
*/
46-
47-
4836
public Point[] findImageOnScreen(String image) throws Exception {
4937
ImageRecognitionSettingsDTO defaultSettings = new ImageRecognitionSettingsDTO();
5038
return findImageOnScreen(image, defaultSettings).getImageRectangle();
@@ -69,18 +57,6 @@ public void waitForImageToDisappearFromScreen(String image) throws Exception {
6957
assert(hasImageDisappeared);
7058
}
7159

72-
73-
74-
75-
76-
/**
77-
* ======================================================================================
78-
* ADB UTILITIES
79-
* ======================================================================================
80-
*/
81-
82-
83-
//Uses adb commands to get the screen size. To be used when appium methods fail. Only works on Android devices.
8460
public Dimension getScreenSize() throws Exception {
8561
log("trying to get size from adb...");
8662
log("------------------------------");
@@ -91,7 +67,6 @@ public Dimension getScreenSize() throws Exception {
9167
}
9268
}
9369

94-
9570
private Dimension getAndroidScreenSize() throws IOException, InterruptedException {
9671
String adb = "adb";
9772
String[] adbCommand = {adb, "shell", "dumpsys", "window"};
@@ -117,54 +92,6 @@ private Dimension getAndroidScreenSize() throws IOException, InterruptedExceptio
11792
return screenSize;
11893
}
11994

120-
public boolean findDeviceTypeADB() throws Exception {
121-
log("trying to find device type ...");
122-
log("------------------------------");
123-
if (platformName.equalsIgnoreCase("iOS")) {
124-
//TO Be added
125-
} else {
126-
String adb = "adb";
127-
String[] adbCommand = {adb, "shell", "getprop", "ro.build.characteristics"};
128-
try {
129-
ProcessBuilder p = new ProcessBuilder(adbCommand);
130-
Process proc = p.start();
131-
InputStream stdin = proc.getInputStream();
132-
InputStreamReader isr = new InputStreamReader(stdin);
133-
BufferedReader br = new BufferedReader(isr);
134-
String line = null;
135-
String[] size = null;
136-
while ((line = br.readLine()) != null) {
137-
if (line.contains("tablet")) {
138-
return true;
139-
}
140-
141-
}
142-
} catch (Throwable t) {
143-
t.printStackTrace();
144-
}
145-
}
146-
return false;
147-
}
148-
149-
public void processBuilder(String[] adbCommand) {
150-
try {
151-
found = true;
152-
ProcessBuilder p = new ProcessBuilder(adbCommand);
153-
Process proc = p.start();
154-
InputStream stdin = proc.getInputStream();
155-
InputStreamReader isr = new InputStreamReader(stdin);
156-
BufferedReader br = new BufferedReader(isr);
157-
String line = null;
158-
while ((line = br.readLine()) != null)
159-
System.out.print(line);
160-
161-
proc.waitFor();
162-
163-
} catch (Throwable t) {
164-
found = false;
165-
t.printStackTrace();
166-
}
167-
}
16895

16996
public String grabTextFromImage(String image) throws Exception {
17097
ImageRecognitionSettingsDTO settings = new ImageRecognitionSettingsDTO();
@@ -173,35 +100,6 @@ public String grabTextFromImage(String image) throws Exception {
173100
String text = ImageRecognition.getTextStringFromImage(imageSearch.getScreenshotFile());
174101
return text;
175102
}
176-
177-
178-
179103

180-
181-
182-
/**
183-
* ======================================================================================
184-
* OTHER UTILITIES
185-
* ======================================================================================
186-
*/
187-
188-
//TODO: experimental method
189-
public Point correctAndroidCoordinates(Point appium_coord) throws Exception {
190-
191-
Dimension appium_dimensions = driver.manage().window().getSize();
192-
int appium_screenWidth = appium_dimensions.getWidth();
193-
int appium_screenHeight = appium_dimensions.getHeight();
194-
195-
Dimension adb_dimension = getScreenSize();
196-
int adb_screenWidth = adb_dimension.getWidth();
197-
int adb_screenHeight = adb_dimension.getHeight();
198-
199-
double x_offset = appium_coord.x / appium_screenWidth;
200-
double y_offset = appium_coord.y / appium_screenHeight;
201-
log("x_offset is : " + x_offset);
202-
log("y_offset is : " + y_offset);
203-
204-
return new Point(x_offset * adb_screenWidth, y_offset * adb_screenHeight);
205-
}
206104

207105
}

0 commit comments

Comments
 (0)