From 75d8fad8eeee968d13706b32101ce3f7a3f29eb5 Mon Sep 17 00:00:00 2001 From: "ben@chromium.org" Date: Tue, 27 Nov 2012 05:01:16 +0000 Subject: [PATCH] Consolidate focus handling a bit more in the new FocusController. There are now three phases of focus change: - input phase (from an input event, window disposition change or API call) - query phase (determination of what window should be focused) - exec phase (state is updated and events dispatched). Secondly, adds activation support and events. Currently passing BasicActivation and ActivationEvents test cases. I don't think we have a use case to support parent (hierarchy) changes to activation, so I am not supporting this for now as it makes the tests considerably more baroque. http://crbug.com/162100 R=sky@chromium.org Review URL: https://codereview.chromium.org/11412173 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@169580 0039d316-1c4b-4281-b951-d872f2087c98 --- ui/views/corewm/base_focus_rules.cc | 36 +++- ui/views/corewm/focus_controller.cc | 145 ++++++++++----- ui/views/corewm/focus_controller.h | 21 ++- ui/views/corewm/focus_controller_unittest.cc | 184 +++++++++++++------ 4 files changed, 272 insertions(+), 114 deletions(-) diff --git a/ui/views/corewm/base_focus_rules.cc b/ui/views/corewm/base_focus_rules.cc index dbc014a38de166..602aba88c7f569 100644 --- a/ui/views/corewm/base_focus_rules.cc +++ b/ui/views/corewm/base_focus_rules.cc @@ -4,6 +4,7 @@ #include "ui/views/corewm/base_focus_rules.h" +#include "ui/aura/root_window.h" #include "ui/aura/window.h" namespace views { @@ -22,8 +23,8 @@ BaseFocusRules::~BaseFocusRules() { // BaseFocusRules, FocusRules implementation: bool BaseFocusRules::CanActivateWindow(aura::Window* window) { - // TODO(beng): - return true; + return !window || + (window->IsVisible() && window->parent() == window->GetRootWindow()); } bool BaseFocusRules::CanFocusWindow(aura::Window* window) { @@ -32,8 +33,16 @@ bool BaseFocusRules::CanFocusWindow(aura::Window* window) { } aura::Window* BaseFocusRules::GetActivatableWindow(aura::Window* window) { - // TODO(beng): - return window; + // BasicFocusRules considers only direct children of the RootWindow as + // activatable. + aura::Window* parent = window->parent(); + aura::Window* activatable = window; + aura::RootWindow* root_window = window->GetRootWindow(); + while (parent != root_window) { + activatable = parent; + parent = parent->parent(); + } + return activatable; } aura::Window* BaseFocusRules::GetFocusableWindow(aura::Window* window) { @@ -45,7 +54,24 @@ aura::Window* BaseFocusRules::GetFocusableWindow(aura::Window* window) { aura::Window* BaseFocusRules::GetNextActivatableWindow(aura::Window* ignore) { DCHECK(ignore); - // TODO(beng): + // Can be called from the RootWindow's destruction, which has a NULL parent. + if (!ignore->parent()) + return NULL; + + // In the basic scenarios handled by BasicFocusRules, the pool of activatable + // windows is limited to the |ignore|'s siblings. + const aura::Window::Windows& siblings = ignore->parent()->children(); + DCHECK(!siblings.empty()); + + for (aura::Window::Windows::const_reverse_iterator rit = siblings.rbegin(); + rit != siblings.rend(); + ++rit) { + aura::Window* cur = *rit; + if (cur == ignore) + continue; + if (CanActivateWindow(cur)) + return cur; + } return NULL; } diff --git a/ui/views/corewm/focus_controller.cc b/ui/views/corewm/focus_controller.cc index 569060ad16ab2d..62527e5c27fadc 100644 --- a/ui/views/corewm/focus_controller.cc +++ b/ui/views/corewm/focus_controller.cc @@ -4,12 +4,41 @@ #include "ui/views/corewm/focus_controller.h" +#include "base/auto_reset.h" #include "ui/aura/env.h" #include "ui/views/corewm/focus_change_event.h" #include "ui/views/corewm/focus_rules.h" namespace views { namespace corewm { +namespace { + +// Updates focused window state and dispatches changing/changed events. +void DispatchEventsAndUpdateState(ui::EventDispatcher* dispatcher, + int changing_event_type, + int changed_event_type, + aura::Window** state, + aura::Window* new_state, + ui::EventTarget** event_dispatch_target) { + int result = ui::ER_UNHANDLED; + { + base::AutoReset reset(event_dispatch_target, *state); + FocusChangeEvent changing_event(changing_event_type); + result = dispatcher->ProcessEvent(*state, &changing_event); + } + DCHECK(!(result & ui::ER_CONSUMED)) + << "Focus and Activation events cannot be consumed"; + + *state = new_state; + + { + base::AutoReset reset(event_dispatch_target, *state); + FocusChangeEvent changed_event(changed_event_type); + dispatcher->ProcessEvent(*state, &changed_event); + } +} + +} // namespace //////////////////////////////////////////////////////////////////////////////// // FocusController, public: @@ -17,6 +46,7 @@ namespace corewm { FocusController::FocusController(FocusRules* rules) : active_window_(NULL), focused_window_(NULL), + event_dispatch_target_(NULL), rules_(rules) { DCHECK(rules); FocusChangeEvent::RegisterEventTypes(); @@ -27,19 +57,8 @@ FocusController::~FocusController() { aura::Env::GetInstance()->RemoveObserver(this); } -void FocusController::SetFocusedWindow(aura::Window* window) { - DCHECK(rules_->CanFocusWindow(window)); - // TODO(beng): dispatch changing events. - FocusChangeEvent changing_event( - FocusChangeEvent::focus_changing_event_type()); - int result = ProcessEvent(focused_window_, &changing_event); - if (result & ui::ER_CONSUMED) - return; - - focused_window_ = window; - - FocusChangeEvent changed_event(FocusChangeEvent::focus_changed_event_type()); - ProcessEvent(focused_window_, &changed_event); +void FocusController::FocusWindow(aura::Window* window) { + SetFocusedWindow(window); } //////////////////////////////////////////////////////////////////////////////// @@ -56,16 +75,15 @@ void FocusController::RemoveObserver( } void FocusController::ActivateWindow(aura::Window* window) { -// TODO(beng): + SetActiveWindow(rules_->GetActivatableWindow(window)); } void FocusController::DeactivateWindow(aura::Window* window) { -// TODO(beng): + SetActiveWindow(rules_->GetNextActivatableWindow(window)); } aura::Window* FocusController::GetActiveWindow() { - // TODO(beng): - return NULL; + return active_window_; } bool FocusController::OnWillFocusWindow(aura::Window* window, @@ -85,11 +103,8 @@ ui::EventResult FocusController::OnKeyEvent(ui::KeyEvent* event) { } ui::EventResult FocusController::OnMouseEvent(ui::MouseEvent* event) { - // TODO(beng): GetFocusableWindow(). - if (event->type() == ui::ET_MOUSE_PRESSED) { - SetFocusedWindow(rules_->GetFocusableWindow( - static_cast(event->target()))); - } + if (event->type() == ui::ET_MOUSE_PRESSED) + WindowFocusedFromInputEvent(static_cast(event->target())); return ui::ER_UNHANDLED; } @@ -102,11 +117,9 @@ ui::EventResult FocusController::OnTouchEvent(ui::TouchEvent* event) { } ui::EventResult FocusController::OnGestureEvent(ui::GestureEvent* event) { - // TODO(beng): GetFocusableWindow(). if (event->type() == ui::ET_GESTURE_BEGIN && event->details().touch_points() == 1) { - SetFocusedWindow(rules_->GetFocusableWindow( - static_cast(event->target()))); + WindowFocusedFromInputEvent(static_cast(event->target())); } return ui::ER_UNHANDLED; } @@ -119,34 +132,20 @@ void FocusController::OnWindowVisibilityChanging(aura::Window* window, // We need to process this change in VisibilityChanging while the window is // still visible, since focus events cannot be dispatched to invisible // windows. - // TODO(beng): evaluate whether or not the visibility restriction is worth - // enforcing for events that aren't user-input. - if (window->Contains(focused_window_)) - SetFocusedWindow(rules_->GetNextFocusableWindow(window)); + if (!visible) + WindowLostFocusFromDispositionChange(window); +} - if (window->Contains(active_window_)) { - // TODO(beng): Reset active window. - } +void FocusController::OnWindowDestroying(aura::Window* window) { + WindowLostFocusFromDispositionChange(window); } void FocusController::OnWindowDestroyed(aura::Window* window) { window->RemoveObserver(this); - - if (window->Contains(focused_window_)) - SetFocusedWindow(rules_->GetNextFocusableWindow(window)); - - if (window->Contains(active_window_)) { - // TODO(beng): Reset active window. - } } void FocusController::OnWillRemoveWindow(aura::Window* window) { - if (window->Contains(focused_window_)) - SetFocusedWindow(rules_->GetNextFocusableWindow(window)); - - if (window->Contains(active_window_)) { - // TODO(beng): Reset active window. - } + WindowLostFocusFromDispositionChange(window); } void FocusController::OnWindowInitialized(aura::Window* window) { @@ -157,8 +156,60 @@ void FocusController::OnWindowInitialized(aura::Window* window) { // FocusController, ui::EventDispatcher implementation: bool FocusController::CanDispatchToTarget(ui::EventTarget* target) { - // TODO(beng): - return true; + return target == event_dispatch_target_; +} + +//////////////////////////////////////////////////////////////////////////////// +// FocusController, private: + +void FocusController::SetFocusedWindow(aura::Window* window) { + DCHECK(rules_->CanFocusWindow(window)); + if (window) + DCHECK_EQ(window, rules_->GetFocusableWindow(window)); + DispatchEventsAndUpdateState( + this, + FocusChangeEvent::focus_changing_event_type(), + FocusChangeEvent::focus_changed_event_type(), + &focused_window_, + window, + &event_dispatch_target_); +} + +void FocusController::SetActiveWindow(aura::Window* window) { + DCHECK(rules_->CanActivateWindow(window)); + if (window) + DCHECK_EQ(window, rules_->GetActivatableWindow(window)); + DispatchEventsAndUpdateState( + this, + FocusChangeEvent::activation_changing_event_type(), + FocusChangeEvent::activation_changed_event_type(), + &active_window_, + window, + &event_dispatch_target_); +} + +void FocusController::WindowLostFocusFromDispositionChange( + aura::Window* window) { + // Activation adjustments are handled first in the event of a disposition + // changed. If an activation change is necessary, focus is reset as part of + // that process so there's no point in updating focus independently. + if (window->Contains(active_window_)) { + aura::Window* next_activatable = rules_->GetNextActivatableWindow(window); + SetActiveWindow(next_activatable); + SetFocusedWindow(next_activatable); + } else if (window->Contains(focused_window_)) { + // Active window isn't changing, but focused window might be. + SetFocusedWindow(rules_->GetNextFocusableWindow(window)); + } +} + +void FocusController::WindowFocusedFromInputEvent(aura::Window* window) { + aura::Window* activatable = rules_->GetActivatableWindow(window); + SetActiveWindow(activatable); + + // This handles switching focus via input events within the active window. + SetFocusedWindow(rules_->GetFocusableWindow( + activatable->Contains(window) ? window : activatable)); } } // namespace corewm diff --git a/ui/views/corewm/focus_controller.h b/ui/views/corewm/focus_controller.h index 9769589a710ba5..1c312d0586c302 100644 --- a/ui/views/corewm/focus_controller.h +++ b/ui/views/corewm/focus_controller.h @@ -44,7 +44,7 @@ class VIEWS_EXPORT FocusController : public aura::client::ActivationClient, // TODO(beng): FocusClient // Sets the focused window, resulting in focus change events being sent. // Must only be called with valid focusable windows per FocusRules. - void SetFocusedWindow(aura::Window* window); + void FocusWindow(aura::Window* window); aura::Window* focused_window() { return focused_window_; } private: @@ -70,6 +70,7 @@ class VIEWS_EXPORT FocusController : public aura::client::ActivationClient, // Overridden from aura::WindowObserver: virtual void OnWindowVisibilityChanging(aura::Window* window, bool visible) OVERRIDE; + virtual void OnWindowDestroying(aura::Window* window) OVERRIDE; virtual void OnWindowDestroyed(aura::Window* window) OVERRIDE; virtual void OnWillRemoveWindow(aura::Window* window) OVERRIDE; @@ -79,9 +80,27 @@ class VIEWS_EXPORT FocusController : public aura::client::ActivationClient, // Overridden from ui::EventDispatcher: virtual bool CanDispatchToTarget(ui::EventTarget* target) OVERRIDE; + // Internal implementations that set the focused/active windows, fire events + // etc. These functions must be called with valid focusable/activatable + // windows. + void SetFocusedWindow(aura::Window* window); + void SetActiveWindow(aura::Window* window); + + // Called when a window's disposition changed such that it and its hierarchy + // are no longer focusable/activatable. The system must determine what window + // to focus next based on rules. + void WindowLostFocusFromDispositionChange(aura::Window* window); + + // Called when an attempt is made to focus or activate a window via an input + // event targeted at that window. Rules determine the best focusable window + // for the input window. + void WindowFocusedFromInputEvent(aura::Window* window); + aura::Window* active_window_; aura::Window* focused_window_; + ui::EventTarget* event_dispatch_target_; + scoped_ptr rules_; DISALLOW_COPY_AND_ASSIGN(FocusController); diff --git a/ui/views/corewm/focus_controller_unittest.cc b/ui/views/corewm/focus_controller_unittest.cc index e29b25d9d95c00..90464cb8c878bb 100644 --- a/ui/views/corewm/focus_controller_unittest.cc +++ b/ui/views/corewm/focus_controller_unittest.cc @@ -2,24 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Tests for: -// Activation/Focus driven by: -// - user input events -// - api calls -// - window hide/destruction -// - focus changes -// GetFocusableWindow -// GetActivatableWindow -// CanFocus -// CanActivate - -// Focus/Activation behavior -// e.g. focus on activation with child windows etc. - #include "ui/views/corewm/focus_controller.h" #include +#include "ui/aura/client/activation_client.h" #include "ui/aura/root_window.h" #include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/event_generator.h" @@ -88,17 +75,21 @@ class FocusControllerTestBase : public aura::test::AuraTestBase { // Overridden from aura::test::AuraTestBase: virtual void SetUp() OVERRIDE { - aura::test::AuraTestBase::SetUp(); + // FocusController registers itself as an Env observer so it can catch all + // window initializations, including the root_window()'s, so we create it + // before allowing the base setup. focus_controller_.reset(new FocusController(new BaseFocusRules)); + aura::test::AuraTestBase::SetUp(); root_window()->AddPreTargetHandler(focus_controller()); + aura::client::SetActivationClient(root_window(), focus_controller()); // Hierarchy used by all tests: // root_window - // +-- w1 - // +-- w11 - // +-- w2 - // +-- w21 - // +-- w211 + // +-- w1 + // +-- w11 + // +-- w2 + // +-- w21 + // +-- w211 aura::Window* w1 = aura::test::CreateTestWindowWithDelegate( aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(), 1, gfx::Rect(0, 0, 50, 50), NULL); @@ -127,10 +118,33 @@ class FocusControllerTestBase : public aura::test::AuraTestBase { return focused_window() ? focused_window()->id() : -1; } + void ActivateWindow(aura::Window* window) { + aura::client::GetActivationClient(root_window())->ActivateWindow(window); + } + aura::Window* GetActiveWindow() { + return aura::client::GetActivationClient(root_window())->GetActiveWindow(); + } + int GetActiveWindowId() { + aura::Window* active_window = GetActiveWindow(); + return active_window ? active_window->id() : -1; + } + + void ExpectActivationEvents(FocusEventsTestHandler* handler, + int expected_changing_event_count, + int expected_changed_event_count) { + EXPECT_EQ(expected_changing_event_count, + handler->GetCountForEventType( + FocusChangeEvent::activation_changing_event_type())); + EXPECT_EQ(expected_changed_event_count, + handler->GetCountForEventType( + FocusChangeEvent::activation_changed_event_type())); + } + // Test functions. virtual void BasicFocus() = 0; + virtual void BasicActivation() = 0; virtual void FocusEvents() = 0; - virtual void ConsumesFocusEvents() = 0; + virtual void ActivationEvents() = 0; private: scoped_ptr focus_controller_; @@ -145,12 +159,18 @@ class FocusControllerDirectTestBase : public FocusControllerTestBase { // Different test types shift focus in different ways. virtual void FocusWindowDirect(aura::Window* window) = 0; + virtual void ActivateWindowDirect(aura::Window* window) = 0; void FocusWindowById(int id) { aura::Window* window = root_window()->GetChildById(id); DCHECK(window); FocusWindowDirect(window); } + void ActivateWindowById(int id) { + aura::Window* window = root_window()->GetChildById(id); + DCHECK(window); + ActivateWindowDirect(window); + } // Overridden from FocusControllerTestBase: virtual void BasicFocus() OVERRIDE { @@ -160,6 +180,13 @@ class FocusControllerDirectTestBase : public FocusControllerTestBase { FocusWindowById(2); EXPECT_EQ(2, focused_window_id()); } + virtual void BasicActivation() OVERRIDE { + EXPECT_EQ(NULL, GetActiveWindow()); + ActivateWindowById(1); + EXPECT_EQ(1, GetActiveWindowId()); + ActivateWindowById(2); + EXPECT_EQ(2, GetActiveWindowId()); + } virtual void FocusEvents() OVERRIDE { FocusEventsTestHandler handler(root_window()->GetChildById(1)); EXPECT_EQ(0, handler.GetCountForEventType( @@ -172,15 +199,21 @@ class FocusControllerDirectTestBase : public FocusControllerTestBase { EXPECT_EQ(1, handler.GetCountForEventType( FocusChangeEvent::focus_changed_event_type())); } - virtual void ConsumesFocusEvents() OVERRIDE { - FocusWindowById(1); - FocusEventsTestHandler handler(root_window()->GetChildById(1)); - handler.set_result(ui::ER_CONSUMED); - FocusWindowById(2); - // |handler| consumed the focus changing event, preventing the change from - // being committed, so 1 is still focused. - EXPECT_EQ(1, focused_window_id()); + virtual void ActivationEvents() OVERRIDE { + ActivateWindowById(1); + + FocusEventsTestHandler handler_root(root_window()); + FocusEventsTestHandler handler_1(root_window()->GetChildById(1)); + FocusEventsTestHandler handler_2(root_window()->GetChildById(2)); + + ExpectActivationEvents(&handler_root, 0, 0); + ExpectActivationEvents(&handler_1, 0, 0); + ExpectActivationEvents(&handler_2, 0, 0); + ActivateWindowById(2); + ExpectActivationEvents(&handler_root, 1, 1); + ExpectActivationEvents(&handler_1, 1, 0); + ExpectActivationEvents(&handler_2, 0, 1); } private: @@ -195,7 +228,10 @@ class FocusControllerApiTest : public FocusControllerDirectTestBase { private: // Overridden from FocusControllerTestBase: virtual void FocusWindowDirect(aura::Window* window) OVERRIDE { - focus_controller()->SetFocusedWindow(window); + focus_controller()->FocusWindow(window); + } + virtual void ActivateWindowDirect(aura::Window* window) OVERRIDE { + ActivateWindow(window); } DISALLOW_COPY_AND_ASSIGN(FocusControllerApiTest); @@ -212,6 +248,10 @@ class FocusControllerMouseEventTest : public FocusControllerDirectTestBase { aura::test::EventGenerator generator(root_window(), window); generator.ClickLeftButton(); } + virtual void ActivateWindowDirect(aura::Window* window) OVERRIDE { + aura::test::EventGenerator generator(root_window(), window); + generator.ClickLeftButton(); + } DISALLOW_COPY_AND_ASSIGN(FocusControllerMouseEventTest); }; @@ -226,6 +266,10 @@ class FocusControllerGestureEventTest : public FocusControllerDirectTestBase { aura::test::EventGenerator generator(root_window(), window); generator.GestureTapAt(window->bounds().CenterPoint()); } + virtual void ActivateWindowDirect(aura::Window* window) OVERRIDE { + aura::test::EventGenerator generator(root_window(), window); + generator.GestureTapAt(window->bounds().CenterPoint()); + } DISALLOW_COPY_AND_ASSIGN(FocusControllerGestureEventTest); }; @@ -246,21 +290,31 @@ class FocusControllerImplicitTestBase : public FocusControllerTestBase { // Overridden from FocusControllerTestBase: virtual void BasicFocus() OVERRIDE { - aura::Window* w211 = root_window()->GetChildById(211); - EXPECT_EQ(NULL, focused_window()); - focus_controller()->SetFocusedWindow(w211); + aura::Window* w211 = root_window()->GetChildById(211); + focus_controller()->FocusWindow(w211); EXPECT_EQ(211, focused_window_id()); ChangeWindowDisposition(w211); - // BasicFocusRules passes focus to the parent. EXPECT_EQ(parent_ ? 2 : 21, focused_window_id()); } + virtual void BasicActivation() OVERRIDE { + DCHECK(!parent_) << "Activation tests don't support parent changes."; + + EXPECT_EQ(NULL, GetActiveWindow()); + + aura::Window* w2 = root_window()->GetChildById(2); + ActivateWindow(w2); + EXPECT_EQ(2, GetActiveWindowId()); + + ChangeWindowDisposition(w2); + EXPECT_EQ(1, GetActiveWindowId()); + } virtual void FocusEvents() OVERRIDE { aura::Window* w211 = root_window()->GetChildById(211); - focus_controller()->SetFocusedWindow(w211); + focus_controller()->FocusWindow(w211); FocusEventsTestHandler handler(root_window()->GetChildById(211)); EXPECT_EQ(0, handler.GetCountForEventType( @@ -273,23 +327,29 @@ class FocusControllerImplicitTestBase : public FocusControllerTestBase { EXPECT_EQ(1, handler.GetCountForEventType( FocusChangeEvent::focus_changed_event_type())); } - virtual void ConsumesFocusEvents() OVERRIDE { - aura::Window* w211 = root_window()->GetChildById(211); - focus_controller()->SetFocusedWindow(w211); + virtual void ActivationEvents() OVERRIDE { + DCHECK(!parent_) << "Activation tests don't support parent changes."; - FocusEventsTestHandler handler(root_window()->GetChildById(211)); - handler.set_result(ui::ER_CONSUMED); + aura::Window* w2 = root_window()->GetChildById(2); + ActivateWindow(w2); - ChangeWindowDisposition(w211); + FocusEventsTestHandler handler_root(root_window()); + FocusEventsTestHandler handler_1(root_window()->GetChildById(1)); + FocusEventsTestHandler handler_2(root_window()->GetChildById(2)); - // |handler| consumed the focus changing event, preventing the change from - // being committed, so 2 is still focused. - EXPECT_EQ(1, focused_window_id()); + ExpectActivationEvents(&handler_root, 0, 0); + ExpectActivationEvents(&handler_1, 0, 0); + ExpectActivationEvents(&handler_2, 0, 0); + + ChangeWindowDisposition(w2); + ExpectActivationEvents(&handler_root, 1, 1); + ExpectActivationEvents(&handler_1, 0, 1); + ExpectActivationEvents(&handler_2, 1, 0); } private: // When true, the disposition change occurs to the parent of the window - // instead of to the window. This verifies that changes occuring in the + // instead of to the window. This verifies that changes occurring in the // hierarchy that contains the window affect the window's focus. bool parent_; @@ -392,7 +452,7 @@ class FocusControllerParentRemovalTest : public FocusControllerRemovalTest { #define FOCUS_CONTROLLER_TEST(TESTCLASS, TESTNAME) \ TEST_F(TESTCLASS, TESTNAME) { TESTNAME(); } -#define FOCUS_CONTROLLER_TESTS(TESTNAME) \ +#define FOCUS_TESTS(TESTNAME) \ FOCUS_CONTROLLER_TEST(FocusControllerApiTest, TESTNAME) \ FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, TESTNAME) \ FOCUS_CONTROLLER_TEST(FocusControllerGestureEventTest, TESTNAME) \ @@ -403,21 +463,27 @@ class FocusControllerParentRemovalTest : public FocusControllerRemovalTest { FOCUS_CONTROLLER_TEST(FocusControllerRemovalTest, TESTNAME) \ FOCUS_CONTROLLER_TEST(FocusControllerParentRemovalTest, TESTNAME) +// Activation tests do not have Parent* variants as that is not a supported +// event flow. +#define ACTIVATION_TESTS(TESTNAME) \ + FOCUS_CONTROLLER_TEST(FocusControllerApiTest, TESTNAME) \ + FOCUS_CONTROLLER_TEST(FocusControllerMouseEventTest, TESTNAME) \ + FOCUS_CONTROLLER_TEST(FocusControllerGestureEventTest, TESTNAME) \ + FOCUS_CONTROLLER_TEST(FocusControllerHideTest, TESTNAME) \ + FOCUS_CONTROLLER_TEST(FocusControllerDestructionTest, TESTNAME) \ + FOCUS_CONTROLLER_TEST(FocusControllerRemovalTest, TESTNAME) + // - Focuses a window, verifies that focus changed. -FOCUS_CONTROLLER_TESTS(BasicFocus); +FOCUS_TESTS(BasicFocus); // - Activates a window, verifies that activation changed. -TEST_F(FocusControllerApiTest, BasicActivation) { - -} +ACTIVATION_TESTS(BasicActivation); // - Focuses a window, verifies that focus events were dispatched. -FOCUS_CONTROLLER_TESTS(FocusEvents); +FOCUS_TESTS(FocusEvents); // - Activates a window, verifies that activation events were dispatched. -TEST_F(FocusControllerApiTest, ActivationEvents) { - -} +ACTIVATION_TESTS(ActivationEvents); // - Focuses a window, re-targets event prior to -ed event being dispatched. TEST_F(FocusControllerApiTest, RetargetFocusEvent) { @@ -429,13 +495,9 @@ TEST_F(FocusControllerApiTest, RetargetActivationEvent) { } -// - Focuses a window, consumes events. -//FOCUS_CONTROLLER_TESTS(ConsumesFocusEvents); - -// - Activates a window, consumes events. -TEST_F(FocusControllerApiTest, ConsumeActivationEvents) { - -} +// TODO(beng): +// . window->window focus changes within an active window +// . focus and activation changes within a single test. } // namespace corewm } // namespace views