OLD | NEW |
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 Loading... |
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), | |
89 did_request_manage_tiles_(false), | 88 did_request_manage_tiles_(false), |
90 did_upload_visible_tile_(false), | 89 did_upload_visible_tile_(false), |
91 reduce_memory_result_(true), | 90 reduce_memory_result_(true), |
92 current_limit_bytes_(0), | 91 current_limit_bytes_(0), |
93 current_priority_cutoff_value_(0) { | 92 current_priority_cutoff_value_(0) { |
94 media::InitializeMediaLibraryForTesting(); | 93 media::InitializeMediaLibraryForTesting(); |
95 } | 94 } |
96 | 95 |
97 LayerTreeSettings DefaultSettings() { | 96 LayerTreeSettings DefaultSettings() { |
98 LayerTreeSettings settings; | 97 LayerTreeSettings settings; |
(...skipping 26 matching lines...) Expand all Loading... |
125 did_notify_ready_to_activate_ = true; | 124 did_notify_ready_to_activate_ = true; |
126 host_impl_->ActivatePendingTree(); | 125 host_impl_->ActivatePendingTree(); |
127 } | 126 } |
128 virtual void SetNeedsRedrawOnImplThread() OVERRIDE { | 127 virtual void SetNeedsRedrawOnImplThread() OVERRIDE { |
129 did_request_redraw_ = true; | 128 did_request_redraw_ = true; |
130 } | 129 } |
131 virtual void SetNeedsRedrawRectOnImplThread( | 130 virtual void SetNeedsRedrawRectOnImplThread( |
132 const gfx::Rect& damage_rect) OVERRIDE { | 131 const gfx::Rect& damage_rect) OVERRIDE { |
133 did_request_redraw_ = true; | 132 did_request_redraw_ = true; |
134 } | 133 } |
135 virtual void SetNeedsAnimateOnImplThread() OVERRIDE { | |
136 did_request_animate_ = true; | |
137 } | |
138 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE { | 134 virtual void SetNeedsManageTilesOnImplThread() OVERRIDE { |
139 did_request_manage_tiles_ = true; | 135 did_request_manage_tiles_ = true; |
140 } | 136 } |
141 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE { | 137 virtual void DidInitializeVisibleTileOnImplThread() OVERRIDE { |
142 did_upload_visible_tile_ = true; | 138 did_upload_visible_tile_ = true; |
143 } | 139 } |
144 virtual void SetNeedsCommitOnImplThread() OVERRIDE { | 140 virtual void SetNeedsCommitOnImplThread() OVERRIDE { |
145 did_request_commit_ = true; | 141 did_request_commit_ = true; |
146 } | 142 } |
147 virtual void PostAnimationEventsToMainThreadOnImplThread( | 143 virtual void PostAnimationEventsToMainThreadOnImplThread( |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 DebugScopedSetImplThread always_impl_thread_; | 389 DebugScopedSetImplThread always_impl_thread_; |
394 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; | 390 DebugScopedSetMainThreadBlocked always_main_thread_blocked_; |
395 | 391 |
396 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; | 392 scoped_ptr<SharedBitmapManager> shared_bitmap_manager_; |
397 scoped_ptr<LayerTreeHostImpl> host_impl_; | 393 scoped_ptr<LayerTreeHostImpl> host_impl_; |
398 FakeRenderingStatsInstrumentation stats_instrumentation_; | 394 FakeRenderingStatsInstrumentation stats_instrumentation_; |
399 bool on_can_draw_state_changed_called_; | 395 bool on_can_draw_state_changed_called_; |
400 bool did_notify_ready_to_activate_; | 396 bool did_notify_ready_to_activate_; |
401 bool did_request_commit_; | 397 bool did_request_commit_; |
402 bool did_request_redraw_; | 398 bool did_request_redraw_; |
403 bool did_request_animate_; | |
404 bool did_request_manage_tiles_; | 399 bool did_request_manage_tiles_; |
405 bool did_upload_visible_tile_; | 400 bool did_upload_visible_tile_; |
406 bool reduce_memory_result_; | 401 bool reduce_memory_result_; |
407 base::TimeDelta requested_scrollbar_animation_delay_; | 402 base::TimeDelta requested_scrollbar_animation_delay_; |
408 size_t current_limit_bytes_; | 403 size_t current_limit_bytes_; |
409 int current_priority_cutoff_value_; | 404 int current_priority_cutoff_value_; |
410 }; | 405 }; |
411 | 406 |
412 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { | 407 TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) { |
413 bool always_draw = false; | 408 bool always_draw = false; |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
902 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); | 897 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); |
903 host_impl_->PinchGestureBegin(); | 898 host_impl_->PinchGestureBegin(); |
904 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | 899 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
905 // While the gesture is still active, the scroll layer should have a | 900 // While the gesture is still active, the scroll layer should have a |
906 // container size delta = container->bounds() * ((1.f - | 901 // container size delta = container->bounds() * ((1.f - |
907 // page_scale_delta)/()) | 902 // page_scale_delta)/()) |
908 EXPECT_EQ(expected_container_size_delta, | 903 EXPECT_EQ(expected_container_size_delta, |
909 scroll_layer->FixedContainerSizeDelta()); | 904 scroll_layer->FixedContainerSizeDelta()); |
910 host_impl_->PinchGestureEnd(); | 905 host_impl_->PinchGestureEnd(); |
911 host_impl_->ScrollEnd(); | 906 host_impl_->ScrollEnd(); |
912 EXPECT_FALSE(did_request_animate_); | |
913 EXPECT_TRUE(did_request_redraw_); | 907 EXPECT_TRUE(did_request_redraw_); |
914 EXPECT_TRUE(did_request_commit_); | 908 EXPECT_TRUE(did_request_commit_); |
915 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); | 909 EXPECT_EQ(gfx::Size(50, 50), container_layer->bounds()); |
916 | 910 |
917 scoped_ptr<ScrollAndScaleSet> scroll_info = | 911 scoped_ptr<ScrollAndScaleSet> scroll_info = |
918 host_impl_->ProcessScrollDeltas(); | 912 host_impl_->ProcessScrollDeltas(); |
919 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 913 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
920 | 914 |
921 EXPECT_EQ(gfx::Vector2d(75, 75).ToString(), | 915 EXPECT_EQ(gfx::Vector2d(75, 75).ToString(), |
922 scroll_layer->MaxScrollOffset().ToString()); | 916 scroll_layer->MaxScrollOffset().ToString()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
969 min_page_scale, | 963 min_page_scale, |
970 max_page_scale); | 964 max_page_scale); |
971 scroll_layer->SetScrollDelta(gfx::Vector2d()); | 965 scroll_layer->SetScrollDelta(gfx::Vector2d()); |
972 | 966 |
973 float page_scale_delta = 2.f; | 967 float page_scale_delta = 2.f; |
974 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); | 968 host_impl_->ScrollBegin(gfx::Point(50, 50), InputHandler::Gesture); |
975 host_impl_->PinchGestureBegin(); | 969 host_impl_->PinchGestureBegin(); |
976 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); | 970 host_impl_->PinchGestureUpdate(page_scale_delta, gfx::Point(50, 50)); |
977 host_impl_->PinchGestureEnd(); | 971 host_impl_->PinchGestureEnd(); |
978 host_impl_->ScrollEnd(); | 972 host_impl_->ScrollEnd(); |
979 EXPECT_FALSE(did_request_animate_); | |
980 EXPECT_TRUE(did_request_redraw_); | 973 EXPECT_TRUE(did_request_redraw_); |
981 EXPECT_TRUE(did_request_commit_); | 974 EXPECT_TRUE(did_request_commit_); |
982 | 975 |
983 scoped_ptr<ScrollAndScaleSet> scroll_info = | 976 scoped_ptr<ScrollAndScaleSet> scroll_info = |
984 host_impl_->ProcessScrollDeltas(); | 977 host_impl_->ProcessScrollDeltas(); |
985 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); | 978 EXPECT_EQ(scroll_info->page_scale_delta, page_scale_delta); |
986 } | 979 } |
987 | 980 |
988 // Zoom-in clamping | 981 // Zoom-in clamping |
989 { | 982 { |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 base::TimeTicks halfway_through_animation = start_time + duration / 2; | 1104 base::TimeTicks halfway_through_animation = start_time + duration / 2; |
1112 base::TimeTicks end_time = start_time + duration; | 1105 base::TimeTicks end_time = start_time + duration; |
1113 | 1106 |
1114 // Non-anchor zoom-in | 1107 // Non-anchor zoom-in |
1115 { | 1108 { |
1116 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | 1109 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, |
1117 min_page_scale, | 1110 min_page_scale, |
1118 max_page_scale); | 1111 max_page_scale); |
1119 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); | 1112 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); |
1120 | 1113 |
| 1114 host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration); |
1121 did_request_redraw_ = false; | 1115 did_request_redraw_ = false; |
1122 did_request_animate_ = false; | 1116 host_impl_->Animate(start_time); |
1123 host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration); | 1117 EXPECT_TRUE(did_request_redraw_); |
1124 EXPECT_FALSE(did_request_redraw_); | |
1125 EXPECT_TRUE(did_request_animate_); | |
1126 | 1118 |
1127 did_request_redraw_ = false; | 1119 did_request_redraw_ = false; |
1128 did_request_animate_ = false; | 1120 host_impl_->Animate(halfway_through_animation); |
1129 host_impl_->Animate(start_time); | |
1130 EXPECT_TRUE(did_request_redraw_); | 1121 EXPECT_TRUE(did_request_redraw_); |
1131 EXPECT_TRUE(did_request_animate_); | |
1132 | 1122 |
1133 did_request_redraw_ = false; | 1123 did_request_redraw_ = false; |
1134 did_request_animate_ = false; | |
1135 host_impl_->Animate(halfway_through_animation); | |
1136 EXPECT_TRUE(did_request_redraw_); | |
1137 EXPECT_TRUE(did_request_animate_); | |
1138 | |
1139 did_request_redraw_ = false; | |
1140 did_request_animate_ = false; | |
1141 did_request_commit_ = false; | 1124 did_request_commit_ = false; |
1142 host_impl_->Animate(end_time); | 1125 host_impl_->Animate(end_time); |
1143 EXPECT_TRUE(did_request_commit_); | 1126 EXPECT_TRUE(did_request_commit_); |
1144 EXPECT_FALSE(did_request_animate_); | |
1145 | 1127 |
1146 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1128 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1147 host_impl_->ProcessScrollDeltas(); | 1129 host_impl_->ProcessScrollDeltas(); |
1148 EXPECT_EQ(scroll_info->page_scale_delta, 2); | 1130 EXPECT_EQ(scroll_info->page_scale_delta, 2); |
1149 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); | 1131 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); |
1150 } | 1132 } |
1151 | 1133 |
1152 // Anchor zoom-out | 1134 // Anchor zoom-out |
1153 { | 1135 { |
1154 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, | 1136 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, |
1155 min_page_scale, | 1137 min_page_scale, |
1156 max_page_scale); | 1138 max_page_scale); |
1157 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); | 1139 scroll_layer->SetScrollOffset(gfx::Vector2d(50, 50)); |
1158 | 1140 |
1159 did_request_redraw_ = false; | |
1160 did_request_animate_ = false; | |
1161 host_impl_->StartPageScaleAnimation( | 1141 host_impl_->StartPageScaleAnimation( |
1162 gfx::Vector2d(25, 25), true, min_page_scale, duration); | 1142 gfx::Vector2d(25, 25), true, min_page_scale, duration); |
1163 EXPECT_FALSE(did_request_redraw_); | |
1164 EXPECT_TRUE(did_request_animate_); | |
1165 | |
1166 did_request_redraw_ = false; | 1143 did_request_redraw_ = false; |
1167 did_request_animate_ = false; | |
1168 host_impl_->Animate(start_time); | 1144 host_impl_->Animate(start_time); |
1169 EXPECT_TRUE(did_request_redraw_); | 1145 EXPECT_TRUE(did_request_redraw_); |
1170 EXPECT_TRUE(did_request_animate_); | |
1171 | 1146 |
1172 did_request_redraw_ = false; | 1147 did_request_redraw_ = false; |
1173 did_request_commit_ = false; | 1148 did_request_commit_ = false; |
1174 did_request_animate_ = false; | |
1175 host_impl_->Animate(end_time); | 1149 host_impl_->Animate(end_time); |
1176 EXPECT_TRUE(did_request_redraw_); | 1150 EXPECT_TRUE(did_request_redraw_); |
1177 EXPECT_FALSE(did_request_animate_); | |
1178 EXPECT_TRUE(did_request_commit_); | 1151 EXPECT_TRUE(did_request_commit_); |
1179 | 1152 |
1180 scoped_ptr<ScrollAndScaleSet> scroll_info = | 1153 scoped_ptr<ScrollAndScaleSet> scroll_info = |
1181 host_impl_->ProcessScrollDeltas(); | 1154 host_impl_->ProcessScrollDeltas(); |
1182 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); | 1155 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); |
1183 // Pushed to (0,0) via clamping against contents layer size. | 1156 // Pushed to (0,0) via clamping against contents layer size. |
1184 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); | 1157 ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50)); |
1185 } | 1158 } |
1186 } | 1159 } |
1187 | 1160 |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1321 host_impl_->ScrollEnd(); | 1294 host_impl_->ScrollEnd(); |
1322 host_impl_->StartScrollbarAnimation(); | 1295 host_impl_->StartScrollbarAnimation(); |
1323 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1296 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
1324 EXPECT_FALSE(did_request_redraw_); | 1297 EXPECT_FALSE(did_request_redraw_); |
1325 | 1298 |
1326 // After a scroll, a fade animation should be scheduled about 20ms from now. | 1299 // After a scroll, a fade animation should be scheduled about 20ms from now. |
1327 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); | 1300 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
1328 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); | 1301 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); |
1329 host_impl_->ScrollEnd(); | 1302 host_impl_->ScrollEnd(); |
1330 did_request_redraw_ = false; | 1303 did_request_redraw_ = false; |
1331 did_request_animate_ = false; | |
1332 host_impl_->StartScrollbarAnimation(); | 1304 host_impl_->StartScrollbarAnimation(); |
1333 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), | 1305 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), |
1334 requested_scrollbar_animation_delay_); | 1306 requested_scrollbar_animation_delay_); |
1335 EXPECT_FALSE(did_request_redraw_); | 1307 EXPECT_FALSE(did_request_redraw_); |
1336 EXPECT_FALSE(did_request_animate_); | |
1337 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1308 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
1338 | 1309 |
1339 // After the fade begins, we should start getting redraws instead of a | 1310 // After the fade begins, we should start getting redraws instead of a |
1340 // scheduled animation. | 1311 // scheduled animation. |
1341 fake_now += base::TimeDelta::FromMilliseconds(25); | 1312 fake_now += base::TimeDelta::FromMilliseconds(25); |
1342 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); | 1313 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); |
1343 host_impl_->StartScrollbarAnimation(); | 1314 host_impl_->StartScrollbarAnimation(); |
1344 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1315 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
1345 EXPECT_TRUE(did_request_animate_); | 1316 EXPECT_TRUE(did_request_redraw_); |
1346 did_request_animate_ = false; | 1317 did_request_redraw_ = false; |
1347 | 1318 |
1348 // If no scroll happened recently, StartScrollbarAnimation should have no | 1319 // If no scroll happened recently, StartScrollbarAnimation should have no |
1349 // effect. | 1320 // effect. |
1350 fake_now += base::TimeDelta::FromMilliseconds(25); | 1321 fake_now += base::TimeDelta::FromMilliseconds(25); |
1351 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); | 1322 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); |
1352 host_impl_->StartScrollbarAnimation(); | 1323 host_impl_->StartScrollbarAnimation(); |
1353 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1324 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
1354 EXPECT_FALSE(did_request_redraw_); | 1325 EXPECT_FALSE(did_request_redraw_); |
1355 | 1326 |
1356 // Setting the scroll offset outside a scroll should also cause the scrollbar | 1327 // Setting the scroll offset outside a scroll should also cause the scrollbar |
1357 // to appear and to schedule a fade. | 1328 // to appear and to schedule a fade. |
1358 host_impl_->InnerViewportScrollLayer()->SetScrollOffset(gfx::Vector2d(5, 5)); | 1329 host_impl_->InnerViewportScrollLayer()->SetScrollOffset(gfx::Vector2d(5, 5)); |
1359 host_impl_->StartScrollbarAnimation(); | 1330 host_impl_->StartScrollbarAnimation(); |
1360 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), | 1331 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), |
1361 requested_scrollbar_animation_delay_); | 1332 requested_scrollbar_animation_delay_); |
1362 EXPECT_FALSE(did_request_redraw_); | 1333 EXPECT_FALSE(did_request_redraw_); |
1363 EXPECT_FALSE(did_request_animate_); | |
1364 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1334 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
1365 | 1335 |
1366 // None of the above should have called CurrentFrameTimeTicks, so if we call | 1336 // None of the above should have called CurrentFrameTimeTicks, so if we call |
1367 // it now we should get the current time. | 1337 // it now we should get the current time. |
1368 fake_now += base::TimeDelta::FromMilliseconds(10); | 1338 fake_now += base::TimeDelta::FromMilliseconds(10); |
1369 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); | 1339 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); |
1370 EXPECT_EQ(fake_now, host_impl_->CurrentFrameTimeTicks()); | 1340 EXPECT_EQ(fake_now, host_impl_->CurrentFrameTimeTicks()); |
1371 } | 1341 } |
1372 | 1342 |
1373 TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { | 1343 TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { |
1374 LayerTreeSettings settings; | 1344 LayerTreeSettings settings; |
1375 settings.scrollbar_animator = LayerTreeSettings::LinearFade; | 1345 settings.scrollbar_animator = LayerTreeSettings::LinearFade; |
1376 settings.scrollbar_linear_fade_delay_ms = 20; | 1346 settings.scrollbar_linear_fade_delay_ms = 20; |
1377 settings.scrollbar_linear_fade_length_ms = 20; | 1347 settings.scrollbar_linear_fade_length_ms = 20; |
1378 settings.use_pinch_zoom_scrollbars = true; | 1348 settings.use_pinch_zoom_scrollbars = true; |
1379 | 1349 |
1380 SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); | 1350 SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); |
1381 | 1351 |
1382 base::TimeTicks fake_now = gfx::FrameTime::Now(); | 1352 base::TimeTicks fake_now = gfx::FrameTime::Now(); |
1383 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); | 1353 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); |
1384 | 1354 |
1385 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); | 1355 host_impl_->active_tree()->SetPageScaleFactorAndLimits(1.f, 1.f, 4.f); |
1386 | 1356 |
1387 // If no scroll happened recently, StartScrollbarAnimation should have no | 1357 // If no scroll happened recently, StartScrollbarAnimation should have no |
1388 // effect. | 1358 // effect. |
1389 host_impl_->StartScrollbarAnimation(); | 1359 host_impl_->StartScrollbarAnimation(); |
1390 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1360 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
1391 EXPECT_FALSE(did_request_animate_); | 1361 EXPECT_FALSE(did_request_redraw_); |
1392 | 1362 |
1393 // If no scroll happened during a scroll gesture, StartScrollbarAnimation | 1363 // If no scroll happened during a scroll gesture, StartScrollbarAnimation |
1394 // should have no effect. | 1364 // should have no effect. |
1395 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); | 1365 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
1396 host_impl_->ScrollEnd(); | 1366 host_impl_->ScrollEnd(); |
1397 host_impl_->StartScrollbarAnimation(); | 1367 host_impl_->StartScrollbarAnimation(); |
1398 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1368 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
1399 EXPECT_FALSE(did_request_animate_); | 1369 EXPECT_FALSE(did_request_redraw_); |
1400 | 1370 |
1401 // After a scroll, no fade animation should be scheduled. | 1371 // After a scroll, no fade animation should be scheduled. |
1402 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); | 1372 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
1403 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); | 1373 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); |
1404 host_impl_->ScrollEnd(); | 1374 host_impl_->ScrollEnd(); |
1405 did_request_redraw_ = false; | 1375 did_request_redraw_ = false; |
1406 host_impl_->StartScrollbarAnimation(); | 1376 host_impl_->StartScrollbarAnimation(); |
1407 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1377 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
1408 EXPECT_FALSE(did_request_animate_); | 1378 EXPECT_FALSE(did_request_redraw_); |
1409 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1379 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
1410 | 1380 |
1411 // We should not see any draw requests. | 1381 // We should not see any draw requests. |
1412 fake_now += base::TimeDelta::FromMilliseconds(25); | 1382 fake_now += base::TimeDelta::FromMilliseconds(25); |
1413 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); | 1383 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); |
1414 host_impl_->StartScrollbarAnimation(); | 1384 host_impl_->StartScrollbarAnimation(); |
1415 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1385 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
1416 EXPECT_FALSE(did_request_animate_); | 1386 EXPECT_FALSE(did_request_redraw_); |
1417 | 1387 |
1418 // Make page scale > min so that subsequent scrolls will trigger fades. | 1388 // Make page scale > min so that subsequent scrolls will trigger fades. |
1419 host_impl_->active_tree()->SetPageScaleDelta(1.1f); | 1389 host_impl_->active_tree()->SetPageScaleDelta(1.1f); |
1420 | 1390 |
1421 // After a scroll, a fade animation should be scheduled about 20ms from now. | 1391 // After a scroll, a fade animation should be scheduled about 20ms from now. |
1422 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); | 1392 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
1423 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); | 1393 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); |
1424 host_impl_->ScrollEnd(); | 1394 host_impl_->ScrollEnd(); |
1425 did_request_redraw_ = false; | 1395 did_request_redraw_ = false; |
1426 host_impl_->StartScrollbarAnimation(); | 1396 host_impl_->StartScrollbarAnimation(); |
1427 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), | 1397 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), |
1428 requested_scrollbar_animation_delay_); | 1398 requested_scrollbar_animation_delay_); |
1429 EXPECT_FALSE(did_request_animate_); | 1399 EXPECT_FALSE(did_request_redraw_); |
1430 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1400 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
1431 | 1401 |
1432 // After the fade begins, we should start getting redraws instead of a | 1402 // After the fade begins, we should start getting redraws instead of a |
1433 // scheduled animation. | 1403 // scheduled animation. |
1434 fake_now += base::TimeDelta::FromMilliseconds(25); | 1404 fake_now += base::TimeDelta::FromMilliseconds(25); |
1435 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); | 1405 host_impl_override_time->SetCurrentPhysicalTimeTicksForTest(fake_now); |
1436 host_impl_->StartScrollbarAnimation(); | 1406 host_impl_->StartScrollbarAnimation(); |
1437 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1407 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
1438 EXPECT_TRUE(did_request_animate_); | 1408 EXPECT_TRUE(did_request_redraw_); |
1439 } | 1409 } |
1440 | 1410 |
1441 void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( | 1411 void LayerTreeHostImplTest::SetupMouseMoveAtWithDeviceScale( |
1442 float device_scale_factor) { | 1412 float device_scale_factor) { |
1443 LayerTreeSettings settings; | 1413 LayerTreeSettings settings; |
1444 settings.scrollbar_animator = LayerTreeSettings::Thinning; | 1414 settings.scrollbar_animator = LayerTreeSettings::Thinning; |
1445 | 1415 |
1446 gfx::Size viewport_size(300, 200); | 1416 gfx::Size viewport_size(300, 200); |
1447 gfx::Size device_viewport_size = gfx::ToFlooredSize( | 1417 gfx::Size device_viewport_size = gfx::ToFlooredSize( |
1448 gfx::ScaleSize(viewport_size, device_scale_factor)); | 1418 gfx::ScaleSize(viewport_size, device_scale_factor)); |
(...skipping 4975 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6424 // Verify implicit limits are calculated correctly with no overflows | 6394 // Verify implicit limits are calculated correctly with no overflows |
6425 host_impl_->SetMemoryPolicy(mem_policy); | 6395 host_impl_->SetMemoryPolicy(mem_policy); |
6426 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, | 6396 EXPECT_EQ(host_impl_->global_tile_state().hard_memory_limit_in_bytes, |
6427 300u * 1024u * 1024u); | 6397 300u * 1024u * 1024u); |
6428 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, | 6398 EXPECT_EQ(host_impl_->global_tile_state().soft_memory_limit_in_bytes, |
6429 150u * 1024u * 1024u); | 6399 150u * 1024u * 1024u); |
6430 } | 6400 } |
6431 | 6401 |
6432 } // namespace | 6402 } // namespace |
6433 } // namespace cc | 6403 } // namespace cc |
OLD | NEW |