[gnome-bluetooth/wip/hadess/default-adapter-work: 8/10] tests: Check that non-default adapter is made non-discoverable




commit 8cc2315e5fe0c2f5e1f63aba2600ec2bf25fd624
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Jan 5 16:33:26 2022 +0100

    tests: Check that non-default adapter is made non-discoverable

 tests/integration-test | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/tests/integration-test b/tests/integration-test
index 7627540f..530ba060 100755
--- a/tests/integration-test
+++ b/tests/integration-test
@@ -195,6 +195,8 @@ class OopTests(dbusmock.DBusTestCase):
         bus = dbus.SystemBus()
         bluez_server = bus.get_object('org.bluez', '/org/bluez')
         dbusmock_bluez = dbus.Interface(bluez_server, 'org.bluez.Mock')
+        hci0_props = dbus.Interface(bus.get_object('org.bluez', '/org/bluez/hci0'), 
'org.freedesktop.DBus.Properties')
+        hci1_props = dbus.Interface(bus.get_object('org.bluez', '/org/bluez/hci1'), 
'org.freedesktop.DBus.Properties')
 
         self.wait_for_condition(lambda: self.client.props.num_adapters != 0)
         self.assertEqual(self.client.props.num_adapters, 2)
@@ -208,10 +210,16 @@ class OopTests(dbusmock.DBusTestCase):
 
         # Set default adapter in setup mode
         self.assertEqual (self.client.props.default_adapter_setup_mode, False)
+        self.assertEqual(hci0_props.Get('org.bluez.Adapter1', 'Discoverable'), False)
+        self.assertEqual(hci1_props.Get('org.bluez.Adapter1', 'Discoverable'), False)
         default_adapter_path = self.client.props.default_adapter
         self.client.props.default_adapter_setup_mode = True
+        self.wait_for_condition(lambda: hci1_props.Get('org.bluez.Adapter1', 'Discoverable') == True)
+        self.assertEqual(hci1_props.Get('org.bluez.Adapter1', 'Discoverable'), True)
         self.wait_for_mainloop()
         self.assertEqual(self.client.props.default_adapter_setup_mode, True)
+        self.assertEqual(hci0_props.Get('org.bluez.Adapter1', 'Discoverable'), False)
+        self.assertEqual(hci1_props.Get('org.bluez.Adapter1', 'Discoverable'), True)
 
         # Remove default adapter
         dbusmock_bluez.RemoveAdapter('hci1')
@@ -219,6 +227,7 @@ class OopTests(dbusmock.DBusTestCase):
         self.assertEqual(self.client.props.num_adapters, 1)
         self.assertNotEqual(self.client.props.default_adapter, default_adapter_path)
         self.assertEqual(self.client.props.default_adapter_setup_mode, False)
+        self.assertEqual(hci0_props.Get('org.bluez.Adapter1', 'Discoverable'), False)
 
         # GListModel
         self.assertEqual(list_store.get_n_items(), 1)
@@ -226,6 +235,9 @@ class OopTests(dbusmock.DBusTestCase):
         self.assertIsNotNone(device)
         self.assertEqual(device.props.name, 'Device on hci0')
 
+        # Make hci0 discoverable
+        self.client.props.default_adapter_setup_mode = True
+
         # Re-add the old adapter, device is still there
         dbusmock_bluez.AddAdapter('hci1', 'hci1')
         self.wait_for_condition(lambda: self.client.props.num_adapters == 2)
@@ -237,6 +249,10 @@ class OopTests(dbusmock.DBusTestCase):
         self.assertIsNotNone(device)
         self.assertEqual(device.props.name, 'Device on hci1')
 
+        self.wait_for_condition(lambda: hci0_props.Get('org.bluez.Adapter1', 'Discoverable') == False)
+        self.assertEqual(hci0_props.Get('org.bluez.Adapter1', 'Discoverable'), False)
+        self.assertEqual(hci1_props.Get('org.bluez.Adapter1', 'Discoverable'), False)
+
     def test_default_adapter_powered(self):
         bus = dbus.SystemBus()
         dbusmock_bluez = dbus.Interface(bus.get_object('org.bluez', '/org/bluez/hci0'), 
'org.freedesktop.DBus.Mock')


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]