OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 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 "cc/animation/scrollbar_animation_controller_linear_fade.h" | 5 #include "cc/animation/scrollbar_animation_controller_linear_fade.h" |
6 | 6 |
7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" | 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" |
8 #include "cc/test/fake_impl_proxy.h" | 8 #include "cc/test/fake_impl_proxy.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/geometry_test_utils.h" | 10 #include "cc/test/geometry_test_utils.h" |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 time += base::TimeDelta::FromSeconds(100); | 123 time += base::TimeDelta::FromSeconds(100); |
124 scrollbar_controller_->Animate(time); | 124 scrollbar_controller_->Animate(time); |
125 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); | 125 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); |
126 | 126 |
127 EXPECT_EQ(0, needs_frame_count_); | 127 EXPECT_EQ(0, needs_frame_count_); |
128 } | 128 } |
129 | 129 |
130 TEST_F(ScrollbarAnimationControllerLinearFadeTest, HideOnResize) { | 130 TEST_F(ScrollbarAnimationControllerLinearFadeTest, HideOnResize) { |
131 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 131 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
132 ASSERT_TRUE(scroll_layer); | 132 ASSERT_TRUE(scroll_layer); |
133 EXPECT_SIZE_EQ(gfx::Size(200, 200), scroll_layer->bounds()); | 133 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); |
134 | 134 |
135 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); | 135 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); |
136 | 136 |
137 // Shrink along X axis, horizontal scrollbar should appear. | 137 // Shrink along X axis, horizontal scrollbar should appear. |
138 clip_layer_->SetBounds(gfx::Size(100, 200)); | 138 clip_layer_->SetBounds(gfx::Size(100, 200)); |
139 EXPECT_SIZE_EQ(gfx::Size(100, 200), clip_layer_->bounds()); | 139 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); |
140 | 140 |
141 scrollbar_controller_->DidScrollBegin(); | 141 scrollbar_controller_->DidScrollBegin(); |
142 | 142 |
143 scrollbar_controller_->DidScrollUpdate(false); | 143 scrollbar_controller_->DidScrollUpdate(false); |
144 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); | 144 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); |
145 | 145 |
146 scrollbar_controller_->DidScrollEnd(); | 146 scrollbar_controller_->DidScrollEnd(); |
147 | 147 |
148 // Shrink along Y axis and expand along X, horizontal scrollbar | 148 // Shrink along Y axis and expand along X, horizontal scrollbar |
149 // should disappear. | 149 // should disappear. |
150 clip_layer_->SetBounds(gfx::Size(200, 100)); | 150 clip_layer_->SetBounds(gfx::Size(200, 100)); |
151 EXPECT_SIZE_EQ(gfx::Size(200, 100), clip_layer_->bounds()); | 151 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); |
152 | 152 |
153 scrollbar_controller_->DidScrollBegin(); | 153 scrollbar_controller_->DidScrollBegin(); |
154 | 154 |
155 scrollbar_controller_->DidScrollUpdate(false); | 155 scrollbar_controller_->DidScrollUpdate(false); |
156 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); | 156 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); |
157 | 157 |
158 scrollbar_controller_->DidScrollEnd(); | 158 scrollbar_controller_->DidScrollEnd(); |
159 } | 159 } |
160 | 160 |
161 TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest, HideOnResize) { | 161 TEST_F(VerticalScrollbarAnimationControllerLinearFadeTest, HideOnResize) { |
162 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 162 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
163 ASSERT_TRUE(scroll_layer); | 163 ASSERT_TRUE(scroll_layer); |
164 EXPECT_SIZE_EQ(gfx::Size(200, 200), scroll_layer->bounds()); | 164 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); |
165 | 165 |
166 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); | 166 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); |
167 | 167 |
168 // Shrink along X axis, vertical scrollbar should remain invisible. | 168 // Shrink along X axis, vertical scrollbar should remain invisible. |
169 clip_layer_->SetBounds(gfx::Size(100, 200)); | 169 clip_layer_->SetBounds(gfx::Size(100, 200)); |
170 EXPECT_SIZE_EQ(gfx::Size(100, 200), clip_layer_->bounds()); | 170 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); |
171 | 171 |
172 scrollbar_controller_->DidScrollBegin(); | 172 scrollbar_controller_->DidScrollBegin(); |
173 | 173 |
174 scrollbar_controller_->DidScrollUpdate(false); | 174 scrollbar_controller_->DidScrollUpdate(false); |
175 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); | 175 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->opacity()); |
176 | 176 |
177 scrollbar_controller_->DidScrollEnd(); | 177 scrollbar_controller_->DidScrollEnd(); |
178 | 178 |
179 // Shrink along Y axis and expand along X, vertical scrollbar should appear. | 179 // Shrink along Y axis and expand along X, vertical scrollbar should appear. |
180 clip_layer_->SetBounds(gfx::Size(200, 100)); | 180 clip_layer_->SetBounds(gfx::Size(200, 100)); |
181 EXPECT_SIZE_EQ(gfx::Size(200, 100), clip_layer_->bounds()); | 181 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); |
182 | 182 |
183 scrollbar_controller_->DidScrollBegin(); | 183 scrollbar_controller_->DidScrollBegin(); |
184 | 184 |
185 scrollbar_controller_->DidScrollUpdate(false); | 185 scrollbar_controller_->DidScrollUpdate(false); |
186 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); | 186 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->opacity()); |
187 | 187 |
188 scrollbar_controller_->DidScrollEnd(); | 188 scrollbar_controller_->DidScrollEnd(); |
189 } | 189 } |
190 | 190 |
191 TEST_F(ScrollbarAnimationControllerLinearFadeTest, | 191 TEST_F(ScrollbarAnimationControllerLinearFadeTest, |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 scrollbar_controller_->DidScrollUpdate(false); | 410 scrollbar_controller_->DidScrollUpdate(false); |
411 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); | 411 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); |
412 | 412 |
413 time += base::TimeDelta::FromSeconds(1); | 413 time += base::TimeDelta::FromSeconds(1); |
414 scrollbar_controller_->DidScrollEnd(); | 414 scrollbar_controller_->DidScrollEnd(); |
415 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); | 415 EXPECT_FLOAT_EQ(1, scrollbar_layer_->opacity()); |
416 } | 416 } |
417 | 417 |
418 } // namespace | 418 } // namespace |
419 } // namespace cc | 419 } // namespace cc |
OLD | NEW |