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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
13 #include "ui/base/ui_base_paths.h" | 13 #include "ui/base/ui_base_paths.h" |
14 #include "ui/base/ui_base_switches.h" | 14 #include "ui/base/ui_base_switches.h" |
15 #include "ui/events/event_processor.h" | 15 #include "ui/events/event_processor.h" |
16 #include "ui/events/test/event_generator.h" | 16 #include "ui/events/test/event_generator.h" |
17 #include "ui/gfx/native_widget_types.h" | 17 #include "ui/gfx/native_widget_types.h" |
18 #include "ui/gl/gl_surface.h" | 18 #include "ui/gl/gl_surface.h" |
19 #include "ui/views/controls/textfield/textfield.h" | 19 #include "ui/views/controls/textfield/textfield.h" |
20 #include "ui/views/controls/textfield/textfield_test_api.h" | 20 #include "ui/views/controls/textfield/textfield_test_api.h" |
21 #include "ui/views/focus/focus_manager.h" | 21 #include "ui/views/focus/focus_manager.h" |
22 #include "ui/views/test/focus_manager_test.h" | 22 #include "ui/views/test/focus_manager_test.h" |
23 #include "ui/views/test/widget_test.h" | 23 #include "ui/views/test/widget_test.h" |
24 #include "ui/views/touchui/touch_selection_controller_impl.h" | 24 #include "ui/views/touchui/touch_selection_controller_impl.h" |
25 #include "ui/views/widget/widget.h" | 25 #include "ui/views/widget/widget.h" |
26 #include "ui/views/window/dialog_delegate.h" | 26 #include "ui/views/window/dialog_delegate.h" |
| 27 #include "ui/wm/core/default_screen_position_client.h" |
27 #include "ui/wm/public/activation_client.h" | 28 #include "ui/wm/public/activation_client.h" |
28 | 29 |
29 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
30 #include "ui/aura/window.h" | 31 #include "ui/aura/window.h" |
31 #include "ui/aura/window_tree_host.h" | 32 #include "ui/aura/window_tree_host.h" |
32 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" | 33 #include "ui/views/widget/desktop_aura/desktop_native_widget_aura.h" |
33 #include "ui/views/win/hwnd_util.h" | 34 #include "ui/views/win/hwnd_util.h" |
34 #endif | 35 #endif |
35 | 36 |
36 namespace views { | 37 namespace views { |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 EXPECT_FALSE(widget.IsActive()); | 758 EXPECT_FALSE(widget.IsActive()); |
758 } | 759 } |
759 | 760 |
760 // Test that touch selection quick menu is not activated when opened. | 761 // Test that touch selection quick menu is not activated when opened. |
761 TEST_F(WidgetTestInteractive, TouchSelectionQuickMenuIsNotActivated) { | 762 TEST_F(WidgetTestInteractive, TouchSelectionQuickMenuIsNotActivated) { |
762 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing); | 763 CommandLine::ForCurrentProcess()->AppendSwitch(switches::kEnableTouchEditing); |
763 #if defined(OS_WIN) | 764 #if defined(OS_WIN) |
764 views_delegate().set_use_desktop_native_widgets(true); | 765 views_delegate().set_use_desktop_native_widgets(true); |
765 #endif // !defined(OS_WIN) | 766 #endif // !defined(OS_WIN) |
766 | 767 |
| 768 wm::DefaultScreenPositionClient screen_position_client; |
767 Widget widget; | 769 Widget widget; |
768 Widget::InitParams init_params = | 770 Widget::InitParams init_params = |
769 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); | 771 CreateParams(Widget::InitParams::TYPE_WINDOW_FRAMELESS); |
770 init_params.bounds = gfx::Rect(0, 0, 200, 200); | 772 init_params.bounds = gfx::Rect(0, 0, 200, 200); |
771 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 773 init_params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
772 widget.Init(init_params); | 774 widget.Init(init_params); |
773 | 775 |
774 Textfield* textfield = new Textfield; | 776 Textfield* textfield = new Textfield; |
775 textfield->SetBounds(0, 0, 200, 20); | 777 textfield->SetBounds(0, 0, 200, 20); |
776 textfield->SetText(base::ASCIIToUTF16("some text")); | 778 textfield->SetText(base::ASCIIToUTF16("some text")); |
777 widget.GetRootView()->AddChildView(textfield); | 779 widget.GetRootView()->AddChildView(textfield); |
778 | 780 |
779 widget.Show(); | 781 widget.Show(); |
780 textfield->RequestFocus(); | 782 textfield->RequestFocus(); |
781 textfield->SelectAll(true); | 783 textfield->SelectAll(true); |
782 TextfieldTestApi textfield_test_api(textfield); | 784 TextfieldTestApi textfield_test_api(textfield); |
| 785 aura::client::SetScreenPositionClient(widget.GetNativeView()->GetRootWindow(), |
| 786 &screen_position_client); |
783 | 787 |
784 RunPendingMessages(); | 788 RunPendingMessages(); |
785 | 789 |
786 ui::test::EventGenerator generator(widget.GetNativeWindow()); | 790 ui::test::EventGenerator generator(widget.GetNativeWindow()); |
787 generator.GestureTapAt(gfx::Point(10, 10)); | 791 generator.GestureTapAt(gfx::Point(10, 10)); |
788 ShowQuickMenuImmediately(static_cast<TouchSelectionControllerImpl*>( | 792 ShowQuickMenuImmediately(static_cast<TouchSelectionControllerImpl*>( |
789 textfield_test_api.touch_selection_controller())); | 793 textfield_test_api.touch_selection_controller())); |
790 | 794 |
791 EXPECT_TRUE(textfield->HasFocus()); | 795 EXPECT_TRUE(textfield->HasFocus()); |
792 EXPECT_TRUE(widget.IsActive()); | 796 EXPECT_TRUE(widget.IsActive()); |
793 EXPECT_TRUE(IsQuickMenuVisible(static_cast<TouchSelectionControllerImpl*>( | 797 EXPECT_TRUE(IsQuickMenuVisible(static_cast<TouchSelectionControllerImpl*>( |
794 textfield_test_api.touch_selection_controller()))); | 798 textfield_test_api.touch_selection_controller()))); |
| 799 aura::client::SetScreenPositionClient(widget.GetNativeView()->GetRootWindow(), |
| 800 nullptr); |
795 } | 801 } |
796 | 802 |
797 TEST_F(WidgetTestInteractive, DisableViewDoesNotActivateWidget) { | 803 TEST_F(WidgetTestInteractive, DisableViewDoesNotActivateWidget) { |
798 #if defined(OS_WIN) | 804 #if defined(OS_WIN) |
799 views_delegate().set_use_desktop_native_widgets(true); | 805 views_delegate().set_use_desktop_native_widgets(true); |
800 #endif // !defined(OS_WIN) | 806 #endif // !defined(OS_WIN) |
801 | 807 |
802 // Create first widget and view, activate the widget, and focus the view. | 808 // Create first widget and view, activate the widget, and focus the view. |
803 Widget widget1; | 809 Widget widget1; |
804 Widget::InitParams params1 = CreateParams(Widget::InitParams::TYPE_POPUP); | 810 Widget::InitParams params1 = CreateParams(Widget::InitParams::TYPE_POPUP); |
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1140 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> | 1146 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> |
1141 GetHost()->event_processor()->OnEventFromSource(&mouse_event); | 1147 GetHost()->event_processor()->OnEventFromSource(&mouse_event); |
1142 ASSERT_FALSE(details.dispatcher_destroyed); | 1148 ASSERT_FALSE(details.dispatcher_destroyed); |
1143 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); | 1149 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); |
1144 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); | 1150 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); |
1145 } | 1151 } |
1146 #endif // defined(OS_WIN) | 1152 #endif // defined(OS_WIN) |
1147 | 1153 |
1148 } // namespace test | 1154 } // namespace test |
1149 } // namespace views | 1155 } // namespace views |
OLD | NEW |