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

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

Issue 2725893002: Media Controls timeline: immediately update current time display (Closed)
Patch Set: 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/html/shadow/MediaControls.h" 5 #include "core/html/shadow/MediaControls.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <memory> 8 #include <memory>
9 #include "core/HTMLNames.h" 9 #include "core/HTMLNames.h"
10 #include "core/css/StylePropertySet.h" 10 #include "core/css/StylePropertySet.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 175
176 void simulateLoadedMetadata() { m_mediaControls->onLoadedMetadata(); } 176 void simulateLoadedMetadata() { m_mediaControls->onLoadedMetadata(); }
177 177
178 MediaControls& mediaControls() { return *m_mediaControls; } 178 MediaControls& mediaControls() { return *m_mediaControls; }
179 MockVideoWebMediaPlayer* webMediaPlayer() { 179 MockVideoWebMediaPlayer* webMediaPlayer() {
180 return static_cast<MockVideoWebMediaPlayer*>( 180 return static_cast<MockVideoWebMediaPlayer*>(
181 mediaControls().mediaElement().webMediaPlayer()); 181 mediaControls().mediaElement().webMediaPlayer());
182 } 182 }
183 Document& document() { return m_pageHolder->document(); } 183 Document& document() { return m_pageHolder->document(); }
184 184
185 void loadMediaWithDuration(double duration) {
186 mediaControls().mediaElement().setSrc("https://example.com/foo.mp4");
187 testing::runPendingTasks();
188
189 WebTimeRange timeRange(0.0, duration);
190 webMediaPlayer()->m_seekable.assign(&timeRange, 1);
191 mediaControls().mediaElement().durationChanged(duration,
192 false /* requestSeek */);
193 simulateLoadedMetadata();
194 }
195
185 private: 196 private:
186 std::unique_ptr<DummyPageHolder> m_pageHolder; 197 std::unique_ptr<DummyPageHolder> m_pageHolder;
187 Persistent<MediaControls> m_mediaControls; 198 Persistent<MediaControls> m_mediaControls;
188 }; 199 };
189 200
190 TEST_F(MediaControlsTest, HideAndShow) { 201 TEST_F(MediaControlsTest, HideAndShow) {
191 mediaControls().mediaElement().setBooleanAttribute(HTMLNames::controlsAttr, 202 mediaControls().mediaElement().setBooleanAttribute(HTMLNames::controlsAttr,
192 true); 203 true);
193 204
194 Element* panel = getElementByShadowPseudoId(mediaControls(), 205 Element* panel = getElementByShadowPseudoId(mediaControls(),
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 } 414 }
404 415
405 TEST_F(MediaControlsTest, TimelineSeekToRoundedEnd) { 416 TEST_F(MediaControlsTest, TimelineSeekToRoundedEnd) {
406 ensureLayout(); 417 ensureLayout();
407 418
408 MediaControlTimelineElement* timeline = 419 MediaControlTimelineElement* timeline =
409 static_cast<MediaControlTimelineElement*>(getElementByShadowPseudoId( 420 static_cast<MediaControlTimelineElement*>(getElementByShadowPseudoId(
410 mediaControls(), "-webkit-media-controls-timeline")); 421 mediaControls(), "-webkit-media-controls-timeline"));
411 ASSERT_NE(nullptr, timeline); 422 ASSERT_NE(nullptr, timeline);
412 423
413 mediaControls().mediaElement().setSrc("https://example.com/foo.mp4");
414 testing::runPendingTasks();
415
416 // Tests the case where the real length of the video, |exactDuration|, gets 424 // Tests the case where the real length of the video, |exactDuration|, gets
417 // rounded up slightly to |roundedUpDuration| when setting the timeline's 425 // rounded up slightly to |roundedUpDuration| when setting the timeline's
418 // |max| attribute (crbug.com/695065). 426 // |max| attribute (crbug.com/695065).
419 double exactDuration = 596.586667; 427 double exactDuration = 596.586667;
420 double roundedUpDuration = 596.587; 428 double roundedUpDuration = 596.587;
421 429 loadMediaWithDuration(exactDuration);
422 WebTimeRange timeRange(0.0, exactDuration);
423 webMediaPlayer()->m_seekable.assign(&timeRange, 1);
424 mediaControls().mediaElement().durationChanged(exactDuration,
425 false /* requestSeek */);
426 simulateLoadedMetadata();
427 430
428 // Simulate a click slightly past the end of the track of the timeline's 431 // Simulate a click slightly past the end of the track of the timeline's
429 // underlying <input type="range">. This would set the |value| to the |max| 432 // underlying <input type="range">. This would set the |value| to the |max|
430 // attribute, which can be slightly rounded relative to the duration. 433 // attribute, which can be slightly rounded relative to the duration.
431 timeline->setValueAsNumber(roundedUpDuration, ASSERT_NO_EXCEPTION); 434 timeline->setValueAsNumber(roundedUpDuration, ASSERT_NO_EXCEPTION);
432 ASSERT_EQ(roundedUpDuration, timeline->valueAsNumber()); 435 ASSERT_EQ(roundedUpDuration, timeline->valueAsNumber());
433 EXPECT_EQ(0.0, mediaControls().mediaElement().currentTime()); 436 EXPECT_EQ(0.0, mediaControls().mediaElement().currentTime());
434 timeline->dispatchInputEvent(); 437 timeline->dispatchInputEvent();
435 EXPECT_EQ(exactDuration, mediaControls().mediaElement().currentTime()); 438 EXPECT_EQ(exactDuration, mediaControls().mediaElement().currentTime());
436 } 439 }
437 440
441 TEST_F(MediaControlsTest, TimelineImmediatelyUpdatesCurrentTime) {
442 ensureLayout();
443
444 MediaControlTimelineElement* timeline =
445 static_cast<MediaControlTimelineElement*>(getElementByShadowPseudoId(
446 mediaControls(), "-webkit-media-controls-timeline"));
447 ASSERT_NE(nullptr, timeline);
448 MediaControlCurrentTimeDisplayElement* currentTimeDisplay =
449 static_cast<MediaControlCurrentTimeDisplayElement*>(
450 getElementByShadowPseudoId(
451 mediaControls(), "-webkit-media-controls-current-time-display"));
452 ASSERT_NE(nullptr, currentTimeDisplay);
453
454 double duration = 600;
455 loadMediaWithDuration(duration);
456
457 // Simulate seeking the underlying range to 50%. Current time display should
458 // 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
459 timeline->setValueAsNumber(duration / 2, ASSERT_NO_EXCEPTION);
460 timeline->dispatchInputEvent();
461 EXPECT_EQ(duration / 2, currentTimeDisplay->currentValue());
462 }
463
438 } // namespace blink 464 } // namespace blink
OLDNEW
« 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