Created
February 29, 2016 10:47
-
-
Save esmasui/f00e255e60a69e20a1c0 to your computer and use it in GitHub Desktop.
Androidのテストでクリップボードから貼り付ける
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ペーストのショートカットCtrl+Vを打鍵すればおk | |
// Espresso | |
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); | |
instrumentation.sendKeySync(new KeyEvent(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_V, 0, KeyEvent.META_CTRL_ON)); | |
instrumentation.sendKeySync(new KeyEvent(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), KeyEvent.ACTION_UP, KeyEvent.KEYCODE_V, 0, KeyEvent.META_CTRL_ON)); | |
//uiautomator | |
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation()); | |
device.pressKeyCode(KeyEvent.KEYCODE_V, KeyEvent.META_CTRL_ON); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment