Scott James Remnant | 4dcd73f | 2013-07-22 15:00:24 -0700 | [diff] [blame] | 1 | # Copyright (c) 2013 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 | |
Scott James Remnant | 4dcd73f | 2013-07-22 15:00:24 -0700 | [diff] [blame] | 5 | from autotest_lib.client.cros import constants |
| 6 | from autotest_lib.server import autotest |
| 7 | |
| 8 | |
| 9 | class BluetoothTester(object): |
Scott James Remnant | 1c72d7a | 2013-07-29 15:00:04 -0700 | [diff] [blame^] | 10 | """BluetoothTester is a thin layer of logic over a remote tester. |
| 11 | |
| 12 | The Autotest host object representing the remote tester, passed to this |
| 13 | class on initialization, can be accessed from its host property. |
| 14 | |
| 15 | """ |
| 16 | |
Scott James Remnant | 4dcd73f | 2013-07-22 15:00:24 -0700 | [diff] [blame] | 17 | |
| 18 | XMLRPC_BRINGUP_TIMEOUT_SECONDS = 60 |
| 19 | |
Scott James Remnant | 4dcd73f | 2013-07-22 15:00:24 -0700 | [diff] [blame] | 20 | def __init__(self, tester_host): |
| 21 | """Construct a BluetoothTester. |
| 22 | |
Scott James Remnant | 1c72d7a | 2013-07-29 15:00:04 -0700 | [diff] [blame^] | 23 | @param tester_host: host object representing a remote host. |
Scott James Remnant | 4dcd73f | 2013-07-22 15:00:24 -0700 | [diff] [blame] | 24 | |
| 25 | """ |
Scott James Remnant | 1c72d7a | 2013-07-29 15:00:04 -0700 | [diff] [blame^] | 26 | self.host = tester_host |
Scott James Remnant | 4dcd73f | 2013-07-22 15:00:24 -0700 | [diff] [blame] | 27 | # Make sure the client library is on the device so that the proxy code |
| 28 | # is there when we try to call it. |
| 29 | client_at = autotest.Autotest(self.host) |
| 30 | client_at.install() |
| 31 | # Start up the XML-RPC proxy on the tester. |
| 32 | self._proxy = self.host.xmlrpc_connect( |
| 33 | constants.BLUETOOTH_TESTER_XMLRPC_SERVER_COMMAND, |
| 34 | constants.BLUETOOTH_TESTER_XMLRPC_SERVER_PORT, |
| 35 | command_name= |
| 36 | constants.BLUETOOTH_TESTER_XMLRPC_SERVER_CLEANUP_PATTERN, |
| 37 | ready_test_name= |
| 38 | constants.BLUETOOTH_TESTER_XMLRPC_SERVER_READY_METHOD, |
| 39 | timeout_seconds=self.XMLRPC_BRINGUP_TIMEOUT_SECONDS) |
| 40 | |
Scott James Remnant | 1c72d7a | 2013-07-29 15:00:04 -0700 | [diff] [blame^] | 41 | |
Scott James Remnant | 4dcd73f | 2013-07-22 15:00:24 -0700 | [diff] [blame] | 42 | def close(self): |
| 43 | """Tear down state associated with the client.""" |
| 44 | # This kills the RPC server. |
Scott James Remnant | 1c72d7a | 2013-07-29 15:00:04 -0700 | [diff] [blame^] | 45 | self.host.close() |