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

Side by Side Diff: ui/views/widget/widget_interactive_uitest.cc

Issue 700563002: Implementing directional text selection handles (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@new_assets_text
Patch Set: Removing the SelectionBound test from Android, since touch_editing_controller not included in Andro… Created 6 years, 1 month 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
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 #if defined(USE_AURA)
786 aura::client::SetScreenPositionClient(widget.GetNativeView()->GetRootWindow(),
787 &screen_position_client);
788 #endif // !defined(USE_AURA)
783 789
784 RunPendingMessages(); 790 RunPendingMessages();
785 791
786 ui::test::EventGenerator generator(widget.GetNativeWindow()); 792 ui::test::EventGenerator generator(widget.GetNativeWindow());
787 generator.GestureTapAt(gfx::Point(10, 10)); 793 generator.GestureTapAt(gfx::Point(10, 10));
788 ShowQuickMenuImmediately(static_cast<TouchSelectionControllerImpl*>( 794 ShowQuickMenuImmediately(static_cast<TouchSelectionControllerImpl*>(
789 textfield_test_api.touch_selection_controller())); 795 textfield_test_api.touch_selection_controller()));
790 796
791 EXPECT_TRUE(textfield->HasFocus()); 797 EXPECT_TRUE(textfield->HasFocus());
792 EXPECT_TRUE(widget.IsActive()); 798 EXPECT_TRUE(widget.IsActive());
793 EXPECT_TRUE(IsQuickMenuVisible(static_cast<TouchSelectionControllerImpl*>( 799 EXPECT_TRUE(IsQuickMenuVisible(static_cast<TouchSelectionControllerImpl*>(
794 textfield_test_api.touch_selection_controller()))); 800 textfield_test_api.touch_selection_controller())));
801 aura::client::SetScreenPositionClient(widget.GetNativeView()->GetRootWindow(),
802 nullptr);
795 } 803 }
796 804
797 TEST_F(WidgetTestInteractive, DisableViewDoesNotActivateWidget) { 805 TEST_F(WidgetTestInteractive, DisableViewDoesNotActivateWidget) {
798 #if defined(OS_WIN) 806 #if defined(OS_WIN)
799 views_delegate().set_use_desktop_native_widgets(true); 807 views_delegate().set_use_desktop_native_widgets(true);
800 #endif // !defined(OS_WIN) 808 #endif // !defined(OS_WIN)
801 809
802 // Create first widget and view, activate the widget, and focus the view. 810 // Create first widget and view, activate the widget, and focus the view.
803 Widget widget1; 811 Widget widget1;
804 Widget::InitParams params1 = CreateParams(Widget::InitParams::TYPE_POPUP); 812 Widget::InitParams params1 = CreateParams(Widget::InitParams::TYPE_POPUP);
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
1140 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> 1148 ui::EventDispatchDetails details = widget1.GetNativeWindow()->
1141 GetHost()->event_processor()->OnEventFromSource(&mouse_event); 1149 GetHost()->event_processor()->OnEventFromSource(&mouse_event);
1142 ASSERT_FALSE(details.dispatcher_destroyed); 1150 ASSERT_FALSE(details.dispatcher_destroyed);
1143 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); 1151 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent());
1144 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); 1152 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent());
1145 } 1153 }
1146 #endif // defined(OS_WIN) 1154 #endif // defined(OS_WIN)
1147 1155
1148 } // namespace test 1156 } // namespace test
1149 } // namespace views 1157 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/touchui/touch_selection_controller_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698