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

Side by Side 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, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 6695 matching lines...) Expand 10 before | Expand all | Expand 10 after
6706 layer1->SetExpectation(false, false); 6706 layer1->SetExpectation(false, false);
6707 layer1->SetUpdateRect(gfx::Rect(layer1->bounds())); 6707 layer1->SetUpdateRect(gfx::Rect(layer1->bounds()));
6708 host_impl_->active_tree()->BuildPropertyTreesForTesting(); 6708 host_impl_->active_tree()->BuildPropertyTreesForTesting();
6709 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame)); 6709 EXPECT_EQ(DRAW_SUCCESS, host_impl_->PrepareToDraw(&frame));
6710 host_impl_->DrawLayers(&frame); 6710 host_impl_->DrawLayers(&frame);
6711 host_impl_->SwapBuffers(frame); 6711 host_impl_->SwapBuffers(frame);
6712 EXPECT_TRUE(layer1->quads_appended()); 6712 EXPECT_TRUE(layer1->quads_appended());
6713 host_impl_->DidDrawAllLayers(frame); 6713 host_impl_->DidDrawAllLayers(frame);
6714 } 6714 }
6715 6715
6716 static bool MayContainVideoBitSetOnFrameData(LayerTreeHostImpl* host_impl) {
6717 host_impl->active_tree()->BuildPropertyTreesForTesting();
6718 LayerTreeHostImpl::FrameData frame;
6719 EXPECT_EQ(DRAW_SUCCESS, host_impl->PrepareToDraw(&frame));
6720 host_impl->DrawLayers(&frame);
6721 host_impl->SwapBuffers(frame);
6722 host_impl->DidDrawAllLayers(frame);
6723 return frame.may_contain_video;
6724 }
6725
6726 TEST_F(LayerTreeHostImplTest, MayContainVideo) {
6727 gfx::Size big_size(1000, 1000);
6728 host_impl_->SetViewportSize(big_size);
6729
6730 int layer_id = 1;
6731 host_impl_->active_tree()->SetRootLayerForTesting(
6732 DidDrawCheckLayer::Create(host_impl_->active_tree(), layer_id++));
6733 DidDrawCheckLayer* root =
6734 static_cast<DidDrawCheckLayer*>(*host_impl_->active_tree()->begin());
6735
6736 root->test_properties()->AddChild(
6737 DidDrawCheckLayer::Create(host_impl_->active_tree(), layer_id++));
6738 DidDrawCheckLayer* video_layer =
6739 static_cast<DidDrawCheckLayer*>(root->test_properties()->children.back());
6740 video_layer->set_may_contain_video(true);
6741 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get()));
6742
6743 // Test with the video layer occluded.
6744 root->test_properties()->AddChild(
6745 DidDrawCheckLayer::Create(host_impl_->active_tree(), layer_id++));
6746 DidDrawCheckLayer* large_layer =
6747 static_cast<DidDrawCheckLayer*>(root->test_properties()->children.back());
6748 large_layer->SetBounds(big_size);
6749 large_layer->SetContentsOpaque(true);
6750 EXPECT_FALSE(MayContainVideoBitSetOnFrameData(host_impl_.get()));
6751
6752 // Remove the large layer.
6753 root->test_properties()->RemoveChild(large_layer);
6754 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get()));
6755
6756 // Move the video layer so it goes beyond the root.
6757 video_layer->SetPosition(gfx::PointF(100.f, 100.f));
6758 EXPECT_FALSE(MayContainVideoBitSetOnFrameData(host_impl_.get()));
6759
6760 video_layer->SetPosition(gfx::PointF(0.f, 0.f));
6761 video_layer->NoteLayerPropertyChanged();
6762 EXPECT_TRUE(MayContainVideoBitSetOnFrameData(host_impl_.get()));
6763 }
6764
6716 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest { 6765 class LayerTreeHostImplViewportCoveredTest : public LayerTreeHostImplTest {
6717 protected: 6766 protected:
6718 LayerTreeHostImplViewportCoveredTest() : 6767 LayerTreeHostImplViewportCoveredTest() :
6719 gutter_quad_material_(DrawQuad::SOLID_COLOR), 6768 gutter_quad_material_(DrawQuad::SOLID_COLOR),
6720 child_(NULL), 6769 child_(NULL),
6721 did_activate_pending_tree_(false) {} 6770 did_activate_pending_tree_(false) {}
6722 6771
6723 std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) { 6772 std::unique_ptr<OutputSurface> CreateFakeOutputSurface(bool software) {
6724 if (software) 6773 if (software)
6725 return FakeOutputSurface::CreateDelegatingSoftware(); 6774 return FakeOutputSurface::CreateDelegatingSoftware();
(...skipping 4072 matching lines...) Expand 10 before | Expand all | Expand 10 after
10798 EXPECT_TRUE(host_impl_->use_gpu_rasterization()); 10847 EXPECT_TRUE(host_impl_->use_gpu_rasterization());
10799 10848
10800 // Re-initialize with a software output surface. 10849 // Re-initialize with a software output surface.
10801 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware(); 10850 output_surface_ = FakeOutputSurface::CreateDelegatingSoftware();
10802 host_impl_->InitializeRenderer(output_surface_.get()); 10851 host_impl_->InitializeRenderer(output_surface_.get());
10803 EXPECT_FALSE(host_impl_->use_gpu_rasterization()); 10852 EXPECT_FALSE(host_impl_->use_gpu_rasterization());
10804 } 10853 }
10805 10854
10806 } // namespace 10855 } // namespace
10807 } // namespace cc 10856 } // namespace cc
OLDNEW
« 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