| 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/empty_ink_drop_ripple.h" |
| 9 #include "ui/views/animation/ink_drop_highlight.h" | 10 #include "ui/views/animation/ink_drop_highlight.h" |
| 10 #include "ui/views/animation/square_ink_drop_ripple.h" | 11 #include "ui/views/animation/square_ink_drop_ripple.h" |
| 11 #include "ui/views/animation/test/ink_drop_highlight_test_api.h" | 12 #include "ui/views/animation/test/ink_drop_highlight_test_api.h" |
| 12 #include "ui/views/animation/test/square_ink_drop_ripple_test_api.h" | 13 #include "ui/views/animation/test/square_ink_drop_ripple_test_api.h" |
| 13 | 14 |
| 14 namespace views { | 15 namespace views { |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 // Test specific subclass of InkDropRipple that returns a test api from | 19 // Test specific subclass of InkDropRipple that returns a test api from |
| 19 // GetTestApi(). | 20 // GetTestApi(). |
| 20 class TestInkDropRipple : public SquareInkDropRipple { | 21 class TestInkDropRipple : public SquareInkDropRipple { |
| 21 public: | 22 public: |
| 22 TestInkDropRipple(const gfx::Size& large_size, | 23 TestInkDropRipple(const gfx::Size& large_size, |
| 23 int large_corner_radius, | 24 int large_corner_radius, |
| 24 const gfx::Size& small_size, | 25 const gfx::Size& small_size, |
| 25 int small_corner_radius, | 26 int small_corner_radius, |
| 26 const gfx::Point& center_point, | 27 const gfx::Point& center_point, |
| 27 SkColor color, | 28 SkColor color, |
| 28 float visible_opacity) | 29 float visible_opacity, |
| 30 bool overrides_highlight) |
| 29 : SquareInkDropRipple(large_size, | 31 : SquareInkDropRipple(large_size, |
| 30 large_corner_radius, | 32 large_corner_radius, |
| 31 small_size, | 33 small_size, |
| 32 small_corner_radius, | 34 small_corner_radius, |
| 33 center_point, | 35 center_point, |
| 34 color, | 36 color, |
| 35 visible_opacity) {} | 37 visible_opacity), |
| 38 overrides_highlight_(overrides_highlight) {} |
| 36 | 39 |
| 37 ~TestInkDropRipple() override {} | 40 ~TestInkDropRipple() override {} |
| 38 | 41 |
| 39 test::InkDropRippleTestApi* GetTestApi() override { | 42 test::InkDropRippleTestApi* GetTestApi() override { |
| 40 if (!test_api_) | 43 if (!test_api_) |
| 41 test_api_.reset(new test::SquareInkDropRippleTestApi(this)); | 44 test_api_.reset(new test::SquareInkDropRippleTestApi(this)); |
| 42 return test_api_.get(); | 45 return test_api_.get(); |
| 43 } | 46 } |
| 44 | 47 |
| 48 bool OverridesHighlight() const override { return overrides_highlight_; } |
| 49 |
| 45 private: | 50 private: |
| 46 std::unique_ptr<test::InkDropRippleTestApi> test_api_; | 51 std::unique_ptr<test::InkDropRippleTestApi> test_api_; |
| 52 bool overrides_highlight_; |
| 47 | 53 |
| 48 DISALLOW_COPY_AND_ASSIGN(TestInkDropRipple); | 54 DISALLOW_COPY_AND_ASSIGN(TestInkDropRipple); |
| 49 }; | 55 }; |
| 50 | 56 |
| 51 // Test specific subclass of InkDropHighlight that returns a test api from | 57 // Test specific subclass of InkDropHighlight that returns a test api from |
| 52 // GetTestApi(). | 58 // GetTestApi(). |
| 53 class TestInkDropHighlight : public InkDropHighlight { | 59 class TestInkDropHighlight : public InkDropHighlight { |
| 54 public: | 60 public: |
| 55 TestInkDropHighlight(const gfx::Size& size, | 61 TestInkDropHighlight(const gfx::Size& size, |
| 56 int corner_radius, | 62 int corner_radius, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 70 std::unique_ptr<test::InkDropHighlightTestApi> test_api_; | 76 std::unique_ptr<test::InkDropHighlightTestApi> test_api_; |
| 71 | 77 |
| 72 DISALLOW_COPY_AND_ASSIGN(TestInkDropHighlight); | 78 DISALLOW_COPY_AND_ASSIGN(TestInkDropHighlight); |
| 73 }; | 79 }; |
| 74 | 80 |
| 75 } // namespace | 81 } // namespace |
| 76 | 82 |
| 77 TestInkDropHost::TestInkDropHost() | 83 TestInkDropHost::TestInkDropHost() |
| 78 : num_ink_drop_layers_(0), | 84 : num_ink_drop_layers_(0), |
| 79 should_show_highlight_(false), | 85 should_show_highlight_(false), |
| 86 should_show_ripple_(true), |
| 87 ripple_overrides_highlight_(true), |
| 80 disable_timers_for_test_(false) {} | 88 disable_timers_for_test_(false) {} |
| 81 | 89 |
| 82 TestInkDropHost::~TestInkDropHost() {} | 90 TestInkDropHost::~TestInkDropHost() {} |
| 83 | 91 |
| 84 void TestInkDropHost::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 92 void TestInkDropHost::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 85 ++num_ink_drop_layers_; | 93 ++num_ink_drop_layers_; |
| 86 } | 94 } |
| 87 | 95 |
| 88 void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 96 void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 89 --num_ink_drop_layers_; | 97 --num_ink_drop_layers_; |
| 90 } | 98 } |
| 91 | 99 |
| 92 std::unique_ptr<InkDropRipple> TestInkDropHost::CreateInkDropRipple() const { | 100 std::unique_ptr<InkDropRipple> TestInkDropHost::CreateInkDropRipple() const { |
| 93 gfx::Size size(10, 10); | 101 gfx::Size size(10, 10); |
| 94 std::unique_ptr<InkDropRipple> ripple(new TestInkDropRipple( | 102 std::unique_ptr<InkDropRipple> ripple(new EmptyInkDropRipple()); |
| 95 size, 5, size, 5, gfx::Point(), SK_ColorBLACK, 0.175f)); | 103 if (should_show_ripple_) { |
| 96 if (disable_timers_for_test_) | 104 ripple.reset(new TestInkDropRipple(size, 5, size, 5, gfx::Point(), |
| 97 ripple->GetTestApi()->SetDisableAnimationTimers(true); | 105 SK_ColorBLACK, 0.175f, |
| 106 ripple_overrides_highlight_)); |
| 107 if (disable_timers_for_test_) |
| 108 ripple->GetTestApi()->SetDisableAnimationTimers(true); |
| 109 } |
| 98 return ripple; | 110 return ripple; |
| 99 } | 111 } |
| 100 | 112 |
| 101 std::unique_ptr<InkDropHighlight> TestInkDropHost::CreateInkDropHighlight() | 113 std::unique_ptr<InkDropHighlight> TestInkDropHost::CreateInkDropHighlight() |
| 102 const { | 114 const { |
| 103 std::unique_ptr<InkDropHighlight> highlight; | 115 std::unique_ptr<InkDropHighlight> highlight; |
| 104 if (should_show_highlight_) { | 116 if (should_show_highlight_) { |
| 105 highlight.reset(new TestInkDropHighlight(gfx::Size(10, 10), 4, | 117 highlight.reset(new TestInkDropHighlight(gfx::Size(10, 10), 4, |
| 106 gfx::PointF(), SK_ColorBLACK)); | 118 gfx::PointF(), SK_ColorBLACK)); |
| 107 if (disable_timers_for_test_) | 119 if (disable_timers_for_test_) |
| 108 highlight->GetTestApi()->SetDisableAnimationTimers(true); | 120 highlight->GetTestApi()->SetDisableAnimationTimers(true); |
| 109 } | 121 } |
| 110 return highlight; | 122 return highlight; |
| 111 } | 123 } |
| 112 | 124 |
| 113 } // namespace views | 125 } // namespace views |
| OLD | NEW |