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/top_controls_manager.h" | 5 #include "cc/input/top_controls_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "cc/input/top_controls_manager_client.h" | 13 #include "cc/input/top_controls_manager_client.h" |
14 #include "cc/layers/layer_impl.h" | 14 #include "cc/layers/layer_impl.h" |
15 #include "cc/test/fake_impl_task_runner_provider.h" | 15 #include "cc/test/fake_impl_task_runner_provider.h" |
16 #include "cc/test/fake_layer_tree_host_impl.h" | 16 #include "cc/test/fake_layer_tree_host_impl.h" |
17 #include "cc/test/test_shared_bitmap_manager.h" | |
18 #include "cc/test/test_task_graph_runner.h" | 17 #include "cc/test/test_task_graph_runner.h" |
19 #include "cc/trees/layer_tree_impl.h" | 18 #include "cc/trees/layer_tree_impl.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "ui/gfx/geometry/vector2d_f.h" | 20 #include "ui/gfx/geometry/vector2d_f.h" |
22 | 21 |
23 namespace cc { | 22 namespace cc { |
24 namespace { | 23 namespace { |
25 | 24 |
26 class MockTopControlsManagerClient : public TopControlsManagerClient { | 25 class MockTopControlsManagerClient : public TopControlsManagerClient { |
27 public: | 26 public: |
28 MockTopControlsManagerClient(float top_controls_height, | 27 MockTopControlsManagerClient(float top_controls_height, |
29 float top_controls_show_threshold, | 28 float top_controls_show_threshold, |
30 float top_controls_hide_threshold) | 29 float top_controls_hide_threshold) |
31 : host_impl_(&task_runner_provider_, | 30 : host_impl_(&task_runner_provider_, |
32 &shared_bitmap_manager_, | |
33 &task_graph_runner_), | 31 &task_graph_runner_), |
34 redraw_needed_(false), | 32 redraw_needed_(false), |
35 update_draw_properties_needed_(false), | 33 update_draw_properties_needed_(false), |
36 bottom_controls_height_(0.f), | 34 bottom_controls_height_(0.f), |
37 top_controls_shown_ratio_(1.f), | 35 top_controls_shown_ratio_(1.f), |
38 top_controls_height_(top_controls_height), | 36 top_controls_height_(top_controls_height), |
39 top_controls_show_threshold_(top_controls_show_threshold), | 37 top_controls_show_threshold_(top_controls_show_threshold), |
40 top_controls_hide_threshold_(top_controls_hide_threshold) { | 38 top_controls_hide_threshold_(top_controls_hide_threshold) { |
41 active_tree_ = base::MakeUnique<LayerTreeImpl>( | 39 active_tree_ = base::MakeUnique<LayerTreeImpl>( |
42 &host_impl_, new SyncedProperty<ScaleGroup>, new SyncedTopControls, | 40 &host_impl_, new SyncedProperty<ScaleGroup>, new SyncedTopControls, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 } | 84 } |
87 | 85 |
88 void SetTopControlsHeight(float height) { top_controls_height_ = height; } | 86 void SetTopControlsHeight(float height) { top_controls_height_ = height; } |
89 | 87 |
90 void SetBottomControlsHeight(float height) { | 88 void SetBottomControlsHeight(float height) { |
91 bottom_controls_height_ = height; | 89 bottom_controls_height_ = height; |
92 } | 90 } |
93 | 91 |
94 private: | 92 private: |
95 FakeImplTaskRunnerProvider task_runner_provider_; | 93 FakeImplTaskRunnerProvider task_runner_provider_; |
96 TestSharedBitmapManager shared_bitmap_manager_; | |
97 TestTaskGraphRunner task_graph_runner_; | 94 TestTaskGraphRunner task_graph_runner_; |
98 FakeLayerTreeHostImpl host_impl_; | 95 FakeLayerTreeHostImpl host_impl_; |
99 std::unique_ptr<LayerTreeImpl> active_tree_; | 96 std::unique_ptr<LayerTreeImpl> active_tree_; |
100 std::unique_ptr<LayerImpl> root_scroll_layer_; | 97 std::unique_ptr<LayerImpl> root_scroll_layer_; |
101 std::unique_ptr<TopControlsManager> manager_; | 98 std::unique_ptr<TopControlsManager> manager_; |
102 bool redraw_needed_; | 99 bool redraw_needed_; |
103 bool update_draw_properties_needed_; | 100 bool update_draw_properties_needed_; |
104 | 101 |
105 float bottom_controls_height_; | 102 float bottom_controls_height_; |
106 float top_controls_shown_ratio_; | 103 float top_controls_shown_ratio_; |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
522 EXPECT_TRUE(manager->has_animation()); | 519 EXPECT_TRUE(manager->has_animation()); |
523 EXPECT_FLOAT_EQ(1.f, client.CurrentTopControlsShownRatio()); | 520 EXPECT_FLOAT_EQ(1.f, client.CurrentTopControlsShownRatio()); |
524 | 521 |
525 manager->UpdateTopControlsState(BOTH, SHOWN, true); | 522 manager->UpdateTopControlsState(BOTH, SHOWN, true); |
526 EXPECT_FALSE(manager->has_animation()); | 523 EXPECT_FALSE(manager->has_animation()); |
527 EXPECT_FLOAT_EQ(1.f, client.CurrentTopControlsShownRatio()); | 524 EXPECT_FLOAT_EQ(1.f, client.CurrentTopControlsShownRatio()); |
528 } | 525 } |
529 | 526 |
530 } // namespace | 527 } // namespace |
531 } // namespace cc | 528 } // namespace cc |
OLD | NEW |