OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/heads_up_display_layer.h" | 5 #include "cc/layers/heads_up_display_layer.h" |
6 #include "cc/layers/layer.h" | 6 #include "cc/layers/layer.h" |
7 #include "cc/test/layer_tree_test.h" | 7 #include "cc/test/layer_tree_test.h" |
8 #include "cc/trees/layer_tree_host.h" | 8 #include "cc/trees/layer_tree_host.h" |
9 | 9 |
10 namespace cc { | 10 namespace cc { |
11 namespace { | 11 namespace { |
12 | 12 |
13 class HeadsUpDisplayTest : public LayerTreeTest { | 13 class HeadsUpDisplayTest : public LayerTreeTest { |
14 protected: | 14 protected: |
15 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE { | 15 virtual void InitializeSettings(LayerTreeSettings* settings) override { |
16 // Enable the HUD without requiring text. | 16 // Enable the HUD without requiring text. |
17 settings->initial_debug_state.show_property_changed_rects = true; | 17 settings->initial_debug_state.show_property_changed_rects = true; |
18 } | 18 } |
19 }; | 19 }; |
20 | 20 |
21 class DrawsContentLayer : public Layer { | 21 class DrawsContentLayer : public Layer { |
22 public: | 22 public: |
23 static scoped_refptr<DrawsContentLayer> Create() { | 23 static scoped_refptr<DrawsContentLayer> Create() { |
24 return make_scoped_refptr(new DrawsContentLayer()); | 24 return make_scoped_refptr(new DrawsContentLayer()); |
25 } | 25 } |
26 virtual bool DrawsContent() const OVERRIDE { return true; } | 26 virtual bool DrawsContent() const override { return true; } |
27 | 27 |
28 private: | 28 private: |
29 DrawsContentLayer() : Layer() {} | 29 DrawsContentLayer() : Layer() {} |
30 virtual ~DrawsContentLayer() {} | 30 virtual ~DrawsContentLayer() {} |
31 }; | 31 }; |
32 | 32 |
33 class HudWithRootLayerChange : public HeadsUpDisplayTest { | 33 class HudWithRootLayerChange : public HeadsUpDisplayTest { |
34 public: | 34 public: |
35 HudWithRootLayerChange() | 35 HudWithRootLayerChange() |
36 : root_layer1_(DrawsContentLayer::Create()), | 36 : root_layer1_(DrawsContentLayer::Create()), |
37 root_layer2_(DrawsContentLayer::Create()), | 37 root_layer2_(DrawsContentLayer::Create()), |
38 num_commits_(0) {} | 38 num_commits_(0) {} |
39 | 39 |
40 virtual void BeginTest() OVERRIDE { | 40 virtual void BeginTest() override { |
41 root_layer1_->SetBounds(gfx::Size(30, 30)); | 41 root_layer1_->SetBounds(gfx::Size(30, 30)); |
42 root_layer2_->SetBounds(gfx::Size(30, 30)); | 42 root_layer2_->SetBounds(gfx::Size(30, 30)); |
43 | 43 |
44 PostSetNeedsCommitToMainThread(); | 44 PostSetNeedsCommitToMainThread(); |
45 } | 45 } |
46 | 46 |
47 virtual void DidCommit() OVERRIDE { | 47 virtual void DidCommit() override { |
48 ++num_commits_; | 48 ++num_commits_; |
49 | 49 |
50 ASSERT_TRUE(layer_tree_host()->hud_layer()); | 50 ASSERT_TRUE(layer_tree_host()->hud_layer()); |
51 | 51 |
52 switch (num_commits_) { | 52 switch (num_commits_) { |
53 case 1: | 53 case 1: |
54 // Change directly to a new root layer. | 54 // Change directly to a new root layer. |
55 layer_tree_host()->SetRootLayer(root_layer1_); | 55 layer_tree_host()->SetRootLayer(root_layer1_); |
56 break; | 56 break; |
57 case 2: | 57 case 2: |
(...skipping 21 matching lines...) Expand all Loading... |
79 // Change directly back to the last root layer/ | 79 // Change directly back to the last root layer/ |
80 layer_tree_host()->SetRootLayer(root_layer1_); | 80 layer_tree_host()->SetRootLayer(root_layer1_); |
81 break; | 81 break; |
82 case 7: | 82 case 7: |
83 EXPECT_EQ(root_layer1_.get(), layer_tree_host()->hud_layer()->parent()); | 83 EXPECT_EQ(root_layer1_.get(), layer_tree_host()->hud_layer()->parent()); |
84 EndTest(); | 84 EndTest(); |
85 break; | 85 break; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 virtual void AfterTest() OVERRIDE {} | 89 virtual void AfterTest() override {} |
90 | 90 |
91 private: | 91 private: |
92 scoped_refptr<DrawsContentLayer> root_layer1_; | 92 scoped_refptr<DrawsContentLayer> root_layer1_; |
93 scoped_refptr<DrawsContentLayer> root_layer2_; | 93 scoped_refptr<DrawsContentLayer> root_layer2_; |
94 int num_commits_; | 94 int num_commits_; |
95 }; | 95 }; |
96 | 96 |
97 MULTI_THREAD_TEST_F(HudWithRootLayerChange); | 97 MULTI_THREAD_TEST_F(HudWithRootLayerChange); |
98 | 98 |
99 } // namespace | 99 } // namespace |
100 } // namespace cc | 100 } // namespace cc |
OLD | NEW |