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

Unified Diff: ui/views/animation/test/test_ink_drop_animation_observer_helper.h

Issue 2615613003: Fix double ripple on activated flood fill ripple (Closed)
Patch Set: Used AssertionResult Created 3 years, 11 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
« no previous file with comments | « ui/views/animation/test/flood_fill_ink_drop_ripple_test_api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/animation/test/test_ink_drop_animation_observer_helper.h
diff --git a/ui/views/animation/test/test_ink_drop_animation_observer_helper.h b/ui/views/animation/test/test_ink_drop_animation_observer_helper.h
index f9e774f4d7359d5008d42915e9f7273bc8a4f30c..3a871087b9b133621a6828265358e4a2d759b731 100644
--- a/ui/views/animation/test/test_ink_drop_animation_observer_helper.h
+++ b/ui/views/animation/test/test_ink_drop_animation_observer_helper.h
@@ -48,12 +48,14 @@ class TestInkDropAnimationObserverHelper {
}
void OnAnimationStarted(ContextType context) {
+ animation_started_contexts_.push_back(context);
last_animation_started_context_ = context;
last_animation_started_ordinal_ = GetNextOrdinal();
}
void OnAnimationEnded(ContextType context,
InkDropAnimationEndedReason reason) {
+ animation_ended_contexts_.push_back(context);
last_animation_ended_context_ = context;
last_animation_ended_ordinal_ = GetNextOrdinal();
last_animation_ended_reason_ = reason;
@@ -110,7 +112,43 @@ class TestInkDropAnimationObserverHelper {
<< last_animation_ended_ordinal() << ".";
}
+ // Passes *_TRUE assertions when |animation_started_context_| is the same as
+ // |expected_contexts|.
+ testing::AssertionResult AnimationStartedContextsMatches(
bruthig 2017/01/11 23:18:04 nit: "Match" reads better to me than "Matches", he
mohsen 2017/01/12 19:31:56 Done.
+ const std::vector<ContextType>& expected_contexts) {
+ return ContextsMatches(expected_contexts, animation_started_contexts_);
+ }
+
+ // Passes *_TRUE assertions when |animation_ended_context_| is the same as
+ // |expected_contexts|.
+ testing::AssertionResult AnimationEndedContextsMatches(
+ const std::vector<ContextType>& expected_contexts) {
+ return ContextsMatches(expected_contexts, animation_ended_contexts_);
+ }
+
private:
+ // Helper function that checks if |actual_contexts| is the same as
+ // |expected_contexts| returning appropraite AssertionResult.
+ testing::AssertionResult ContextsMatches(
+ const std::vector<ContextType>& expected_contexts,
+ const std::vector<ContextType>& actual_contexts) {
+ if (expected_contexts.size() != actual_contexts.size()) {
+ return testing::AssertionFailure()
+ << "Size mismatch. Expected " << expected_contexts.size()
+ << " elements while there are " << actual_contexts.size()
+ << " elements.";
+ }
+ for (size_t i = 0; i < expected_contexts.size(); i++) {
+ if (expected_contexts[i] != actual_contexts[i]) {
+ return testing::AssertionFailure()
bruthig 2017/01/11 23:18:04 nit: Consider capturing log output for the entire
mohsen 2017/01/12 19:31:56 Done.
+ << i << "th elements do not match. Expected "
+ << ToString(expected_contexts[i]) << " while it is "
+ << ToString(actual_contexts[i]) << ".";
+ }
+ }
+ return testing::AssertionSuccess() << "Lists are the same.";
+ }
+
// Returns the next event ordinal. The first returned ordinal will be 1.
int GetNextOrdinal() const {
return std::max(1, std::max(last_animation_started_ordinal_,
@@ -121,12 +159,18 @@ class TestInkDropAnimationObserverHelper {
// The ordinal time of the last AnimationStarted() call.
int last_animation_started_ordinal_;
+ // List of contexts for which animation is started.
+ std::vector<ContextType> animation_started_contexts_;
+
// The |context| passed to the last call to AnimationStarted().
ContextType last_animation_started_context_;
// The ordinal time of the last AnimationEnded() call.
int last_animation_ended_ordinal_;
+ // List of contexts for which animation is ended.
+ std::vector<ContextType> animation_ended_contexts_;
+
// The |context| passed to the last call to AnimationEnded().
ContextType last_animation_ended_context_;
« no previous file with comments | « ui/views/animation/test/flood_fill_ink_drop_ripple_test_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698