Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: third_party/WebKit/LayoutTests/media/track/track-cue-rendering.html

Issue 1913423002: Convert track tests from video-test.js to testharness.js based (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comment Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/track/track-cue-rendering-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <title>Test that default positioned TextTrack's cues are rendered correctly.</ti tle>
3 <head> 3 <script src="../media-file.js"></script>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 4 <script src="../media-controls.js"></script>
5 <script src="../../resources/testharness.js"></script>
6 <script src="../../resources/testharnessreport.js"></script>
7 <video>
8 <track src="captions-webvtt/captions.vtt" kind="captions" default>
9 </video>
10 <script>
11 async_test(function(t) {
12 var video = document.querySelector("video");
13 var testTrack = document.querySelector("track");
14 video.src = findMediaFile("video", "../content/test");
5 15
6 <script src=../media-file.js></script> 16 var cueTextIndex = 0;
7 <!-- TODO(philipj): Convert test to testharness.js. crbug.com/588956 17 var cueText = [ "Lorem", "ipsum", "dolor", "sit" ];
8 (Please avoid writing new tests using video-test.js) --> 18 video.onseeked = t.step_func(function() {
9 <script src=../video-test.js></script> 19 assert_equals(video.currentTime, cueTextIndex + 0.5);
10 <script src=../media-controls.js></script> 20 assert_equals(testTrack.track.activeCues.length, 1);
21 assert_equals(testTrack.track.activeCues[0].text, cueText[cueTextIndex]) ;
11 22
12 <script> 23 var testCueDisplayBox = textTrackDisplayElement(video, "display");
24 assert_equals(testCueDisplayBox.innerText, cueText[cueTextIndex]);
25 assert_equals(2 * testCueDisplayBox.offsetLeft, video.videoWidth - testC ueDisplayBox.offsetWidth)
13 26
14 var testTrack; 27 if (++cueTextIndex == cueText.length) {
15 var testCueDisplayBox; 28 // Test the cue display colors and font.
16 var seekedCount = 0;
17 var info = [ "Lorem", "ipsum", "dolor", "sit" ];
18
19 function testFontSize(width, height)
20 {
21 run("video.width = " + width);
22 run("video.height = " + height);
23 document.body.offsetTop;
24 testExpected("getComputedStyle(textTrackDisplayElement(video)).fontS ize", parseInt(height * 0.05) + "px");
25 consoleWrite("");
26 }
27
28 function testCueStyle()
29 {
30 consoleWrite("<br>Test the cue display colors and font.");
31 testFontSize(320, 240); 29 testFontSize(320, 240);
32 testFontSize(640, 480); 30 testFontSize(640, 480);
33 testFontSize(1280, 960); 31 testFontSize(1280, 960);
34 testFontSize(2560, 1440); 32 testFontSize(2560, 1440);
35 33
36 testExpected("getComputedStyle(textTrackDisplayElement(video)).fontF amily", "sans-serif"); 34 assert_equals(getComputedStyle(textTrackDisplayElement(video)).fontF amily, "sans-serif");
37 testExpected("getComputedStyle(textTrackDisplayElement(video)).color ", "rgb(255, 255, 255)"); 35 assert_equals(getComputedStyle(textTrackDisplayElement(video)).color , "rgb(255, 255, 255)");
38 testExpected("getComputedStyle(textTrackDisplayElement(video, 'displ ay').firstChild).backgroundColor", "rgba(0, 0, 0, 0.796875)"); 36 assert_equals(getComputedStyle(textTrackDisplayElement(video, "displ ay").firstChild).backgroundColor, "rgba(0, 0, 0, 0.8)");
39 37
40 endTest(); 38 t.done();
39 } else {
40 video.currentTime += 1;
41 }
42 });
41 43
42 // Resize the video so it is easier to interact with it manually, if necessary. 44 function testFontSize(width, height) {
43 video.width = 320; 45 video.width = width;
44 video.height = 240; 46 video.height = height;
45 } 47 // Force a relayout of the document
46 48 document.body.offsetTop;
47 function seeked() 49 assert_equals(getComputedStyle(textTrackDisplayElement(video)).fontSize, parseInt(height * 0.05) + "px");
48 { 50 }
49 if (testEnded) 51
50 return; 52 video.currentTime = 0.5;
51 53 });
52 testExpected("video.currentTime", seekedCount + .5); 54 </script>
53 testExpected("testTrack.track.activeCues.length", 1);
54 testExpected("testTrack.track.activeCues[0].text", info[seekedCount] );
55
56 testCueDisplayBox = textTrackDisplayElement(video, 'display');
57 testExpected("testCueDisplayBox.innerText", info[seekedCount]);
58 testExpected("2 * testCueDisplayBox.offsetLeft == video.videoWidth - testCueDisplayBox.offsetWidth", true)
59
60 if (++seekedCount == info.length)
61 testCueStyle();
62 else {
63 consoleWrite("");
64 run("video.currentTime = " + (video.currentTime + 1));
65 return;
66 }
67 }
68
69 function loaded()
70 {
71 consoleWrite("Test that default positioned TextTrack's cues are rend ered correctly.");
72 findMediaElement();
73 testTrack = document.querySelector('track');
74 video.src = findMediaFile('video', '../content/test');
75 waitForEvent('seeked', seeked);
76 waitForEventOnce('canplaythrough', function() { video.currentTime = .5; });
77 }
78
79 </script>
80 </head>
81 <body onload="loaded()">
82 <video controls >
83 <track src="captions-webvtt/captions.vtt" kind="captions" default>
84 </video>
85 </body>
86 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/media/track/track-cue-rendering-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698