Skip to content

Commit

Permalink
more test debugging
Browse files Browse the repository at this point in the history
Signed-off-by: Hubert Figuière <[email protected]>
  • Loading branch information
hfiguiere committed Nov 1, 2024
1 parent 3651c74 commit 787cf12
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions tests/test_usb.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,21 @@ def cb_device_events(session_handle, events):
== "Canon_Inc._Canon_Digital_Camera_C767F1C714174C309255F70E4A7B2EE2"
)

@pytest.mark.parametrize("usb_queries", ["vnd:04a9", None])
@pytest.mark.parametrize("usb_queries", ["vnd:04a9;vnd:04aa", None])
def test_device_remove(self, portal_mock, app_id, usb_queries):
device_events_signal_count = 0
devices_received = 0
devices_removed = 0

dev_path = self.generate_device(
portal_mock.umockdev,
"04aa",
"Someone Else.",
"31c0",
"SomeProduct",
"00001",
)

dev_path = self.generate_device(
portal_mock.umockdev,
"04a9",
Expand All @@ -229,18 +238,20 @@ def cb_device_events(session_handle, events):
nonlocal device_events_signal_count
nonlocal devices_received
nonlocal devices_removed

assert session.handle == session_handle

print("events ", events)
for action, id, device in events:
print("device event ", action)
if action == "add":
devices_received += 1
elif action == "remove":
devices_removed += 1
else:
assert False

device_events_signal_count += 1
print("count ", device_events_signal_count)
print("count recv", devices_received)

usb_intf.connect_to_signal("DeviceEvents", cb_device_events)

Expand All @@ -254,22 +265,26 @@ def cb_device_events(session_handle, events):
assert devices_removed == 0
else:
assert device_events_signal_count == 1
assert devices_received == 1
assert devices_received == 2
assert devices_removed == 0

print("Removong device ", dev_path);
portal_mock.umockdev.remove_device(dev_path)
print("Removed")

mainloop = GLib.MainLoop()
GLib.timeout_add(1000, mainloop.quit)
mainloop.run()

print("End of loop")

if usb_queries is None:
assert device_events_signal_count == 0
assert devices_received == 0
assert devices_removed == 0
else:
assert device_events_signal_count == 2
assert devices_received == 1
assert devices_received == 2
assert devices_removed == 1

@pytest.mark.parametrize("usb_queries", ["vnd:04a9;vnd:04aa"])
Expand Down

0 comments on commit 787cf12

Please sign in to comment.