summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2020-07-19 21:54:49 +0200
committerjaseg <code@jaseg.net>2020-07-19 21:54:49 +0200
commitdae47345f7bf177000731c347769886220d207e8 (patch)
tree8fec69b96d14c2316ef5eec7720f411eada5b7b2
parent583f12ed6334eb6deac767a726f5ac6f9e7be9be (diff)
downloadpython-mpv-dae47345f7bf177000731c347769886220d207e8.tar.gz
python-mpv-dae47345f7bf177000731c347769886220d207e8.tar.bz2
python-mpv-dae47345f7bf177000731c347769886220d207e8.zip
tests: add tests for new wait_* API
-rwxr-xr-xmpv-test.py87
1 files changed, 87 insertions, 0 deletions
diff --git a/mpv-test.py b/mpv-test.py
index 5a74eb7..cb6297c 100755
--- a/mpv-test.py
+++ b/mpv-test.py
@@ -561,6 +561,93 @@ class TestLifecycle(unittest.TestCase):
handler.assert_not_called()
@devnull_libmpv()
+ def test_wait_for_property_negative(self):
+ self.disp = Xvfb()
+ self.disp.start()
+ m = mpv.MPV()
+ m.play(TESTVID)
+ def run():
+ nonlocal self
+ try:
+ m.wait_for_property('mute')
+ self.fail()
+ except mpv.ShutdownError:
+ pass
+ t = threading.Thread(target=run, daemon=True)
+ t.start()
+ time.sleep(1)
+ m.terminate()
+ t.join()
+ self.disp.stop()
+
+ @devnull_libmpv()
+ def test_wait_for_property_positive(self):
+ self.disp = Xvfb()
+ self.disp.start()
+ handler = mock.Mock()
+ m = mpv.MPV()
+ m.play(TESTVID)
+ def run():
+ nonlocal self
+ m.wait_for_property('mute')
+ handler()
+ t = threading.Thread(target=run, daemon=True)
+ t.start()
+ m.wait_until_playing()
+ m.mute = True
+ t.join()
+ m.terminate()
+ handler.assert_called()
+ self.disp.stop()
+
+ @devnull_libmpv()
+ def test_wait_for_event(self):
+ self.disp = Xvfb()
+ self.disp.start()
+ handler = mock.Mock()
+ m = mpv.MPV()
+ m.play(TESTVID)
+ def run():
+ nonlocal self
+ try:
+ m.wait_for_event('seek')
+ self.fail()
+ except mpv.ShutdownError:
+ pass
+ t = threading.Thread(target=run, daemon=True)
+ t.start()
+ time.sleep(1)
+ m.terminate()
+ t.join()
+ self.disp.stop()
+
+ @devnull_libmpv()
+ def test_wait_for_property_shutdown(self):
+ self.disp = Xvfb()
+ self.disp.start()
+ handler = mock.Mock()
+ m = mpv.MPV()
+ m.play(TESTVID)
+ with self.assertRaises(mpv.ShutdownError):
+ # level_sensitive=false needed to prevent get_property on dead
+ # handle
+ with m.prepare_and_wait_for_property('mute', level_sensitive=False):
+ m.terminate()
+ self.disp.stop()
+
+ @devnull_libmpv()
+ def test_wait_for_event_shutdown(self):
+ self.disp = Xvfb()
+ self.disp.start()
+ handler = mock.Mock()
+ m = mpv.MPV()
+ m.play(TESTVID)
+ with self.assertRaises(mpv.ShutdownError):
+ with m.prepare_and_wait_for_event('seek'):
+ m.terminate()
+ self.disp.stop()
+
+ @devnull_libmpv()
def test_log_handler(self):
handler = mock.Mock()
self.disp = Xvfb()