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

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

Issue 2710713003: Media Controls: Remove download button for infinite streams (Closed)
Patch Set: 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 685b14cd1c28754d9f67aa512892e13a2b30ff86..111dfe1453b1ab208ff3fa8fe38b98ce239631e2 100644
--- a/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp
+++ b/third_party/WebKit/Source/core/html/shadow/MediaControlsTest.cpp
@@ -4,6 +4,8 @@
#include "core/html/shadow/MediaControls.h"
+#include <limits>
+#include <memory>
#include "core/HTMLNames.h"
#include "core/css/StylePropertySet.h"
#include "core/dom/Document.h"
@@ -20,7 +22,6 @@
#include "public/platform/modules/remoteplayback/WebRemotePlaybackAvailability.h"
#include "public/platform/modules/remoteplayback/WebRemotePlaybackClient.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include <memory>
namespace blink {
@@ -28,6 +29,7 @@ namespace {
class MockVideoWebMediaPlayer : public WebMediaPlayer {
public:
+ // WebMediaPlayer overrides:
void load(LoadType, const WebMediaPlayerSource&, CORSMode) override{};
void play() override{};
void pause() override{};
@@ -168,6 +170,8 @@ class MediaControlsTest : public ::testing::Test {
m_mediaControls->hideMediaControlsTimerFired(nullptr);
}
+ void simulateLoadedMetadata() { m_mediaControls->onLoadedMetadata(); }
+
MediaControls& mediaControls() { return *m_mediaControls; }
Document& document() { return m_pageHolder->document(); }
@@ -315,4 +319,64 @@ TEST_F(MediaControlsTest, KeepControlsVisibleIfOverflowListVisible) {
EXPECT_TRUE(isElementVisible(*panel));
}
+TEST_F(MediaControlsTest, DownloadButtonDisplayed) {
+ ensureLayout();
+
+ Element* downloadButton = getElementByShadowPseudoId(
+ mediaControls(), "-internal-media-controls-download-button");
+ ASSERT_NE(nullptr, downloadButton);
+
+ mediaControls().mediaElement().setSrc("https://example.com/foo.mp4");
+ testing::runPendingTasks();
+ simulateLoadedMetadata();
+
+ // Download button should normally be displayed.
+ EXPECT_TRUE(isElementVisible(*downloadButton));
+}
+
+TEST_F(MediaControlsTest, DownloadButtonNotDisplayedEmptyUrl) {
+ ensureLayout();
+
+ Element* downloadButton = getElementByShadowPseudoId(
+ mediaControls(), "-internal-media-controls-download-button");
+ ASSERT_NE(nullptr, downloadButton);
+
+ // Download button should not be displayed when URL is empty.
+ mediaControls().mediaElement().setSrc("");
+ testing::runPendingTasks();
+ simulateLoadedMetadata();
+ EXPECT_FALSE(isElementVisible(*downloadButton));
+}
+
+TEST_F(MediaControlsTest, DownloadButtonNotDisplayedInfiniteDuration) {
+ ensureLayout();
+
+ Element* downloadButton = getElementByShadowPseudoId(
+ mediaControls(), "-internal-media-controls-download-button");
+ ASSERT_NE(nullptr, downloadButton);
+
+ mediaControls().mediaElement().setSrc("https://example.com/foo.mp4");
+ testing::runPendingTasks();
+
+ // Download button should not be displayed when duration is infinite.
+ mediaControls().mediaElement().durationChanged(
+ std::numeric_limits<double>::infinity(), false /* requestSeek */);
+ simulateLoadedMetadata();
+ EXPECT_FALSE(isElementVisible(*downloadButton));
+}
+
+TEST_F(MediaControlsTest, DownloadButtonNotDisplayedHLS) {
+ ensureLayout();
+
+ Element* downloadButton = getElementByShadowPseudoId(
+ mediaControls(), "-internal-media-controls-download-button");
+ ASSERT_NE(nullptr, downloadButton);
+
+ // Download button should not be displayed for HLS streams.
+ mediaControls().mediaElement().setSrc("https://example.com/foo.m3u8");
+ testing::runPendingTasks();
+ simulateLoadedMetadata();
+ EXPECT_FALSE(isElementVisible(*downloadButton));
+}
+
} // 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