@@ -319,6 +319,40 @@ def test_ruby(self):
319319 self .assertIsNotNone (to_model (f ))
320320
321321
322+ def test_line_origin_extent (self ):
323+ f = io .StringIO (r"""WEBVTT
324+
325+ 1
326+ 00:00:00.000 --> 00:00:02.000 line:0
327+ Line 0 starting from top
328+
329+ 2
330+ 00:00:03.000 --> 00:00:05.000 line:5
331+ Line 5 starting from top
332+
333+ 3
334+ 00:00:06.000 --> 00:00:08.000 line:45%
335+ Line in percentage
336+
337+ 4
338+ 00:00:09.000 --> 00:00:11.000 line:-1
339+ Line 1 starting from bottom
340+ """ )
341+ doc = to_model (f )
342+ regions = list (doc .iter_regions ())
343+ # line 0 starting from top
344+ self .assertEqual (round (regions [0 ].get_style (styles .StyleProperties .Origin ).y .value ), 0 )
345+ self .assertEqual (round (regions [0 ].get_style (styles .StyleProperties .Extent ).height .value ), 100 )
346+ # line 5 starting from top
347+ self .assertEqual (round (regions [1 ].get_style (styles .StyleProperties .Origin ).y .value ), 22 )
348+ self .assertEqual (round (regions [1 ].get_style (styles .StyleProperties .Extent ).height .value ), 78 )
349+ # line in percentage
350+ self .assertEqual (round (regions [2 ].get_style (styles .StyleProperties .Origin ).y .value ), 45 )
351+ self .assertEqual (round (regions [2 ].get_style (styles .StyleProperties .Extent ).height .value ), 55 )
352+ # line 1 starting from bottom
353+ self .assertEqual (round (regions [3 ].get_style (styles .StyleProperties .Origin ).y .value ), 96 )
354+ self .assertEqual (round (regions [3 ].get_style (styles .StyleProperties .Extent ).height .value ), 4 )
355+
322356
323357
324358if __name__ == '__main__' :
0 commit comments