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

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

Issue 2786693002: Add PointerDetails to ui::MouseEvent's constructors (Closed)
Patch Set: mouse event constructor Created 3 years, 8 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 <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 790 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 root->GetHost()->dispatcher()->GetDefaultEventTargeter(); 801 root->GetHost()->dispatcher()->GetDefaultEventTargeter();
802 802
803 // Create the first window containing a Views::Textfield. 803 // Create the first window containing a Views::Textfield.
804 CreateTextfield(); 804 CreateTextfield();
805 aura::Window* window1 = textfield_widget_->GetNativeView(); 805 aura::Window* window1 = textfield_widget_->GetNativeView();
806 806
807 // Start touch editing, check that the handle is above the first window, and 807 // Start touch editing, check that the handle is above the first window, and
808 // end touch editing. 808 // end touch editing.
809 StartTouchEditing(); 809 StartTouchEditing();
810 gfx::Point test_point = GetCursorHandleDragPoint(); 810 gfx::Point test_point = GetCursorHandleDragPoint();
811 ui::MouseEvent test_event1(ui::ET_MOUSE_MOVED, test_point, test_point, 811 ui::MouseEvent test_event1(
812 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 812 ui::ET_MOUSE_MOVED, test_point, test_point, ui::EventTimeForNow(),
813 ui::EF_NONE, ui::EF_NONE,
814 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
813 EXPECT_EQ(GetCursorHandleNativeView(), 815 EXPECT_EQ(GetCursorHandleNativeView(),
814 targeter->FindTargetForEvent(root, &test_event1)); 816 targeter->FindTargetForEvent(root, &test_event1));
815 EndTouchEditing(); 817 EndTouchEditing();
816 818
817 // Create the second (empty) window over the first one. 819 // Create the second (empty) window over the first one.
818 CreateWidget(); 820 CreateWidget();
819 aura::Window* window2 = widget_->GetNativeView(); 821 aura::Window* window2 = widget_->GetNativeView();
820 822
821 // Start touch editing (in the first window) and check that the handle is not 823 // Start touch editing (in the first window) and check that the handle is not
822 // above the second window. 824 // above the second window.
823 StartTouchEditing(); 825 StartTouchEditing();
824 ui::MouseEvent test_event2(ui::ET_MOUSE_MOVED, test_point, test_point, 826 ui::MouseEvent test_event2(
825 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 827 ui::ET_MOUSE_MOVED, test_point, test_point, ui::EventTimeForNow(),
828 ui::EF_NONE, ui::EF_NONE,
829 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
826 EXPECT_EQ(window2, targeter->FindTargetForEvent(root, &test_event2)); 830 EXPECT_EQ(window2, targeter->FindTargetForEvent(root, &test_event2));
827 831
828 // Move the first window to top and check that the handle is kept above the 832 // Move the first window to top and check that the handle is kept above the
829 // first window. 833 // first window.
830 window1->GetRootWindow()->StackChildAtTop(window1); 834 window1->GetRootWindow()->StackChildAtTop(window1);
831 ui::MouseEvent test_event3(ui::ET_MOUSE_MOVED, test_point, test_point, 835 ui::MouseEvent test_event3(
832 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 836 ui::ET_MOUSE_MOVED, test_point, test_point, ui::EventTimeForNow(),
837 ui::EF_NONE, ui::EF_NONE,
838 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
833 EXPECT_EQ(GetCursorHandleNativeView(), 839 EXPECT_EQ(GetCursorHandleNativeView(),
834 targeter->FindTargetForEvent(root, &test_event3)); 840 targeter->FindTargetForEvent(root, &test_event3));
835 } 841 }
836 842
837 TEST_F(TouchSelectionControllerImplTest, MouseEventDeactivatesTouchSelection) { 843 TEST_F(TouchSelectionControllerImplTest, MouseEventDeactivatesTouchSelection) {
838 // TODO: see comment in SetUp(). 844 // TODO: see comment in SetUp().
839 if (IsMus()) 845 if (IsMus())
840 return; 846 return;
841 847
842 CreateTextfield(); 848 CreateTextfield();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 EXPECT_FALSE(GetSelectionController()); 894 EXPECT_FALSE(GetSelectionController());
889 895
890 ui::test::EventGenerator generator( 896 ui::test::EventGenerator generator(
891 textfield_widget_->GetNativeView()->GetRootWindow()); 897 textfield_widget_->GetNativeView()->GetRootWindow());
892 RunPendingMessages(); 898 RunPendingMessages();
893 899
894 // Start touch editing; then generate a mouse-capture-changed event and ensure 900 // Start touch editing; then generate a mouse-capture-changed event and ensure
895 // it does not deactivate touch selection. 901 // it does not deactivate touch selection.
896 StartTouchEditing(); 902 StartTouchEditing();
897 EXPECT_TRUE(GetSelectionController()); 903 EXPECT_TRUE(GetSelectionController());
898 ui::MouseEvent capture_changed(ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(5, 5), 904 ui::MouseEvent capture_changed(
899 gfx::Point(5, 5), base::TimeTicks(), 0, 0); 905 ui::ET_MOUSE_CAPTURE_CHANGED, gfx::Point(5, 5), gfx::Point(5, 5),
906 base::TimeTicks(), 0, 0,
907 ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_MOUSE));
900 generator.Dispatch(&capture_changed); 908 generator.Dispatch(&capture_changed);
901 RunPendingMessages(); 909 RunPendingMessages();
902 EXPECT_TRUE(GetSelectionController()); 910 EXPECT_TRUE(GetSelectionController());
903 } 911 }
904 912
905 TEST_F(TouchSelectionControllerImplTest, KeyEventDeactivatesTouchSelection) { 913 TEST_F(TouchSelectionControllerImplTest, KeyEventDeactivatesTouchSelection) {
906 // TODO: see comment in SetUp(). 914 // TODO: see comment in SetUp().
907 if (IsMus()) 915 if (IsMus())
908 return; 916 return;
909 917
910 CreateTextfield(); 918 CreateTextfield();
911 EXPECT_FALSE(GetSelectionController()); 919 EXPECT_FALSE(GetSelectionController());
912 920
913 ui::test::EventGenerator generator( 921 ui::test::EventGenerator generator(
914 textfield_widget_->GetNativeView()->GetRootWindow()); 922 textfield_widget_->GetNativeView()->GetRootWindow());
915 923
916 RunPendingMessages(); 924 RunPendingMessages();
917 925
918 // Start touch editing; then press a key and ensure it deactivates touch 926 // Start touch editing; then press a key and ensure it deactivates touch
919 // selection. 927 // selection.
920 StartTouchEditing(); 928 StartTouchEditing();
921 EXPECT_TRUE(GetSelectionController()); 929 EXPECT_TRUE(GetSelectionController());
922 generator.PressKey(ui::VKEY_A, 0); 930 generator.PressKey(ui::VKEY_A, 0);
923 RunPendingMessages(); 931 RunPendingMessages();
924 EXPECT_FALSE(GetSelectionController()); 932 EXPECT_FALSE(GetSelectionController());
925 } 933 }
926 934
927 } // namespace views 935 } // namespace views
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698