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

Unified Diff: third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp

Issue 2487373003: Disable background video track behind a feature flag (Closed)
Patch Set: Added the feature flag to histograms.xml Created 4 years, 1 month 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
Index: third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp
diff --git a/third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp b/third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp
index 8d91cf19126c90b69f863225fa993ae83eafbdeb..da60de3ae04685fc2891e98f1f186bbde9a7919e 100644
--- a/third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp
+++ b/third_party/WebKit/Source/core/html/HTMLVideoElementTest.cpp
@@ -9,6 +9,7 @@
#include "core/loader/EmptyClients.h"
#include "core/page/NetworkStateNotifier.h"
#include "core/testing/DummyPageHolder.h"
+#include "platform/RuntimeEnabledFeatures.h"
#include "platform/UserGestureIndicator.h"
#include "platform/testing/UnitTestHelpers.h"
#include "public/platform/WebMediaPlayer.h"
@@ -62,6 +63,10 @@ class EmptyWebMediaPlayer : public WebMediaPlayer {
class MockWebMediaPlayer : public EmptyWebMediaPlayer {
public:
MOCK_METHOD1(setBufferingStrategy, void(BufferingStrategy));
+ MOCK_METHOD1(selectedVideoTrackChanged,
+ void(blink::WebMediaPlayer::TrackId*));
+ MOCK_CONST_METHOD0(hasAudio, bool());
+ MOCK_CONST_METHOD0(hasVideo, bool());
};
class StubFrameLoaderClient : public EmptyFrameLoaderClient {
@@ -95,6 +100,14 @@ class HTMLVideoElementTest : public ::testing::Test {
testing::runPendingTasks();
}
+ void setReadyState(HTMLMediaElement::ReadyState state) {
+ m_video->setReadyState(state);
+ }
+
+ void hide() { m_video->hidden(); }
+
+ void show() { m_video->shown(); }
+
MockWebMediaPlayer* webMediaPlayer() {
return static_cast<MockWebMediaPlayer*>(m_video->webMediaPlayer());
}
@@ -153,4 +166,25 @@ TEST_F(HTMLVideoElementTest, setBufferingStrategy_UserPause) {
::testing::Mock::VerifyAndClearExpectations(player);
}
+TEST_F(HTMLVideoElementTest, unselectSelectVideoTrackWhenHiddenAndShown) {
+ RuntimeEnabledFeatures::setBackgroundVideoTrackOptimizationEnabled(true);
+
+ setSrc("http://foo.bar/");
+ MockWebMediaPlayer* player = webMediaPlayer();
+ ASSERT_TRUE(player);
+
+ EXPECT_CALL(*player, hasAudio()).WillRepeatedly(::testing::Return(true));
+ EXPECT_CALL(*player, hasVideo()).WillRepeatedly(::testing::Return(true));
+
+ setReadyState(HTMLMediaElement::kHaveMetadata);
+
+ EXPECT_CALL(*player, selectedVideoTrackChanged(nullptr));
+ hide();
+ ::testing::Mock::VerifyAndClearExpectations(player);
+
+ EXPECT_CALL(*player, selectedVideoTrackChanged(::testing::_));
+ show();
+ ::testing::Mock::VerifyAndClearExpectations(player);
+}
mlamouri (slow - plz ping) 2016/11/12 23:35:48 tests <3
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698