Title: [189359] trunk
Revision
189359
Author
[email protected]
Date
2015-09-04 11:12:21 -0700 (Fri, 04 Sep 2015)

Log Message

[mediacontrols] Test the ordering of elements in the controls panel
https://bugs.webkit.org/show_bug.cgi?id=148804
<rdar://problem/22579232>

Reviewed by Eric Carlson.

Source/WebCore:

Add information about various controls elements to the status object.

Test: media/controls/elementOrder.html

* Modules/mediacontrols/mediaControlsApple.js:

LayoutTests:

Add a new test that checks the visual order of the buttons and
elements in the controls panel. This is helpful because they
are not necessarily in that order within the DOM.

I also added caching of the current state to the testing helper,
to save generating the JSON status multiple times in subsequent
calls.

* media/controls/elementOrder.html: New test.
* media/controls/elementOrder-expected.txt: New results.
* media/controls/controls-test-helpers.js:
(ControlsTest):
(ControlsTest.prototype.get currentState): Added caching.
(ControlsTest.prototype.stateForControlsElement):
(ControlsTest.prototype.isGreaterThan): New test helper.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (189358 => 189359)


--- trunk/LayoutTests/ChangeLog	2015-09-04 18:12:16 UTC (rev 189358)
+++ trunk/LayoutTests/ChangeLog	2015-09-04 18:12:21 UTC (rev 189359)
@@ -1,3 +1,27 @@
+2015-09-04  Dean Jackson  <[email protected]>
+
+        [mediacontrols] Test the ordering of elements in the controls panel
+        https://bugs.webkit.org/show_bug.cgi?id=148804
+        <rdar://problem/22579232>
+
+        Reviewed by Eric Carlson.
+
+        Add a new test that checks the visual order of the buttons and
+        elements in the controls panel. This is helpful because they
+        are not necessarily in that order within the DOM.
+
+        I also added caching of the current state to the testing helper,
+        to save generating the JSON status multiple times in subsequent
+        calls.
+
+        * media/controls/elementOrder.html: New test.
+        * media/controls/elementOrder-expected.txt: New results.
+        * media/controls/controls-test-helpers.js:
+        (ControlsTest):
+        (ControlsTest.prototype.get currentState): Added caching.
+        (ControlsTest.prototype.stateForControlsElement):
+        (ControlsTest.prototype.isGreaterThan): New test helper.
+
 2015-09-03  Dean Jackson  <[email protected]>
 
         [mediacontrols] Expose bounding rectangles and computed style to testing

Modified: trunk/LayoutTests/media/controls/controls-test-helpers.js (189358 => 189359)


--- trunk/LayoutTests/media/controls/controls-test-helpers.js	2015-09-04 18:12:16 UTC (rev 189358)
+++ trunk/LayoutTests/media/controls/controls-test-helpers.js	2015-09-04 18:12:21 UTC (rev 189359)
@@ -11,6 +11,7 @@
         this.eventTrigger = eventTrigger || "canplaythrough";
         this.currentMessage = "";
         this.currentValue = null;
+        this.cachedCurrentState = null;
     }
 
     whenReady(callback)
@@ -25,8 +26,10 @@
         if (!this.media)
             return null;
 
-        if (window.internals)
-            return JSON.parse(internals.getCurrentMediaControlsStatusForElement(this.media));
+        if (window.internals) {
+            this.cachedCurrentState = JSON.parse(internals.getCurrentMediaControlsStatusForElement(this.media));
+            return this.cachedCurrentState;
+        }
 
         // This is only for fallback testing. Even then it is pretty useless.
         return { idiom: "apple", status: "fail" };
@@ -34,7 +37,7 @@
 
     stateForControlsElement(elementName)
     {
-        var state = this.currentState;
+        var state = this.cachedCurrentState || this.currentState;
         if (state.elements && state.elements.length) {
             for (var i = 0; i < state.elements.length; i++) {
                 if (state.elements[i].name == elementName)
@@ -175,4 +178,12 @@
             this.logFailure(`${this.currentMessage} Expected a non-zero value`);
     }
 
+    isGreaterThan(value)
+    {
+        if (this.currentValue > value)
+            this.logSuccess(this.currentMessage);
+        else
+            this.logFailure(`${this.currentMessage} Actual: "${this.currentValue}" is not greater than Expected: "${value}"`);
+    }
+
 }

Added: trunk/LayoutTests/media/controls/elementOrder-expected.txt (0 => 189359)


--- trunk/LayoutTests/media/controls/elementOrder-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/media/controls/elementOrder-expected.txt	2015-09-04 18:12:21 UTC (rev 189359)
@@ -0,0 +1,14 @@
+This tests for the content in the status display.
+
+This test only runs in DRT!
+
+
+EVENT: canplaythrough
+PASS: We are using the apple idiom
+PASS: Rewind Button is to the right of Play Button
+PASS: Timeline Box is to the right of Rewind Button
+PASS: Mute Box is to the right of Timeline Box
+PASS: Fullscreen Button is to the right of Mute Box
+
+Testing finished.
+
Property changes on: trunk/LayoutTests/media/controls/elementOrder-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/media/controls/elementOrder.html (0 => 189359)


--- trunk/LayoutTests/media/controls/elementOrder.html	                        (rev 0)
+++ trunk/LayoutTests/media/controls/elementOrder.html	2015-09-04 18:12:21 UTC (rev 189359)
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <script src=""
+        <script src=""
+        <script>
+            var tester = new ControlsTest()
+                .whenReady(runTests)
+                .start();
+
+            function runTests()
+            {
+                currentState = tester.currentState;
+                tester.test("We are using the apple idiom")
+                    .value(currentState.idiom)
+                    .isEqualTo("apple");
+
+                var elementNames = ["Play Button", "Rewind Button", "Timeline Box", "Mute Box", "Fullscreen Button"];
+                var previousElementName = "";
+                var previousLeftValue = 0;
+
+                elementNames.forEach(function (name) {
+                    var elementState = tester.stateForControlsElement(name);
+                    var leftValue = elementState.bounds.left;
+                    if (previousElementName && previousLeftValue) {
+                        tester.test(`${name} is to the right of ${previousElementName}`)
+                            .value(elementState.bounds.left)
+                        .isGreaterThan(previousLeftValue);
+                    }
+                    previousElementName = name;
+                    previousLeftValue = leftValue;
+                });
+
+                tester.end();
+            }
+
+        </script>
+    </head>
+    <body>
+        <p>This tests for the content in the status display.</p>
+        <p>This test only runs in DRT!</p>
+        <video controls></video>
+    </body>
+</html>
Property changes on: trunk/LayoutTests/media/controls/elementOrder.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (189358 => 189359)


--- trunk/Source/WebCore/ChangeLog	2015-09-04 18:12:16 UTC (rev 189358)
+++ trunk/Source/WebCore/ChangeLog	2015-09-04 18:12:21 UTC (rev 189359)
@@ -1,3 +1,17 @@
+2015-09-04  Dean Jackson  <[email protected]>
+
+        [mediacontrols] Test the ordering of elements in the controls panel
+        https://bugs.webkit.org/show_bug.cgi?id=148804
+        <rdar://problem/22579232>
+
+        Reviewed by Eric Carlson.
+
+        Add information about various controls elements to the status object.
+
+        Test: media/controls/elementOrder.html
+
+        * Modules/mediacontrols/mediaControlsApple.js:
+
 2015-09-03  Dean Jackson  <[email protected]>
 
         [mediacontrols] Expose bounding rectangles and computed style to testing

Modified: trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js (189358 => 189359)


--- trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2015-09-04 18:12:16 UTC (rev 189358)
+++ trunk/Source/WebCore/Modules/mediacontrols/mediaControlsApple.js	2015-09-04 18:12:21 UTC (rev 189359)
@@ -2112,6 +2112,26 @@
                 object: this.controls.statusDisplay,
                 styleValues: ["display"],
                 extraProperties: ["textContent"]
+            },
+            {
+                name: "Play Button",
+                object: this.controls.playButton
+            },
+            {
+                name: "Rewind Button",
+                object: this.controls.rewindButton
+            },
+            {
+                name: "Timeline Box",
+                object: this.controls.timelineBox
+            },
+            {
+                name: "Mute Box",
+                object: this.controls.muteBox
+            },
+            {
+                name: "Fullscreen Button",
+                object: this.controls.fullscreenButton
             }
         ];
 
@@ -2125,16 +2145,18 @@
                 element.styleValues.forEach(function (propertyName) {
                     element.computedStyle[propertyName] = computedStyle[propertyName];
                 });
+                delete element.styleValues;
             }
-            delete element.styleValues;
 
             element.bounds = obj.getBoundingClientRect();
             element.className = obj.className;
 
-            element.extraProperties.forEach(function (property) {
-                element[property] = obj[property];
-            });
-            delete element.extraProperties;
+            if (element.extraProperties) {
+                element.extraProperties.forEach(function (property) {
+                    element[property] = obj[property];
+                });
+                delete element.extraProperties;
+            }
         });
 
         result.elements = elements;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to