| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "ui/views/animation/ink_drop_animation_controller_impl.h" | 5 #include "ui/views/animation/ink_drop_animation_controller_impl.h" |
| 6 | 6 |
| 7 #include "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/test/test_simple_task_runner.h" | 8 #include "base/test/test_simple_task_runner.h" |
| 9 #include "base/thread_task_runner_handle.h" | 9 #include "base/thread_task_runner_handle.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 EXPECT_TRUE(is_hover_fading_in_or_visible()); | 66 EXPECT_TRUE(is_hover_fading_in_or_visible()); |
| 67 | 67 |
| 68 ink_drop_animation_controller_.SetHovered(false); | 68 ink_drop_animation_controller_.SetHovered(false); |
| 69 EXPECT_FALSE(is_hover_fading_in_or_visible()); | 69 EXPECT_FALSE(is_hover_fading_in_or_visible()); |
| 70 } | 70 } |
| 71 | 71 |
| 72 TEST_F(InkDropAnimationControllerImplTest, | 72 TEST_F(InkDropAnimationControllerImplTest, |
| 73 HoverDoesntFadeInAfterAnimationIfHoverNotSet) { | 73 HoverDoesntFadeInAfterAnimationIfHoverNotSet) { |
| 74 ink_drop_host_.set_should_show_hover(true); | 74 ink_drop_host_.set_should_show_hover(true); |
| 75 ink_drop_animation_controller_.SetHovered(false); | 75 ink_drop_animation_controller_.SetHovered(false); |
| 76 ink_drop_animation_controller_.AnimateToState(InkDropState::QUICK_ACTION); | 76 ink_drop_animation_controller_.AnimateToState(InkDropState::ACTION_TRIGGERED); |
| 77 | 77 |
| 78 EXPECT_FALSE(task_runner_->HasPendingTask()); | 78 EXPECT_FALSE(task_runner_->HasPendingTask()); |
| 79 EXPECT_FALSE(is_hover_fading_in_or_visible()); | 79 EXPECT_FALSE(is_hover_fading_in_or_visible()); |
| 80 } | 80 } |
| 81 | 81 |
| 82 TEST_F(InkDropAnimationControllerImplTest, | 82 TEST_F(InkDropAnimationControllerImplTest, |
| 83 HoverFadesInAfterAnimationWhenHostIsHovered) { | 83 HoverFadesInAfterAnimationWhenHostIsHovered) { |
| 84 ink_drop_host_.set_should_show_hover(true); | 84 ink_drop_host_.set_should_show_hover(true); |
| 85 ink_drop_animation_controller_.SetHovered(true); | 85 ink_drop_animation_controller_.SetHovered(true); |
| 86 ink_drop_animation_controller_.AnimateToState(InkDropState::QUICK_ACTION); | 86 ink_drop_animation_controller_.AnimateToState(InkDropState::ACTION_TRIGGERED); |
| 87 | 87 |
| 88 EXPECT_TRUE(task_runner_->HasPendingTask()); | 88 EXPECT_TRUE(task_runner_->HasPendingTask()); |
| 89 | 89 |
| 90 task_runner_->RunPendingTasks(); | 90 task_runner_->RunPendingTasks(); |
| 91 | 91 |
| 92 EXPECT_TRUE(is_hover_fading_in_or_visible()); | 92 EXPECT_TRUE(is_hover_fading_in_or_visible()); |
| 93 } | 93 } |
| 94 | 94 |
| 95 TEST_F(InkDropAnimationControllerImplTest, | 95 TEST_F(InkDropAnimationControllerImplTest, |
| 96 HoverDoesntFadeInAfterAnimationWhenHostIsNotHovered) { | 96 HoverDoesntFadeInAfterAnimationWhenHostIsNotHovered) { |
| 97 ink_drop_host_.set_should_show_hover(false); | 97 ink_drop_host_.set_should_show_hover(false); |
| 98 ink_drop_animation_controller_.SetHovered(true); | 98 ink_drop_animation_controller_.SetHovered(true); |
| 99 ink_drop_animation_controller_.AnimateToState(InkDropState::QUICK_ACTION); | 99 ink_drop_animation_controller_.AnimateToState(InkDropState::ACTION_TRIGGERED); |
| 100 | 100 |
| 101 EXPECT_TRUE(task_runner_->HasPendingTask()); | 101 EXPECT_TRUE(task_runner_->HasPendingTask()); |
| 102 | 102 |
| 103 task_runner_->RunPendingTasks(); | 103 task_runner_->RunPendingTasks(); |
| 104 | 104 |
| 105 EXPECT_FALSE(is_hover_fading_in_or_visible()); | 105 EXPECT_FALSE(is_hover_fading_in_or_visible()); |
| 106 } | 106 } |
| 107 | 107 |
| 108 TEST_F(InkDropAnimationControllerImplTest, | 108 TEST_F(InkDropAnimationControllerImplTest, |
| 109 HoveredStateNotVisibleOrFadingInAfterAnimateToState) { | 109 HoveredStateNotVisibleOrFadingInAfterAnimateToState) { |
| 110 ink_drop_host_.set_should_show_hover(true); | 110 ink_drop_host_.set_should_show_hover(true); |
| 111 | 111 |
| 112 ink_drop_animation_controller_.SetHovered(true); | 112 ink_drop_animation_controller_.SetHovered(true); |
| 113 EXPECT_TRUE(is_hover_fading_in_or_visible()); | 113 EXPECT_TRUE(is_hover_fading_in_or_visible()); |
| 114 | 114 |
| 115 ink_drop_animation_controller_.AnimateToState(InkDropState::QUICK_ACTION); | 115 ink_drop_animation_controller_.AnimateToState(InkDropState::ACTION_TRIGGERED); |
| 116 EXPECT_FALSE(is_hover_fading_in_or_visible()); | 116 EXPECT_FALSE(is_hover_fading_in_or_visible()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 // Verifies that there is not a crash when setting hovered state and the host | 119 // Verifies that there is not a crash when setting hovered state and the host |
| 120 // returns null for the hover. | 120 // returns null for the hover. |
| 121 TEST_F(InkDropAnimationControllerImplTest, | 121 TEST_F(InkDropAnimationControllerImplTest, |
| 122 SetHoveredFalseWorksWhenNoInkDropHoverExists) { | 122 SetHoveredFalseWorksWhenNoInkDropHoverExists) { |
| 123 ink_drop_host_.set_should_show_hover(false); | 123 ink_drop_host_.set_should_show_hover(false); |
| 124 ink_drop_animation_controller_.SetHovered(true); | 124 ink_drop_animation_controller_.SetHovered(true); |
| 125 EXPECT_FALSE(hover()); | 125 EXPECT_FALSE(hover()); |
| 126 ink_drop_animation_controller_.SetHovered(false); | 126 ink_drop_animation_controller_.SetHovered(false); |
| 127 EXPECT_FALSE(hover()); | 127 EXPECT_FALSE(hover()); |
| 128 } | 128 } |
| 129 | 129 |
| 130 TEST_F(InkDropAnimationControllerImplTest, HoverFadesOutOnSnapToActivated) { | 130 TEST_F(InkDropAnimationControllerImplTest, HoverFadesOutOnSnapToActivated) { |
| 131 ink_drop_host_.set_should_show_hover(true); | 131 ink_drop_host_.set_should_show_hover(true); |
| 132 ink_drop_animation_controller_.SetHovered(true); | 132 ink_drop_animation_controller_.SetHovered(true); |
| 133 | 133 |
| 134 EXPECT_TRUE(is_hover_fading_in_or_visible()); | 134 EXPECT_TRUE(is_hover_fading_in_or_visible()); |
| 135 | 135 |
| 136 ink_drop_animation_controller_.SnapToActivated(); | 136 ink_drop_animation_controller_.SnapToActivated(); |
| 137 | 137 |
| 138 EXPECT_FALSE(is_hover_fading_in_or_visible()); | 138 EXPECT_FALSE(is_hover_fading_in_or_visible()); |
| 139 } | 139 } |
| 140 | 140 |
| 141 } // namespace views | 141 } // namespace views |
| OLD | NEW |