Add Sad Tab resources to the iOS build.
[chromium-blink-merge.git] / cc / heads_up_display_unittest.cc
blobf93adaefab3b56641430b361d74af8d2b8d7ff1f
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 "config.h"
7 #include "cc/heads_up_display_layer.h"
8 #include "cc/layer.h"
9 #include "cc/layer_tree_host.h"
10 #include "cc/test/layer_tree_test_common.h"
12 using namespace cc;
13 using namespace WebKitTests;
15 namespace {
17 class HeadsUpDisplayTest : public ThreadedTest {
18 protected:
19 virtual void initializeSettings(LayerTreeSettings& settings) OVERRIDE
21 // Enable the HUD without requiring text.
22 settings.showPropertyChangedRects = true;
26 class DrawsContentLayer : public Layer {
27 public:
28 static scoped_refptr<DrawsContentLayer> create() { return make_scoped_refptr(new DrawsContentLayer()); }
29 virtual bool drawsContent() const OVERRIDE { return true; }
31 private:
32 DrawsContentLayer() : Layer() { }
33 virtual ~DrawsContentLayer()
38 class HudWithRootLayerChange : public HeadsUpDisplayTest {
39 public:
40 HudWithRootLayerChange()
41 : m_rootLayer1(DrawsContentLayer::create())
42 , m_rootLayer2(DrawsContentLayer::create())
43 , m_numCommits(0)
47 virtual void beginTest() OVERRIDE
49 m_rootLayer1->setBounds(gfx::Size(30, 30));
50 m_rootLayer2->setBounds(gfx::Size(30, 30));
52 postSetNeedsCommitToMainThread();
55 virtual void didCommit() OVERRIDE
57 ++m_numCommits;
59 ASSERT_TRUE(m_layerTreeHost->hudLayer());
61 switch (m_numCommits) {
62 case 1:
63 // Change directly to a new root layer.
64 m_layerTreeHost->setRootLayer(m_rootLayer1);
65 break;
66 case 2:
67 EXPECT_EQ(m_rootLayer1.get(), m_layerTreeHost->hudLayer()->parent());
68 // Unset the root layer.
69 m_layerTreeHost->setRootLayer(0);
70 break;
71 case 3:
72 EXPECT_EQ(0, m_layerTreeHost->hudLayer()->parent());
73 // Change back to the previous root layer.
74 m_layerTreeHost->setRootLayer(m_rootLayer1);
75 break;
76 case 4:
77 EXPECT_EQ(m_rootLayer1.get(), m_layerTreeHost->hudLayer()->parent());
78 // Unset the root layer.
79 m_layerTreeHost->setRootLayer(0);
80 break;
81 case 5:
82 EXPECT_EQ(0, m_layerTreeHost->hudLayer()->parent());
83 // Change to a new root layer from a null root.
84 m_layerTreeHost->setRootLayer(m_rootLayer2);
85 break;
86 case 6:
87 EXPECT_EQ(m_rootLayer2.get(), m_layerTreeHost->hudLayer()->parent());
88 // Change directly back to the last root layer/
89 m_layerTreeHost->setRootLayer(m_rootLayer1);
90 break;
91 case 7:
92 EXPECT_EQ(m_rootLayer1.get(), m_layerTreeHost->hudLayer()->parent());
93 endTest();
94 break;
98 virtual void afterTest() OVERRIDE
102 private:
103 scoped_refptr<DrawsContentLayer> m_rootLayer1;
104 scoped_refptr<DrawsContentLayer> m_rootLayer2;
105 int m_numCommits;
108 TEST_F(HudWithRootLayerChange, runMultiThread)
110 runTest(true);
113 } // anonymous namespace