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 "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/time/time.h" | 8 #include "base/time/time.h" |
9 #include "cc/input/top_controls_manager_client.h" | 9 #include "cc/input/top_controls_manager_client.h" |
10 #include "cc/layers/layer_impl.h" | 10 #include "cc/layers/layer_impl.h" |
11 #include "cc/test/fake_impl_proxy.h" | 11 #include "cc/test/fake_impl_proxy.h" |
12 #include "cc/test/fake_layer_tree_host_impl.h" | 12 #include "cc/test/fake_layer_tree_host_impl.h" |
| 13 #include "cc/test/test_shared_bitmap_manager.h" |
13 #include "cc/trees/layer_tree_impl.h" | 14 #include "cc/trees/layer_tree_impl.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "ui/gfx/frame_time.h" | 16 #include "ui/gfx/frame_time.h" |
16 #include "ui/gfx/vector2d_f.h" | 17 #include "ui/gfx/vector2d_f.h" |
17 | 18 |
18 namespace cc { | 19 namespace cc { |
19 namespace { | 20 namespace { |
20 | 21 |
21 static const float kTopControlsHeight = 100; | 22 static const float kTopControlsHeight = 100; |
22 | 23 |
23 class MockTopControlsManagerClient : public TopControlsManagerClient { | 24 class MockTopControlsManagerClient : public TopControlsManagerClient { |
24 public: | 25 public: |
25 MockTopControlsManagerClient(float top_controls_show_threshold, | 26 MockTopControlsManagerClient(float top_controls_show_threshold, |
26 float top_controls_hide_threshold) | 27 float top_controls_hide_threshold) |
27 : host_impl_(&proxy_), | 28 : host_impl_(&proxy_, &shared_bitmap_manager_), |
28 redraw_needed_(false), | 29 redraw_needed_(false), |
29 update_draw_properties_needed_(false), | 30 update_draw_properties_needed_(false), |
30 top_controls_show_threshold_(top_controls_show_threshold), | 31 top_controls_show_threshold_(top_controls_show_threshold), |
31 top_controls_hide_threshold_(top_controls_hide_threshold) { | 32 top_controls_hide_threshold_(top_controls_hide_threshold) { |
32 active_tree_ = LayerTreeImpl::create(&host_impl_); | 33 active_tree_ = LayerTreeImpl::create(&host_impl_); |
33 root_scroll_layer_ = LayerImpl::Create(active_tree_.get(), 1); | 34 root_scroll_layer_ = LayerImpl::Create(active_tree_.get(), 1); |
34 } | 35 } |
35 | 36 |
36 virtual ~MockTopControlsManagerClient() {} | 37 virtual ~MockTopControlsManagerClient() {} |
37 | 38 |
(...skipping 15 matching lines...) Expand all Loading... |
53 manager_ = TopControlsManager::Create(this, | 54 manager_ = TopControlsManager::Create(this, |
54 kTopControlsHeight, | 55 kTopControlsHeight, |
55 top_controls_show_threshold_, | 56 top_controls_show_threshold_, |
56 top_controls_hide_threshold_); | 57 top_controls_hide_threshold_); |
57 } | 58 } |
58 return manager_.get(); | 59 return manager_.get(); |
59 } | 60 } |
60 | 61 |
61 private: | 62 private: |
62 FakeImplProxy proxy_; | 63 FakeImplProxy proxy_; |
| 64 TestSharedBitmapManager shared_bitmap_manager_; |
63 FakeLayerTreeHostImpl host_impl_; | 65 FakeLayerTreeHostImpl host_impl_; |
64 scoped_ptr<LayerTreeImpl> active_tree_; | 66 scoped_ptr<LayerTreeImpl> active_tree_; |
65 scoped_ptr<LayerImpl> root_scroll_layer_; | 67 scoped_ptr<LayerImpl> root_scroll_layer_; |
66 scoped_ptr<TopControlsManager> manager_; | 68 scoped_ptr<TopControlsManager> manager_; |
67 bool redraw_needed_; | 69 bool redraw_needed_; |
68 bool update_draw_properties_needed_; | 70 bool update_draw_properties_needed_; |
69 | 71 |
70 float top_controls_show_threshold_; | 72 float top_controls_show_threshold_; |
71 float top_controls_hide_threshold_; | 73 float top_controls_hide_threshold_; |
72 }; | 74 }; |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 manager->Animate(time); | 367 manager->Animate(time); |
366 EXPECT_GT(manager->controls_top_offset(), previous_offset); | 368 EXPECT_GT(manager->controls_top_offset(), previous_offset); |
367 previous_offset = manager->controls_top_offset(); | 369 previous_offset = manager->controls_top_offset(); |
368 } | 370 } |
369 EXPECT_FALSE(manager->animation()); | 371 EXPECT_FALSE(manager->animation()); |
370 EXPECT_EQ(0.f, manager->controls_top_offset()); | 372 EXPECT_EQ(0.f, manager->controls_top_offset()); |
371 } | 373 } |
372 | 374 |
373 } // namespace | 375 } // namespace |
374 } // namespace cc | 376 } // namespace cc |
OLD | NEW |