tests: Add device removal test

This commit is contained in:
Benjamin Berg
2020-11-17 14:46:22 +01:00
parent 08fb209aed
commit ab8118bde2

View File

@ -303,6 +303,11 @@ class FPrintdTest(dbusmock.DBusTestCase):
with Connection(self.sockaddr) as con: with Connection(self.sockaddr) as con:
con.sendall(struct.pack('ii', -2, error)) con.sendall(struct.pack('ii', -2, error))
# From libfprint tests
def send_remove(self):
with Connection(self.sockaddr) as con:
con.sendall(struct.pack('ii', -5, 0))
# From libfprint tests # From libfprint tests
def send_image(self, image): def send_image(self, image):
img = self.prints[image] img = self.prints[image]
@ -682,6 +687,27 @@ class FPrintdVirtualDeviceTest(FPrintdVirtualDeviceBaseTest):
time.sleep(1) time.sleep(1)
def test_removal_during_enroll(self):
self._polkitd_obj.SetAllowed(['net.reactivated.fprint.device.setusername',
'net.reactivated.fprint.device.enroll'])
self.device.Claim('(s)', 'testuser')
self.device.EnrollStart('(s)', 'left-index-finger')
# Now remove the device while we are enrolling, which will cause an error
self.send_remove()
self.wait_for_result(expected='enroll-unknown-error')
# The device will still be there now until it is released
devices = self.manager.GetDevices()
self.assertIn(self.device.get_object_path(), devices)
with self.assertFprintError('Internal'):
self.device.Release()
# And now it will be gone
devices = self.manager.GetDevices()
self.assertNotIn(self.device.get_object_path(), devices)
class FPrintdVirtualDeviceClaimedTest(FPrintdVirtualDeviceBaseTest): class FPrintdVirtualDeviceClaimedTest(FPrintdVirtualDeviceBaseTest):
def setUp(self): def setUp(self):