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

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
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 LayerImpl* rootScrollLayer() const OVERRIDE {
44 return active_tree_.get(); 43 return root_scroll_layer_.get();
45 } 44 }
46 45
47 TopControlsManager* manager() { 46 TopControlsManager* manager() {
48 if (!manager_) 47 if (!manager_)
49 manager_ = TopControlsManager::Create(this, kTopControlsHeight); 48 manager_ = TopControlsManager::Create(this, kTopControlsHeight);
50 return manager_.get(); 49 return manager_.get();
51 } 50 }
52 51
53 LayerImpl* rootScrollLayer() {
54 return root_scroll_layer_.get();
55 }
56
57 private: 52 private:
58 FakeImplProxy proxy_; 53 FakeImplProxy proxy_;
59 FakeLayerTreeHostImpl host_impl_; 54 FakeLayerTreeHostImpl host_impl_;
60 scoped_ptr<LayerTreeImpl> active_tree_; 55 scoped_ptr<LayerTreeImpl> active_tree_;
61 scoped_ptr<LayerImpl> root_scroll_layer_; 56 scoped_ptr<LayerImpl> root_scroll_layer_;
62 scoped_ptr<TopControlsManager> manager_; 57 scoped_ptr<TopControlsManager> manager_;
63 bool redraw_needed_; 58 bool redraw_needed_;
64 bool update_draw_properties_needed_; 59 bool update_draw_properties_needed_;
65 }; 60 };
66 61
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 previous_offset = manager->controls_top_offset(); 189 previous_offset = manager->controls_top_offset();
195 } 190 }
196 EXPECT_FALSE(manager->animation()); 191 EXPECT_FALSE(manager->animation());
197 EXPECT_EQ(0.f, manager->controls_top_offset()); 192 EXPECT_EQ(0.f, manager->controls_top_offset());
198 EXPECT_EQ(0.f, manager->content_top_offset()); 193 EXPECT_EQ(0.f, manager->content_top_offset());
199 EXPECT_TRUE(manager->is_overlay_mode()); 194 EXPECT_TRUE(manager->is_overlay_mode());
200 } 195 }
201 196
202 } // namespace 197 } // namespace
203 } // namespace cc 198 } // namespace cc
OLDNEW
« cc/top_controls_manager_client.h ('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