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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 2140783002: services/ui: Detect when a video is playing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tot merge Created 4 years, 5 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 | « cc/trees/layer_tree_host_impl.cc ('k') | content/renderer/pepper/pepper_plugin_instance_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index ead747a512476f16490273d5df084a2ff9129c57..862ef2f8b6106729a81e2d393f9b37b3fde3e074 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -6713,6 +6713,55 @@ TEST_F(LayerTreeHostImplTest, BlendingOffWhenDrawingOpaqueLayers) {
host_impl_->DidDrawAllLayers(frame);
}
+static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) {
+ host_impl->active_tree()->BuildPropertyTreesForTesting();
+ LayerTreeHostImpl::FrameData frame;
+ EXPECT_EQ(DRAW_SUCCESS, host_impl->PrepareToDraw(&frame));
+ host_impl->DrawLayers(&frame);
+ host_impl->SwapBuffers(frame);
+ host_impl->DidDrawAllLayers(frame);
+ return frame.may_contain_video;
+}
+
+TEST_F(LayerTreeHostImplTest, MayContainVideo) {
+ gfx::Size big_size(1000, 1000);
+ host_impl_->SetViewportSize(big_size);
+
+ int layer_id = 1;
+ host_impl_->active_tree()->SetRootLayerForTesting(
+ DidDrawCheckLayer::Create(host_impl_->active_tree(), layer_id++));
+ DidDrawCheckLayer* root =
+ static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin());
+
+ root->test_properties()->AddChild(
+ DidDrawCheckLayer::Create(host_impl_->active_tree(), layer_id++));
+ DidDrawCheckLayer* video_layer =
+ static_cast<DidDrawCheckLayer*>(root->test_properties()->children.back());
+ video_layer->set_may_contain_video(true);
+ EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get()));
+
+ // Test with the video layer occluded.
+ root->test_properties()->AddChild(
+ DidDrawCheckLayer::Create(host_impl_->active_tree(), layer_id++));
+ DidDrawCheckLayer* large_layer =
+ static_cast<DidDrawCheckLayer*>(root->test_properties()->children.back());
+ large_layer->SetBounds(big_size);
+ large_layer->SetContentsOpaque(true);
+ EXPECT_FALSE(MayContainVideoBitSetOnFrameData(host_impl_.get()));
+
+ // Remove the large layer.
+ root->test_properties()->RemoveChild(large_layer);
+ EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get()));
+
+ // Move the video layer so it goes beyond the root.
+ video_layer->SetPosition(gfx::PointF(100.f, 100.f));
+ EXPECT_FALSE(MayContainVideoBitSetOnFrameData(host_impl_.get()));
+
+ video_layer->SetPosition(gfx::PointF(0.f, 0.f));
+ video_layer->NoteLayerPropertyChanged();
+ EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get()));
+}
+
class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
protected:
LayerTreeHostImplViewportCoveredTest() :
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | content/renderer/pepper/pepper_plugin_instance_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698