Chromium Code Reviews| Index: third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp |
| diff --git a/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp b/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp |
| index 4382731a04b497a200cbc9f1f4505674a7107c99..7d66030f0ab6a734e293c66d95bc50f11daae792 100644 |
| --- a/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp |
| +++ b/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp |
| @@ -182,6 +182,17 @@ class MediaControlsTest : public ::testing::Test { |
| } |
| Document& document() { return m_pageHolder->document(); } |
| + void loadMediaWithDuration(double duration) { |
| + mediaControls().mediaElement().setSrc("https://example.com/foo.mp4"); |
| + testing::runPendingTasks(); |
| + |
| + WebTimeRange timeRange(0.0, duration); |
| + webMediaPlayer()->m_seekable.assign(&timeRange, 1); |
| + mediaControls().mediaElement().durationChanged(duration, |
| + false /* requestSeek */); |
| + simulateLoadedMetadata(); |
| + } |
| + |
| private: |
| std::unique_ptr<DummyPageHolder> m_pageHolder; |
| Persistent<MediaControls> m_mediaControls; |
| @@ -410,20 +421,12 @@ TEST_F(MediaControlsTest, TimelineSeekToRoundedEnd) { |
| mediaControls(), "-webkit-media-controls-timeline")); |
| ASSERT_NE(nullptr, timeline); |
| - mediaControls().mediaElement().setSrc("https://example.com/foo.mp4"); |
| - testing::runPendingTasks(); |
| - |
| // Tests the case where the real length of the video, |exactDuration|, gets |
| // rounded up slightly to |roundedUpDuration| when setting the timeline's |
| // |max| attribute (crbug.com/695065). |
| double exactDuration = 596.586667; |
| double roundedUpDuration = 596.587; |
| - |
| - WebTimeRange timeRange(0.0, exactDuration); |
| - webMediaPlayer()->m_seekable.assign(&timeRange, 1); |
| - mediaControls().mediaElement().durationChanged(exactDuration, |
| - false /* requestSeek */); |
| - simulateLoadedMetadata(); |
| + loadMediaWithDuration(exactDuration); |
| // Simulate a click slightly past the end of the track of the timeline's |
| // underlying <input type="range">. This would set the |value| to the |max| |
| @@ -435,4 +438,27 @@ TEST_F(MediaControlsTest, TimelineSeekToRoundedEnd) { |
| EXPECT_EQ(exactDuration, mediaControls().mediaElement().currentTime()); |
| } |
| +TEST_F(MediaControlsTest, TimelineImmediatelyUpdatesCurrentTime) { |
| + ensureLayout(); |
| + |
| + MediaControlTimelineElement* timeline = |
| + static_cast<MediaControlTimelineElement*>(getElementByShadowPseudoId( |
| + mediaControls(), "-webkit-media-controls-timeline")); |
| + ASSERT_NE(nullptr, timeline); |
| + MediaControlCurrentTimeDisplayElement* currentTimeDisplay = |
| + static_cast<MediaControlCurrentTimeDisplayElement*>( |
| + getElementByShadowPseudoId( |
| + mediaControls(), "-webkit-media-controls-current-time-display")); |
| + ASSERT_NE(nullptr, currentTimeDisplay); |
| + |
| + double duration = 600; |
| + loadMediaWithDuration(duration); |
| + |
| + // Simulate seeking the underlying range to 50%. Current time display should |
| + // update synchronously (crbug.com/695459). |
|
mlamouri (slow - plz ping)
2017/03/02 10:37:19
No need to link to the bug, if someone needs to ha
johnme
2017/03/02 13:31:30
Done (though the bug provides useful clarification
|
| + timeline->setValueAsNumber(duration / 2, ASSERT_NO_EXCEPTION); |
| + timeline->dispatchInputEvent(); |
| + EXPECT_EQ(duration / 2, currentTimeDisplay->currentValue()); |
| +} |
| + |
| } // namespace blink |