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

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

Issue 1944043002: Enabled tests to control material design ink drop animations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Replaced unique_ptr with scoped_ptr. Created 4 years, 7 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/views.gyp » ('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"
6
7 #include "base/memory/scoped_ptr.h"
5 #include "ui/gfx/geometry/size.h" 8 #include "ui/gfx/geometry/size.h"
6 #include "ui/views/animation/ink_drop_hover.h" 9 #include "ui/views/animation/ink_drop_hover.h"
7 #include "ui/views/animation/square_ink_drop_animation.h" 10 #include "ui/views/animation/square_ink_drop_animation.h"
8 #include "ui/views/animation/test/test_ink_drop_host.h" 11 #include "ui/views/animation/test/ink_drop_hover_test_api.h"
12 #include "ui/views/animation/test/square_ink_drop_animation_test_api.h"
9 13
10 namespace views { 14 namespace views {
11 15
16 namespace {
17
18 // Test specific subclass of InkDropAnimation that returns a test api from
19 // GetTestApi().
20 class TestInkDropAnimation : public SquareInkDropAnimation {
21 public:
22 TestInkDropAnimation(const gfx::Size& large_size,
23 int large_corner_radius,
24 const gfx::Size& small_size,
25 int small_corner_radius,
26 const gfx::Point& center_point,
27 SkColor color)
28 : SquareInkDropAnimation(large_size,
29 large_corner_radius,
30 small_size,
31 small_corner_radius,
32 center_point,
33 color) {}
34
35 ~TestInkDropAnimation() override {}
36
37 test::InkDropAnimationTestApi* GetTestApi() override {
38 if (!test_api_)
39 test_api_.reset(new test::SquareInkDropAnimationTestApi(this));
40 return test_api_.get();
41 }
42
43 private:
44 scoped_ptr<test::InkDropAnimationTestApi> test_api_;
45
46 DISALLOW_COPY_AND_ASSIGN(TestInkDropAnimation);
47 };
48
49 // Test specific subclass of InkDropHover that returns a test api from
50 // GetTestApi().
51 class TestInkDropHover : public InkDropHover {
52 public:
53 TestInkDropHover(const gfx::Size& size,
54 int corner_radius,
55 const gfx::Point& center_point,
56 SkColor color)
57 : InkDropHover(size, corner_radius, center_point, color) {}
58
59 ~TestInkDropHover() override {}
60
61 test::InkDropHoverTestApi* GetTestApi() override {
62 if (!test_api_)
63 test_api_.reset(new test::InkDropHoverTestApi(this));
64 return test_api_.get();
65 }
66
67 private:
68 scoped_ptr<test::InkDropHoverTestApi> test_api_;
69
70 DISALLOW_COPY_AND_ASSIGN(TestInkDropHover);
71 };
72
73 } // namespace
74
12 TestInkDropHost::TestInkDropHost() 75 TestInkDropHost::TestInkDropHost()
13 : num_ink_drop_layers_(0), should_show_hover_(false) {} 76 : num_ink_drop_layers_(0),
77 should_show_hover_(false),
78 disable_timers_for_test_(false) {}
14 79
15 TestInkDropHost::~TestInkDropHost() {} 80 TestInkDropHost::~TestInkDropHost() {}
16 81
17 void TestInkDropHost::AddInkDropLayer(ui::Layer* ink_drop_layer) { 82 void TestInkDropHost::AddInkDropLayer(ui::Layer* ink_drop_layer) {
18 ++num_ink_drop_layers_; 83 ++num_ink_drop_layers_;
19 } 84 }
20 85
21 void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) { 86 void TestInkDropHost::RemoveInkDropLayer(ui::Layer* ink_drop_layer) {
22 --num_ink_drop_layers_; 87 --num_ink_drop_layers_;
23 } 88 }
24 89
25 scoped_ptr<InkDropAnimation> TestInkDropHost::CreateInkDropAnimation() const { 90 scoped_ptr<InkDropAnimation> TestInkDropHost::CreateInkDropAnimation() const {
26 gfx::Size size(10, 10); 91 gfx::Size size(10, 10);
27 return make_scoped_ptr(new SquareInkDropAnimation( 92 scoped_ptr<InkDropAnimation> animation(
28 size, 5, size, 5, gfx::Point(), SK_ColorBLACK)); 93 new TestInkDropAnimation(size, 5, size, 5, gfx::Point(), SK_ColorBLACK));
94 if (disable_timers_for_test_)
95 animation->GetTestApi()->SetDisableAnimationTimers(true);
96 return animation;
29 } 97 }
30 98
31 scoped_ptr<InkDropHover> TestInkDropHost::CreateInkDropHover() const { 99 scoped_ptr<InkDropHover> TestInkDropHost::CreateInkDropHover() const {
32 return should_show_hover_ 100 scoped_ptr<InkDropHover> hover;
33 ? make_scoped_ptr(new InkDropHover(gfx::Size(10, 10), 4, 101 if (should_show_hover_) {
34 gfx::Point(), SK_ColorBLACK)) 102 hover.reset(new TestInkDropHover(gfx::Size(10, 10), 4, gfx::Point(),
35 : nullptr; 103 SK_ColorBLACK));
104 if (disable_timers_for_test_)
105 hover->GetTestApi()->SetDisableAnimationTimers(true);
106 }
107 return hover;
36 } 108 }
37 109
38 } // namespace views 110 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/animation/test/test_ink_drop_host.h ('k') | ui/views/views.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698