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

Side by Side Diff: cc/top_controls_manager_unittest.cc

Issue 11953040: Add a scroll threshold/marker to control hiding/showing top controls. (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
« no previous file with comments | « cc/top_controls_manager.cc ('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"
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 client.rootScrollLayer()->scrollDelta() + remaining_scroll); 134 client.rootScrollLayer()->scrollDelta() + remaining_scroll);
135 135
136 remaining_scroll = manager->ScrollBy(gfx::Vector2dF(0.f, -50.f)); 136 remaining_scroll = manager->ScrollBy(gfx::Vector2dF(0.f, -50.f));
137 EXPECT_EQ(0.f, manager->controls_top_offset()); 137 EXPECT_EQ(0.f, manager->controls_top_offset());
138 EXPECT_EQ(100.f, manager->content_top_offset()); 138 EXPECT_EQ(100.f, manager->content_top_offset());
139 EXPECT_FALSE(manager->is_overlay_mode()); 139 EXPECT_FALSE(manager->is_overlay_mode());
140 client.rootScrollLayer()->setScrollDelta( 140 client.rootScrollLayer()->setScrollDelta(
141 client.rootScrollLayer()->scrollDelta() + remaining_scroll); 141 client.rootScrollLayer()->scrollDelta() + remaining_scroll);
142 } 142 }
143 143
144 TEST(TopControlsManagerTest, enssureScrollThresholdApplied) {
jamesr 2013/01/24 22:05:29 typo "enssure" -> "ensure"
Ted C 2013/01/24 23:56:01 Done.
145 MockTopControlsManagerClient client;
146 TopControlsManager* manager = client.manager();
147 client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 200));
148
149 manager->ScrollBegin();
150
151 // Scroll down to hide the controls entirely.
152 manager->ScrollBy(gfx::Vector2dF(0.f, 30.f));
153 EXPECT_EQ(-30.f, manager->controls_top_offset());
154 EXPECT_EQ(70.f, manager->content_top_offset());
155 client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 230));
156
157 manager->ScrollBy(gfx::Vector2dF(0.f, 30.f));
158 EXPECT_EQ(-60.f, manager->controls_top_offset());
159 EXPECT_EQ(40.f, manager->content_top_offset());
160 client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 260));
161
162 manager->ScrollBy(gfx::Vector2dF(0.f, 100.f));
163 EXPECT_EQ(-100.f, manager->controls_top_offset());
164 EXPECT_EQ(0.f, manager->content_top_offset());
165 client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 360));
166
167 // Scroll back up a bit and ensure the controls don't move until we cross
168 // the threshold.
169 manager->ScrollBy(gfx::Vector2dF(0.f, -10.f));
170 EXPECT_EQ(-100.f, manager->controls_top_offset());
171 EXPECT_EQ(0.f, manager->content_top_offset());
172 client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 350));
173
174 manager->ScrollBy(gfx::Vector2dF(0.f, -50.f));
175 EXPECT_EQ(-100.f, manager->controls_top_offset());
176 EXPECT_EQ(0.f, manager->content_top_offset());
177 client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 300));
178
179 // After hitting the threshold, further scrolling up should result in the top
180 // controls showing.
181 manager->ScrollBy(gfx::Vector2dF(0.f, -10.f));
182 EXPECT_EQ(-90.f, manager->controls_top_offset());
183 EXPECT_EQ(0.f, manager->content_top_offset());
184 client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 290));
185
186 manager->ScrollBy(gfx::Vector2dF(0.f, -50.f));
187 EXPECT_EQ(-40.f, manager->controls_top_offset());
188 EXPECT_EQ(0.f, manager->content_top_offset());
189 client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 240));
190
191 manager->ScrollEnd();
192 }
193
144 TEST(TopControlsManagerTest, partialShownHideAnimation) { 194 TEST(TopControlsManagerTest, partialShownHideAnimation) {
145 MockTopControlsManagerClient client; 195 MockTopControlsManagerClient client;
146 TopControlsManager* manager = client.manager(); 196 TopControlsManager* manager = client.manager();
147 client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 300)); 197 client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 300));
148 manager->ScrollBy(gfx::Vector2dF(0.f, 300.f)); 198 manager->ScrollBy(gfx::Vector2dF(0.f, 300.f));
149 EXPECT_EQ(-100.f, manager->controls_top_offset()); 199 EXPECT_EQ(-100.f, manager->controls_top_offset());
150 EXPECT_EQ(0.f, manager->content_top_offset()); 200 EXPECT_EQ(0.f, manager->content_top_offset());
151 EXPECT_TRUE(manager->is_overlay_mode()); 201 EXPECT_TRUE(manager->is_overlay_mode());
152 202
153 client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 270)); 203 client.rootScrollLayer()->setScrollOffset(gfx::Vector2d(0, 270));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 previous_offset = manager->controls_top_offset(); 250 previous_offset = manager->controls_top_offset();
201 } 251 }
202 EXPECT_FALSE(manager->animation()); 252 EXPECT_FALSE(manager->animation());
203 EXPECT_EQ(0.f, manager->controls_top_offset()); 253 EXPECT_EQ(0.f, manager->controls_top_offset());
204 EXPECT_EQ(0.f, manager->content_top_offset()); 254 EXPECT_EQ(0.f, manager->content_top_offset());
205 EXPECT_TRUE(manager->is_overlay_mode()); 255 EXPECT_TRUE(manager->is_overlay_mode());
206 } 256 }
207 257
208 } // namespace 258 } // namespace
209 } // namespace cc 259 } // namespace cc
OLDNEW
« no previous file with comments | « cc/top_controls_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698