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

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

Issue 2447523002: [ash-md] Added different highlighting modes to the InkDropImpl. (Closed)
Patch Set: Fixed InkDropHostView::GetInkDrop() to use CreateInkDrop(). Created 4 years, 1 month 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/checkbox.h » ('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/ink_drop_impl.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)
29 bool overrides_highlight)
30 : SquareInkDropRipple(large_size, 30 : SquareInkDropRipple(large_size,
31 large_corner_radius, 31 large_corner_radius,
32 small_size, 32 small_size,
33 small_corner_radius, 33 small_corner_radius,
34 center_point, 34 center_point,
35 color, 35 color,
36 visible_opacity), 36 visible_opacity) {}
37 overrides_highlight_(overrides_highlight) {}
38 37
39 ~TestInkDropRipple() override {} 38 ~TestInkDropRipple() override {}
40 39
41 test::InkDropRippleTestApi* GetTestApi() override { 40 test::InkDropRippleTestApi* GetTestApi() override {
42 if (!test_api_) 41 if (!test_api_)
43 test_api_.reset(new test::SquareInkDropRippleTestApi(this)); 42 test_api_.reset(new test::SquareInkDropRippleTestApi(this));
44 return test_api_.get(); 43 return test_api_.get();
45 } 44 }
46 45
47 bool OverridesHighlight() const override {
48 return overrides_highlight_;
49 }
50
51 private: 46 private:
52 std::unique_ptr<test::InkDropRippleTestApi> test_api_; 47 std::unique_ptr<test::InkDropRippleTestApi> test_api_;
53 bool overrides_highlight_;
54 48
55 DISALLOW_COPY_AND_ASSIGN(TestInkDropRipple); 49 DISALLOW_COPY_AND_ASSIGN(TestInkDropRipple);
56 }; 50 };
57 51
58 // Test specific subclass of InkDropHighlight that returns a test api from 52 // Test specific subclass of InkDropHighlight that returns a test api from
59 // GetTestApi(). 53 // GetTestApi().
60 class TestInkDropHighlight : public InkDropHighlight { 54 class TestInkDropHighlight : public InkDropHighlight {
61 public: 55 public:
62 TestInkDropHighlight(const gfx::Size& size, 56 TestInkDropHighlight(const gfx::Size& size,
63 int corner_radius, 57 int corner_radius,
(...skipping 13 matching lines...) Expand all
77 std::unique_ptr<test::InkDropHighlightTestApi> test_api_; 71 std::unique_ptr<test::InkDropHighlightTestApi> test_api_;
78 72
79 DISALLOW_COPY_AND_ASSIGN(TestInkDropHighlight); 73 DISALLOW_COPY_AND_ASSIGN(TestInkDropHighlight);
80 }; 74 };
81 75
82 } // namespace 76 } // namespace
83 77
84 TestInkDropHost::TestInkDropHost() 78 TestInkDropHost::TestInkDropHost()
85 : num_ink_drop_layers_added_(0), 79 : num_ink_drop_layers_added_(0),
86 num_ink_drop_layers_removed_(0), 80 num_ink_drop_layers_removed_(0),
87 should_show_highlight_(false),
88 ripple_overrides_highlight_(true),
89 disable_timers_for_test_(false) {} 81 disable_timers_for_test_(false) {}
90 82
91 TestInkDropHost::~TestInkDropHost() {} 83 TestInkDropHost::~TestInkDropHost() {}
92 84
93 void TestInkDropHost::AddInkDropLayer(ui::Layer* ink_drop_layer) { 85 void TestInkDropHost::AddInkDropLayer(ui::Layer* ink_drop_layer) {
94 ++num_ink_drop_layers_added_; 86 ++num_ink_drop_layers_added_;
95 } 87 }
96 88
97 void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { 89 void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
98 ++num_ink_drop_layers_removed_; 90 ++num_ink_drop_layers_removed_;
99 } 91 }
100 92
93 std::unique_ptr<InkDrop> TestInkDropHost::CreateInkDrop() {
94 NOTREACHED();
95 return nullptr;
96 }
97
101 std::unique_ptr<InkDropRipple> TestInkDropHost::CreateInkDropRipple() const { 98 std::unique_ptr<InkDropRipple> TestInkDropHost::CreateInkDropRipple() const {
102 gfx::Size size(10, 10); 99 gfx::Size size(10, 10);
103 std::unique_ptr<InkDropRipple> ripple( 100 std::unique_ptr<InkDropRipple> ripple(new TestInkDropRipple(
104 new TestInkDropRipple(size, 5, size, 5, gfx::Point(), SK_ColorBLACK, 101 size, 5, size, 5, gfx::Point(), SK_ColorBLACK, 0.175f));
105 0.175f, ripple_overrides_highlight_));
106 if (disable_timers_for_test_) 102 if (disable_timers_for_test_)
107 ripple->GetTestApi()->SetDisableAnimationTimers(true); 103 ripple->GetTestApi()->SetDisableAnimationTimers(true);
108 return ripple; 104 return ripple;
109 } 105 }
110 106
111 std::unique_ptr<InkDropHighlight> TestInkDropHost::CreateInkDropHighlight() 107 std::unique_ptr<InkDropHighlight> TestInkDropHost::CreateInkDropHighlight()
112 const { 108 const {
113 std::unique_ptr<InkDropHighlight> highlight; 109 std::unique_ptr<InkDropHighlight> highlight;
114 if (should_show_highlight_) { 110 highlight.reset(new TestInkDropHighlight(gfx::Size(10, 10), 4, gfx::PointF(),
115 highlight.reset(new TestInkDropHighlight(gfx::Size(10, 10), 4, 111 SK_ColorBLACK));
116 gfx::PointF(), SK_ColorBLACK)); 112 if (disable_timers_for_test_)
117 if (disable_timers_for_test_) 113 highlight->GetTestApi()->SetDisableAnimationTimers(true);
118 highlight->GetTestApi()->SetDisableAnimationTimers(true);
119 }
120 return highlight; 114 return highlight;
121 } 115 }
122 116
123 } // namespace views 117 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/test/test_ink_drop_host.h ('k') | ui/views/controls/button/checkbox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698