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