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

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 compile errors. 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
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 27 matching lines...) Expand all
91 TestInkDropHost::~TestInkDropHost() {} 85 TestInkDropHost::~TestInkDropHost() {}
92 86
93 void TestInkDropHost::AddInkDropLayer(ui::Layer* ink_drop_layer) { 87 void TestInkDropHost::AddInkDropLayer(ui::Layer* ink_drop_layer) {
94 ++num_ink_drop_layers_added_; 88 ++num_ink_drop_layers_added_;
95 } 89 }
96 90
97 void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { 91 void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
98 ++num_ink_drop_layers_removed_; 92 ++num_ink_drop_layers_removed_;
99 } 93 }
100 94
95 std::unique_ptr<InkDrop> TestInkDropHost::CreateInkDrop() {
96 std::unique_ptr<InkDropImpl> ink_drop = base::MakeUnique<InkDropImpl>(this);
97 if (ripple_overrides_highlight_) {
98 ink_drop->SetAutoHighlightMode(
99 InkDropImpl::AutoHighlightMode::HIDE_ON_RIPPLE);
100 }
101 return ink_drop;
102 }
103
101 std::unique_ptr<InkDropRipple> TestInkDropHost::CreateInkDropRipple() const { 104 std::unique_ptr<InkDropRipple> TestInkDropHost::CreateInkDropRipple() const {
102 gfx::Size size(10, 10); 105 gfx::Size size(10, 10);
103 std::unique_ptr<InkDropRipple> ripple( 106 std::unique_ptr<InkDropRipple> ripple(new TestInkDropRipple(
104 new TestInkDropRipple(size, 5, size, 5, gfx::Point(), SK_ColorBLACK, 107 size, 5, size, 5, gfx::Point(), SK_ColorBLACK, 0.175f));
105 0.175f, ripple_overrides_highlight_));
106 if (disable_timers_for_test_) 108 if (disable_timers_for_test_)
107 ripple->GetTestApi()->SetDisableAnimationTimers(true); 109 ripple->GetTestApi()->SetDisableAnimationTimers(true);
108 return ripple; 110 return ripple;
109 } 111 }
110 112
111 std::unique_ptr<InkDropHighlight> TestInkDropHost::CreateInkDropHighlight() 113 std::unique_ptr<InkDropHighlight> TestInkDropHost::CreateInkDropHighlight()
112 const { 114 const {
113 std::unique_ptr<InkDropHighlight> highlight; 115 std::unique_ptr<InkDropHighlight> highlight;
114 if (should_show_highlight_) { 116 if (should_show_highlight_) {
115 highlight.reset(new TestInkDropHighlight(gfx::Size(10, 10), 4, 117 highlight.reset(new TestInkDropHighlight(gfx::Size(10, 10), 4,
116 gfx::PointF(), SK_ColorBLACK)); 118 gfx::PointF(), SK_ColorBLACK));
117 if (disable_timers_for_test_) 119 if (disable_timers_for_test_)
118 highlight->GetTestApi()->SetDisableAnimationTimers(true); 120 highlight->GetTestApi()->SetDisableAnimationTimers(true);
119 } 121 }
120 return highlight; 122 return highlight;
121 } 123 }
122 124
123 } // namespace views 125 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698