diff options
author | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-30 15:17:22 +0000 |
---|---|---|
committer | rohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-30 15:17:22 +0000 |
commit | 1d16be87574156e7e47d5d06245d54ba80a0f914 (patch) | |
tree | 139865662c80f7bf7cc42f38e640324c92c75558 /chrome | |
parent | 300329cc9afd4f411843138c4c7d6a9bdc764a39 (diff) | |
download | chromium_src-1d16be87574156e7e47d5d06245d54ba80a0f914.zip chromium_src-1d16be87574156e7e47d5d06245d54ba80a0f914.tar.gz chromium_src-1d16be87574156e7e47d5d06245d54ba80a0f914.tar.bz2 |
[Mac] Reposition the status bubble whenever adding it to a window.
BUG=50599
TEST=Open a window and let its webpage load. Move the window left or right, without allowing the mouse to pass over the web area. Then type in a new url and load it, again without letting the mouse pass over the web area. Status bubble should appear in the proper place.
Review URL: http://codereview.chromium.org/3041028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54320 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/cocoa/status_bubble_mac.mm | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/status_bubble_mac_unittest.mm | 20 |
2 files changed, 23 insertions, 1 deletions
diff --git a/chrome/browser/cocoa/status_bubble_mac.mm b/chrome/browser/cocoa/status_bubble_mac.mm index a286c4d..3f5c0a8 100644 --- a/chrome/browser/cocoa/status_bubble_mac.mm +++ b/chrome/browser/cocoa/status_bubble_mac.mm @@ -347,8 +347,10 @@ void StatusBubbleMac::Create() { void StatusBubbleMac::Attach() { // This method may be called several times during the process of creating or // showing a status bubble to attach the bubble to its parent window. - if (!is_attached()) + if (!is_attached()) { [parent_ addChildWindow:window_ ordered:NSWindowAbove]; + UpdateSizeAndPosition(); + } } void StatusBubbleMac::Detach() { diff --git a/chrome/browser/cocoa/status_bubble_mac_unittest.mm b/chrome/browser/cocoa/status_bubble_mac_unittest.mm index 6a15f8b..d61b270 100644 --- a/chrome/browser/cocoa/status_bubble_mac_unittest.mm +++ b/chrome/browser/cocoa/status_bubble_mac_unittest.mm @@ -458,3 +458,23 @@ TEST_F(StatusBubbleMacTest, UpdateSizeAndPosition) { EXPECT_NE(rect_before.size.width, rect_after.size.width); EXPECT_EQ(rect_before.size.height, rect_after.size.height); } + +TEST_F(StatusBubbleMacTest, MovingWindowUpdatesPosition) { + NSWindow* window = test_window(); + + // Show the bubble and make sure it has the same origin as |window|. + bubble_->SetStatus(L"Showing"); + NSWindow* child = GetWindow(); + EXPECT_TRUE(NSEqualPoints([window frame].origin, [child frame].origin)); + + // Hide the bubble, move the window, and show it again. + bubble_->Hide(); + NSRect frame = [window frame]; + frame.origin.x += 50; + [window setFrame:frame display:YES]; + bubble_->SetStatus(L"Reshowing"); + + // The bubble should reattach in the correct location. + child = GetWindow(); + EXPECT_TRUE(NSEqualPoints([window frame].origin, [child frame].origin)); +} |