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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 generator.GestureTapAt(gfx::Point(10, 10)); | 775 generator.GestureTapAt(gfx::Point(10, 10)); |
776 ShowQuickMenuImmediately(static_cast<TouchSelectionControllerImpl*>( | 776 ShowQuickMenuImmediately(static_cast<TouchSelectionControllerImpl*>( |
777 textfield_test_api.touch_selection_controller())); | 777 textfield_test_api.touch_selection_controller())); |
778 | 778 |
779 EXPECT_TRUE(textfield->HasFocus()); | 779 EXPECT_TRUE(textfield->HasFocus()); |
780 EXPECT_TRUE(widget.IsActive()); | 780 EXPECT_TRUE(widget.IsActive()); |
781 EXPECT_TRUE(IsQuickMenuVisible(static_cast<TouchSelectionControllerImpl*>( | 781 EXPECT_TRUE(IsQuickMenuVisible(static_cast<TouchSelectionControllerImpl*>( |
782 textfield_test_api.touch_selection_controller()))); | 782 textfield_test_api.touch_selection_controller()))); |
783 } | 783 } |
784 | 784 |
| 785 TEST_F(WidgetTestInteractive, DisableViewDoesNotActivateWidget) { |
| 786 #if defined(OS_WIN) |
| 787 views_delegate().set_use_desktop_native_widgets(true); |
| 788 #endif // !defined(OS_WIN) |
| 789 |
| 790 // Create first widget and view, activate the widget, and focus the view. |
| 791 Widget widget1; |
| 792 Widget::InitParams params1 = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 793 params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 794 params1.activatable = Widget::InitParams::ACTIVATABLE_YES; |
| 795 widget1.Init(params1); |
| 796 |
| 797 View* view1 = new View(); |
| 798 view1->SetFocusable(true); |
| 799 widget1.GetRootView()->AddChildView(view1); |
| 800 |
| 801 widget1.Activate(); |
| 802 EXPECT_TRUE(widget1.IsActive()); |
| 803 |
| 804 FocusManager* focus_manager1 = widget1.GetFocusManager(); |
| 805 ASSERT_TRUE(focus_manager1); |
| 806 focus_manager1->SetFocusedView(view1); |
| 807 EXPECT_EQ(view1, focus_manager1->GetFocusedView()); |
| 808 |
| 809 // Create second widget and view, activate the widget, and focus the view. |
| 810 Widget widget2; |
| 811 Widget::InitParams params2 = CreateParams(Widget::InitParams::TYPE_POPUP); |
| 812 params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 813 params2.activatable = Widget::InitParams::ACTIVATABLE_YES; |
| 814 widget2.Init(params2); |
| 815 |
| 816 View* view2 = new View(); |
| 817 view2->SetFocusable(true); |
| 818 widget2.GetRootView()->AddChildView(view2); |
| 819 |
| 820 widget2.Activate(); |
| 821 EXPECT_TRUE(widget2.IsActive()); |
| 822 EXPECT_FALSE(widget1.IsActive()); |
| 823 |
| 824 FocusManager* focus_manager2 = widget2.GetFocusManager(); |
| 825 ASSERT_TRUE(focus_manager2); |
| 826 focus_manager2->SetFocusedView(view2); |
| 827 EXPECT_EQ(view2, focus_manager2->GetFocusedView()); |
| 828 |
| 829 // Disable the first view and make sure it loses focus, but its widget is not |
| 830 // activated. |
| 831 view1->SetEnabled(false); |
| 832 EXPECT_NE(view1, focus_manager1->GetFocusedView()); |
| 833 EXPECT_FALSE(widget1.IsActive()); |
| 834 EXPECT_TRUE(widget2.IsActive()); |
| 835 } |
| 836 |
785 namespace { | 837 namespace { |
786 | 838 |
787 // Used to veirfy OnMouseCaptureLost() has been invoked. | 839 // Used to veirfy OnMouseCaptureLost() has been invoked. |
788 class CaptureLostTrackingWidget : public Widget { | 840 class CaptureLostTrackingWidget : public Widget { |
789 public: | 841 public: |
790 CaptureLostTrackingWidget() : got_capture_lost_(false) {} | 842 CaptureLostTrackingWidget() : got_capture_lost_(false) {} |
791 virtual ~CaptureLostTrackingWidget() {} | 843 virtual ~CaptureLostTrackingWidget() {} |
792 | 844 |
793 bool GetAndClearGotCaptureLost() { | 845 bool GetAndClearGotCaptureLost() { |
794 bool value = got_capture_lost_; | 846 bool value = got_capture_lost_; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> | 1132 ui::EventDispatchDetails details = widget1.GetNativeWindow()-> |
1081 GetHost()->event_processor()->OnEventFromSource(&mouse_event); | 1133 GetHost()->event_processor()->OnEventFromSource(&mouse_event); |
1082 ASSERT_FALSE(details.dispatcher_destroyed); | 1134 ASSERT_FALSE(details.dispatcher_destroyed); |
1083 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); | 1135 EXPECT_TRUE(widget1.GetAndClearGotMouseEvent()); |
1084 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); | 1136 EXPECT_FALSE(widget2.GetAndClearGotMouseEvent()); |
1085 } | 1137 } |
1086 #endif | 1138 #endif |
1087 | 1139 |
1088 } // namespace test | 1140 } // namespace test |
1089 } // namespace views | 1141 } // namespace views |
OLD | NEW |