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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 980 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 textfield_test_api.touch_selection_controller())); | 991 textfield_test_api.touch_selection_controller())); |
992 | 992 |
993 EXPECT_TRUE(textfield->HasFocus()); | 993 EXPECT_TRUE(textfield->HasFocus()); |
994 EXPECT_TRUE(widget->IsActive()); | 994 EXPECT_TRUE(widget->IsActive()); |
995 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); | 995 EXPECT_TRUE(ui::TouchSelectionMenuRunner::GetInstance()->IsRunning()); |
996 widget->CloseNow(); | 996 widget->CloseNow(); |
997 } | 997 } |
998 #endif // defined(USE_AURA) | 998 #endif // defined(USE_AURA) |
999 | 999 |
1000 TEST_F(WidgetTestInteractive, DisableViewDoesNotActivateWidget) { | 1000 TEST_F(WidgetTestInteractive, DisableViewDoesNotActivateWidget) { |
1001 // TODO: see http://crbug.com/678070 for details. | |
1002 if (IsMus()) | |
1003 return; | |
1004 | |
1005 #if defined(OS_WIN) | 1001 #if defined(OS_WIN) |
1006 views_delegate()->set_use_desktop_native_widgets(true); | 1002 views_delegate()->set_use_desktop_native_widgets(true); |
1007 #endif // !defined(OS_WIN) | 1003 #endif // !defined(OS_WIN) |
1008 | 1004 |
1009 // Create first widget and view, activate the widget, and focus the view. | 1005 // Create first widget and view, activate the widget, and focus the view. |
1010 Widget widget1; | 1006 Widget widget1; |
1011 Widget::InitParams params1 = CreateParams(Widget::InitParams::TYPE_POPUP); | 1007 Widget::InitParams params1 = CreateParams(Widget::InitParams::TYPE_POPUP); |
1012 params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 1008 params1.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
1013 params1.activatable = Widget::InitParams::ACTIVATABLE_YES; | 1009 params1.activatable = Widget::InitParams::ACTIVATABLE_YES; |
1014 widget1.Init(params1); | 1010 widget1.Init(params1); |
1015 | 1011 |
1016 View* view1 = new View(); | 1012 View* view1 = new View(); |
1017 view1->SetFocusBehavior(View::FocusBehavior::ALWAYS); | 1013 view1->SetFocusBehavior(View::FocusBehavior::ALWAYS); |
1018 widget1.GetRootView()->AddChildView(view1); | 1014 widget1.GetRootView()->AddChildView(view1); |
1019 | 1015 |
| 1016 widget1.Show(); |
1020 ActivateSync(&widget1); | 1017 ActivateSync(&widget1); |
1021 | 1018 |
1022 FocusManager* focus_manager1 = widget1.GetFocusManager(); | 1019 FocusManager* focus_manager1 = widget1.GetFocusManager(); |
1023 ASSERT_TRUE(focus_manager1); | 1020 ASSERT_TRUE(focus_manager1); |
1024 focus_manager1->SetFocusedView(view1); | 1021 focus_manager1->SetFocusedView(view1); |
1025 EXPECT_EQ(view1, focus_manager1->GetFocusedView()); | 1022 EXPECT_EQ(view1, focus_manager1->GetFocusedView()); |
1026 | 1023 |
1027 // Create second widget and view, activate the widget, and focus the view. | 1024 // Create second widget and view, activate the widget, and focus the view. |
1028 Widget widget2; | 1025 Widget widget2; |
1029 Widget::InitParams params2 = CreateParams(Widget::InitParams::TYPE_POPUP); | 1026 Widget::InitParams params2 = CreateParams(Widget::InitParams::TYPE_POPUP); |
1030 params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 1027 params2.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
1031 params2.activatable = Widget::InitParams::ACTIVATABLE_YES; | 1028 params2.activatable = Widget::InitParams::ACTIVATABLE_YES; |
1032 widget2.Init(params2); | 1029 widget2.Init(params2); |
1033 | 1030 |
1034 View* view2 = new View(); | 1031 View* view2 = new View(); |
1035 view2->SetFocusBehavior(View::FocusBehavior::ALWAYS); | 1032 view2->SetFocusBehavior(View::FocusBehavior::ALWAYS); |
1036 widget2.GetRootView()->AddChildView(view2); | 1033 widget2.GetRootView()->AddChildView(view2); |
1037 | 1034 |
| 1035 widget2.Show(); |
1038 ActivateSync(&widget2); | 1036 ActivateSync(&widget2); |
1039 EXPECT_TRUE(widget2.IsActive()); | 1037 EXPECT_TRUE(widget2.IsActive()); |
1040 EXPECT_FALSE(widget1.IsActive()); | 1038 EXPECT_FALSE(widget1.IsActive()); |
1041 | 1039 |
1042 FocusManager* focus_manager2 = widget2.GetFocusManager(); | 1040 FocusManager* focus_manager2 = widget2.GetFocusManager(); |
1043 ASSERT_TRUE(focus_manager2); | 1041 ASSERT_TRUE(focus_manager2); |
1044 focus_manager2->SetFocusedView(view2); | 1042 focus_manager2->SetFocusedView(view2); |
1045 EXPECT_EQ(view2, focus_manager2->GetFocusedView()); | 1043 EXPECT_EQ(view2, focus_manager2->GetFocusedView()); |
1046 | 1044 |
1047 // Disable the first view and make sure it loses focus, but its widget is not | 1045 // Disable the first view and make sure it loses focus, but its widget is not |
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1808 | 1806 |
1809 ui::KeyEvent key_event2(key_event); | 1807 ui::KeyEvent key_event2(key_event); |
1810 widget->OnKeyEvent(&key_event2); | 1808 widget->OnKeyEvent(&key_event2); |
1811 EXPECT_FALSE(key_event2.stopped_propagation()); | 1809 EXPECT_FALSE(key_event2.stopped_propagation()); |
1812 | 1810 |
1813 widget->CloseNow(); | 1811 widget->CloseNow(); |
1814 } | 1812 } |
1815 | 1813 |
1816 } // namespace test | 1814 } // namespace test |
1817 } // namespace views | 1815 } // namespace views |
OLD | NEW |