| 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 "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/window.h" | 8 #include "ui/aura/window.h" |
| 9 #include "ui/base/resource/resource_bundle.h" | 9 #include "ui/base/resource/resource_bundle.h" |
| 10 #include "ui/base/touch/touch_editing_controller.h" | 10 #include "ui/base/touch/touch_editing_controller.h" |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 | 568 |
| 569 void set_cursor_rect(const gfx::Rect& cursor_rect) { | 569 void set_cursor_rect(const gfx::Rect& cursor_rect) { |
| 570 cursor_rect_ = cursor_rect; | 570 cursor_rect_ = cursor_rect; |
| 571 } | 571 } |
| 572 | 572 |
| 573 virtual ~TestTouchEditable() {} | 573 virtual ~TestTouchEditable() {} |
| 574 | 574 |
| 575 private: | 575 private: |
| 576 // Overridden from ui::TouchEditable. | 576 // Overridden from ui::TouchEditable. |
| 577 virtual void SelectRect( | 577 virtual void SelectRect( |
| 578 const gfx::Point& start, const gfx::Point& end) OVERRIDE { | 578 const gfx::Point& start, const gfx::Point& end) override { |
| 579 NOTREACHED(); | 579 NOTREACHED(); |
| 580 } | 580 } |
| 581 virtual void MoveCaretTo(const gfx::Point& point) OVERRIDE { | 581 virtual void MoveCaretTo(const gfx::Point& point) override { |
| 582 NOTREACHED(); | 582 NOTREACHED(); |
| 583 } | 583 } |
| 584 virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) OVERRIDE { | 584 virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) override { |
| 585 *p1 = *p2 = cursor_rect_; | 585 *p1 = *p2 = cursor_rect_; |
| 586 } | 586 } |
| 587 virtual gfx::Rect GetBounds() OVERRIDE { | 587 virtual gfx::Rect GetBounds() override { |
| 588 return gfx::Rect(bounds_.size()); | 588 return gfx::Rect(bounds_.size()); |
| 589 } | 589 } |
| 590 virtual gfx::NativeView GetNativeView() const OVERRIDE { | 590 virtual gfx::NativeView GetNativeView() const override { |
| 591 return window_; | 591 return window_; |
| 592 } | 592 } |
| 593 virtual void ConvertPointToScreen(gfx::Point* point) OVERRIDE { | 593 virtual void ConvertPointToScreen(gfx::Point* point) override { |
| 594 aura::client::ScreenPositionClient* screen_position_client = | 594 aura::client::ScreenPositionClient* screen_position_client = |
| 595 aura::client::GetScreenPositionClient(window_->GetRootWindow()); | 595 aura::client::GetScreenPositionClient(window_->GetRootWindow()); |
| 596 if (screen_position_client) | 596 if (screen_position_client) |
| 597 screen_position_client->ConvertPointToScreen(window_, point); | 597 screen_position_client->ConvertPointToScreen(window_, point); |
| 598 } | 598 } |
| 599 virtual void ConvertPointFromScreen(gfx::Point* point) OVERRIDE { | 599 virtual void ConvertPointFromScreen(gfx::Point* point) override { |
| 600 aura::client::ScreenPositionClient* screen_position_client = | 600 aura::client::ScreenPositionClient* screen_position_client = |
| 601 aura::client::GetScreenPositionClient(window_->GetRootWindow()); | 601 aura::client::GetScreenPositionClient(window_->GetRootWindow()); |
| 602 if (screen_position_client) | 602 if (screen_position_client) |
| 603 screen_position_client->ConvertPointFromScreen(window_, point); | 603 screen_position_client->ConvertPointFromScreen(window_, point); |
| 604 } | 604 } |
| 605 virtual bool DrawsHandles() OVERRIDE { | 605 virtual bool DrawsHandles() override { |
| 606 return false; | 606 return false; |
| 607 } | 607 } |
| 608 virtual void OpenContextMenu(const gfx::Point& anchor) OVERRIDE { | 608 virtual void OpenContextMenu(const gfx::Point& anchor) override { |
| 609 NOTREACHED(); | 609 NOTREACHED(); |
| 610 } | 610 } |
| 611 virtual void DestroyTouchSelection() OVERRIDE { | 611 virtual void DestroyTouchSelection() override { |
| 612 NOTREACHED(); | 612 NOTREACHED(); |
| 613 } | 613 } |
| 614 | 614 |
| 615 // Overridden from ui::SimpleMenuModel::Delegate. | 615 // Overridden from ui::SimpleMenuModel::Delegate. |
| 616 virtual bool IsCommandIdChecked(int command_id) const OVERRIDE { | 616 virtual bool IsCommandIdChecked(int command_id) const override { |
| 617 NOTREACHED(); | 617 NOTREACHED(); |
| 618 return false; | 618 return false; |
| 619 } | 619 } |
| 620 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE { | 620 virtual bool IsCommandIdEnabled(int command_id) const override { |
| 621 NOTREACHED(); | 621 NOTREACHED(); |
| 622 return false; | 622 return false; |
| 623 } | 623 } |
| 624 virtual bool GetAcceleratorForCommandId( | 624 virtual bool GetAcceleratorForCommandId( |
| 625 int command_id, | 625 int command_id, |
| 626 ui::Accelerator* accelerator) OVERRIDE { | 626 ui::Accelerator* accelerator) override { |
| 627 NOTREACHED(); | 627 NOTREACHED(); |
| 628 return false; | 628 return false; |
| 629 } | 629 } |
| 630 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE { | 630 virtual void ExecuteCommand(int command_id, int event_flags) override { |
| 631 NOTREACHED(); | 631 NOTREACHED(); |
| 632 } | 632 } |
| 633 | 633 |
| 634 aura::Window* window_; | 634 aura::Window* window_; |
| 635 | 635 |
| 636 // Boundaries of the client view. | 636 // Boundaries of the client view. |
| 637 gfx::Rect bounds_; | 637 gfx::Rect bounds_; |
| 638 | 638 |
| 639 // Cursor position inside the client view. | 639 // Cursor position inside the client view. |
| 640 gfx::Rect cursor_rect_; | 640 gfx::Rect cursor_rect_; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 726 } | 726 } |
| 727 | 727 |
| 728 // A simple implementation of TouchEditingMenuController that enables all | 728 // A simple implementation of TouchEditingMenuController that enables all |
| 729 // available commands. | 729 // available commands. |
| 730 class TestTouchEditingMenuController : public TouchEditingMenuController { | 730 class TestTouchEditingMenuController : public TouchEditingMenuController { |
| 731 public: | 731 public: |
| 732 TestTouchEditingMenuController() {} | 732 TestTouchEditingMenuController() {} |
| 733 virtual ~TestTouchEditingMenuController() {} | 733 virtual ~TestTouchEditingMenuController() {} |
| 734 | 734 |
| 735 // Overriden from TouchEditingMenuController. | 735 // Overriden from TouchEditingMenuController. |
| 736 virtual bool IsCommandIdEnabled(int command_id) const OVERRIDE { | 736 virtual bool IsCommandIdEnabled(int command_id) const override { |
| 737 // Return true, since we want the menu to have all |kMenuCommandCount| | 737 // Return true, since we want the menu to have all |kMenuCommandCount| |
| 738 // available commands. | 738 // available commands. |
| 739 return true; | 739 return true; |
| 740 } | 740 } |
| 741 virtual void ExecuteCommand(int command_id, int event_flags) OVERRIDE { | 741 virtual void ExecuteCommand(int command_id, int event_flags) override { |
| 742 NOTREACHED(); | 742 NOTREACHED(); |
| 743 } | 743 } |
| 744 virtual void OpenContextMenu() OVERRIDE { | 744 virtual void OpenContextMenu() override { |
| 745 NOTREACHED(); | 745 NOTREACHED(); |
| 746 } | 746 } |
| 747 virtual void OnMenuClosed(TouchEditingMenuView* menu) OVERRIDE {} | 747 virtual void OnMenuClosed(TouchEditingMenuView* menu) override {} |
| 748 | 748 |
| 749 private: | 749 private: |
| 750 DISALLOW_COPY_AND_ASSIGN(TestTouchEditingMenuController); | 750 DISALLOW_COPY_AND_ASSIGN(TestTouchEditingMenuController); |
| 751 }; | 751 }; |
| 752 | 752 |
| 753 // Tests if anchor rect for touch editing quick menu is adjusted correctly based | 753 // Tests if anchor rect for touch editing quick menu is adjusted correctly based |
| 754 // on the distance of handles. | 754 // on the distance of handles. |
| 755 TEST_F(TouchSelectionControllerImplTest, QuickMenuAdjustsAnchorRect) { | 755 TEST_F(TouchSelectionControllerImplTest, QuickMenuAdjustsAnchorRect) { |
| 756 CreateWidget(); | 756 CreateWidget(); |
| 757 aura::Window* window = widget_->GetNativeView(); | 757 aura::Window* window = widget_->GetNativeView(); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 // Start touch editing; then press a key and ensure it deactivates touch | 843 // Start touch editing; then press a key and ensure it deactivates touch |
| 844 // selection. | 844 // selection. |
| 845 StartTouchEditing(); | 845 StartTouchEditing(); |
| 846 EXPECT_TRUE(GetSelectionController()); | 846 EXPECT_TRUE(GetSelectionController()); |
| 847 generator.PressKey(ui::VKEY_A, 0); | 847 generator.PressKey(ui::VKEY_A, 0); |
| 848 RunPendingMessages(); | 848 RunPendingMessages(); |
| 849 EXPECT_FALSE(GetSelectionController()); | 849 EXPECT_FALSE(GetSelectionController()); |
| 850 } | 850 } |
| 851 | 851 |
| 852 } // namespace views | 852 } // namespace views |
| OLD | NEW |