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 #include "ui/touch_selection/touch_selection_controller_test_api.h" |
12 | 13 |
13 using testing::ElementsAre; | 14 using testing::ElementsAre; |
14 using testing::IsEmpty; | 15 using testing::IsEmpty; |
15 using ui::test::MockMotionEvent; | 16 using ui::test::MockMotionEvent; |
16 | 17 |
17 namespace ui { | 18 namespace ui { |
18 namespace { | 19 namespace { |
19 | 20 |
20 const int kDefaultTapTimeoutMs = 200; | 21 const int kDefaultTapTimeoutMs = 200; |
21 const float kDefaulTapSlop = 10.f; | 22 const float kDefaulTapSlop = 10.f; |
(...skipping 14 matching lines...) Expand all Loading... |
36 } | 37 } |
37 | 38 |
38 private: | 39 private: |
39 bool* intersects_rect_; | 40 bool* intersects_rect_; |
40 | 41 |
41 DISALLOW_COPY_AND_ASSIGN(MockTouchHandleDrawable); | 42 DISALLOW_COPY_AND_ASSIGN(MockTouchHandleDrawable); |
42 }; | 43 }; |
43 | 44 |
44 } // namespace | 45 } // namespace |
45 | 46 |
46 class TouchSelectionControllerTestApi { | |
47 public: | |
48 explicit TouchSelectionControllerTestApi(TouchSelectionController* controller) | |
49 : controller_(controller) {} | |
50 ~TouchSelectionControllerTestApi() {} | |
51 | |
52 bool GetStartVisible() const { return controller_->GetStartVisible(); } | |
53 bool GetEndVisible() const { return controller_->GetEndVisible(); } | |
54 | |
55 private: | |
56 TouchSelectionController* controller_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerTestApi); | |
59 }; | |
60 | |
61 class TouchSelectionControllerTest : public testing::Test, | 47 class TouchSelectionControllerTest : public testing::Test, |
62 public TouchSelectionControllerClient { | 48 public TouchSelectionControllerClient { |
63 public: | 49 public: |
64 TouchSelectionControllerTest() | 50 TouchSelectionControllerTest() |
65 : caret_moved_(false), | 51 : caret_moved_(false), |
66 selection_moved_(false), | 52 selection_moved_(false), |
67 selection_points_swapped_(false), | 53 selection_points_swapped_(false), |
68 needs_animate_(false), | 54 needs_animate_(false), |
69 animation_enabled_(true), | 55 animation_enabled_(true), |
70 dragging_enabled_(false) {} | 56 dragging_enabled_(false) {} |
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 EXPECT_EQ(gfx::RectF(6, 5, 44, 10), controller().GetRectBetweenBounds()); | 1276 EXPECT_EQ(gfx::RectF(6, 5, 44, 10), controller().GetRectBetweenBounds()); |
1291 EXPECT_EQ(GetLastEventBoundsRect(), controller().GetRectBetweenBounds()); | 1277 EXPECT_EQ(GetLastEventBoundsRect(), controller().GetRectBetweenBounds()); |
1292 | 1278 |
1293 ClearSelection(); | 1279 ClearSelection(); |
1294 ASSERT_THAT(GetAndResetEvents(), | 1280 ASSERT_THAT(GetAndResetEvents(), |
1295 ElementsAre(SELECTION_DISSOLVED, SELECTION_HANDLES_CLEARED)); | 1281 ElementsAre(SELECTION_DISSOLVED, SELECTION_HANDLES_CLEARED)); |
1296 EXPECT_EQ(gfx::RectF(), controller().GetRectBetweenBounds()); | 1282 EXPECT_EQ(gfx::RectF(), controller().GetRectBetweenBounds()); |
1297 } | 1283 } |
1298 | 1284 |
1299 } // namespace ui | 1285 } // namespace ui |
OLD | NEW |