| OLD | NEW |
| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "ui/aura/client/screen_position_client.h" | 10 #include "ui/aura/client/screen_position_client.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 EXPECT_EQ(ui::SelectionBound::CENTER, focus.type()) << from_str; | 266 EXPECT_EQ(ui::SelectionBound::CENTER, focus.type()) << from_str; |
| 267 EXPECT_EQ(ui::SelectionBound::CENTER, anchor.type()) << from_str; | 267 EXPECT_EQ(ui::SelectionBound::CENTER, anchor.type()) << from_str; |
| 268 } | 268 } |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 | 271 |
| 272 Widget* textfield_widget_; | 272 Widget* textfield_widget_; |
| 273 Widget* widget_; | 273 Widget* widget_; |
| 274 | 274 |
| 275 Textfield* textfield_; | 275 Textfield* textfield_; |
| 276 scoped_ptr<TextfieldTestApi> textfield_test_api_; | 276 std::unique_ptr<TextfieldTestApi> textfield_test_api_; |
| 277 scoped_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_; | 277 std::unique_ptr<ViewsTouchEditingControllerFactory> views_tsc_factory_; |
| 278 scoped_ptr<aura::test::TestCursorClient> test_cursor_client_; | 278 std::unique_ptr<aura::test::TestCursorClient> test_cursor_client_; |
| 279 | 279 |
| 280 private: | 280 private: |
| 281 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerImplTest); | 281 DISALLOW_COPY_AND_ASSIGN(TouchSelectionControllerImplTest); |
| 282 }; | 282 }; |
| 283 | 283 |
| 284 // Tests that the selection handles are placed appropriately when selection in | 284 // Tests that the selection handles are placed appropriately when selection in |
| 285 // a Textfield changes. | 285 // a Textfield changes. |
| 286 TEST_F(TouchSelectionControllerImplTest, SelectionInTextfieldTest) { | 286 TEST_F(TouchSelectionControllerImplTest, SelectionInTextfieldTest) { |
| 287 CreateTextfield(); | 287 CreateTextfield(); |
| 288 textfield_->SetText(ASCIIToUTF16("some text")); | 288 textfield_->SetText(ASCIIToUTF16("some text")); |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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::TouchEditingControllerDeprecated> touch_selection_controller( | 688 std::unique_ptr<ui::TouchEditingControllerDeprecated> |
| 689 ui::TouchEditingControllerDeprecated::Create(&touch_editable)); | 689 touch_selection_controller( |
| 690 ui::TouchEditingControllerDeprecated::Create(&touch_editable)); |
| 690 | 691 |
| 691 touch_editable.set_bounds(gfx::Rect(0, 0, 100, 20)); | 692 touch_editable.set_bounds(gfx::Rect(0, 0, 100, 20)); |
| 692 | 693 |
| 693 // Put the cursor completely inside the client bounds. Handle should be | 694 // Put the cursor completely inside the client bounds. Handle should be |
| 694 // visible. | 695 // visible. |
| 695 touch_editable.set_cursor_rect(gfx::RectF(2.f, 0.f, 1.f, 20.f)); | 696 touch_editable.set_cursor_rect(gfx::RectF(2.f, 0.f, 1.f, 20.f)); |
| 696 touch_selection_controller->SelectionChanged(); | 697 touch_selection_controller->SelectionChanged(); |
| 697 EXPECT_TRUE(IsCursorHandleVisibleFor(touch_selection_controller.get())); | 698 EXPECT_TRUE(IsCursorHandleVisibleFor(touch_selection_controller.get())); |
| 698 | 699 |
| 699 // Move the cursor up such that |kBarMinHeight| pixels are still in the client | 700 // Move the cursor up such that |kBarMinHeight| pixels are still in the client |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 837 // Start touch editing; then press a key and ensure it deactivates touch | 838 // Start touch editing; then press a key and ensure it deactivates touch |
| 838 // selection. | 839 // selection. |
| 839 StartTouchEditing(); | 840 StartTouchEditing(); |
| 840 EXPECT_TRUE(GetSelectionController()); | 841 EXPECT_TRUE(GetSelectionController()); |
| 841 generator.PressKey(ui::VKEY_A, 0); | 842 generator.PressKey(ui::VKEY_A, 0); |
| 842 RunPendingMessages(); | 843 RunPendingMessages(); |
| 843 EXPECT_FALSE(GetSelectionController()); | 844 EXPECT_FALSE(GetSelectionController()); |
| 844 } | 845 } |
| 845 | 846 |
| 846 } // namespace views | 847 } // namespace views |
| OLD | NEW |