Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: ui/views/animation/test/test_ink_drop_host.cc

Issue 2250783002: Allow InkDropRipple to co-exist with highlight (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove EmptyInkDropRipple Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/views/animation/test/test_ink_drop_host.h ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_highlight.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_highlight_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:
22 TestInkDropRipple(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 float visible_opacity) 28 float visible_opacity,
29 bool overrides_highlight)
29 : SquareInkDropRipple(large_size, 30 : SquareInkDropRipple(large_size,
30 large_corner_radius, 31 large_corner_radius,
31 small_size, 32 small_size,
32 small_corner_radius, 33 small_corner_radius,
33 center_point, 34 center_point,
34 color, 35 color,
35 visible_opacity) {} 36 visible_opacity),
37 overrides_highlight_(overrides_highlight) {}
36 38
37 ~TestInkDropRipple() override {} 39 ~TestInkDropRipple() override {}
38 40
39 test::InkDropRippleTestApi* GetTestApi() override { 41 test::InkDropRippleTestApi* GetTestApi() override {
40 if (!test_api_) 42 if (!test_api_)
41 test_api_.reset(new test::SquareInkDropRippleTestApi(this)); 43 test_api_.reset(new test::SquareInkDropRippleTestApi(this));
42 return test_api_.get(); 44 return test_api_.get();
43 } 45 }
44 46
47 bool OverridesHighlight() const override {
48 return overrides_highlight_;
49 }
50
45 private: 51 private:
46 std::unique_ptr<test::InkDropRippleTestApi> test_api_; 52 std::unique_ptr<test::InkDropRippleTestApi> test_api_;
53 bool overrides_highlight_;
47 54
48 DISALLOW_COPY_AND_ASSIGN(TestInkDropRipple); 55 DISALLOW_COPY_AND_ASSIGN(TestInkDropRipple);
49 }; 56 };
50 57
51 // Test specific subclass of InkDropHighlight that returns a test api from 58 // Test specific subclass of InkDropHighlight that returns a test api from
52 // GetTestApi(). 59 // GetTestApi().
53 class TestInkDropHighlight : public InkDropHighlight { 60 class TestInkDropHighlight : public InkDropHighlight {
54 public: 61 public:
55 TestInkDropHighlight(const gfx::Size& size, 62 TestInkDropHighlight(const gfx::Size& size,
56 int corner_radius, 63 int corner_radius,
(...skipping 13 matching lines...) Expand all
70 std::unique_ptr<test::InkDropHighlightTestApi> test_api_; 77 std::unique_ptr<test::InkDropHighlightTestApi> test_api_;
71 78
72 DISALLOW_COPY_AND_ASSIGN(TestInkDropHighlight); 79 DISALLOW_COPY_AND_ASSIGN(TestInkDropHighlight);
73 }; 80 };
74 81
75 } // namespace 82 } // namespace
76 83
77 TestInkDropHost::TestInkDropHost() 84 TestInkDropHost::TestInkDropHost()
78 : num_ink_drop_layers_(0), 85 : num_ink_drop_layers_(0),
79 should_show_highlight_(false), 86 should_show_highlight_(false),
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(
95 size, 5, size, 5, gfx::Point(), SK_ColorBLACK, 0.175f)); 103 new TestInkDropRipple(size, 5, size, 5, gfx::Point(), SK_ColorBLACK,
104 0.175f, ripple_overrides_highlight_));
96 if (disable_timers_for_test_) 105 if (disable_timers_for_test_)
97 ripple->GetTestApi()->SetDisableAnimationTimers(true); 106 ripple->GetTestApi()->SetDisableAnimationTimers(true);
98 return ripple; 107 return ripple;
99 } 108 }
100 109
101 std::unique_ptr<InkDropHighlight> TestInkDropHost::CreateInkDropHighlight() 110 std::unique_ptr<InkDropHighlight> TestInkDropHost::CreateInkDropHighlight()
102 const { 111 const {
103 std::unique_ptr<InkDropHighlight> highlight; 112 std::unique_ptr<InkDropHighlight> highlight;
104 if (should_show_highlight_) { 113 if (should_show_highlight_) {
105 highlight.reset(new TestInkDropHighlight(gfx::Size(10, 10), 4, 114 highlight.reset(new TestInkDropHighlight(gfx::Size(10, 10), 4,
106 gfx::PointF(), SK_ColorBLACK)); 115 gfx::PointF(), SK_ColorBLACK));
107 if (disable_timers_for_test_) 116 if (disable_timers_for_test_)
108 highlight->GetTestApi()->SetDisableAnimationTimers(true); 117 highlight->GetTestApi()->SetDisableAnimationTimers(true);
109 } 118 }
110 return highlight; 119 return highlight;
111 } 120 }
112 121
113 } // namespace views 122 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/test/test_ink_drop_host.h ('k') | ui/views/controls/button/label_button.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698