[gnome-bluetooth/wip/hadess/lib-changes: 7/8] tests: Add more tests




commit 51ee2a10b2c2bd4bff503bbf805adb615b2c35ff
Author: Bastien Nocera <hadess hadess net>
Date:   Tue Nov 23 17:39:35 2021 +0100

    tests: Add more tests

 tests/integration-test | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
---
diff --git a/tests/integration-test b/tests/integration-test
index ab9d6115..8f90295b 100755
--- a/tests/integration-test
+++ b/tests/integration-test
@@ -84,6 +84,55 @@ class OopTests(dbusmock.DBusTestCase):
         self.wait_for_condition(lambda: self.client.get_property('num-adapters') != 0)
         self.assertEqual(self.client.get_property('num-adapters'), 1)
 
+    def test_one_device(self):
+        self.wait_for_condition(lambda: self.client.get_property('num-adapters') != 0)
+
+        # GtkTreeModel
+        model = self.client.get_model()
+        path = Gtk.TreePath([0, 0])
+        treeiter = model.get_iter(path)
+        self.assertEqual(model.get_value(treeiter, GnomeBluetoothPriv.Column.ADDRESS), '22:33:44:55:66:77')
+
+    def test_default_adapter(self):
+        self.wait_for_condition(lambda: self.client.get_property('num-adapters') != 0)
+        self.assertEqual(self.client.get_property('num-adapters'), 2)
+
+        # GtkTreeModel
+        model = self.client.get_model()
+
+        path = Gtk.TreePath([1])
+        treeiter = model.get_iter(path)
+        self.assertEqual(model.get_value(treeiter, GnomeBluetoothPriv.Column.DEFAULT), False)
+        self.assertEqual(model.get_value(treeiter, GnomeBluetoothPriv.Column.NAME), 'my-computer')
+        path = Gtk.TreePath([1, 0])
+        treeiter = model.get_iter(path)
+        self.assertEqual(model.get_value(treeiter, GnomeBluetoothPriv.Column.ADDRESS), '11:22:33:44:55:66')
+
+        path = Gtk.TreePath([0])
+        treeiter = model.get_iter(path)
+        self.assertEqual(model.get_value(treeiter, GnomeBluetoothPriv.Column.NAME), 'my-computer #2')
+        self.assertEqual(model.get_value(treeiter, GnomeBluetoothPriv.Column.DEFAULT), True)
+        path = Gtk.TreePath([0, 0])
+        treeiter = model.get_iter(path)
+        self.assertEqual(model.get_value(treeiter, GnomeBluetoothPriv.Column.ADDRESS), '22:33:44:55:66:77')
+
+        # Remove default adapter
+        bus = dbus.SystemBus()
+        bluez_server = bus.get_object('org.bluez', '/org/bluez')
+        dbusmock_bluez = dbus.Interface(bluez_server, 'org.bluez.Mock')
+        dbusmock_bluez.RemoveAdapter('hci1')
+        self.wait_for_condition(lambda: self.client.get_property('num-adapters') != 2)
+        self.assertEqual(self.client.get_property('num-adapters'), 1)
+
+        # GtkTreeModel
+        path = Gtk.TreePath([0])
+        treeiter = model.get_iter(path)
+        self.assertEqual(model.get_value(treeiter, GnomeBluetoothPriv.Column.DEFAULT), True)
+        self.assertEqual(model.get_value(treeiter, GnomeBluetoothPriv.Column.NAME), 'my-computer')
+        path = Gtk.TreePath([0, 0])
+        treeiter = model.get_iter(path)
+        self.assertEqual(model.get_value(treeiter, GnomeBluetoothPriv.Column.ADDRESS), '11:22:33:44:55:66')
+
     def _pair_cb(self, client, result, user_data=None):
         success, path = client.setup_device_finish(result)
         self.assertEqual(success, True)
@@ -164,6 +213,18 @@ class Tests(dbusmock.DBusTestCase):
         self.dbusmock_bluez.AddAdapter('hci0', 'my-computer')
         self.run_test_process()
 
+    def test_one_device(self):
+        self.dbusmock_bluez.AddAdapter('hci0', 'my-computer')
+        self.dbusmock_bluez.AddDevice('hci0', '22:33:44:55:66:77', 'My Mouse')
+        self.run_test_process()
+
+    def test_default_adapter(self):
+        self.dbusmock_bluez.AddAdapter('hci0', 'my-computer')
+        self.dbusmock_bluez.AddAdapter('hci1', 'my-computer #2')
+        self.dbusmock_bluez.AddDevice('hci0', '11:22:33:44:55:66', 'My Phone')
+        self.dbusmock_bluez.AddDevice('hci1', '22:33:44:55:66:77', 'My Mouse')
+        self.run_test_process()
+
     def test_pairing(self):
         adapter_name = 'hci0'
         self.dbusmock_bluez.AddAdapter(adapter_name, 'my-computer')


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