OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/layers/painted_scrollbar_layer.h" | 5 #include "cc/layers/painted_scrollbar_layer.h" |
6 | 6 |
7 #include "cc/layers/layer_settings.h" | |
8 #include "cc/test/fake_layer_tree_host.h" | 7 #include "cc/test/fake_layer_tree_host.h" |
9 #include "cc/test/fake_layer_tree_host_client.h" | 8 #include "cc/test/fake_layer_tree_host_client.h" |
10 #include "cc/test/fake_scrollbar.h" | 9 #include "cc/test/fake_scrollbar.h" |
11 #include "cc/test/test_task_graph_runner.h" | 10 #include "cc/test/test_task_graph_runner.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 11 #include "testing/gmock/include/gmock/gmock.h" |
13 | 12 |
14 using ::testing::Mock; | 13 using ::testing::Mock; |
15 using ::testing::_; | 14 using ::testing::_; |
16 | 15 |
17 namespace cc { | 16 namespace cc { |
18 | 17 |
19 namespace { | 18 namespace { |
20 | 19 |
21 class MockScrollbar : public FakeScrollbar { | 20 class MockScrollbar : public FakeScrollbar { |
22 public: | 21 public: |
23 MockScrollbar() : FakeScrollbar(true, true, true) {} | 22 MockScrollbar() : FakeScrollbar(true, true, true) {} |
24 MOCK_METHOD3(PaintPart, | 23 MOCK_METHOD3(PaintPart, |
25 void(SkCanvas* canvas, | 24 void(SkCanvas* canvas, |
26 ScrollbarPart part, | 25 ScrollbarPart part, |
27 const gfx::Rect& content_rect)); | 26 const gfx::Rect& content_rect)); |
28 }; | 27 }; |
29 | 28 |
30 TEST(PaintedScrollbarLayerTest, NeedsPaint) { | 29 TEST(PaintedScrollbarLayerTest, NeedsPaint) { |
31 FakeLayerTreeHostClient fake_client_(FakeLayerTreeHostClient::DIRECT_3D); | 30 FakeLayerTreeHostClient fake_client_(FakeLayerTreeHostClient::DIRECT_3D); |
32 TestTaskGraphRunner task_graph_runner_; | 31 TestTaskGraphRunner task_graph_runner_; |
33 scoped_ptr<FakeLayerTreeHost> layer_tree_host_; | 32 scoped_ptr<FakeLayerTreeHost> layer_tree_host_; |
34 LayerSettings layer_settings_; | |
35 | 33 |
36 layer_tree_host_ = | 34 layer_tree_host_ = |
37 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_); | 35 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_); |
38 RendererCapabilities renderer_capabilities; | 36 RendererCapabilities renderer_capabilities; |
39 renderer_capabilities.max_texture_size = 2048; | 37 renderer_capabilities.max_texture_size = 2048; |
40 layer_tree_host_->set_renderer_capabilities(renderer_capabilities); | 38 layer_tree_host_->set_renderer_capabilities(renderer_capabilities); |
41 | 39 |
42 MockScrollbar* scrollbar = new MockScrollbar(); | 40 MockScrollbar* scrollbar = new MockScrollbar(); |
43 scoped_refptr<PaintedScrollbarLayer> scrollbar_layer = | 41 scoped_refptr<PaintedScrollbarLayer> scrollbar_layer = |
44 PaintedScrollbarLayer::Create(layer_settings_, | 42 PaintedScrollbarLayer::Create(scoped_ptr<Scrollbar>(scrollbar), 1); |
45 scoped_ptr<Scrollbar>(scrollbar), 1); | |
46 | 43 |
47 scrollbar_layer->SetIsDrawable(true); | 44 scrollbar_layer->SetIsDrawable(true); |
48 scrollbar_layer->SetBounds(gfx::Size(100, 100)); | 45 scrollbar_layer->SetBounds(gfx::Size(100, 100)); |
49 | 46 |
50 layer_tree_host_->SetRootLayer(scrollbar_layer); | 47 layer_tree_host_->SetRootLayer(scrollbar_layer); |
51 EXPECT_EQ(scrollbar_layer->layer_tree_host(), layer_tree_host_.get()); | 48 EXPECT_EQ(scrollbar_layer->layer_tree_host(), layer_tree_host_.get()); |
52 scrollbar_layer->SavePaintProperties(); | 49 scrollbar_layer->SavePaintProperties(); |
53 | 50 |
54 // Request no paint, but expect them to be painted because they have not | 51 // Request no paint, but expect them to be painted because they have not |
55 // yet been initialized. | 52 // yet been initialized. |
(...skipping 22 matching lines...) Expand all Loading... |
78 EXPECT_CALL(*scrollbar, PaintPart(_, THUMB, _)).Times(0); | 75 EXPECT_CALL(*scrollbar, PaintPart(_, THUMB, _)).Times(0); |
79 EXPECT_CALL(*scrollbar, PaintPart(_, TRACK, _)).Times(1); | 76 EXPECT_CALL(*scrollbar, PaintPart(_, TRACK, _)).Times(1); |
80 scrollbar->set_needs_paint_thumb(false); | 77 scrollbar->set_needs_paint_thumb(false); |
81 scrollbar->set_needs_paint_track(true); | 78 scrollbar->set_needs_paint_track(true); |
82 scrollbar_layer->Update(); | 79 scrollbar_layer->Update(); |
83 Mock::VerifyAndClearExpectations(scrollbar); | 80 Mock::VerifyAndClearExpectations(scrollbar); |
84 } | 81 } |
85 | 82 |
86 } // namespace | 83 } // namespace |
87 } // namespace cc | 84 } // namespace cc |
OLD | NEW |