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

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

Issue 2384053002: cancel overlay-scrollbar hover state when moving pointer out of window for ChromeOS (Closed)
Patch Set: remove fix for not chromeos 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 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 // stay thick and dark 511 // stay thick and dark
512 // test for 10 seconds, stay thick and dark 512 // test for 10 seconds, stay thick and dark
513 for (int i = 0; i < 10; ++i) { 513 for (int i = 0; i < 10; ++i) {
514 time += base::TimeDelta::FromSeconds(1); 514 time += base::TimeDelta::FromSeconds(1);
515 scrollbar_controller_->Animate(time); 515 scrollbar_controller_->Animate(time);
516 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity()); 516 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
517 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor()); 517 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
518 } 518 }
519 } 519 }
520 520
521 // Move mouse on scrollbar then move out of window. Confirm that the bar gets
522 // thin and light.
523 TEST_F(ScrollbarAnimationControllerThinningTest, MouseExitWindowFromScrollbar) {
524 base::TimeTicks time;
525 time += base::TimeDelta::FromSeconds(1);
526
527 // Move in
528 scrollbar_controller_->DidMouseMoveNear(0);
529
530 scrollbar_controller_->Animate(time);
531 time += base::TimeDelta::FromSeconds(kDuration);
532 scrollbar_controller_->Animate(time);
533 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
534 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
535
536 // move out of window
537 scrollbar_controller_->DidMouseLeave();
538
539 // get thin and light
540 time += base::TimeDelta::FromSeconds(1);
541 scrollbar_controller_->Animate(time);
542 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
543 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
544
545 time += base::TimeDelta::FromSeconds(1);
546 scrollbar_controller_->Animate(time);
547 EXPECT_FLOAT_EQ(0.9f, scrollbar_layer_->Opacity());
548 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->thumb_thickness_scale_factor());
549
550 time += base::TimeDelta::FromSeconds(1);
551 scrollbar_controller_->Animate(time);
552 EXPECT_FLOAT_EQ(0.8f, scrollbar_layer_->Opacity());
553 EXPECT_FLOAT_EQ(0.6f, scrollbar_layer_->thumb_thickness_scale_factor());
554
555 time += base::TimeDelta::FromSeconds(1);
556 scrollbar_controller_->Animate(time);
557 EXPECT_FLOAT_EQ(0.7f, scrollbar_layer_->Opacity());
558 EXPECT_FLOAT_EQ(0.4f, scrollbar_layer_->thumb_thickness_scale_factor());
559 }
560
561 // Move mouse on scrollbar and capture then move out of window. Confirm that
562 // the bar stays thick and dark.
563 TEST_F(ScrollbarAnimationControllerThinningTest,
564 MouseCapturedAndExitWindowFromScrollbar) {
565 base::TimeTicks time;
566 time += base::TimeDelta::FromSeconds(1);
567
568 // Move in
569 scrollbar_controller_->DidMouseMoveNear(0);
570
571 scrollbar_controller_->Animate(time);
572 time += base::TimeDelta::FromSeconds(kDuration);
573 scrollbar_controller_->Animate(time);
574 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
575 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
576
577 // Capture
578 scrollbar_controller_->DidCaptureScrollbarBegin();
579 time += base::TimeDelta::FromSeconds(1);
580 scrollbar_controller_->Animate(time);
581 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
582 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
583
584 // move out of window
585 scrollbar_controller_->DidMouseLeave();
586
587 // test for 10 seconds, stay thick and dark
588 for (int i = 0; i < 10; ++i) {
589 time += base::TimeDelta::FromSeconds(1);
590 scrollbar_controller_->Animate(time);
591 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->Opacity());
592 EXPECT_FLOAT_EQ(1.0f, scrollbar_layer_->thumb_thickness_scale_factor());
593 }
594 }
595
521 } // namespace 596 } // namespace
522 } // namespace cc 597 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698