| 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_impl.h" | 5 #include "ui/views/animation/ink_drop_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/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/views/animation/ink_drop_ripple.h" | |
| 12 #include "ui/views/animation/test/ink_drop_impl_test_api.h" | 11 #include "ui/views/animation/test/ink_drop_impl_test_api.h" |
| 13 #include "ui/views/animation/test/test_ink_drop_host.h" | 12 #include "ui/views/animation/test/test_ink_drop_host.h" |
| 14 | 13 |
| 15 namespace views { | 14 namespace views { |
| 16 | 15 |
| 17 // NOTE: The InkDropImpl class is also tested by the InkDropFactoryTest tests. | 16 // NOTE: The InkDropImpl class is also tested by the InkDropFactoryTest tests. |
| 18 class InkDropImplTest : public testing::Test { | 17 class InkDropImplTest : public testing::Test { |
| 19 public: | 18 public: |
| 20 InkDropImplTest(); | 19 InkDropImplTest(); |
| 21 ~InkDropImplTest() override; | 20 ~InkDropImplTest() override; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 245 |
| 247 test_api_.CompleteAnimations(); | 246 test_api_.CompleteAnimations(); |
| 248 | 247 |
| 249 ink_drop_.SetHovered(false); | 248 ink_drop_.SetHovered(false); |
| 250 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); | 249 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); |
| 251 | 250 |
| 252 ink_drop_.SetHovered(true); | 251 ink_drop_.SetHovered(true); |
| 253 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); | 252 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); |
| 254 } | 253 } |
| 255 | 254 |
| 255 TEST_F(InkDropImplTest, AnimationWhenDeactivated) { |
| 256 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers()); |
| 257 |
| 258 ink_drop_.AnimateToState(InkDropState::ACTIVATED); |
| 259 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); |
| 260 test_api_.CompleteAnimations(); |
| 261 |
| 262 ink_drop_.AnimateToState(InkDropState::DEACTIVATED); |
| 263 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); |
| 264 EXPECT_TRUE(test_api_.HasActiveAnimations()); |
| 265 EXPECT_FALSE(test_api_.IsHighlightFadingInOrVisible()); |
| 266 } |
| 267 |
| 268 TEST_F(InkDropImplTest, AnimationSkippedWhenFocusedAndDeactivated) { |
| 269 ink_drop_host_.set_should_show_highlight(true); |
| 270 |
| 271 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers()); |
| 272 |
| 273 ink_drop_.SetFocused(true); |
| 274 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); |
| 275 |
| 276 ink_drop_.AnimateToState(InkDropState::ACTIVATED); |
| 277 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); |
| 278 test_api_.CompleteAnimations(); |
| 279 |
| 280 ink_drop_.AnimateToState(InkDropState::DEACTIVATED); |
| 281 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); |
| 282 EXPECT_FALSE(test_api_.HasActiveAnimations()); |
| 283 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible()); |
| 284 EXPECT_EQ(InkDropState::HIDDEN, ink_drop_.GetTargetInkDropState()); |
| 285 } |
| 286 |
| 287 TEST_F(InkDropImplTest, FocusHighlightComesBackImmediatelyAfterAction) { |
| 288 ink_drop_host_.set_should_show_highlight(true); |
| 289 |
| 290 EXPECT_EQ(0, ink_drop_host_.num_ink_drop_layers()); |
| 291 |
| 292 ink_drop_.SetFocused(true); |
| 293 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); |
| 294 |
| 295 ink_drop_.AnimateToState(InkDropState::ACTION_PENDING); |
| 296 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); |
| 297 |
| 298 ink_drop_.AnimateToState(InkDropState::ACTION_TRIGGERED); |
| 299 EXPECT_EQ(1, ink_drop_host_.num_ink_drop_layers()); |
| 300 |
| 301 test_api_.CompleteAnimations(); |
| 302 |
| 303 // No delay (unlike in the hover case). |
| 304 EXPECT_FALSE(task_runner_->HasPendingTask()); |
| 305 |
| 306 // Highlight should be back. |
| 307 EXPECT_TRUE(test_api_.IsHighlightFadingInOrVisible()); |
| 308 } |
| 309 |
| 256 } // namespace views | 310 } // namespace views |
| OLD | NEW |