Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / cc / layers / heads_up_display_unittest.cc
blob532a169c3683b8a47dc543b49d507db754cc9fb0
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
3 // found in the LICENSE file.
5 #include "cc/layers/heads_up_display_layer.h"
6 #include "cc/layers/layer.h"
7 #include "cc/test/layer_tree_test.h"
8 #include "cc/trees/layer_tree_host.h"
10 namespace cc {
11 namespace {
13 class HeadsUpDisplayTest : public LayerTreeTest {
14 protected:
15 void InitializeSettings(LayerTreeSettings* settings) override {
16 // Enable the HUD without requiring text.
17 settings->initial_debug_state.show_property_changed_rects = true;
21 class DrawsContentLayer : public Layer {
22 public:
23 static scoped_refptr<DrawsContentLayer> Create() {
24 return make_scoped_refptr(new DrawsContentLayer());
26 bool DrawsContent() const override { return true; }
28 private:
29 DrawsContentLayer() : Layer(LayerSettings()) {}
30 ~DrawsContentLayer() override {}
33 class HudWithRootLayerChange : public HeadsUpDisplayTest {
34 public:
35 HudWithRootLayerChange()
36 : root_layer1_(DrawsContentLayer::Create()),
37 root_layer2_(DrawsContentLayer::Create()),
38 num_commits_(0) {}
40 void BeginTest() override {
41 root_layer1_->SetBounds(gfx::Size(30, 30));
42 root_layer2_->SetBounds(gfx::Size(30, 30));
44 PostSetNeedsCommitToMainThread();
47 void DidCommit() override {
48 ++num_commits_;
50 ASSERT_TRUE(layer_tree_host()->hud_layer());
52 switch (num_commits_) {
53 case 1:
54 // Change directly to a new root layer.
55 layer_tree_host()->SetRootLayer(root_layer1_);
56 break;
57 case 2:
58 EXPECT_EQ(root_layer1_.get(), layer_tree_host()->hud_layer()->parent());
59 // Unset the root layer.
60 layer_tree_host()->SetRootLayer(nullptr);
61 break;
62 case 3:
63 EXPECT_EQ(0, layer_tree_host()->hud_layer()->parent());
64 // Change back to the previous root layer.
65 layer_tree_host()->SetRootLayer(root_layer1_);
66 break;
67 case 4:
68 EXPECT_EQ(root_layer1_.get(), layer_tree_host()->hud_layer()->parent());
69 // Unset the root layer.
70 layer_tree_host()->SetRootLayer(nullptr);
71 break;
72 case 5:
73 EXPECT_EQ(0, layer_tree_host()->hud_layer()->parent());
74 // Change to a new root layer from a null root.
75 layer_tree_host()->SetRootLayer(root_layer2_);
76 break;
77 case 6:
78 EXPECT_EQ(root_layer2_.get(), layer_tree_host()->hud_layer()->parent());
79 // Change directly back to the last root layer/
80 layer_tree_host()->SetRootLayer(root_layer1_);
81 break;
82 case 7:
83 EXPECT_EQ(root_layer1_.get(), layer_tree_host()->hud_layer()->parent());
84 EndTest();
85 break;
89 void AfterTest() override {}
91 private:
92 scoped_refptr<DrawsContentLayer> root_layer1_;
93 scoped_refptr<DrawsContentLayer> root_layer2_;
94 int num_commits_;
97 MULTI_THREAD_TEST_F(HudWithRootLayerChange);
99 } // namespace
100 } // namespace cc