Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Unified Diff: chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa_unittest.mm

Issue 528213004: Don't try to show the Mac password bubble on an inactive tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa_unittest.mm
diff --git a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa_unittest.mm b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa_unittest.mm
index 82eb43084dc22a475e5aaa58844a3132d8760a5e..5db7f0222cff0bf12d3520dda94e91fbf882c1a0 100644
--- a/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa_unittest.mm
+++ b/chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa_unittest.mm
@@ -34,8 +34,7 @@ class ManagePasswordsBubbleCocoaTest : public CocoaProfileTest {
// Create the WebContents.
siteInstance_ = content::SiteInstance::Create(profile());
- webContents_ = content::WebContents::Create(
- content::WebContents::CreateParams(profile(), siteInstance_.get()));
+ webContents_ = CreateWebContents();
browser()->tab_strip_model()->AppendWebContents(
webContents_, /*foreground=*/true);
@@ -49,19 +48,19 @@ class ManagePasswordsBubbleCocoaTest : public CocoaProfileTest {
content::WebContents* webContents() { return webContents_; }
+ content::WebContents* CreateWebContents() {
+ return content::WebContents::Create(
+ content::WebContents::CreateParams(profile(), siteInstance_.get()));
+ }
+
void ShowBubble() {
- NSWindow* nativeWindow = browser()->window()->GetNativeWindow();
- BrowserWindowController* bwc =
- [BrowserWindowController browserWindowControllerForWindow:nativeWindow];
- ManagePasswordsIcon* icon =
- [bwc locationBarBridge]->manage_passwords_decoration()->icon();
-
- ManagePasswordsBubbleCocoa::ShowBubble(
- webContents(), ManagePasswordsBubble::DisplayReason::AUTOMATIC, icon);
- // Disable animations so that closing happens immediately.
- InfoBubbleWindow* bubbleWindow = base::mac::ObjCCast<InfoBubbleWindow>(
- [ManagePasswordsBubbleCocoa::instance()->controller_ window]);
- [bubbleWindow setAllowedAnimations:info_bubble::kAnimateNone];
+ chrome::ShowManagePasswordsBubble(webContents());
+ if (ManagePasswordsBubbleCocoa::instance()) {
+ // Disable animations so that closing happens immediately.
+ InfoBubbleWindow* bubbleWindow = base::mac::ObjCCast<InfoBubbleWindow>(
+ [ManagePasswordsBubbleCocoa::instance()->controller_ window]);
+ [bubbleWindow setAllowedAnimations:info_bubble::kAnimateNone];
+ }
}
void CloseBubble() {
@@ -104,3 +103,19 @@ TEST_F(ManagePasswordsBubbleCocoaTest, BackgroundCloseShouldDeleteBubble) {
EXPECT_FALSE(ManagePasswordsBubbleCocoa::instance());
EXPECT_FALSE([bubbleWindow() isVisible]);
}
+
+TEST_F(ManagePasswordsBubbleCocoaTest, ShowBubbleOnInactiveTabShouldDoNothing) {
+ // Start in the tab that we'll try to show the bubble on.
+ EXPECT_TRUE(webContents()->GetTopLevelNativeWindow());
+
+ // Open a second tab and make it active.
+ content::WebContents* webContents2 = CreateWebContents();
+ browser()->tab_strip_model()->AppendWebContents(webContents2,
+ /*foreground=*/true);
+ EXPECT_FALSE(webContents()->GetTopLevelNativeWindow());
+ EXPECT_TRUE(webContents2->GetTopLevelNativeWindow());
+
+ // Try to show the bubble on the inactive tab. Nothing should happen.
+ ShowBubble();
+ EXPECT_FALSE(ManagePasswordsBubbleCocoa::instance());
+}
« no previous file with comments | « chrome/browser/ui/cocoa/passwords/manage_passwords_bubble_cocoa.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698