OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "platform/graphics/CompositorMutableState.h" | 5 #include "platform/graphics/CompositorMutableState.h" |
6 | 6 |
7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
8 #include "cc/test/fake_impl_task_runner_provider.h" | 8 #include "cc/test/fake_impl_task_runner_provider.h" |
9 #include "cc/test/fake_layer_tree_host_impl.h" | 9 #include "cc/test/fake_layer_tree_host_impl.h" |
10 #include "cc/test/fake_output_surface.h" | 10 #include "cc/test/fake_output_surface.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // properties. We should not be able to get any mutable state. | 73 // properties. We should not be able to get any mutable state. |
74 std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree()
, 42); | 74 std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree()
, 42); |
75 SetLayerPropertiesForTesting(root.get()); | 75 SetLayerPropertiesForTesting(root.get()); |
76 | 76 |
77 hostImpl().SetViewportSize(root->bounds()); | 77 hostImpl().SetViewportSize(root->bounds()); |
78 hostImpl().active_tree()->SetRootLayer(std::move(root)); | 78 hostImpl().active_tree()->SetRootLayer(std::move(root)); |
79 hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 79 hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
80 | 80 |
81 CompositorMutations mutations; | 81 CompositorMutations mutations; |
82 CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations
); | 82 CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations
); |
83 OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(42)); | 83 std::unique_ptr<CompositorMutableState> state(provider.getMutableStateFor(42
)); |
84 EXPECT_FALSE(state); | 84 EXPECT_FALSE(state); |
85 } | 85 } |
86 | 86 |
87 TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) | 87 TEST_F(CompositorMutableStateTest, MutableStateMutableProperties) |
88 { | 88 { |
89 // In this test, there is a layer with an element id and mutable properties. | 89 // In this test, there is a layer with an element id and mutable properties. |
90 // In this case, we should get a valid mutable state for this element id tha
t | 90 // In this case, we should get a valid mutable state for this element id tha
t |
91 // has a real effect on the corresponding layer. | 91 // has a real effect on the corresponding layer. |
92 std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree()
, 42); | 92 std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree()
, 42); |
93 | 93 |
(...skipping 13 matching lines...) Expand all Loading... |
107 root->SetMutableProperties(CompositorMutableProperty::kOpacity | CompositorM
utableProperty::kTransform); | 107 root->SetMutableProperties(CompositorMutableProperty::kOpacity | CompositorM
utableProperty::kTransform); |
108 layer->SetMutableProperties(CompositorMutableProperty::kScrollLeft | Composi
torMutableProperty::kScrollTop); | 108 layer->SetMutableProperties(CompositorMutableProperty::kScrollLeft | Composi
torMutableProperty::kScrollTop); |
109 | 109 |
110 hostImpl().SetViewportSize(layer->bounds()); | 110 hostImpl().SetViewportSize(layer->bounds()); |
111 hostImpl().active_tree()->SetRootLayer(std::move(root)); | 111 hostImpl().active_tree()->SetRootLayer(std::move(root)); |
112 hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); | 112 hostImpl().UpdateNumChildrenAndDrawPropertiesForActiveTree(); |
113 | 113 |
114 CompositorMutations mutations; | 114 CompositorMutations mutations; |
115 CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations
); | 115 CompositorMutableStateProvider provider(hostImpl().active_tree(), &mutations
); |
116 | 116 |
117 OwnPtr<CompositorMutableState> state(provider.getMutableStateFor(primaryId))
; | 117 std::unique_ptr<CompositorMutableState> state(provider.getMutableStateFor(pr
imaryId)); |
118 EXPECT_TRUE(state.get()); | 118 EXPECT_TRUE(state.get()); |
119 | 119 |
120 EXPECT_EQ(1.0, rootLayer()->Opacity()); | 120 EXPECT_EQ(1.0, rootLayer()->Opacity()); |
121 EXPECT_EQ(gfx::Transform().ToString(), rootLayer()->transform().ToString()); | 121 EXPECT_EQ(gfx::Transform().ToString(), rootLayer()->transform().ToString()); |
122 EXPECT_EQ(0.0, layer->CurrentScrollOffset().x()); | 122 EXPECT_EQ(0.0, layer->CurrentScrollOffset().x()); |
123 EXPECT_EQ(0.0, layer->CurrentScrollOffset().y()); | 123 EXPECT_EQ(0.0, layer->CurrentScrollOffset().y()); |
124 | 124 |
125 gfx::Transform zero(0, 0, 0, 0, 0, 0); | 125 gfx::Transform zero(0, 0, 0, 0, 0, 0); |
126 state->setOpacity(0.5); | 126 state->setOpacity(0.5); |
127 state->setTransform(zero.matrix()); | 127 state->setTransform(zero.matrix()); |
(...skipping 14 matching lines...) Expand all Loading... |
142 EXPECT_TRUE(mutation.isScrollLeftMutated()); | 142 EXPECT_TRUE(mutation.isScrollLeftMutated()); |
143 EXPECT_TRUE(mutation.isScrollTopMutated()); | 143 EXPECT_TRUE(mutation.isScrollTopMutated()); |
144 | 144 |
145 EXPECT_EQ(0.5, mutation.opacity()); | 145 EXPECT_EQ(0.5, mutation.opacity()); |
146 EXPECT_EQ(zero.ToString(), gfx::Transform(mutation.transform()).ToString()); | 146 EXPECT_EQ(zero.ToString(), gfx::Transform(mutation.transform()).ToString()); |
147 EXPECT_EQ(1.0, mutation.scrollLeft()); | 147 EXPECT_EQ(1.0, mutation.scrollLeft()); |
148 EXPECT_EQ(1.0, mutation.scrollTop()); | 148 EXPECT_EQ(1.0, mutation.scrollTop()); |
149 } | 149 } |
150 | 150 |
151 } // namespace blink | 151 } // namespace blink |
OLD | NEW |