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/wm/core/focus_controller.h" | 5 #include "ui/wm/core/focus_controller.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "ui/aura/client/aura_constants.h" | 9 #include "ui/aura/client/aura_constants.h" |
10 #include "ui/aura/client/default_capture_client.h" | 10 #include "ui/aura/client/default_capture_client.h" |
(...skipping 953 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 | 964 |
965 aura::Window* GetDispositionWindow(aura::Window* window) { | 965 aura::Window* GetDispositionWindow(aura::Window* window) { |
966 return parent_ ? window->parent() : window; | 966 return parent_ ? window->parent() : window; |
967 } | 967 } |
968 | 968 |
969 // Change the disposition of |window| in such a way as it will lose focus. | 969 // Change the disposition of |window| in such a way as it will lose focus. |
970 virtual void ChangeWindowDisposition(aura::Window* window) = 0; | 970 virtual void ChangeWindowDisposition(aura::Window* window) = 0; |
971 | 971 |
972 // Allow each disposition change test to add additional post-disposition | 972 // Allow each disposition change test to add additional post-disposition |
973 // change expectations. | 973 // change expectations. |
974 virtual void PostDispostionChangeExpectations() {} | 974 virtual void PostDispositionChangeExpectations() {} |
975 | 975 |
976 // Overridden from FocusControllerTestBase: | 976 // Overridden from FocusControllerTestBase: |
977 void BasicFocus() override { | 977 void BasicFocus() override { |
978 EXPECT_EQ(NULL, GetFocusedWindow()); | 978 EXPECT_EQ(NULL, GetFocusedWindow()); |
979 | 979 |
980 aura::Window* w211 = root_window()->GetChildById(211); | 980 aura::Window* w211 = root_window()->GetChildById(211); |
981 FocusWindow(w211); | 981 FocusWindow(w211); |
982 EXPECT_EQ(211, GetFocusedWindowId()); | 982 EXPECT_EQ(211, GetFocusedWindowId()); |
983 | 983 |
984 ChangeWindowDisposition(w211); | 984 ChangeWindowDisposition(w211); |
985 // BasicFocusRules passes focus to the parent. | 985 // BasicFocusRules passes focus to the parent. |
986 EXPECT_EQ(parent_ ? 2 : 21, GetFocusedWindowId()); | 986 EXPECT_EQ(parent_ ? 2 : 21, GetFocusedWindowId()); |
987 } | 987 } |
988 void BasicActivation() override { | 988 void BasicActivation() override { |
989 DCHECK(!parent_) << "Activation tests don't support parent changes."; | 989 DCHECK(!parent_) << "Activation tests don't support parent changes."; |
990 | 990 |
991 EXPECT_EQ(NULL, GetActiveWindow()); | 991 EXPECT_EQ(NULL, GetActiveWindow()); |
992 | 992 |
993 aura::Window* w2 = root_window()->GetChildById(2); | 993 aura::Window* w2 = root_window()->GetChildById(2); |
994 ActivateWindow(w2); | 994 ActivateWindow(w2); |
995 EXPECT_EQ(2, GetActiveWindowId()); | 995 EXPECT_EQ(2, GetActiveWindowId()); |
996 | 996 |
997 ChangeWindowDisposition(w2); | 997 ChangeWindowDisposition(w2); |
998 EXPECT_EQ(3, GetActiveWindowId()); | 998 EXPECT_EQ(3, GetActiveWindowId()); |
999 PostDispostionChangeExpectations(); | 999 PostDispositionChangeExpectations(); |
1000 } | 1000 } |
1001 void FocusEvents() override { | 1001 void FocusEvents() override { |
1002 aura::Window* w211 = root_window()->GetChildById(211); | 1002 aura::Window* w211 = root_window()->GetChildById(211); |
1003 FocusWindow(w211); | 1003 FocusWindow(w211); |
1004 | 1004 |
1005 ScopedFocusNotificationObserver root_observer(root_window()); | 1005 ScopedFocusNotificationObserver root_observer(root_window()); |
1006 ScopedTargetFocusNotificationObserver observer211(root_window(), 211); | 1006 ScopedTargetFocusNotificationObserver observer211(root_window(), 211); |
1007 root_observer.ExpectCounts(0, 0); | 1007 root_observer.ExpectCounts(0, 0); |
1008 observer211.ExpectCounts(0, 0); | 1008 observer211.ExpectCounts(0, 0); |
1009 | 1009 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, DontPassDeletedWindow); | 1266 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, DontPassDeletedWindow); |
1267 | 1267 |
1268 // - Verifies that the focused text input client is cleard when the window focus | 1268 // - Verifies that the focused text input client is cleard when the window focus |
1269 // changes. | 1269 // changes. |
1270 ALL_FOCUS_TESTS(FocusedTextInputClient); | 1270 ALL_FOCUS_TESTS(FocusedTextInputClient); |
1271 | 1271 |
1272 // If a mouse event was handled, it should not activate a window. | 1272 // If a mouse event was handled, it should not activate a window. |
1273 FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, IgnoreHandledEvent); | 1273 FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, IgnoreHandledEvent); |
1274 | 1274 |
1275 } // namespace wm | 1275 } // namespace wm |
OLD | NEW |