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 SetLayout(const gfx::PointF& position, |
| 31 ui::TouchHandleOrientation orientation, |
| 32 bool mirror_vertical, |
| 33 bool mirror_horizontal) 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 gfx::SizeF GetDrawablePadding() const override { return gfx::SizeF(); } |
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 TouchSelectionControllerTest : public testing::Test, | 49 class TouchSelectionControllerTest : public testing::Test, |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1040 // A point outside the rect should not be handled. | 1043 // A point outside the rect should not be handled. |
1041 EXPECT_FALSE(controller().WillHandleLongPressEvent(outer_point)); | 1044 EXPECT_FALSE(controller().WillHandleLongPressEvent(outer_point)); |
1042 EXPECT_THAT(GetAndResetEvents(), IsEmpty()); | 1045 EXPECT_THAT(GetAndResetEvents(), IsEmpty()); |
1043 | 1046 |
1044 // A point inside the rect should be handled. | 1047 // A point inside the rect should be handled. |
1045 EXPECT_TRUE(controller().WillHandleLongPressEvent(inner_point)); | 1048 EXPECT_TRUE(controller().WillHandleLongPressEvent(inner_point)); |
1046 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN)); | 1049 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_SHOWN)); |
1047 } | 1050 } |
1048 | 1051 |
1049 } // namespace ui | 1052 } // namespace ui |
OLD | NEW |