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

Side by Side Diff: ui/views/touchui/touch_selection_controller_impl_unittest.cc

Issue 798683003: Rename old Aura TouchSelectionController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Minor fixes Created 6 years 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
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl.cc ('k') | ui/views/views_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "ui/aura/client/screen_position_client.h" 7 #include "ui/aura/client/screen_position_client.h"
8 #include "ui/aura/test/test_cursor_client.h" 8 #include "ui/aura/test/test_cursor_client.h"
9 #include "ui/aura/window.h" 9 #include "ui/aura/window.h"
10 #include "ui/base/resource/resource_bundle.h" 10 #include "ui/base/resource/resource_bundle.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 } // namespace 58 } // namespace
59 59
60 namespace views { 60 namespace views {
61 61
62 class TouchSelectionControllerImplTest : public ViewsTestBase { 62 class TouchSelectionControllerImplTest : public ViewsTestBase {
63 public: 63 public:
64 TouchSelectionControllerImplTest() 64 TouchSelectionControllerImplTest()
65 : textfield_widget_(nullptr), 65 : textfield_widget_(nullptr),
66 widget_(nullptr), 66 widget_(nullptr),
67 textfield_(nullptr), 67 textfield_(nullptr),
68 views_tsc_factory_(new ViewsTouchSelectionControllerFactory) { 68 views_tsc_factory_(new ViewsTouchEditingControllerFactory) {
69 CommandLine::ForCurrentProcess()->AppendSwitch( 69 CommandLine::ForCurrentProcess()->AppendSwitch(
70 switches::kEnableTouchEditing); 70 switches::kEnableTouchEditing);
71 ui::TouchSelectionControllerFactory::SetInstance(views_tsc_factory_.get()); 71 ui::TouchEditingControllerFactory::SetInstance(views_tsc_factory_.get());
72 } 72 }
73 73
74 ~TouchSelectionControllerImplTest() override { 74 ~TouchSelectionControllerImplTest() override {
75 ui::TouchSelectionControllerFactory::SetInstance(nullptr); 75 ui::TouchEditingControllerFactory::SetInstance(nullptr);
76 } 76 }
77 77
78 void SetUp() override { 78 void SetUp() override {
79 ViewsTestBase::SetUp(); 79 ViewsTestBase::SetUp();
80 test_cursor_client_.reset(new aura::test::TestCursorClient(GetContext())); 80 test_cursor_client_.reset(new aura::test::TestCursorClient(GetContext()));
81 } 81 }
82 82
83 void TearDown() override { 83 void TearDown() override {
84 test_cursor_client_.reset(); 84 test_cursor_client_.reset();
85 if (textfield_widget_ && !textfield_widget_->IsClosed()) 85 if (textfield_widget_ && !textfield_widget_->IsClosed())
(...skipping 24 matching lines...) Expand all
110 void CreateWidget() { 110 void CreateWidget() {
111 widget_ = new Widget; 111 widget_ = new Widget;
112 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP); 112 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_POPUP);
113 params.bounds = gfx::Rect(0, 0, 200, 200); 113 params.bounds = gfx::Rect(0, 0, 200, 200);
114 widget_->Init(params); 114 widget_->Init(params);
115 widget_->Show(); 115 widget_->Show();
116 } 116 }
117 117
118 protected: 118 protected:
119 static bool IsCursorHandleVisibleFor( 119 static bool IsCursorHandleVisibleFor(
120 ui::TouchSelectionController* controller) { 120 ui::TouchEditingControllerDeprecated* controller) {
121 TouchSelectionControllerImpl* impl = 121 TouchSelectionControllerImpl* impl =
122 static_cast<TouchSelectionControllerImpl*>(controller); 122 static_cast<TouchSelectionControllerImpl*>(controller);
123 return impl->IsCursorHandleVisible(); 123 return impl->IsCursorHandleVisible();
124 } 124 }
125 125
126 gfx::Rect GetCursorRect(const gfx::SelectionModel& sel) { 126 gfx::Rect GetCursorRect(const gfx::SelectionModel& sel) {
127 return textfield_test_api_->GetRenderText()->GetCursorBounds(sel, true); 127 return textfield_test_api_->GetRenderText()->GetCursorBounds(sel, true);
128 } 128 }
129 129
130 gfx::Point GetCursorPosition(const gfx::SelectionModel& sel) { 130 gfx::Point GetCursorPosition(const gfx::SelectionModel& sel) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 EXPECT_EQ(ui::SelectionBound::CENTER, anchor.type()) << from_str; 269 EXPECT_EQ(ui::SelectionBound::CENTER, anchor.type()) << from_str;
270 } 270 }
271 } 271 }
272 } 272 }
273 273
274 Widget* textfield_widget_; 274 Widget* textfield_widget_;
275 Widget* widget_; 275 Widget* widget_;
276 276
277 Textfield* textfield_; 277 Textfield* textfield_;
278 scoped_ptr<TextfieldTestApi> textfield_test_api_; 278 scoped_ptr<TextfieldTestApi> textfield_test_api_;
279 scoped_ptr<ViewsTouchSelectionControllerFactory> views_tsc_factory_; 279 scoped_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_;
280 scoped_ptr<aura::test::TestCursorClient> test_cursor_client_; 280 scoped_ptr<aura::test::TestCursorClient> test_cursor_client_;
281 281
282 private: 282 private:
283 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerImplTest); 283 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerImplTest);
284 }; 284 };
285 285
286 // Tests that the selection handles are placed appropriately when selection in 286 // Tests that the selection handles are placed appropriately when selection in
287 // a Textfield changes. 287 // a Textfield changes.
288 TEST_F(TouchSelectionControllerImplTest, SelectionInTextfieldTest) { 288 TEST_F(TouchSelectionControllerImplTest, SelectionInTextfieldTest) {
289 CreateTextfield(); 289 CreateTextfield();
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 DISALLOW_COPY_AND_ASSIGN(TestTouchEditable); 678 DISALLOW_COPY_AND_ASSIGN(TestTouchEditable);
679 }; 679 };
680 680
681 // Tests if the touch editing handle is shown or hidden properly according to 681 // Tests if the touch editing handle is shown or hidden properly according to
682 // the cursor position relative to the client boundaries. 682 // the cursor position relative to the client boundaries.
683 TEST_F(TouchSelectionControllerImplTest, 683 TEST_F(TouchSelectionControllerImplTest,
684 VisibilityOfHandleRegardingClientBounds) { 684 VisibilityOfHandleRegardingClientBounds) {
685 CreateWidget(); 685 CreateWidget();
686 686
687 TestTouchEditable touch_editable(widget_->GetNativeView()); 687 TestTouchEditable touch_editable(widget_->GetNativeView());
688 scoped_ptr<ui::TouchSelectionController> touch_selection_controller( 688 scoped_ptr<ui::TouchEditingControllerDeprecated> touch_selection_controller(
689 ui::TouchSelectionController::create(&touch_editable)); 689 ui::TouchEditingControllerDeprecated::Create(&touch_editable));
690 690
691 touch_editable.set_bounds(gfx::Rect(0, 0, 100, 20)); 691 touch_editable.set_bounds(gfx::Rect(0, 0, 100, 20));
692 692
693 // Put the cursor completely inside the client bounds. Handle should be 693 // Put the cursor completely inside the client bounds. Handle should be
694 // visible. 694 // visible.
695 touch_editable.set_cursor_rect(gfx::Rect(2, 0, 1, 20)); 695 touch_editable.set_cursor_rect(gfx::Rect(2, 0, 1, 20));
696 touch_selection_controller->SelectionChanged(); 696 touch_selection_controller->SelectionChanged();
697 EXPECT_TRUE(IsCursorHandleVisibleFor(touch_selection_controller.get())); 697 EXPECT_TRUE(IsCursorHandleVisibleFor(touch_selection_controller.get()));
698 698
699 // Move the cursor up such that |kBarMinHeight| pixels are still in the client 699 // Move the cursor up such that |kBarMinHeight| pixels are still in the client
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 // Start touch editing; then press a key and ensure it deactivates touch 877 // Start touch editing; then press a key and ensure it deactivates touch
878 // selection. 878 // selection.
879 StartTouchEditing(); 879 StartTouchEditing();
880 EXPECT_TRUE(GetSelectionController()); 880 EXPECT_TRUE(GetSelectionController());
881 generator.PressKey(ui::VKEY_A, 0); 881 generator.PressKey(ui::VKEY_A, 0);
882 RunPendingMessages(); 882 RunPendingMessages();
883 EXPECT_FALSE(GetSelectionController()); 883 EXPECT_FALSE(GetSelectionController());
884 } 884 }
885 885
886 } // namespace views 886 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl.cc ('k') | ui/views/views_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698