| 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 #include "ui/views/animation/test/ink_drop_impl_test_api.h" | 5 #include "ui/views/animation/test/ink_drop_impl_test_api.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
| 7 #include "ui/views/animation/ink_drop_highlight.h" | 8 #include "ui/views/animation/ink_drop_highlight.h" |
| 8 #include "ui/views/animation/ink_drop_impl.h" | |
| 9 #include "ui/views/animation/ink_drop_ripple.h" | 9 #include "ui/views/animation/ink_drop_ripple.h" |
| 10 #include "ui/views/animation/test/ink_drop_highlight_test_api.h" | 10 #include "ui/views/animation/test/ink_drop_highlight_test_api.h" |
| 11 #include "ui/views/animation/test/ink_drop_ripple_test_api.h" | 11 #include "ui/views/animation/test/ink_drop_ripple_test_api.h" |
| 12 | 12 |
| 13 namespace views { | 13 namespace views { |
| 14 namespace test { | 14 namespace test { |
| 15 | 15 |
| 16 // |
| 17 // AccessFactoryOnExitHighlightState |
| 18 // |
| 19 |
| 20 void InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install( |
| 21 InkDropImpl::HighlightStateFactory* state_factory) { |
| 22 state_factory->ink_drop()->SetHighlightState( |
| 23 base::MakeUnique<InkDropImplTestApi::AccessFactoryOnExitHighlightState>( |
| 24 state_factory)); |
| 25 } |
| 26 |
| 27 InkDropImplTestApi::AccessFactoryOnExitHighlightState:: |
| 28 AccessFactoryOnExitHighlightState( |
| 29 InkDropImpl::HighlightStateFactory* state_factory) |
| 30 : HighlightState(state_factory) {} |
| 31 |
| 32 void InkDropImplTestApi::AccessFactoryOnExitHighlightState::Exit() { |
| 33 state_factory()->ink_drop()->SetHovered(false); |
| 34 } |
| 35 |
| 36 void InkDropImplTestApi::AccessFactoryOnExitHighlightState:: |
| 37 ShowOnHoverChanged() {} |
| 38 |
| 39 void InkDropImplTestApi::AccessFactoryOnExitHighlightState::OnHoverChanged() {} |
| 40 |
| 41 void InkDropImplTestApi::AccessFactoryOnExitHighlightState:: |
| 42 ShowOnFocusChanged() {} |
| 43 |
| 44 void InkDropImplTestApi::AccessFactoryOnExitHighlightState::OnFocusChanged() {} |
| 45 |
| 46 void InkDropImplTestApi::AccessFactoryOnExitHighlightState::AnimationStarted( |
| 47 InkDropState ink_drop_state) {} |
| 48 |
| 49 void InkDropImplTestApi::AccessFactoryOnExitHighlightState::AnimationEnded( |
| 50 InkDropState ink_drop_state, |
| 51 InkDropAnimationEndedReason reason) {} |
| 52 |
| 53 // |
| 54 // AccessFactoryOnExitHighlightState |
| 55 // |
| 56 |
| 57 void InkDropImplTestApi::SetStateOnExitHighlightState::Install( |
| 58 InkDropImpl::HighlightStateFactory* state_factory) { |
| 59 state_factory->ink_drop()->SetHighlightState( |
| 60 base::MakeUnique<InkDropImplTestApi::SetStateOnExitHighlightState>( |
| 61 state_factory)); |
| 62 } |
| 63 |
| 64 InkDropImplTestApi::SetStateOnExitHighlightState::SetStateOnExitHighlightState( |
| 65 InkDropImpl::HighlightStateFactory* state_factory) |
| 66 : HighlightState(state_factory) {} |
| 67 |
| 68 void InkDropImplTestApi::SetStateOnExitHighlightState::Exit() { |
| 69 InkDropImplTestApi::AccessFactoryOnExitHighlightState::Install( |
| 70 state_factory()); |
| 71 } |
| 72 |
| 73 void InkDropImplTestApi::SetStateOnExitHighlightState::ShowOnHoverChanged() {} |
| 74 |
| 75 void InkDropImplTestApi::SetStateOnExitHighlightState::OnHoverChanged() {} |
| 76 |
| 77 void InkDropImplTestApi::SetStateOnExitHighlightState::ShowOnFocusChanged() {} |
| 78 |
| 79 void InkDropImplTestApi::SetStateOnExitHighlightState::OnFocusChanged() {} |
| 80 |
| 81 void InkDropImplTestApi::SetStateOnExitHighlightState::AnimationStarted( |
| 82 InkDropState ink_drop_state) {} |
| 83 |
| 84 void InkDropImplTestApi::SetStateOnExitHighlightState::AnimationEnded( |
| 85 InkDropState ink_drop_state, |
| 86 InkDropAnimationEndedReason reason) {} |
| 87 |
| 88 // |
| 89 // InkDropImplTestApi |
| 90 // |
| 91 |
| 16 InkDropImplTestApi::InkDropImplTestApi(InkDropImpl* ink_drop) | 92 InkDropImplTestApi::InkDropImplTestApi(InkDropImpl* ink_drop) |
| 17 : ui::test::MultiLayerAnimatorTestController(this), ink_drop_(ink_drop) {} | 93 : ui::test::MultiLayerAnimatorTestController(this), ink_drop_(ink_drop) {} |
| 18 | 94 |
| 19 InkDropImplTestApi::~InkDropImplTestApi() {} | 95 InkDropImplTestApi::~InkDropImplTestApi() {} |
| 20 | 96 |
| 97 void InkDropImplTestApi::SetShouldHighlight(bool should_highlight) { |
| 98 ink_drop_->SetShowHighlightOnHover(should_highlight); |
| 99 ink_drop_->SetHovered(should_highlight); |
| 100 ink_drop_->SetShowHighlightOnFocus(should_highlight); |
| 101 ink_drop_->SetFocused(should_highlight); |
| 102 DCHECK_EQ(should_highlight, ink_drop_->ShouldHighlight()); |
| 103 } |
| 104 |
| 21 const InkDropHighlight* InkDropImplTestApi::highlight() const { | 105 const InkDropHighlight* InkDropImplTestApi::highlight() const { |
| 22 return ink_drop_->highlight_.get(); | 106 return ink_drop_->highlight_.get(); |
| 23 } | 107 } |
| 24 | 108 |
| 25 bool InkDropImplTestApi::IsHighlightFadingInOrVisible() const { | 109 bool InkDropImplTestApi::IsHighlightFadingInOrVisible() const { |
| 26 return ink_drop_->IsHighlightFadingInOrVisible(); | 110 return ink_drop_->IsHighlightFadingInOrVisible(); |
| 27 } | 111 } |
| 28 | 112 |
| 113 bool InkDropImplTestApi::ShouldHighlight() const { |
| 114 return ink_drop_->ShouldHighlight(); |
| 115 } |
| 116 |
| 29 std::vector<ui::LayerAnimator*> InkDropImplTestApi::GetLayerAnimators() { | 117 std::vector<ui::LayerAnimator*> InkDropImplTestApi::GetLayerAnimators() { |
| 30 std::vector<ui::LayerAnimator*> animators; | 118 std::vector<ui::LayerAnimator*> animators; |
| 31 | 119 |
| 32 if (ink_drop_->highlight_) { | 120 if (ink_drop_->highlight_) { |
| 33 InkDropHighlightTestApi* ink_drop_highlight_test_api = | 121 InkDropHighlightTestApi* ink_drop_highlight_test_api = |
| 34 ink_drop_->highlight_->GetTestApi(); | 122 ink_drop_->highlight_->GetTestApi(); |
| 35 std::vector<ui::LayerAnimator*> ink_drop_highlight_animators = | 123 std::vector<ui::LayerAnimator*> ink_drop_highlight_animators = |
| 36 ink_drop_highlight_test_api->GetLayerAnimators(); | 124 ink_drop_highlight_test_api->GetLayerAnimators(); |
| 37 animators.insert(animators.end(), ink_drop_highlight_animators.begin(), | 125 animators.insert(animators.end(), ink_drop_highlight_animators.begin(), |
| 38 ink_drop_highlight_animators.end()); | 126 ink_drop_highlight_animators.end()); |
| 39 } | 127 } |
| 40 | 128 |
| 41 if (ink_drop_->ink_drop_ripple_) { | 129 if (ink_drop_->ink_drop_ripple_) { |
| 42 InkDropRippleTestApi* ink_drop_ripple_test_api = | 130 InkDropRippleTestApi* ink_drop_ripple_test_api = |
| 43 ink_drop_->ink_drop_ripple_->GetTestApi(); | 131 ink_drop_->ink_drop_ripple_->GetTestApi(); |
| 44 std::vector<ui::LayerAnimator*> ink_drop_ripple_animators = | 132 std::vector<ui::LayerAnimator*> ink_drop_ripple_animators = |
| 45 ink_drop_ripple_test_api->GetLayerAnimators(); | 133 ink_drop_ripple_test_api->GetLayerAnimators(); |
| 46 animators.insert(animators.end(), ink_drop_ripple_animators.begin(), | 134 animators.insert(animators.end(), ink_drop_ripple_animators.begin(), |
| 47 ink_drop_ripple_animators.end()); | 135 ink_drop_ripple_animators.end()); |
| 48 } | 136 } |
| 49 | 137 |
| 50 return animators; | 138 return animators; |
| 51 } | 139 } |
| 52 | 140 |
| 53 } // namespace test | 141 } // namespace test |
| 54 } // namespace views | 142 } // namespace views |
| OLD | NEW |