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

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

Issue 2707043004: Media Controls: Fix seek to end when max attr is rounded up (Closed)
Patch Set: Simplify time>duration check Created 3 years, 10 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 d6fc73e2cba1e9938c256dea9c22cc35d57d7312..0ee9f232228ec34c06baf49d810ace3d715f7f3f 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp
@@ -13,6 +13,7 @@
#include "core/dom/StyleEngine.h"
#include "core/frame/Settings.h"
#include "core/html/HTMLVideoElement.h"
+#include "core/html/shadow/MediaControlElementTypes.h"
#include "core/loader/EmptyClients.h"
#include "core/testing/DummyPageHolder.h"
#include "platform/heap/Handle.h"
@@ -38,7 +39,7 @@ class MockVideoWebMediaPlayer : public WebMediaPlayer {
void setRate(double) override{};
void setVolume(double) override{};
WebTimeRanges buffered() const override { return WebTimeRanges(); };
- WebTimeRanges seekable() const override { return WebTimeRanges(); };
+ WebTimeRanges seekable() const override { return m_seekable; };
void setSinkId(const WebString& sinkId,
const WebSecurityOrigin&,
WebSetSinkIdCallbacks*) override{};
@@ -63,6 +64,8 @@ class MockVideoWebMediaPlayer : public WebMediaPlayer {
size_t audioDecodedByteCount() const override { return 0; };
size_t videoDecodedByteCount() const override { return 0; };
void paint(WebCanvas*, const WebRect&, PaintFlags&) override{};
+
+ WebTimeRanges m_seekable;
};
class MockWebRemotePlaybackClient : public WebRemotePlaybackClient {
@@ -173,6 +176,10 @@ class MediaControlsTest : public ::testing::Test {
void simulateLoadedMetadata() { m_mediaControls->onLoadedMetadata(); }
MediaControls& mediaControls() { return *m_mediaControls; }
+ MockVideoWebMediaPlayer* webMediaPlayer() {
+ return static_cast<MockVideoWebMediaPlayer*>(
+ mediaControls().mediaElement().webMediaPlayer());
+ }
Document& document() { return m_pageHolder->document(); }
private:
@@ -395,4 +402,37 @@ TEST_F(MediaControlsTest, DownloadButtonNotDisplayedHLS) {
EXPECT_FALSE(isElementVisible(*downloadButton));
}
+TEST_F(MediaControlsTest, TimelineSeekToRoundedEnd) {
+ ensureLayout();
+
+ MediaControlTimelineElement* timeline =
+ static_cast<MediaControlTimelineElement*>(getElementByShadowPseudoId(
+ 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();
+
+ // 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|
+ // attribute, which can be slightly rounded relative to the duration.
+ timeline->setValueAsNumber(roundedUpDuration, ASSERT_NO_EXCEPTION);
+ ASSERT_EQ(roundedUpDuration, timeline->valueAsNumber());
+ EXPECT_EQ(0.0, mediaControls().mediaElement().currentTime());
+ timeline->dispatchInputEvent();
+ EXPECT_EQ(exactDuration, mediaControls().mediaElement().currentTime());
+}
+
} // 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