Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(176)

Side by Side Diff: cc/top_controls_manager_unittest.cc

Issue 12025031: Find root scroll layer at tree activation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« cc/layer_tree_impl.cc ('K') | « cc/top_controls_manager_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/top_controls_manager.h" 5 #include "cc/top_controls_manager.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "base/time.h" 8 #include "base/time.h"
9 #include "cc/layer_impl.h" 9 #include "cc/layer_impl.h"
10 #include "cc/layer_tree_impl.h" 10 #include "cc/layer_tree_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/top_controls_manager_client.h" 13 #include "cc/top_controls_manager_client.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "ui/gfx/vector2d_f.h" 15 #include "ui/gfx/vector2d_f.h"
16 16
17 namespace cc { 17 namespace cc {
18 namespace { 18 namespace {
19 19
20 static const float kTopControlsHeight = 100; 20 static const float kTopControlsHeight = 100;
21 21
22 class MockTopControlsManagerClient : public TopControlsManagerClient { 22 class MockTopControlsManagerClient : public TopControlsManagerClient {
23 public: 23 public:
24 MockTopControlsManagerClient() 24 MockTopControlsManagerClient()
25 : host_impl_(&proxy_), 25 : host_impl_(&proxy_),
26 redraw_needed_(false), 26 redraw_needed_(false),
27 update_draw_properties_needed_(false) { 27 update_draw_properties_needed_(false) {
28 active_tree_ = LayerTreeImpl::create(&host_impl_); 28 active_tree_ = LayerTreeImpl::create(&host_impl_);
29 root_scroll_layer_ = LayerImpl::create(active_tree_.get(), 1); 29 root_scroll_layer_ = LayerImpl::create(active_tree_.get(), 1);
30 active_tree_->set_root_scroll_layer(root_scroll_layer_.get());
31 } 30 }
32 31
33 virtual ~MockTopControlsManagerClient() {} 32 virtual ~MockTopControlsManagerClient() {}
34 33
35 virtual void setNeedsRedraw() OVERRIDE { 34 virtual void setNeedsRedraw() OVERRIDE {
36 redraw_needed_ = true; 35 redraw_needed_ = true;
37 } 36 }
38 37
39 virtual void setNeedsUpdateDrawProperties() OVERRIDE { 38 virtual void setNeedsUpdateDrawProperties() OVERRIDE {
40 update_draw_properties_needed_ = true; 39 update_draw_properties_needed_ = true;
41 } 40 }
42 41
43 virtual LayerTreeImpl* activeTree() OVERRIDE { 42 virtual bool haveRootScrollLayer() const OVERRIDE {
44 return active_tree_.get(); 43 return true;
44 }
45
46 virtual float rootScrollLayerTotalScrollY() const OVERRIDE {
47 return root_scroll_layer_->scrollOffset().y() +
48 root_scroll_layer_->scrollDelta().y();
49 }
50
51 LayerImpl* rootScrollLayer() {
52 return root_scroll_layer_.get();
45 } 53 }
46 54
47 TopControlsManager* manager() { 55 TopControlsManager* manager() {
48 if (!manager_) 56 if (!manager_)
49 manager_ = TopControlsManager::Create(this, kTopControlsHeight); 57 manager_ = TopControlsManager::Create(this, kTopControlsHeight);
50 return manager_.get(); 58 return manager_.get();
51 } 59 }
52 60
53 LayerImpl* rootScrollLayer() {
54 return root_scroll_layer_.get();
55 }
56
57 private: 61 private:
58 FakeImplProxy proxy_; 62 FakeImplProxy proxy_;
59 FakeLayerTreeHostImpl host_impl_; 63 FakeLayerTreeHostImpl host_impl_;
60 scoped_ptr<LayerTreeImpl> active_tree_; 64 scoped_ptr<LayerTreeImpl> active_tree_;
61 scoped_ptr<LayerImpl> root_scroll_layer_; 65 scoped_ptr<LayerImpl> root_scroll_layer_;
62 scoped_ptr<TopControlsManager> manager_; 66 scoped_ptr<TopControlsManager> manager_;
63 bool redraw_needed_; 67 bool redraw_needed_;
64 bool update_draw_properties_needed_; 68 bool update_draw_properties_needed_;
65 }; 69 };
66 70
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 previous_offset = manager->controls_top_offset(); 198 previous_offset = manager->controls_top_offset();
195 } 199 }
196 EXPECT_FALSE(manager->animation()); 200 EXPECT_FALSE(manager->animation());
197 EXPECT_EQ(0.f, manager->controls_top_offset()); 201 EXPECT_EQ(0.f, manager->controls_top_offset());
198 EXPECT_EQ(0.f, manager->content_top_offset()); 202 EXPECT_EQ(0.f, manager->content_top_offset());
199 EXPECT_TRUE(manager->is_overlay_mode()); 203 EXPECT_TRUE(manager->is_overlay_mode());
200 } 204 }
201 205
202 } // namespace 206 } // namespace
203 } // namespace cc 207 } // namespace cc
OLDNEW
« cc/layer_tree_impl.cc ('K') | « cc/top_controls_manager_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698