| 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" |
| 11 #include "ui/aura/client/focus_change_observer.h" | 11 #include "ui/aura/client/focus_change_observer.h" |
| 12 #include "ui/aura/test/aura_test_base.h" | |
| 13 #include "ui/aura/test/event_generator.h" | 12 #include "ui/aura/test/event_generator.h" |
| 14 #include "ui/aura/test/test_window_delegate.h" | 13 #include "ui/aura/test/test_window_delegate.h" |
| 15 #include "ui/aura/test/test_windows.h" | 14 #include "ui/aura/test/test_windows.h" |
| 16 #include "ui/aura/window.h" | 15 #include "ui/aura/window.h" |
| 17 #include "ui/aura/window_event_dispatcher.h" | 16 #include "ui/aura/window_event_dispatcher.h" |
| 18 #include "ui/aura/window_tracker.h" | 17 #include "ui/aura/window_tracker.h" |
| 19 #include "ui/events/event_handler.h" | 18 #include "ui/events/event_handler.h" |
| 20 #include "ui/wm/core/base_focus_rules.h" | 19 #include "ui/wm/core/base_focus_rules.h" |
| 21 #include "ui/wm/core/wm_state.h" | 20 #include "ui/wm/core/wm_state.h" |
| 22 #include "ui/wm/public/activation_change_observer.h" | 21 #include "ui/wm/public/activation_change_observer.h" |
| 23 #include "ui/wm/public/activation_client.h" | 22 #include "ui/wm/public/activation_client.h" |
| 23 #include "ui/wm/test/wm_test_base.h" |
| 24 | 24 |
| 25 namespace wm { | 25 namespace wm { |
| 26 | 26 |
| 27 class FocusNotificationObserver : public aura::client::ActivationChangeObserver, | 27 class FocusNotificationObserver : public aura::client::ActivationChangeObserver, |
| 28 public aura::client::FocusChangeObserver { | 28 public aura::client::FocusChangeObserver { |
| 29 public: | 29 public: |
| 30 FocusNotificationObserver() | 30 FocusNotificationObserver() |
| 31 : activation_changed_count_(0), | 31 : activation_changed_count_(0), |
| 32 focus_changed_count_(0), | 32 focus_changed_count_(0), |
| 33 reactivation_count_(0), | 33 reactivation_count_(0), |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 bool CanFocusOrActivate(aura::Window* window) const { | 334 bool CanFocusOrActivate(aura::Window* window) const { |
| 335 return !focus_restriction_ || focus_restriction_->Contains(window); | 335 return !focus_restriction_ || focus_restriction_->Contains(window); |
| 336 } | 336 } |
| 337 | 337 |
| 338 aura::Window* focus_restriction_; | 338 aura::Window* focus_restriction_; |
| 339 | 339 |
| 340 DISALLOW_COPY_AND_ASSIGN(TestFocusRules); | 340 DISALLOW_COPY_AND_ASSIGN(TestFocusRules); |
| 341 }; | 341 }; |
| 342 | 342 |
| 343 // Common infrastructure shared by all FocusController test types. | 343 // Common infrastructure shared by all FocusController test types. |
| 344 class FocusControllerTestBase : public aura::test::AuraTestBase { | 344 class FocusControllerTestBase : public WMTestBase { |
| 345 protected: | 345 protected: |
| 346 FocusControllerTestBase() {} | 346 FocusControllerTestBase() {} |
| 347 | 347 |
| 348 // Overridden from aura::test::AuraTestBase: | 348 // Overridden from aura::test::AuraTestBase: |
| 349 virtual void SetUp() OVERRIDE { | 349 virtual void SetUp() OVERRIDE { |
| 350 wm_state_.reset(new wm::WMState); | 350 wm_state_.reset(new wm::WMState); |
| 351 // FocusController registers itself as an Env observer so it can catch all | 351 // FocusController registers itself as an Env observer so it can catch all |
| 352 // window initializations, including the root_window()'s, so we create it | 352 // window initializations, including the root_window()'s, so we create it |
| 353 // before allowing the base setup. | 353 // before allowing the base setup. |
| 354 test_focus_rules_ = new TestFocusRules; | 354 test_focus_rules_ = new TestFocusRules; |
| (...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 // Clicking on a window which has capture should not result in a focus change. | 1175 // Clicking on a window which has capture should not result in a focus change. |
| 1176 DIRECT_FOCUS_CHANGE_TESTS(NoFocusChangeOnClickOnCaptureWindow); | 1176 DIRECT_FOCUS_CHANGE_TESTS(NoFocusChangeOnClickOnCaptureWindow); |
| 1177 | 1177 |
| 1178 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, | 1178 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, |
| 1179 ChangeFocusWhenNothingFocusedAndCaptured); | 1179 ChangeFocusWhenNothingFocusedAndCaptured); |
| 1180 | 1180 |
| 1181 // See description above DontPassDeletedWindow() for details. | 1181 // See description above DontPassDeletedWindow() for details. |
| 1182 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, DontPassDeletedWindow); | 1182 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, DontPassDeletedWindow); |
| 1183 | 1183 |
| 1184 } // namespace wm | 1184 } // namespace wm |
| OLD | NEW |