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

Unified Diff: content/renderer/media/webmediaplayer_ms_unittest.cc

Issue 2348903003: Change WebMediaPlayerMS layers transparency dynamically (Closed)
Patch Set: mcasas@ comments. Created 4 years, 3 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 | « content/renderer/media/webmediaplayer_ms.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/webmediaplayer_ms_unittest.cc
diff --git a/content/renderer/media/webmediaplayer_ms_unittest.cc b/content/renderer/media/webmediaplayer_ms_unittest.cc
index 3920fb0b1b719797f04d15a750aab862549342f9..115683a47a058539bcbc93fedba8bbb20f5b5a07 100644
--- a/content/renderer/media/webmediaplayer_ms_unittest.cc
+++ b/content/renderer/media/webmediaplayer_ms_unittest.cc
@@ -12,6 +12,7 @@
#include "content/renderer/render_frame_impl.h"
#include "media/base/test_helpers.h"
#include "media/base/video_frame.h"
+#include "third_party/WebKit/public/platform/WebLayer.h"
#include "third_party/WebKit/public/platform/WebMediaPlayer.h"
#include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
#include "third_party/WebKit/public/platform/WebMediaPlayerSource.h"
@@ -454,6 +455,7 @@ class WebMediaPlayerMSTest
std::unique_ptr<WebMediaPlayerMS> player_;
WebMediaPlayerMSCompositor* compositor_;
ReusableMessageLoopEvent message_loop_controller_;
+ blink::WebLayer* web_layer_;
private:
// Main function trying to ask WebMediaPlayerMS to submit a frame for
@@ -507,6 +509,7 @@ void WebMediaPlayerMSTest::readyStateChanged() {
}
void WebMediaPlayerMSTest::setWebLayer(blink::WebLayer* layer) {
+ web_layer_ = layer;
if (layer)
compositor_->SetVideoFrameProviderClient(this);
DoSetWebLayer(!!layer);
@@ -749,6 +752,46 @@ TEST_F(WebMediaPlayerMSTest, RotatedVideoFrame) {
EXPECT_CALL(*this, DoStopRendering());
}
+// During this test, we check that web layer changes opacity according to the
+// given frames.
+TEST_F(WebMediaPlayerMSTest, OpacityChange) {
+ MockMediaStreamVideoRenderer* provider = LoadAndGetFrameProvider(true);
+
+ // Push one opaque frame.
+ const int kTestBrake = static_cast<int>(FrameType::TEST_BRAKE);
+ static int tokens[] = {0, kTestBrake};
+ std::vector<int> timestamps(tokens, tokens + arraysize(tokens));
+ provider->QueueFrames(timestamps, true);
+ EXPECT_CALL(*this, DoSetWebLayer(true));
+ EXPECT_CALL(*this, DoStartRendering());
+ EXPECT_CALL(*this, DoReadyStateChanged(
+ blink::WebMediaPlayer::ReadyStateHaveMetadata));
+ EXPECT_CALL(*this, DoReadyStateChanged(
+ blink::WebMediaPlayer::ReadyStateHaveEnoughData));
+ EXPECT_CALL(*this,
+ CheckSizeChanged(gfx::Size(kStandardWidth, kStandardHeight)));
+ message_loop_controller_.RunAndWaitForStatus(
+ media::PipelineStatus::PIPELINE_OK);
+ ASSERT_TRUE(web_layer_ != nullptr);
+ EXPECT_TRUE(web_layer_->opaque());
+
+ // Push one transparent frame.
+ provider->QueueFrames(timestamps, false);
+ message_loop_controller_.RunAndWaitForStatus(
+ media::PipelineStatus::PIPELINE_OK);
+ EXPECT_FALSE(web_layer_->opaque());
+
+ // Push another opaque frame.
+ provider->QueueFrames(timestamps, true);
+ message_loop_controller_.RunAndWaitForStatus(
+ media::PipelineStatus::PIPELINE_OK);
+ EXPECT_TRUE(web_layer_->opaque());
+
+ testing::Mock::VerifyAndClearExpectations(this);
+ EXPECT_CALL(*this, DoSetWebLayer(false));
+ EXPECT_CALL(*this, DoStopRendering());
+}
+
TEST_F(WebMediaPlayerMSTest, BackgroundRendering) {
// During this test, we will switch to background rendering mode, in which
// WebMediaPlayerMS::pause does not get called, but
« no previous file with comments | « content/renderer/media/webmediaplayer_ms.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698