OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/views/focus/focus_manager.h" | 5 #include "ui/views/focus/focus_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
116 ASSERT_EQ(1, static_cast<int>(listener.focus_changes().size())); | 116 ASSERT_EQ(1, static_cast<int>(listener.focus_changes().size())); |
117 EXPECT_TRUE(listener.focus_changes()[0] == ViewPair(view1, view2)); | 117 EXPECT_TRUE(listener.focus_changes()[0] == ViewPair(view1, view2)); |
118 listener.ClearFocusChanges(); | 118 listener.ClearFocusChanges(); |
119 | 119 |
120 GetFocusManager()->ClearFocus(); | 120 GetFocusManager()->ClearFocus(); |
121 ASSERT_EQ(1, static_cast<int>(listener.focus_changes().size())); | 121 ASSERT_EQ(1, static_cast<int>(listener.focus_changes().size())); |
122 EXPECT_TRUE(listener.focus_changes()[0] == ViewPair(view2, null_view)); | 122 EXPECT_TRUE(listener.focus_changes()[0] == ViewPair(view2, null_view)); |
123 } | 123 } |
124 | 124 |
125 TEST_F(FocusManagerTest, WidgetFocusChangeListener) { | 125 TEST_F(FocusManagerTest, WidgetFocusChangeListener) { |
126 // SimulateNativeActive() doesn't work correctly in mus. | |
sky
2016/06/08 04:25:02
I recommend NOTIMPLEMENTEDs and filing bugs for al
sadrul
2016/06/08 14:57:42
Ended up fixing this particular test in https://co
| |
127 if (IsMus()) | |
128 return; | |
126 // First, ensure the simulator is aware of the Widget created in SetUp() being | 129 // First, ensure the simulator is aware of the Widget created in SetUp() being |
127 // currently active. | 130 // currently active. |
128 test::WidgetTest::SimulateNativeActivate(GetWidget()); | 131 test::WidgetTest::SimulateNativeActivate(GetWidget()); |
129 | 132 |
130 TestWidgetFocusChangeListener widget_listener; | 133 TestWidgetFocusChangeListener widget_listener; |
131 AddWidgetFocusChangeListener(&widget_listener); | 134 AddWidgetFocusChangeListener(&widget_listener); |
132 | 135 |
133 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); | 136 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); |
134 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 137 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
135 params.bounds = gfx::Rect(10, 10, 100, 100); | 138 params.bounds = gfx::Rect(10, 10, 100, 100); |
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
859 Widget* widget_; | 862 Widget* widget_; |
860 bool should_advance_focus_to_parent_; | 863 bool should_advance_focus_to_parent_; |
861 | 864 |
862 DISALLOW_COPY_AND_ASSIGN(AdvanceFocusWidgetDelegate); | 865 DISALLOW_COPY_AND_ASSIGN(AdvanceFocusWidgetDelegate); |
863 }; | 866 }; |
864 | 867 |
865 } // namespace | 868 } // namespace |
866 | 869 |
867 // Verifies focus wrapping happens in the same widget. | 870 // Verifies focus wrapping happens in the same widget. |
868 TEST_F(FocusManagerTest, AdvanceFocusStaysInWidget) { | 871 TEST_F(FocusManagerTest, AdvanceFocusStaysInWidget) { |
872 // Mus doesn't support child Widgets well yet. https://crbug.com/612820 | |
873 if (IsMus()) | |
874 return; | |
869 // Add |widget_view| as a child of the Widget. | 875 // Add |widget_view| as a child of the Widget. |
870 View* widget_view = new View; | 876 View* widget_view = new View; |
871 widget_view->SetFocusBehavior(View::FocusBehavior::ALWAYS); | 877 widget_view->SetFocusBehavior(View::FocusBehavior::ALWAYS); |
872 widget_view->SetBounds(20, 0, 20, 20); | 878 widget_view->SetBounds(20, 0, 20, 20); |
873 GetContentsView()->AddChildView(widget_view); | 879 GetContentsView()->AddChildView(widget_view); |
874 | 880 |
875 // Create a widget with two views, focus the second. | 881 // Create a widget with two views, focus the second. |
876 std::unique_ptr<AdvanceFocusWidgetDelegate> delegate; | 882 std::unique_ptr<AdvanceFocusWidgetDelegate> delegate; |
877 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); | 883 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); |
878 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 884 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
(...skipping 29 matching lines...) Expand all Loading... | |
908 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView()); | 914 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView()); |
909 | 915 |
910 // Allow focus to go to the parent, and focus backwards which should now move | 916 // Allow focus to go to the parent, and focus backwards which should now move |
911 // up |widget_view| (in the parent). | 917 // up |widget_view| (in the parent). |
912 delegate->set_should_advance_focus_to_parent(true); | 918 delegate->set_should_advance_focus_to_parent(true); |
913 GetFocusManager()->AdvanceFocus(true); | 919 GetFocusManager()->AdvanceFocus(true); |
914 EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView()); | 920 EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView()); |
915 } | 921 } |
916 | 922 |
917 } // namespace views | 923 } // namespace views |
OLD | NEW |