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/browser_controls_offset_manager.h" | 5 #include "cc/input/browser_controls_offset_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/browser_controls_offset_manager_client.h" | 13 #include "cc/input/browser_controls_offset_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 MockBrowserControlsOffsetManagerClient | 25 class MockBrowserControlsOffsetManagerClient |
27 : public BrowserControlsOffsetManagerClient { | 26 : public BrowserControlsOffsetManagerClient { |
28 public: | 27 public: |
29 MockBrowserControlsOffsetManagerClient(float top_controls_height, | 28 MockBrowserControlsOffsetManagerClient(float top_controls_height, |
30 float browser_controls_show_threshold, | 29 float browser_controls_show_threshold, |
31 float browser_controls_hide_threshold) | 30 float browser_controls_hide_threshold) |
32 : host_impl_(&task_runner_provider_, | 31 : host_impl_(&task_runner_provider_, |
33 &shared_bitmap_manager_, | |
34 &task_graph_runner_), | 32 &task_graph_runner_), |
35 redraw_needed_(false), | 33 redraw_needed_(false), |
36 update_draw_properties_needed_(false), | 34 update_draw_properties_needed_(false), |
37 bottom_controls_height_(0.f), | 35 bottom_controls_height_(0.f), |
38 top_controls_shown_ratio_(1.f), | 36 top_controls_shown_ratio_(1.f), |
39 top_controls_height_(top_controls_height), | 37 top_controls_height_(top_controls_height), |
40 browser_controls_show_threshold_(browser_controls_show_threshold), | 38 browser_controls_show_threshold_(browser_controls_show_threshold), |
41 browser_controls_hide_threshold_(browser_controls_hide_threshold) { | 39 browser_controls_hide_threshold_(browser_controls_hide_threshold) { |
42 active_tree_ = base::MakeUnique<LayerTreeImpl>( | 40 active_tree_ = base::MakeUnique<LayerTreeImpl>( |
43 &host_impl_, new SyncedProperty<ScaleGroup>, new SyncedBrowserControls, | 41 &host_impl_, new SyncedProperty<ScaleGroup>, new SyncedBrowserControls, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 } | 83 } |
86 | 84 |
87 void SetBrowserControlsHeight(float height) { top_controls_height_ = height; } | 85 void SetBrowserControlsHeight(float height) { top_controls_height_ = height; } |
88 | 86 |
89 void SetBottomControlsHeight(float height) { | 87 void SetBottomControlsHeight(float height) { |
90 bottom_controls_height_ = height; | 88 bottom_controls_height_ = height; |
91 } | 89 } |
92 | 90 |
93 private: | 91 private: |
94 FakeImplTaskRunnerProvider task_runner_provider_; | 92 FakeImplTaskRunnerProvider task_runner_provider_; |
95 TestSharedBitmapManager shared_bitmap_manager_; | |
96 TestTaskGraphRunner task_graph_runner_; | 93 TestTaskGraphRunner task_graph_runner_; |
97 FakeLayerTreeHostImpl host_impl_; | 94 FakeLayerTreeHostImpl host_impl_; |
98 std::unique_ptr<LayerTreeImpl> active_tree_; | 95 std::unique_ptr<LayerTreeImpl> active_tree_; |
99 std::unique_ptr<LayerImpl> root_scroll_layer_; | 96 std::unique_ptr<LayerImpl> root_scroll_layer_; |
100 std::unique_ptr<BrowserControlsOffsetManager> manager_; | 97 std::unique_ptr<BrowserControlsOffsetManager> manager_; |
101 bool redraw_needed_; | 98 bool redraw_needed_; |
102 bool update_draw_properties_needed_; | 99 bool update_draw_properties_needed_; |
103 | 100 |
104 float bottom_controls_height_; | 101 float bottom_controls_height_; |
105 float top_controls_shown_ratio_; | 102 float top_controls_shown_ratio_; |
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
547 EXPECT_TRUE(manager->has_animation()); | 544 EXPECT_TRUE(manager->has_animation()); |
548 EXPECT_FLOAT_EQ(1.f, client.CurrentBrowserControlsShownRatio()); | 545 EXPECT_FLOAT_EQ(1.f, client.CurrentBrowserControlsShownRatio()); |
549 | 546 |
550 manager->UpdateBrowserControlsState(BOTH, SHOWN, true); | 547 manager->UpdateBrowserControlsState(BOTH, SHOWN, true); |
551 EXPECT_FALSE(manager->has_animation()); | 548 EXPECT_FALSE(manager->has_animation()); |
552 EXPECT_FLOAT_EQ(1.f, client.CurrentBrowserControlsShownRatio()); | 549 EXPECT_FLOAT_EQ(1.f, client.CurrentBrowserControlsShownRatio()); |
553 } | 550 } |
554 | 551 |
555 } // namespace | 552 } // namespace |
556 } // namespace cc | 553 } // namespace cc |
OLD | NEW |