bluetooth autotest: Fix a import pattern that was causing a failure
TEST=Tested locally
BUG=b:138597710
Change-Id: Ibce6d31d90047eaa0c29a9b8c1b3fc84fe098395
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/1890725
Tested-by: Shijin Abraham <shijinabraham@google.com>
Auto-Submit: Shijin Abraham <shijinabraham@google.com>
Reviewed-by: Daniel Winkler <danielwinkler@google.com>
Commit-Queue: Shijin Abraham <shijinabraham@google.com>
diff --git a/server/cros/bluetooth/bluetooth_adapter_hidreports_tests.py b/server/cros/bluetooth/bluetooth_adapter_hidreports_tests.py
new file mode 100644
index 0000000..2960bb8
--- /dev/null
+++ b/server/cros/bluetooth/bluetooth_adapter_hidreports_tests.py
@@ -0,0 +1,110 @@
+# Copyright 2019 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Server side bluetooth tests about sending bluetooth HID reports."""
+
+import logging
+import time
+
+from autotest_lib.server.cros.bluetooth import bluetooth_adapter_tests
+from autotest_lib.server.cros.multimedia import remote_facade_factory
+
+
+class BluetoothAdapterHIDReportTests(
+ bluetooth_adapter_tests.BluetoothAdapterTests):
+ """Server side bluetooth tests about sending bluetooth HID reports.
+
+ This test tries to send HID reports to a DUT and verifies if the DUT
+ could receive the reports correctly. For the time being, only bluetooth
+ mouse events are tested. Bluetooth keyboard events will be supported
+ later.
+ """
+
+ HID_TEST_SLEEP_SECS = 5
+
+ def run_mouse_tests(self, device):
+ """Run all bluetooth mouse reports tests.
+
+ @param device: the bluetooth HID device.
+
+ """
+ self.test_mouse_left_click(device)
+ self.test_mouse_right_click(device)
+ self.test_mouse_move_in_x(device, 80)
+ self.test_mouse_move_in_y(device, -50)
+ self.test_mouse_move_in_xy(device, -60, 100)
+ self.test_mouse_scroll_down(device, 70)
+ self.test_mouse_scroll_up(device, 40)
+ self.test_mouse_click_and_drag(device, 90, 30)
+
+
+ def run_keyboard_tests(self, device):
+ """Run all bluetooth mouse reports tests.
+
+ @param device: the bluetooth HID device.
+
+ """
+
+ self.test_keyboard_input_from_trace(device, "simple_text")
+
+
+ def run_hid_reports_test(self, device, suspend_resume=False, reboot=False):
+ """Running Bluetooth HID reports tests."""
+ logging.info("run hid reports test")
+ # Reset the adapter and set it pairable.
+ self.test_reset_on_adapter()
+ self.test_pairable()
+
+ # Let the adapter pair, and connect to the target device.
+ time.sleep(self.HID_TEST_SLEEP_SECS)
+ self.test_discover_device(device.address)
+ time.sleep(self.HID_TEST_SLEEP_SECS)
+ self.test_pairing(device.address, device.pin, trusted=True)
+ time.sleep(self.HID_TEST_SLEEP_SECS)
+ self.test_connection_by_adapter(device.address)
+
+ if suspend_resume:
+ self.suspend_resume()
+
+ time.sleep(self.HID_TEST_SLEEP_SECS)
+ self.test_device_is_paired(device.address)
+
+ # After a suspend/resume, we should check if the device is
+ # connected.
+ # NOTE: After a suspend/resume, the RN42 kit remains connected.
+ # However, this is not expected behavior for all bluetooth
+ # peripherals.
+ time.sleep(self.HID_TEST_SLEEP_SECS)
+ self.test_device_is_connected(device.address)
+
+ time.sleep(self.HID_TEST_SLEEP_SECS)
+ self.test_device_name(device.address, device.name)
+
+ if reboot:
+ self.host.reboot()
+
+ # NOTE: We need to recreate the bluetooth_facade after a reboot.
+ factory = remote_facade_factory.RemoteFacadeFactory(self.host)
+ self.bluetooth_facade = factory.create_bluetooth_hid_facade()
+ self.input_facade = factory.create_input_facade()
+
+ time.sleep(self.HID_TEST_SLEEP_SECS)
+ self.test_device_is_paired(device.address)
+
+ time.sleep(self.HID_TEST_SLEEP_SECS)
+ self.test_connection_by_device(device)
+
+ time.sleep(self.HID_TEST_SLEEP_SECS)
+ self.test_device_name(device.address, device.name)
+
+ # Run tests about mouse reports.
+ if device.device_type.endswith('MOUSE'):
+ self.run_mouse_tests(device)
+
+ if device.device_type.endswith('KEYBOARD'):
+ self.run_keyboard_tests(device)
+
+ # Disconnect the device, and remove the pairing.
+ self.test_disconnection_by_adapter(device.address)
+ self.test_remove_pairing(device.address)
diff --git a/server/site_tests/bluetooth_AdapterHIDReports/bluetooth_AdapterHIDReports.py b/server/site_tests/bluetooth_AdapterHIDReports/bluetooth_AdapterHIDReports.py
index 8c36cf0..aaa2cf1 100644
--- a/server/site_tests/bluetooth_AdapterHIDReports/bluetooth_AdapterHIDReports.py
+++ b/server/site_tests/bluetooth_AdapterHIDReports/bluetooth_AdapterHIDReports.py
@@ -5,15 +5,15 @@
"""Server side bluetooth tests about sending bluetooth HID reports."""
import logging
-import time
from autotest_lib.client.common_lib import error
-from autotest_lib.server.cros.bluetooth import bluetooth_adapter_tests
+from autotest_lib.server.cros.bluetooth import \
+ bluetooth_adapter_hidreports_tests
from autotest_lib.server.cros.multimedia import remote_facade_factory
class bluetooth_AdapterHIDReports(
- bluetooth_adapter_tests.BluetoothAdapterTests):
+ bluetooth_adapter_hidreports_tests.BluetoothAdapterHIDReportTests):
"""Server side bluetooth tests about sending bluetooth HID reports.
This test tries to send HID reports to a DUT and verifies if the DUT
@@ -22,94 +22,6 @@
later.
"""
- HID_TEST_SLEEP_SECS = 5
-
- def run_mouse_tests(self, device):
- """Run all bluetooth mouse reports tests.
-
- @param device: the bluetooth HID device.
-
- """
- self.test_mouse_left_click(device)
- self.test_mouse_right_click(device)
- self.test_mouse_move_in_x(device, 80)
- self.test_mouse_move_in_y(device, -50)
- self.test_mouse_move_in_xy(device, -60, 100)
- self.test_mouse_scroll_down(device, 70)
- self.test_mouse_scroll_up(device, 40)
- self.test_mouse_click_and_drag(device, 90, 30)
-
-
- def run_keyboard_tests(self, device):
- """Run all bluetooth mouse reports tests.
-
- @param device: the bluetooth HID device.
-
- """
-
- self.test_keyboard_input_from_trace(device, "simple_text")
-
-
- def run_hid_reports_test(self, device, suspend_resume=False, reboot=False):
- """Running Bluetooth HID reports tests."""
- logging.info("run hid reports test")
- # Reset the adapter and set it pairable.
- self.test_reset_on_adapter()
- self.test_pairable()
-
- # Let the adapter pair, and connect to the target device.
- time.sleep(self.HID_TEST_SLEEP_SECS)
- self.test_discover_device(device.address)
- time.sleep(self.HID_TEST_SLEEP_SECS)
- self.test_pairing(device.address, device.pin, trusted=True)
- time.sleep(self.HID_TEST_SLEEP_SECS)
- self.test_connection_by_adapter(device.address)
-
- if suspend_resume:
- self.suspend_resume()
-
- time.sleep(self.HID_TEST_SLEEP_SECS)
- self.test_device_is_paired(device.address)
-
- # After a suspend/resume, we should check if the device is
- # connected.
- # NOTE: After a suspend/resume, the RN42 kit remains connected.
- # However, this is not expected behavior for all bluetooth
- # peripherals.
- time.sleep(self.HID_TEST_SLEEP_SECS)
- self.test_device_is_connected(device.address)
-
- time.sleep(self.HID_TEST_SLEEP_SECS)
- self.test_device_name(device.address, device.name)
-
- if reboot:
- self.host.reboot()
-
- # NOTE: We need to recreate the bluetooth_facade after a reboot.
- factory = remote_facade_factory.RemoteFacadeFactory(self.host)
- self.bluetooth_facade = factory.create_bluetooth_hid_facade()
- self.input_facade = factory.create_input_facade()
-
- time.sleep(self.HID_TEST_SLEEP_SECS)
- self.test_device_is_paired(device.address)
-
- time.sleep(self.HID_TEST_SLEEP_SECS)
- self.test_connection_by_device(device)
-
- time.sleep(self.HID_TEST_SLEEP_SECS)
- self.test_device_name(device.address, device.name)
-
- # Run tests about mouse reports.
- if device.device_type.endswith('MOUSE'):
- self.run_mouse_tests(device)
-
- if device.device_type.endswith('KEYBOARD'):
- self.run_keyboard_tests(device)
-
- # Disconnect the device, and remove the pairing.
- self.test_disconnection_by_adapter(device.address)
- self.test_remove_pairing(device.address)
-
def run_once(self, host, device_type, num_iterations=1, min_pass_count=1,
suspend_resume=False, reboot=False):
diff --git a/server/site_tests/bluetooth_AdapterLESanity/bluetooth_AdapterLESanity.py b/server/site_tests/bluetooth_AdapterLESanity/bluetooth_AdapterLESanity.py
index 052583c..de81463 100644
--- a/server/site_tests/bluetooth_AdapterLESanity/bluetooth_AdapterLESanity.py
+++ b/server/site_tests/bluetooth_AdapterLESanity/bluetooth_AdapterLESanity.py
@@ -10,11 +10,12 @@
BluetoothAdapterQuickTests
from autotest_lib.server.cros.bluetooth.bluetooth_adapter_pairing_tests import \
BluetoothAdapterPairingTests
-from autotest_lib.server.site_tests.bluetooth_AdapterHIDReports.bluetooth_AdapterHIDReports import bluetooth_AdapterHIDReports
+from autotest_lib.server.cros.bluetooth.bluetooth_adapter_hidreports_tests \
+ import BluetoothAdapterHIDReportTests
class bluetooth_AdapterLESanity(BluetoothAdapterQuickTests,
BluetoothAdapterPairingTests,
- bluetooth_AdapterHIDReports):
+ BluetoothAdapterHIDReportTests):
"""A Batch of Bluetooth LE sanity tests. This test is written as a batch
of tests in order to reduce test time, since auto-test ramp up time is
costly. The batch is using BluetoothAdapterQuickTests wrapper methods to
diff --git a/server/site_tests/bluetooth_AdapterPairing/bluetooth_AdapterPairing.py b/server/site_tests/bluetooth_AdapterPairing/bluetooth_AdapterPairing.py
index 28ca617..049547b 100644
--- a/server/site_tests/bluetooth_AdapterPairing/bluetooth_AdapterPairing.py
+++ b/server/site_tests/bluetooth_AdapterPairing/bluetooth_AdapterPairing.py
@@ -10,9 +10,6 @@
import logging
from autotest_lib.client.common_lib import error
-from autotest_lib.server.cros.bluetooth import bluetooth_adapter_tests
-from autotest_lib.server.cros.multimedia import remote_facade_factory
-
from autotest_lib.server.cros.bluetooth import bluetooth_adapter_pairing_tests
from autotest_lib.server.cros.multimedia import remote_facade_factory