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 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.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_proxy.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" | 17 #include "cc/test/test_shared_bitmap_manager.h" |
18 #include "cc/test/test_task_graph_runner.h" | 18 #include "cc/test/test_task_graph_runner.h" |
19 #include "cc/trees/layer_tree_impl.h" | 19 #include "cc/trees/layer_tree_impl.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 20 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "ui/gfx/geometry/vector2d_f.h" | 21 #include "ui/gfx/geometry/vector2d_f.h" |
22 | 22 |
23 namespace cc { | 23 namespace cc { |
24 namespace { | 24 namespace { |
25 | 25 |
26 class MockTopControlsManagerClient : public TopControlsManagerClient { | 26 class MockTopControlsManagerClient : public TopControlsManagerClient { |
27 public: | 27 public: |
28 MockTopControlsManagerClient(float top_controls_height, | 28 MockTopControlsManagerClient(float top_controls_height, |
29 float top_controls_show_threshold, | 29 float top_controls_show_threshold, |
30 float top_controls_hide_threshold) | 30 float top_controls_hide_threshold) |
31 : host_impl_(&proxy_, &shared_bitmap_manager_, &task_graph_runner_), | 31 : host_impl_(&task_runner_provider_, |
| 32 &shared_bitmap_manager_, |
| 33 &task_graph_runner_), |
32 redraw_needed_(false), | 34 redraw_needed_(false), |
33 update_draw_properties_needed_(false), | 35 update_draw_properties_needed_(false), |
34 top_controls_shown_ratio_(1.f), | 36 top_controls_shown_ratio_(1.f), |
35 top_controls_height_(top_controls_height), | 37 top_controls_height_(top_controls_height), |
36 top_controls_show_threshold_(top_controls_show_threshold), | 38 top_controls_show_threshold_(top_controls_show_threshold), |
37 top_controls_hide_threshold_(top_controls_hide_threshold) { | 39 top_controls_hide_threshold_(top_controls_hide_threshold) { |
38 active_tree_ = LayerTreeImpl::create( | 40 active_tree_ = LayerTreeImpl::create( |
39 &host_impl_, new SyncedProperty<ScaleGroup>, new SyncedTopControls, | 41 &host_impl_, new SyncedProperty<ScaleGroup>, new SyncedTopControls, |
40 new SyncedElasticOverscroll); | 42 new SyncedElasticOverscroll); |
41 root_scroll_layer_ = LayerImpl::Create(active_tree_.get(), 1); | 43 root_scroll_layer_ = LayerImpl::Create(active_tree_.get(), 1); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 manager_ = TopControlsManager::Create(this, | 76 manager_ = TopControlsManager::Create(this, |
75 top_controls_show_threshold_, | 77 top_controls_show_threshold_, |
76 top_controls_hide_threshold_); | 78 top_controls_hide_threshold_); |
77 } | 79 } |
78 return manager_.get(); | 80 return manager_.get(); |
79 } | 81 } |
80 | 82 |
81 void SetTopControlsHeight(float height) { top_controls_height_ = height; } | 83 void SetTopControlsHeight(float height) { top_controls_height_ = height; } |
82 | 84 |
83 private: | 85 private: |
84 FakeImplProxy proxy_; | 86 FakeImplTaskRunnerProvider task_runner_provider_; |
85 TestSharedBitmapManager shared_bitmap_manager_; | 87 TestSharedBitmapManager shared_bitmap_manager_; |
86 TestTaskGraphRunner task_graph_runner_; | 88 TestTaskGraphRunner task_graph_runner_; |
87 FakeLayerTreeHostImpl host_impl_; | 89 FakeLayerTreeHostImpl host_impl_; |
88 scoped_ptr<LayerTreeImpl> active_tree_; | 90 scoped_ptr<LayerTreeImpl> active_tree_; |
89 scoped_ptr<LayerImpl> root_scroll_layer_; | 91 scoped_ptr<LayerImpl> root_scroll_layer_; |
90 scoped_ptr<TopControlsManager> manager_; | 92 scoped_ptr<TopControlsManager> manager_; |
91 bool redraw_needed_; | 93 bool redraw_needed_; |
92 bool update_draw_properties_needed_; | 94 bool update_draw_properties_needed_; |
93 | 95 |
94 float top_controls_shown_ratio_; | 96 float top_controls_shown_ratio_; |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 EXPECT_FLOAT_EQ(20.f, pending.y()); | 464 EXPECT_FLOAT_EQ(20.f, pending.y()); |
463 EXPECT_FLOAT_EQ(0.f, manager->ControlsTopOffset()); | 465 EXPECT_FLOAT_EQ(0.f, manager->ControlsTopOffset()); |
464 EXPECT_FLOAT_EQ(0.f, manager->ContentTopOffset()); | 466 EXPECT_FLOAT_EQ(0.f, manager->ContentTopOffset()); |
465 EXPECT_FLOAT_EQ(1.f, client.CurrentTopControlsShownRatio()); | 467 EXPECT_FLOAT_EQ(1.f, client.CurrentTopControlsShownRatio()); |
466 manager->ScrollEnd(); | 468 manager->ScrollEnd(); |
467 } | 469 } |
468 | 470 |
469 | 471 |
470 } // namespace | 472 } // namespace |
471 } // namespace cc | 473 } // namespace cc |
OLD | NEW |