Commit dc8462fe authored by Kuo-Hsin Yang's avatar Kuo-Hsin Yang Committed by Commit Bot

cros_tab_switching: upload keyboard emulator property file

Upload the keyboard property file for keyboard emulator to remove the
dependency to /usr/local/autotest/cros/input_playback/keyboard.prop.

Bug: chromium:881240
Change-Id: I65daf0326d9237ac5a904f2966be4e95c6f8e210
Reviewed-on: https://chromium-review.googlesource.com/1209135
Commit-Queue: Vovo Yang <vovoy@chromium.org>
Reviewed-by: default avatarCheng-Yu Lee <cylee@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589452}
parent b4edab24
......@@ -126,7 +126,9 @@ class KeyboardEmulator(object):
for i in range(5):
kbd.SwitchTab()
"""
REMOTE_LOG_KEY_FILENAME = '/usr/local/tmp/log_key_tab_switch'
REMOTE_TEMP_DIR = '/usr/local/tmp/'
REMOTE_LOG_KEY_FILENAME = 'log_key_tab_switch'
REMOTE_KEY_PROP_FILENAME = 'keyboard.prop'
def __init__(self, dut_ip):
"""Inits KeyboardEmulator.
......@@ -146,7 +148,8 @@ class KeyboardEmulator(object):
Raises:
RuntimeError: Keyboard emulation failed.
"""
kbd_prop_filename = '/usr/local/autotest/cros/input_playback/keyboard.prop'
kbd_prop_filename = os.path.join(KeyboardEmulator.REMOTE_TEMP_DIR,
KeyboardEmulator.REMOTE_KEY_PROP_FILENAME)
ret = _RunCommand(self._dut_ip, 'test -e %s' % kbd_prop_filename)
if ret != 0:
......@@ -171,22 +174,25 @@ class KeyboardEmulator(object):
return key_device_name
def _SetupKeyDispatch(self):
"""Uploads the script to send key to switch tabs."""
"""Uploads required files to emulate keyboard."""
cur_dir = os.path.dirname(os.path.abspath(__file__))
log_key_filename = os.path.join(cur_dir, 'data', 'log_key_tab_switch')
_CopyToDUT(self._dut_ip, log_key_filename,
KeyboardEmulator.REMOTE_LOG_KEY_FILENAME)
for filename in (KeyboardEmulator.REMOTE_KEY_PROP_FILENAME,
KeyboardEmulator.REMOTE_LOG_KEY_FILENAME):
src = os.path.join(cur_dir, 'data', filename)
dest = os.path.join(KeyboardEmulator.REMOTE_TEMP_DIR, filename)
_CopyToDUT(self._dut_ip, src, dest)
def __enter__(self):
self._key_device_name = self._StartRemoteKeyboardEmulator()
self._SetupKeyDispatch()
self._key_device_name = self._StartRemoteKeyboardEmulator()
return self
def SwitchTab(self):
"""Sending Ctrl-tab key to trigger tab switching."""
log_key_filename = os.path.join(KeyboardEmulator.REMOTE_TEMP_DIR,
KeyboardEmulator.REMOTE_LOG_KEY_FILENAME)
cmd = ('evemu-play --insert-slot0 %s < %s' %
(self._key_device_name,
KeyboardEmulator.REMOTE_LOG_KEY_FILENAME))
(self._key_device_name, log_key_filename))
_RunCommand(self._dut_ip, cmd)
def __exit__(self, exc_type, exc_value, traceback):
......
N: Emulated Keyboard
I: 0003 0461 4e05 0111
P: 00 00 00 00 00 00 00 00
B: 00 13 00 12 00 00 00 00 00
B: 01 fe ff ff ff ff ff ff ff
B: 01 ff ff ef ff df ff be fe
B: 01 ff 57 40 c1 7a 20 9f ff
B: 01 07 00 00 00 00 00 01 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 01 00 00 00 00 00 00 00 00
B: 02 00 00 00 00 00 00 00 00
B: 03 00 00 00 00 00 00 00 00
B: 04 10 00 00 00 00 00 00 00
B: 05 00 00 00 00 00 00 00 00
B: 11 1f 00 00 00 00 00 00 00
B: 12 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
B: 15 00 00 00 00 00 00 00 00
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment