diff options
Diffstat (limited to 'cc/layers/scrollbar_layer_unittest.cc')
-rw-r--r-- | cc/layers/scrollbar_layer_unittest.cc | 123 |
1 files changed, 64 insertions, 59 deletions
diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc index 97d1c80..74882a1 100644 --- a/cc/layers/scrollbar_layer_unittest.cc +++ b/cc/layers/scrollbar_layer_unittest.cc @@ -35,24 +35,24 @@ namespace cc { namespace { -LayerImpl* LayerImplForScrollAreaAndScrollbar(FakeLayerTreeHost* host, +LayerImpl* LayerImplForScrollAreaAndScrollbar(const LayerSettings& settings, + FakeLayerTreeHost* host, scoped_ptr<Scrollbar> scrollbar, bool reverse_order, bool use_solid_color_scrollbar, int thumb_thickness, int track_start) { - scoped_refptr<Layer> layer_tree_root = Layer::Create(); - scoped_refptr<Layer> child1 = Layer::Create(); + scoped_refptr<Layer> layer_tree_root = Layer::Create(settings); + scoped_refptr<Layer> child1 = Layer::Create(settings); scoped_refptr<Layer> child2; if (use_solid_color_scrollbar) { const bool kIsLeftSideVerticalScrollbar = false; - child2 = SolidColorScrollbarLayer::Create(scrollbar->Orientation(), - thumb_thickness, - track_start, - kIsLeftSideVerticalScrollbar, - child1->id()); + child2 = SolidColorScrollbarLayer::Create( + settings, scrollbar->Orientation(), thumb_thickness, track_start, + kIsLeftSideVerticalScrollbar, child1->id()); } else { - child2 = PaintedScrollbarLayer::Create(scrollbar.Pass(), child1->id()); + child2 = + PaintedScrollbarLayer::Create(settings, scrollbar.Pass(), child1->id()); } child2->ToScrollbarLayer()->SetClipLayer(layer_tree_root->id()); layer_tree_root->AddChild(child1); @@ -134,16 +134,20 @@ class ScrollbarLayerTest : public testing::Test { EXPECT_FALSE(layer_tree_host_->output_surface_lost()); } + const LayerSettings& layer_settings() { return layer_settings_; } + protected: FakeLayerTreeHostClient fake_client_; LayerTreeSettings layer_tree_settings_; + LayerSettings layer_settings_; scoped_ptr<FakeResourceTrackingLayerTreeHost> layer_tree_host_; }; TEST_F(ScrollbarLayerTest, ResolveScrollLayerPointer) { scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( - layer_tree_host_.get(), scrollbar.Pass(), false, false, 0, 0); + layer_settings(), layer_tree_host_.get(), scrollbar.Pass(), false, false, + 0, 0); LayerImpl* cc_child1 = layer_impl_tree_root->children()[0]; PaintedScrollbarLayerImpl* cc_child2 = @@ -157,7 +161,8 @@ TEST_F(ScrollbarLayerTest, ResolveScrollLayerPointer) { TEST_F(ScrollbarLayerTest, ResolveScrollLayerPointer_ReverseOrder) { scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( - layer_tree_host_.get(), scrollbar.Pass(), true, false, 0, 0); + layer_settings(), layer_tree_host_.get(), scrollbar.Pass(), true, false, + 0, 0); PaintedScrollbarLayerImpl* cc_child1 = static_cast<PaintedScrollbarLayerImpl*>( @@ -172,7 +177,8 @@ TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { // Create and attach a non-overlay scrollbar. scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( - layer_tree_host_.get(), scrollbar.Pass(), false, false, 0, 0); + layer_settings(), layer_tree_host_.get(), scrollbar.Pass(), false, false, + 0, 0); PaintedScrollbarLayerImpl* scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( layer_impl_tree_root->children()[1]); @@ -189,7 +195,8 @@ TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { scrollbar.reset(new FakeScrollbar(false, false, true)); layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( - layer_tree_host_.get(), scrollbar.Pass(), false, false, 0, 0); + layer_settings(), layer_tree_host_.get(), scrollbar.Pass(), false, false, + 0, 0); scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( layer_impl_tree_root->children()[1]); @@ -203,11 +210,11 @@ TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); - scoped_refptr<Layer> layer_tree_root = Layer::Create(); - scoped_refptr<Layer> scroll_layer = Layer::Create(); - scoped_refptr<Layer> content_layer = Layer::Create(); - scoped_refptr<Layer> scrollbar_layer = - PaintedScrollbarLayer::Create(scrollbar.Pass(), layer_tree_root->id()); + scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings()); + scoped_refptr<Layer> scroll_layer = Layer::Create(layer_settings()); + scoped_refptr<Layer> content_layer = Layer::Create(layer_settings()); + scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( + layer_settings(), scrollbar.Pass(), layer_tree_root->id()); // Choose bounds to give max_scroll_offset = (30, 50). layer_tree_root->SetBounds(gfx::Size(70, 150)); @@ -272,11 +279,12 @@ TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { } while (false) TEST_F(ScrollbarLayerTest, UpdatePropertiesOfScrollBarWhenThumbRemoved) { - scoped_refptr<Layer> root_clip_layer = Layer::Create(); - scoped_refptr<Layer> root_layer = Layer::Create(); - scoped_refptr<Layer> content_layer = Layer::Create(); + scoped_refptr<Layer> root_clip_layer = Layer::Create(layer_settings()); + scoped_refptr<Layer> root_layer = Layer::Create(layer_settings()); + scoped_refptr<Layer> content_layer = Layer::Create(layer_settings()); scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = - FakePaintedScrollbarLayer::Create(false, true, root_layer->id()); + FakePaintedScrollbarLayer::Create(layer_settings(), false, true, + root_layer->id()); root_layer->SetScrollClipLayerId(root_clip_layer->id()); // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). @@ -313,11 +321,12 @@ TEST_F(ScrollbarLayerTest, UpdatePropertiesOfScrollBarWhenThumbRemoved) { } TEST_F(ScrollbarLayerTest, ThumbRect) { - scoped_refptr<Layer> root_clip_layer = Layer::Create(); - scoped_refptr<Layer> root_layer = Layer::Create(); - scoped_refptr<Layer> content_layer = Layer::Create(); + scoped_refptr<Layer> root_clip_layer = Layer::Create(layer_settings()); + scoped_refptr<Layer> root_layer = Layer::Create(layer_settings()); + scoped_refptr<Layer> content_layer = Layer::Create(layer_settings()); scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = - FakePaintedScrollbarLayer::Create(false, true, root_layer->id()); + FakePaintedScrollbarLayer::Create(layer_settings(), false, true, + root_layer->id()); root_layer->SetScrollClipLayerId(root_clip_layer->id()); // Give the root-clip a size that will result in MaxScrollOffset = (80, 0). @@ -397,8 +406,8 @@ TEST_F(ScrollbarLayerTest, SolidColorDrawQuads) { scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( - layer_tree_host_.get(), scrollbar.Pass(), false, true, kThumbThickness, - kTrackStart); + layer_settings(), layer_tree_host_.get(), scrollbar.Pass(), false, true, + kThumbThickness, kTrackStart); ScrollbarLayerImplBase* scrollbar_layer_impl = static_cast<SolidColorScrollbarLayerImpl*>( layer_impl_tree_root->children()[1]); @@ -472,17 +481,15 @@ TEST_F(ScrollbarLayerTest, LayerDrivenSolidColorDrawQuads) { scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); { - scoped_refptr<Layer> layer_tree_root = Layer::Create(); - scoped_refptr<Layer> scroll_layer = Layer::Create(); + scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings()); + scoped_refptr<Layer> scroll_layer = Layer::Create(layer_settings()); scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); - scoped_refptr<Layer> child1 = Layer::Create(); + scoped_refptr<Layer> child1 = Layer::Create(layer_settings()); scoped_refptr<Layer> child2; const bool kIsLeftSideVerticalScrollbar = false; - child2 = SolidColorScrollbarLayer::Create(scrollbar->Orientation(), - kThumbThickness, - kTrackStart, - kIsLeftSideVerticalScrollbar, - child1->id()); + child2 = SolidColorScrollbarLayer::Create( + layer_settings(), scrollbar->Orientation(), kThumbThickness, + kTrackStart, kIsLeftSideVerticalScrollbar, child1->id()); child2->ToScrollbarLayer()->SetScrollLayer(scroll_layer->id()); child2->ToScrollbarLayer()->SetClipLayer(layer_tree_root->id()); scroll_layer->AddChild(child1); @@ -631,12 +638,12 @@ class ScrollbarLayerTestMaxTextureSize : public LayerTreeTest { void SetScrollbarBounds(const gfx::Size& bounds) { bounds_ = bounds; } void BeginTest() override { - scroll_layer_ = Layer::Create(); + scroll_layer_ = Layer::Create(layer_settings()); layer_tree_host()->root_layer()->AddChild(scroll_layer_); scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); - scrollbar_layer_ = - PaintedScrollbarLayer::Create(scrollbar.Pass(), scroll_layer_->id()); + scrollbar_layer_ = PaintedScrollbarLayer::Create( + layer_settings(), scrollbar.Pass(), scroll_layer_->id()); scrollbar_layer_->SetScrollLayer(scroll_layer_->id()); scrollbar_layer_->SetLayerTreeHost(layer_tree_host()); scrollbar_layer_->SetBounds(bounds_); @@ -695,22 +702,19 @@ class ScrollbarLayerTestResourceCreationAndRelease : public ScrollbarLayerTest { int expected_deleted, bool use_solid_color_scrollbar) { scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, false)); - scoped_refptr<Layer> layer_tree_root = Layer::Create(); - scoped_refptr<Layer> content_layer = Layer::Create(); + scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings()); + scoped_refptr<Layer> content_layer = Layer::Create(layer_settings()); scoped_refptr<Layer> scrollbar_layer; if (use_solid_color_scrollbar) { const int kThumbThickness = 3; const int kTrackStart = 0; const bool kIsLeftSideVerticalScrollbar = false; - scrollbar_layer = - SolidColorScrollbarLayer::Create(scrollbar->Orientation(), - kThumbThickness, - kTrackStart, - kIsLeftSideVerticalScrollbar, - layer_tree_root->id()); + scrollbar_layer = SolidColorScrollbarLayer::Create( + layer_settings(), scrollbar->Orientation(), kThumbThickness, + kTrackStart, kIsLeftSideVerticalScrollbar, layer_tree_root->id()); } else { - scrollbar_layer = PaintedScrollbarLayer::Create(scrollbar.Pass(), - layer_tree_root->id()); + scrollbar_layer = PaintedScrollbarLayer::Create( + layer_settings(), scrollbar.Pass(), layer_tree_root->id()); } layer_tree_root->AddChild(content_layer); layer_tree_root->AddChild(scrollbar_layer); @@ -773,10 +777,11 @@ TEST_F(ScrollbarLayerTestResourceCreationAndRelease, TEST_F(ScrollbarLayerTestResourceCreationAndRelease, TestResourceUpdate) { gfx::Point scrollbar_location(0, 185); - scoped_refptr<Layer> layer_tree_root = Layer::Create(); - scoped_refptr<Layer> content_layer = Layer::Create(); + scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings()); + scoped_refptr<Layer> content_layer = Layer::Create(layer_settings()); scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = - FakePaintedScrollbarLayer::Create(false, true, layer_tree_root->id()); + FakePaintedScrollbarLayer::Create(layer_settings(), false, true, + layer_tree_root->id()); layer_tree_root->AddChild(content_layer); layer_tree_root->AddChild(scrollbar_layer); @@ -910,10 +915,11 @@ class ScaledScrollbarLayerTestResourceCreation : public ScrollbarLayerTest { public: void TestResourceUpload(const float test_scale) { gfx::Point scrollbar_location(0, 185); - scoped_refptr<Layer> layer_tree_root = Layer::Create(); - scoped_refptr<Layer> content_layer = Layer::Create(); + scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings()); + scoped_refptr<Layer> content_layer = Layer::Create(layer_settings()); scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = - FakePaintedScrollbarLayer::Create(false, true, layer_tree_root->id()); + FakePaintedScrollbarLayer::Create(layer_settings(), false, true, + layer_tree_root->id()); layer_tree_root->AddChild(content_layer); layer_tree_root->AddChild(scrollbar_layer); @@ -986,11 +992,10 @@ class ScaledScrollbarLayerTestScaledRasterization : public ScrollbarLayerTest { void TestScale(const gfx::Rect scrollbar_rect, const float test_scale) { bool paint_during_update = true; bool has_thumb = false; - scoped_refptr<Layer> layer_tree_root = Layer::Create(); + scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings()); scoped_refptr<FakePaintedScrollbarLayer> scrollbar_layer = - FakePaintedScrollbarLayer::Create(paint_during_update, - has_thumb, - layer_tree_root->id()); + FakePaintedScrollbarLayer::Create(layer_settings(), paint_during_update, + has_thumb, layer_tree_root->id()); layer_tree_root->AddChild(scrollbar_layer); |