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