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

Unified Diff: third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp

Issue 2725893002: Media Controls timeline: immediately update current time display (Closed)
Patch Set: Mark media/controls-drag-timebar-rendering.html failing, see crbug.com/699096 Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 19caa77d06e23f5d97f51275f8c21f9d241465f0..be8bd727ef4b5bfa5962c880dce21d967ca339db 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp
@@ -192,6 +192,16 @@ class MediaControlsTest : public ::testing::Test {
HistogramTester& histogramTester() { return m_histogramTester; }
+ 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;
@@ -481,20 +491,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|
@@ -506,4 +508,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 (rather than waiting for media to finish seeking).
+ timeline->setValueAsNumber(duration / 2, ASSERT_NO_EXCEPTION);
+ timeline->dispatchInputEvent();
+ EXPECT_EQ(duration / 2, currentTimeDisplay->currentValue());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/html/shadow/MediaControlElements.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698