summaryrefslogtreecommitdiff
path: root/mpv-test.py
diff options
context:
space:
mode:
authorjaseg <code@jaseg.net>2020-07-12 13:27:53 +0200
committerjaseg <code@jaseg.net>2020-07-12 13:27:53 +0200
commitc3eef35f595bc4aa2c2aa30345ad63ee583e98e1 (patch)
tree94648f0fc8d56199ff33dfe2031164fb3e658bb0 /mpv-test.py
parent3ef4ecf765820cbb34921a3bc2893e3d2e8c440a (diff)
downloadpython-mpv-c3eef35f595bc4aa2c2aa30345ad63ee583e98e1.tar.gz
python-mpv-c3eef35f595bc4aa2c2aa30345ad63ee583e98e1.tar.bz2
python-mpv-c3eef35f595bc4aa2c2aa30345ad63ee583e98e1.zip
Fix handling of dashed options in loadfile.
Add tests based on --sub-file. Also add a test for sub_add here.
Diffstat (limited to 'mpv-test.py')
-rwxr-xr-xmpv-test.py41
1 files changed, 34 insertions, 7 deletions
diff --git a/mpv-test.py b/mpv-test.py
index b9a3d65..031b806 100755
--- a/mpv-test.py
+++ b/mpv-test.py
@@ -544,6 +544,8 @@ class TestLifecycle(unittest.TestCase):
def test_log_handler(self):
handler = mock.Mock()
+ self.disp = Xvfb()
+ self.disp.start()
m = mpv.MPV(video=False, log_handler=handler)
m.play(TESTVID)
m.wait_for_playback()
@@ -554,6 +556,32 @@ class TestLifecycle(unittest.TestCase):
break
else:
self.fail('"Playing: foo..." call not found in log handler calls: '+','.join(repr(call) for call in handler.mock_calls))
+ self.disp.stop()
+
+
+class CommandTests(MpvTestCase):
+
+ def test_loadfile_with_subtitles(self):
+ handler = mock.Mock()
+ self.m.property_observer('sub-text')(handler)
+
+ self.m.loadfile(TESTVID, sub_file='test.srt')
+
+ self.m.wait_for_playback()
+ handler.assert_any_call('sub-text', 'This is\na subtitle test.')
+ handler.assert_any_call('sub-text', 'This is the second subtitle line.')
+
+ def test_sub_add(self):
+ handler = mock.Mock()
+ self.m.property_observer('sub-text')(handler)
+
+ self.m.loadfile(TESTVID)
+ self.m.wait_for_property('core-idle', lambda x: not x)
+ self.m.sub_add('test.srt')
+
+ self.m.wait_for_playback()
+ handler.assert_any_call('sub-text', 'This is\na subtitle test.')
+ handler.assert_any_call('sub-text', 'This is the second subtitle line.')
class RegressionTests(MpvTestCase):
@@ -591,20 +619,19 @@ class RegressionTests(MpvTestCase):
t = T()
m.loop = 'inf'
+ time.sleep(0.5)
m.observe_property('loop', t.t)
+ time.sleep(0.5)
m.loop = False
- self.assertEqual(m.loop, False)
- # Wait for tick. AFAICT property events are only generated at regular
- # intervals, and if we change a property too fast we don't get any
- # events. This is a limitation of the upstream API.
- time.sleep(0.01)
+ time.sleep(0.5)
+
m.loop = 'inf'
- self.assertEqual(m.loop, True)
+ time.sleep(0.5)
- time.sleep(0.02)
m.unobserve_property('loop', t.t)
+ time.sleep(0.5)
m.loop = False
m.loop = 'inf'