| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/test_ink_drop_host.h" | 5 #include "ui/views/animation/test/test_ink_drop_host.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "ui/gfx/geometry/size.h" | 8 #include "ui/gfx/geometry/size.h" |
| 9 #include "ui/views/animation/ink_drop_hover.h" | 9 #include "ui/views/animation/ink_drop_hover.h" |
| 10 #include "ui/views/animation/square_ink_drop_animation.h" | 10 #include "ui/views/animation/square_ink_drop_ripple.h" |
| 11 #include "ui/views/animation/test/ink_drop_hover_test_api.h" | 11 #include "ui/views/animation/test/ink_drop_hover_test_api.h" |
| 12 #include "ui/views/animation/test/square_ink_drop_animation_test_api.h" | 12 #include "ui/views/animation/test/square_ink_drop_ripple_test_api.h" |
| 13 | 13 |
| 14 namespace views { | 14 namespace views { |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 // Test specific subclass of InkDropAnimation that returns a test api from | 18 // Test specific subclass of InkDropRipple that returns a test api from |
| 19 // GetTestApi(). | 19 // GetTestApi(). |
| 20 class TestInkDropAnimation : public SquareInkDropAnimation { | 20 class TestInkDropRipple : public SquareInkDropRipple { |
| 21 public: | 21 public: |
| 22 TestInkDropAnimation(const gfx::Size& large_size, | 22 TestInkDropRipple(const gfx::Size& large_size, |
| 23 int large_corner_radius, | 23 int large_corner_radius, |
| 24 const gfx::Size& small_size, | 24 const gfx::Size& small_size, |
| 25 int small_corner_radius, | 25 int small_corner_radius, |
| 26 const gfx::Point& center_point, | 26 const gfx::Point& center_point, |
| 27 SkColor color) | 27 SkColor color) |
| 28 : SquareInkDropAnimation(large_size, | 28 : SquareInkDropRipple(large_size, |
| 29 large_corner_radius, | 29 large_corner_radius, |
| 30 small_size, | 30 small_size, |
| 31 small_corner_radius, | 31 small_corner_radius, |
| 32 center_point, | 32 center_point, |
| 33 color) {} | 33 color) {} |
| 34 | 34 |
| 35 ~TestInkDropAnimation() override {} | 35 ~TestInkDropRipple() override {} |
| 36 | 36 |
| 37 test::InkDropAnimationTestApi* GetTestApi() override { | 37 test::InkDropRippleTestApi* GetTestApi() override { |
| 38 if (!test_api_) | 38 if (!test_api_) |
| 39 test_api_.reset(new test::SquareInkDropAnimationTestApi(this)); | 39 test_api_.reset(new test::SquareInkDropRippleTestApi(this)); |
| 40 return test_api_.get(); | 40 return test_api_.get(); |
| 41 } | 41 } |
| 42 | 42 |
| 43 private: | 43 private: |
| 44 std::unique_ptr<test::InkDropAnimationTestApi> test_api_; | 44 std::unique_ptr<test::InkDropRippleTestApi> test_api_; |
| 45 | 45 |
| 46 DISALLOW_COPY_AND_ASSIGN(TestInkDropAnimation); | 46 DISALLOW_COPY_AND_ASSIGN(TestInkDropRipple); |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 // Test specific subclass of InkDropHover that returns a test api from | 49 // Test specific subclass of InkDropHover that returns a test api from |
| 50 // GetTestApi(). | 50 // GetTestApi(). |
| 51 class TestInkDropHover : public InkDropHover { | 51 class TestInkDropHover : public InkDropHover { |
| 52 public: | 52 public: |
| 53 TestInkDropHover(const gfx::Size& size, | 53 TestInkDropHover(const gfx::Size& size, |
| 54 int corner_radius, | 54 int corner_radius, |
| 55 const gfx::Point& center_point, | 55 const gfx::Point& center_point, |
| 56 SkColor color) | 56 SkColor color) |
| (...skipping 23 matching lines...) Expand all Loading... |
| 80 TestInkDropHost::~TestInkDropHost() {} | 80 TestInkDropHost::~TestInkDropHost() {} |
| 81 | 81 |
| 82 void TestInkDropHost::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 82 void TestInkDropHost::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 83 ++num_ink_drop_layers_; | 83 ++num_ink_drop_layers_; |
| 84 } | 84 } |
| 85 | 85 |
| 86 void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 86 void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 87 --num_ink_drop_layers_; | 87 --num_ink_drop_layers_; |
| 88 } | 88 } |
| 89 | 89 |
| 90 std::unique_ptr<InkDropAnimation> TestInkDropHost::CreateInkDropAnimation() | 90 std::unique_ptr<InkDropRipple> TestInkDropHost::CreateInkDropRipple() const { |
| 91 const { | |
| 92 gfx::Size size(10, 10); | 91 gfx::Size size(10, 10); |
| 93 std::unique_ptr<InkDropAnimation> animation( | 92 std::unique_ptr<InkDropRipple> ripple( |
| 94 new TestInkDropAnimation(size, 5, size, 5, gfx::Point(), SK_ColorBLACK)); | 93 new TestInkDropRipple(size, 5, size, 5, gfx::Point(), SK_ColorBLACK)); |
| 95 if (disable_timers_for_test_) | 94 if (disable_timers_for_test_) |
| 96 animation->GetTestApi()->SetDisableAnimationTimers(true); | 95 ripple->GetTestApi()->SetDisableAnimationTimers(true); |
| 97 return animation; | 96 return ripple; |
| 98 } | 97 } |
| 99 | 98 |
| 100 std::unique_ptr<InkDropHover> TestInkDropHost::CreateInkDropHover() const { | 99 std::unique_ptr<InkDropHover> TestInkDropHost::CreateInkDropHover() const { |
| 101 std::unique_ptr<InkDropHover> hover; | 100 std::unique_ptr<InkDropHover> hover; |
| 102 if (should_show_hover_) { | 101 if (should_show_hover_) { |
| 103 hover.reset(new TestInkDropHover(gfx::Size(10, 10), 4, gfx::Point(), | 102 hover.reset(new TestInkDropHover(gfx::Size(10, 10), 4, gfx::Point(), |
| 104 SK_ColorBLACK)); | 103 SK_ColorBLACK)); |
| 105 if (disable_timers_for_test_) | 104 if (disable_timers_for_test_) |
| 106 hover->GetTestApi()->SetDisableAnimationTimers(true); | 105 hover->GetTestApi()->SetDisableAnimationTimers(true); |
| 107 } | 106 } |
| 108 return hover; | 107 return hover; |
| 109 } | 108 } |
| 110 | 109 |
| 111 } // namespace views | 110 } // namespace views |
| OLD | NEW |