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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 206793003: cc: Split animating and drawing into separate actions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix input handler proxy test build. Created 6 years, 7 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/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 public: 78 public:
79 LayerTreeHostImplTest() 79 LayerTreeHostImplTest()
80 : proxy_(base::MessageLoopProxy::current()), 80 : proxy_(base::MessageLoopProxy::current()),
81 always_impl_thread_(&proxy_), 81 always_impl_thread_(&proxy_),
82 always_main_thread_blocked_(&proxy_), 82 always_main_thread_blocked_(&proxy_),
83 shared_bitmap_manager_(new TestSharedBitmapManager()), 83 shared_bitmap_manager_(new TestSharedBitmapManager()),
84 on_can_draw_state_changed_called_(false), 84 on_can_draw_state_changed_called_(false),
85 did_notify_ready_to_activate_(false), 85 did_notify_ready_to_activate_(false),
86 did_request_commit_(false), 86 did_request_commit_(false),
87 did_request_redraw_(false), 87 did_request_redraw_(false),
88 did_request_animate_(false),
88 did_request_manage_tiles_(false), 89 did_request_manage_tiles_(false),
89 did_upload_visible_tile_(false), 90 did_upload_visible_tile_(false),
90 reduce_memory_result_(true), 91 reduce_memory_result_(true),
91 current_limit_bytes_(0), 92 current_limit_bytes_(0),
92 current_priority_cutoff_value_(0) { 93 current_priority_cutoff_value_(0) {
93 media::InitializeMediaLibraryForTesting(); 94 media::InitializeMediaLibraryForTesting();
94 } 95 }
95 96
96 LayerTreeSettings DefaultSettings() { 97 LayerTreeSettings DefaultSettings() {
97 LayerTreeSettings settings; 98 LayerTreeSettings settings;
(...skipping 26 matching lines...) Expand all
124 did_notify_ready_to_activate_ = true; 125 did_notify_ready_to_activate_ = true;
125 host_impl_->ActivatePendingTree(); 126 host_impl_->ActivatePendingTree();
126 } 127 }
127 virtual void SetNeedsRedrawOnImplThread() OVERRIDE { 128 virtual void SetNeedsRedrawOnImplThread() OVERRIDE {
128 did_request_redraw_ = true; 129 did_request_redraw_ = true;
129 } 130 }
130 virtual void SetNeedsRedrawRectOnImplThread( 131 virtual void SetNeedsRedrawRectOnImplThread(
131 const gfx::Rect& damage_rect) OVERRIDE { 132 const gfx::Rect& damage_rect) OVERRIDE {
132 did_request_redraw_ = true; 133 did_request_redraw_ = true;
133 } 134 }
135 virtual void SetNeedsAnimateOnImplThread() OVERRIDE {
136 did_request_animate_ = true;
137 }
134 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE { 138 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE {
135 did_request_manage_tiles_ = true; 139 did_request_manage_tiles_ = true;
136 } 140 }
137 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE { 141 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE {
138 did_upload_visible_tile_ = true; 142 did_upload_visible_tile_ = true;
139 } 143 }
140 virtual void SetNeedsCommitOnImplThread() OVERRIDE { 144 virtual void SetNeedsCommitOnImplThread() OVERRIDE {
141 did_request_commit_ = true; 145 did_request_commit_ = true;
142 } 146 }
143 virtual void PostAnimationEventsToMainThreadOnImplThread( 147 virtual void PostAnimationEventsToMainThreadOnImplThread(
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 DebugScopedSetImplThread always_impl_thread_; 393 DebugScopedSetImplThread always_impl_thread_;
390 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; 394 DebugScopedSetMainThreadBlocked always_main_thread_blocked_;
391 395
392 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; 396 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_;
393 scoped_ptr<LayerTreeHostImpl> host_impl_; 397 scoped_ptr<LayerTreeHostImpl> host_impl_;
394 FakeRenderingStatsInstrumentation stats_instrumentation_; 398 FakeRenderingStatsInstrumentation stats_instrumentation_;
395 bool on_can_draw_state_changed_called_; 399 bool on_can_draw_state_changed_called_;
396 bool did_notify_ready_to_activate_; 400 bool did_notify_ready_to_activate_;
397 bool did_request_commit_; 401 bool did_request_commit_;
398 bool did_request_redraw_; 402 bool did_request_redraw_;
403 bool did_request_animate_;
399 bool did_request_manage_tiles_; 404 bool did_request_manage_tiles_;
400 bool did_upload_visible_tile_; 405 bool did_upload_visible_tile_;
401 bool reduce_memory_result_; 406 bool reduce_memory_result_;
402 base::TimeDelta requested_scrollbar_animation_delay_; 407 base::TimeDelta requested_scrollbar_animation_delay_;
403 size_t current_limit_bytes_; 408 size_t current_limit_bytes_;
404 int current_priority_cutoff_value_; 409 int current_priority_cutoff_value_;
405 }; 410 };
406 411
407 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { 412 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) {
408 bool always_draw = false; 413 bool always_draw = false;
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
897 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); 902 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture);
898 host_impl_->PinchGestureBegin(); 903 host_impl_->PinchGestureBegin();
899 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); 904 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50));
900 // While the gesture is still active, the scroll layer should have a 905 // While the gesture is still active, the scroll layer should have a
901 // container size delta = container->bounds() * ((1.f - 906 // container size delta = container->bounds() * ((1.f -
902 // page_scale_delta)/()) 907 // page_scale_delta)/())
903 EXPECT_EQ(expected_container_size_delta, 908 EXPECT_EQ(expected_container_size_delta,
904 scroll_layer->FixedContainerSizeDelta()); 909 scroll_layer->FixedContainerSizeDelta());
905 host_impl_->PinchGestureEnd(); 910 host_impl_->PinchGestureEnd();
906 host_impl_->ScrollEnd(); 911 host_impl_->ScrollEnd();
912 EXPECT_FALSE(did_request_animate_);
907 EXPECT_TRUE(did_request_redraw_); 913 EXPECT_TRUE(did_request_redraw_);
908 EXPECT_TRUE(did_request_commit_); 914 EXPECT_TRUE(did_request_commit_);
909 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); 915 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds());
910 916
911 scoped_ptr<ScrollAndScaleSet> scroll_info = 917 scoped_ptr<ScrollAndScaleSet> scroll_info =
912 host_impl_->ProcessScrollDeltas(); 918 host_impl_->ProcessScrollDeltas();
913 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 919 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
914 920
915 EXPECT_EQ(gfx::Vector2d(75, 75).ToString(), 921 EXPECT_EQ(gfx::Vector2d(75, 75).ToString(),
916 scroll_layer->MaxScrollOffset().ToString()); 922 scroll_layer->MaxScrollOffset().ToString());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
963 min_page_scale, 969 min_page_scale,
964 max_page_scale); 970 max_page_scale);
965 scroll_layer->SetScrollDelta(gfx::Vector2d()); 971 scroll_layer->SetScrollDelta(gfx::Vector2d());
966 972
967 float page_scale_delta = 2.f; 973 float page_scale_delta = 2.f;
968 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); 974 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture);
969 host_impl_->PinchGestureBegin(); 975 host_impl_->PinchGestureBegin();
970 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); 976 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50));
971 host_impl_->PinchGestureEnd(); 977 host_impl_->PinchGestureEnd();
972 host_impl_->ScrollEnd(); 978 host_impl_->ScrollEnd();
979 EXPECT_FALSE(did_request_animate_);
973 EXPECT_TRUE(did_request_redraw_); 980 EXPECT_TRUE(did_request_redraw_);
974 EXPECT_TRUE(did_request_commit_); 981 EXPECT_TRUE(did_request_commit_);
975 982
976 scoped_ptr<ScrollAndScaleSet> scroll_info = 983 scoped_ptr<ScrollAndScaleSet> scroll_info =
977 host_impl_->ProcessScrollDeltas(); 984 host_impl_->ProcessScrollDeltas();
978 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); 985 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta);
979 } 986 }
980 987
981 // Zoom-in clamping 988 // Zoom-in clamping
982 { 989 {
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 base::TimeTicks halfway_through_animation = start_time + duration / 2; 1111 base::TimeTicks halfway_through_animation = start_time + duration / 2;
1105 base::TimeTicks end_time = start_time + duration; 1112 base::TimeTicks end_time = start_time + duration;
1106 1113
1107 // Non-anchor zoom-in 1114 // Non-anchor zoom-in
1108 { 1115 {
1109 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1116 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
1110 min_page_scale, 1117 min_page_scale,
1111 max_page_scale); 1118 max_page_scale);
1112 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); 1119 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50));
1113 1120
1121 did_request_redraw_ = false;
1122 did_request_animate_ = false;
1114 host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration); 1123 host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration);
1124 EXPECT_FALSE(did_request_redraw_);
1125 EXPECT_TRUE(did_request_animate_);
1126
1115 did_request_redraw_ = false; 1127 did_request_redraw_ = false;
1128 did_request_animate_ = false;
1116 host_impl_->Animate(start_time); 1129 host_impl_->Animate(start_time);
1117 EXPECT_TRUE(did_request_redraw_); 1130 EXPECT_TRUE(did_request_redraw_);
1131 EXPECT_TRUE(did_request_animate_);
1118 1132
1119 did_request_redraw_ = false; 1133 did_request_redraw_ = false;
1134 did_request_animate_ = false;
1120 host_impl_->Animate(halfway_through_animation); 1135 host_impl_->Animate(halfway_through_animation);
1121 EXPECT_TRUE(did_request_redraw_); 1136 EXPECT_TRUE(did_request_redraw_);
1137 EXPECT_TRUE(did_request_animate_);
1122 1138
1123 did_request_redraw_ = false; 1139 did_request_redraw_ = false;
1140 did_request_animate_ = false;
1124 did_request_commit_ = false; 1141 did_request_commit_ = false;
1125 host_impl_->Animate(end_time); 1142 host_impl_->Animate(end_time);
1126 EXPECT_TRUE(did_request_commit_); 1143 EXPECT_TRUE(did_request_commit_);
1144 EXPECT_FALSE(did_request_animate_);
1127 1145
1128 scoped_ptr<ScrollAndScaleSet> scroll_info = 1146 scoped_ptr<ScrollAndScaleSet> scroll_info =
1129 host_impl_->ProcessScrollDeltas(); 1147 host_impl_->ProcessScrollDeltas();
1130 EXPECT_EQ(scroll_info->page_scale_delta, 2); 1148 EXPECT_EQ(scroll_info->page_scale_delta, 2);
1131 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); 1149 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50));
1132 } 1150 }
1133 1151
1134 // Anchor zoom-out 1152 // Anchor zoom-out
1135 { 1153 {
1136 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1154 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f,
1137 min_page_scale, 1155 min_page_scale,
1138 max_page_scale); 1156 max_page_scale);
1139 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); 1157 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50));
1140 1158
1159 did_request_redraw_ = false;
1160 did_request_animate_ = false;
1141 host_impl_->StartPageScaleAnimation( 1161 host_impl_->StartPageScaleAnimation(
1142 gfx::Vector2d(25, 25), true, min_page_scale, duration); 1162 gfx::Vector2d(25, 25), true, min_page_scale, duration);
1163 EXPECT_FALSE(did_request_redraw_);
1164 EXPECT_TRUE(did_request_animate_);
1165
1143 did_request_redraw_ = false; 1166 did_request_redraw_ = false;
1167 did_request_animate_ = false;
1144 host_impl_->Animate(start_time); 1168 host_impl_->Animate(start_time);
1145 EXPECT_TRUE(did_request_redraw_); 1169 EXPECT_TRUE(did_request_redraw_);
1170 EXPECT_TRUE(did_request_animate_);
1146 1171
1147 did_request_redraw_ = false; 1172 did_request_redraw_ = false;
1148 did_request_commit_ = false; 1173 did_request_commit_ = false;
1174 did_request_animate_ = false;
1149 host_impl_->Animate(end_time); 1175 host_impl_->Animate(end_time);
1150 EXPECT_TRUE(did_request_redraw_); 1176 EXPECT_TRUE(did_request_redraw_);
1177 EXPECT_FALSE(did_request_animate_);
1151 EXPECT_TRUE(did_request_commit_); 1178 EXPECT_TRUE(did_request_commit_);
1152 1179
1153 scoped_ptr<ScrollAndScaleSet> scroll_info = 1180 scoped_ptr<ScrollAndScaleSet> scroll_info =
1154 host_impl_->ProcessScrollDeltas(); 1181 host_impl_->ProcessScrollDeltas();
1155 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); 1182 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale);
1156 // Pushed to (0,0) via clamping against contents layer size. 1183 // Pushed to (0,0) via clamping against contents layer size.
1157 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); 1184 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50));
1158 } 1185 }
1159 } 1186 }
1160 1187
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1294 host_impl_->ScrollEnd(); 1321 host_impl_->ScrollEnd();
1295 host_impl_->StartScrollbarAnimation(); 1322 host_impl_->StartScrollbarAnimation();
1296 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); 1323 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
1297 EXPECT_FALSE(did_request_redraw_); 1324 EXPECT_FALSE(did_request_redraw_);
1298 1325
1299 // After a scroll, a fade animation should be scheduled about 20ms from now. 1326 // After a scroll, a fade animation should be scheduled about 20ms from now.
1300 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); 1327 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel);
1301 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); 1328 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0));
1302 host_impl_->ScrollEnd(); 1329 host_impl_->ScrollEnd();
1303 did_request_redraw_ = false; 1330 did_request_redraw_ = false;
1331 did_request_animate_ = false;
1304 host_impl_->StartScrollbarAnimation(); 1332 host_impl_->StartScrollbarAnimation();
1305 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), 1333 EXPECT_LT(base::TimeDelta::FromMilliseconds(19),
1306 requested_scrollbar_animation_delay_); 1334 requested_scrollbar_animation_delay_);
1307 EXPECT_FALSE(did_request_redraw_); 1335 EXPECT_FALSE(did_request_redraw_);
1336 EXPECT_FALSE(did_request_animate_);
1308 requested_scrollbar_animation_delay_ = base::TimeDelta(); 1337 requested_scrollbar_animation_delay_ = base::TimeDelta();
1309 1338
1310 // After the fade begins, we should start getting redraws instead of a 1339 // After the fade begins, we should start getting redraws instead of a
1311 // scheduled animation. 1340 // scheduled animation.
1312 fake_now += base::TimeDelta::FromMilliseconds(25); 1341 fake_now += base::TimeDelta::FromMilliseconds(25);
1313 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); 1342 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
1314 host_impl_->StartScrollbarAnimation(); 1343 host_impl_->StartScrollbarAnimation();
1315 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); 1344 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
1316 EXPECT_TRUE(did_request_redraw_); 1345 EXPECT_TRUE(did_request_animate_);
1317 did_request_redraw_ = false; 1346 did_request_animate_ = false;
1318 1347
1319 // If no scroll happened recently, StartScrollbarAnimation should have no 1348 // If no scroll happened recently, StartScrollbarAnimation should have no
1320 // effect. 1349 // effect.
1321 fake_now += base::TimeDelta::FromMilliseconds(25); 1350 fake_now += base::TimeDelta::FromMilliseconds(25);
1322 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); 1351 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
1323 host_impl_->StartScrollbarAnimation(); 1352 host_impl_->StartScrollbarAnimation();
1324 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); 1353 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
1325 EXPECT_FALSE(did_request_redraw_); 1354 EXPECT_FALSE(did_request_redraw_);
1326 1355
1327 // Setting the scroll offset outside a scroll should also cause the scrollbar 1356 // Setting the scroll offset outside a scroll should also cause the scrollbar
1328 // to appear and to schedule a fade. 1357 // to appear and to schedule a fade.
1329 host_impl_->InnerViewportScrollLayer()->SetScrollOffset(gfx::Vector2d(5, 5)); 1358 host_impl_->InnerViewportScrollLayer()->SetScrollOffset(gfx::Vector2d(5, 5));
1330 host_impl_->StartScrollbarAnimation(); 1359 host_impl_->StartScrollbarAnimation();
1331 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), 1360 EXPECT_LT(base::TimeDelta::FromMilliseconds(19),
1332 requested_scrollbar_animation_delay_); 1361 requested_scrollbar_animation_delay_);
1333 EXPECT_FALSE(did_request_redraw_); 1362 EXPECT_FALSE(did_request_redraw_);
1363 EXPECT_FALSE(did_request_animate_);
1334 requested_scrollbar_animation_delay_ = base::TimeDelta(); 1364 requested_scrollbar_animation_delay_ = base::TimeDelta();
1335 1365
1336 // None of the above should have called CurrentFrameTimeTicks, so if we call 1366 // None of the above should have called CurrentFrameTimeTicks, so if we call
1337 // it now we should get the current time. 1367 // it now we should get the current time.
1338 fake_now += base::TimeDelta::FromMilliseconds(10); 1368 fake_now += base::TimeDelta::FromMilliseconds(10);
1339 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); 1369 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
1340 EXPECT_EQ(fake_now, host_impl_->CurrentFrameTimeTicks()); 1370 EXPECT_EQ(fake_now, host_impl_->CurrentFrameTimeTicks());
1341 } 1371 }
1342 1372
1343 TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { 1373 TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) {
1344 LayerTreeSettings settings; 1374 LayerTreeSettings settings;
1345 settings.scrollbar_animator = LayerTreeSettings::LinearFade; 1375 settings.scrollbar_animator = LayerTreeSettings::LinearFade;
1346 settings.scrollbar_linear_fade_delay_ms = 20; 1376 settings.scrollbar_linear_fade_delay_ms = 20;
1347 settings.scrollbar_linear_fade_length_ms = 20; 1377 settings.scrollbar_linear_fade_length_ms = 20;
1348 settings.use_pinch_zoom_scrollbars = true; 1378 settings.use_pinch_zoom_scrollbars = true;
1349 1379
1350 SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); 1380 SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST();
1351 1381
1352 base::TimeTicks fake_now = gfx::FrameTime::Now(); 1382 base::TimeTicks fake_now = gfx::FrameTime::Now();
1353 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); 1383 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
1354 1384
1355 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); 1385 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f);
1356 1386
1357 // If no scroll happened recently, StartScrollbarAnimation should have no 1387 // If no scroll happened recently, StartScrollbarAnimation should have no
1358 // effect. 1388 // effect.
1359 host_impl_->StartScrollbarAnimation(); 1389 host_impl_->StartScrollbarAnimation();
1360 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); 1390 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
1361 EXPECT_FALSE(did_request_redraw_); 1391 EXPECT_FALSE(did_request_animate_);
1362 1392
1363 // If no scroll happened during a scroll gesture, StartScrollbarAnimation 1393 // If no scroll happened during a scroll gesture, StartScrollbarAnimation
1364 // should have no effect. 1394 // should have no effect.
1365 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); 1395 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel);
1366 host_impl_->ScrollEnd(); 1396 host_impl_->ScrollEnd();
1367 host_impl_->StartScrollbarAnimation(); 1397 host_impl_->StartScrollbarAnimation();
1368 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); 1398 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
1369 EXPECT_FALSE(did_request_redraw_); 1399 EXPECT_FALSE(did_request_animate_);
1370 1400
1371 // After a scroll, no fade animation should be scheduled. 1401 // After a scroll, no fade animation should be scheduled.
1372 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); 1402 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel);
1373 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); 1403 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0));
1374 host_impl_->ScrollEnd(); 1404 host_impl_->ScrollEnd();
1375 did_request_redraw_ = false; 1405 did_request_redraw_ = false;
1376 host_impl_->StartScrollbarAnimation(); 1406 host_impl_->StartScrollbarAnimation();
1377 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); 1407 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
1378 EXPECT_FALSE(did_request_redraw_); 1408 EXPECT_FALSE(did_request_animate_);
1379 requested_scrollbar_animation_delay_ = base::TimeDelta(); 1409 requested_scrollbar_animation_delay_ = base::TimeDelta();
1380 1410
1381 // We should not see any draw requests. 1411 // We should not see any draw requests.
1382 fake_now += base::TimeDelta::FromMilliseconds(25); 1412 fake_now += base::TimeDelta::FromMilliseconds(25);
1383 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); 1413 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
1384 host_impl_->StartScrollbarAnimation(); 1414 host_impl_->StartScrollbarAnimation();
1385 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); 1415 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
1386 EXPECT_FALSE(did_request_redraw_); 1416 EXPECT_FALSE(did_request_animate_);
1387 1417
1388 // Make page scale > min so that subsequent scrolls will trigger fades. 1418 // Make page scale > min so that subsequent scrolls will trigger fades.
1389 host_impl_->active_tree()->SetPageScaleDelta(1.1f); 1419 host_impl_->active_tree()->SetPageScaleDelta(1.1f);
1390 1420
1391 // After a scroll, a fade animation should be scheduled about 20ms from now. 1421 // After a scroll, a fade animation should be scheduled about 20ms from now.
1392 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); 1422 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel);
1393 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); 1423 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0));
1394 host_impl_->ScrollEnd(); 1424 host_impl_->ScrollEnd();
1395 did_request_redraw_ = false; 1425 did_request_redraw_ = false;
1396 host_impl_->StartScrollbarAnimation(); 1426 host_impl_->StartScrollbarAnimation();
1397 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), 1427 EXPECT_LT(base::TimeDelta::FromMilliseconds(19),
1398 requested_scrollbar_animation_delay_); 1428 requested_scrollbar_animation_delay_);
1399 EXPECT_FALSE(did_request_redraw_); 1429 EXPECT_FALSE(did_request_animate_);
1400 requested_scrollbar_animation_delay_ = base::TimeDelta(); 1430 requested_scrollbar_animation_delay_ = base::TimeDelta();
1401 1431
1402 // After the fade begins, we should start getting redraws instead of a 1432 // After the fade begins, we should start getting redraws instead of a
1403 // scheduled animation. 1433 // scheduled animation.
1404 fake_now += base::TimeDelta::FromMilliseconds(25); 1434 fake_now += base::TimeDelta::FromMilliseconds(25);
1405 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); 1435 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now);
1406 host_impl_->StartScrollbarAnimation(); 1436 host_impl_->StartScrollbarAnimation();
1407 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); 1437 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_);
1408 EXPECT_TRUE(did_request_redraw_); 1438 EXPECT_TRUE(did_request_animate_);
1409 } 1439 }
1410 1440
1411 void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( 1441 void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale(
1412 float device_scale_factor) { 1442 float device_scale_factor) {
1413 LayerTreeSettings settings; 1443 LayerTreeSettings settings;
1414 settings.scrollbar_animator = LayerTreeSettings::Thinning; 1444 settings.scrollbar_animator = LayerTreeSettings::Thinning;
1415 1445
1416 gfx::Size viewport_size(300, 200); 1446 gfx::Size viewport_size(300, 200);
1417 gfx::Size device_viewport_size = gfx::ToFlooredSize( 1447 gfx::Size device_viewport_size = gfx::ToFlooredSize(
1418 gfx::ScaleSize(viewport_size, device_scale_factor)); 1448 gfx::ScaleSize(viewport_size, device_scale_factor));
(...skipping 4785 matching lines...) Expand 10 before | Expand all | Expand 10 after
6204 6234
6205 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; 6235 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50;
6206 6236
6207 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { 6237 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) {
6208 SetupScrollAndContentsLayers(gfx::Size(100, 100)) 6238 SetupScrollAndContentsLayers(gfx::Size(100, 100))
6209 ->SetScrollOffset(gfx::Vector2d(0, 10)); 6239 ->SetScrollOffset(gfx::Vector2d(0, 10));
6210 host_impl_->Animate(base::TimeTicks()); 6240 host_impl_->Animate(base::TimeTicks());
6211 EXPECT_FALSE(did_request_redraw_); 6241 EXPECT_FALSE(did_request_redraw_);
6212 } 6242 }
6213 6243
6244 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationScheduling) {
6245 SetupScrollAndContentsLayers(gfx::Size(100, 100))
6246 ->SetScrollOffset(gfx::Vector2d(0, 10));
6247 host_impl_->DidChangeTopControlsPosition();
6248 EXPECT_TRUE(did_request_animate_);
6249 EXPECT_TRUE(did_request_redraw_);
6250 }
6251
6214 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) { 6252 TEST_F(LayerTreeHostImplWithTopControlsTest, ScrollHandledByTopControls) {
6215 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); 6253 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
6216 host_impl_->SetViewportSize(gfx::Size(100, 100)); 6254 host_impl_->SetViewportSize(gfx::Size(100, 100));
6217 DrawFrame(); 6255 DrawFrame();
6218 6256
6219 EXPECT_EQ(InputHandler::ScrollStarted, 6257 EXPECT_EQ(InputHandler::ScrollStarted,
6220 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture)); 6258 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Gesture));
6221 EXPECT_EQ(0, host_impl_->top_controls_manager()->controls_top_offset()); 6259 EXPECT_EQ(0, host_impl_->top_controls_manager()->controls_top_offset());
6222 EXPECT_EQ(gfx::Vector2dF().ToString(), 6260 EXPECT_EQ(gfx::Vector2dF().ToString(),
6223 scroll_layer->TotalScrollOffset().ToString()); 6261 scroll_layer->TotalScrollOffset().ToString());
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
6394 // Verify implicit limits are calculated correctly with no overflows 6432 // Verify implicit limits are calculated correctly with no overflows
6395 host_impl_->SetMemoryPolicy(mem_policy); 6433 host_impl_->SetMemoryPolicy(mem_policy);
6396 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, 6434 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes,
6397 300u * 1024u * 1024u); 6435 300u * 1024u * 1024u);
6398 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, 6436 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes,
6399 150u * 1024u * 1024u); 6437 150u * 1024u * 1024u);
6400 } 6438 }
6401 6439
6402 } // namespace 6440 } // namespace
6403 } // namespace cc 6441 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_animation.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698