Revert "Merged all Chromoting Host code into remoting_core.dll (Windows)."
[chromium-blink-merge.git] / cc / heads_up_display_unittest.cc
blob1bbdbf25533e4e8b9483f86f3317c9e74fdfd98b
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/heads_up_display_layer.h"
6 #include "cc/layer.h"
7 #include "cc/layer_tree_host.h"
8 #include "cc/test/layer_tree_test_common.h"
10 namespace cc {
11 namespace {
13 class HeadsUpDisplayTest : public ThreadedTest {
14 protected:
15 virtual void initializeSettings(LayerTreeSettings& settings) OVERRIDE
17 // Enable the HUD without requiring text.
18 settings.initialDebugState.showPropertyChangedRects = true;
22 class DrawsContentLayer : public Layer {
23 public:
24 static scoped_refptr<DrawsContentLayer> create() { return make_scoped_refptr(new DrawsContentLayer()); }
25 virtual bool drawsContent() const OVERRIDE { return true; }
27 private:
28 DrawsContentLayer() : Layer() { }
29 virtual ~DrawsContentLayer()
34 class HudWithRootLayerChange : public HeadsUpDisplayTest {
35 public:
36 HudWithRootLayerChange()
37 : m_rootLayer1(DrawsContentLayer::create())
38 , m_rootLayer2(DrawsContentLayer::create())
39 , m_numCommits(0)
43 virtual void beginTest() OVERRIDE
45 m_rootLayer1->setBounds(gfx::Size(30, 30));
46 m_rootLayer2->setBounds(gfx::Size(30, 30));
48 postSetNeedsCommitToMainThread();
51 virtual void didCommit() OVERRIDE
53 ++m_numCommits;
55 ASSERT_TRUE(m_layerTreeHost->hudLayer());
57 switch (m_numCommits) {
58 case 1:
59 // Change directly to a new root layer.
60 m_layerTreeHost->setRootLayer(m_rootLayer1);
61 break;
62 case 2:
63 EXPECT_EQ(m_rootLayer1.get(), m_layerTreeHost->hudLayer()->parent());
64 // Unset the root layer.
65 m_layerTreeHost->setRootLayer(0);
66 break;
67 case 3:
68 EXPECT_EQ(0, m_layerTreeHost->hudLayer()->parent());
69 // Change back to the previous root layer.
70 m_layerTreeHost->setRootLayer(m_rootLayer1);
71 break;
72 case 4:
73 EXPECT_EQ(m_rootLayer1.get(), m_layerTreeHost->hudLayer()->parent());
74 // Unset the root layer.
75 m_layerTreeHost->setRootLayer(0);
76 break;
77 case 5:
78 EXPECT_EQ(0, m_layerTreeHost->hudLayer()->parent());
79 // Change to a new root layer from a null root.
80 m_layerTreeHost->setRootLayer(m_rootLayer2);
81 break;
82 case 6:
83 EXPECT_EQ(m_rootLayer2.get(), m_layerTreeHost->hudLayer()->parent());
84 // Change directly back to the last root layer/
85 m_layerTreeHost->setRootLayer(m_rootLayer1);
86 break;
87 case 7:
88 EXPECT_EQ(m_rootLayer1.get(), m_layerTreeHost->hudLayer()->parent());
89 endTest();
90 break;
94 virtual void afterTest() OVERRIDE
98 private:
99 scoped_refptr<DrawsContentLayer> m_rootLayer1;
100 scoped_refptr<DrawsContentLayer> m_rootLayer2;
101 int m_numCommits;
104 TEST_F(HudWithRootLayerChange, runMultiThread)
106 runTest(true);
109 } // namespace
110 } // namespace cc