Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 875 | 875 |
| 876 private: | 876 private: |
| 877 DISALLOW_COPY_AND_ASSIGN(WidgetCaptureTest); | 877 DISALLOW_COPY_AND_ASSIGN(WidgetCaptureTest); |
| 878 }; | 878 }; |
| 879 | 879 |
| 880 // See description in TestCapture(). | 880 // See description in TestCapture(). |
| 881 TEST_F(WidgetCaptureTest, Capture) { | 881 TEST_F(WidgetCaptureTest, Capture) { |
| 882 TestCapture(false); | 882 TestCapture(false); |
| 883 } | 883 } |
| 884 | 884 |
| 885 #if !defined(OS_LINUX) | 885 #if !defined(OS_CHROMEOS) |
| 886 // See description in TestCapture(). Creates DesktopNativeWidget. | 886 // See description in TestCapture(). Creates DesktopNativeWidget. |
| 887 TEST_F(WidgetCaptureTest, CaptureDesktopNativeWidget) { | 887 TEST_F(WidgetCaptureTest, CaptureDesktopNativeWidget) { |
| 888 TestCapture(true); | 888 TestCapture(true); |
| 889 } | 889 } |
| 890 #endif | 890 #endif |
| 891 | 891 |
| 892 #if !defined(OS_CHROMEOS) | 892 #if !defined(OS_CHROMEOS) |
| 893 // Test that a synthetic mouse exit is sent to the widget which was handling | 893 // Test that a synthetic mouse exit is sent to the widget which was handling |
| 894 // mouse events when a different widget grabs capture. | 894 // mouse events when a different widget grabs capture. |
| 895 // TODO(pkotwicz): Make test pass on CrOS. | 895 // TODO(pkotwicz): Make test pass on CrOS. |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 923 EXPECT_EQ(0, mouse_view1->ExitedCalls()); | 923 EXPECT_EQ(0, mouse_view1->ExitedCalls()); |
| 924 | 924 |
| 925 widget2.SetCapture(NULL); | 925 widget2.SetCapture(NULL); |
| 926 EXPECT_EQ(0, mouse_view1->EnteredCalls()); | 926 EXPECT_EQ(0, mouse_view1->EnteredCalls()); |
| 927 // Grabbing native capture on Windows generates a ui::ET_MOUSE_EXITED event | 927 // Grabbing native capture on Windows generates a ui::ET_MOUSE_EXITED event |
| 928 // in addition to the one generated by Chrome. | 928 // in addition to the one generated by Chrome. |
| 929 EXPECT_LT(0, mouse_view1->ExitedCalls()); | 929 EXPECT_LT(0, mouse_view1->ExitedCalls()); |
| 930 } | 930 } |
| 931 #endif | 931 #endif |
| 932 | 932 |
| 933 #if !defined(OS_CHROMEOS) | 933 #if defined(OS_WIN) |
| 934 namespace { | 934 namespace { |
| 935 | 935 |
| 936 // Used to veirfy OnMouseEvent() has been invoked. | 936 // Used to verify OnMouseEvent() has been invoked. |
| 937 class MouseEventTrackingWidget : public Widget { | 937 class MouseEventTrackingWidget : public Widget { |
| 938 public: | 938 public: |
| 939 MouseEventTrackingWidget() : got_mouse_event_(false) {} | 939 MouseEventTrackingWidget() : got_mouse_event_(false) {} |
| 940 virtual ~MouseEventTrackingWidget() {} | 940 virtual ~MouseEventTrackingWidget() {} |
| 941 | 941 |
| 942 bool GetAndClearGotMouseEvent() { | 942 bool GetAndClearGotMouseEvent() { |
| 943 bool value = got_mouse_event_; | 943 bool value = got_mouse_event_; |
| 944 got_mouse_event_ = false; | 944 got_mouse_event_ = false; |
| 945 return value; | 945 return value; |
| 946 } | 946 } |
| 947 | 947 |
| 948 // Widget: | 948 // Widget: |
| 949 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | 949 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { |
| 950 got_mouse_event_ = true; | 950 got_mouse_event_ = true; |
| 951 Widget::OnMouseEvent(event); | 951 Widget::OnMouseEvent(event); |
| 952 } | 952 } |
| 953 | 953 |
| 954 private: | 954 private: |
| 955 bool got_mouse_event_; | 955 bool got_mouse_event_; |
| 956 | 956 |
| 957 DISALLOW_COPY_AND_ASSIGN(MouseEventTrackingWidget); | 957 DISALLOW_COPY_AND_ASSIGN(MouseEventTrackingWidget); |
| 958 }; | 958 }; |
| 959 | 959 |
| 960 } // namespace | 960 } // namespace |
| 961 | 961 |
| 962 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | |
| 963 // TODO(erg): linux_aura bringup: http://crbug.com/163931 | |
| 964 #define MAYBE_MouseEventDispatchedToRightWindow \ | |
| 965 DISABLED_MouseEventDispatchedToRightWindow | |
| 966 #else | |
| 967 #define MAYBE_MouseEventDispatchedToRightWindow \ | |
| 968 MouseEventDispatchedToRightWindow | |
| 969 #endif | |
| 970 | |
| 971 // Verifies if a mouse event is received on a widget that doesn't have capture | 962 // Verifies if a mouse event is received on a widget that doesn't have capture |
| 972 // it is correctly processed by the widget that doesn't have capture. | 963 // on Windows that it is correctly processed by the widget that doesn't have |
| 973 TEST_F(WidgetCaptureTest, MAYBE_MouseEventDispatchedToRightWindow) { | 964 // capture. This behavior is not desired on OSes other than Windows. |
|
pkotwicz
2014/07/10 19:22:28
We do not want this behavior on Desktop Linux. Not
| |
| 965 TEST_F(WidgetCaptureTest, MouseEventDispatchedToRightWindow) { | |
| 974 MouseEventTrackingWidget widget1; | 966 MouseEventTrackingWidget widget1; |
| 975 Widget::InitParams params1 = | 967 Widget::InitParams params1 = |
| 976 CreateParams(views::Widget::InitParams::TYPE_WINDOW); | 968 CreateParams(views::Widget::InitParams::TYPE_WINDOW); |
| 977 params1.native_widget = new DesktopNativeWidgetAura(&widget1); | 969 params1.native_widget = new DesktopNativeWidgetAura(&widget1); |
| 978 params1.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 970 params1.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 979 widget1.Init(params1); | 971 widget1.Init(params1); |
| 980 widget1.Show(); | 972 widget1.Show(); |
| 981 | 973 |
| 982 MouseEventTrackingWidget widget2; | 974 MouseEventTrackingWidget widget2; |
| 983 Widget::InitParams params2 = | 975 Widget::InitParams params2 = |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1001 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> | 993 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> |
| 1002 GetHost()->event_processor()->OnEventFromSource(&mouse_event); | 994 GetHost()->event_processor()->OnEventFromSource(&mouse_event); |
| 1003 ASSERT_FALSE(details.dispatcher_destroyed); | 995 ASSERT_FALSE(details.dispatcher_destroyed); |
| 1004 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); | 996 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); |
| 1005 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); | 997 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); |
| 1006 } | 998 } |
| 1007 #endif | 999 #endif |
| 1008 | 1000 |
| 1009 } // namespace test | 1001 } // namespace test |
| 1010 } // namespace views | 1002 } // namespace views |
| OLD | NEW |