diff options
author | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-18 23:27:40 +0000 |
---|---|---|
committer | derat@chromium.org <derat@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-18 23:27:40 +0000 |
commit | 87a4b990583c80a24b2122662beebc63e7b96451 (patch) | |
tree | 70a000af2b45c1465eaf5f49dc8a1c67d83aa12c /ui/views/focus/focus_manager_test.cc | |
parent | 1fe51aca23ab7d0d9286045077d0c50f0ddabddd (diff) | |
download | chromium_src-87a4b990583c80a24b2122662beebc63e7b96451.zip chromium_src-87a4b990583c80a24b2122662beebc63e7b96451.tar.gz chromium_src-87a4b990583c80a24b2122662beebc63e7b96451.tar.bz2 |
aura: Fix WidgetFocusChangeListener::OnNativeFocusChange().
In Aura, we were passing the newly-focused view through
views::WidgetFocusManager::OnWidgetFocusEvent()'s
"focused_before" parameter. This made us not close
extension popups when they lost the focus.
(Note that a popup still doesn't get closed upon clicking
outside of the popup on the desktop, presumably because the
popup retains the focus in Ash.)
BUG=132697
TEST=added, also manual testing
Review URL: https://chromiumcodereview.appspot.com/10562025
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142858 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/focus/focus_manager_test.cc')
-rw-r--r-- | ui/views/focus/focus_manager_test.cc | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/ui/views/focus/focus_manager_test.cc b/ui/views/focus/focus_manager_test.cc index da15b27..4344f12 100644 --- a/ui/views/focus/focus_manager_test.cc +++ b/ui/views/focus/focus_manager_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -14,7 +14,8 @@ namespace views { FocusManagerTest::FocusManagerTest() : contents_view_(new View), - focus_change_listener_(NULL) { + focus_change_listener_(NULL), + widget_focus_change_listener_(NULL) { } FocusManagerTest::~FocusManagerTest() { @@ -38,6 +39,10 @@ void FocusManagerTest::SetUp() { void FocusManagerTest::TearDown() { if (focus_change_listener_) GetFocusManager()->RemoveFocusChangeListener(focus_change_listener_); + if (widget_focus_change_listener_) { + WidgetFocusManager::GetInstance()->RemoveFocusChangeListener( + widget_focus_change_listener_); + } GetWidget()->Close(); // Flush the message loop to make application verifiers happy. @@ -72,6 +77,13 @@ void FocusManagerTest::AddFocusChangeListener(FocusChangeListener* listener) { GetFocusManager()->AddFocusChangeListener(listener); } +void FocusManagerTest::AddWidgetFocusChangeListener( + WidgetFocusChangeListener* listener) { + ASSERT_FALSE(widget_focus_change_listener_); + widget_focus_change_listener_ = listener; + WidgetFocusManager::GetInstance()->AddFocusChangeListener(listener); +} + #if defined(OS_WIN) && !defined(USE_AURA) void FocusManagerTest::SimulateActivateWindow() { SendMessage(GetWidget()->GetNativeWindow(), WM_ACTIVATE, WA_ACTIVE, NULL); @@ -111,4 +123,23 @@ void TestFocusChangeListener::ClearFocusChanges() { focus_changes_.clear(); } +//////////////////////////////////////////////////////////////////////////////// +// TestWidgetFocusChangeListener + +TestWidgetFocusChangeListener::TestWidgetFocusChangeListener() { +} + +TestWidgetFocusChangeListener::~TestWidgetFocusChangeListener() { +} + +void TestWidgetFocusChangeListener::ClearFocusChanges() { + focus_changes_.clear(); +} + +void TestWidgetFocusChangeListener::OnNativeFocusChange( + gfx::NativeView focused_before, + gfx::NativeView focused_now) { + focus_changes_.push_back(NativeViewPair(focused_before, focused_now)); +} + } // namespace views |