calabash-android 0.4.0.pre6 → 0.4.0.pre7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. data/bin/calabash-android +7 -0
  2. data/bin/calabash-android-build.rb +1 -1
  3. data/bin/calabash-android-console.rb +1 -1
  4. data/bin/calabash-android-run.rb +1 -1
  5. data/calabash-android.gemspec +1 -0
  6. data/irbrc +2 -0
  7. data/lib/calabash-android/helpers.rb +4 -2
  8. data/lib/calabash-android/lib/TestServer.apk +0 -0
  9. data/lib/calabash-android/operations.rb +31 -22
  10. data/lib/calabash-android/version.rb +1 -1
  11. data/test-server/instrumentation-backend/.classpath +0 -1
  12. data/test-server/instrumentation-backend/antlr/UIQuery.g +11 -2
  13. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/Command.java +4 -3
  14. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/FranklyResult.java +95 -0
  15. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/Result.java +7 -1
  16. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/HttpServer.java +15 -23
  17. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/location/FakeGPSLocation.java +13 -10
  18. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/CalabashChromeClient.java +136 -36
  19. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/DumpBodyHtml.java +38 -18
  20. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/DumpHtml.java +38 -16
  21. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/EnterTextByCssSelector.java +94 -66
  22. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/ExecuteAsyncJavascript.java +55 -33
  23. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/ExecuteJavascript.java +54 -31
  24. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/JavaScriptOperation.java +44 -0
  25. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/PressByCssSelector.java +52 -27
  26. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/QueryHelper.java +39 -32
  27. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/ScrollTo.java +56 -41
  28. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetPropertyByCssSelector.java +50 -25
  29. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/SetText.java +19 -22
  30. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/CompletedFuture.java +40 -0
  31. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/InvocationOperation.java +201 -0
  32. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/Operation.java +7 -0
  33. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/PropertyOperation.java +56 -0
  34. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/Query.java +144 -72
  35. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/UIQuery.tokens +15 -12
  36. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/UIQueryResultVoid.java +22 -0
  37. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ViewMapper.java +38 -11
  38. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/antlr/UIQueryLexer.java +226 -109
  39. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/antlr/UIQueryParser.java +237 -84
  40. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/PartialFutureList.java +100 -0
  41. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryAST.java +1 -1
  42. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryASTClassName.java +26 -22
  43. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryASTWith.java +170 -102
  44. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryEvaluator.java +54 -155
  45. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryUtils.java +97 -2
  46. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/query/ast/UIQueryVisibility.java +32 -0
  47. metadata +27 -5
  48. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Query.java +0 -24
  49. data/test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/webview/Touch.java +0 -44
  50. data/test-server/instrumentation-backend/tests/sh/calaba/instrumentationbackend/query/tests/UIQueryTest.java +0 -134
@@ -1,11 +1,16 @@
1
1
  package sh.calaba.instrumentationbackend.actions.webview;
2
2
 
3
- import java.lang.reflect.Field;
4
3
  import java.lang.reflect.Method;
5
4
  import java.util.ArrayList;
5
+ import java.util.HashMap;
6
6
  import java.util.List;
7
- import java.util.concurrent.atomic.AtomicReference;
7
+ import java.util.Map;
8
+ import java.util.concurrent.ExecutionException;
9
+ import java.util.concurrent.Future;
10
+ import java.util.concurrent.TimeUnit;
11
+ import java.util.concurrent.TimeoutException;
8
12
 
13
+ import android.os.Looper;
9
14
  import sh.calaba.instrumentationbackend.InstrumentationBackend;
10
15
  import android.os.Build;
11
16
  import android.os.ConditionVariable;
@@ -14,72 +19,167 @@ import android.webkit.JsPromptResult;
14
19
  import android.webkit.WebChromeClient;
15
20
  import android.webkit.WebView;
16
21
 
17
-
18
22
  public class CalabashChromeClient extends WebChromeClient {
19
- private final ConditionVariable eventHandled = new ConditionVariable();
20
- private final Result result = new Result();
21
23
  private WebChromeClient mWebChromeClient;
22
24
  private final WebView webView;
25
+ private final WebFuture scriptFuture;
23
26
 
24
- public CalabashChromeClient(WebView webView) {
27
+ public CalabashChromeClient(final WebView webView) {
25
28
  this.webView = webView;
26
- if (Build.VERSION.SDK_INT < 16) { // jelly bean
27
- try {
28
- Method methodGetConfiguration = webView.getClass().getMethod("getWebChromeClient");
29
- mWebChromeClient = (WebChromeClient)methodGetConfiguration.invoke(webView);
30
- } catch(Exception e) {
31
- throw new RuntimeException(e);
32
- }
29
+ this.scriptFuture = new WebFuture(webView);
30
+ if (Build.VERSION.SDK_INT < 16) { // jelly bean
31
+ try {
32
+ Method methodGetConfiguration = webView.getClass().getMethod(
33
+ "getWebChromeClient");
34
+ mWebChromeClient = (WebChromeClient) methodGetConfiguration
35
+ .invoke(webView);
36
+ } catch (Exception e) {
37
+ throw new RuntimeException(e);
38
+ }
33
39
  }
34
- webView.setWebChromeClient(this);
40
+
41
+ if ( Looper.getMainLooper().getThread() == Thread.currentThread()) {
42
+ webView.setWebChromeClient(this);
43
+ } else {
44
+ InstrumentationBackend.instrumentation.runOnMainSync(new Runnable() {
45
+ @Override
46
+ public void run() {
47
+ webView.setWebChromeClient(CalabashChromeClient.this);
48
+ }
49
+ });
50
+ }
35
51
  }
36
52
 
37
53
  @Override
38
- public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult r) {
54
+ public boolean onJsPrompt(WebView view, String url, String message,
55
+ String defaultValue, JsPromptResult r) {
39
56
  if (message != null && message.startsWith("calabash:")) {
40
57
  r.confirm("CALABASH_ACK");
41
58
  System.out.println("onJsPrompt: " + message);
42
- result.message = message.replaceFirst("calabash:", "");
43
- eventHandled.open();
44
-
59
+ String jsonResponse = message.replaceFirst("calabash:", "");
60
+ try {
61
+ scriptFuture.setResult(jsonResponse);
62
+ } catch (Exception e) {
63
+ e.printStackTrace();
64
+ scriptFuture.setResult(null);
65
+ }
45
66
  return true;
46
67
  } else {
47
68
  if (mWebChromeClient == null) {
48
69
  r.confirm("CALABASH_ERROR");
70
+ scriptFuture.complete();
49
71
  return true;
50
72
  } else {
51
- return mWebChromeClient.onJsPrompt(view, url, message, defaultValue, r);
73
+ // TODO I'm not what this case does...
74
+ return mWebChromeClient.onJsPrompt(view, url, message,
75
+ defaultValue, r);
52
76
  }
53
77
  }
54
78
  }
55
79
 
56
- public WebView getWebView() {
57
- return webView;
58
- }
59
-
60
- public String getResult() {
61
- eventHandled.block(3000);
62
- if (result.message == null) {
63
- throw new RuntimeException("Timed out waiting for result for JavaScript");
64
- }
65
- return result.message;
80
+ public WebView getWebView() {
81
+ return webView;
66
82
  }
67
83
 
68
- private class Result {
69
- String message;
84
+ public static CalabashChromeClient prepareWebView(WebView webView) {
85
+ CalabashChromeClient calabashChromeClient = new CalabashChromeClient(
86
+ webView);
87
+ webView.getSettings().setJavaScriptEnabled(true);
88
+ return calabashChromeClient;
70
89
  }
71
90
 
72
91
  public static List<CalabashChromeClient> findAndPrepareWebViews() {
73
92
  List<CalabashChromeClient> webViews = new ArrayList<CalabashChromeClient>();
74
93
  ArrayList<View> views = InstrumentationBackend.solo.getCurrentViews();
75
94
  for (View view : views) {
76
- if ( view instanceof WebView) {
77
- WebView webView = (WebView)view;
78
- webViews.add(new CalabashChromeClient(webView));
79
- webView.getSettings().setJavaScriptEnabled(true);
80
- System.out.println("Setting CalabashChromeClient");
95
+ if (view instanceof WebView) {
96
+ WebView webView = (WebView) view;
97
+ webViews.add(prepareWebView(webView));
81
98
  }
82
99
  }
83
100
  return webViews;
101
+
102
+ }
103
+
104
+ public WebFuture getResult() {
105
+ return scriptFuture;
106
+ }
107
+
108
+ @SuppressWarnings("rawtypes")
109
+ public static class WebFuture implements Future {
110
+ private final ConditionVariable eventHandled;
111
+ private volatile boolean complete;
112
+ private String result;
113
+ private final WebView webView;
114
+
115
+ public WebView getWebView() {
116
+ return webView;
117
+ }
118
+
119
+ public void complete() {
120
+ this.complete = true;
121
+ this.eventHandled.open();
122
+ }
123
+
124
+ public WebFuture(WebView webView) {
125
+ this.webView = webView;
126
+ eventHandled = new ConditionVariable();
127
+ result = null;
128
+ }
129
+
130
+ public synchronized void setResult(String result) {
131
+ this.result = result;
132
+ this.complete();
133
+ }
134
+
135
+ public synchronized String getResult() {
136
+ return this.result;
137
+ }
138
+
139
+ public boolean cancel(boolean mayInterruptIfRunning) {
140
+ return false;
141
+ }
142
+
143
+ @Override
144
+ public Object get() throws InterruptedException, ExecutionException {
145
+ eventHandled.block();
146
+ return asMap();
147
+ }
148
+
149
+ @Override
150
+ public Object get(long timeout, TimeUnit unit)
151
+ throws InterruptedException, ExecutionException,
152
+ TimeoutException {
153
+ eventHandled.block(unit.convert(timeout, TimeUnit.MILLISECONDS));
154
+ return asMap();
155
+ }
156
+
157
+ @Override
158
+ public boolean isCancelled() {
159
+ return false;
160
+ }
161
+
162
+ @Override
163
+ public boolean isDone() {
164
+ return complete;
165
+ }
166
+
167
+ public String getAsString() {
168
+ try {
169
+ get(10,TimeUnit.SECONDS);
170
+ return getResult();
171
+ } catch (Exception e) {
172
+ e.printStackTrace();
173
+ throw new RuntimeException(e);
174
+ }
175
+ }
176
+
177
+ @SuppressWarnings("unchecked")
178
+ public Map asMap() {
179
+ HashMap m = new HashMap();
180
+ m.put("webView", webView);
181
+ m.put("result",getResult());
182
+ return m;
183
+ }
84
184
  }
85
185
  }
@@ -1,31 +1,51 @@
1
1
  package sh.calaba.instrumentationbackend.actions.webview;
2
2
 
3
3
 
4
- import sh.calaba.instrumentationbackend.InstrumentationBackend;
4
+ import java.util.ArrayList;
5
+ import java.util.List;
6
+ import java.util.concurrent.Callable;
7
+
5
8
  import sh.calaba.instrumentationbackend.Result;
6
9
  import sh.calaba.instrumentationbackend.actions.Action;
10
+ import sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient.WebFuture;
11
+ import sh.calaba.instrumentationbackend.query.ast.UIQueryUtils;
7
12
  import android.webkit.WebView;
8
13
 
14
+ @Deprecated
9
15
  public class DumpBodyHtml implements Action {
10
16
 
11
- @Override
17
+ @SuppressWarnings({ "rawtypes", "unchecked" })
18
+ @Override
12
19
  public Result execute(String... args) {
13
-
14
- final Result result = Result.successResult();
15
- for (CalabashChromeClient ccc : CalabashChromeClient.findAndPrepareWebViews()) {
16
- WebView webView = ccc.getWebView();
17
- webView.loadUrl("javascript:(function() {" +
18
- "prompt('calabash:' + document.body.innerHTML);" +
19
- "})()");
20
- String r = ccc.getResult();
21
- System.out.println("Html:");
22
- System.out.println("" + r);
23
- result.addBonusInformation(r);
24
-
25
- return result;
26
-
27
- }
28
- return new Result(false, "No WebView found");
20
+
21
+ List<WebFuture> webResults = (List<WebFuture>) UIQueryUtils.evaluateSyncInMainThread(new Callable() {
22
+ public Object call() throws Exception {
23
+
24
+ List<WebFuture> webResults = new ArrayList();
25
+ for (CalabashChromeClient ccc : CalabashChromeClient.findAndPrepareWebViews()) {
26
+ WebView webView = ccc.getWebView();
27
+ webView.loadUrl("javascript:(function() {" +
28
+ "prompt('calabash:' + document.body.innerHTML);" +
29
+ "})()");
30
+ webResults.add(ccc.getResult());
31
+ }
32
+ return webResults;
33
+
34
+ }
35
+ });
36
+
37
+ List<String> allResults = new ArrayList<String>(webResults.size());
38
+ for (WebFuture f : webResults) {
39
+ allResults.add(f.getAsString());
40
+ }
41
+
42
+ if (allResults.size() == 0) {
43
+ return new Result(false, "No WebView found");
44
+ }
45
+ else {
46
+ return new Result(true, allResults);
47
+ }
48
+
29
49
  }
30
50
  public String key() {
31
51
  return "dump_body_html";
@@ -1,32 +1,54 @@
1
1
  package sh.calaba.instrumentationbackend.actions.webview;
2
2
 
3
3
 
4
- import sh.calaba.instrumentationbackend.InstrumentationBackend;
4
+ import java.util.ArrayList;
5
+ import java.util.List;
6
+ import java.util.concurrent.Callable;
7
+
5
8
  import sh.calaba.instrumentationbackend.Result;
6
9
  import sh.calaba.instrumentationbackend.actions.Action;
10
+ import sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient.WebFuture;
11
+ import sh.calaba.instrumentationbackend.query.ast.UIQueryUtils;
7
12
  import android.webkit.WebView;
8
13
 
9
14
  public class DumpHtml implements Action {
10
15
 
11
- @Override
16
+ @SuppressWarnings({ "unchecked", "rawtypes" })
17
+ @Override
12
18
  public Result execute(String... args) {
13
-
14
- Result result = Result.successResult();
15
- for (CalabashChromeClient ccc : CalabashChromeClient.findAndPrepareWebViews()) {
16
- final WebView webView = ccc.getWebView();
17
- webView.loadUrl("javascript:(function() {" +
18
- "prompt('calabash:' + document.body.parentNode.innerHTML);" +
19
- "})()");
20
- String r = ccc.getResult();
21
- System.out.println("Html:");
22
- System.out.println("" + r);
23
- result.addBonusInformation(r);
24
- }
19
+
20
+ List<WebFuture> webResults = (List<WebFuture>) UIQueryUtils.evaluateSyncInMainThread(new Callable() {
21
+
22
+ public Object call() throws Exception {
23
+
24
+ List<WebFuture> webResults = new ArrayList();
25
+ for (CalabashChromeClient ccc : CalabashChromeClient.findAndPrepareWebViews()) {
26
+ final WebView webView = ccc.getWebView();
27
+ webView.loadUrl("javascript:(function() {" +
28
+ "prompt('calabash:' + document.body.parentNode.innerHTML);" +
29
+ "})()");
30
+ webResults.add(ccc.getResult());
31
+ }
32
+ return webResults;
33
+
34
+ }
35
+ });
36
+
37
+ List<String> allResults = new ArrayList<String>(webResults.size());
38
+ for (WebFuture f : webResults) {
39
+ allResults.add(f.getAsString());
40
+ }
41
+
42
+ if (allResults.size() == 0) {
43
+ return new Result(false, "No WebView found");
44
+ }
45
+ else {
46
+ return new Result(true, allResults);
47
+ }
25
48
 
26
- return result;
27
49
  }
28
50
 
29
- @Override
51
+ @Override
30
52
  public String key() {
31
53
  return "dump_html";
32
54
  }
@@ -1,88 +1,116 @@
1
1
  package sh.calaba.instrumentationbackend.actions.webview;
2
2
 
3
3
 
4
- import sh.calaba.instrumentationbackend.InstrumentationBackend;
4
+ import java.util.ArrayList;
5
+ import java.util.List;
6
+ import java.util.concurrent.Callable;
7
+
5
8
  import sh.calaba.instrumentationbackend.Result;
6
- import sh.calaba.instrumentationbackend.TestHelpers;
7
9
  import sh.calaba.instrumentationbackend.actions.Action;
10
+ import sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient.WebFuture;
11
+ import sh.calaba.instrumentationbackend.query.ast.UIQueryUtils;
8
12
  import android.webkit.WebView;
9
13
 
10
-
14
+ @Deprecated
11
15
  public class EnterTextByCssSelector implements Action {
12
16
 
13
- @Override
17
+ @SuppressWarnings({ "unchecked", "rawtypes" })
18
+ @Override
14
19
  public Result execute(String... args) {
15
20
  final String cssSelector = args[0];
16
21
  final String value = args[1];
22
+
23
+ List<WebFuture> webResults = (List<WebFuture>) UIQueryUtils.evaluateSyncInMainThread(new Callable() {
24
+
25
+ public Object call() throws Exception {
26
+
27
+ List<WebFuture> webResults = new ArrayList();
28
+ for (CalabashChromeClient ccc : CalabashChromeClient.findAndPrepareWebViews()) {
29
+ WebView webView = ccc.getWebView();
17
30
 
18
- for (CalabashChromeClient ccc : CalabashChromeClient.findAndPrepareWebViews()) {
19
- WebView webView = ccc.getWebView();
20
-
21
- String functions = " function simulateKeyEvent(elem, character) {\n" +
22
- " var ch = character.charCodeAt(0);\n" +
23
- "\n" +
24
- " var evt;\n" +
25
- "\n" +
26
- " evt = document.createEvent('KeyboardEvent');\n" +
27
- " evt.initKeyboardEvent('keydown', true, true, window, 0, 0, 0, 0, 0, ch);\n" +
28
- " elem.dispatchEvent(evt);\n" +
29
- "\n" +
30
- " evt = document.createEvent('KeyboardEvent');\n" +
31
- " evt.initKeyboardEvent('keyup', true, true, window, 0, 0, 0, 0, 0, ch);\n" +
32
- " elem.dispatchEvent(evt);\n" +
33
- "\n" +
34
- " evt = document.createEvent('KeyboardEvent');\n" +
35
- " evt.initKeyboardEvent('keypress', true, true, window, 0, 0, 0, 0, 0, ch);\n" +
36
- " elem.dispatchEvent(evt);\n" +
37
- " }\n" +
38
- "";
31
+ String functions = " function simulateKeyEvent(elem, character) {\n" +
32
+ " var ch = character.charCodeAt(0);\n" +
33
+ "\n" +
34
+ " var evt;\n" +
35
+ "\n" +
36
+ " evt = document.createEvent('KeyboardEvent');\n" +
37
+ " evt.initKeyboardEvent('keydown', true, true, window, 0, 0, 0, 0, 0, ch);\n" +
38
+ " elem.dispatchEvent(evt);\n" +
39
+ "\n" +
40
+ " evt = document.createEvent('KeyboardEvent');\n" +
41
+ " evt.initKeyboardEvent('keyup', true, true, window, 0, 0, 0, 0, 0, ch);\n" +
42
+ " elem.dispatchEvent(evt);\n" +
43
+ "\n" +
44
+ " evt = document.createEvent('KeyboardEvent');\n" +
45
+ " evt.initKeyboardEvent('keypress', true, true, window, 0, 0, 0, 0, 0, ch);\n" +
46
+ " elem.dispatchEvent(evt);\n" +
47
+ " }\n" +
48
+ "";
39
49
 
40
- functions +=
41
- " function enterTextIntoInputField(elem, text) {\n" +
42
- " for (var i = 0; i < text.length; i++) {\n" +
43
- " var ch = text.charAt(i);\n" +
44
- " elem.value += ch;\n" +
45
- " simulateKeyEvent(elem, ch);\n" +
46
- " }\n" +
47
- " }\n" +
48
- "";
50
+ functions +=
51
+ " function enterTextIntoInputField(elem, text) {\n" +
52
+ " for (var i = 0; i < text.length; i++) {\n" +
53
+ " var ch = text.charAt(i);\n" +
54
+ " elem.value += ch;\n" +
55
+ " simulateKeyEvent(elem, ch);\n" +
56
+ " }\n" +
57
+ " }\n" +
58
+ "";
49
59
 
50
- functions +=
51
- " function fireHTMLEvent(elem, eventName) {\n" +
52
- " var evt = document.createEvent(\"HTMLEvents\");\n" +
53
- " evt.initEvent(eventName, true, true );\n" +
54
- " return !elem.dispatchEvent(evt);\n" +
55
- " }\n" +
56
- "";
60
+ functions +=
61
+ " function fireHTMLEvent(elem, eventName) {\n" +
62
+ " var evt = document.createEvent(\"HTMLEvents\");\n" +
63
+ " evt.initEvent(eventName, true, true );\n" +
64
+ " return !elem.dispatchEvent(evt);\n" +
65
+ " }\n" +
66
+ "";
57
67
 
58
- functions +=
59
- " function selectInputField(elem) {\n" +
60
- " elem.click();\n" +
61
- " elem.focus();\n" +
62
- " }\n" +
63
- "";
68
+ functions +=
69
+ " function selectInputField(elem) {\n" +
70
+ " elem.click();\n" +
71
+ " elem.focus();\n" +
72
+ " }\n" +
73
+ "";
64
74
 
65
- functions +=
66
- " function deselectInputField(elem) {\n" +
67
- " fireHTMLEvent(elem, 'change');\n" +
68
- " fireHTMLEvent(elem, 'blur');\n" +
69
- " }\n" +
70
- "";
75
+ functions +=
76
+ " function deselectInputField(elem) {\n" +
77
+ " fireHTMLEvent(elem, 'change');\n" +
78
+ " fireHTMLEvent(elem, 'blur');\n" +
79
+ " }\n" +
80
+ "";
71
81
 
72
- webView.loadUrl("javascript:(function() {" +
73
- functions +
74
- "var elem = document.querySelector(\"" + cssSelector + "\"); selectInputField(elem); enterTextIntoInputField(elem, '" + value + "'); deselectInputField(elem); " +
75
- "prompt('calabash:true');" +
76
- "})()");
82
+ webView.loadUrl("javascript:(function() {" +
83
+ functions +
84
+ "var elem = document.querySelector(\"" + cssSelector + "\"); selectInputField(elem); enterTextIntoInputField(elem, '" + value + "'); deselectInputField(elem); " +
85
+ "prompt('calabash:true');" +
86
+ "})()");
87
+
88
+ webResults.add(ccc.getResult());
89
+ }
90
+
91
+ return webResults;
92
+
93
+ }
94
+ });
95
+
96
+ List<String> allResults = new ArrayList<String>(webResults.size());
97
+ boolean allSucceed = true;
98
+ for (WebFuture f : webResults) {
99
+ String result = f.getAsString();
100
+ allResults.add(result);
101
+ if (!"true".equals(result)) {
102
+ allSucceed = false;
103
+ }
104
+ }
77
105
 
78
- String r = ccc.getResult();
79
- System.out.println("enterTextIntoInputField: " + r);
80
- if ("true".equals(r)) {
81
- TestHelpers.wait(0.3);
82
- return Result.successResult();
83
- }
84
- }
85
- return new Result(false, "");
106
+
107
+ if (allResults.size() == 0) {
108
+ return new Result(false, "No WebView found");
109
+ }
110
+ else {
111
+ return new Result(allSucceed, allResults);
112
+ }
113
+
86
114
  }
87
115
 
88
116
  @Override