diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-22 21:40:33 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-22 21:40:33 +0000 |
commit | c414fbc1e11d0fdcf2a1b0dda7ff477835f91c9c (patch) | |
tree | d2af465f02aeb3d022338158b076467d4ad829b9 /ui | |
parent | a7e5e4a980af7274f7dd434e3bc500df6f12bde0 (diff) | |
download | chromium_src-c414fbc1e11d0fdcf2a1b0dda7ff477835f91c9c.zip chromium_src-c414fbc1e11d0fdcf2a1b0dda7ff477835f91c9c.tar.gz chromium_src-c414fbc1e11d0fdcf2a1b0dda7ff477835f91c9c.tar.bz2 |
aura: Move focus to the parent window when the focusd window closes.
BUG=110991
TEST=aura_unittests:WindowTest.FocusedWindowTest
Review URL: https://chromiumcodereview.appspot.com/9142005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118651 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/aura/root_window.cc | 2 | ||||
-rw-r--r-- | ui/aura/window_unittest.cc | 15 |
2 files changed, 16 insertions, 1 deletions
diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index edb52fc..dd84728 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -284,7 +284,7 @@ void RootWindow::WindowInitialized(Window* window) { void RootWindow::WindowDestroying(Window* window) { // Update the focused window state if the window was focused. if (focused_window_ == window) - SetFocusedWindow(NULL); + SetFocusedWindow(focused_window_->parent()); // When a window is being destroyed it's likely that the WindowDelegate won't // want events, so we reset the mouse_pressed_handler_ and capture_window_ and diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index ffb7f56..3ef60ff 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -807,6 +807,21 @@ TEST_F(WindowTest, TransientChildren) { EXPECT_EQ(w1.get(), parent->children()[1]); } +// Tests that when a focused window is closed, its parent inherits the focus. +TEST_F(WindowTest, FocusedWindowTest) { + scoped_ptr<Window> parent(CreateTestWindowWithId(0, NULL)); + scoped_ptr<Window> child(CreateTestWindowWithId(1, parent.get())); + + parent->Show(); + + child->Focus(); + EXPECT_TRUE(child->HasFocus()); + EXPECT_FALSE(parent->HasFocus()); + + child.reset(); + EXPECT_TRUE(parent->HasFocus()); +} + TEST_F(WindowTest, Property) { scoped_ptr<Window> w(CreateTestWindowWithId(0, NULL)); const char* key = "test"; |