Title: [206032] trunk
Revision
206032
Author
jer.no...@apple.com
Date
2016-09-16 11:04:54 -0700 (Fri, 16 Sep 2016)

Log Message

[media-source] fix imported/w3c/web-platform-tests/media-source/mediasource-duration.html
https://bugs.webkit.org/show_bug.cgi?id=161999

Reviewed by Eric Carlson.

LayoutTests/imported/w3c:

Expected results had a stray newline.

* web-platform-tests/media-source/mediasource-duration-expected.txt:

Source/WTF:

The mediasource-duration.html test tries to set the duration of a MediaSource to a double value
(5.0), then some work happens and the duration is set to a media time (12533/2500, or 5.0132).
The test then tries to set that value as the duration, converted from a media time to a double,
and asserts that no duration change event is fired.  But because the floating point value and the
media time value are ever so slightly different, this round-tripping fails.

Fix this bug in MediaTime by, when one side or the other of a comparison is a floating point
MediaTime, convert both sides to doubles and run the comparison against those values. This preserves
the transitive equality of doubles <-> MediaTimes.

* wtf/MediaTime.cpp:
(WTF::MediaTime::compare):

Tools:

* TestWebKitAPI/Tests/WTF/MediaTime.cpp:
(TestWebKitAPI::TEST):

LayoutTests:

* platform/mac/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (206031 => 206032)


--- trunk/LayoutTests/ChangeLog	2016-09-16 17:46:51 UTC (rev 206031)
+++ trunk/LayoutTests/ChangeLog	2016-09-16 18:04:54 UTC (rev 206032)
@@ -1,3 +1,12 @@
+2016-09-14  Jer Noble  <jer.no...@apple.com>
+
+        [media-source] fix imported/w3c/web-platform-tests/media-source/mediasource-duration.html
+        https://bugs.webkit.org/show_bug.cgi?id=161999
+
+        Reviewed by Eric Carlson.
+
+        * platform/mac/TestExpectations:
+
 2016-09-16  Jer Noble  <jer.no...@apple.com>
 
         [media-source] Fix imported/w3c/web-platform-tests/media-source/mediasource-timestamp-offset.html

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (206031 => 206032)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-09-16 17:46:51 UTC (rev 206031)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-09-16 18:04:54 UTC (rev 206032)
@@ -1,3 +1,14 @@
+2016-09-14  Jer Noble  <jer.no...@apple.com>
+
+        [media-source] fix imported/w3c/web-platform-tests/media-source/mediasource-duration.html
+        https://bugs.webkit.org/show_bug.cgi?id=161999
+
+        Reviewed by Eric Carlson.
+
+        Expected results had a stray newline.
+
+        * web-platform-tests/media-source/mediasource-duration-expected.txt:
+
 2016-09-16  Chris Dumez  <cdu...@apple.com>
 
         Cloning a textarea does not clone the textarea's value

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-duration-expected.txt (206031 => 206032)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-duration-expected.txt	2016-09-16 17:46:51 UTC (rev 206031)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/media-source/mediasource-duration-expected.txt	2016-09-16 18:04:54 UTC (rev 206032)
@@ -4,3 +4,4 @@
 PASS Test endOfStream completes previous seek to truncated duration 
 PASS Test setting same duration multiple times does not fire duplicate durationchange 
 PASS Test setting the duration to less than the highest starting presentation timestamp will throw 
+

Modified: trunk/LayoutTests/platform/mac/TestExpectations (206031 => 206032)


--- trunk/LayoutTests/platform/mac/TestExpectations	2016-09-16 17:46:51 UTC (rev 206031)
+++ trunk/LayoutTests/platform/mac/TestExpectations	2016-09-16 18:04:54 UTC (rev 206032)
@@ -1049,6 +1049,7 @@
 [ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-addsourcebuffer.html [ Pass ]
 [ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-closed.html [ Pass ]
 [ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-config-change-mp4-v-bitrate.html [ Pass ]
+[ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-duration.html [ Pass ]
 [ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-endofstream-invaliderror.html [ Pass ]
 [ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-multiple-attach.html [ Pass ]
 [ Yosemite+ ] imported/w3c/web-platform-tests/media-source/mediasource-play.html [ Pass ]

Modified: trunk/Source/WTF/ChangeLog (206031 => 206032)


--- trunk/Source/WTF/ChangeLog	2016-09-16 17:46:51 UTC (rev 206031)
+++ trunk/Source/WTF/ChangeLog	2016-09-16 18:04:54 UTC (rev 206032)
@@ -1,3 +1,23 @@
+2016-09-14  Jer Noble  <jer.no...@apple.com>
+
+        [media-source] fix imported/w3c/web-platform-tests/media-source/mediasource-duration.html
+        https://bugs.webkit.org/show_bug.cgi?id=161999
+
+        Reviewed by Eric Carlson.
+
+        The mediasource-duration.html test tries to set the duration of a MediaSource to a double value
+        (5.0), then some work happens and the duration is set to a media time (12533/2500, or 5.0132).
+        The test then tries to set that value as the duration, converted from a media time to a double,
+        and asserts that no duration change event is fired.  But because the floating point value and the
+        media time value are ever so slightly different, this round-tripping fails.
+
+        Fix this bug in MediaTime by, when one side or the other of a comparison is a floating point
+        MediaTime, convert both sides to doubles and run the comparison against those values. This preserves
+        the transitive equality of doubles <-> MediaTimes.
+
+        * wtf/MediaTime.cpp:
+        (WTF::MediaTime::compare):
+
 2016-09-16  Anders Carlsson  <ander...@apple.com>
 
         Fix isValidEnum to work with older versions of GCC

Modified: trunk/Source/WTF/wtf/MediaTime.cpp (206031 => 206032)


--- trunk/Source/WTF/wtf/MediaTime.cpp	2016-09-16 17:46:51 UTC (rev 206031)
+++ trunk/Source/WTF/wtf/MediaTime.cpp	2016-09-16 18:04:54 UTC (rev 206032)
@@ -407,15 +407,19 @@
         return m_timeValueAsDouble < rhs.m_timeValueAsDouble ? LessThan : GreaterThan;
     }
 
+    if (hasDoubleValue() || rhs.hasDoubleValue()) {
+        double a = toDouble();
+        double b = rhs.toDouble();
+        if (a > b)
+            return GreaterThan;
+        if (a < b)
+            return LessThan;
+        return EqualTo;
+    }
+
     MediaTime a = *this;
     MediaTime b = rhs;
 
-    if (a.hasDoubleValue())
-        a.setTimeScale(DefaultTimeScale);
-
-    if (b.hasDoubleValue())
-        b.setTimeScale(DefaultTimeScale);
-
     int64_t rhsWhole = b.m_timeValue / b.m_timeScale;
     int64_t lhsWhole = a.m_timeValue / a.m_timeScale;
     if (lhsWhole > rhsWhole)

Modified: trunk/Tools/ChangeLog (206031 => 206032)


--- trunk/Tools/ChangeLog	2016-09-16 17:46:51 UTC (rev 206031)
+++ trunk/Tools/ChangeLog	2016-09-16 18:04:54 UTC (rev 206032)
@@ -1,3 +1,13 @@
+2016-09-14  Jer Noble  <jer.no...@apple.com>
+
+        [media-source] fix imported/w3c/web-platform-tests/media-source/mediasource-duration.html
+        https://bugs.webkit.org/show_bug.cgi?id=161999
+
+        Reviewed by Eric Carlson.
+
+        * TestWebKitAPI/Tests/WTF/MediaTime.cpp:
+        (TestWebKitAPI::TEST):
+
 2016-09-16  Anders Carlsson  <ander...@apple.com>
 
         Fix isValidEnum to work with older versions of GCC

Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp (206031 => 206032)


--- trunk/Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp	2016-09-16 17:46:51 UTC (rev 206031)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/MediaTime.cpp	2016-09-16 18:04:54 UTC (rev 206032)
@@ -185,6 +185,7 @@
     // Floating Point Round Trip
     EXPECT_EQ(10.0123456789f, MediaTime::createWithFloat(10.0123456789f).toFloat());
     EXPECT_EQ(10.0123456789, MediaTime::createWithDouble(10.0123456789).toDouble());
+    EXPECT_EQ(MediaTime(1, 3), MediaTime::createWithDouble(MediaTime(1, 3).toDouble()));
 
     // Floating Point Math
     EXPECT_EQ(1.5 + 3.3, (MediaTime::createWithDouble(1.5) + MediaTime::createWithDouble(3.3)).toDouble());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to