| 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 { |
| 49 return overrides_highlight_; |
| 50 } |
| 51 |
| 45 private: | 52 private: |
| 46 std::unique_ptr<test::InkDropRippleTestApi> test_api_; | 53 std::unique_ptr<test::InkDropRippleTestApi> test_api_; |
| 54 bool overrides_highlight_; |
| 47 | 55 |
| 48 DISALLOW_COPY_AND_ASSIGN(TestInkDropRipple); | 56 DISALLOW_COPY_AND_ASSIGN(TestInkDropRipple); |
| 49 }; | 57 }; |
| 50 | 58 |
| 51 // Test specific subclass of InkDropHighlight that returns a test api from | 59 // Test specific subclass of InkDropHighlight that returns a test api from |
| 52 // GetTestApi(). | 60 // GetTestApi(). |
| 53 class TestInkDropHighlight : public InkDropHighlight { | 61 class TestInkDropHighlight : public InkDropHighlight { |
| 54 public: | 62 public: |
| 55 TestInkDropHighlight(const gfx::Size& size, | 63 TestInkDropHighlight(const gfx::Size& size, |
| 56 int corner_radius, | 64 int corner_radius, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 70 std::unique_ptr<test::InkDropHighlightTestApi> test_api_; | 78 std::unique_ptr<test::InkDropHighlightTestApi> test_api_; |
| 71 | 79 |
| 72 DISALLOW_COPY_AND_ASSIGN(TestInkDropHighlight); | 80 DISALLOW_COPY_AND_ASSIGN(TestInkDropHighlight); |
| 73 }; | 81 }; |
| 74 | 82 |
| 75 } // namespace | 83 } // namespace |
| 76 | 84 |
| 77 TestInkDropHost::TestInkDropHost() | 85 TestInkDropHost::TestInkDropHost() |
| 78 : num_ink_drop_layers_(0), | 86 : num_ink_drop_layers_(0), |
| 79 should_show_highlight_(false), | 87 should_show_highlight_(false), |
| 88 should_show_ripple_(true), |
| 89 ripple_overrides_highlight_(true), |
| 80 disable_timers_for_test_(false) {} | 90 disable_timers_for_test_(false) {} |
| 81 | 91 |
| 82 TestInkDropHost::~TestInkDropHost() {} | 92 TestInkDropHost::~TestInkDropHost() {} |
| 83 | 93 |
| 84 void TestInkDropHost::AddInkDropLayer(ui::Layer* ink_drop_layer) { | 94 void TestInkDropHost::AddInkDropLayer(ui::Layer* ink_drop_layer) { |
| 85 ++num_ink_drop_layers_; | 95 ++num_ink_drop_layers_; |
| 86 } | 96 } |
| 87 | 97 |
| 88 void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { | 98 void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { |
| 89 --num_ink_drop_layers_; | 99 --num_ink_drop_layers_; |
| 90 } | 100 } |
| 91 | 101 |
| 92 std::unique_ptr<InkDropRipple> TestInkDropHost::CreateInkDropRipple() const { | 102 std::unique_ptr<InkDropRipple> TestInkDropHost::CreateInkDropRipple() const { |
| 93 gfx::Size size(10, 10); | 103 gfx::Size size(10, 10); |
| 94 std::unique_ptr<InkDropRipple> ripple(new TestInkDropRipple( | 104 std::unique_ptr<InkDropRipple> ripple(new EmptyInkDropRipple()); |
| 95 size, 5, size, 5, gfx::Point(), SK_ColorBLACK, 0.175f)); | 105 if (should_show_ripple_) { |
| 96 if (disable_timers_for_test_) | 106 ripple.reset(new TestInkDropRipple(size, 5, size, 5, gfx::Point(), |
| 97 ripple->GetTestApi()->SetDisableAnimationTimers(true); | 107 SK_ColorBLACK, 0.175f, |
| 108 ripple_overrides_highlight_)); |
| 109 if (disable_timers_for_test_) |
| 110 ripple->GetTestApi()->SetDisableAnimationTimers(true); |
| 111 } |
| 98 return ripple; | 112 return ripple; |
| 99 } | 113 } |
| 100 | 114 |
| 101 std::unique_ptr<InkDropHighlight> TestInkDropHost::CreateInkDropHighlight() | 115 std::unique_ptr<InkDropHighlight> TestInkDropHost::CreateInkDropHighlight() |
| 102 const { | 116 const { |
| 103 std::unique_ptr<InkDropHighlight> highlight; | 117 std::unique_ptr<InkDropHighlight> highlight; |
| 104 if (should_show_highlight_) { | 118 if (should_show_highlight_) { |
| 105 highlight.reset(new TestInkDropHighlight(gfx::Size(10, 10), 4, | 119 highlight.reset(new TestInkDropHighlight(gfx::Size(10, 10), 4, |
| 106 gfx::PointF(), SK_ColorBLACK)); | 120 gfx::PointF(), SK_ColorBLACK)); |
| 107 if (disable_timers_for_test_) | 121 if (disable_timers_for_test_) |
| 108 highlight->GetTestApi()->SetDisableAnimationTimers(true); | 122 highlight->GetTestApi()->SetDisableAnimationTimers(true); |
| 109 } | 123 } |
| 110 return highlight; | 124 return highlight; |
| 111 } | 125 } |
| 112 | 126 |
| 113 } // namespace views | 127 } // namespace views |
| OLD | NEW |