Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(534)

Side by Side Diff: cc/heads_up_display_unittest.cc

Issue 12603013: Part 10 of cc/ directory shuffles: layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/heads_up_display_layer_impl.cc ('k') | cc/image_layer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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.
4
5 #include "cc/heads_up_display_layer.h"
6 #include "cc/layer.h"
7 #include "cc/test/layer_tree_test_common.h"
8 #include "cc/trees/layer_tree_host.h"
9
10 namespace cc {
11 namespace {
12
13 class HeadsUpDisplayTest : public ThreadedTest {
14 protected:
15 virtual void initializeSettings(LayerTreeSettings& settings) OVERRIDE
16 {
17 // Enable the HUD without requiring text.
18 settings.initialDebugState.showPropertyChangedRects = true;
19 }
20 };
21
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; }
26
27 private:
28 DrawsContentLayer() : Layer() { }
29 virtual ~DrawsContentLayer()
30 {
31 }
32 };
33
34 class HudWithRootLayerChange : public HeadsUpDisplayTest {
35 public:
36 HudWithRootLayerChange()
37 : m_rootLayer1(DrawsContentLayer::Create())
38 , m_rootLayer2(DrawsContentLayer::Create())
39 , m_numCommits(0)
40 {
41 }
42
43 virtual void beginTest() OVERRIDE
44 {
45 m_rootLayer1->SetBounds(gfx::Size(30, 30));
46 m_rootLayer2->SetBounds(gfx::Size(30, 30));
47
48 postSetNeedsCommitToMainThread();
49 }
50
51 virtual void didCommit() OVERRIDE
52 {
53 ++m_numCommits;
54
55 ASSERT_TRUE(m_layerTreeHost->hud_layer());
56
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->hud_layer()->parent() );
64 // Unset the root layer.
65 m_layerTreeHost->SetRootLayer(NULL);
66 break;
67 case 3:
68 EXPECT_EQ(0, m_layerTreeHost->hud_layer()->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->hud_layer()->parent() );
74 // Unset the root layer.
75 m_layerTreeHost->SetRootLayer(NULL);
76 break;
77 case 5:
78 EXPECT_EQ(0, m_layerTreeHost->hud_layer()->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->hud_layer()->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->hud_layer()->parent() );
89 endTest();
90 break;
91 }
92 }
93
94 virtual void afterTest() OVERRIDE
95 {
96 }
97
98 private:
99 scoped_refptr<DrawsContentLayer> m_rootLayer1;
100 scoped_refptr<DrawsContentLayer> m_rootLayer2;
101 int m_numCommits;
102 };
103
104 TEST_F(HudWithRootLayerChange, runMultiThread)
105 {
106 runTest(true);
107 }
108
109 } // namespace
110 } // namespace cc
OLDNEW
« no previous file with comments | « cc/heads_up_display_layer_impl.cc ('k') | cc/image_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698