This source file includes following definitions.
- pressEnter
- pressTab
- pressBackspace
- pressBack
- inputString
package org.chromium.content.browser.test.util;
import android.app.Instrumentation;
import android.view.KeyEvent;
public class KeyUtils {
public static void pressEnter(Instrumentation instrumentation) {
instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_ENTER));
instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_ENTER));
instrumentation.waitForIdleSync();
}
public static void pressTab(Instrumentation instrumentation) {
instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_TAB));
instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_TAB));
instrumentation.waitForIdleSync();
}
public static void pressBackspace(Instrumentation instrumentation) {
instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_DEL));
instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_DEL));
instrumentation.waitForIdleSync();
}
public static void pressBack(Instrumentation instrumentation) {
instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_BACK));
instrumentation.sendKeySync(new KeyEvent(KeyEvent.ACTION_UP,
KeyEvent.KEYCODE_BACK));
instrumentation.waitForIdleSync();
}
public static void inputString(Instrumentation instrumentation, String text) {
instrumentation.sendStringSync(text);
instrumentation.waitForIdleSync();
}
}