Skip to content

Commit

Permalink
Adding a few more methods to UiObject, such as click, etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
vidstige committed Jul 28, 2013
1 parent 72aa968 commit cc1682c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
32 changes: 32 additions & 0 deletions src/se/vidstige/android/uimultimator/UiObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, String>(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<String, String>(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<String, String> parameters = new HashMap<String, String>();
Expand Down

0 comments on commit cc1682c

Please sign in to comment.