From 23ce806b80ff717f21f270aaed0aefbd7666b0eb Mon Sep 17 00:00:00 2001 From: ScottDowne Date: Mon, 16 May 2011 20:12:01 -0400 Subject: [PATCH] [#t381] subtitle position check on all platforms --- plugins/subtitle/popcorn.subtitle.unit.js | 51 ++++++++++++++--------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/plugins/subtitle/popcorn.subtitle.unit.js b/plugins/subtitle/popcorn.subtitle.unit.js index 1078c66..ac118c7 100644 --- a/plugins/subtitle/popcorn.subtitle.unit.js +++ b/plugins/subtitle/popcorn.subtitle.unit.js @@ -3,10 +3,8 @@ test("Popcorn Subtitle Plugin", function () { var popped = Popcorn("#video"), expects = 9, count = 0, - interval, - interval2, - interval3, - interval4, + subTop = 9001, + subLeft = 9001, subtitlediv; expect(expects); @@ -53,16 +51,40 @@ test("Popcorn Subtitle Plugin", function () { popped.exec( 0.5, function() { - equals ( subtitlediv.style.left, "400px", "subtitle left position moved" ); - plus(); - equals ( subtitlediv.style.top, "657px", "subtitle top position moved" ); - plus(); - equals (subtitlediv.innerHTML, "this is the first subtitle of 2011", "subtitle displaying correct information" ); + // capturing location now, to check against later, + // a subtitle must be displayed to get valid data + // which is why we do this in exec + subLeft = subtitlediv.style.left; + subTop = subtitlediv.style.top; + + // changing position + popped.media.style.position = "absolute"; + popped.media.style.left = "400px"; + popped.media.style.top = "600px"; + + equals( subtitlediv.innerHTML, "this is the first subtitle of 2011", "subtitle displaying correct information" ); plus(); }); popped.exec( 1.5, function() { + + // check position of subttile that should of moved with video, + // a subtitle must be displayed to get valid data + ok( subtitlediv.style.left !== subLeft, "subtitle's left position has changed" ); + plus(); + ok( subtitlediv.style.top !== subTop, "subtitle's top position has changed" ); + plus(); + + // we know values have changed, but how accurate are they? + // check values against the video's values + // we need four checks because if we just check against video's position, + // and video's position hasn't updated either, we'll pass when we should fail + equals( subtitlediv.style.left, popped.position().left + "px", "subtitle left position moved" ); + plus(); + ok( Popcorn.position( subtitlediv ).top > popped.position().top, "subtitle top position moved" ); + plus(); + equals (subtitlediv.innerHTML, "this is the second subtitle of 2011", "subtitle displaying correct information" ); plus(); }); @@ -78,14 +100,5 @@ test("Popcorn Subtitle Plugin", function () { equals (subtitlediv.innerHTML, "this is the third subtitle of 2011", "subtitle displaying correct information" ); plus(); }); - - equals ( "8px", subtitlediv.style.left, "subtitle left position default" ); - plus(); - equals ( "247px", subtitlediv.style.top, "subtitle top position default" ); - plus(); - - popped.media.style.position = "absolute"; - popped.media.style.left = "400px"; - popped.media.style.top = "600px"; - }); + -- 2.43.0