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 1341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1352 | 1352 |
1353 // If no scroll happened during a scroll gesture, it should have no effect. | 1353 // If no scroll happened during a scroll gesture, it should have no effect. |
1354 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); | 1354 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
1355 host_impl_->ScrollEnd(); | 1355 host_impl_->ScrollEnd(); |
1356 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1356 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
1357 EXPECT_FALSE(did_request_redraw_); | 1357 EXPECT_FALSE(did_request_redraw_); |
1358 EXPECT_TRUE(scrollbar_fade_start_.Equals(base::Closure())); | 1358 EXPECT_TRUE(scrollbar_fade_start_.Equals(base::Closure())); |
1359 | 1359 |
1360 // After a scroll, a fade animation should be scheduled about 20ms from now. | 1360 // After a scroll, a fade animation should be scheduled about 20ms from now. |
1361 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); | 1361 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); |
1362 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); | 1362 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(0, 5)); |
weiliangc
2014/09/16 16:02:11
Just want to make sure, why would this fix the tes
MuVen
2014/09/16 16:10:14
Crash in the sense Expect_LT has failed.Sorry or m
| |
1363 host_impl_->ScrollEnd(); | 1363 host_impl_->ScrollEnd(); |
1364 did_request_redraw_ = false; | 1364 did_request_redraw_ = false; |
1365 did_request_animate_ = false; | 1365 did_request_animate_ = false; |
1366 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), | 1366 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), |
1367 requested_scrollbar_animation_delay_); | 1367 requested_scrollbar_animation_delay_); |
1368 EXPECT_FALSE(did_request_redraw_); | 1368 EXPECT_FALSE(did_request_redraw_); |
1369 EXPECT_FALSE(did_request_animate_); | 1369 EXPECT_FALSE(did_request_animate_); |
1370 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1370 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
1371 scrollbar_fade_start_.Run(); | 1371 scrollbar_fade_start_.Run(); |
1372 host_impl_->Animate(fake_now); | 1372 host_impl_->Animate(fake_now); |
1373 | 1373 |
1374 // After the fade begins, we should start getting redraws instead of a | 1374 // After the fade begins, we should start getting redraws instead of a |
1375 // scheduled animation. | 1375 // scheduled animation. |
1376 fake_now += base::TimeDelta::FromMilliseconds(25); | 1376 fake_now += base::TimeDelta::FromMilliseconds(25); |
1377 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | 1377 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); |
1378 EXPECT_TRUE(did_request_animate_); | 1378 EXPECT_TRUE(did_request_animate_); |
1379 did_request_animate_ = false; | 1379 did_request_animate_ = false; |
1380 | 1380 |
1381 // Setting the scroll offset outside a scroll should also cause the scrollbar | 1381 // Setting the scroll offset outside a scroll should also cause the scrollbar |
1382 // to appear and to schedule a fade. | 1382 // to appear and to schedule a fade. |
1383 host_impl_->InnerViewportScrollLayer()->SetScrollOffset(gfx::Vector2d(5, 5)); | 1383 host_impl_->InnerViewportScrollLayer()->SetScrollOffset(gfx::Vector2d(5, 5)); |
1384 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), | 1384 EXPECT_LT(base::TimeDelta::FromMilliseconds(19), |
1385 requested_scrollbar_animation_delay_); | 1385 requested_scrollbar_animation_delay_); |
1386 EXPECT_FALSE(did_request_redraw_); | 1386 EXPECT_FALSE(did_request_redraw_); |
1387 EXPECT_FALSE(did_request_animate_); | 1387 EXPECT_FALSE(did_request_animate_); |
1388 requested_scrollbar_animation_delay_ = base::TimeDelta(); | 1388 requested_scrollbar_animation_delay_ = base::TimeDelta(); |
1389 | |
1390 // Unnecessarily Fade animation of solid color scrollbar is not triggered. | |
1391 host_impl_->ScrollBegin(gfx::Point(), InputHandler::Wheel); | |
1392 host_impl_->ScrollBy(gfx::Point(), gfx::Vector2dF(5, 0)); | |
1393 host_impl_->ScrollEnd(); | |
1394 EXPECT_EQ(base::TimeDelta(), requested_scrollbar_animation_delay_); | |
1389 } | 1395 } |
1390 | 1396 |
1391 TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { | 1397 TEST_F(LayerTreeHostImplTest, ScrollbarFadePinchZoomScrollbars) { |
1392 LayerTreeSettings settings; | 1398 LayerTreeSettings settings; |
1393 settings.scrollbar_animator = LayerTreeSettings::LinearFade; | 1399 settings.scrollbar_animator = LayerTreeSettings::LinearFade; |
1394 settings.scrollbar_fade_delay_ms = 20; | 1400 settings.scrollbar_fade_delay_ms = 20; |
1395 settings.scrollbar_fade_duration_ms = 20; | 1401 settings.scrollbar_fade_duration_ms = 20; |
1396 settings.use_pinch_zoom_scrollbars = true; | 1402 settings.use_pinch_zoom_scrollbars = true; |
1397 | 1403 |
1398 SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); | 1404 SETUP_LAYERS_FOR_SCROLLBAR_ANIMATION_TEST(); |
(...skipping 5713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7112 // surface. | 7118 // surface. |
7113 EXPECT_EQ(0, num_lost_surfaces_); | 7119 EXPECT_EQ(0, num_lost_surfaces_); |
7114 host_impl_->DidLoseOutputSurface(); | 7120 host_impl_->DidLoseOutputSurface(); |
7115 EXPECT_EQ(1, num_lost_surfaces_); | 7121 EXPECT_EQ(1, num_lost_surfaces_); |
7116 host_impl_->DidLoseOutputSurface(); | 7122 host_impl_->DidLoseOutputSurface(); |
7117 EXPECT_LE(1, num_lost_surfaces_); | 7123 EXPECT_LE(1, num_lost_surfaces_); |
7118 } | 7124 } |
7119 | 7125 |
7120 } // namespace | 7126 } // namespace |
7121 } // namespace cc | 7127 } // namespace cc |
OLD | NEW |