diff options
author | mohsen@chromium.org <mohsen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-02 16:43:03 +0000 |
---|---|---|
committer | mohsen@chromium.org <mohsen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-02 16:43:03 +0000 |
commit | eaaf7bcaddc43f5b30d48f56820eaa6ad9a80d7e (patch) | |
tree | 9258d7229988fa733ab70e351555147a168e1a9f /ui/views/touchui/touch_selection_controller_impl_unittest.cc | |
parent | 600ee6d286f0d390bf32bf7bb7f0eaf07a6d4f19 (diff) | |
download | chromium_src-eaaf7bcaddc43f5b30d48f56820eaa6ad9a80d7e.zip chromium_src-eaaf7bcaddc43f5b30d48f56820eaa6ad9a80d7e.tar.gz chromium_src-eaaf7bcaddc43f5b30d48f56820eaa6ad9a80d7e.tar.bz2 |
End touch editing on mouse and keyboard events
Whenever a mouse or keyboard event happens anywhere in any display,
touch text seleciton should be deactivated. We do not want to deactivate
if mouse event is due to a touch action, therefore we check if mouse
events are not disabled (because of a touch action).
BUG=286030
Review URL: https://codereview.chromium.org/257573003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@267813 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/touchui/touch_selection_controller_impl_unittest.cc')
-rw-r--r-- | ui/views/touchui/touch_selection_controller_impl_unittest.cc | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/ui/views/touchui/touch_selection_controller_impl_unittest.cc b/ui/views/touchui/touch_selection_controller_impl_unittest.cc index d228caf..07d78c4 100644 --- a/ui/views/touchui/touch_selection_controller_impl_unittest.cc +++ b/ui/views/touchui/touch_selection_controller_impl_unittest.cc @@ -92,7 +92,7 @@ class TouchSelectionControllerImplTest : public ViewsTestBase { textfield_widget_->SetContentsView(container); container->AddChildView(textfield_); - textfield_->SetBoundsRect(params.bounds); + textfield_->SetBoundsRect(gfx::Rect(0, 0, 200, 20)); textfield_->set_id(1); textfield_widget_->Show(); @@ -600,6 +600,9 @@ class TestTouchEditable : public ui::TouchEditable { virtual void OpenContextMenu(const gfx::Point& anchor) OVERRIDE { NOTREACHED(); } + virtual void DestroyTouchSelection() OVERRIDE { + NOTREACHED(); + } // Overridden from ui::SimpleMenuModel::Delegate. virtual bool IsCommandIdChecked(int command_id) const OVERRIDE { @@ -779,4 +782,63 @@ TEST_F(TouchSelectionControllerImplTest, QuickMenuAdjustsAnchorRect) { widget_ = NULL; } +TEST_F(TouchSelectionControllerImplTest, MouseEventDeactivatesTouchSelection) { + CreateTextfield(); + EXPECT_FALSE(GetSelectionController()); + + aura::test::EventGenerator generator( + textfield_widget_->GetNativeView()->GetRootWindow()); + + generator.set_current_location(gfx::Point(5, 5)); + RunPendingMessages(); + + // Start touch editing; then move mouse over the textfield and ensure it + // deactivates touch selection. + StartTouchEditing(); + EXPECT_TRUE(GetSelectionController()); + generator.MoveMouseTo(gfx::Point(5, 10)); + RunPendingMessages(); + EXPECT_FALSE(GetSelectionController()); + + generator.MoveMouseTo(gfx::Point(5, 50)); + RunPendingMessages(); + + // Start touch editing; then move mouse out of the textfield, but inside the + // winow and ensure it deactivates touch selection. + StartTouchEditing(); + EXPECT_TRUE(GetSelectionController()); + generator.MoveMouseTo(gfx::Point(5, 55)); + RunPendingMessages(); + EXPECT_FALSE(GetSelectionController()); + + generator.MoveMouseTo(gfx::Point(5, 500)); + RunPendingMessages(); + + // Start touch editing; then move mouse out of the textfield and window and + // ensure it deactivates touch selection. + StartTouchEditing(); + EXPECT_TRUE(GetSelectionController()); + generator.MoveMouseTo(5, 505); + RunPendingMessages(); + EXPECT_FALSE(GetSelectionController()); +} + +TEST_F(TouchSelectionControllerImplTest, KeyEventDeactivatesTouchSelection) { + CreateTextfield(); + EXPECT_FALSE(GetSelectionController()); + + aura::test::EventGenerator generator( + textfield_widget_->GetNativeView()->GetRootWindow()); + + RunPendingMessages(); + + // Start touch editing; then press a key and ensure it deactivates touch + // selection. + StartTouchEditing(); + EXPECT_TRUE(GetSelectionController()); + generator.PressKey(ui::VKEY_A, 0); + RunPendingMessages(); + EXPECT_FALSE(GetSelectionController()); +} + } // namespace views |