diff --git a/command-tests/src/se/vidstige/android/uimultimator/UiObjectCommands.java b/command-tests/src/se/vidstige/android/uimultimator/UiObjectCommands.java index 819a0f7..c43f113 100644 --- a/command-tests/src/se/vidstige/android/uimultimator/UiObjectCommands.java +++ b/command-tests/src/se/vidstige/android/uimultimator/UiObjectCommands.java @@ -9,7 +9,25 @@ public class UiObjectCommands extends UiCommandsTestCase { private UiObject uiObject() throws UnsupportedEncodingException { return new UiObject(recreateSelector()); - } + } + + public void testClick() throws UiObjectNotFoundException, UnsupportedEncodingException { + uiObject().click(); + } + public void testLongClick() throws UiObjectNotFoundException, UnsupportedEncodingException { + uiObject().longClick(); + } + + public void testGetContentDescription() throws UiObjectNotFoundException, UnsupportedEncodingException { + respond(uiObject().getContentDescription()); + } + + public void testIsChecked() throws UiObjectNotFoundException, UnsupportedEncodingException { + respond(uiObject().isChecked()); + } + public void testIsEnabled() throws UiObjectNotFoundException, UnsupportedEncodingException { + respond(uiObject().isEnabled()); + } public void testSetText() throws UiObjectNotFoundException, UnsupportedEncodingException { diff --git a/src/se/vidstige/android/uimultimator/UiObject.java b/src/se/vidstige/android/uimultimator/UiObject.java index 975b83e..db6c71e 100644 --- a/src/se/vidstige/android/uimultimator/UiObject.java +++ b/src/se/vidstige/android/uimultimator/UiObject.java @@ -14,6 +14,38 @@ public class UiObject { this.selector = selector; } + private void run(String methodname) throws UiMultimatorException { + runner.run("se.vidstige.android.uimultimator.UiObjectCommands", methodname); + } + private boolean runBool(String methodname) throws UiMultimatorException { + String result = runner.run("se.vidstige.android.uimultimator.UiObjectCommands", methodname, new HashMap(0)); + return Boolean.parseBoolean(result); + } + + public void click() throws UiMultimatorException { + run("testClick"); + } + + public void testLongClick() throws UiMultimatorException { + run("testLongClick"); + } + + public String getContentDescription() throws UiMultimatorException { + String result = runner.run( + "se.vidstige.android.uimultimator.UiObjectCommands", + "testGetContentDescription", + new HashMap(0)); + return result; + } + + public boolean isChecked() throws UiMultimatorException { + return runBool("testIsChecked"); + } + + public boolean isEnabled() throws UiMultimatorException { + return runBool("testIsEnabled"); + } + public void clickAndWaitForNewWindow() throws UnsupportedEncodingException, IOException, InterruptedException, UiMultimatorException { Map parameters = new HashMap();