| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/input/scrollbar_animation_controller_thinning.h" | 5 #include "cc/input/scrollbar_animation_controller_thinning.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_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/geometry_test_utils.h" | 10 #include "cc/test/geometry_test_utils.h" |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 bool did_request_animate_; | 90 bool did_request_animate_; |
| 91 }; | 91 }; |
| 92 | 92 |
| 93 // Check initialization of scrollbar. | 93 // Check initialization of scrollbar. |
| 94 TEST_F(ScrollbarAnimationControllerThinningTest, Idle) { | 94 TEST_F(ScrollbarAnimationControllerThinningTest, Idle) { |
| 95 scrollbar_controller_->Animate(base::TimeTicks()); | 95 scrollbar_controller_->Animate(base::TimeTicks()); |
| 96 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); | 96 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); |
| 97 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); | 97 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 98 } | 98 } |
| 99 | 99 |
| 100 // Check that scrollbar appears again, when the layer becomes scrollable. |
| 101 TEST_F(ScrollbarAnimationControllerThinningTest, AppearOnResize) { |
| 102 scrollbar_controller_->DidScrollUpdate(false); |
| 103 // Make the Layer non-scrollable, scrollbar disappears. |
| 104 clip_layer_->SetBounds(gfx::Size(200, 200)); |
| 105 scrollbar_controller_->DidScrollUpdate(false); |
| 106 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); |
| 107 // Make the layer scrollable, scrollbar appears again. |
| 108 clip_layer_->SetBounds(gfx::Size(100, 100)); |
| 109 scrollbar_controller_->DidScrollUpdate(false); |
| 110 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); |
| 111 } |
| 112 |
| 100 // Check that scrollbar disappears when the layer becomes non-scrollable. | 113 // Check that scrollbar disappears when the layer becomes non-scrollable. |
| 101 TEST_F(ScrollbarAnimationControllerThinningTest, HideOnResize) { | 114 TEST_F(ScrollbarAnimationControllerThinningTest, HideOnResize) { |
| 102 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); | 115 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); |
| 103 ASSERT_TRUE(scroll_layer); | 116 ASSERT_TRUE(scroll_layer); |
| 104 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); | 117 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); |
| 105 | 118 |
| 106 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); | 119 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); |
| 107 | 120 |
| 108 // Shrink along X axis, horizontal scrollbar should appear. | 121 // Shrink along X axis, horizontal scrollbar should appear. |
| 109 clip_layer_->SetBounds(gfx::Size(100, 200)); | 122 clip_layer_->SetBounds(gfx::Size(100, 200)); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 394 |
| 382 time += base::TimeDelta::FromSeconds(1); | 395 time += base::TimeDelta::FromSeconds(1); |
| 383 scrollbar_controller_->Animate(time); | 396 scrollbar_controller_->Animate(time); |
| 384 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); | 397 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); |
| 385 // The thickness now gets big again. | 398 // The thickness now gets big again. |
| 386 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); | 399 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); |
| 387 } | 400 } |
| 388 | 401 |
| 389 } // namespace | 402 } // namespace |
| 390 } // namespace cc | 403 } // namespace cc |
| OLD | NEW |