honeydew 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (21) hide show
  1. data/lib/honeydew/device.rb +3 -1
  2. data/lib/honeydew/version.rb +1 -1
  3. data/server/pom.xml +1 -1
  4. data/server/src/main/java/com/amplify/honeydew_server/Action.java +8 -0
  5. data/server/src/main/java/com/amplify/honeydew_server/actions/Click.java +9 -2
  6. data/server/src/main/java/com/amplify/honeydew_server/actions/ClickAndWaitForNewWindow.java +9 -2
  7. data/server/src/main/java/com/amplify/honeydew_server/actions/HasSettingsMenuItem.java +2 -1
  8. data/server/src/main/java/com/amplify/honeydew_server/actions/InspectOptionInSettingsMenu.java +5 -1
  9. data/server/src/main/java/com/amplify/honeydew_server/actions/IsButtonPresent.java +1 -1
  10. data/server/src/main/java/com/amplify/honeydew_server/actions/IsElementWithNestedTextPresent.java +7 -2
  11. data/server/src/main/java/com/amplify/honeydew_server/actions/IsTextPresent.java +1 -1
  12. data/server/src/main/java/com/amplify/honeydew_server/actions/LaunchApp.java +15 -4
  13. data/server/src/main/java/com/amplify/honeydew_server/actions/LongClick.java +9 -2
  14. data/server/src/main/java/com/amplify/honeydew_server/actions/ScrollToTextByIndex.java +6 -1
  15. data/server/src/main/java/com/amplify/honeydew_server/actions/SelectFromAppsList.java +15 -3
  16. data/server/src/main/java/com/amplify/honeydew_server/actions/SelectMenuInSettings.java +14 -3
  17. data/server/src/main/java/com/amplify/honeydew_server/actions/SetText.java +9 -3
  18. data/server/src/main/java/com/amplify/honeydew_server/actions/SetTextByIndex.java +14 -8
  19. data/server/src/main/java/com/amplify/honeydew_server/actions/SetTextByLabel.java +9 -5
  20. data/server/src/main/java/com/amplify/honeydew_server/actions/Unlock.java +4 -4
  21. metadata +3 -3
@@ -38,6 +38,8 @@ module Honeydew
38
38
  def perform_assertion action, arguments = {}, options = {}
39
39
  ensure_device_ready
40
40
 
41
+ arguments[:timeout] = Honeydew.config.timeout.to_s
42
+
41
43
  log "performing assertion #{action} with arguments #{arguments}"
42
44
  Timeout.timeout Honeydew.config.timeout.to_i, FinderTimeout do
43
45
  begin
@@ -53,7 +55,7 @@ module Honeydew
53
55
 
54
56
  def perform_action action, arguments = {}, options = {}
55
57
  ensure_device_ready
56
-
58
+ arguments[:timeout] = Honeydew.config.timeout.to_s
57
59
  log "performing action #{action} with arguments #{arguments}"
58
60
  send_command action, arguments
59
61
  end
@@ -1,3 +1,3 @@
1
1
  module Honeydew
2
- VERSION = '0.14.0'
2
+ VERSION = '0.15.0'
3
3
  end
data/server/pom.xml CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  <groupId>amplify</groupId>
7
7
  <artifactId>honeydew-server</artifactId>
8
- <version>0.14.0</version>
8
+ <version>0.15.0</version>
9
9
  <packaging>jar</packaging>
10
10
  <name>Honeydew Android Server</name>
11
11
 
@@ -23,6 +23,14 @@ public abstract class Action {
23
23
  return uiDevice;
24
24
  }
25
25
 
26
+ private Integer getTimeoutInMs(Map<String, Object> arguments){
27
+ return Integer.parseInt((String) arguments.get("timeout")) * 1000;
28
+ }
29
+
30
+ protected boolean isUiObjectAvailable(UiObject uiObject, Map<String, Object> arguments){
31
+ return uiObject.waitForExists(getTimeoutInMs(arguments));
32
+ }
33
+
26
34
  protected UiObject getUiObject(Map<String, Object> arguments) {
27
35
  ViewSelector viewSelector = getViewSelector(arguments);
28
36
  return viewSelector.find();
@@ -3,6 +3,7 @@ package com.amplify.honeydew_server.actions;
3
3
  import com.amplify.honeydew_server.Action;
4
4
  import com.amplify.honeydew_server.Result;
5
5
  import com.android.uiautomator.core.UiDevice;
6
+ import com.android.uiautomator.core.UiObject;
6
7
  import com.android.uiautomator.core.UiObjectNotFoundException;
7
8
 
8
9
  import java.util.Map;
@@ -14,7 +15,13 @@ public class Click extends Action {
14
15
 
15
16
  @Override
16
17
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
- getUiObject(arguments).click();
18
- return Result.OK;
18
+ final UiObject uiObject = getUiObject(arguments);
19
+
20
+ if (isUiObjectAvailable(uiObject, arguments)) {
21
+ uiObject.click();
22
+ return Result.OK;
23
+ }
24
+
25
+ return Result.FAILURE;
19
26
  }
20
27
  }
@@ -1,6 +1,7 @@
1
1
  package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.UiDevice;
4
+ import com.android.uiautomator.core.UiObject;
4
5
  import com.android.uiautomator.core.UiObjectNotFoundException;
5
6
  import com.amplify.honeydew_server.Action;
6
7
  import com.amplify.honeydew_server.Result;
@@ -14,7 +15,13 @@ public class ClickAndWaitForNewWindow extends Action {
14
15
 
15
16
  @Override
16
17
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
- getUiObject(arguments).clickAndWaitForNewWindow();
18
- return Result.OK;
18
+ final UiObject uiObject = getUiObject(arguments);
19
+
20
+ if (isUiObjectAvailable(uiObject, arguments)) {
21
+ uiObject.clickAndWaitForNewWindow();
22
+ return Result.OK;
23
+ }
24
+
25
+ return Result.FAILURE;
19
26
  }
20
27
  }
@@ -15,8 +15,9 @@ public class HasSettingsMenuItem extends Action {
15
15
  @Override
16
16
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
17
  String menuName = (String) arguments.get("menuName");
18
+
18
19
  UiScrollable settingsMenu = new UiScrollable(new UiSelector().scrollable(true).focused(true));
19
20
  UiObject menuItem = settingsMenu.getChildByText(new UiSelector().className(TextView.class.getName()), menuName);
20
- return menuItem.exists() ? Result.OK : Result.FAILURE;
21
+ return isUiObjectAvailable(menuItem, arguments) ? Result.OK : Result.FAILURE;
21
22
  }
22
23
  }
@@ -21,9 +21,13 @@ public abstract class InspectOptionInSettingsMenu extends SelectMenuInSettings {
21
21
  List<String> optionNames = (List<String>)arguments.get("optionNames");
22
22
  UiScrollable optionsMenu = new UiScrollable(new UiSelector().className("android.widget.ListView").packageName("com.android.settings").focused(false));
23
23
 
24
+ if(!isUiObjectAvailable(optionsMenu, arguments)){
25
+ return Result.FAILURE;
26
+ }
27
+
24
28
  for (String optionName : optionNames) {
25
29
  UiObject option = optionsMenu.getChildByText(new UiSelector().className(TextView.class.getName()), optionName);
26
- if (!enabled.equals(option.isEnabled())) {
30
+ if (!isUiObjectAvailable(option, arguments) && !enabled.equals(option.isEnabled())) {
27
31
  return Result.FAILURE;
28
32
  }
29
33
  }
@@ -18,6 +18,6 @@ public class IsButtonPresent extends Action {
18
18
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
19
19
  String text = (String) arguments.get("text");
20
20
  UiObject textView = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).textContains(text));
21
- return textView.exists() ? Result.OK : Result.FAILURE;
21
+ return isUiObjectAvailable(textView, arguments) ? Result.OK : Result.FAILURE;
22
22
  }
23
23
  }
@@ -1,8 +1,12 @@
1
1
  package com.amplify.honeydew_server.actions;
2
2
 
3
- import com.android.uiautomator.core.*;
4
3
  import com.amplify.honeydew_server.Action;
5
4
  import com.amplify.honeydew_server.Result;
5
+ import com.android.uiautomator.core.UiCollection;
6
+ import com.android.uiautomator.core.UiDevice;
7
+ import com.android.uiautomator.core.UiObject;
8
+ import com.android.uiautomator.core.UiObjectNotFoundException;
9
+ import com.android.uiautomator.core.UiSelector;
6
10
 
7
11
  import java.util.Map;
8
12
 
@@ -18,7 +22,8 @@ public class IsElementWithNestedTextPresent extends Action {
18
22
 
19
23
  UiCollection parentElement = new UiCollection(new UiSelector().description(parentDescription));
20
24
  UiObject child = parentElement.getChild(new UiSelector().text(childText));
21
- return child.exists() ? Result.OK : Result.FAILURE;
25
+
26
+ return isUiObjectAvailable(child, arguments) ? Result.OK : Result.FAILURE;
22
27
  }
23
28
 
24
29
  }
@@ -14,6 +14,6 @@ public class IsTextPresent extends Action {
14
14
 
15
15
  @Override
16
16
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
- return getUiObject(arguments).exists() ? Result.OK : Result.FAILURE;
17
+ return isUiObjectAvailable(getUiObject(arguments), arguments) ? Result.OK : Result.FAILURE;
18
18
  }
19
19
  }
@@ -15,11 +15,22 @@ public class LaunchApp extends Action {
15
15
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
16
16
  String appName = (String) arguments.get("appName");
17
17
  getUiDevice().pressHome();
18
- new UiObject(new UiSelector().description("Apps")).click();
18
+ final UiObject uiObject = new UiObject(new UiSelector().description("Apps"));
19
+
20
+ if(isUiObjectAvailable(uiObject,arguments)){
21
+ uiObject.click();
22
+ }else{
23
+ return Result.FAILURE;
24
+ }
19
25
 
20
26
  UiScrollable appViews = new UiScrollable(new UiSelector().scrollable(true));
21
- appViews.setAsHorizontalList();
22
- appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()), appName).clickAndWaitForNewWindow();
23
- return Result.OK;
27
+
28
+ if(isUiObjectAvailable(appViews, arguments)){
29
+ appViews.setAsHorizontalList();
30
+ appViews.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()), appName).clickAndWaitForNewWindow();
31
+ return Result.OK;
32
+ }
33
+
34
+ return Result.FAILURE;
24
35
  }
25
36
  }
@@ -1,6 +1,7 @@
1
1
  package com.amplify.honeydew_server.actions;
2
2
 
3
3
  import com.android.uiautomator.core.UiDevice;
4
+ import com.android.uiautomator.core.UiObject;
4
5
  import com.android.uiautomator.core.UiObjectNotFoundException;
5
6
  import com.amplify.honeydew_server.Action;
6
7
  import com.amplify.honeydew_server.Result;
@@ -14,7 +15,13 @@ public class LongClick extends Action {
14
15
 
15
16
  @Override
16
17
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
- getUiObject(arguments).longClick();
18
- return Result.OK;
18
+ final UiObject uiObject = getUiObject(arguments);
19
+
20
+ if(isUiObjectAvailable(uiObject, arguments)){
21
+ uiObject.longClick();
22
+ return Result.OK;
23
+ }
24
+
25
+ return Result.FAILURE;
19
26
  }
20
27
  }
@@ -22,6 +22,11 @@ public class ScrollToTextByIndex extends Action {
22
22
  UiSelector scrollSelector = new UiSelector().scrollable(true).index(index);
23
23
  UiScrollable uiScrollable = new UiScrollable(scrollSelector);
24
24
 
25
- return uiScrollable.scrollTextIntoView(text) ? Result.OK : Result.FAILURE;
25
+ if(isUiObjectAvailable(uiScrollable, arguments)){
26
+ uiScrollable.scrollTextIntoView(text);
27
+ return Result.OK;
28
+ }
29
+
30
+ return Result.FAILURE;
26
31
  }
27
32
  }
@@ -1,5 +1,6 @@
1
1
  package com.amplify.honeydew_server.actions;
2
2
 
3
+ import android.widget.TextView;
3
4
  import com.android.uiautomator.core.*;
4
5
  import com.amplify.honeydew_server.Action;
5
6
  import com.amplify.honeydew_server.Result;
@@ -13,12 +14,23 @@ public class SelectFromAppsList extends Action {
13
14
 
14
15
  @Override
15
16
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
16
- String appName = (String)arguments.get("appName");
17
+ String appName = (String) arguments.get("appName");
17
18
  //TODO: Using a better selector
18
19
  UiScrollable settingsMenu = new UiScrollable(new UiSelector().scrollable(true).focused(false));
20
+
21
+ if (!isUiObjectAvailable(settingsMenu, arguments)) {
22
+ return Result.FAILURE;
23
+ }
24
+
19
25
  settingsMenu.setAsVerticalList();
26
+ final UiSelector childPattern = new UiSelector().className(TextView.class.getName());
27
+ final UiObject childByText = settingsMenu.getChildByText(childPattern, appName);
28
+
29
+ if (isUiObjectAvailable(childByText, arguments)) {
30
+ childByText.click();
31
+ return Result.OK;
32
+ }
20
33
 
21
- (settingsMenu.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),appName)).click();
22
- return Result.OK;
34
+ return Result.FAILURE;
23
35
  }
24
36
  }
@@ -1,5 +1,6 @@
1
1
  package com.amplify.honeydew_server.actions;
2
2
 
3
+ import android.widget.TextView;
3
4
  import com.android.uiautomator.core.*;
4
5
  import com.amplify.honeydew_server.Action;
5
6
  import com.amplify.honeydew_server.Result;
@@ -14,9 +15,19 @@ public class SelectMenuInSettings extends Action {
14
15
  @Override
15
16
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
16
17
  String menuName = (String) arguments.get("menuName");
17
- UiScrollable settingsMenu = new UiScrollable(new UiSelector().scrollable(true).focused(true));
18
18
 
19
- (settingsMenu.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),menuName)).click();
20
- return Result.OK;
19
+ final UiScrollable settingsMenu = new UiScrollable(new UiSelector().scrollable(true).focused(true));
20
+ if(!isUiObjectAvailable(settingsMenu,arguments)){
21
+ return Result.FAILURE;
22
+ }
23
+
24
+ final UiSelector childPattern = new UiSelector().className(TextView.class.getName());
25
+ final UiObject childByText = settingsMenu.getChildByText(childPattern, menuName);
26
+ if (isUiObjectAvailable(childByText, arguments)) {
27
+ childByText.click();
28
+ return Result.OK;
29
+ }
30
+
31
+ return Result.FAILURE;
21
32
  }
22
33
  }
@@ -19,9 +19,15 @@ public class SetText extends Action {
19
19
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
20
20
  String textDescription = (String) arguments.get("description");
21
21
  String text = (String) arguments.get("text");
22
+
22
23
  UiObject textField = new UiObject(new UiSelector().description(textDescription));
23
- textField.setText(text);
24
- uiDevice.pressDPadDown();
25
- return Result.OK;
24
+
25
+ if(isUiObjectAvailable(textField, arguments)){
26
+ textField.setText(text);
27
+ uiDevice.pressDPadDown();
28
+ return Result.OK;
29
+ }
30
+
31
+ return Result.FAILURE;
26
32
  }
27
33
  }
@@ -1,10 +1,13 @@
1
1
  package com.amplify.honeydew_server.actions;
2
2
 
3
- import android.util.*;
4
- import com.android.uiautomator.core.*;
5
- import com.amplify.honeydew_server.*;
3
+ import com.amplify.honeydew_server.Action;
4
+ import com.amplify.honeydew_server.Result;
5
+ import com.android.uiautomator.core.UiDevice;
6
+ import com.android.uiautomator.core.UiObject;
7
+ import com.android.uiautomator.core.UiObjectNotFoundException;
8
+ import com.android.uiautomator.core.UiSelector;
6
9
 
7
- import java.util.*;
10
+ import java.util.Map;
8
11
 
9
12
  public class SetTextByIndex extends Action {
10
13
 
@@ -14,12 +17,15 @@ public class SetTextByIndex extends Action {
14
17
 
15
18
  @Override
16
19
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
- Log.i("SetTextByIndex", "Found index field: " + arguments.get("index"));
18
20
  int index = Integer.parseInt((String) arguments.get("index"));
19
21
  String text = (String) arguments.get("text");
20
22
  UiObject textField = new UiObject(new UiSelector().className("android.widget.EditText").index(index));
21
- Log.i("SetTextByIndex", "Found text field: " + textField);
22
- textField.setText(text);
23
- return Result.OK;
23
+
24
+ if (isUiObjectAvailable(textField, arguments)) {
25
+ textField.setText(text);
26
+ return Result.OK;
27
+ }
28
+
29
+ return Result.FAILURE;
24
30
  }
25
31
  }
@@ -19,10 +19,14 @@ public class SetTextByLabel extends Action {
19
19
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
20
20
  String label = (String) arguments.get("label");
21
21
  String inputText = (String) arguments.get("text");
22
- UiObject textField = null;
23
- textField = new UiObject(new UiSelector().text(label));
24
- textField.setText(inputText);
25
- uiDevice.pressDPadDown();
26
- return Result.OK;
22
+ UiObject textField = new UiObject(new UiSelector().text(label));
23
+
24
+ if (isUiObjectAvailable(textField, arguments)) {
25
+ textField.setText(inputText);
26
+ uiDevice.pressDPadDown();
27
+ return Result.OK;
28
+ }
29
+
30
+ return Result.FAILURE;
27
31
  }
28
32
  }
@@ -1,11 +1,11 @@
1
1
  package com.amplify.honeydew_server.actions;
2
2
 
3
+ import com.amplify.honeydew_server.Action;
4
+ import com.amplify.honeydew_server.Result;
3
5
  import com.android.uiautomator.core.UiDevice;
4
6
  import com.android.uiautomator.core.UiObject;
5
7
  import com.android.uiautomator.core.UiObjectNotFoundException;
6
8
  import com.android.uiautomator.core.UiSelector;
7
- import com.amplify.honeydew_server.Action;
8
- import com.amplify.honeydew_server.Result;
9
9
 
10
10
  import java.util.Map;
11
11
 
@@ -17,9 +17,9 @@ public class Unlock extends Action {
17
17
  @Override
18
18
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
19
19
  UiObject uiObject = new UiObject(new UiSelector().description("Slide area."));
20
- uiObject = uiObject.exists() ? uiObject : new UiObject(new UiSelector().className("android.view.View"));
20
+ uiObject = isUiObjectAvailable(uiObject, arguments) ? uiObject : new UiObject(new UiSelector().className("android.view.View"));
21
21
  try {
22
- if (uiObject.exists()) {
22
+ if (isUiObjectAvailable(uiObject, arguments)) {
23
23
  uiObject.swipeRight(100);
24
24
  }
25
25
  } catch (UiObjectNotFoundException e) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: honeydew
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-07-15 00:00:00.000000000 Z
15
+ date: 2013-07-17 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activesupport
@@ -198,7 +198,7 @@ files:
198
198
  - spec/honeydew/device_matchers_spec.rb
199
199
  - spec/honeydew/device_spec.rb
200
200
  - spec/spec_helper.rb
201
- - server/target/honeydew-server-0.14.0.jar
201
+ - server/target/honeydew-server-0.15.0.jar
202
202
  homepage:
203
203
  licenses: []
204
204
  post_install_message: