| 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/activation_change_observer.h" | 9 #include "ui/aura/client/activation_change_observer.h" |
| 10 #include "ui/aura/client/activation_client.h" | 10 #include "ui/aura/client/activation_client.h" |
| 11 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
| 12 #include "ui/aura/client/default_capture_client.h" | 12 #include "ui/aura/client/default_capture_client.h" |
| 13 #include "ui/aura/client/focus_change_observer.h" | 13 #include "ui/aura/client/focus_change_observer.h" |
| 14 #include "ui/aura/test/aura_test_base.h" | 14 #include "ui/aura/test/aura_test_base.h" |
| 15 #include "ui/aura/test/event_generator.h" | 15 #include "ui/aura/test/event_generator.h" |
| 16 #include "ui/aura/test/test_window_delegate.h" | 16 #include "ui/aura/test/test_window_delegate.h" |
| 17 #include "ui/aura/test/test_windows.h" | 17 #include "ui/aura/test/test_windows.h" |
| 18 #include "ui/aura/window.h" | 18 #include "ui/aura/window.h" |
| 19 #include "ui/aura/window_event_dispatcher.h" | 19 #include "ui/aura/window_event_dispatcher.h" |
| 20 #include "ui/aura/window_tracker.h" | 20 #include "ui/aura/window_tracker.h" |
| 21 #include "ui/events/event_handler.h" | 21 #include "ui/events/event_handler.h" |
| 22 #include "ui/wm/core/base_focus_rules.h" | 22 #include "ui/wm/core/base_focus_rules.h" |
| 23 #include "ui/wm/core/wm_state.h" | 23 #include "ui/wm/core/wm_state.h" |
| 24 | 24 |
| 25 namespace views { | 25 namespace wm { |
| 26 namespace corewm { | |
| 27 | 26 |
| 28 class FocusNotificationObserver : public aura::client::ActivationChangeObserver, | 27 class FocusNotificationObserver : public aura::client::ActivationChangeObserver, |
| 29 public aura::client::FocusChangeObserver { | 28 public aura::client::FocusChangeObserver { |
| 30 public: | 29 public: |
| 31 FocusNotificationObserver() | 30 FocusNotificationObserver() |
| 32 : activation_changed_count_(0), | 31 : activation_changed_count_(0), |
| 33 focus_changed_count_(0), | 32 focus_changed_count_(0), |
| 34 reactivation_count_(0), | 33 reactivation_count_(0), |
| 35 reactivation_requested_window_(NULL), | 34 reactivation_requested_window_(NULL), |
| 36 reactivation_actual_window_(NULL) {} | 35 reactivation_actual_window_(NULL) {} |
| (...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 DISALLOW_COPY_AND_ASSIGN(TestFocusRules); | 340 DISALLOW_COPY_AND_ASSIGN(TestFocusRules); |
| 342 }; | 341 }; |
| 343 | 342 |
| 344 // Common infrastructure shared by all FocusController test types. | 343 // Common infrastructure shared by all FocusController test types. |
| 345 class FocusControllerTestBase : public aura::test::AuraTestBase { | 344 class FocusControllerTestBase : public aura::test::AuraTestBase { |
| 346 protected: | 345 protected: |
| 347 FocusControllerTestBase() {} | 346 FocusControllerTestBase() {} |
| 348 | 347 |
| 349 // Overridden from aura::test::AuraTestBase: | 348 // Overridden from aura::test::AuraTestBase: |
| 350 virtual void SetUp() OVERRIDE { | 349 virtual void SetUp() OVERRIDE { |
| 351 wm_state_.reset(new views::corewm::WMState); | 350 wm_state_.reset(new wm::WMState); |
| 352 // 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 |
| 353 // window initializations, including the root_window()'s, so we create it | 352 // window initializations, including the root_window()'s, so we create it |
| 354 // before allowing the base setup. | 353 // before allowing the base setup. |
| 355 test_focus_rules_ = new TestFocusRules; | 354 test_focus_rules_ = new TestFocusRules; |
| 356 focus_controller_.reset(new FocusController(test_focus_rules_)); | 355 focus_controller_.reset(new FocusController(test_focus_rules_)); |
| 357 aura::test::AuraTestBase::SetUp(); | 356 aura::test::AuraTestBase::SetUp(); |
| 358 root_window()->AddPreTargetHandler(focus_controller_.get()); | 357 root_window()->AddPreTargetHandler(focus_controller_.get()); |
| 359 aura::client::SetFocusClient(root_window(), focus_controller_.get()); | 358 aura::client::SetFocusClient(root_window(), focus_controller_.get()); |
| 360 aura::client::SetActivationClient(root_window(), focus_controller_.get()); | 359 aura::client::SetActivationClient(root_window(), focus_controller_.get()); |
| 361 | 360 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 virtual void ShiftFocusOnActivation() {} | 439 virtual void ShiftFocusOnActivation() {} |
| 441 virtual void ShiftFocusOnActivationDueToHide() {} | 440 virtual void ShiftFocusOnActivationDueToHide() {} |
| 442 virtual void NoShiftActiveOnActivation() {} | 441 virtual void NoShiftActiveOnActivation() {} |
| 443 virtual void NoFocusChangeOnClickOnCaptureWindow() {} | 442 virtual void NoFocusChangeOnClickOnCaptureWindow() {} |
| 444 virtual void ChangeFocusWhenNothingFocusedAndCaptured() {} | 443 virtual void ChangeFocusWhenNothingFocusedAndCaptured() {} |
| 445 virtual void DontPassDeletedWindow() {} | 444 virtual void DontPassDeletedWindow() {} |
| 446 | 445 |
| 447 private: | 446 private: |
| 448 scoped_ptr<FocusController> focus_controller_; | 447 scoped_ptr<FocusController> focus_controller_; |
| 449 TestFocusRules* test_focus_rules_; | 448 TestFocusRules* test_focus_rules_; |
| 450 scoped_ptr<views::corewm::WMState> wm_state_; | 449 scoped_ptr<wm::WMState> wm_state_; |
| 451 | 450 |
| 452 DISALLOW_COPY_AND_ASSIGN(FocusControllerTestBase); | 451 DISALLOW_COPY_AND_ASSIGN(FocusControllerTestBase); |
| 453 }; | 452 }; |
| 454 | 453 |
| 455 // Test base for tests where focus is directly set to a target window. | 454 // Test base for tests where focus is directly set to a target window. |
| 456 class FocusControllerDirectTestBase : public FocusControllerTestBase { | 455 class FocusControllerDirectTestBase : public FocusControllerTestBase { |
| 457 protected: | 456 protected: |
| 458 FocusControllerDirectTestBase() {} | 457 FocusControllerDirectTestBase() {} |
| 459 | 458 |
| 460 // Different test types shift focus in different ways. | 459 // Different test types shift focus in different ways. |
| (...skipping 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 | 1192 |
| 1194 // Clicking on a window which has capture should not result in a focus change. | 1193 // Clicking on a window which has capture should not result in a focus change. |
| 1195 DIRECT_FOCUS_CHANGE_TESTS(NoFocusChangeOnClickOnCaptureWindow); | 1194 DIRECT_FOCUS_CHANGE_TESTS(NoFocusChangeOnClickOnCaptureWindow); |
| 1196 | 1195 |
| 1197 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, | 1196 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, |
| 1198 ChangeFocusWhenNothingFocusedAndCaptured); | 1197 ChangeFocusWhenNothingFocusedAndCaptured); |
| 1199 | 1198 |
| 1200 // See description above DontPassDeletedWindow() for details. | 1199 // See description above DontPassDeletedWindow() for details. |
| 1201 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, DontPassDeletedWindow); | 1200 FOCUS_CONTROLLER_TEST(FocusControllerApiTest, DontPassDeletedWindow); |
| 1202 | 1201 |
| 1203 } // namespace corewm | 1202 } // namespace wm |
| 1204 } // namespace views | |
| OLD | NEW |