mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-20 11:58:55 +00:00
BaseUiAutomation: Added functions for checking version strings
Added splitVersion and compareVersions functions allow versions strings like "3.2.045" to be compared. Also fixed the build script to now copy to the correct folder
This commit is contained in:
parent
544c498eb6
commit
46cd26e774
Binary file not shown.
2
wlauto/external/uiauto/build.sh
vendored
2
wlauto/external/uiauto/build.sh
vendored
@ -18,4 +18,4 @@
|
||||
|
||||
ant build
|
||||
|
||||
cp bin/classes/com/arm/wlauto/uiauto/BaseUiAutomation.class ../../common
|
||||
cp bin/classes/com/arm/wlauto/uiauto/BaseUiAutomation.class ../../common/android
|
||||
|
@ -20,6 +20,10 @@ import java.io.File;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.Arrays;
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
@ -109,5 +113,40 @@ public class BaseUiAutomation extends UiAutomatorTestCase {
|
||||
throw new TimeoutException("Timed out waiting for Logcat text \"%s\"".format(searchText));
|
||||
}
|
||||
}
|
||||
|
||||
public Integer[] splitVersion(String versionString) {
|
||||
String pattern = "(\\d+).(\\d+).(\\d+)";
|
||||
Pattern r = Pattern.compile(pattern);
|
||||
ArrayList<Integer> result = new ArrayList<Integer>();
|
||||
|
||||
Matcher m = r.matcher(versionString);
|
||||
if (m.find() && m.groupCount() > 0) {
|
||||
for(int i=1; i<=m.groupCount(); i++) {
|
||||
result.add(Integer.parseInt(m.group(i)));
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException(versionString + " - unknown format");
|
||||
}
|
||||
return result.toArray(new Integer[result.size()]);
|
||||
}
|
||||
|
||||
//Return values:
|
||||
// -1 = a lower than b
|
||||
// 0 = a and b equal
|
||||
// 1 = a greater than b
|
||||
public int compareVersions(Integer[] a, Integer[] b) {
|
||||
if (a.length != b.length) {
|
||||
String msg = "Versions do not match format:\n %1$s\n %1$s";
|
||||
msg = String.format(msg, Arrays.toString(a), Arrays.toString(b));
|
||||
throw new IllegalArgumentException(msg);
|
||||
}
|
||||
for(int i=0; i<a.length; i++) {
|
||||
if(a[i] > b[i])
|
||||
return 1;
|
||||
else if(a[i] < b[i])
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user