<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[189254] trunk/LayoutTests</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/189254">189254</a></dd>
<dt>Author</dt> <dd>dino@apple.com</dd>
<dt>Date</dt> <dd>2015-09-02 10:33:17 -0700 (Wed, 02 Sep 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>[mediacontrols] Improve media controls testing helpers
https://bugs.webkit.org/show_bug.cgi?id=148697
&lt;rdar://problem/22530876&gt;

Reviewed by Eric Carlson.

Implement a more modern-looking testing API for media
controls tests, and update the existing tests to
use the new API.

* media/controls/basic-expected.txt:
* media/controls/basic.html:
* media/controls/controls-test-helpers.js:
(ControlsTest): New class for helping testing.
(statusForControlsElement): Deleted.
* media/controls/showControlsButton-expected.txt:
* media/controls/showControlsButton.html:
* media/controls/statusDisplay-expected.txt:
* media/controls/statusDisplay.html:
* media/controls/statusDisplayBad-expected.txt:
* media/controls/statusDisplayBad.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsmediacontrolsbasicexpectedtxt">trunk/LayoutTests/media/controls/basic-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediacontrolsbasichtml">trunk/LayoutTests/media/controls/basic.html</a></li>
<li><a href="#trunkLayoutTestsmediacontrolscontrolstesthelpersjs">trunk/LayoutTests/media/controls/controls-test-helpers.js</a></li>
<li><a href="#trunkLayoutTestsmediacontrolsshowControlsButtonexpectedtxt">trunk/LayoutTests/media/controls/showControlsButton-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediacontrolsshowControlsButtonhtml">trunk/LayoutTests/media/controls/showControlsButton.html</a></li>
<li><a href="#trunkLayoutTestsmediacontrolsstatusDisplayexpectedtxt">trunk/LayoutTests/media/controls/statusDisplay-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediacontrolsstatusDisplayhtml">trunk/LayoutTests/media/controls/statusDisplay.html</a></li>
<li><a href="#trunkLayoutTestsmediacontrolsstatusDisplayBadexpectedtxt">trunk/LayoutTests/media/controls/statusDisplayBad-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediacontrolsstatusDisplayBadhtml">trunk/LayoutTests/media/controls/statusDisplayBad.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (189253 => 189254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-09-02 17:09:00 UTC (rev 189253)
+++ trunk/LayoutTests/ChangeLog        2015-09-02 17:33:17 UTC (rev 189254)
</span><span class="lines">@@ -1,3 +1,27 @@
</span><ins>+2015-09-01  Dean Jackson  &lt;dino@apple.com&gt;
+
+        [mediacontrols] Improve media controls testing helpers
+        https://bugs.webkit.org/show_bug.cgi?id=148697
+        &lt;rdar://problem/22530876&gt;
+
+        Reviewed by Eric Carlson.
+
+        Implement a more modern-looking testing API for media
+        controls tests, and update the existing tests to
+        use the new API.
+
+        * media/controls/basic-expected.txt:
+        * media/controls/basic.html:
+        * media/controls/controls-test-helpers.js:
+        (ControlsTest): New class for helping testing.
+        (statusForControlsElement): Deleted.
+        * media/controls/showControlsButton-expected.txt:
+        * media/controls/showControlsButton.html:
+        * media/controls/statusDisplay-expected.txt:
+        * media/controls/statusDisplay.html:
+        * media/controls/statusDisplayBad-expected.txt:
+        * media/controls/statusDisplayBad.html:
+
</ins><span class="cx"> 2015-09-02  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         document.createProcessingInstruction() does not behave according to specification
</span></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsbasicexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/controls/basic-expected.txt (189253 => 189254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/basic-expected.txt        2015-09-02 17:09:00 UTC (rev 189253)
+++ trunk/LayoutTests/media/controls/basic-expected.txt        2015-09-02 17:33:17 UTC (rev 189254)
</span><span class="lines">@@ -3,8 +3,8 @@
</span><span class="cx"> This test only runs in DRT!
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-EVENT(canplaythrough)
-TEST(currentStatus != null) OK
-EXPECTED (currentStatus.status == 'ok') OK
-END OF TEST
</del><ins>+EVENT: canplaythrough
+PASS: Check that status is ok
</ins><span class="cx"> 
</span><ins>+Testing finished.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsbasichtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/controls/basic.html (189253 => 189254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/basic.html        2015-09-02 17:09:00 UTC (rev 189253)
+++ trunk/LayoutTests/media/controls/basic.html        2015-09-02 17:33:17 UTC (rev 189254)
</span><span class="lines">@@ -2,34 +2,24 @@
</span><span class="cx"> &lt;html&gt;
</span><span class="cx">     &lt;head&gt;
</span><span class="cx">         &lt;script src=&quot;../media-file.js&quot;&gt;&lt;/script&gt;
</span><del>-        &lt;script src=&quot;../video-test.js&quot;&gt;&lt;/script&gt;
</del><ins>+        &lt;script src=&quot;controls-test-helpers.js&quot;&gt;&lt;/script&gt;
</ins><span class="cx">         &lt;script&gt;
</span><del>-            var video;
-            var currentStatus;
</del><ins>+            var tester = new ControlsTest()
+                .whenReady(runTests)
+                .start();
</ins><span class="cx"> 
</span><del>-            function init()
</del><ins>+            function runTests()
</ins><span class="cx">             {
</span><del>-                findMediaElement();
-                video.src = findMediaFile(&quot;video&quot;, &quot;../content/test&quot;);
</del><ins>+                currentState = tester.currentState;
+                tester.test(&quot;Check that status is ok&quot;)
+                    .value(currentState.status)
+                    .isEqualTo(&quot;ok&quot;);
</ins><span class="cx"> 
</span><del>-                waitForEvent(&quot;canplaythrough&quot;, canplaythrough);
-                waitForEventAndFail(&quot;error&quot;);
</del><ins>+                tester.end();
</ins><span class="cx">             }
</span><del>-
-            function canplaythrough()
-            {
-                if (!window.testRunner)
-                    return;
-
-                currentStatus = JSON.parse(internals.getCurrentMediaControlsStatusForElement(video));
-                test(&quot;currentStatus != null&quot;);
-                if (currentStatus)
-                    testExpected(&quot;currentStatus.status&quot;, &quot;ok&quot;);
-                endTest();
-            }
</del><span class="cx">         &lt;/script&gt;
</span><span class="cx">     &lt;/head&gt;
</span><del>-    &lt;body onload=&quot;init()&quot;&gt;
</del><ins>+    &lt;body&gt;
</ins><span class="cx">         &lt;p&gt;This is a basic test of the internal controls status API.&lt;/p&gt;
</span><span class="cx">         &lt;p&gt;This test only runs in DRT!&lt;/p&gt;
</span><span class="cx">         &lt;video controls&gt;&lt;/video&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsmediacontrolscontrolstesthelpersjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/controls/controls-test-helpers.js (189253 => 189254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/controls-test-helpers.js        2015-09-02 17:09:00 UTC (rev 189253)
+++ trunk/LayoutTests/media/controls/controls-test-helpers.js        2015-09-02 17:33:17 UTC (rev 189254)
</span><span class="lines">@@ -1,10 +1,170 @@
</span><del>-function statusForControlsElement(statusObject, elementName)
-{
-    if (statusObject.elements &amp;&amp; statusObject.elements.length) {
-        for (var i = 0; i &lt; statusObject.elements.length; i++) {
-            if (statusObject.elements[i].name == elementName)
-                return statusObject.elements[i];
</del><ins>+ControlsTest = class ControlsTest {
+    constructor(mediaURL, eventTrigger)
+    {
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
</ins><span class="cx">         }
</span><ins>+
+        this.callback = null;
+        this.mediaURL = mediaURL || &quot;../content/test&quot;;
+        this.eventTrigger = eventTrigger || &quot;canplaythrough&quot;;
+        this.currentMessage = &quot;&quot;;
+        this.currentValue = null;
</ins><span class="cx">     }
</span><del>-    return null;
</del><ins>+
+    whenReady(callback)
+    {
+        if (typeof callback == &quot;function&quot;)
+            this.callback = callback;
+        return this;
+    }
+
+    get currentState()
+    {
+        if (!this.media)
+            return null;
+
+        if (window.internals)
+            return JSON.parse(internals.getCurrentMediaControlsStatusForElement(this.media));
+
+        // This is only for fallback testing. Even then it is pretty useless.
+        return { idiom: &quot;apple&quot;, status: &quot;fail&quot; };
+    }
+
+    stateForControlsElement(elementName)
+    {
+        var state = this.currentState;
+        if (state.elements &amp;&amp; state.elements.length) {
+            for (var i = 0; i &lt; state.elements.length; i++) {
+                if (state.elements[i].name == elementName)
+                    return state.elements[i];
+            }
+        }
+        return null;
+    }
+
+    handleEvent(event)
+    {
+        this.logMessage(`EVENT: ${event.type}`);
+        if (event.type == this.eventTrigger &amp;&amp; this.callback)
+            this.callback();
+    }
+
+    logSuccess(msg)
+    {
+        this.logMessage(`PASS: ${msg}`);
+    }
+
+    logFailure(msg)
+    {
+        this.logMessage(`FAIL: ${msg}`);
+    }
+
+    logMessage(msg)
+    {
+        this.console.appendChild(document.createTextNode(msg));
+        this.logBlankLine();
+    }
+
+    logBlankLine()
+    {
+        this.console.appendChild(document.createElement(&quot;br&quot;));
+    }
+
+    startNewSection(msg)
+    {
+        this.logBlankLine();
+        this.logMessage(msg);
+        this.logBlankLine();
+    }
+
+    setup()
+    {
+        if (!window.testRunner) {
+            this.logFailure(&quot;Test requires DRT.&quot;);
+            return false;
+        }
+
+        this.console = document.createElement(&quot;div&quot;);
+        this.console.className = &quot;console&quot;;
+        document.body.appendChild(this.console);
+
+        this.media = document.querySelector(&quot;video&quot;);
+
+        if (!this.media) {
+            this.logFailure(&quot;Unable to find media element&quot;);
+            this.end();
+            return false;
+        }
+
+        this.media.addEventListener(this.eventTrigger, this, false);
+        this.media.src = findMediaFile(&quot;video&quot;, this.mediaURL);
+
+        return true;
+    }
+
+    start(msg)
+    {
+        window.addEventListener(&quot;load&quot;, function () {
+            this.setup();
+            if (msg)
+                this.startNewSection(msg);
+        }.bind(this), false);
+        return this;
+    }
+
+    end()
+    {
+        this.logMessage(&quot;&quot;);
+        this.logMessage(&quot;Testing finished.&quot;);
+        if (window.testRunner)
+            testRunner.notifyDone();
+        return this;
+    }
+
+    test(message)
+    {
+        this.currentMessage = message;
+        return this;
+    }
+
+    value(newValue)
+    {
+        this.currentValue = newValue;
+        return this;
+    }
+
+    isEqualTo(value)
+    {
+        if (this.currentValue == value)
+            this.logSuccess(this.currentMessage);
+        else
+            this.logFailure(`${this.currentMessage} Expected: &quot;${value}&quot;. Actual: &quot;${this.currentValue}&quot;`);
+    }
+
+    isEmptyString()
+    {
+        if (!this.currentValue &amp;&amp; typeof this.currentValue == &quot;string&quot;)
+            this.logSuccess(this.currentMessage);
+        else
+            this.logFailure(`${this.currentMessage} Expected an empty string. Actual: &quot;${this.currentValue}&quot;`);
+    }
+
+    isTrue()
+    {
+        if (this.currentValue)
+            this.logSuccess(this.currentMessage);
+        else
+            this.logFailure(`${this.currentMessage} Expected a true value. Actual: &quot;${this.currentValue}&quot;`);
+    }
+
+    isFalse()
+    {
+        if (!this.currentValue)
+            this.logSuccess(this.currentMessage);
+        else
+            this.logFailure(`${this.currentMessage} Expected a false value. Actual: &quot;${this.currentValue}&quot;`);
+    }
+
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsshowControlsButtonexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/controls/showControlsButton-expected.txt (189253 => 189254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/showControlsButton-expected.txt        2015-09-02 17:09:00 UTC (rev 189253)
+++ trunk/LayoutTests/media/controls/showControlsButton-expected.txt        2015-09-02 17:33:17 UTC (rev 189254)
</span><span class="lines">@@ -3,8 +3,16 @@
</span><span class="cx"> This test only runs in DRT!
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-EVENT(canplaythrough)
-EXPECTED (showControlsButtonInfo.name == 'Show Controls') OK
-EXPECTED (showControlsButtonInfo.hidden == 'true') OK
-END OF TEST
</del><span class="cx"> 
</span><ins>+Test for Show Controls button
+
+EVENT: canplaythrough
+PASS: We are using the apple idiom
+
+Get the button that shows controls while in Voice Over
+
+PASS: Name is 'Show Controls'
+PASS: Is hidden
+
+Testing finished.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsshowControlsButtonhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/controls/showControlsButton.html (189253 => 189254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/showControlsButton.html        2015-09-02 17:09:00 UTC (rev 189253)
+++ trunk/LayoutTests/media/controls/showControlsButton.html        2015-09-02 17:33:17 UTC (rev 189254)
</span><span class="lines">@@ -2,42 +2,35 @@
</span><span class="cx"> &lt;html&gt;
</span><span class="cx">     &lt;head&gt;
</span><span class="cx">         &lt;script src=&quot;../media-file.js&quot;&gt;&lt;/script&gt;
</span><del>-        &lt;script src=&quot;../video-test.js&quot;&gt;&lt;/script&gt;
</del><span class="cx">         &lt;script src=&quot;controls-test-helpers.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">         &lt;script&gt;
</span><del>-            var video;
-            var currentStatus;
-            var showControlsButtonInfo;
</del><ins>+            var tester = new ControlsTest()
+                .whenReady(runTests)
+                .start(&quot;Test for Show Controls button&quot;);
</ins><span class="cx"> 
</span><del>-            function init()
</del><ins>+            function runTests()
</ins><span class="cx">             {
</span><del>-                findMediaElement();
-                video.src = findMediaFile(&quot;video&quot;, &quot;../content/test&quot;);
</del><ins>+                currentState = tester.currentState;
+                tester.test(&quot;We are using the apple idiom&quot;)
+                    .value(currentState.idiom)
+                    .isEqualTo(&quot;apple&quot;);
</ins><span class="cx"> 
</span><del>-                waitForEvent(&quot;canplaythrough&quot;, canplaythrough);
-                waitForEventAndFail(&quot;error&quot;);
-            }
</del><ins>+                tester.startNewSection(&quot;Get the button that shows controls while in Voice Over&quot;);
+                var controlsButtonState = tester.stateForControlsElement(&quot;Show Controls&quot;);
</ins><span class="cx"> 
</span><del>-            function canplaythrough()
-            {
-                if (!window.testRunner)
-                    return;
</del><ins>+                tester.test(&quot;Name is 'Show Controls'&quot;)
+                    .value(controlsButtonState.name)
+                    .isEqualTo(&quot;Show Controls&quot;);
</ins><span class="cx"> 
</span><del>-                currentStatus = JSON.parse(internals.getCurrentMediaControlsStatusForElement(video));
-                if (currentStatus) {
-                    if (currentStatus.idiom == &quot;apple&quot;) {
-                        showControlsButtonInfo = statusForControlsElement(currentStatus, &quot;Show Controls&quot;);
-                        if (showControlsButtonInfo) {
-                            testExpected(&quot;showControlsButtonInfo.name&quot;, &quot;Show Controls&quot;);
-                            testExpected(&quot;showControlsButtonInfo.hidden&quot;, true);
-                        }
-                    }
-                }
-                endTest();
</del><ins>+                tester.test(&quot;Is hidden&quot;)
+                    .value(controlsButtonState.hidden)
+                    .isTrue();
+
+                tester.end();
</ins><span class="cx">             }
</span><span class="cx">         &lt;/script&gt;
</span><span class="cx">     &lt;/head&gt;
</span><del>-    &lt;body onload=&quot;init()&quot;&gt;
</del><ins>+    &lt;body&gt;
</ins><span class="cx">         &lt;p&gt;This tests for the existence of a hidden Show Controls button.&lt;/p&gt;
</span><span class="cx">         &lt;p&gt;This test only runs in DRT!&lt;/p&gt;
</span><span class="cx">         &lt;video controls&gt;&lt;/video&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsstatusDisplayexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/controls/statusDisplay-expected.txt (189253 => 189254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/statusDisplay-expected.txt        2015-09-02 17:09:00 UTC (rev 189253)
+++ trunk/LayoutTests/media/controls/statusDisplay-expected.txt        2015-09-02 17:33:17 UTC (rev 189254)
</span><span class="lines">@@ -3,9 +3,14 @@
</span><span class="cx"> This test only runs in DRT!
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-EVENT(canplaythrough)
-EXPECTED (statusDisplayInfo.name == 'Status Display') OK
-EXPECTED (statusDisplayInfo.className == 'hidden') OK
-EXPECTED (statusDisplayInfo.content == '') OK
-END OF TEST
</del><ins>+EVENT: canplaythrough
+PASS: We are using the apple idiom
</ins><span class="cx"> 
</span><ins>+Get the status label state
+
+PASS: Name is 'Status Display'
+PASS: Has hidden class
+PASS: Content is Empty
+
+Testing finished.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsstatusDisplayhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/controls/statusDisplay.html (189253 => 189254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/statusDisplay.html        2015-09-02 17:09:00 UTC (rev 189253)
+++ trunk/LayoutTests/media/controls/statusDisplay.html        2015-09-02 17:33:17 UTC (rev 189254)
</span><span class="lines">@@ -2,43 +2,40 @@
</span><span class="cx"> &lt;html&gt;
</span><span class="cx">     &lt;head&gt;
</span><span class="cx">         &lt;script src=&quot;../media-file.js&quot;&gt;&lt;/script&gt;
</span><del>-        &lt;script src=&quot;../video-test.js&quot;&gt;&lt;/script&gt;
</del><span class="cx">         &lt;script src=&quot;controls-test-helpers.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">         &lt;script&gt;
</span><del>-            var video;
-            var currentStatus;
-            var statusDisplayInfo;
</del><ins>+            var tester = new ControlsTest()
+                .whenReady(runTests)
+                .start();
</ins><span class="cx"> 
</span><del>-            function init()
</del><ins>+            function runTests()
</ins><span class="cx">             {
</span><del>-                findMediaElement();
-                video.src = findMediaFile(&quot;video&quot;, &quot;../content/test&quot;);
</del><ins>+                currentState = tester.currentState;
+                tester.test(&quot;We are using the apple idiom&quot;)
+                    .value(currentState.idiom)
+                    .isEqualTo(&quot;apple&quot;);
</ins><span class="cx"> 
</span><del>-                waitForEvent(&quot;canplaythrough&quot;, canplaythrough);
-                waitForEventAndFail(&quot;error&quot;);
-            }
</del><ins>+                tester.startNewSection(&quot;Get the status label state&quot;);
+                var statusDisplayLabelState = tester.stateForControlsElement(&quot;Status Display&quot;);
</ins><span class="cx"> 
</span><del>-            function canplaythrough()
-            {
-                if (!window.testRunner)
-                    return;
</del><ins>+                tester.test(&quot;Name is 'Status Display'&quot;)
+                    .value(statusDisplayLabelState.name)
+                    .isEqualTo(&quot;Status Display&quot;);
</ins><span class="cx"> 
</span><del>-                currentStatus = JSON.parse(internals.getCurrentMediaControlsStatusForElement(video));
-                if (currentStatus) {
-                    if (currentStatus.idiom == &quot;apple&quot;) {
-                        statusDisplayInfo = statusForControlsElement(currentStatus, &quot;Status Display&quot;);
-                        if (statusDisplayInfo) {
-                            testExpected(&quot;statusDisplayInfo.name&quot;, &quot;Status Display&quot;);
-                            testExpected(&quot;statusDisplayInfo.className&quot;, &quot;hidden&quot;);
-                            testExpected(&quot;statusDisplayInfo.content&quot;, &quot;&quot;);
-                        }
-                    }
-                }
-                endTest();
</del><ins>+                tester.test(&quot;Has hidden class&quot;)
+                    .value(statusDisplayLabelState.className)
+                    .isEqualTo(&quot;hidden&quot;);
+
+                tester.test(&quot;Content is Empty&quot;)
+                    .value(statusDisplayLabelState.content)
+                    .isEmptyString();
+
+                tester.end();
</ins><span class="cx">             }
</span><ins>+
</ins><span class="cx">         &lt;/script&gt;
</span><span class="cx">     &lt;/head&gt;
</span><del>-    &lt;body onload=&quot;init()&quot;&gt;
</del><ins>+    &lt;body&gt;
</ins><span class="cx">         &lt;p&gt;This tests for the content in the status display.&lt;/p&gt;
</span><span class="cx">         &lt;p&gt;This test only runs in DRT!&lt;/p&gt;
</span><span class="cx">         &lt;video controls&gt;&lt;/video&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsstatusDisplayBadexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/controls/statusDisplayBad-expected.txt (189253 => 189254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/statusDisplayBad-expected.txt        2015-09-02 17:09:00 UTC (rev 189253)
+++ trunk/LayoutTests/media/controls/statusDisplayBad-expected.txt        2015-09-02 17:33:17 UTC (rev 189254)
</span><span class="lines">@@ -3,9 +3,14 @@
</span><span class="cx"> This test only runs in DRT!
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-EVENT(error)
-EXPECTED (statusDisplayInfo.name == 'Status Display') OK
-EXPECTED (statusDisplayInfo.className == '') OK
-EXPECTED (statusDisplayInfo.content == 'Error') OK
-END OF TEST
</del><ins>+EVENT: error
+PASS: We are using the apple idiom
</ins><span class="cx"> 
</span><ins>+Get the status label state
+
+PASS: Name is 'Status Display'
+PASS: Has empty class
+PASS: Content is 'Error'
+
+Testing finished.
+
</ins></span></pre></div>
<a id="trunkLayoutTestsmediacontrolsstatusDisplayBadhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/controls/statusDisplayBad.html (189253 => 189254)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/controls/statusDisplayBad.html        2015-09-02 17:09:00 UTC (rev 189253)
+++ trunk/LayoutTests/media/controls/statusDisplayBad.html        2015-09-02 17:33:17 UTC (rev 189254)
</span><span class="lines">@@ -2,42 +2,39 @@
</span><span class="cx"> &lt;html&gt;
</span><span class="cx">     &lt;head&gt;
</span><span class="cx">         &lt;script src=&quot;../media-file.js&quot;&gt;&lt;/script&gt;
</span><del>-        &lt;script src=&quot;../video-test.js&quot;&gt;&lt;/script&gt;
</del><span class="cx">         &lt;script src=&quot;controls-test-helpers.js&quot;&gt;&lt;/script&gt;
</span><span class="cx">         &lt;script&gt;
</span><del>-            var video;
-            var currentStatus;
-            var statusDisplayInfo;
</del><ins>+            var tester = new ControlsTest(&quot;non-existent-media-file&quot;, &quot;error&quot;)
+                .whenReady(runTests)
+                .start();
</ins><span class="cx"> 
</span><del>-            function init()
</del><ins>+            function runTests()
</ins><span class="cx">             {
</span><del>-                findMediaElement();
-                video.src = findMediaFile(&quot;video&quot;, &quot;non-existent-media-file&quot;);
</del><ins>+                currentState = tester.currentState;
+                tester.test(&quot;We are using the apple idiom&quot;)
+                    .value(currentState.idiom)
+                    .isEqualTo(&quot;apple&quot;);
</ins><span class="cx"> 
</span><del>-                waitForEvent(&quot;error&quot;, runTest);
-            }
</del><ins>+                tester.startNewSection(&quot;Get the status label state&quot;);
+                var statusDisplayLabelState = tester.stateForControlsElement(&quot;Status Display&quot;);
</ins><span class="cx"> 
</span><del>-            function runTest()
-            {
-                if (!window.testRunner)
-                    return;
</del><ins>+                tester.test(&quot;Name is 'Status Display'&quot;)
+                    .value(statusDisplayLabelState.name)
+                    .isEqualTo(&quot;Status Display&quot;);
</ins><span class="cx"> 
</span><del>-                currentStatus = JSON.parse(internals.getCurrentMediaControlsStatusForElement(video));
-                if (currentStatus) {
-                    if (currentStatus.idiom == &quot;apple&quot;) {
-                        statusDisplayInfo = statusForControlsElement(currentStatus, &quot;Status Display&quot;);
-                        if (statusDisplayInfo) {
-                            testExpected(&quot;statusDisplayInfo.name&quot;, &quot;Status Display&quot;);
-                            testExpected(&quot;statusDisplayInfo.className&quot;, &quot;&quot;);
-                            testExpected(&quot;statusDisplayInfo.content&quot;, &quot;Error&quot;);
-                        }
-                    }
-                }
-                endTest();
</del><ins>+                tester.test(&quot;Has empty class&quot;)
+                    .value(statusDisplayLabelState.className)
+                    .isEmptyString();
+
+                tester.test(&quot;Content is 'Error'&quot;)
+                    .value(statusDisplayLabelState.content)
+                    .isEqualTo(&quot;Error&quot;);
+
+                tester.end();
</ins><span class="cx">             }
</span><span class="cx">         &lt;/script&gt;
</span><span class="cx">     &lt;/head&gt;
</span><del>-    &lt;body onload=&quot;init()&quot;&gt;
</del><ins>+    &lt;body&gt;
</ins><span class="cx">         &lt;p&gt;This tests that the status display has the corrent error message.&lt;/p&gt;
</span><span class="cx">         &lt;p&gt;This test only runs in DRT!&lt;/p&gt;
</span><span class="cx">         &lt;video controls&gt;&lt;/video&gt;
</span></span></pre>
</div>
</div>

</body>
</html>