Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(136)

Side by Side Diff: ui/touch_selection/touch_selection_controller_unittest.cc

Issue 1868363002: Replace scoped_ptr with std::unique_ptr in //ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@scopedptrcc
Patch Set: scopedptrui: rebase-make_scoped_ptr Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h"
10 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/events/test/motion_event_test_utils.h" 13 #include "ui/events/test/motion_event_test_utils.h"
13 #include "ui/touch_selection/touch_selection_controller_test_api.h" 14 #include "ui/touch_selection/touch_selection_controller_test_api.h"
14 15
15 using testing::ElementsAre; 16 using testing::ElementsAre;
16 using testing::IsEmpty; 17 using testing::IsEmpty;
17 using ui::test::MockMotionEvent; 18 using ui::test::MockMotionEvent;
18 19
19 namespace ui { 20 namespace ui {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 selection_end_ = extent; 95 selection_end_ = extent;
95 } 96 }
96 97
97 void OnSelectionEvent(SelectionEventType event) override { 98 void OnSelectionEvent(SelectionEventType event) override {
98 events_.push_back(event); 99 events_.push_back(event);
99 last_event_start_ = controller_->GetStartPosition(); 100 last_event_start_ = controller_->GetStartPosition();
100 last_event_end_ = controller_->GetEndPosition(); 101 last_event_end_ = controller_->GetEndPosition();
101 last_event_bounds_rect_ = controller_->GetRectBetweenBounds(); 102 last_event_bounds_rect_ = controller_->GetRectBetweenBounds();
102 } 103 }
103 104
104 scoped_ptr<TouchHandleDrawable> CreateDrawable() override { 105 std::unique_ptr<TouchHandleDrawable> CreateDrawable() override {
105 return make_scoped_ptr(new MockTouchHandleDrawable(&dragging_enabled_)); 106 return base::WrapUnique(new MockTouchHandleDrawable(&dragging_enabled_));
106 } 107 }
107 108
108 void AllowShowingOnTapForEmptyEditable() { 109 void AllowShowingOnTapForEmptyEditable() {
109 TouchSelectionController::Config config = DefaultConfig(); 110 TouchSelectionController::Config config = DefaultConfig();
110 config.show_on_tap_for_empty_editable = true; 111 config.show_on_tap_for_empty_editable = true;
111 controller_.reset(new TouchSelectionController(this, config)); 112 controller_.reset(new TouchSelectionController(this, config));
112 } 113 }
113 114
114 void EnableLongPressDragSelection() { 115 void EnableLongPressDragSelection() {
115 TouchSelectionController::Config config = DefaultConfig(); 116 TouchSelectionController::Config config = DefaultConfig();
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 gfx::PointF selection_start_; 232 gfx::PointF selection_start_;
232 gfx::PointF selection_end_; 233 gfx::PointF selection_end_;
233 gfx::RectF last_event_bounds_rect_; 234 gfx::RectF last_event_bounds_rect_;
234 std::vector<SelectionEventType> events_; 235 std::vector<SelectionEventType> events_;
235 bool caret_moved_; 236 bool caret_moved_;
236 bool selection_moved_; 237 bool selection_moved_;
237 bool selection_points_swapped_; 238 bool selection_points_swapped_;
238 bool needs_animate_; 239 bool needs_animate_;
239 bool animation_enabled_; 240 bool animation_enabled_;
240 bool dragging_enabled_; 241 bool dragging_enabled_;
241 scoped_ptr<TouchSelectionController> controller_; 242 std::unique_ptr<TouchSelectionController> controller_;
242 243
243 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerTest); 244 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerTest);
244 }; 245 };
245 246
246 TEST_F(TouchSelectionControllerTest, InsertionBasic) { 247 TEST_F(TouchSelectionControllerTest, InsertionBasic) {
247 gfx::RectF insertion_rect(5, 5, 0, 10); 248 gfx::RectF insertion_rect(5, 5, 0, 10);
248 bool visible = true; 249 bool visible = true;
249 250
250 // Insertion handles are not shown until automatic showing is enabled. 251 // Insertion handles are not shown until automatic showing is enabled.
251 ChangeInsertion(insertion_rect, visible); 252 ChangeInsertion(insertion_rect, visible);
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1474 offset_rect.x(), offset_rect.bottom()); 1475 offset_rect.x(), offset_rect.bottom());
1475 EXPECT_TRUE(controller().WillHandleTouchEvent(event)); 1476 EXPECT_TRUE(controller().WillHandleTouchEvent(event));
1476 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_HANDLE_DRAG_STOPPED)); 1477 EXPECT_THAT(GetAndResetEvents(), ElementsAre(SELECTION_HANDLE_DRAG_STOPPED));
1477 EXPECT_EQ(test_controller.GetStartHandleOrientation(), 1478 EXPECT_EQ(test_controller.GetStartHandleOrientation(),
1478 TouchHandleOrientation::LEFT); 1479 TouchHandleOrientation::LEFT);
1479 EXPECT_EQ(test_controller.GetEndHandleOrientation(), 1480 EXPECT_EQ(test_controller.GetEndHandleOrientation(),
1480 TouchHandleOrientation::RIGHT); 1481 TouchHandleOrientation::RIGHT);
1481 } 1482 }
1482 1483
1483 } // namespace ui 1484 } // namespace ui
OLDNEW
« no previous file with comments | « ui/touch_selection/touch_selection_controller.cc ('k') | ui/views/accessibility/ax_aura_obj_cache_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698