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

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

Issue 2358323003: Keep expanded if mouse moves off of scrollbar while dragging (Closed)
Patch Set: fix style and check left button Created 4 years, 2 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_thinning.h" 5 #include "cc/input/scrollbar_animation_controller_thinning.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"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // The thickness now gets big again. 379 // The thickness now gets big again.
380 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor()); 380 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor());
381 381
382 time += base::TimeDelta::FromSeconds(1); 382 time += base::TimeDelta::FromSeconds(1);
383 scrollbar_controller_->Animate(time); 383 scrollbar_controller_->Animate(time);
384 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity()); 384 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity());
385 // The thickness now gets big again. 385 // The thickness now gets big again.
386 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 386 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
387 } 387 }
388 388
389 // First move the pointer on the scrollbar, then press it, then away and move
bokan 2016/09/23 00:39:12 what do you mean by "move down"?
390 // down. Confirm that the bar gets thick and dark. Then mouse up. Confirm that
391 // the bar gets thickness and light.
bokan 2016/09/23 00:39:12 Nit: thickness->thin
392 TEST_F(ScrollbarAnimationControllerThinningTest,
393 MouseCaptureAndReleaseOutOfBar) {
394 base::TimeTicks time;
395
396 // Move in
397 scrollbar_controller_->DidMouseMoveNear(0);
398
399 time += base::TimeDelta::FromSeconds(1);
400 scrollbar_controller_->Animate(time);
401 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity());
402 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor());
403
404 // Should animate to thickened and darkened.
405 time += base::TimeDelta::FromSeconds(1);
406 scrollbar_controller_->Animate(time);
407 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->Opacity());
408 EXPECT_FLOAT_EQ(0.6f, scrollbar_layer_->thumb_thickness_scale_factor());
409
410 time += base::TimeDelta::FromSeconds(1);
bokan 2016/09/23 00:39:12 We're overfitting here. Changing the animation cur
chaopeng 2016/09/23 00:54:57 I have tried jump 5 seconds but cannot get the exp
bokan 2016/09/23 18:06:31 Ah, got it, the duration is set specifically for t
411 scrollbar_controller_->Animate(time);
412 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity());
413 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor());
414
415 time += base::TimeDelta::FromSeconds(1);
416 scrollbar_controller_->Animate(time);
417 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
418 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
419
420 // Capture
421 scrollbar_controller_->DidCaptureScrollbarBegin();
422 time += base::TimeDelta::FromSeconds(1);
423 scrollbar_controller_->Animate(time);
424 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
425 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
426
427 // move away from bar.
428 scrollbar_controller_->DidMouseMoveNear(26);
429
430 // test for 10 seconds, stay thick and dark
431 for (int i = 0; i < 10; ++i) {
432 time += base::TimeDelta::FromSeconds(1);
433 scrollbar_controller_->Animate(time);
434 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
435 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
436 }
437
438 // release
439 scrollbar_controller_->DidCaptureScrollbarEnd();
440
441 // get thickness and light
442 time += base::TimeDelta::FromSeconds(1);
443 scrollbar_controller_->Animate(time);
444 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
445 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
446
447 time += base::TimeDelta::FromSeconds(1);
448 scrollbar_controller_->Animate(time);
449 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity());
450 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor());
451
452 time += base::TimeDelta::FromSeconds(1);
453 scrollbar_controller_->Animate(time);
454 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->Opacity());
455 EXPECT_FLOAT_EQ(0.6f, scrollbar_layer_->thumb_thickness_scale_factor());
456
457 time += base::TimeDelta::FromSeconds(1);
458 scrollbar_controller_->Animate(time);
459 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity());
460 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor());
461 }
462
463 // First move the pointer on the scrollbar, then press it, then away and move
464 // down. Confirm that the bar gets thick and dark. Then move point on the
465 // scrollbar and mouse up. Confirm that the bar gets thick and dark.
466 TEST_F(ScrollbarAnimationControllerThinningTest, MouseCaptureAndReleaseOnBar) {
467 base::TimeTicks time;
468
469 // Move in
470 scrollbar_controller_->DidMouseMoveNear(0);
471
472 time += base::TimeDelta::FromSeconds(1);
473 scrollbar_controller_->Animate(time);
474 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity());
475 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor());
476
477 // Should animate to thickened and darkened.
478 time += base::TimeDelta::FromSeconds(1);
479 scrollbar_controller_->Animate(time);
480 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->Opacity());
481 EXPECT_FLOAT_EQ(0.6f, scrollbar_layer_->thumb_thickness_scale_factor());
482
483 time += base::TimeDelta::FromSeconds(1);
484 scrollbar_controller_->Animate(time);
485 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity());
486 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor());
487
488 time += base::TimeDelta::FromSeconds(1);
489 scrollbar_controller_->Animate(time);
490 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
491 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
492
493 // Capture
494 scrollbar_controller_->DidCaptureScrollbarBegin();
495 time += base::TimeDelta::FromSeconds(1);
496 scrollbar_controller_->Animate(time);
497 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
498 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
499
500 // move away from bar.
501 scrollbar_controller_->DidMouseMoveNear(26);
502
503 // test for 10 seconds, stay thick and dark
504 for (int i = 0; i < 10; ++i) {
505 time += base::TimeDelta::FromSeconds(1);
506 scrollbar_controller_->Animate(time);
bokan 2016/09/23 00:39:12 I'd add some DidMouseMoveNear calls here to make s
507 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
508 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
509 }
510
511 // move to the bar.
512 scrollbar_controller_->DidMouseMoveNear(0);
513
514 // release
515 scrollbar_controller_->DidCaptureScrollbarEnd();
516
517 // stay thick and dark
518 // test for 10 seconds, stay thick and dark
519 for (int i = 0; i < 10; ++i) {
520 time += base::TimeDelta::FromSeconds(1);
521 scrollbar_controller_->Animate(time);
522 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
523 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
524 }
525 }
526
389 } // namespace 527 } // namespace
390 } // namespace cc 528 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698