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

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

Issue 679233002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/view_targeter_unittest.cc » ('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/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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 TouchSelectionControllerImplTest() 64 TouchSelectionControllerImplTest()
65 : textfield_widget_(NULL), 65 : textfield_widget_(NULL),
66 widget_(NULL), 66 widget_(NULL),
67 textfield_(NULL), 67 textfield_(NULL),
68 views_tsc_factory_(new ViewsTouchSelectionControllerFactory) { 68 views_tsc_factory_(new ViewsTouchSelectionControllerFactory) {
69 CommandLine::ForCurrentProcess()->AppendSwitch( 69 CommandLine::ForCurrentProcess()->AppendSwitch(
70 switches::kEnableTouchEditing); 70 switches::kEnableTouchEditing);
71 ui::TouchSelectionControllerFactory::SetInstance(views_tsc_factory_.get()); 71 ui::TouchSelectionControllerFactory::SetInstance(views_tsc_factory_.get());
72 } 72 }
73 73
74 virtual ~TouchSelectionControllerImplTest() { 74 ~TouchSelectionControllerImplTest() override {
75 ui::TouchSelectionControllerFactory::SetInstance(NULL); 75 ui::TouchSelectionControllerFactory::SetInstance(NULL);
76 } 76 }
77 77
78 virtual void TearDown() { 78 void TearDown() override {
79 if (textfield_widget_ && !textfield_widget_->IsClosed()) 79 if (textfield_widget_ && !textfield_widget_->IsClosed())
80 textfield_widget_->Close(); 80 textfield_widget_->Close();
81 if (widget_ && !widget_->IsClosed()) 81 if (widget_ && !widget_->IsClosed())
82 widget_->Close(); 82 widget_->Close();
83 ViewsTestBase::TearDown(); 83 ViewsTestBase::TearDown();
84 } 84 }
85 85
86 void CreateTextfield() { 86 void CreateTextfield() {
87 textfield_ = new Textfield(); 87 textfield_ = new Textfield();
88 textfield_widget_ = new Widget; 88 textfield_widget_ = new Widget;
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 } 563 }
564 564
565 void set_bounds(const gfx::Rect& bounds) { 565 void set_bounds(const gfx::Rect& bounds) {
566 bounds_ = bounds; 566 bounds_ = bounds;
567 } 567 }
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 ~TestTouchEditable() override {}
574 574
575 private: 575 private:
576 // Overridden from ui::TouchEditable. 576 // Overridden from ui::TouchEditable.
577 virtual void SelectRect( 577 void SelectRect(const gfx::Point& start, const gfx::Point& end) override {
578 const gfx::Point& start, const gfx::Point& end) override {
579 NOTREACHED(); 578 NOTREACHED();
580 } 579 }
581 virtual void MoveCaretTo(const gfx::Point& point) override { 580 void MoveCaretTo(const gfx::Point& point) override { NOTREACHED(); }
582 NOTREACHED(); 581 void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) override {
583 }
584 virtual void GetSelectionEndPoints(gfx::Rect* p1, gfx::Rect* p2) override {
585 *p1 = *p2 = cursor_rect_; 582 *p1 = *p2 = cursor_rect_;
586 } 583 }
587 virtual gfx::Rect GetBounds() override { 584 gfx::Rect GetBounds() override { return gfx::Rect(bounds_.size()); }
588 return gfx::Rect(bounds_.size()); 585 gfx::NativeView GetNativeView() const override { return window_; }
589 } 586 void ConvertPointToScreen(gfx::Point* point) override {
590 virtual gfx::NativeView GetNativeView() const override {
591 return window_;
592 }
593 virtual void ConvertPointToScreen(gfx::Point* point) override {
594 aura::client::ScreenPositionClient* screen_position_client = 587 aura::client::ScreenPositionClient* screen_position_client =
595 aura::client::GetScreenPositionClient(window_->GetRootWindow()); 588 aura::client::GetScreenPositionClient(window_->GetRootWindow());
596 if (screen_position_client) 589 if (screen_position_client)
597 screen_position_client->ConvertPointToScreen(window_, point); 590 screen_position_client->ConvertPointToScreen(window_, point);
598 } 591 }
599 virtual void ConvertPointFromScreen(gfx::Point* point) override { 592 void ConvertPointFromScreen(gfx::Point* point) override {
600 aura::client::ScreenPositionClient* screen_position_client = 593 aura::client::ScreenPositionClient* screen_position_client =
601 aura::client::GetScreenPositionClient(window_->GetRootWindow()); 594 aura::client::GetScreenPositionClient(window_->GetRootWindow());
602 if (screen_position_client) 595 if (screen_position_client)
603 screen_position_client->ConvertPointFromScreen(window_, point); 596 screen_position_client->ConvertPointFromScreen(window_, point);
604 } 597 }
605 virtual bool DrawsHandles() override { 598 bool DrawsHandles() override { return false; }
599 void OpenContextMenu(const gfx::Point& anchor) override { NOTREACHED(); }
600 void DestroyTouchSelection() override { NOTREACHED(); }
601
602 // Overridden from ui::SimpleMenuModel::Delegate.
603 bool IsCommandIdChecked(int command_id) const override {
604 NOTREACHED();
606 return false; 605 return false;
607 } 606 }
608 virtual void OpenContextMenu(const gfx::Point& anchor) override { 607 bool IsCommandIdEnabled(int command_id) const override {
609 NOTREACHED(); 608 NOTREACHED();
609 return false;
610 } 610 }
611 virtual void DestroyTouchSelection() override { 611 bool GetAcceleratorForCommandId(int command_id,
612 ui::Accelerator* accelerator) override {
613 NOTREACHED();
614 return false;
615 }
616 void ExecuteCommand(int command_id, int event_flags) override {
612 NOTREACHED(); 617 NOTREACHED();
613 } 618 }
614 619
615 // Overridden from ui::SimpleMenuModel::Delegate.
616 virtual bool IsCommandIdChecked(int command_id) const override {
617 NOTREACHED();
618 return false;
619 }
620 virtual bool IsCommandIdEnabled(int command_id) const override {
621 NOTREACHED();
622 return false;
623 }
624 virtual bool GetAcceleratorForCommandId(
625 int command_id,
626 ui::Accelerator* accelerator) override {
627 NOTREACHED();
628 return false;
629 }
630 virtual void ExecuteCommand(int command_id, int event_flags) override {
631 NOTREACHED();
632 }
633
634 aura::Window* window_; 620 aura::Window* window_;
635 621
636 // Boundaries of the client view. 622 // Boundaries of the client view.
637 gfx::Rect bounds_; 623 gfx::Rect bounds_;
638 624
639 // Cursor position inside the client view. 625 // Cursor position inside the client view.
640 gfx::Rect cursor_rect_; 626 gfx::Rect cursor_rect_;
641 627
642 DISALLOW_COPY_AND_ASSIGN(TestTouchEditable); 628 DISALLOW_COPY_AND_ASSIGN(TestTouchEditable);
643 }; 629 };
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 ui::EF_NONE, ui::EF_NONE); 709 ui::EF_NONE, ui::EF_NONE);
724 EXPECT_EQ(GetCursorHandleNativeView(), 710 EXPECT_EQ(GetCursorHandleNativeView(),
725 targeter->FindTargetForEvent(root, &test_event3)); 711 targeter->FindTargetForEvent(root, &test_event3));
726 } 712 }
727 713
728 // A simple implementation of TouchEditingMenuController that enables all 714 // A simple implementation of TouchEditingMenuController that enables all
729 // available commands. 715 // available commands.
730 class TestTouchEditingMenuController : public TouchEditingMenuController { 716 class TestTouchEditingMenuController : public TouchEditingMenuController {
731 public: 717 public:
732 TestTouchEditingMenuController() {} 718 TestTouchEditingMenuController() {}
733 virtual ~TestTouchEditingMenuController() {} 719 ~TestTouchEditingMenuController() override {}
734 720
735 // Overriden from TouchEditingMenuController. 721 // Overriden from TouchEditingMenuController.
736 virtual bool IsCommandIdEnabled(int command_id) const override { 722 bool IsCommandIdEnabled(int command_id) const override {
737 // Return true, since we want the menu to have all |kMenuCommandCount| 723 // Return true, since we want the menu to have all |kMenuCommandCount|
738 // available commands. 724 // available commands.
739 return true; 725 return true;
740 } 726 }
741 virtual void ExecuteCommand(int command_id, int event_flags) override { 727 void ExecuteCommand(int command_id, int event_flags) override {
742 NOTREACHED(); 728 NOTREACHED();
743 } 729 }
744 virtual void OpenContextMenu() override { 730 void OpenContextMenu() override { NOTREACHED(); }
745 NOTREACHED(); 731 void OnMenuClosed(TouchEditingMenuView* menu) override {}
746 }
747 virtual void OnMenuClosed(TouchEditingMenuView* menu) override {}
748 732
749 private: 733 private:
750 DISALLOW_COPY_AND_ASSIGN(TestTouchEditingMenuController); 734 DISALLOW_COPY_AND_ASSIGN(TestTouchEditingMenuController);
751 }; 735 };
752 736
753 // Tests if anchor rect for touch editing quick menu is adjusted correctly based 737 // Tests if anchor rect for touch editing quick menu is adjusted correctly based
754 // on the distance of handles. 738 // on the distance of handles.
755 TEST_F(TouchSelectionControllerImplTest, QuickMenuAdjustsAnchorRect) { 739 TEST_F(TouchSelectionControllerImplTest, QuickMenuAdjustsAnchorRect) {
756 CreateWidget(); 740 CreateWidget();
757 aura::Window* window = widget_->GetNativeView(); 741 aura::Window* window = widget_->GetNativeView();
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 // Start touch editing; then press a key and ensure it deactivates touch 827 // Start touch editing; then press a key and ensure it deactivates touch
844 // selection. 828 // selection.
845 StartTouchEditing(); 829 StartTouchEditing();
846 EXPECT_TRUE(GetSelectionController()); 830 EXPECT_TRUE(GetSelectionController());
847 generator.PressKey(ui::VKEY_A, 0); 831 generator.PressKey(ui::VKEY_A, 0);
848 RunPendingMessages(); 832 RunPendingMessages();
849 EXPECT_FALSE(GetSelectionController()); 833 EXPECT_FALSE(GetSelectionController());
850 } 834 }
851 835
852 } // namespace views 836 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl.cc ('k') | ui/views/view_targeter_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698