| 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 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 859 Widget* widget_; | 859 Widget* widget_; |
| 860 bool should_advance_focus_to_parent_; | 860 bool should_advance_focus_to_parent_; |
| 861 | 861 |
| 862 DISALLOW_COPY_AND_ASSIGN(AdvanceFocusWidgetDelegate); | 862 DISALLOW_COPY_AND_ASSIGN(AdvanceFocusWidgetDelegate); |
| 863 }; | 863 }; |
| 864 | 864 |
| 865 } // namespace | 865 } // namespace |
| 866 | 866 |
| 867 // Verifies focus wrapping happens in the same widget. | 867 // Verifies focus wrapping happens in the same widget. |
| 868 TEST_F(FocusManagerTest, AdvanceFocusStaysInWidget) { | 868 TEST_F(FocusManagerTest, AdvanceFocusStaysInWidget) { |
| 869 // Mus doesn't support child Widgets well yet. https://crbug.com/612820 |
| 870 if (IsMus()) |
| 871 return; |
| 869 // Add |widget_view| as a child of the Widget. | 872 // Add |widget_view| as a child of the Widget. |
| 870 View* widget_view = new View; | 873 View* widget_view = new View; |
| 871 widget_view->SetFocusBehavior(View::FocusBehavior::ALWAYS); | 874 widget_view->SetFocusBehavior(View::FocusBehavior::ALWAYS); |
| 872 widget_view->SetBounds(20, 0, 20, 20); | 875 widget_view->SetBounds(20, 0, 20, 20); |
| 873 GetContentsView()->AddChildView(widget_view); | 876 GetContentsView()->AddChildView(widget_view); |
| 874 | 877 |
| 875 // Create a widget with two views, focus the second. | 878 // Create a widget with two views, focus the second. |
| 876 std::unique_ptr<AdvanceFocusWidgetDelegate> delegate; | 879 std::unique_ptr<AdvanceFocusWidgetDelegate> delegate; |
| 877 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); | 880 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 878 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 881 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 908 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView()); | 911 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView()); |
| 909 | 912 |
| 910 // Allow focus to go to the parent, and focus backwards which should now move | 913 // Allow focus to go to the parent, and focus backwards which should now move |
| 911 // up |widget_view| (in the parent). | 914 // up |widget_view| (in the parent). |
| 912 delegate->set_should_advance_focus_to_parent(true); | 915 delegate->set_should_advance_focus_to_parent(true); |
| 913 GetFocusManager()->AdvanceFocus(true); | 916 GetFocusManager()->AdvanceFocus(true); |
| 914 EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView()); | 917 EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView()); |
| 915 } | 918 } |
| 916 | 919 |
| 917 } // namespace views | 920 } // namespace views |
| OLD | NEW |