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

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

Issue 1260453006: ui: events: Add a class to hold common touch and stylus properties (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address build problems, add accessor and unit tests. Created 5 years, 4 months 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
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 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 ui::EventTargeter* targeter = root->GetEventTargeter(); 725 ui::EventTargeter* targeter = root->GetEventTargeter();
726 726
727 // Create the first window containing a Views::Textfield. 727 // Create the first window containing a Views::Textfield.
728 CreateTextfield(); 728 CreateTextfield();
729 aura::Window* window1 = textfield_widget_->GetNativeView(); 729 aura::Window* window1 = textfield_widget_->GetNativeView();
730 730
731 // Start touch editing, check that the handle is above the first window, and 731 // Start touch editing, check that the handle is above the first window, and
732 // end touch editing. 732 // end touch editing.
733 StartTouchEditing(); 733 StartTouchEditing();
734 gfx::Point test_point = GetCursorHandleDragPoint(); 734 gfx::Point test_point = GetCursorHandleDragPoint();
735 ui::MouseEvent test_event1(ui::ET_MOUSE_MOVED, test_point, test_point, 735 ui::MouseEvent test_event1(
736 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 736 ui::ET_MOUSE_MOVED, test_point, test_point, ui::EventTimeForNow(),
737 ui::EF_NONE, ui::EF_NONE,
738 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
737 EXPECT_EQ(GetCursorHandleNativeView(), 739 EXPECT_EQ(GetCursorHandleNativeView(),
738 targeter->FindTargetForEvent(root, &test_event1)); 740 targeter->FindTargetForEvent(root, &test_event1));
739 EndTouchEditing(); 741 EndTouchEditing();
740 742
741 // Create the second (empty) window over the first one. 743 // Create the second (empty) window over the first one.
742 CreateWidget(); 744 CreateWidget();
743 aura::Window* window2 = widget_->GetNativeView(); 745 aura::Window* window2 = widget_->GetNativeView();
744 746
745 // Start touch editing (in the first window) and check that the handle is not 747 // Start touch editing (in the first window) and check that the handle is not
746 // above the second window. 748 // above the second window.
747 StartTouchEditing(); 749 StartTouchEditing();
748 ui::MouseEvent test_event2(ui::ET_MOUSE_MOVED, test_point, test_point, 750 ui::MouseEvent test_event2(
749 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 751 ui::ET_MOUSE_MOVED, test_point, test_point, ui::EventTimeForNow(),
752 ui::EF_NONE, ui::EF_NONE,
753 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
750 EXPECT_EQ(window2, targeter->FindTargetForEvent(root, &test_event2)); 754 EXPECT_EQ(window2, targeter->FindTargetForEvent(root, &test_event2));
751 755
752 // Move the first window to top and check that the handle is kept above the 756 // Move the first window to top and check that the handle is kept above the
753 // first window. 757 // first window.
754 window1->GetRootWindow()->StackChildAtTop(window1); 758 window1->GetRootWindow()->StackChildAtTop(window1);
755 ui::MouseEvent test_event3(ui::ET_MOUSE_MOVED, test_point, test_point, 759 ui::MouseEvent test_event3(
756 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 760 ui::ET_MOUSE_MOVED, test_point, test_point, ui::EventTimeForNow(),
761 ui::EF_NONE, ui::EF_NONE,
762 ui::PointerEventDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
757 EXPECT_EQ(GetCursorHandleNativeView(), 763 EXPECT_EQ(GetCursorHandleNativeView(),
758 targeter->FindTargetForEvent(root, &test_event3)); 764 targeter->FindTargetForEvent(root, &test_event3));
759 } 765 }
760 766
761 TEST_F(TouchSelectionControllerImplTest, MouseEventDeactivatesTouchSelection) { 767 TEST_F(TouchSelectionControllerImplTest, MouseEventDeactivatesTouchSelection) {
762 CreateTextfield(); 768 CreateTextfield();
763 EXPECT_FALSE(GetSelectionController()); 769 EXPECT_FALSE(GetSelectionController());
764 770
765 ui::test::EventGenerator generator( 771 ui::test::EventGenerator generator(
766 textfield_widget_->GetNativeView()->GetRootWindow()); 772 textfield_widget_->GetNativeView()->GetRootWindow());
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 // Start touch editing; then press a key and ensure it deactivates touch 817 // Start touch editing; then press a key and ensure it deactivates touch
812 // selection. 818 // selection.
813 StartTouchEditing(); 819 StartTouchEditing();
814 EXPECT_TRUE(GetSelectionController()); 820 EXPECT_TRUE(GetSelectionController());
815 generator.PressKey(ui::VKEY_A, 0); 821 generator.PressKey(ui::VKEY_A, 0);
816 RunPendingMessages(); 822 RunPendingMessages();
817 EXPECT_FALSE(GetSelectionController()); 823 EXPECT_FALSE(GetSelectionController());
818 } 824 }
819 825
820 } // namespace views 826 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698