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

Side by Side Diff: cc/input/scrollbar_animation_controller_unittest.cc

Issue 2866733002: Remove owning_id from EffectNode and replace it by an opaque stable_id (Closed)
Patch Set: none Created 3 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
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/input/scrollbar_animation_controller.h" 5 #include "cc/input/scrollbar_animation_controller.h"
6 6
7 #include "cc/layers/solid_color_scrollbar_layer_impl.h" 7 #include "cc/layers/solid_color_scrollbar_layer_impl.h"
8 #include "cc/test/fake_impl_task_runner_provider.h" 8 #include "cc/test/fake_impl_task_runner_provider.h"
9 #include "cc/test/fake_layer_tree_host_impl.h" 9 #include "cc/test/fake_layer_tree_host_impl.h"
10 #include "cc/test/geometry_test_utils.h" 10 #include "cc/test/geometry_test_utils.h"
11 #include "cc/test/layer_test_common.h"
11 #include "cc/test/test_task_graph_runner.h" 12 #include "cc/test/test_task_graph_runner.h"
13 #include "cc/trees/effect_node.h"
12 #include "cc/trees/layer_tree_impl.h" 14 #include "cc/trees/layer_tree_impl.h"
13 #include "testing/gmock/include/gmock/gmock.h" 15 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
15 17
16 using testing::AtLeast; 18 using testing::AtLeast;
17 using testing::Mock; 19 using testing::Mock;
18 using testing::NiceMock; 20 using testing::NiceMock;
19 using testing::_; 21 using testing::_;
20 22
21 namespace cc { 23 namespace cc {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 LayerTreeHostImpl* host_impl_; 60 LayerTreeHostImpl* host_impl_;
59 }; 61 };
60 62
61 class ScrollbarAnimationControllerAuraOverlayTest : public testing::Test { 63 class ScrollbarAnimationControllerAuraOverlayTest : public testing::Test {
62 public: 64 public:
63 ScrollbarAnimationControllerAuraOverlayTest() 65 ScrollbarAnimationControllerAuraOverlayTest()
64 : host_impl_(&task_runner_provider_, &task_graph_runner_), 66 : host_impl_(&task_runner_provider_, &task_graph_runner_),
65 client_(&host_impl_) {} 67 client_(&host_impl_) {}
66 68
67 void ExpectScrollbarsOpacity(float opacity) { 69 void ExpectScrollbarsOpacity(float opacity) {
68 EXPECT_FLOAT_EQ(opacity, v_scrollbar_layer_->Opacity()); 70 EXPECT_FLOAT_EQ(opacity, OpacityForLayer(v_scrollbar_layer_));
69 EXPECT_FLOAT_EQ(opacity, h_scrollbar_layer_->Opacity()); 71 EXPECT_FLOAT_EQ(opacity, OpacityForLayer(h_scrollbar_layer_));
70 } 72 }
71 73
72 protected: 74 protected:
73 const base::TimeDelta kFadeDelay = base::TimeDelta::FromSeconds(4); 75 const base::TimeDelta kFadeDelay = base::TimeDelta::FromSeconds(4);
74 const base::TimeDelta kFadeDuration = base::TimeDelta::FromSeconds(3); 76 const base::TimeDelta kFadeDuration = base::TimeDelta::FromSeconds(3);
75 const base::TimeDelta kThinningDuration = base::TimeDelta::FromSeconds(2); 77 const base::TimeDelta kThinningDuration = base::TimeDelta::FromSeconds(2);
76 78
77 void SetUp() override { 79 void SetUp() override {
78 std::unique_ptr<LayerImpl> scroll_layer = 80 std::unique_ptr<LayerImpl> scroll_layer =
79 LayerImpl::Create(host_impl_.active_tree(), 1); 81 LayerImpl::Create(host_impl_.active_tree(), 1);
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 ASSERT_TRUE(scroll_layer); 202 ASSERT_TRUE(scroll_layer);
201 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); 203 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds());
202 204
203 // Shrink along X axis, horizontal scrollbar should appear. 205 // Shrink along X axis, horizontal scrollbar should appear.
204 clip_layer_->SetBounds(gfx::Size(100, 200)); 206 clip_layer_->SetBounds(gfx::Size(100, 200));
205 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); 207 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds());
206 208
207 scrollbar_controller_->DidScrollBegin(); 209 scrollbar_controller_->DidScrollBegin();
208 210
209 scrollbar_controller_->DidScrollUpdate(); 211 scrollbar_controller_->DidScrollUpdate();
210 EXPECT_FLOAT_EQ(1, h_scrollbar_layer_->Opacity()); 212
213 EXPECT_FLOAT_EQ(1, OpacityForLayer(h_scrollbar_layer_));
211 214
212 scrollbar_controller_->DidScrollEnd(); 215 scrollbar_controller_->DidScrollEnd();
213 216
214 // Shrink along Y axis and expand along X, horizontal scrollbar 217 // Shrink along Y axis and expand along X, horizontal scrollbar
215 // should disappear. 218 // should disappear.
216 clip_layer_->SetBounds(gfx::Size(200, 100)); 219 clip_layer_->SetBounds(gfx::Size(200, 100));
217 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); 220 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds());
218 221
219 scrollbar_controller_->DidScrollBegin(); 222 scrollbar_controller_->DidScrollBegin();
220 223
221 scrollbar_controller_->DidScrollUpdate(); 224 scrollbar_controller_->DidScrollUpdate();
222 EXPECT_FLOAT_EQ(0.0f, h_scrollbar_layer_->Opacity()); 225 EXPECT_FLOAT_EQ(0.0f, OpacityForLayer(h_scrollbar_layer_));
223 226
224 scrollbar_controller_->DidScrollEnd(); 227 scrollbar_controller_->DidScrollEnd();
225 } 228 }
226 229
227 // Scroll content. Confirm the scrollbar appears and fades out. 230 // Scroll content. Confirm the scrollbar appears and fades out.
228 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicAppearAndFadeOut) { 231 TEST_F(ScrollbarAnimationControllerAuraOverlayTest, BasicAppearAndFadeOut) {
229 base::TimeTicks time; 232 base::TimeTicks time;
230 time += base::TimeDelta::FromSeconds(1); 233 time += base::TimeDelta::FromSeconds(1);
231 234
232 // Scrollbar should be invisible. 235 // Scrollbar should be invisible.
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 1285
1283 class VerticalScrollbarAnimationControllerAndroidTest 1286 class VerticalScrollbarAnimationControllerAndroidTest
1284 : public ScrollbarAnimationControllerAndroidTest { 1287 : public ScrollbarAnimationControllerAndroidTest {
1285 protected: 1288 protected:
1286 ScrollbarOrientation orientation() const override { return VERTICAL; } 1289 ScrollbarOrientation orientation() const override { return VERTICAL; }
1287 }; 1290 };
1288 1291
1289 TEST_F(ScrollbarAnimationControllerAndroidTest, HiddenInBegin) { 1292 TEST_F(ScrollbarAnimationControllerAndroidTest, HiddenInBegin) {
1290 scrollbar_layer_->SetOverlayScrollbarLayerOpacityAnimated(0.f); 1293 scrollbar_layer_->SetOverlayScrollbarLayerOpacityAnimated(0.f);
1291 scrollbar_controller_->Animate(base::TimeTicks()); 1294 scrollbar_controller_->Animate(base::TimeTicks());
1292 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1295 EXPECT_FLOAT_EQ(0.0f, OpacityForLayer(scrollbar_layer_));
1293 } 1296 }
1294 1297
1295 TEST_F(ScrollbarAnimationControllerAndroidTest, 1298 TEST_F(ScrollbarAnimationControllerAndroidTest,
1296 HiddenAfterNonScrollingGesture) { 1299 HiddenAfterNonScrollingGesture) {
1297 scrollbar_layer_->SetOverlayScrollbarLayerOpacityAnimated(0.f); 1300 scrollbar_layer_->SetOverlayScrollbarLayerOpacityAnimated(0.f);
1298 scrollbar_controller_->DidScrollBegin(); 1301 scrollbar_controller_->DidScrollBegin();
1299 1302
1300 base::TimeTicks time; 1303 base::TimeTicks time;
1301 time += base::TimeDelta::FromSeconds(100); 1304 time += base::TimeDelta::FromSeconds(100);
1302 scrollbar_controller_->Animate(time); 1305 scrollbar_controller_->Animate(time);
1303 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1306
1307 float opacity = scrollbar_layer_->layer_tree_impl()
1308 ->property_trees()
1309 ->effect_tree.Node(scrollbar_layer_->effect_tree_index())
1310 ->opacity;
1311 EXPECT_FLOAT_EQ(0.0f, opacity);
1304 scrollbar_controller_->DidScrollEnd(); 1312 scrollbar_controller_->DidScrollEnd();
1305 1313
1306 EXPECT_TRUE(start_fade_.Equals(base::Closure())); 1314 EXPECT_TRUE(start_fade_.Equals(base::Closure()));
1307 1315
1308 time += base::TimeDelta::FromSeconds(100); 1316 time += base::TimeDelta::FromSeconds(100);
1309 scrollbar_controller_->Animate(time); 1317 scrollbar_controller_->Animate(time);
1310 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1318 EXPECT_FLOAT_EQ(0.0f, OpacityForLayer(scrollbar_layer_));
1311 } 1319 }
1312 1320
1313 // Confirm the scrollbar does not appear on WillUpdateScroll on Android. 1321 // Confirm the scrollbar does not appear on WillUpdateScroll on Android.
1314 TEST_F(ScrollbarAnimationControllerAndroidTest, 1322 TEST_F(ScrollbarAnimationControllerAndroidTest,
1315 WillUpdateScrollNotAppearScrollbar) { 1323 WillUpdateScrollNotAppearScrollbar) {
1316 base::TimeTicks time; 1324 base::TimeTicks time;
1317 time += base::TimeDelta::FromSeconds(1); 1325 time += base::TimeDelta::FromSeconds(1);
1318 1326
1319 // Scrollbar should be invisible. 1327 // Scrollbar should be invisible.
1320 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1328 EXPECT_FLOAT_EQ(0.0f, OpacityForLayer(scrollbar_layer_));
1321 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); 1329 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
1322 1330
1323 // Scrollbar should appear when scroll will update. 1331 // Scrollbar should appear when scroll will update.
1324 scrollbar_controller_->WillUpdateScroll(); 1332 scrollbar_controller_->WillUpdateScroll();
1325 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1333 EXPECT_FLOAT_EQ(0.0f, OpacityForLayer(scrollbar_layer_));
1326 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden()); 1334 EXPECT_TRUE(scrollbar_controller_->ScrollbarsHidden());
1327 1335
1328 // No fade out animation should have been enqueued. 1336 // No fade out animation should have been enqueued.
1329 EXPECT_TRUE(start_fade_.Equals(base::Closure())); 1337 EXPECT_TRUE(start_fade_.Equals(base::Closure()));
1330 } 1338 }
1331 1339
1332 TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnResize) { 1340 TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnResize) {
1333 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 1341 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
1334 ASSERT_TRUE(scroll_layer); 1342 ASSERT_TRUE(scroll_layer);
1335 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); 1343 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds());
1336 1344
1337 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); 1345 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation());
1338 1346
1339 // Shrink along X axis, horizontal scrollbar should appear. 1347 // Shrink along X axis, horizontal scrollbar should appear.
1340 clip_layer_->SetBounds(gfx::Size(100, 200)); 1348 clip_layer_->SetBounds(gfx::Size(100, 200));
1341 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); 1349 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds());
1342 1350
1343 scrollbar_controller_->DidScrollBegin(); 1351 scrollbar_controller_->DidScrollBegin();
1344 1352
1345 scrollbar_controller_->DidScrollUpdate(); 1353 scrollbar_controller_->DidScrollUpdate();
1346 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1354 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1347 1355
1348 scrollbar_controller_->DidScrollEnd(); 1356 scrollbar_controller_->DidScrollEnd();
1349 1357
1350 // Shrink along Y axis and expand along X, horizontal scrollbar 1358 // Shrink along Y axis and expand along X, horizontal scrollbar
1351 // should disappear. 1359 // should disappear.
1352 clip_layer_->SetBounds(gfx::Size(200, 100)); 1360 clip_layer_->SetBounds(gfx::Size(200, 100));
1353 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); 1361 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds());
1354 1362
1355 scrollbar_controller_->DidScrollBegin(); 1363 scrollbar_controller_->DidScrollBegin();
1356 1364
1357 scrollbar_controller_->DidScrollUpdate(); 1365 scrollbar_controller_->DidScrollUpdate();
1358 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1366 EXPECT_FLOAT_EQ(0.0f, OpacityForLayer(scrollbar_layer_));
1359 1367
1360 scrollbar_controller_->DidScrollEnd(); 1368 scrollbar_controller_->DidScrollEnd();
1361 } 1369 }
1362 1370
1363 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, HideOnResize) { 1371 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, HideOnResize) {
1364 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 1372 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
1365 ASSERT_TRUE(scroll_layer); 1373 ASSERT_TRUE(scroll_layer);
1366 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds()); 1374 EXPECT_EQ(gfx::Size(200, 200), scroll_layer->bounds());
1367 1375
1368 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); 1376 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation());
1369 1377
1370 // Shrink along X axis, vertical scrollbar should remain invisible. 1378 // Shrink along X axis, vertical scrollbar should remain invisible.
1371 clip_layer_->SetBounds(gfx::Size(100, 200)); 1379 clip_layer_->SetBounds(gfx::Size(100, 200));
1372 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds()); 1380 EXPECT_EQ(gfx::Size(100, 200), clip_layer_->bounds());
1373 1381
1374 scrollbar_controller_->DidScrollBegin(); 1382 scrollbar_controller_->DidScrollBegin();
1375 1383
1376 scrollbar_controller_->DidScrollUpdate(); 1384 scrollbar_controller_->DidScrollUpdate();
1377 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1385 EXPECT_FLOAT_EQ(0.0f, OpacityForLayer(scrollbar_layer_));
1378 1386
1379 scrollbar_controller_->DidScrollEnd(); 1387 scrollbar_controller_->DidScrollEnd();
1380 1388
1381 // Shrink along Y axis and expand along X, vertical scrollbar should appear. 1389 // Shrink along Y axis and expand along X, vertical scrollbar should appear.
1382 clip_layer_->SetBounds(gfx::Size(200, 100)); 1390 clip_layer_->SetBounds(gfx::Size(200, 100));
1383 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds()); 1391 EXPECT_EQ(gfx::Size(200, 100), clip_layer_->bounds());
1384 1392
1385 scrollbar_controller_->DidScrollBegin(); 1393 scrollbar_controller_->DidScrollBegin();
1386 1394
1387 scrollbar_controller_->DidScrollUpdate(); 1395 scrollbar_controller_->DidScrollUpdate();
1388 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1396 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1389 1397
1390 scrollbar_controller_->DidScrollEnd(); 1398 scrollbar_controller_->DidScrollEnd();
1391 } 1399 }
1392 1400
1393 TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnUserNonScrollableHorz) { 1401 TEST_F(ScrollbarAnimationControllerAndroidTest, HideOnUserNonScrollableHorz) {
1394 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); 1402 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation());
1395 1403
1396 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 1404 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
1397 ASSERT_TRUE(scroll_layer); 1405 ASSERT_TRUE(scroll_layer);
1398 scroll_layer->set_user_scrollable_horizontal(false); 1406 scroll_layer->set_user_scrollable_horizontal(false);
1399 1407
1400 scrollbar_controller_->DidScrollBegin(); 1408 scrollbar_controller_->DidScrollBegin();
1401 1409
1402 scrollbar_controller_->DidScrollUpdate(); 1410 scrollbar_controller_->DidScrollUpdate();
1403 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1411 EXPECT_FLOAT_EQ(0.0f, OpacityForLayer(scrollbar_layer_));
1404 1412
1405 scrollbar_controller_->DidScrollEnd(); 1413 scrollbar_controller_->DidScrollEnd();
1406 } 1414 }
1407 1415
1408 TEST_F(ScrollbarAnimationControllerAndroidTest, ShowOnUserNonScrollableVert) { 1416 TEST_F(ScrollbarAnimationControllerAndroidTest, ShowOnUserNonScrollableVert) {
1409 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation()); 1417 EXPECT_EQ(HORIZONTAL, scrollbar_layer_->orientation());
1410 1418
1411 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 1419 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
1412 ASSERT_TRUE(scroll_layer); 1420 ASSERT_TRUE(scroll_layer);
1413 scroll_layer->set_user_scrollable_vertical(false); 1421 scroll_layer->set_user_scrollable_vertical(false);
1414 1422
1415 scrollbar_controller_->DidScrollBegin(); 1423 scrollbar_controller_->DidScrollBegin();
1416 1424
1417 scrollbar_controller_->DidScrollUpdate(); 1425 scrollbar_controller_->DidScrollUpdate();
1418 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1426 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1419 1427
1420 scrollbar_controller_->DidScrollEnd(); 1428 scrollbar_controller_->DidScrollEnd();
1421 } 1429 }
1422 1430
1423 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, 1431 TEST_F(VerticalScrollbarAnimationControllerAndroidTest,
1424 HideOnUserNonScrollableVert) { 1432 HideOnUserNonScrollableVert) {
1425 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); 1433 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation());
1426 1434
1427 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 1435 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
1428 ASSERT_TRUE(scroll_layer); 1436 ASSERT_TRUE(scroll_layer);
1429 scroll_layer->set_user_scrollable_vertical(false); 1437 scroll_layer->set_user_scrollable_vertical(false);
1430 1438
1431 scrollbar_controller_->DidScrollBegin(); 1439 scrollbar_controller_->DidScrollBegin();
1432 1440
1433 scrollbar_controller_->DidScrollUpdate(); 1441 scrollbar_controller_->DidScrollUpdate();
1434 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1442 EXPECT_FLOAT_EQ(0.0f, OpacityForLayer(scrollbar_layer_));
1435 1443
1436 scrollbar_controller_->DidScrollEnd(); 1444 scrollbar_controller_->DidScrollEnd();
1437 } 1445 }
1438 1446
1439 TEST_F(VerticalScrollbarAnimationControllerAndroidTest, 1447 TEST_F(VerticalScrollbarAnimationControllerAndroidTest,
1440 ShowOnUserNonScrollableHorz) { 1448 ShowOnUserNonScrollableHorz) {
1441 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation()); 1449 EXPECT_EQ(VERTICAL, scrollbar_layer_->orientation());
1442 1450
1443 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1); 1451 LayerImpl* scroll_layer = host_impl_.active_tree()->LayerById(1);
1444 ASSERT_TRUE(scroll_layer); 1452 ASSERT_TRUE(scroll_layer);
1445 scroll_layer->set_user_scrollable_horizontal(false); 1453 scroll_layer->set_user_scrollable_horizontal(false);
1446 1454
1447 scrollbar_controller_->DidScrollBegin(); 1455 scrollbar_controller_->DidScrollBegin();
1448 1456
1449 scrollbar_controller_->DidScrollUpdate(); 1457 scrollbar_controller_->DidScrollUpdate();
1450 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1458 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1451 1459
1452 scrollbar_controller_->DidScrollEnd(); 1460 scrollbar_controller_->DidScrollEnd();
1453 } 1461 }
1454 1462
1455 TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByScrollingGesture) { 1463 TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByScrollingGesture) {
1456 base::TimeTicks time; 1464 base::TimeTicks time;
1457 time += base::TimeDelta::FromSeconds(1); 1465 time += base::TimeDelta::FromSeconds(1);
1458 scrollbar_controller_->DidScrollBegin(); 1466 scrollbar_controller_->DidScrollBegin();
1459 EXPECT_FALSE(did_request_animate_); 1467 EXPECT_FALSE(did_request_animate_);
1460 1468
1461 scrollbar_controller_->DidScrollUpdate(); 1469 scrollbar_controller_->DidScrollUpdate();
1462 EXPECT_FALSE(did_request_animate_); 1470 EXPECT_FALSE(did_request_animate_);
1463 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1471 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1464 1472
1465 EXPECT_TRUE(start_fade_.Equals(base::Closure())); 1473 EXPECT_TRUE(start_fade_.Equals(base::Closure()));
1466 1474
1467 time += base::TimeDelta::FromSeconds(100); 1475 time += base::TimeDelta::FromSeconds(100);
1468 1476
1469 scrollbar_controller_->Animate(time); 1477 scrollbar_controller_->Animate(time);
1470 EXPECT_FALSE(did_request_animate_); 1478 EXPECT_FALSE(did_request_animate_);
1471 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1479 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1472 scrollbar_controller_->DidScrollEnd(); 1480 scrollbar_controller_->DidScrollEnd();
1473 EXPECT_FALSE(did_request_animate_); 1481 EXPECT_FALSE(did_request_animate_);
1474 start_fade_.Run(); 1482 start_fade_.Run();
1475 EXPECT_TRUE(did_request_animate_); 1483 EXPECT_TRUE(did_request_animate_);
1476 did_request_animate_ = false; 1484 did_request_animate_ = false;
1477 1485
1478 time += base::TimeDelta::FromSeconds(2); 1486 time += base::TimeDelta::FromSeconds(2);
1479 scrollbar_controller_->Animate(time); 1487 scrollbar_controller_->Animate(time);
1480 EXPECT_TRUE(did_request_animate_); 1488 EXPECT_TRUE(did_request_animate_);
1481 did_request_animate_ = false; 1489 did_request_animate_ = false;
1482 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1490 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1483 1491
1484 time += base::TimeDelta::FromSeconds(1); 1492 time += base::TimeDelta::FromSeconds(1);
1485 scrollbar_controller_->Animate(time); 1493 scrollbar_controller_->Animate(time);
1486 EXPECT_TRUE(did_request_animate_); 1494 EXPECT_TRUE(did_request_animate_);
1487 did_request_animate_ = false; 1495 did_request_animate_ = false;
1488 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); 1496 EXPECT_FLOAT_EQ(2.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1489 1497
1490 time += base::TimeDelta::FromSeconds(1); 1498 time += base::TimeDelta::FromSeconds(1);
1491 scrollbar_controller_->Animate(time); 1499 scrollbar_controller_->Animate(time);
1492 EXPECT_TRUE(did_request_animate_); 1500 EXPECT_TRUE(did_request_animate_);
1493 did_request_animate_ = false; 1501 did_request_animate_ = false;
1494 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); 1502 EXPECT_FLOAT_EQ(1.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1495 1503
1496 time += base::TimeDelta::FromSeconds(1); 1504 time += base::TimeDelta::FromSeconds(1);
1497 1505
1498 scrollbar_controller_->DidScrollBegin(); 1506 scrollbar_controller_->DidScrollBegin();
1499 scrollbar_controller_->DidScrollUpdate(); 1507 scrollbar_controller_->DidScrollUpdate();
1500 scrollbar_controller_->DidScrollEnd(); 1508 scrollbar_controller_->DidScrollEnd();
1501 1509
1502 start_fade_.Run(); 1510 start_fade_.Run();
1503 EXPECT_TRUE(did_request_animate_); 1511 EXPECT_TRUE(did_request_animate_);
1504 did_request_animate_ = false; 1512 did_request_animate_ = false;
1505 1513
1506 time += base::TimeDelta::FromSeconds(2); 1514 time += base::TimeDelta::FromSeconds(2);
1507 scrollbar_controller_->Animate(time); 1515 scrollbar_controller_->Animate(time);
1508 EXPECT_TRUE(did_request_animate_); 1516 EXPECT_TRUE(did_request_animate_);
1509 did_request_animate_ = false; 1517 did_request_animate_ = false;
1510 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1518 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1511 1519
1512 time += base::TimeDelta::FromSeconds(1); 1520 time += base::TimeDelta::FromSeconds(1);
1513 scrollbar_controller_->Animate(time); 1521 scrollbar_controller_->Animate(time);
1514 EXPECT_TRUE(did_request_animate_); 1522 EXPECT_TRUE(did_request_animate_);
1515 did_request_animate_ = false; 1523 did_request_animate_ = false;
1516 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); 1524 EXPECT_FLOAT_EQ(2.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1517 1525
1518 time += base::TimeDelta::FromSeconds(1); 1526 time += base::TimeDelta::FromSeconds(1);
1519 scrollbar_controller_->Animate(time); 1527 scrollbar_controller_->Animate(time);
1520 EXPECT_TRUE(did_request_animate_); 1528 EXPECT_TRUE(did_request_animate_);
1521 did_request_animate_ = false; 1529 did_request_animate_ = false;
1522 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); 1530 EXPECT_FLOAT_EQ(1.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1523 1531
1524 time += base::TimeDelta::FromSeconds(1); 1532 time += base::TimeDelta::FromSeconds(1);
1525 scrollbar_controller_->Animate(time); 1533 scrollbar_controller_->Animate(time);
1526 EXPECT_FALSE(did_request_animate_); 1534 EXPECT_FALSE(did_request_animate_);
1527 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1535 EXPECT_FLOAT_EQ(0.0f, OpacityForLayer(scrollbar_layer_));
1528 } 1536 }
1529 1537
1530 TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByProgrammaticScroll) { 1538 TEST_F(ScrollbarAnimationControllerAndroidTest, AwakenByProgrammaticScroll) {
1531 base::TimeTicks time; 1539 base::TimeTicks time;
1532 time += base::TimeDelta::FromSeconds(1); 1540 time += base::TimeDelta::FromSeconds(1);
1533 scrollbar_controller_->DidScrollUpdate(); 1541 scrollbar_controller_->DidScrollUpdate();
1534 EXPECT_FALSE(did_request_animate_); 1542 EXPECT_FALSE(did_request_animate_);
1535 1543
1536 start_fade_.Run(); 1544 start_fade_.Run();
1537 EXPECT_TRUE(did_request_animate_); 1545 EXPECT_TRUE(did_request_animate_);
1538 did_request_animate_ = false; 1546 did_request_animate_ = false;
1539 scrollbar_controller_->Animate(time); 1547 scrollbar_controller_->Animate(time);
1540 EXPECT_TRUE(did_request_animate_); 1548 EXPECT_TRUE(did_request_animate_);
1541 did_request_animate_ = false; 1549 did_request_animate_ = false;
1542 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1550 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1543 1551
1544 time += base::TimeDelta::FromSeconds(1); 1552 time += base::TimeDelta::FromSeconds(1);
1545 scrollbar_controller_->Animate(time); 1553 scrollbar_controller_->Animate(time);
1546 EXPECT_TRUE(did_request_animate_); 1554 EXPECT_TRUE(did_request_animate_);
1547 did_request_animate_ = false; 1555 did_request_animate_ = false;
1548 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); 1556 EXPECT_FLOAT_EQ(2.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1549 scrollbar_controller_->DidScrollUpdate(); 1557 scrollbar_controller_->DidScrollUpdate();
1550 EXPECT_FALSE(did_request_animate_); 1558 EXPECT_FALSE(did_request_animate_);
1551 1559
1552 start_fade_.Run(); 1560 start_fade_.Run();
1553 EXPECT_TRUE(did_request_animate_); 1561 EXPECT_TRUE(did_request_animate_);
1554 did_request_animate_ = false; 1562 did_request_animate_ = false;
1555 time += base::TimeDelta::FromSeconds(2); 1563 time += base::TimeDelta::FromSeconds(2);
1556 scrollbar_controller_->Animate(time); 1564 scrollbar_controller_->Animate(time);
1557 EXPECT_TRUE(did_request_animate_); 1565 EXPECT_TRUE(did_request_animate_);
1558 did_request_animate_ = false; 1566 did_request_animate_ = false;
1559 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1567 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1560 1568
1561 time += base::TimeDelta::FromSeconds(1); 1569 time += base::TimeDelta::FromSeconds(1);
1562 scrollbar_controller_->Animate(time); 1570 scrollbar_controller_->Animate(time);
1563 EXPECT_TRUE(did_request_animate_); 1571 EXPECT_TRUE(did_request_animate_);
1564 did_request_animate_ = false; 1572 did_request_animate_ = false;
1565 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); 1573 EXPECT_FLOAT_EQ(2.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1566 1574
1567 time += base::TimeDelta::FromSeconds(1); 1575 time += base::TimeDelta::FromSeconds(1);
1568 scrollbar_controller_->Animate(time); 1576 scrollbar_controller_->Animate(time);
1569 EXPECT_TRUE(did_request_animate_); 1577 EXPECT_TRUE(did_request_animate_);
1570 did_request_animate_ = false; 1578 did_request_animate_ = false;
1571 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); 1579 EXPECT_FLOAT_EQ(1.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1572 1580
1573 time += base::TimeDelta::FromSeconds(1); 1581 time += base::TimeDelta::FromSeconds(1);
1574 scrollbar_controller_->DidScrollUpdate(); 1582 scrollbar_controller_->DidScrollUpdate();
1575 start_fade_.Run(); 1583 start_fade_.Run();
1576 time += base::TimeDelta::FromSeconds(1); 1584 time += base::TimeDelta::FromSeconds(1);
1577 scrollbar_controller_->Animate(time); 1585 scrollbar_controller_->Animate(time);
1578 EXPECT_TRUE(did_request_animate_); 1586 EXPECT_TRUE(did_request_animate_);
1579 did_request_animate_ = false; 1587 did_request_animate_ = false;
1580 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1588 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1581 1589
1582 time += base::TimeDelta::FromSeconds(1); 1590 time += base::TimeDelta::FromSeconds(1);
1583 scrollbar_controller_->Animate(time); 1591 scrollbar_controller_->Animate(time);
1584 EXPECT_TRUE(did_request_animate_); 1592 EXPECT_TRUE(did_request_animate_);
1585 did_request_animate_ = false; 1593 did_request_animate_ = false;
1586 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); 1594 EXPECT_FLOAT_EQ(2.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1587 1595
1588 time += base::TimeDelta::FromSeconds(1); 1596 time += base::TimeDelta::FromSeconds(1);
1589 scrollbar_controller_->Animate(time); 1597 scrollbar_controller_->Animate(time);
1590 EXPECT_TRUE(did_request_animate_); 1598 EXPECT_TRUE(did_request_animate_);
1591 did_request_animate_ = false; 1599 did_request_animate_ = false;
1592 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); 1600 EXPECT_FLOAT_EQ(1.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1593 1601
1594 time += base::TimeDelta::FromSeconds(1); 1602 time += base::TimeDelta::FromSeconds(1);
1595 scrollbar_controller_->Animate(time); 1603 scrollbar_controller_->Animate(time);
1596 EXPECT_FALSE(did_request_animate_); 1604 EXPECT_FALSE(did_request_animate_);
1597 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1605 EXPECT_FLOAT_EQ(0.0f, OpacityForLayer(scrollbar_layer_));
1598 } 1606 }
1599 1607
1600 TEST_F(ScrollbarAnimationControllerAndroidTest, 1608 TEST_F(ScrollbarAnimationControllerAndroidTest,
1601 AnimationPreservedByNonScrollingGesture) { 1609 AnimationPreservedByNonScrollingGesture) {
1602 base::TimeTicks time; 1610 base::TimeTicks time;
1603 time += base::TimeDelta::FromSeconds(1); 1611 time += base::TimeDelta::FromSeconds(1);
1604 scrollbar_controller_->DidScrollUpdate(); 1612 scrollbar_controller_->DidScrollUpdate();
1605 start_fade_.Run(); 1613 start_fade_.Run();
1606 EXPECT_TRUE(did_request_animate_); 1614 EXPECT_TRUE(did_request_animate_);
1607 did_request_animate_ = false; 1615 did_request_animate_ = false;
1608 scrollbar_controller_->Animate(time); 1616 scrollbar_controller_->Animate(time);
1609 EXPECT_TRUE(did_request_animate_); 1617 EXPECT_TRUE(did_request_animate_);
1610 did_request_animate_ = false; 1618 did_request_animate_ = false;
1611 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1619 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1612 1620
1613 time += base::TimeDelta::FromSeconds(1); 1621 time += base::TimeDelta::FromSeconds(1);
1614 scrollbar_controller_->Animate(time); 1622 scrollbar_controller_->Animate(time);
1615 EXPECT_TRUE(did_request_animate_); 1623 EXPECT_TRUE(did_request_animate_);
1616 did_request_animate_ = false; 1624 did_request_animate_ = false;
1617 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); 1625 EXPECT_FLOAT_EQ(2.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1618 1626
1619 scrollbar_controller_->DidScrollBegin(); 1627 scrollbar_controller_->DidScrollBegin();
1620 EXPECT_FALSE(did_request_animate_); 1628 EXPECT_FALSE(did_request_animate_);
1621 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); 1629 EXPECT_FLOAT_EQ(2.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1622 1630
1623 time += base::TimeDelta::FromSeconds(1); 1631 time += base::TimeDelta::FromSeconds(1);
1624 scrollbar_controller_->Animate(time); 1632 scrollbar_controller_->Animate(time);
1625 EXPECT_TRUE(did_request_animate_); 1633 EXPECT_TRUE(did_request_animate_);
1626 did_request_animate_ = false; 1634 did_request_animate_ = false;
1627 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); 1635 EXPECT_FLOAT_EQ(1.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1628 1636
1629 scrollbar_controller_->DidScrollEnd(); 1637 scrollbar_controller_->DidScrollEnd();
1630 EXPECT_FALSE(did_request_animate_); 1638 EXPECT_FALSE(did_request_animate_);
1631 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); 1639 EXPECT_FLOAT_EQ(1.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1632 1640
1633 time += base::TimeDelta::FromSeconds(1); 1641 time += base::TimeDelta::FromSeconds(1);
1634 scrollbar_controller_->Animate(time); 1642 scrollbar_controller_->Animate(time);
1635 EXPECT_FALSE(did_request_animate_); 1643 EXPECT_FALSE(did_request_animate_);
1636 EXPECT_FLOAT_EQ(0.0f, scrollbar_layer_->Opacity()); 1644 EXPECT_FLOAT_EQ(0.0f, OpacityForLayer(scrollbar_layer_));
1637 } 1645 }
1638 1646
1639 TEST_F(ScrollbarAnimationControllerAndroidTest, 1647 TEST_F(ScrollbarAnimationControllerAndroidTest,
1640 AnimationOverriddenByScrollingGesture) { 1648 AnimationOverriddenByScrollingGesture) {
1641 base::TimeTicks time; 1649 base::TimeTicks time;
1642 time += base::TimeDelta::FromSeconds(1); 1650 time += base::TimeDelta::FromSeconds(1);
1643 scrollbar_controller_->DidScrollUpdate(); 1651 scrollbar_controller_->DidScrollUpdate();
1644 EXPECT_FALSE(did_request_animate_); 1652 EXPECT_FALSE(did_request_animate_);
1645 start_fade_.Run(); 1653 start_fade_.Run();
1646 EXPECT_TRUE(did_request_animate_); 1654 EXPECT_TRUE(did_request_animate_);
1647 did_request_animate_ = false; 1655 did_request_animate_ = false;
1648 scrollbar_controller_->Animate(time); 1656 scrollbar_controller_->Animate(time);
1649 EXPECT_TRUE(did_request_animate_); 1657 EXPECT_TRUE(did_request_animate_);
1650 did_request_animate_ = false; 1658 did_request_animate_ = false;
1651 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 1659 EXPECT_FLOAT_EQ(1.0f, OpacityForLayer(scrollbar_layer_));
1652 1660
1653 time += base::TimeDelta::FromSeconds(1); 1661 time += base::TimeDelta::FromSeconds(1);
1654 scrollbar_controller_->Animate(time); 1662 scrollbar_controller_->Animate(time);
1655 EXPECT_TRUE(did_request_animate_); 1663 EXPECT_TRUE(did_request_animate_);
1656 did_request_animate_ = false; 1664 did_request_animate_ = false;
1657 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); 1665 EXPECT_FLOAT_EQ(2.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1658 1666
1659 scrollbar_controller_->DidScrollBegin(); 1667 scrollbar_controller_->DidScrollBegin();
1660 EXPECT_FLOAT_EQ(2.0f / 3.0f, scrollbar_layer_->Opacity()); 1668 EXPECT_FLOAT_EQ(2.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1661 1669
1662 time += base::TimeDelta::FromSeconds(1); 1670 time += base::TimeDelta::FromSeconds(1);
1663 scrollbar_controller_->Animate(time); 1671 scrollbar_controller_->Animate(time);
1664 EXPECT_TRUE(did_request_animate_); 1672 EXPECT_TRUE(did_request_animate_);
1665 did_request_animate_ = false; 1673 did_request_animate_ = false;
1666 EXPECT_FLOAT_EQ(1.0f / 3.0f, scrollbar_layer_->Opacity()); 1674 EXPECT_FLOAT_EQ(1.0f / 3.0f, OpacityForLayer(scrollbar_layer_));
1667 1675
1668 time += base::TimeDelta::FromSeconds(1); 1676 time += base::TimeDelta::FromSeconds(1);
1669 scrollbar_controller_->DidScrollUpdate(); 1677 scrollbar_controller_->DidScrollUpdate();
1670 EXPECT_FALSE(did_request_animate_); 1678 EXPECT_FALSE(did_request_animate_);
1671 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1679 EXPECT_FLOAT_EQ(1, OpacityForLayer(scrollbar_layer_));
1672 1680
1673 time += base::TimeDelta::FromSeconds(1); 1681 time += base::TimeDelta::FromSeconds(1);
1674 scrollbar_controller_->DidScrollEnd(); 1682 scrollbar_controller_->DidScrollEnd();
1675 EXPECT_FALSE(did_request_animate_); 1683 EXPECT_FALSE(did_request_animate_);
1676 EXPECT_FLOAT_EQ(1, scrollbar_layer_->Opacity()); 1684 EXPECT_FLOAT_EQ(1, OpacityForLayer(scrollbar_layer_));
1677 } 1685 }
1678 1686
1679 } // namespace 1687 } // namespace
1680 } // namespace cc 1688 } // namespace cc
OLDNEW
« no previous file with comments | « cc/input/scrollbar_animation_controller.cc ('k') | cc/layers/effect_tree_layer_list_iterator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698