OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/touch_selection/touch_handle.h" | 5 #include "ui/touch_selection/touch_handle.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/events/test/motion_event_test_utils.h" | 9 #include "ui/events/test/motion_event_test_utils.h" |
9 #include "ui/gfx/geometry/rect_f.h" | 10 #include "ui/gfx/geometry/rect_f.h" |
10 #include "ui/touch_selection/touch_handle_orientation.h" | 11 #include "ui/touch_selection/touch_handle_orientation.h" |
11 | 12 |
12 using ui::test::MockMotionEvent; | 13 using ui::test::MockMotionEvent; |
13 | 14 |
14 namespace ui { | 15 namespace ui { |
15 namespace { | 16 namespace { |
16 | 17 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 } | 101 } |
101 | 102 |
102 bool IsWithinTapSlop(const gfx::Vector2dF& delta) const override { | 103 bool IsWithinTapSlop(const gfx::Vector2dF& delta) const override { |
103 return delta.LengthSquared() < (kDefaultTapSlop * kDefaultTapSlop); | 104 return delta.LengthSquared() < (kDefaultTapSlop * kDefaultTapSlop); |
104 } | 105 } |
105 | 106 |
106 void OnHandleTapped(const TouchHandle& handle) override { tapped_ = true; } | 107 void OnHandleTapped(const TouchHandle& handle) override { tapped_ = true; } |
107 | 108 |
108 void SetNeedsAnimate() override { needs_animate_ = true; } | 109 void SetNeedsAnimate() override { needs_animate_ = true; } |
109 | 110 |
110 scoped_ptr<TouchHandleDrawable> CreateDrawable() override { | 111 std::unique_ptr<TouchHandleDrawable> CreateDrawable() override { |
111 return make_scoped_ptr(new MockTouchHandleDrawable(&drawable_data_)); | 112 return base::WrapUnique(new MockTouchHandleDrawable(&drawable_data_)); |
112 } | 113 } |
113 | 114 |
114 base::TimeDelta GetMaxTapDuration() const override { | 115 base::TimeDelta GetMaxTapDuration() const override { |
115 return base::TimeDelta::FromMilliseconds(kDefaultTapDurationMs); | 116 return base::TimeDelta::FromMilliseconds(kDefaultTapDurationMs); |
116 } | 117 } |
117 | 118 |
118 bool IsAdaptiveHandleOrientationEnabled() const override { | 119 bool IsAdaptiveHandleOrientationEnabled() const override { |
119 // Enable adaptive handle orientation by default for unittests | 120 // Enable adaptive handle orientation by default for unittests |
120 return true; | 121 return true; |
121 } | 122 } |
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 UpdateViewportRect(handle, gfx::RectF(0, 0, 230, 600)); | 679 UpdateViewportRect(handle, gfx::RectF(0, 0, 230, 600)); |
679 EXPECT_TRUE(drawable().mirror_vertical); | 680 EXPECT_TRUE(drawable().mirror_vertical); |
680 EXPECT_TRUE(drawable().mirror_horizontal); | 681 EXPECT_TRUE(drawable().mirror_horizontal); |
681 | 682 |
682 UpdateViewportRect(handle, kDefaultViewportRect); | 683 UpdateViewportRect(handle, kDefaultViewportRect); |
683 EXPECT_FALSE(drawable().mirror_vertical); | 684 EXPECT_FALSE(drawable().mirror_vertical); |
684 EXPECT_FALSE(drawable().mirror_horizontal); | 685 EXPECT_FALSE(drawable().mirror_horizontal); |
685 } | 686 } |
686 | 687 |
687 } // namespace ui | 688 } // namespace ui |
OLD | NEW |