calabash-android 0.2.10 → 0.2.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,8 @@
1
+ 0.2.11:
2
+ Added is_enabled action that determines if a view is enabled.
3
+
4
+ Cleaner return values when executing javascript.
5
+
1
6
  0.2.10:
2
7
  Various small improvements and bug fixes.
3
8
 
@@ -1,6 +1,6 @@
1
1
  module Calabash
2
2
  module Android
3
- VERSION = "0.2.10"
4
- FRAMEWORK_VERSION = "0.2.10"
3
+ VERSION = "0.2.11"
4
+ FRAMEWORK_VERSION = "0.2.11"
5
5
  end
6
6
  end
@@ -64,6 +64,14 @@ public class Result {
64
64
  public static Result successResult() {
65
65
  return successResult;
66
66
  }
67
+
68
+ public static Result failedResult() {
69
+ return new Result(false);
70
+ }
71
+
72
+ public static Result failedResult(final String message) {
73
+ return new Result(false, message);
74
+ }
67
75
 
68
76
  public String toString() {
69
77
  return "Success: " + success + ", message: " + message;
@@ -77,7 +77,7 @@ public class HttpServer extends NanoHTTPD {
77
77
  lock.unlock();
78
78
  }
79
79
 
80
- } else if ("/ready".equals(uri)) {
80
+ } else if (uri.endsWith("/ready")) {
81
81
  return new Response(HTTP_OK, MIME_HTML, Boolean.toString(ready));
82
82
 
83
83
 
@@ -0,0 +1,30 @@
1
+ package sh.calaba.instrumentationbackend.actions.view;
2
+
3
+ import sh.calaba.instrumentationbackend.Result;
4
+ import sh.calaba.instrumentationbackend.TestHelpers;
5
+ import sh.calaba.instrumentationbackend.actions.Action;
6
+ import android.view.View;
7
+
8
+ public class IsEnabled implements Action {
9
+
10
+ @Override
11
+ public Result execute(String... args) {
12
+ final String firstArgument = args[0];
13
+ final View foundView = TestHelpers.getViewById(firstArgument);
14
+
15
+ if( null == foundView ) {
16
+ return notFoundResult(firstArgument);
17
+ }
18
+
19
+ return new Result(foundView.isEnabled());
20
+ }
21
+
22
+ @Override
23
+ public String key() {
24
+ return "is_enabled";
25
+ }
26
+
27
+ private Result notFoundResult(final String firstArgument) {
28
+ return Result.failedResult(String.format("View with id %s was not found", firstArgument));
29
+ }
30
+ }
@@ -13,9 +13,16 @@ public class ExecuteJavascript implements Action {
13
13
  CalabashChromeClient ccc = CalabashChromeClient.findAndPrepareWebViews().get(0);
14
14
  final WebView webView = ccc.getWebView();
15
15
  final String script = "javascript:(function() {"
16
- + "var result;"
16
+ + " var r;"
17
+ + " try {"
18
+ + " r = (function() {"
17
19
  + args[0] + ";"
18
- + "prompt('calabash:'+result);" + "})()";
20
+ + " }());"
21
+ + " } catch (e) {"
22
+ + " r = 'Exception: ' + e;"
23
+ + " }"
24
+ + " prompt('calabash:'+r);"
25
+ + "}())";
19
26
 
20
27
  System.out.println("execute javascript: " + script);
21
28
 
@@ -30,7 +37,12 @@ public class ExecuteJavascript implements Action {
30
37
  String r = ccc.getResult();
31
38
  System.out.println("javascript result: " + r);
32
39
 
33
- return new Result(true, r);
40
+ boolean success = true;
41
+ if (r.startsWith("Exception:")) {
42
+ success = false;
43
+ }
44
+
45
+ return new Result(success, r);
34
46
  }
35
47
 
36
48
  @Override
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-android
3
3
  version: !ruby/object:Gem::Version
4
- hash: 3
4
+ hash: 1
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 10
10
- version: 0.2.10
9
+ - 11
10
+ version: 0.2.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jonas Maturana Larsen
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-08-13 00:00:00 +02:00
18
+ date: 2012-08-14 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -197,6 +197,7 @@ files:
197
197
  - test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/time/SetTimeByContentDescription.java
198
198
  - test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/time/SetTimeByIndex.java
199
199
  - test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/ClickOnViewById.java
200
+ - test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/IsEnabled.java
200
201
  - test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/LongPressOnViewById.java
201
202
  - test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/Press.java
202
203
  - test-server/instrumentation-backend/src/sh/calaba/instrumentationbackend/actions/view/WaitForView.java