honeydew 0.1.4

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.
Files changed (72) hide show
  1. data/.gitignore +21 -0
  2. data/.rspec +2 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +22 -0
  5. data/README.md +29 -0
  6. data/Rakefile +17 -0
  7. data/android-server/.gitignore +4 -0
  8. data/android-server/pom.xml +215 -0
  9. data/android-server/repo/com/google/android/uiautomator/4.1.1.4/_maven.repositories +4 -0
  10. data/android-server/repo/com/google/android/uiautomator/4.1.1.4/uiautomator-4.1.1.4.jar +0 -0
  11. data/android-server/repo/com/google/android/uiautomator/4.1.1.4/uiautomator-4.1.1.4.pom +9 -0
  12. data/android-server/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/android-maven-plugin-3.5.2-SNAPSHOT.jar +0 -0
  13. data/android-server/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/android-maven-plugin-3.5.2-SNAPSHOT.pom +56 -0
  14. data/android-server/repo/com/jayway/maven/plugins/android/generation2/android-maven-plugin/3.5.2-SNAPSHOT/maven-metadata-local.xml +24 -0
  15. data/android-server/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/_maven.repositories +4 -0
  16. data/android-server/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/commons-jxpath-1.4-SNAPSHOT.jar +0 -0
  17. data/android-server/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/commons-jxpath-1.4-SNAPSHOT.pom +9 -0
  18. data/android-server/repo/commons-jxpath/commons-jxpath/1.4-SNAPSHOT/maven-metadata-local.xml +24 -0
  19. data/android-server/repo/commons-jxpath/commons-jxpath/maven-metadata-local.xml +11 -0
  20. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/Action.java +65 -0
  21. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/ActionsExecutor.java +73 -0
  22. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/Command.java +16 -0
  23. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/Result.java +36 -0
  24. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/TestRunner.java +26 -0
  25. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/Click.java +20 -0
  26. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/ClickAndWaitForNewWindow.java +20 -0
  27. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/DumpWindowHierarchy.java +28 -0
  28. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/HasSettingsMenuItem.java +23 -0
  29. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/InspectOptionInSettingsMenu.java +32 -0
  30. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/IsButtonPresent.java +23 -0
  31. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/IsChildCountEqualTo.java +26 -0
  32. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/IsElementWithNestedTextPresent.java +24 -0
  33. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/IsOptionInSettingsMenuDisabled.java +9 -0
  34. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/IsOptionInSettingsMenuEnabled.java +9 -0
  35. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/IsTextPresent.java +19 -0
  36. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/LaunchApp.java +25 -0
  37. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/LaunchHome.java +19 -0
  38. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/LongClick.java +20 -0
  39. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/PressBack.java +19 -0
  40. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/PressEnter.java +19 -0
  41. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/SelectFromAppsList.java +24 -0
  42. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/SelectMenuInSettings.java +22 -0
  43. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/SetText.java +27 -0
  44. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/SetTextByIndex.java +25 -0
  45. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/SetTextByLabel.java +28 -0
  46. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/Unlock.java +31 -0
  47. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/actions/WakeUp.java +24 -0
  48. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/httpd/NanoHTTPD.java +1100 -0
  49. data/android-server/src/main/java/com/uiautomator_cucumber/android_server/httpd/RemoteCommandReceiver.java +64 -0
  50. data/example/Gemfile +5 -0
  51. data/example/Rakefile +9 -0
  52. data/example/features/example.feature +10 -0
  53. data/example/features/step_definitions/honeydew_steps.rb +1 -0
  54. data/example/features/support/hooks.rb +4 -0
  55. data/honeydew.gemspec +28 -0
  56. data/honeydew.iml +28 -0
  57. data/lib/honeydew/cucumber.rb +4 -0
  58. data/lib/honeydew/device.rb +79 -0
  59. data/lib/honeydew/device_actions.rb +151 -0
  60. data/lib/honeydew/device_commands.rb +84 -0
  61. data/lib/honeydew/device_matchers.rb +52 -0
  62. data/lib/honeydew/dsl.rb +9 -0
  63. data/lib/honeydew/hooks.rb +0 -0
  64. data/lib/honeydew/step_definitions.rb +75 -0
  65. data/lib/honeydew/version.rb +3 -0
  66. data/lib/honeydew.rb +72 -0
  67. data/lib/tasks/honeydew.rake +7 -0
  68. data/spec/honeydew/device_matchers_spec.rb +58 -0
  69. data/spec/honeydew/device_spec.rb +66 -0
  70. data/spec/spec_helper.rb +39 -0
  71. data/todo.md +9 -0
  72. metadata +232 -0
@@ -0,0 +1,36 @@
1
+ package com.uiautomator_cucumber.android_server;
2
+
3
+ import org.apache.commons.lang.exception.ExceptionUtils;
4
+
5
+ public class Result {
6
+ private final boolean success;
7
+ private String description;
8
+ private String errorMessage;
9
+ private String stackTrace;
10
+
11
+ public static Result OK = new Result();
12
+ public static Result FAILURE = new Result(false);
13
+
14
+ public Result() {
15
+ this.success = true;
16
+ }
17
+
18
+ public Result(boolean success) {
19
+ this.success = success;
20
+ }
21
+
22
+ public Result(boolean success, String description) {
23
+ this.success = success;
24
+ this.description = description;
25
+ }
26
+
27
+ public Result(String errorMessage, Throwable exception) {
28
+ this(errorMessage);
29
+ this.stackTrace = ExceptionUtils.getFullStackTrace(exception);
30
+ }
31
+
32
+ public Result(String errorMessage) {
33
+ this.success = false;
34
+ this.errorMessage = errorMessage;
35
+ }
36
+ }
@@ -0,0 +1,26 @@
1
+ package com.uiautomator_cucumber.android_server;
2
+
3
+ import android.view.KeyEvent;
4
+ import com.android.uiautomator.core.UiDevice;
5
+ import com.android.uiautomator.testrunner.UiAutomatorTestCase;
6
+ import com.uiautomator_cucumber.android_server.httpd.RemoteCommandReceiver;
7
+
8
+ public class TestRunner extends UiAutomatorTestCase {
9
+
10
+ public static final String TAG = "UIAutomatorRemote";
11
+
12
+ public void testRemoteLoop() throws Exception {
13
+ UiDevice uiDevice = getUiDevice();
14
+ uiDevice.wakeUp();
15
+ unlockEmulator();
16
+
17
+ new RemoteCommandReceiver(new ActionsExecutor(uiDevice));
18
+ }
19
+
20
+ private void unlockEmulator() {
21
+ getUiDevice().pressKeyCode(KeyEvent.KEYCODE_SOFT_LEFT);
22
+ getUiDevice().pressKeyCode(KeyEvent.KEYCODE_SOFT_RIGHT);
23
+ getUiDevice().pressKeyCode(KeyEvent.KEYCODE_MENU);
24
+ getUiDevice().pressKeyCode(KeyEvent.KEYCODE_MENU);
25
+ }
26
+ }
@@ -0,0 +1,20 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.UiDevice;
4
+ import com.android.uiautomator.core.UiObjectNotFoundException;
5
+ import com.uiautomator_cucumber.android_server.Action;
6
+ import com.uiautomator_cucumber.android_server.Result;
7
+
8
+ import java.util.Map;
9
+
10
+ public class Click extends Action {
11
+ public Click(UiDevice uiDevice) {
12
+ super(uiDevice);
13
+ }
14
+
15
+ @Override
16
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
+ getUiObject(arguments).click();
18
+ return Result.OK;
19
+ }
20
+ }
@@ -0,0 +1,20 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.UiDevice;
4
+ import com.android.uiautomator.core.UiObjectNotFoundException;
5
+ import com.uiautomator_cucumber.android_server.Action;
6
+ import com.uiautomator_cucumber.android_server.Result;
7
+
8
+ import java.util.Map;
9
+
10
+ public class ClickAndWaitForNewWindow extends Action {
11
+ public ClickAndWaitForNewWindow(UiDevice uiDevice) {
12
+ super(uiDevice);
13
+ }
14
+
15
+ @Override
16
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
+ getUiObject(arguments).clickAndWaitForNewWindow();
18
+ return Result.OK;
19
+ }
20
+ }
@@ -0,0 +1,28 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.UiDevice;
4
+ import com.android.uiautomator.core.UiObjectNotFoundException;
5
+ import com.uiautomator_cucumber.android_server.Action;
6
+ import com.uiautomator_cucumber.android_server.Result;
7
+ import org.apache.commons.io.FileUtils;
8
+
9
+ import java.io.File;
10
+ import java.io.IOException;
11
+ import java.util.Map;
12
+
13
+ public class DumpWindowHierarchy extends Action {
14
+ public DumpWindowHierarchy(UiDevice uiDevice) {
15
+ super(uiDevice);
16
+ }
17
+
18
+ @Override
19
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
20
+ try {
21
+ FileUtils.forceMkdir(new File("/data/local/tmp/local/tmp/"));
22
+ } catch (IOException e) {
23
+ return new Result("Create directory failed", e);
24
+ }
25
+ uiDevice.dumpWindowHierarchy("honeydew-window-hierarchy");
26
+ return new Result(true, "/data/local/tmp/local/tmp/honeydew-window-hierarchy");
27
+ }
28
+ }
@@ -0,0 +1,23 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import android.widget.TextView;
4
+ import com.android.uiautomator.core.*;
5
+ import com.uiautomator_cucumber.android_server.Action;
6
+ import com.uiautomator_cucumber.android_server.Result;
7
+
8
+ import java.util.List;
9
+ import java.util.Map;
10
+
11
+ public class HasSettingsMenuItem extends Action {
12
+ public HasSettingsMenuItem(UiDevice uiDevice) {
13
+ super(uiDevice);
14
+ }
15
+
16
+ @Override
17
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
18
+ String menuName = (String) arguments.get("menuName");
19
+ UiScrollable settingsMenu = new UiScrollable(new UiSelector().scrollable(true).focused(true));
20
+ UiObject menuItem = settingsMenu.getChildByText(new UiSelector().className(TextView.class.getName()), menuName);
21
+ return menuItem.exists() ? Result.OK : Result.FAILURE;
22
+ }
23
+ }
@@ -0,0 +1,32 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import android.widget.TextView;
4
+ import com.android.uiautomator.core.*;
5
+ import com.uiautomator_cucumber.android_server.Result;
6
+
7
+ import java.util.List;
8
+ import java.util.Map;
9
+
10
+ public abstract class InspectOptionInSettingsMenu extends SelectMenuInSettings {
11
+ private Boolean enabled;
12
+
13
+ public InspectOptionInSettingsMenu(UiDevice uiDevice, boolean enabled) {
14
+ super(uiDevice);
15
+ this.enabled = enabled;
16
+ }
17
+
18
+ @Override
19
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
20
+ super.execute(arguments);
21
+ List<String> optionNames = (List<String>) arguments.get("optionNames");
22
+ UiScrollable optionsMenu = new UiScrollable(new UiSelector().className("android.widget.ListView").packageName("com.android.settings").focused(false));
23
+
24
+ for (String optionName : optionNames) {
25
+ UiObject option = optionsMenu.getChildByText(new UiSelector().className(TextView.class.getName()), optionName);
26
+ if (!enabled.equals(option.isEnabled())) {
27
+ return Result.FAILURE;
28
+ }
29
+ }
30
+ return Result.OK;
31
+ }
32
+ }
@@ -0,0 +1,23 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.UiDevice;
4
+ import com.android.uiautomator.core.UiObject;
5
+ import com.android.uiautomator.core.UiObjectNotFoundException;
6
+ import com.android.uiautomator.core.UiSelector;
7
+ import com.uiautomator_cucumber.android_server.Action;
8
+ import com.uiautomator_cucumber.android_server.Result;
9
+
10
+ import java.util.Map;
11
+
12
+ public class IsButtonPresent extends Action {
13
+ public IsButtonPresent(UiDevice uiDevice) {
14
+ super(uiDevice);
15
+ }
16
+
17
+ @Override
18
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
19
+ String text = (String) arguments.get("text");
20
+ UiObject textView = new UiObject(new UiSelector().className(android.widget.Button.class.getName()).textContains(text));
21
+ return textView.exists() ? Result.OK : Result.FAILURE;
22
+ }
23
+ }
@@ -0,0 +1,26 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.*;
4
+ import com.uiautomator_cucumber.android_server.Action;
5
+ import com.uiautomator_cucumber.android_server.Result;
6
+
7
+ import java.util.Map;
8
+
9
+ public class IsChildCountEqualTo extends Action {
10
+
11
+ public IsChildCountEqualTo(UiDevice uiDevice) {
12
+ super(uiDevice);
13
+ }
14
+
15
+ @Override
16
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
+ String parentDescription = (String) arguments.get("parent_description");
18
+ String childDescription = (String) arguments.get("child_description");
19
+ int childCount = ((Double)arguments.get("child_count")).intValue();
20
+
21
+ UiCollection parentElement = new UiCollection(new UiSelector().description(parentDescription));
22
+ int count = parentElement.getChildCount(new UiSelector().description(childDescription));
23
+ return new Result(childCount == count, "Actual count was: " + count + " when " + childCount + " was expected");
24
+ }
25
+
26
+ }
@@ -0,0 +1,24 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.*;
4
+ import com.uiautomator_cucumber.android_server.Action;
5
+ import com.uiautomator_cucumber.android_server.Result;
6
+
7
+ import java.util.Map;
8
+
9
+ public class IsElementWithNestedTextPresent extends Action {
10
+ public IsElementWithNestedTextPresent(UiDevice uiDevice) {
11
+ super(uiDevice);
12
+ }
13
+
14
+ @Override
15
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
16
+ String parentDescription = (String) arguments.get("parent_description");
17
+ String childText = (String) arguments.get("child_text");
18
+
19
+ UiCollection parentElement = new UiCollection(new UiSelector().description(parentDescription));
20
+ UiObject child = parentElement.getChild(new UiSelector().text(childText));
21
+ return child.exists() ? Result.OK : Result.FAILURE;
22
+ }
23
+
24
+ }
@@ -0,0 +1,9 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.UiDevice;
4
+
5
+ public class IsOptionInSettingsMenuDisabled extends InspectOptionInSettingsMenu {
6
+ public IsOptionInSettingsMenuDisabled(UiDevice uiDevice) {
7
+ super(uiDevice, false);
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.UiDevice;
4
+
5
+ public class IsOptionInSettingsMenuEnabled extends InspectOptionInSettingsMenu {
6
+ public IsOptionInSettingsMenuEnabled(UiDevice uiDevice) {
7
+ super(uiDevice, true);
8
+ }
9
+ }
@@ -0,0 +1,19 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.UiDevice;
4
+ import com.android.uiautomator.core.UiObjectNotFoundException;
5
+ import com.uiautomator_cucumber.android_server.Action;
6
+ import com.uiautomator_cucumber.android_server.Result;
7
+
8
+ import java.util.Map;
9
+
10
+ public class IsTextPresent extends Action {
11
+ public IsTextPresent(UiDevice uiDevice) {
12
+ super(uiDevice);
13
+ }
14
+
15
+ @Override
16
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
+ return getUiObject(arguments).exists() ? Result.OK : Result.FAILURE;
18
+ }
19
+ }
@@ -0,0 +1,25 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.*;
4
+ import com.uiautomator_cucumber.android_server.Action;
5
+ import com.uiautomator_cucumber.android_server.Result;
6
+
7
+ import java.util.Map;
8
+
9
+ public class LaunchApp extends Action {
10
+ public LaunchApp(UiDevice uiDevice) {
11
+ super(uiDevice);
12
+ }
13
+
14
+ @Override
15
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
16
+ String appName = (String) arguments.get("appName");
17
+ getUiDevice().pressHome();
18
+ new UiObject(new UiSelector().description("Apps")).click();
19
+
20
+ 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;
24
+ }
25
+ }
@@ -0,0 +1,19 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.*;
4
+ import com.uiautomator_cucumber.android_server.Action;
5
+ import com.uiautomator_cucumber.android_server.Result;
6
+
7
+ import java.util.Map;
8
+
9
+ public class LaunchHome extends Action {
10
+ public LaunchHome(UiDevice uiDevice) {
11
+ super(uiDevice);
12
+ }
13
+
14
+ @Override
15
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
16
+ getUiDevice().pressHome();
17
+ return Result.OK;
18
+ }
19
+ }
@@ -0,0 +1,20 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.UiDevice;
4
+ import com.android.uiautomator.core.UiObjectNotFoundException;
5
+ import com.uiautomator_cucumber.android_server.Action;
6
+ import com.uiautomator_cucumber.android_server.Result;
7
+
8
+ import java.util.Map;
9
+
10
+ public class LongClick extends Action {
11
+ public LongClick(UiDevice uiDevice) {
12
+ super(uiDevice);
13
+ }
14
+
15
+ @Override
16
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
+ getUiObject(arguments).longClick();
18
+ return Result.OK;
19
+ }
20
+ }
@@ -0,0 +1,19 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.*;
4
+ import com.uiautomator_cucumber.android_server.Action;
5
+ import com.uiautomator_cucumber.android_server.Result;
6
+
7
+ import java.util.Map;
8
+
9
+ public class PressBack extends Action {
10
+ public PressBack(UiDevice uiDevice) {
11
+ super(uiDevice);
12
+ }
13
+
14
+ @Override
15
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
16
+ getUiDevice().pressBack();
17
+ return Result.OK;
18
+ }
19
+ }
@@ -0,0 +1,19 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.*;
4
+ import com.uiautomator_cucumber.android_server.Action;
5
+ import com.uiautomator_cucumber.android_server.Result;
6
+
7
+ import java.util.Map;
8
+
9
+ public class PressEnter extends Action {
10
+ public PressEnter(UiDevice uiDevice) {
11
+ super(uiDevice);
12
+ }
13
+
14
+ @Override
15
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
16
+ getUiDevice().pressEnter();
17
+ return Result.OK;
18
+ }
19
+ }
@@ -0,0 +1,24 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.*;
4
+ import com.uiautomator_cucumber.android_server.Action;
5
+ import com.uiautomator_cucumber.android_server.Result;
6
+
7
+ import java.util.Map;
8
+
9
+ public class SelectFromAppsList extends Action {
10
+ public SelectFromAppsList(UiDevice uiDevice) {
11
+ super(uiDevice);
12
+ }
13
+
14
+ @Override
15
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
16
+ String appName = (String) arguments.get("appName");
17
+ //TODO: Using a better selector
18
+ UiScrollable settingsMenu = new UiScrollable(new UiSelector().scrollable(true).focused(false));
19
+ settingsMenu.setAsVerticalList();
20
+
21
+ (settingsMenu.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),appName)).click();
22
+ return Result.OK;
23
+ }
24
+ }
@@ -0,0 +1,22 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.*;
4
+ import com.uiautomator_cucumber.android_server.Action;
5
+ import com.uiautomator_cucumber.android_server.Result;
6
+
7
+ import java.util.Map;
8
+
9
+ public class SelectMenuInSettings extends Action {
10
+ public SelectMenuInSettings(UiDevice uiDevice) {
11
+ super(uiDevice);
12
+ }
13
+
14
+ @Override
15
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
16
+ String menuName = (String) arguments.get("menuName");
17
+ UiScrollable settingsMenu = new UiScrollable(new UiSelector().scrollable(true).focused(true));
18
+
19
+ (settingsMenu.getChildByText(new UiSelector().className(android.widget.TextView.class.getName()),menuName)).click();
20
+ return Result.OK;
21
+ }
22
+ }
@@ -0,0 +1,27 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.UiDevice;
4
+ import com.android.uiautomator.core.UiObject;
5
+ import com.android.uiautomator.core.UiObjectNotFoundException;
6
+ import com.android.uiautomator.core.UiSelector;
7
+ import com.uiautomator_cucumber.android_server.Action;
8
+ import com.uiautomator_cucumber.android_server.Result;
9
+
10
+ import java.util.Map;
11
+
12
+ public class SetText extends Action {
13
+
14
+ public SetText(UiDevice uiDevice) {
15
+ super(uiDevice);
16
+ }
17
+
18
+ @Override
19
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
20
+ String textDescription = (String) arguments.get("description");
21
+ String text = (String) arguments.get("text");
22
+ UiObject textField = new UiObject(new UiSelector().description(textDescription));
23
+ textField.setText(text);
24
+ uiDevice.pressDPadDown();
25
+ return Result.OK;
26
+ }
27
+ }
@@ -0,0 +1,25 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import android.util.*;
4
+ import com.android.uiautomator.core.*;
5
+ import com.uiautomator_cucumber.android_server.*;
6
+
7
+ import java.util.*;
8
+
9
+ public class SetTextByIndex extends Action {
10
+
11
+ public SetTextByIndex(UiDevice uiDevice) {
12
+ super(uiDevice);
13
+ }
14
+
15
+ @Override
16
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
+ Log.i("SetTextByIndex", "Found index field: " + arguments.get("index"));
18
+ int index = Integer.parseInt((String) arguments.get("index"));
19
+ String text = (String) arguments.get("text");
20
+ 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;
24
+ }
25
+ }
@@ -0,0 +1,28 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.UiDevice;
4
+ import com.android.uiautomator.core.UiObject;
5
+ import com.android.uiautomator.core.UiObjectNotFoundException;
6
+ import com.android.uiautomator.core.UiSelector;
7
+ import com.uiautomator_cucumber.android_server.Action;
8
+ import com.uiautomator_cucumber.android_server.Result;
9
+
10
+ import java.util.Map;
11
+
12
+ public class SetTextByLabel extends Action {
13
+
14
+ public SetTextByLabel(UiDevice uiDevice) {
15
+ super(uiDevice);
16
+ }
17
+
18
+ @Override
19
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
20
+ String label = (String) arguments.get("label");
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;
27
+ }
28
+ }
@@ -0,0 +1,31 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.UiDevice;
4
+ import com.android.uiautomator.core.UiObject;
5
+ import com.android.uiautomator.core.UiObjectNotFoundException;
6
+ import com.android.uiautomator.core.UiSelector;
7
+ import com.uiautomator_cucumber.android_server.Action;
8
+ import com.uiautomator_cucumber.android_server.Result;
9
+
10
+ import java.util.Map;
11
+
12
+ public class Unlock extends Action {
13
+ public Unlock(UiDevice uiDevice) {
14
+ super(uiDevice);
15
+ }
16
+
17
+ @Override
18
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
19
+ UiObject uiObject = new UiObject(new UiSelector().description("Slide area."));
20
+ uiObject = uiObject.exists() ? uiObject : new UiObject(new UiSelector().className("android.view.View"));
21
+ try {
22
+ if (uiObject.exists()) {
23
+ uiObject.swipeRight(100);
24
+ }
25
+ } catch (UiObjectNotFoundException e) {
26
+ // The device is unlocked already?"
27
+ }
28
+ getUiDevice().pressHome();
29
+ return Result.OK;
30
+ }
31
+ }
@@ -0,0 +1,24 @@
1
+ package com.uiautomator_cucumber.android_server.actions;
2
+
3
+ import com.android.uiautomator.core.*;
4
+ import com.uiautomator_cucumber.android_server.Action;
5
+ import com.uiautomator_cucumber.android_server.Result;
6
+ import android.os.RemoteException;
7
+
8
+ import java.util.Map;
9
+
10
+ public class WakeUp extends Action {
11
+ public WakeUp(UiDevice uiDevice) {
12
+ super(uiDevice);
13
+ }
14
+
15
+ @Override
16
+ public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
17
+ try {
18
+ getUiDevice().wakeUp();
19
+ } catch (RemoteException e) {
20
+ return Result.FAILURE;
21
+ }
22
+ return Result.OK;
23
+ }
24
+ }