Home | History | Annotate | Download | only in multimedia
      1 # Copyright 2017 The Chromium OS Authors. All rights reserved.
      2 # Use of this source code is governed by a BSD-style license that can be
      3 # found in the LICENSE file.
      4 
      5 """An adapter to remotely access the input facade on DUT."""
      6 
      7 import json
      8 
      9 
     10 class InputFacadeRemoteAdapter(object):
     11     """This is an adapter to remotely capture the DUT's input events.
     12 
     13     The Autotest host object representing the remote DUT, passed to this
     14     class on initialization, can be accessed from its _client property.
     15 
     16     """
     17     def __init__(self, remote_facade_proxy):
     18         """Constructs an InputFacadeRemoteAdapter.
     19 
     20         @param remote_facade_proxy: RemoteFacadeProxy object.
     21 
     22         """
     23         self._proxy = remote_facade_proxy
     24 
     25 
     26     @property
     27     def _input_proxy(self):
     28         """Gets the proxy to DUT input facade.
     29 
     30         @return XML RPC proxy to DUT input facade.
     31 
     32         """
     33         return self._proxy.input
     34 
     35 
     36     def initialize_input_recorder(self, device_name):
     37         """Initialize an input event recorder object.
     38 
     39         @param device_name: the name of the input device to record.
     40 
     41         """
     42         self._input_proxy.initialize_input_recorder(device_name)
     43 
     44 
     45     def clear_input_events(self):
     46         """Clear the event list."""
     47         self._input_proxy.clear_input_events()
     48 
     49 
     50     def start_input_recorder(self):
     51         """Start the recording thread."""
     52         self._input_proxy.start_input_recorder()
     53 
     54 
     55     def stop_input_recorder(self):
     56         """Stop the recording thread."""
     57         self._input_proxy.stop_input_recorder()
     58 
     59 
     60     def get_input_events(self):
     61         """Get the bluetooth device events.
     62 
     63         @returns: the recorded input events.
     64 
     65         """
     66         return json.loads(self._input_proxy.get_input_events())
     67 
     68 
     69     def press_keys(self, key_list):
     70         """ Simulating key press
     71 
     72         @param key_list: A list of key strings, e.g. ['LEFTCTRL', 'F4']
     73         """
     74         self._input_proxy.press_keys(key_list)
     75