Chromium Code Reviews| 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_ripple.h" | 5 #include "ui/views/animation/ink_drop_ripple.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/gfx/geometry/insets.h" | 11 #include "ui/gfx/geometry/insets.h" |
| 12 #include "ui/gfx/geometry/size.h" | 12 #include "ui/gfx/geometry/size.h" |
| 13 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" | 13 #include "ui/views/animation/flood_fill_ink_drop_ripple.h" |
| 14 #include "ui/views/animation/ink_drop_ripple_observer.h" | 14 #include "ui/views/animation/ink_drop_ripple_observer.h" |
| 15 #include "ui/views/animation/ink_drop_state.h" | 15 #include "ui/views/animation/ink_drop_state.h" |
| 16 #include "ui/views/animation/square_ink_drop_ripple.h" | 16 #include "ui/views/animation/square_ink_drop_ripple.h" |
| 17 #include "ui/views/animation/test/flood_fill_ink_drop_ripple_test_api.h" | 17 #include "ui/views/animation/test/flood_fill_ink_drop_ripple_test_api.h" |
| 18 #include "ui/views/animation/test/ink_drop_ripple_test_api.h" | 18 #include "ui/views/animation/test/ink_drop_ripple_test_api.h" |
| 19 #include "ui/views/animation/test/square_ink_drop_ripple_test_api.h" | 19 #include "ui/views/animation/test/square_ink_drop_ripple_test_api.h" |
| 20 #include "ui/views/animation/test/test_ink_drop_ripple_observer.h" | 20 #include "ui/views/animation/test/test_ink_drop_ripple_observer.h" |
| 21 | 21 |
| 22 namespace views { | 22 namespace views { |
| 23 namespace test { | 23 namespace test { |
| 24 namespace { | |
| 25 | |
| 26 std::string InkDropStatesToString(const std::vector<InkDropState>& states) { | |
| 27 std::string result; | |
| 28 for (size_t i = 0; i < states.size(); i++) { | |
| 29 if (i) | |
| 30 result += " "; | |
| 31 result += ToString(states[i]); | |
| 32 } | |
| 33 return result; | |
| 34 } | |
| 35 | |
| 36 } | |
| 24 | 37 |
| 25 const float kVisibleOpacity = 0.175f; | 38 const float kVisibleOpacity = 0.175f; |
| 26 | 39 |
| 27 // Represents all the derivatives of the InkDropRipple class. To be used with | 40 // Represents all the derivatives of the InkDropRipple class. To be used with |
| 28 // the InkDropRippleTest fixture to test all derviatives. | 41 // the InkDropRippleTest fixture to test all derviatives. |
| 29 enum InkDropRippleTestTypes { | 42 enum InkDropRippleTestTypes { |
| 30 SQUARE_INK_DROP_RIPPLE, | 43 SQUARE_INK_DROP_RIPPLE, |
| 31 FLOOD_FILL_INK_DROP_RIPPLE | 44 FLOOD_FILL_INK_DROP_RIPPLE |
| 32 }; | 45 }; |
| 33 | 46 |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 | 364 |
| 352 ink_drop_ripple_->AnimateToState(views::InkDropState::HIDDEN); | 365 ink_drop_ripple_->AnimateToState(views::InkDropState::HIDDEN); |
| 353 | 366 |
| 354 test_api_->CompleteAnimations(); | 367 test_api_->CompleteAnimations(); |
| 355 | 368 |
| 356 EXPECT_TRUE(observer_.AnimationHasEnded()); | 369 EXPECT_TRUE(observer_.AnimationHasEnded()); |
| 357 EXPECT_EQ(views::InkDropState::HIDDEN, | 370 EXPECT_EQ(views::InkDropState::HIDDEN, |
| 358 observer_.target_state_at_last_animation_ended()); | 371 observer_.target_state_at_last_animation_ended()); |
| 359 } | 372 } |
| 360 | 373 |
| 374 // Verifies that when an we ink drop transitions from ACTION_PENDING to | |
| 375 // ACTIVATED state, animation observers are called in order. | |
| 376 TEST_P(InkDropRippleTest, RipplePendingToActivatedObserverOrder) { | |
| 377 ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING); | |
| 378 ink_drop_ripple_->AnimateToState(views::InkDropState::ACTIVATED); | |
| 379 test_api_->CompleteAnimations(); | |
| 380 | |
| 381 EXPECT_EQ( | |
| 382 "ACTION_PENDING ACTIVATED", | |
|
bruthig
2017/01/10 17:08:03
How come you are building concatenated strings her
mohsen
2017/01/10 22:28:16
Yeah, I also prefer gmock matchers, but gmock is f
bruthig
2017/01/11 00:41:07
Hmm that's unfortunate. Is that documented somewh
mohsen
2017/01/11 15:59:44
It is explicitly banned in ui/views/DEPS file (see
bruthig
2017/01/11 18:22:30
Thx
| |
| 383 InkDropStatesToString(observer_.GetAndResetAnimationStartedStates())); | |
| 384 EXPECT_EQ("ACTION_PENDING ACTIVATED", | |
| 385 InkDropStatesToString(observer_.GetAndResetAnimationEndedStates())); | |
| 386 } | |
| 387 | |
| 361 } // namespace test | 388 } // namespace test |
| 362 } // namespace views | 389 } // namespace views |
| OLD | NEW |