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_selection_controller.h" | 5 #include "ui/touch_selection/touch_selection_controller.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/events/test/motion_event_test_utils.h" | 11 #include "ui/events/test/motion_event_test_utils.h" |
12 | 12 |
13 using testing::ElementsAre; | 13 using testing::ElementsAre; |
14 using testing::IsEmpty; | 14 using testing::IsEmpty; |
15 using ui::test::MockMotionEvent; | 15 using ui::test::MockMotionEvent; |
16 | 16 |
17 namespace ui { | 17 namespace ui { |
18 namespace { | 18 namespace { |
19 | 19 |
20 const int kDefaultTapTimeoutMs = 200; | 20 const int kDefaultTapTimeoutMs = 200; |
21 const float kDefaulTapSlop = 10.f; | 21 const float kDefaulTapSlop = 10.f; |
22 const gfx::PointF kIgnoredPoint(0, 0); | 22 const gfx::PointF kIgnoredPoint(0, 0); |
23 | 23 |
24 class MockTouchHandleDrawable : public TouchHandleDrawable { | 24 class MockTouchHandleDrawable : public TouchHandleDrawable { |
25 public: | 25 public: |
26 explicit MockTouchHandleDrawable(bool* contains_point) | 26 explicit MockTouchHandleDrawable(bool* contains_point) |
27 : intersects_rect_(contains_point) {} | 27 : intersects_rect_(contains_point) {} |
28 ~MockTouchHandleDrawable() override {} | 28 ~MockTouchHandleDrawable() override {} |
29 void SetEnabled(bool enabled) override {} | 29 void SetEnabled(bool enabled) override {} |
30 void SetOrientation(TouchHandleOrientation orientation) override {} | 30 void SetOrientation(ui::TouchHandleOrientation orientation, |
| 31 bool mirror_vertical, |
| 32 bool mirror_horizontal) override {} |
| 33 void SetOrigin(const gfx::PointF& origin) override {} |
31 void SetAlpha(float alpha) override {} | 34 void SetAlpha(float alpha) override {} |
32 void SetFocus(const gfx::PointF& position) override {} | |
33 gfx::RectF GetVisibleBounds() const override { | 35 gfx::RectF GetVisibleBounds() const override { |
34 return *intersects_rect_ ? gfx::RectF(-1000, -1000, 2000, 2000) | 36 return *intersects_rect_ ? gfx::RectF(-1000, -1000, 2000, 2000) |
35 : gfx::RectF(-1000, -1000, 0, 0); | 37 : gfx::RectF(-1000, -1000, 0, 0); |
36 } | 38 } |
| 39 const float GetDrawableHorizontalPadding() const override { return 0; } |
37 | 40 |
38 private: | 41 private: |
39 bool* intersects_rect_; | 42 bool* intersects_rect_; |
40 | 43 |
41 DISALLOW_COPY_AND_ASSIGN(MockTouchHandleDrawable); | 44 DISALLOW_COPY_AND_ASSIGN(MockTouchHandleDrawable); |
42 }; | 45 }; |
43 | 46 |
44 } // namespace | 47 } // namespace |
45 | 48 |
46 class TouchSelectionControllerTestApi { | 49 class TouchSelectionControllerTestApi { |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 EXPECT_EQ(gfx::RectF(6, 5, 44, 10), controller().GetRectBetweenBounds()); | 1293 EXPECT_EQ(gfx::RectF(6, 5, 44, 10), controller().GetRectBetweenBounds()); |
1291 EXPECT_EQ(GetLastEventBoundsRect(), controller().GetRectBetweenBounds()); | 1294 EXPECT_EQ(GetLastEventBoundsRect(), controller().GetRectBetweenBounds()); |
1292 | 1295 |
1293 ClearSelection(); | 1296 ClearSelection(); |
1294 ASSERT_THAT(GetAndResetEvents(), | 1297 ASSERT_THAT(GetAndResetEvents(), |
1295 ElementsAre(SELECTION_DISSOLVED, SELECTION_HANDLES_CLEARED)); | 1298 ElementsAre(SELECTION_DISSOLVED, SELECTION_HANDLES_CLEARED)); |
1296 EXPECT_EQ(gfx::RectF(), controller().GetRectBetweenBounds()); | 1299 EXPECT_EQ(gfx::RectF(), controller().GetRectBetweenBounds()); |
1297 } | 1300 } |
1298 | 1301 |
1299 } // namespace ui | 1302 } // namespace ui |
OLD | NEW |