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_highlight.h" |
10 #include "ui/views/animation/square_ink_drop_ripple.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_highlight_test_api.h" |
12 #include "ui/views/animation/test/square_ink_drop_ripple_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 InkDropRipple that returns a test api from | 18 // Test specific subclass of InkDropRipple that returns a test api from |
19 // GetTestApi(). | 19 // GetTestApi(). |
20 class TestInkDropRipple : public SquareInkDropRipple { | 20 class TestInkDropRipple : public SquareInkDropRipple { |
21 public: | 21 public: |
(...skipping 17 matching lines...) Expand all Loading... | |
39 test_api_.reset(new test::SquareInkDropRippleTestApi(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::InkDropRippleTestApi> test_api_; | 44 std::unique_ptr<test::InkDropRippleTestApi> test_api_; |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(TestInkDropRipple); | 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 InkDropHighlight that returns a test api from |
50 // GetTestApi(). | 50 // GetTestApi(). |
51 class TestInkDropHover : public InkDropHover { | 51 class TestInkDropHighlight : public InkDropHighlight { |
52 public: | 52 public: |
53 TestInkDropHover(const gfx::Size& size, | 53 TestInkDropHighlight(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) |
57 : InkDropHover(size, corner_radius, center_point, color) {} | 57 : InkDropHighlight(size, corner_radius, center_point, color) {} |
58 | 58 |
59 ~TestInkDropHover() override {} | 59 ~TestInkDropHighlight() override {} |
60 | 60 |
61 test::InkDropHoverTestApi* GetTestApi() override { | 61 test::InkDropHighlightTestApi* GetTestApi() override { |
62 if (!test_api_) | 62 if (!test_api_) |
63 test_api_.reset(new test::InkDropHoverTestApi(this)); | 63 test_api_.reset(new test::InkDropHighlightTestApi(this)); |
64 return test_api_.get(); | 64 return test_api_.get(); |
65 } | 65 } |
66 | 66 |
67 private: | 67 private: |
68 std::unique_ptr<test::InkDropHoverTestApi> test_api_; | 68 std::unique_ptr<test::InkDropHighlightTestApi> test_api_; |
69 | 69 |
70 DISALLOW_COPY_AND_ASSIGN(TestInkDropHover); | 70 DISALLOW_COPY_AND_ASSIGN(TestInkDropHighlight); |
71 }; | 71 }; |
72 | 72 |
73 } // namespace | 73 } // namespace |
74 | 74 |
75 TestInkDropHost::TestInkDropHost() | 75 TestInkDropHost::TestInkDropHost() |
76 : num_ink_drop_layers_(0), | 76 : num_ink_drop_layers_(0), |
77 should_show_hover_(false), | 77 should_show_highlight_(false), |
78 disable_timers_for_test_(false) {} | 78 disable_timers_for_test_(false) {} |
79 | 79 |
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<InkDropRipple> TestInkDropHost::CreateInkDropRipple() const { | 90 std::unique_ptr<InkDropRipple> TestInkDropHost::CreateInkDropRipple() const { |
91 gfx::Size size(10, 10); | 91 gfx::Size size(10, 10); |
92 std::unique_ptr<InkDropRipple> ripple( | 92 std::unique_ptr<InkDropRipple> ripple( |
93 new TestInkDropRipple(size, 5, size, 5, gfx::Point(), SK_ColorBLACK)); | 93 new TestInkDropRipple(size, 5, size, 5, gfx::Point(), SK_ColorBLACK)); |
94 if (disable_timers_for_test_) | 94 if (disable_timers_for_test_) |
95 ripple->GetTestApi()->SetDisableAnimationTimers(true); | 95 ripple->GetTestApi()->SetDisableAnimationTimers(true); |
96 return ripple; | 96 return ripple; |
97 } | 97 } |
98 | 98 |
99 std::unique_ptr<InkDropHover> TestInkDropHost::CreateInkDropHover() const { | 99 std::unique_ptr<InkDropHighlight> TestInkDropHost::CreateInkDropHighlight() |
100 std::unique_ptr<InkDropHover> hover; | 100 const { |
101 if (should_show_hover_) { | 101 std::unique_ptr<InkDropHighlight> hover; |
bruthig
2016/06/03 02:50:46
Rename 'hover' as 'highlight'.
| |
102 hover.reset(new TestInkDropHover(gfx::Size(10, 10), 4, gfx::Point(), | 102 if (should_show_highlight_) { |
103 SK_ColorBLACK)); | 103 hover.reset(new TestInkDropHighlight(gfx::Size(10, 10), 4, gfx::Point(), |
104 SK_ColorBLACK)); | |
104 if (disable_timers_for_test_) | 105 if (disable_timers_for_test_) |
105 hover->GetTestApi()->SetDisableAnimationTimers(true); | 106 hover->GetTestApi()->SetDisableAnimationTimers(true); |
106 } | 107 } |
107 return hover; | 108 return hover; |
108 } | 109 } |
109 | 110 |
110 } // namespace views | 111 } // namespace views |
OLD | NEW |