calabash-android 0.4.19.pre1 → 0.4.19.pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/calabash-android/calabash_steps.rb +3 -0
- data/lib/calabash-android/helpers.rb +1 -1
- data/lib/calabash-android/java_keystore.rb +1 -1
- data/lib/calabash-android/lib/TestServer.apk +0 -0
- data/lib/calabash-android/operations.rb +1 -3
- data/lib/calabash-android/steps/list_steps.rb +5 -4
- data/lib/calabash-android/version.rb +1 -1
- data/test-server/calabash-js/src/calabash.js +4 -0
- data/test-server/calabash-js/src/set_text.js +63 -57
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/FranklyResult.java +19 -25
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/HttpServer.java +3 -1
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/ScrollTo.java +4 -2
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetText.java +45 -28
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/Query.java +1 -2
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/QueryResult.java +18 -0
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryEvaluator.java +3 -33
- data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryUtils.java +4 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00ae1ecac8ab3e1399cda4706404382dff6a455b
|
4
|
+
data.tar.gz: b4670156a2737a79759ba4e855e0a6c30bd29ff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cff1e932b04d5f78010e1ff07b6fa2ca7a3de1f0864f4b538d4bdfbebfa97c5f70fd817da1a122f9ce5ad60425a95f20d9f56b9e21526e6a6585d905f050a7fb
|
7
|
+
data.tar.gz: 850e99a1f0a184e7c5f848237ed7110cf55151e624cb540a941d903ee1ad4f3920c0e53839020c5dd32a01fe88e901d781d5f8731d1567fc880bac46fce19380
|
@@ -1,3 +1,4 @@
|
|
1
|
+
|
1
2
|
WAIT_TIMEOUT = (ENV['WAIT_TIMEOUT'] || 30).to_f
|
2
3
|
STEP_PAUSE = (ENV['STEP_PAUSE'] || 0.5).to_f
|
3
4
|
|
@@ -17,3 +18,5 @@ require 'calabash-android/steps/screenshot_steps'
|
|
17
18
|
require 'calabash-android/steps/search_steps'
|
18
19
|
require 'calabash-android/steps/spinner_steps'
|
19
20
|
require 'calabash-android/steps/time_picker_steps'
|
21
|
+
require 'calabash-android/steps/list_steps'
|
22
|
+
|
@@ -91,7 +91,7 @@ def fingerprint_from_apk(app_path)
|
|
91
91
|
raise "No RSA file found in META-INF. Cannot proceed." if rsa_files.empty?
|
92
92
|
raise "More than one RSA file found in META-INF. Cannot proceed." if rsa_files.length > 1
|
93
93
|
|
94
|
-
cmd = "#{Env.keytool_path} -v -printcert -file \"#{rsa_files.first}\""
|
94
|
+
cmd = "#{Env.keytool_path} -v -printcert -J'-Dfile.encoding=utf-8' -file \"#{rsa_files.first}\""
|
95
95
|
log cmd
|
96
96
|
fingerprints = `#{cmd}`
|
97
97
|
md5_fingerprint = extract_md5_fingerprint(fingerprints)
|
@@ -3,7 +3,7 @@ class JavaKeystore
|
|
3
3
|
def initialize(location, keystore_alias, password)
|
4
4
|
raise "No such file #{location}" unless File.exists?(File.expand_path(location))
|
5
5
|
|
6
|
-
keystore_data = system_with_stdout_on_success(Env.keytool_path, '-list', '-v', '-alias', keystore_alias, '-keystore', location, '-storepass', password)
|
6
|
+
keystore_data = system_with_stdout_on_success(Env.keytool_path, '-list', '-v', '-alias', keystore_alias, '-keystore', location, '-storepass', password, '-J-Dfile.encoding=utf-8')
|
7
7
|
if keystore_data.nil?
|
8
8
|
error = "Could not list certificates in keystore. Probably because the password was incorrect."
|
9
9
|
@errors = [{:message => error}]
|
Binary file
|
@@ -275,7 +275,7 @@ module Operations
|
|
275
275
|
raise "Empty result from TestServer" if result.chomp.empty?
|
276
276
|
result = JSON.parse(result)
|
277
277
|
if not result["success"] then
|
278
|
-
raise "
|
278
|
+
raise "Action '#{action}' unsuccessful: #{result["message"]}"
|
279
279
|
end
|
280
280
|
result
|
281
281
|
end
|
@@ -729,11 +729,9 @@ module Operations
|
|
729
729
|
|
730
730
|
def set_text(uiquery, txt)
|
731
731
|
raise "Currently queries are only supported for webviews" unless uiquery.start_with? "webView"
|
732
|
-
|
733
732
|
uiquery.slice!(0, "webView".length)
|
734
733
|
if uiquery =~ /(css|xpath):\s*(.*)/
|
735
734
|
r = performAction("set_text", $1, $2, txt)
|
736
|
-
JSON.parse(r["message"])
|
737
735
|
else
|
738
736
|
raise "Invalid query #{uiquery}"
|
739
737
|
end
|
@@ -5,12 +5,13 @@
|
|
5
5
|
Then /^I should see following list:$/ do | expected_table |
|
6
6
|
result = performAction('get_list_item_text')
|
7
7
|
response_table = result['bonusInformation']
|
8
|
-
|
8
|
+
response_table_array = []
|
9
|
+
response_table.each do | row_data|
|
9
10
|
row_data = JSON.parse( row_data )
|
10
|
-
|
11
|
+
tmpArray = [row_data.values.first]
|
12
|
+
response_table_array.push(tmpArray)
|
11
13
|
end
|
12
|
-
|
13
|
-
expected_table.diff!(response_table)
|
14
|
+
expected_table.diff!(response_table_array)
|
14
15
|
end
|
15
16
|
|
16
17
|
# Note: This step is currently intended as more of an example rather than a rock-solid, well-tested step.
|
@@ -1,49 +1,49 @@
|
|
1
1
|
(function () {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
2
|
+
function simulateKeyEvent(elem, character) {
|
3
|
+
var ch = character.charCodeAt(0);
|
4
|
+
|
5
|
+
var evt;
|
6
|
+
evt = document.createEvent('KeyboardEvent');
|
7
|
+
evt.initKeyboardEvent('keydown', true, true, window, 0, 0, 0, 0, 0, ch);
|
8
|
+
elem.dispatchEvent(evt);
|
9
|
+
|
10
|
+
evt = document.createEvent('KeyboardEvent');
|
11
|
+
evt.initKeyboardEvent('keyup', true, true, window, 0, 0, 0, 0, 0, ch);
|
12
|
+
elem.dispatchEvent(evt);
|
13
|
+
evt = document.createEvent('KeyboardEvent');
|
14
|
+
evt.initKeyboardEvent('keypress', true, true, window, 0, 0, 0, 0, 0, ch);
|
15
|
+
elem.dispatchEvent(evt);
|
16
|
+
}
|
17
|
+
|
18
|
+
|
19
|
+
function enterTextIntoInputField(elem, text) {
|
20
|
+
elem.value = "";
|
21
|
+
for (var i = 0; i < text.length; i++) {
|
22
|
+
var ch = text.charAt(i);
|
23
|
+
elem.value += ch;
|
24
|
+
simulateKeyEvent(elem, ch);
|
25
|
+
}
|
26
|
+
}
|
27
|
+
|
28
|
+
|
29
|
+
function fireHTMLEvent(elem, eventName) {
|
30
|
+
var evt = document.createEvent("HTMLEvents");
|
31
|
+
evt.initEvent(eventName, true, true );
|
32
|
+
return !elem.dispatchEvent(evt);
|
33
|
+
}
|
34
|
+
|
35
|
+
function selectInputField(elem) {
|
36
|
+
elem.click();
|
37
|
+
elem.focus();
|
38
|
+
}
|
39
|
+
|
40
|
+
|
41
|
+
function deselectInputField(elem) {
|
42
|
+
fireHTMLEvent(elem, 'change');
|
43
|
+
fireHTMLEvent(elem, 'blur');
|
44
|
+
}
|
45
|
+
|
46
|
+
|
47
47
|
/** David Mark's isHostMethod function,
|
48
48
|
* http://peter.michaux.ca/articles/feature-detection-state-of-the-art-browser-scripting
|
49
49
|
* Modified to use strict equality
|
@@ -72,7 +72,7 @@
|
|
72
72
|
}
|
73
73
|
else if (object instanceof Node)//TODO: support for frames!
|
74
74
|
{
|
75
|
-
res = {}
|
75
|
+
res = {};
|
76
76
|
if (isHostMethod(object,'getBoundingClientRect'))
|
77
77
|
{
|
78
78
|
res['rect'] = object.getBoundingClientRect();
|
@@ -81,6 +81,9 @@
|
|
81
81
|
res.nodeName = object.nodeName;
|
82
82
|
res.id = object.id || '';
|
83
83
|
res['class'] = object.className || '';
|
84
|
+
if (object.hasOwnProperty('value')) {
|
85
|
+
res.value = object.value;
|
86
|
+
}
|
84
87
|
res.html = object.outerHTML || '';
|
85
88
|
res.nodeValue = object.nodeValue;
|
86
89
|
}
|
@@ -102,23 +105,26 @@
|
|
102
105
|
}
|
103
106
|
return res;
|
104
107
|
}
|
105
|
-
|
108
|
+
|
106
109
|
///TODO: no support for now frames
|
107
110
|
//idea would be map XPath across window.frames
|
108
111
|
//must take care of visibility questions
|
109
112
|
|
110
113
|
try
|
111
|
-
{
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
el=document.elementFromPoint(exp.rect.left, exp.rect.top);
|
114
|
+
{
|
115
|
+
var exp = JSON.parse('%@')/* dynamic */,
|
116
|
+
el,
|
117
|
+
text = '%@',
|
118
|
+
i,N;
|
119
|
+
|
120
|
+
el=document.elementFromPoint(exp.rect.left + exp.rect.width / 2, exp.rect.top + exp.rect.height / 2);
|
121
|
+
if(exp.id){
|
122
|
+
el = document.getElementById(exp.id);
|
123
|
+
}
|
118
124
|
if (/input/i.test(el.tagName))
|
119
125
|
{
|
120
|
-
|
121
|
-
|
126
|
+
selectInputField(el);
|
127
|
+
enterTextIntoInputField(el, text);
|
122
128
|
}
|
123
129
|
else
|
124
130
|
{
|
@@ -130,4 +136,4 @@
|
|
130
136
|
return JSON.stringify({error:'Exception while running query: '+exp, details:e.toString()})
|
131
137
|
}
|
132
138
|
return JSON.stringify(toJSON(el));
|
133
|
-
})();
|
139
|
+
})();
|
data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/FranklyResult.java
CHANGED
@@ -8,6 +8,7 @@ import java.util.List;
|
|
8
8
|
import java.util.Map;
|
9
9
|
|
10
10
|
import sh.calaba.instrumentationbackend.json.JSONUtils;
|
11
|
+
import sh.calaba.instrumentationbackend.query.QueryResult;
|
11
12
|
|
12
13
|
/**
|
13
14
|
* Represents a response in the Frankly protocol.
|
@@ -23,66 +24,59 @@ public class FranklyResult {
|
|
23
24
|
final String reason;
|
24
25
|
final String detail;
|
25
26
|
@SuppressWarnings("rawtypes")
|
26
|
-
final
|
27
|
+
final QueryResult result;
|
27
28
|
|
28
29
|
|
29
30
|
@SuppressWarnings({ "rawtypes" })
|
30
|
-
public FranklyResult(boolean success,
|
31
|
-
String detail) {
|
31
|
+
public FranklyResult(boolean success, QueryResult result, String reason, String detail) {
|
32
32
|
super();
|
33
33
|
this.success = success;
|
34
|
-
this.
|
34
|
+
this.result = result;
|
35
35
|
this.reason = reason;
|
36
36
|
this.detail = detail;
|
37
37
|
}
|
38
38
|
|
39
39
|
public static FranklyResult fromThrowable(Throwable t) {
|
40
40
|
CharArrayWriter caw = new CharArrayWriter();
|
41
|
-
t.printStackTrace(new PrintWriter(caw));
|
42
|
-
|
41
|
+
t.printStackTrace(new PrintWriter(caw));
|
42
|
+
|
43
|
+
return new FranklyResult(false, null, t.getMessage(),caw.toString());
|
43
44
|
}
|
44
45
|
|
45
46
|
public static FranklyResult emptyResult() {
|
46
|
-
return new FranklyResult(true,
|
47
|
+
return new FranklyResult(true, null, null,null);
|
47
48
|
}
|
48
49
|
|
49
50
|
public static FranklyResult failedResult(String message,String detail) {
|
50
|
-
return new FranklyResult(false,
|
51
|
+
return new FranklyResult(false, null, message,detail);
|
51
52
|
}
|
52
53
|
|
53
54
|
public String asJson() {
|
54
55
|
return JSONUtils.asJson(asMap());
|
55
56
|
}
|
56
57
|
|
57
|
-
public Map<String,Object> asMap()
|
58
|
+
public Map<String, Object> asMap()
|
58
59
|
{
|
59
|
-
Map<String,Object>
|
60
|
-
|
60
|
+
Map<String,Object> map = new HashMap<String, Object>();
|
61
|
+
map.put("outcome", success ? "SUCCESS" : "ERROR");
|
61
62
|
|
62
|
-
if (
|
63
|
+
if (success)
|
63
64
|
{
|
64
|
-
|
65
|
+
map.put("results", result.asList());
|
65
66
|
}
|
66
67
|
else
|
67
68
|
{
|
68
|
-
|
69
|
-
if (
|
69
|
+
map.put("reason", reason);
|
70
|
+
if (detail != null)
|
70
71
|
{
|
71
|
-
|
72
|
+
map.put("detail", detail);
|
72
73
|
}
|
73
74
|
}
|
74
|
-
return
|
75
|
-
}
|
76
|
-
|
77
|
-
@Override
|
78
|
-
public String toString()
|
79
|
-
{
|
80
|
-
return "FranklyResult [success=" + success + ", reason=" + reason
|
81
|
-
+ ", details=" + detail + ", results=" + results + "]";
|
75
|
+
return map;
|
82
76
|
}
|
83
77
|
|
84
78
|
@SuppressWarnings("rawtypes")
|
85
|
-
public static FranklyResult successResult(
|
79
|
+
public static FranklyResult successResult(QueryResult result) {
|
86
80
|
return new FranklyResult(true, result, null,null);
|
87
81
|
}
|
88
82
|
}
|
@@ -20,6 +20,7 @@ import sh.calaba.instrumentationbackend.InstrumentationBackend;
|
|
20
20
|
import sh.calaba.instrumentationbackend.Result;
|
21
21
|
import sh.calaba.instrumentationbackend.json.JSONUtils;
|
22
22
|
import sh.calaba.instrumentationbackend.query.Query;
|
23
|
+
import sh.calaba.instrumentationbackend.query.QueryResult;
|
23
24
|
import sh.calaba.org.codehaus.jackson.map.ObjectMapper;
|
24
25
|
import android.graphics.Bitmap;
|
25
26
|
import android.util.Log;
|
@@ -124,6 +125,7 @@ public class HttpServer extends NanoHTTPD {
|
|
124
125
|
Map command = mapper.readValue(commandString, Map.class);
|
125
126
|
|
126
127
|
String uiQuery = (String) command.get("query");
|
128
|
+
uiQuery = uiQuery.trim();
|
127
129
|
Map op = (Map) command.get("operation");
|
128
130
|
@SuppressWarnings("unused") //TODO: support other methods, e.g., flash
|
129
131
|
String methodName = (String) op.get("method_name");
|
@@ -132,7 +134,7 @@ public class HttpServer extends NanoHTTPD {
|
|
132
134
|
//For now we only support query
|
133
135
|
|
134
136
|
|
135
|
-
|
137
|
+
QueryResult queryResult = new Query(uiQuery,arguments).executeQuery();
|
136
138
|
|
137
139
|
return new NanoHTTPD.Response(HTTP_OK, "application/json;charset=utf-8",
|
138
140
|
FranklyResult.successResult(queryResult).asJson());
|
@@ -8,6 +8,8 @@ import sh.calaba.instrumentationbackend.InstrumentationBackend;
|
|
8
8
|
import sh.calaba.instrumentationbackend.Result;
|
9
9
|
import sh.calaba.instrumentationbackend.actions.Action;
|
10
10
|
import sh.calaba.instrumentationbackend.actions.Actions;
|
11
|
+
import sh.calaba.instrumentationbackend.query.QueryResult;
|
12
|
+
|
11
13
|
import android.test.TouchUtils;
|
12
14
|
import android.webkit.WebView;
|
13
15
|
|
@@ -71,11 +73,11 @@ public class ScrollTo implements Action {
|
|
71
73
|
|
72
74
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
73
75
|
private int getCenterY(String uiQuery, WebView webView) {
|
74
|
-
|
76
|
+
QueryResult queryResult = new sh.calaba.instrumentationbackend.query.Query(uiQuery).executeQuery();
|
75
77
|
if (queryResult.isEmpty()) {
|
76
78
|
throw new RuntimeException("Query found no elements");
|
77
79
|
}
|
78
|
-
final Map<String, Object> firstVisibleRectangle = QueryHelper.findFirstVisibleRectangle(queryResult);
|
80
|
+
final Map<String, Object> firstVisibleRectangle = QueryHelper.findFirstVisibleRectangle(queryResult.asList());
|
79
81
|
|
80
82
|
return Math.round((Float)firstVisibleRectangle.get("center_y"));
|
81
83
|
}
|
@@ -1,12 +1,15 @@
|
|
1
1
|
package sh.calaba.instrumentationbackend.actions.webview;
|
2
2
|
|
3
3
|
|
4
|
-
import
|
4
|
+
import android.webkit.WebView;
|
5
|
+
|
5
6
|
import java.util.Map;
|
7
|
+
import java.util.concurrent.Callable;
|
6
8
|
|
7
9
|
import sh.calaba.instrumentationbackend.Result;
|
8
10
|
import sh.calaba.instrumentationbackend.actions.Action;
|
9
|
-
import sh.calaba.instrumentationbackend.
|
11
|
+
import sh.calaba.instrumentationbackend.query.QueryResult;
|
12
|
+
import sh.calaba.instrumentationbackend.query.ast.UIQueryUtils;
|
10
13
|
|
11
14
|
|
12
15
|
public class SetText implements Action {
|
@@ -19,29 +22,43 @@ public class SetText implements Action {
|
|
19
22
|
@SuppressWarnings({ "rawtypes", "unchecked"})
|
20
23
|
@Override
|
21
24
|
public Result execute(final String... args) {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
}
|
25
|
+
String query = args[1];
|
26
|
+
if (!query.startsWith("'")) {
|
27
|
+
query = "'" + query;
|
28
|
+
}
|
29
|
+
if (!query.endsWith("'")) {
|
30
|
+
query = query + "'";
|
31
|
+
}
|
32
|
+
|
33
|
+
final String uiQuery = "android.webkit.WebView " + args[0] + ":" + query;
|
34
|
+
QueryResult queryResult = new sh.calaba.instrumentationbackend.query.Query(uiQuery).executeQuery();
|
35
|
+
if (queryResult.isEmpty()) {
|
36
|
+
return Result.failedResult("No element found: " + query);
|
37
|
+
}
|
38
|
+
Map<String, Object> firstElement = QueryHelper.findFirstVisibleElement(queryResult.getResult());
|
39
|
+
firstElement.remove("class");
|
40
|
+
firstElement.remove("html");
|
41
|
+
final WebView webView = (WebView) firstElement.remove("webView");
|
42
|
+
|
43
|
+
final String firstElementJson = QueryHelper.toJsonString(firstElement);
|
44
|
+
|
45
|
+
|
46
|
+
Map<String, Object> result = (Map<String, Object>) UIQueryUtils.evaluateSyncInMainThread(new Callable() {
|
47
|
+
@Override
|
48
|
+
public Object call() throws Exception {
|
49
|
+
return QueryHelper.executeAsyncJavascriptInWebviews(webView, "set_text.js", firstElementJson, args[2]);
|
50
|
+
}
|
51
|
+
});
|
52
|
+
|
53
|
+
if (result.containsKey("error")) {
|
54
|
+
return Result.failedResult(result.get("details").toString());
|
55
|
+
}
|
56
|
+
return new Result(true);
|
57
|
+
}
|
58
|
+
|
59
|
+
@Override
|
60
|
+
public String key() {
|
61
|
+
return "set_text";
|
62
|
+
}
|
63
|
+
|
64
|
+
}
|
data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/Query.java
CHANGED
@@ -47,8 +47,7 @@ public class Query {
|
|
47
47
|
this.operations = args;
|
48
48
|
}
|
49
49
|
|
50
|
-
|
51
|
-
public List executeQuery() {
|
50
|
+
public QueryResult executeQuery() {
|
52
51
|
return UIQueryEvaluator.evaluateQueryWithOptions(parseQuery(this.queryString), rootViews(), parseOperations(this.operations));
|
53
52
|
}
|
54
53
|
|
data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/QueryResult.java
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
package sh.calaba.instrumentationbackend.query;
|
2
2
|
|
3
3
|
import java.io.IOException;
|
4
|
+
import java.util.ArrayList;
|
4
5
|
import java.util.List;
|
5
6
|
|
6
7
|
import sh.calaba.org.codehaus.jackson.map.ObjectMapper;
|
@@ -14,6 +15,9 @@ public class QueryResult {
|
|
14
15
|
this.result = result;
|
15
16
|
}
|
16
17
|
|
18
|
+
public boolean isEmpty() {
|
19
|
+
return result.isEmpty();
|
20
|
+
}
|
17
21
|
|
18
22
|
public String asJson() {
|
19
23
|
ObjectMapper mapper = new ObjectMapper();
|
@@ -24,4 +28,18 @@ public class QueryResult {
|
|
24
28
|
throw new RuntimeException("Could not convert result to json", e);
|
25
29
|
}
|
26
30
|
}
|
31
|
+
|
32
|
+
public List getResult() {
|
33
|
+
return result;
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
public List asList() {
|
38
|
+
List<Object> finalResult = new ArrayList(result.size());
|
39
|
+
for (Object o : result) {
|
40
|
+
finalResult.add(ViewMapper.mapView(o));
|
41
|
+
}
|
42
|
+
return finalResult;
|
43
|
+
}
|
44
|
+
|
27
45
|
}
|
@@ -4,50 +4,20 @@ import java.util.ArrayList;
|
|
4
4
|
import java.util.List;
|
5
5
|
|
6
6
|
import sh.calaba.instrumentationbackend.query.Operation;
|
7
|
+
import sh.calaba.instrumentationbackend.query.QueryResult;
|
7
8
|
import sh.calaba.instrumentationbackend.query.UIQueryResultVoid;
|
8
9
|
import sh.calaba.instrumentationbackend.query.ViewMapper;
|
9
10
|
|
10
11
|
public class UIQueryEvaluator {
|
11
12
|
|
12
13
|
@SuppressWarnings({ "rawtypes" })
|
13
|
-
public static
|
14
|
-
List<Operation> operations) {
|
15
|
-
|
16
|
-
long before = System.currentTimeMillis();
|
17
|
-
|
14
|
+
public static QueryResult evaluateQueryWithOptions(List<UIQueryAST> query, List inputViews, List<Operation> operations) {
|
18
15
|
List views = evaluateQueryForPath(query, inputViews);
|
19
|
-
|
20
|
-
long after = System.currentTimeMillis();
|
21
|
-
String action = "EvaluateQuery";
|
22
|
-
System.out.println(action+ " took: "+ (after-before) + "ms");
|
23
|
-
|
24
|
-
before = System.currentTimeMillis();
|
25
|
-
|
26
16
|
List result = applyOperations(views, operations);
|
27
|
-
|
28
|
-
after = System.currentTimeMillis();
|
29
|
-
action = "ApplyOperations";
|
30
|
-
System.out.println(action+ " took: "+ (after-before) + "ms");
|
31
|
-
|
32
|
-
before = System.currentTimeMillis();
|
33
|
-
|
34
|
-
List finalResult = mapViews(result);
|
35
|
-
|
36
|
-
after = System.currentTimeMillis();
|
37
|
-
action = "MapViews";
|
38
|
-
return finalResult;
|
17
|
+
return new QueryResult(result);
|
39
18
|
}
|
40
19
|
|
41
20
|
|
42
|
-
@SuppressWarnings({ "unchecked", "rawtypes" })
|
43
|
-
public static List mapViews(List result) {
|
44
|
-
List finalResult = new ArrayList(result.size());
|
45
|
-
for (Object o : result) {
|
46
|
-
finalResult.add(ViewMapper.mapView(o));
|
47
|
-
}
|
48
|
-
return finalResult;
|
49
|
-
}
|
50
|
-
|
51
21
|
|
52
22
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
53
23
|
public static List applyOperations(List views, List<Operation> operations) {
|
@@ -194,10 +194,8 @@ public class UIQueryUtils {
|
|
194
194
|
}
|
195
195
|
|
196
196
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
197
|
-
public static Future evaluateAsyncInMainThread(final Callable callable)
|
198
|
-
|
199
|
-
|
200
|
-
|
197
|
+
public static Future evaluateAsyncInMainThread(final Callable callable) throws Exception {
|
198
|
+
|
201
199
|
final AtomicReference<Future> result = new AtomicReference<Future>();
|
202
200
|
final AtomicReference<Exception> errorResult = new AtomicReference<Exception>();
|
203
201
|
|
@@ -248,10 +246,8 @@ public class UIQueryUtils {
|
|
248
246
|
new TypeReference<List<HashMap<String, Object>>>() {
|
249
247
|
});
|
250
248
|
for (Map<String, Object> data : parsedResult) {
|
251
|
-
Map<String, Object> rect = (Map<String, Object>) data
|
252
|
-
|
253
|
-
Map<String, Object> updatedRect = QueryHelper
|
254
|
-
.translateRectToScreenCoordinates(webView, rect);
|
249
|
+
Map<String, Object> rect = (Map<String, Object>) data.get("rect");
|
250
|
+
Map<String, Object> updatedRect = QueryHelper.translateRectToScreenCoordinates(webView, rect);
|
255
251
|
data.put("rect", updatedRect);
|
256
252
|
data.put("webView", webView);
|
257
253
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: calabash-android
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.19.
|
4
|
+
version: 0.4.19.pre2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Maturana Larsen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|