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

Unified Diff: ui/views/animation/ink_drop_ripple_unittest.cc

Issue 2340993002: Tweaks to "Allow InkDropRipple to co-exist with highlight or not exist at all." (Closed)
Patch Set: Fixed InkDropImplTest.HighlightCanExistWithoutRipple. Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: ui/views/animation/ink_drop_ripple_unittest.cc
diff --git a/ui/views/animation/ink_drop_ripple_unittest.cc b/ui/views/animation/ink_drop_ripple_unittest.cc
index b4bbc5446c031e17284878d4d36eb8eb5ace3603..34629b63b330e8be2ac824b905bf3c4b6e7653f3 100644
--- a/ui/views/animation/ink_drop_ripple_unittest.cc
+++ b/ui/views/animation/ink_drop_ripple_unittest.cc
@@ -13,6 +13,7 @@
#include "ui/views/animation/ink_drop_ripple_observer.h"
#include "ui/views/animation/ink_drop_state.h"
#include "ui/views/animation/square_ink_drop_ripple.h"
+#include "ui/views/animation/test/empty_ink_drop_ripple_test_api.h"
#include "ui/views/animation/test/flood_fill_ink_drop_ripple_test_api.h"
#include "ui/views/animation/test/ink_drop_ripple_test_api.h"
#include "ui/views/animation/test/square_ink_drop_ripple_test_api.h"
@@ -27,17 +28,22 @@ const float kVisibleOpacity = 0.175f;
// the InkDropRippleTest fixture to test all derviatives.
enum InkDropRippleTestTypes {
SQUARE_INK_DROP_RIPPLE,
- FLOOD_FILL_INK_DROP_RIPPLE
+ FLOOD_FILL_INK_DROP_RIPPLE,
+ EMPTY_INK_DROP_RIPPLE,
};
// Test fixture for all InkDropRipple class derivatives.
//
// To add a new derivative:
-// 1. Add a value to the InkDropRippleTestTypes enum.
-// 2. Implement set up and tear down code for the new enum value in
-// InkDropRippleTest() and
-// ~InkDropRippleTest().
-// 3. Add the new enum value to the INSTANTIATE_TEST_CASE_P) Values list.
+// 1. Add a value to the InkDropRippleTestTypes enum.
+// 2. Implement set up and tear down code for the new enum value in
+// InkDropRippleTest() and ~InkDropRippleTest().
+// 3a. If the new InkDropRipple type has animations with a duration then add
+// the new enum value to the INSTANTIATE_TEST_CASE_P(InkDropRippleTest)
+// Values list.
+// 3b. If the new InkDropRipple type doesn't have animations with a duration
+// then add the new enum value to the
+// INSTANTIATE_TEST_CASE_P(AnimationInkDropRippleTest) Values list.
class InkDropRippleTest
: public testing::TestWithParam<InkDropRippleTestTypes> {
public:
@@ -74,6 +80,11 @@ InkDropRippleTest::InkDropRippleTest() {
new FloodFillInkDropRippleTestApi(flood_fill_ink_drop_ripple));
break;
}
+ case EMPTY_INK_DROP_RIPPLE:
+ EmptyInkDropRipple* empty_ink_drop_ripple = new EmptyInkDropRipple();
+ ink_drop_ripple_.reset(empty_ink_drop_ripple);
+ test_api_.reset(new EmptyInkDropRippleTestApi(empty_ink_drop_ripple));
+ break;
}
ink_drop_ripple_->set_observer(&observer_);
observer_.set_ink_drop_ripple(ink_drop_ripple_.get());
@@ -87,6 +98,18 @@ InkDropRippleTest::~InkDropRippleTest() {}
INSTANTIATE_TEST_CASE_P(,
InkDropRippleTest,
testing::Values(SQUARE_INK_DROP_RIPPLE,
+ FLOOD_FILL_INK_DROP_RIPPLE,
+ EMPTY_INK_DROP_RIPPLE));
+
+// Provides a test fixture scope for all InkDropRipple flavors that have
+// animations with a duration.
+using AnimationInkDropRippleTest = InkDropRippleTest;
+
+// Note: First argument is optional and intentionally left blank.
+// (it's a prefix for the generated test cases)
+INSTANTIATE_TEST_CASE_P(,
+ AnimationInkDropRippleTest,
+ testing::Values(SQUARE_INK_DROP_RIPPLE,
FLOOD_FILL_INK_DROP_RIPPLE));
TEST_P(InkDropRippleTest, InitialStateAfterConstruction) {
@@ -95,7 +118,7 @@ TEST_P(InkDropRippleTest, InitialStateAfterConstruction) {
}
// Verify no animations are used when animating from HIDDEN to HIDDEN.
-TEST_P(InkDropRippleTest, AnimateToHiddenFromInvisibleState) {
+TEST_P(AnimationInkDropRippleTest, AnimateToHiddenFromInvisibleState) {
EXPECT_EQ(InkDropState::HIDDEN, ink_drop_ripple_->target_ink_drop_state());
ink_drop_ripple_->AnimateToState(InkDropState::HIDDEN);
@@ -105,7 +128,7 @@ TEST_P(InkDropRippleTest, AnimateToHiddenFromInvisibleState) {
EXPECT_FALSE(ink_drop_ripple_->IsVisible());
}
-TEST_P(InkDropRippleTest, AnimateToHiddenFromVisibleState) {
+TEST_P(AnimationInkDropRippleTest, AnimateToHiddenFromVisibleState) {
ink_drop_ripple_->AnimateToState(InkDropState::ACTION_PENDING);
test_api_->CompleteAnimations();
EXPECT_EQ(1, observer_.last_animation_started_ordinal());
@@ -121,14 +144,14 @@ TEST_P(InkDropRippleTest, AnimateToHiddenFromVisibleState) {
EXPECT_EQ(InkDropRipple::kHiddenOpacity, test_api_->GetCurrentOpacity());
}
-TEST_P(InkDropRippleTest, ActionPendingOpacity) {
+TEST_P(AnimationInkDropRippleTest, ActionPendingOpacity) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING);
test_api_->CompleteAnimations();
EXPECT_EQ(kVisibleOpacity, test_api_->GetCurrentOpacity());
}
-TEST_P(InkDropRippleTest, QuickActionOpacity) {
+TEST_P(AnimationInkDropRippleTest, QuickActionOpacity) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING);
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_TRIGGERED);
test_api_->CompleteAnimations();
@@ -136,7 +159,7 @@ TEST_P(InkDropRippleTest, QuickActionOpacity) {
EXPECT_EQ(InkDropRipple::kHiddenOpacity, test_api_->GetCurrentOpacity());
}
-TEST_P(InkDropRippleTest, SlowActionPendingOpacity) {
+TEST_P(AnimationInkDropRippleTest, SlowActionPendingOpacity) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING);
ink_drop_ripple_->AnimateToState(
views::InkDropState::ALTERNATE_ACTION_PENDING);
@@ -145,7 +168,7 @@ TEST_P(InkDropRippleTest, SlowActionPendingOpacity) {
EXPECT_EQ(kVisibleOpacity, test_api_->GetCurrentOpacity());
}
-TEST_P(InkDropRippleTest, SlowActionOpacity) {
+TEST_P(AnimationInkDropRippleTest, SlowActionOpacity) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING);
ink_drop_ripple_->AnimateToState(
views::InkDropState::ALTERNATE_ACTION_PENDING);
@@ -156,14 +179,14 @@ TEST_P(InkDropRippleTest, SlowActionOpacity) {
EXPECT_EQ(InkDropRipple::kHiddenOpacity, test_api_->GetCurrentOpacity());
}
-TEST_P(InkDropRippleTest, ActivatedOpacity) {
+TEST_P(AnimationInkDropRippleTest, ActivatedOpacity) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTIVATED);
test_api_->CompleteAnimations();
EXPECT_EQ(kVisibleOpacity, test_api_->GetCurrentOpacity());
}
-TEST_P(InkDropRippleTest, DeactivatedOpacity) {
+TEST_P(AnimationInkDropRippleTest, DeactivatedOpacity) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTIVATED);
ink_drop_ripple_->AnimateToState(views::InkDropState::DEACTIVATED);
test_api_->CompleteAnimations();
@@ -173,7 +196,7 @@ TEST_P(InkDropRippleTest, DeactivatedOpacity) {
// Verify animations are aborted during deletion and the
// InkDropRippleObservers are notified.
-TEST_P(InkDropRippleTest, AnimationsAbortedDuringDeletion) {
+TEST_P(AnimationInkDropRippleTest, AnimationsAbortedDuringDeletion) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING);
ink_drop_ripple_.reset();
EXPECT_EQ(1, observer_.last_animation_started_ordinal());
@@ -187,6 +210,21 @@ TEST_P(InkDropRippleTest, AnimationsAbortedDuringDeletion) {
TEST_P(InkDropRippleTest, VerifyObserversAreNotified) {
ink_drop_ripple_->AnimateToState(InkDropState::ACTION_PENDING);
+ test_api_->CompleteAnimations();
+
+ EXPECT_EQ(1, observer_.last_animation_started_ordinal());
+ EXPECT_EQ(InkDropState::ACTION_PENDING,
+ observer_.last_animation_started_context());
+
+ EXPECT_EQ(2, observer_.last_animation_ended_ordinal());
+ EXPECT_EQ(InkDropState::ACTION_PENDING,
+ observer_.last_animation_ended_context());
+}
+
+TEST_P(AnimationInkDropRippleTest,
+ VerifyAnimationEndedIsNotifiedAfterAnimations) {
+ ink_drop_ripple_->AnimateToState(InkDropState::ACTION_PENDING);
+
EXPECT_TRUE(test_api_->HasActiveAnimations());
EXPECT_EQ(1, observer_.last_animation_started_ordinal());
EXPECT_TRUE(observer_.AnimationHasNotEnded());
@@ -211,7 +249,8 @@ TEST_P(InkDropRippleTest, VerifyObserversAreNotifiedOfSuccessfulAnimations) {
observer_.last_animation_ended_reason());
}
-TEST_P(InkDropRippleTest, VerifyObserversAreNotifiedOfPreemptedAnimations) {
+TEST_P(AnimationInkDropRippleTest,
+ VerifyObserversAreNotifiedOfPreemptedAnimations) {
ink_drop_ripple_->AnimateToState(InkDropState::ACTION_PENDING);
ink_drop_ripple_->AnimateToState(InkDropState::ALTERNATE_ACTION_PENDING);
@@ -227,7 +266,7 @@ TEST_P(InkDropRippleTest, InkDropStatesPersistWhenCallingAnimateToState) {
ink_drop_ripple_->target_ink_drop_state());
}
-TEST_P(InkDropRippleTest, HideImmediatelyWithoutActiveAnimations) {
+TEST_P(AnimationInkDropRippleTest, HideImmediatelyWithoutActiveAnimations) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING);
test_api_->CompleteAnimations();
EXPECT_EQ(1, observer_.last_animation_started_ordinal());
@@ -250,7 +289,7 @@ TEST_P(InkDropRippleTest, HideImmediatelyWithoutActiveAnimations) {
// Verifies all active animations are aborted and the InkDropState is set to
// HIDDEN after invoking HideImmediately().
-TEST_P(InkDropRippleTest, HideImmediatelyWithActiveAnimations) {
+TEST_P(AnimationInkDropRippleTest, HideImmediatelyWithActiveAnimations) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING);
EXPECT_TRUE(test_api_->HasActiveAnimations());
EXPECT_NE(InkDropState::HIDDEN, ink_drop_ripple_->target_ink_drop_state());
@@ -272,7 +311,7 @@ TEST_P(InkDropRippleTest, HideImmediatelyWithActiveAnimations) {
EXPECT_FALSE(ink_drop_ripple_->IsVisible());
}
-TEST_P(InkDropRippleTest, SnapToActivatedWithoutActiveAnimations) {
+TEST_P(AnimationInkDropRippleTest, SnapToActivatedWithoutActiveAnimations) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING);
test_api_->CompleteAnimations();
EXPECT_EQ(1, observer_.last_animation_started_ordinal());
@@ -295,7 +334,7 @@ TEST_P(InkDropRippleTest, SnapToActivatedWithoutActiveAnimations) {
// Verifies all active animations are aborted and the InkDropState is set to
// ACTIVATED after invoking SnapToActivated().
-TEST_P(InkDropRippleTest, SnapToActivatedWithActiveAnimations) {
+TEST_P(AnimationInkDropRippleTest, SnapToActivatedWithActiveAnimations) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING);
EXPECT_TRUE(test_api_->HasActiveAnimations());
EXPECT_NE(InkDropState::ACTIVATED, ink_drop_ripple_->target_ink_drop_state());
@@ -316,7 +355,7 @@ TEST_P(InkDropRippleTest, SnapToActivatedWithActiveAnimations) {
EXPECT_TRUE(ink_drop_ripple_->IsVisible());
}
-TEST_P(InkDropRippleTest, AnimateToVisibleFromHidden) {
+TEST_P(AnimationInkDropRippleTest, AnimateToVisibleFromHidden) {
EXPECT_EQ(InkDropState::HIDDEN, ink_drop_ripple_->target_ink_drop_state());
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING);
EXPECT_TRUE(ink_drop_ripple_->IsVisible());
@@ -325,7 +364,7 @@ TEST_P(InkDropRippleTest, AnimateToVisibleFromHidden) {
// Verifies that the value of InkDropRipple::target_ink_drop_state() returns
// the most recent value passed to AnimateToState() when notifying observers
// that an animation has started within the AnimateToState() function call.
-TEST_P(InkDropRippleTest, TargetInkDropStateOnAnimationStarted) {
+TEST_P(AnimationInkDropRippleTest, TargetInkDropStateOnAnimationStarted) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING);
ink_drop_ripple_->AnimateToState(views::InkDropState::HIDDEN);
@@ -337,7 +376,7 @@ TEST_P(InkDropRippleTest, TargetInkDropStateOnAnimationStarted) {
// Verifies that the value of InkDropRipple::target_ink_drop_state() returns
// the most recent value passed to AnimateToState() when notifying observers
// that an animation has ended within the AnimateToState() function call.
-TEST_P(InkDropRippleTest, TargetInkDropStateOnAnimationEnded) {
+TEST_P(AnimationInkDropRippleTest, TargetInkDropStateOnAnimationEnded) {
ink_drop_ripple_->AnimateToState(views::InkDropState::ACTION_PENDING);
ink_drop_ripple_->AnimateToState(views::InkDropState::HIDDEN);

Powered by Google App Engine
This is Rietveld 408576698