Index: ui/views/animation/test/test_ink_drop_animation_observer.h |
diff --git a/ui/views/animation/test/test_ink_drop_animation_observer.h b/ui/views/animation/test/test_ink_drop_animation_observer.h |
index 7ce6dc6985aadd0dbd2221c48e7bee6ba7b244e8..8c0bce0945e4dc2942a4d2176da4ec1dab339796 100644 |
--- a/ui/views/animation/test/test_ink_drop_animation_observer.h |
+++ b/ui/views/animation/test/test_ink_drop_animation_observer.h |
@@ -8,6 +8,7 @@ |
#include "testing/gtest/include/gtest/gtest.h" |
#include "ui/views/animation/ink_drop_animation_observer.h" |
#include "ui/views/animation/ink_drop_state.h" |
+#include "ui/views/animation/test/test_ink_drop_animation_observer_helper.h" |
namespace views { |
class InkDropAnimation; |
@@ -17,7 +18,9 @@ namespace test { |
// Simple InkDropAnimationObserver test double that tracks if |
// InkDropAnimationObserver methods are invoked and the parameters used for the |
// last invocation. |
-class TestInkDropAnimationObserver : public InkDropAnimationObserver { |
+class TestInkDropAnimationObserver |
+ : public InkDropAnimationObserver, |
+ public TestInkDropAnimationObserverHelper<InkDropState> { |
public: |
TestInkDropAnimationObserver(); |
~TestInkDropAnimationObserver() override; |
@@ -26,26 +29,6 @@ class TestInkDropAnimationObserver : public InkDropAnimationObserver { |
ink_drop_animation_ = ink_drop_animation; |
} |
- int last_animation_started_ordinal() const { |
- return last_animation_started_ordinal_; |
- } |
- |
- int last_animation_ended_ordinal() const { |
- return last_animation_ended_ordinal_; |
- } |
- |
- InkDropState last_animation_state_started() const { |
- return last_animation_state_started_; |
- } |
- |
- InkDropState last_animation_state_ended() const { |
- return last_animation_state_ended_; |
- } |
- |
- InkDropAnimationEndedReason last_animation_ended_reason() const { |
- return last_animation_ended_reason_; |
- } |
- |
InkDropState target_state_at_last_animation_started() const { |
return target_state_at_last_animation_started_; |
} |
@@ -54,59 +37,14 @@ class TestInkDropAnimationObserver : public InkDropAnimationObserver { |
return target_state_at_last_animation_ended_; |
} |
- // |
- // Collection of assertion predicates to be used with GTest test assertions. |
- // i.e. EXPECT_TRUE/EXPECT_FALSE and the ASSERT_ counterparts. |
- // |
- // Example: |
- // |
- // TestInkDropAnimationObserver observer; |
- // observer.set_ink_drop_animation(ink_drop_animation); |
- // EXPECT_TRUE(observer.AnimationHasNotStarted()); |
- // |
- |
- // Passes *_TRUE assertions when an InkDropAnimationStarted() event has been |
- // observed. |
- testing::AssertionResult AnimationHasStarted(); |
- |
- // Passes *_TRUE assertions when an InkDropAnimationStarted() event has NOT |
- // been observed. |
- testing::AssertionResult AnimationHasNotStarted(); |
- |
- // Passes *_TRUE assertions when an InkDropAnimationEnded() event has been |
- // observed. |
- testing::AssertionResult AnimationHasEnded(); |
- |
- // Passes *_TRUE assertions when an InkDropAnimationEnded() event has NOT been |
- // observed. |
- testing::AssertionResult AnimationHasNotEnded(); |
- |
- // InkDropAnimation: |
- void InkDropAnimationStarted(InkDropState ink_drop_state) override; |
- void InkDropAnimationEnded(InkDropState ink_drop_state, |
- InkDropAnimationEndedReason reason) override; |
+ // InkDropAnimationObserver: |
+ void AnimationStarted(InkDropState ink_drop_state) override; |
+ void AnimationEnded(InkDropState ink_drop_state, |
+ InkDropAnimationEndedReason reason) override; |
private: |
- // Returns the next event ordinal. The first returned ordinal will be 1. |
- int GetNextOrdinal() const; |
- |
- // The ordinal time of the last InkDropAnimationStarted() event. |
- int last_animation_started_ordinal_; |
- |
- // The ordinal time of the last InkDropAnimationended() event. |
- int last_animation_ended_ordinal_; |
- |
- // The |ink_drop_state| parameter used for the last invocation of |
- // InkDropAnimationStarted(). Only valid if |animation_started_| is true. |
- InkDropState last_animation_state_started_; |
- |
- // The |ink_drop_state| parameter used for the last invocation of |
- // InkDropAnimationEnded(). Only valid if |animation_ended_| is true. |
- InkDropState last_animation_state_ended_; |
- |
- // The |reason| parameter used for the last invocation of |
- // InkDropAnimationEnded(). Only valid if |animation_ended_| is true. |
- InkDropAnimationEndedReason last_animation_ended_reason_; |
+ // The type as this inherits from. Reduces verbosity in .cc file. |
+ using ObserverHelper = TestInkDropAnimationObserverHelper<InkDropState>; |
// The value of InkDropAnimation::GetTargetInkDropState() the last time an |
// InkDropAnimationStarted() event was handled. This is only valid if |
@@ -114,7 +52,7 @@ class TestInkDropAnimationObserver : public InkDropAnimationObserver { |
InkDropState target_state_at_last_animation_started_; |
// The value of InkDropAnimation::GetTargetInkDropState() the last time an |
- // InkDropAnimationEnded() event was handled. This is only valid if |
+ // AnimationEnded() event was handled. This is only valid if |
// |ink_drop_animation_| is not null. |
InkDropState target_state_at_last_animation_ended_; |