add setText and add group memeber script
This commit is contained in:
@@ -36,6 +36,8 @@ import static android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.
|
||||
|
||||
public class UiObject extends AccessibilityNodeInfoCompat {
|
||||
|
||||
public static final int ACTION_APPEND_TEXT = 0x00200001;
|
||||
|
||||
private static final String TAG = "UiObject";
|
||||
private static final boolean DEBUG = false;
|
||||
private static int notRecycledCount = 0;
|
||||
|
||||
@@ -42,14 +42,18 @@ public class ActionFactory {
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
|
||||
public static SimpleAction createActionWithEditableFilter(int action, int index, final String text) {
|
||||
public static SimpleAction createActionWithEditableFilter(final int action, int index, final String text) {
|
||||
return new SearchTargetAction(action, new FilterAction.EditableFilter(index)) {
|
||||
|
||||
@Override
|
||||
protected void performAction(UiObject node) {
|
||||
Bundle args = new Bundle();
|
||||
args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, node.text() + text);
|
||||
node.performAction(getAction(), args);
|
||||
if (action == AccessibilityNodeInfo.ACTION_SET_TEXT) {
|
||||
args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text);
|
||||
} else {
|
||||
args.putCharSequence(AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, node.text() + text);
|
||||
}
|
||||
node.performAction(AccessibilityNodeInfo.ACTION_SET_TEXT, args);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.stardust.uiautomator;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.InstrumentationInfo;
|
||||
import android.widget.Toast;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by Stardust on 2017/5/9.
|
||||
*/
|
||||
|
||||
public class Test {
|
||||
|
||||
|
||||
private void runTests(Context context) {
|
||||
final String packageName = context.getPackageName();
|
||||
final List<InstrumentationInfo> list =
|
||||
context.getPackageManager().queryInstrumentation(packageName, 0);
|
||||
if (list.isEmpty()) {
|
||||
Toast.makeText(context, "Cannot find instrumentation for " + packageName,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
final InstrumentationInfo instrumentationInfo = list.get(0);
|
||||
final ComponentName componentName =
|
||||
new ComponentName(instrumentationInfo.packageName,
|
||||
instrumentationInfo.name);
|
||||
if (!context.startInstrumentation(componentName, null, null)) {
|
||||
Toast.makeText(context, "Cannot run instrumentation for " + packageName,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user