| 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 ASSERT_EQ(1, static_cast<int>(listener.focus_changes().size())); | 115 ASSERT_EQ(1, static_cast<int>(listener.focus_changes().size())); |
| 116 EXPECT_TRUE(listener.focus_changes()[0] == ViewPair(view1, view2)); | 116 EXPECT_TRUE(listener.focus_changes()[0] == ViewPair(view1, view2)); |
| 117 listener.ClearFocusChanges(); | 117 listener.ClearFocusChanges(); |
| 118 | 118 |
| 119 GetFocusManager()->ClearFocus(); | 119 GetFocusManager()->ClearFocus(); |
| 120 ASSERT_EQ(1, static_cast<int>(listener.focus_changes().size())); | 120 ASSERT_EQ(1, static_cast<int>(listener.focus_changes().size())); |
| 121 EXPECT_TRUE(listener.focus_changes()[0] == ViewPair(view2, null_view)); | 121 EXPECT_TRUE(listener.focus_changes()[0] == ViewPair(view2, null_view)); |
| 122 } | 122 } |
| 123 | 123 |
| 124 TEST_F(FocusManagerTest, WidgetFocusChangeListener) { | 124 TEST_F(FocusManagerTest, WidgetFocusChangeListener) { |
| 125 // TODO: this test ends up calling focus on the aura::Window associated with |
| 126 // the Widget and expecting that to change activation. This should work for |
| 127 // aura-mus-client as well. http://crbug.com/664261. |
| 128 if (IsAuraMusClient()) |
| 129 return; |
| 130 |
| 125 // First, ensure the simulator is aware of the Widget created in SetUp() being | 131 // First, ensure the simulator is aware of the Widget created in SetUp() being |
| 126 // currently active. | 132 // currently active. |
| 127 test::WidgetTest::SimulateNativeActivate(GetWidget()); | 133 test::WidgetTest::SimulateNativeActivate(GetWidget()); |
| 128 | 134 |
| 129 TestWidgetFocusChangeListener widget_listener; | 135 TestWidgetFocusChangeListener widget_listener; |
| 130 AddWidgetFocusChangeListener(&widget_listener); | 136 AddWidgetFocusChangeListener(&widget_listener); |
| 131 | 137 |
| 132 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); | 138 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); |
| 133 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 139 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 134 params.bounds = gfx::Rect(10, 10, 100, 100); | 140 params.bounds = gfx::Rect(10, 10, 100, 100); |
| (...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 895 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView()); | 901 EXPECT_EQ(view1, GetFocusManager()->GetFocusedView()); |
| 896 | 902 |
| 897 // Allow focus to go to the parent, and focus backwards which should now move | 903 // Allow focus to go to the parent, and focus backwards which should now move |
| 898 // up |widget_view| (in the parent). | 904 // up |widget_view| (in the parent). |
| 899 delegate->set_should_advance_focus_to_parent(true); | 905 delegate->set_should_advance_focus_to_parent(true); |
| 900 GetFocusManager()->AdvanceFocus(true); | 906 GetFocusManager()->AdvanceFocus(true); |
| 901 EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView()); | 907 EXPECT_EQ(widget_view, GetFocusManager()->GetFocusedView()); |
| 902 } | 908 } |
| 903 | 909 |
| 904 } // namespace views | 910 } // namespace views |
| OLD | NEW |