| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef UI_VIEWS_ANIMATION_TEST_INK_DROP_IMPL_TEST_API_H_ | 5 #ifndef UI_VIEWS_ANIMATION_TEST_INK_DROP_IMPL_TEST_API_H_ |
| 6 #define UI_VIEWS_ANIMATION_TEST_INK_DROP_IMPL_TEST_API_H_ | 6 #define UI_VIEWS_ANIMATION_TEST_INK_DROP_IMPL_TEST_API_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/macros.h" | 11 #include "base/macros.h" |
| 11 #include "ui/compositor/test/multi_layer_animator_test_controller.h" | 12 #include "ui/compositor/test/multi_layer_animator_test_controller.h" |
| 12 #include "ui/compositor/test/multi_layer_animator_test_controller_delegate.h" | 13 #include "ui/compositor/test/multi_layer_animator_test_controller_delegate.h" |
| 14 #include "ui/views/animation/ink_drop_impl.h" |
| 13 | 15 |
| 14 namespace ui { | 16 namespace ui { |
| 15 class LayerAnimator; | 17 class LayerAnimator; |
| 16 } // namespace ui | 18 } // namespace ui |
| 17 | 19 |
| 18 namespace views { | 20 namespace views { |
| 19 class InkDropImpl; | |
| 20 class InkDropHighlight; | 21 class InkDropHighlight; |
| 21 | 22 |
| 22 namespace test { | 23 namespace test { |
| 23 | 24 |
| 24 // Test API to provide internal access to an InkDropImpl instance. This can also | 25 // Test API to provide internal access to an InkDropImpl instance. This can also |
| 25 // be used to control the InkDropRipple and InkDropHighlight animations via the | 26 // be used to control the InkDropRipple and InkDropHighlight animations via the |
| 26 // ui::test::MultiLayerAnimatorTestController API. | 27 // ui::test::MultiLayerAnimatorTestController API. |
| 27 class InkDropImplTestApi | 28 class InkDropImplTestApi |
| 28 : public ui::test::MultiLayerAnimatorTestController, | 29 : public ui::test::MultiLayerAnimatorTestController, |
| 29 public ui::test::MultiLayerAnimatorTestControllerDelegate { | 30 public ui::test::MultiLayerAnimatorTestControllerDelegate { |
| 30 public: | 31 public: |
| 32 // Highlight state that access the HighlightStateFactory during the Exit() |
| 33 // method. |
| 34 class AccessFactoryOnExitHighlightState : public InkDropImpl::HighlightState { |
| 35 public: |
| 36 // Installs an instance of |this| to the ink drop that owns |state_factory|. |
| 37 static void Install(InkDropImpl::HighlightStateFactory* state_factory); |
| 38 |
| 39 explicit AccessFactoryOnExitHighlightState( |
| 40 InkDropImpl::HighlightStateFactory* state_factory); |
| 41 |
| 42 // HighlightState: |
| 43 void Exit() override; |
| 44 void ShowOnHoverChanged() override; |
| 45 void OnHoverChanged() override; |
| 46 void ShowOnFocusChanged() override; |
| 47 void OnFocusChanged() override; |
| 48 void AnimationStarted(InkDropState ink_drop_state) override; |
| 49 void AnimationEnded(InkDropState ink_drop_state, |
| 50 InkDropAnimationEndedReason reason) override; |
| 51 |
| 52 private: |
| 53 DISALLOW_COPY_AND_ASSIGN(AccessFactoryOnExitHighlightState); |
| 54 }; |
| 55 |
| 56 // Highlight state that attempts to set a new highlight state during Exit(). |
| 57 class SetStateOnExitHighlightState : public InkDropImpl::HighlightState { |
| 58 public: |
| 59 // Installs an instance of |this| to the ink drop that owns |state_factory|. |
| 60 static void Install(InkDropImpl::HighlightStateFactory* state_factory); |
| 61 |
| 62 explicit SetStateOnExitHighlightState( |
| 63 InkDropImpl::HighlightStateFactory* state_factory); |
| 64 |
| 65 // HighlightState: |
| 66 void Exit() override; |
| 67 void ShowOnHoverChanged() override; |
| 68 void OnHoverChanged() override; |
| 69 void ShowOnFocusChanged() override; |
| 70 void OnFocusChanged() override; |
| 71 void AnimationStarted(InkDropState ink_drop_state) override; |
| 72 void AnimationEnded(InkDropState ink_drop_state, |
| 73 InkDropAnimationEndedReason reason) override; |
| 74 |
| 75 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(SetStateOnExitHighlightState); |
| 77 }; |
| 78 |
| 31 explicit InkDropImplTestApi(InkDropImpl* ink_drop); | 79 explicit InkDropImplTestApi(InkDropImpl* ink_drop); |
| 32 ~InkDropImplTestApi() override; | 80 ~InkDropImplTestApi() override; |
| 33 | 81 |
| 82 // Ensures that |ink_drop_|->ShouldHighlight() returns the same value as |
| 83 // |should_highlight| by updating the hover/focus status of |ink_drop_|. |
| 84 void SetShouldHighlight(bool should_highlight); |
| 85 |
| 34 // Wrappers to InkDropImpl internals: | 86 // Wrappers to InkDropImpl internals: |
| 87 InkDropImpl::HighlightStateFactory* state_factory() { |
| 88 return ink_drop_->highlight_state_factory_.get(); |
| 89 } |
| 90 |
| 35 const InkDropHighlight* highlight() const; | 91 const InkDropHighlight* highlight() const; |
| 36 bool IsHighlightFadingInOrVisible() const; | 92 bool IsHighlightFadingInOrVisible() const; |
| 93 bool ShouldHighlight() const; |
| 37 | 94 |
| 38 protected: | 95 protected: |
| 39 // MultiLayerAnimatorTestControllerDelegate: | 96 // MultiLayerAnimatorTestControllerDelegate: |
| 40 std::vector<ui::LayerAnimator*> GetLayerAnimators() override; | 97 std::vector<ui::LayerAnimator*> GetLayerAnimators() override; |
| 41 | 98 |
| 42 private: | 99 private: |
| 43 // The InkDrop to provide internal access to. | 100 // The InkDrop to provide internal access to. |
| 44 InkDropImpl* ink_drop_; | 101 InkDropImpl* ink_drop_; |
| 45 | 102 |
| 46 DISALLOW_COPY_AND_ASSIGN(InkDropImplTestApi); | 103 DISALLOW_COPY_AND_ASSIGN(InkDropImplTestApi); |
| 47 }; | 104 }; |
| 48 | 105 |
| 49 } // namespace test | 106 } // namespace test |
| 50 } // namespace views | 107 } // namespace views |
| 51 | 108 |
| 52 #endif // UI_VIEWS_ANIMATION_TEST_INK_DROP_IMPL_TEST_API_H_ | 109 #endif // UI_VIEWS_ANIMATION_TEST_INK_DROP_IMPL_TEST_API_H_ |
| OLD | NEW |