OLD | NEW |
| (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 "config.h" | |
6 | |
7 #include "CCLayerTreeHost.h" | |
8 #include "CCThreadedTest.h" | |
9 #include "HeadsUpDisplayLayerChromium.h" | |
10 #include "LayerChromium.h" | |
11 | |
12 using namespace cc; | |
13 using namespace WebKitTests; | |
14 | |
15 namespace { | |
16 | |
17 class CCHeadsUpDisplayTest : public CCThreadedTest { | |
18 protected: | |
19 virtual void initializeSettings(CCLayerTreeSettings& settings) OVERRIDE | |
20 { | |
21 // Enable the HUD without requiring text. | |
22 settings.showPropertyChangedRects = true; | |
23 } | |
24 }; | |
25 | |
26 class DrawsContentLayerChromium : public LayerChromium { | |
27 public: | |
28 static scoped_refptr<DrawsContentLayerChromium> create() { return make_scope
d_refptr(new DrawsContentLayerChromium()); } | |
29 virtual bool drawsContent() const OVERRIDE { return true; } | |
30 | |
31 private: | |
32 DrawsContentLayerChromium() : LayerChromium() { } | |
33 virtual ~DrawsContentLayerChromium() | |
34 { | |
35 } | |
36 }; | |
37 | |
38 class CCHudWithRootLayerChange : public CCHeadsUpDisplayTest { | |
39 public: | |
40 CCHudWithRootLayerChange() | |
41 : m_rootLayer1(DrawsContentLayerChromium::create()) | |
42 , m_rootLayer2(DrawsContentLayerChromium::create()) | |
43 , m_numCommits(0) | |
44 { | |
45 } | |
46 | |
47 virtual void beginTest() OVERRIDE | |
48 { | |
49 m_rootLayer1->setBounds(IntSize(30, 30)); | |
50 m_rootLayer2->setBounds(IntSize(30, 30)); | |
51 | |
52 postSetNeedsCommitToMainThread(); | |
53 } | |
54 | |
55 virtual void didCommit() OVERRIDE | |
56 { | |
57 ++m_numCommits; | |
58 | |
59 ASSERT_TRUE(m_layerTreeHost->hudLayer()); | |
60 | |
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; | |
95 } | |
96 } | |
97 | |
98 virtual void afterTest() OVERRIDE | |
99 { | |
100 } | |
101 | |
102 private: | |
103 scoped_refptr<DrawsContentLayerChromium> m_rootLayer1; | |
104 scoped_refptr<DrawsContentLayerChromium> m_rootLayer2; | |
105 int m_numCommits; | |
106 }; | |
107 | |
108 TEST_F(CCHudWithRootLayerChange, runMultiThread) | |
109 { | |
110 runTest(true); | |
111 } | |
112 | |
113 } // namespace | |
OLD | NEW |