calabash-android 0.4.19.pre2 → 0.4.19.pre3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00ae1ecac8ab3e1399cda4706404382dff6a455b
4
- data.tar.gz: b4670156a2737a79759ba4e855e0a6c30bd29ff1
3
+ metadata.gz: defa8cb4b262a40357f1f00a8c76c7155629952f
4
+ data.tar.gz: 353e205839ac2e5055d5792400437ba6e6c5c945
5
5
  SHA512:
6
- metadata.gz: cff1e932b04d5f78010e1ff07b6fa2ca7a3de1f0864f4b538d4bdfbebfa97c5f70fd817da1a122f9ce5ad60425a95f20d9f56b9e21526e6a6585d905f050a7fb
7
- data.tar.gz: 850e99a1f0a184e7c5f848237ed7110cf55151e624cb540a941d903ee1ad4f3920c0e53839020c5dd32a01fe88e901d781d5f8731d1567fc880bac46fce19380
6
+ metadata.gz: 314abb26cf7d23bdd0020b971c6eb7b474397639fab09f67a699860816a36af9e5dc2066b62c3dd2bcb4824690d5cd558d306d118d655479598fb269439cca45
7
+ data.tar.gz: 8f554170e76f87e4e33a6d160969e8b84dd03c1febd3c91b969fab036d63bb19c1ec6eed1a696693e19454ae02cf053e40ab4e96c318e87e677d5f50e5258991
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- calabash-android (0.4.16)
4
+ calabash-android (0.4.19.pre3)
5
5
  awesome_print
6
6
  cucumber
7
7
  escape (~> 0.0.4)
@@ -17,7 +17,7 @@ GEM
17
17
  specs:
18
18
  awesome_print (1.2.0)
19
19
  builder (3.2.2)
20
- cucumber (1.3.9)
20
+ cucumber (1.3.10)
21
21
  builder (>= 2.1.2)
22
22
  diff-lcs (>= 1.1.3)
23
23
  gherkin (~> 2.12)
@@ -31,7 +31,7 @@ GEM
31
31
  json (1.8.1)
32
32
  mime-types (2.0)
33
33
  multi_json (1.8.2)
34
- multi_test (0.0.2)
34
+ multi_test (0.0.3)
35
35
  rake (10.1.0)
36
36
  rest-client (1.6.7)
37
37
  mime-types (>= 1.16)
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ def build
15
15
  "package",
16
16
  "-debug",
17
17
  "-Dtools.dir=\"#{Env.tools_dir}\"",
18
- "-Dandroid.api.level=17",
18
+ "-Dandroid.api.level=19",
19
19
  "-Dversion=#{Calabash::Android::VERSION}",
20
20
  ]
21
21
  Dir.chdir(@test_server_dir) do
@@ -1,5 +1,5 @@
1
1
  module Calabash
2
2
  module Android
3
- VERSION = "0.4.19.pre2"
3
+ VERSION = "0.4.19.pre3"
4
4
  end
5
5
  end
@@ -10,7 +10,7 @@
10
10
  (!!(t==='object' && object[property])) ||
11
11
  t==='unknown';
12
12
  }
13
- //http://www.w3.org/TR/DOM-Level-2-Core/core.html
13
+ /*http://www.w3.org/TR/DOM-Level-2-Core/core.html*/
14
14
  var NODE_TYPES = {
15
15
  /*ELEMENT_NODE : */ 1 : 'ELEMENT_NODE',
16
16
  /*ATTRIBUTE_NODE : */ 2: 'ATTRIBUTE_NODE',
@@ -75,14 +75,14 @@
75
75
 
76
76
 
77
77
  }
78
- else if (object instanceof Node)//TODO: support for frames!
78
+ else if (object instanceof Node)
79
79
  {
80
80
  res = computeRectForNode(object);
81
81
  }
82
- else if (object instanceof NodeList || //TODO: support for frames!
82
+ else if (object instanceof NodeList ||
83
83
  (typeof object=='object' && object &&
84
84
  typeof object.length === 'number' &&
85
- object.length > 0 //array like
85
+ object.length > 0
86
86
  && typeof object[0] !== 'undefined'))
87
87
  {
88
88
  res = [];
@@ -97,9 +97,6 @@
97
97
  }
98
98
  return res;
99
99
  }
100
- ///TODO: no support for now frames
101
- //idea would be map XPath across window.frames
102
- //must take care of visibility questions
103
100
 
104
101
  var exp = '%@'/* dynamic */,
105
102
  queryType = '%@',
@@ -1,5 +1,7 @@
1
1
  package sh.calaba.instrumentationbackend.actions.webview;
2
2
 
3
+ import java.io.IOException;
4
+ import java.lang.RuntimeException;
3
5
  import java.lang.reflect.Field;
4
6
  import java.lang.reflect.Method;
5
7
  import java.util.ArrayList;
@@ -13,10 +15,14 @@ import java.util.concurrent.TimeoutException;
13
15
 
14
16
  import android.os.Looper;
15
17
  import sh.calaba.instrumentationbackend.InstrumentationBackend;
18
+ import sh.calaba.org.codehaus.jackson.map.ObjectMapper;
19
+ import sh.calaba.org.codehaus.jackson.type.TypeReference;
20
+
16
21
  import android.os.Build;
17
22
  import android.os.ConditionVariable;
18
23
  import android.view.View;
19
24
  import android.webkit.JsPromptResult;
25
+ import android.webkit.ValueCallback;
20
26
  import android.webkit.WebChromeClient;
21
27
  import android.webkit.WebView;
22
28
 
@@ -144,7 +150,25 @@ public class CalabashChromeClient extends WebChromeClient {
144
150
  return scriptFuture;
145
151
  }
146
152
 
147
- @SuppressWarnings("rawtypes")
153
+ public void evaluateCalabashScript(String script) {
154
+ webView.evaluateJavascript(script, new ValueCallback<String>() {
155
+ public void onReceiveValue(String rawResponseJSON) {
156
+ String jsonResponse = null;
157
+
158
+ try {
159
+ jsonResponse = new ObjectMapper().readValue(
160
+ rawResponseJSON, new TypeReference<String>() {
161
+ });
162
+ } catch (IOException e) {
163
+ throw new RuntimeException("Incorrect JSON format returned from javascript: " + rawResponseJSON, e);
164
+ }
165
+
166
+ scriptFuture.setResult(jsonResponse);
167
+ }
168
+ });
169
+ }
170
+
171
+ @SuppressWarnings("rawtypes")
148
172
  public static class WebFuture implements Future {
149
173
  private final ConditionVariable eventHandled;
150
174
  private volatile boolean complete;
@@ -12,6 +12,7 @@ import sh.calaba.instrumentationbackend.InstrumentationBackend;
12
12
  import sh.calaba.instrumentationbackend.actions.webview.CalabashChromeClient.WebFuture;
13
13
  import sh.calaba.org.codehaus.jackson.map.ObjectMapper;
14
14
  import android.util.Log;
15
+ import android.webkit.ValueCallback;
15
16
  import android.webkit.WebView;
16
17
 
17
18
  public class QueryHelper {
@@ -89,17 +90,21 @@ public class QueryHelper {
89
90
  }
90
91
 
91
92
  public static WebFuture executeAsyncJavascriptInWebviews(WebView webView,
92
- String scriptPath, String selector, String type) {
93
+ String scriptPath, String selector, String type) {
93
94
 
94
95
  String script = readJavascriptFromAsset(scriptPath);
95
96
 
96
97
  script = script.replaceFirst("%@", selector);
97
98
  script = script.replaceFirst("%@", type);
98
-
99
- CalabashChromeClient chromeClient = CalabashChromeClient.prepareWebView(webView);
100
- webView.loadUrl("javascript:calabash_result = " + script + ";prompt('calabash:' + calabash_result);");
101
- return chromeClient.getResult();
102
- }
103
99
 
100
+ CalabashChromeClient chromeClient = CalabashChromeClient.prepareWebView(webView);
101
+
102
+ if (android.os.Build.VERSION.SDK_INT < 19) { // Android 4.4
103
+ webView.loadUrl("javascript:calabash_result = " + script + ";prompt('calabash:' + calabash_result);");
104
+ } else {
105
+ chromeClient.evaluateCalabashScript(script);
106
+ }
104
107
 
108
+ return chromeClient.getResult();
109
+ }
105
110
  }
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.pre2
4
+ version: 0.4.19.pre3
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: 2014-01-02 00:00:00.000000000 Z
11
+ date: 2014-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber