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

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: . 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
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 bb58db57bc7d85b54b9c5a300ffb295d726458a0..e26e15740401a3b0a886ffcd62913bf4f1088f2b 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -6714,6 +6714,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() :

Powered by Google App Engine
This is Rietveld 408576698