コード例 #1
0
  @Override
  public Result execute(Map<String, Object> arguments) throws UiObjectNotFoundException {
    super.execute(arguments);
    @SuppressWarnings("unchecked")
    List<String> optionNames = (List<String>) arguments.get("optionNames");
    ;
    UiScrollable optionsMenu =
        new UiScrollable(
            new UiSelector()
                .className("android.widget.ListView")
                .packageName("com.android.settings")
                .focused(false));

    if (!isUiObjectAvailable(optionsMenu, arguments)) {
      return Result.FAILURE;
    }

    for (String optionName : optionNames) {
      UiObject option =
          optionsMenu.getChildByText(
              new UiSelector().className(TextView.class.getName()), optionName);
      if (!isUiObjectAvailable(option, arguments) && !enabled.equals(option.isEnabled())) {
        return Result.FAILURE;
      }
    }
    return Result.OK;
  }
コード例 #2
0
 public boolean getBoolAttribute(final String attr)
     throws UiObjectNotFoundException, NoAttributeFoundException {
   boolean res = false;
   if (attr.equals("enabled")) {
     res = el.isEnabled();
   } else if (attr.equals("checkable")) {
     res = el.isCheckable();
   } else if (attr.equals("checked")) {
     res = el.isChecked();
   } else if (attr.equals("clickable")) {
     res = el.isClickable();
   } else if (attr.equals("focusable")) {
     res = el.isFocusable();
   } else if (attr.equals("focused")) {
     res = el.isFocused();
   } else if (attr.equals("longClickable")) {
     res = el.isLongClickable();
   } else if (attr.equals("scrollable")) {
     res = el.isScrollable();
   } else if (attr.equals("selected")) {
     res = el.isSelected();
   } else if (attr.equals("displayed")) {
     res = el.exists();
   } else {
     throw new NoAttributeFoundException(attr);
   }
   return res;
 }