| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/mac/foundation_util.h" | 5 #include "base/mac/foundation_util.h" |
| 6 #include "base/mac/scoped_objc_class_swizzler.h" | 6 #include "base/mac/scoped_objc_class_swizzler.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/browser_window.h" | 8 #include "chrome/browser/ui/browser_window.h" |
| 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 9 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
| 10 #import "chrome/browser/ui/cocoa/info_bubble_window.h" | 10 #import "chrome/browser/ui/cocoa/info_bubble_window.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 @implementation AlwaysKeyNSWindow | 26 @implementation AlwaysKeyNSWindow |
| 27 - (BOOL)isKeyWindow { | 27 - (BOOL)isKeyWindow { |
| 28 return YES; | 28 return YES; |
| 29 } | 29 } |
| 30 @end | 30 @end |
| 31 | 31 |
| 32 // Integration tests for the Mac password bubble. | 32 // Integration tests for the Mac password bubble. |
| 33 class ManagePasswordsBubbleTest : public ManagePasswordsTest { | 33 class ManagePasswordsBubbleTest : public ManagePasswordsTest { |
| 34 public: | 34 public: |
| 35 virtual void SetUpOnMainThread() OVERRIDE { | 35 virtual void SetUpOnMainThread() override { |
| 36 ManagePasswordsTest::SetUpOnMainThread(); | 36 ManagePasswordsTest::SetUpOnMainThread(); |
| 37 browser()->window()->Show(); | 37 browser()->window()->Show(); |
| 38 } | 38 } |
| 39 | 39 |
| 40 virtual void TearDownOnMainThread() OVERRIDE { | 40 virtual void TearDownOnMainThread() override { |
| 41 ManagePasswordsTest::TearDownOnMainThread(); | 41 ManagePasswordsTest::TearDownOnMainThread(); |
| 42 } | 42 } |
| 43 | 43 |
| 44 ManagePasswordsBubbleController* controller() { | 44 ManagePasswordsBubbleController* controller() { |
| 45 return ManagePasswordsBubbleCocoa::instance() | 45 return ManagePasswordsBubbleCocoa::instance() |
| 46 ? ManagePasswordsBubbleCocoa::instance()->controller_ | 46 ? ManagePasswordsBubbleCocoa::instance()->controller_ |
| 47 : nil; | 47 : nil; |
| 48 } | 48 } |
| 49 | 49 |
| 50 void DoWithSwizzledNSWindow(void (^block)(void)) { | 50 void DoWithSwizzledNSWindow(void (^block)(void)) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 61 [window setAllowedAnimations:info_bubble::kAnimateNone]; | 61 [window setAllowedAnimations:info_bubble::kAnimateNone]; |
| 62 } | 62 } |
| 63 | 63 |
| 64 ManagePasswordsDecoration* decoration() { | 64 ManagePasswordsDecoration* decoration() { |
| 65 NSWindow* window = browser()->window()->GetNativeWindow(); | 65 NSWindow* window = browser()->window()->GetNativeWindow(); |
| 66 BrowserWindowController* bwc = | 66 BrowserWindowController* bwc = |
| 67 [BrowserWindowController browserWindowControllerForWindow:window]; | 67 [BrowserWindowController browserWindowControllerForWindow:window]; |
| 68 return [bwc locationBarBridge]->manage_passwords_decoration(); | 68 return [bwc locationBarBridge]->manage_passwords_decoration(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 virtual ManagePasswordsIcon* view() OVERRIDE { | 71 virtual ManagePasswordsIcon* view() override { |
| 72 return decoration()->icon(); | 72 return decoration()->icon(); |
| 73 } | 73 } |
| 74 }; | 74 }; |
| 75 | 75 |
| 76 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest, | 76 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest, |
| 77 PasswordEntryShowsPendingSaveView) { | 77 PasswordEntryShowsPendingSaveView) { |
| 78 EXPECT_FALSE(ManagePasswordsBubbleCocoa::instance()); | 78 EXPECT_FALSE(ManagePasswordsBubbleCocoa::instance()); |
| 79 DoWithSwizzledNSWindow(^{ SetupPendingPassword(); }); | 79 DoWithSwizzledNSWindow(^{ SetupPendingPassword(); }); |
| 80 EXPECT_TRUE(ManagePasswordsBubbleCocoa::instance()); | 80 EXPECT_TRUE(ManagePasswordsBubbleCocoa::instance()); |
| 81 EXPECT_EQ([ManagePasswordsBubblePendingViewController class], | 81 EXPECT_EQ([ManagePasswordsBubblePendingViewController class], |
| (...skipping 25 matching lines...) Expand all Loading... |
| 107 // Open a new tab. | 107 // Open a new tab. |
| 108 int firstTab = browser()->tab_strip_model()->active_index(); | 108 int firstTab = browser()->tab_strip_model()->active_index(); |
| 109 AddTabAtIndex( | 109 AddTabAtIndex( |
| 110 firstTab + 1, GURL("http://foo.bar/"), ui::PAGE_TRANSITION_TYPED); | 110 firstTab + 1, GURL("http://foo.bar/"), ui::PAGE_TRANSITION_TYPED); |
| 111 EXPECT_FALSE(decoration()->IsVisible()); | 111 EXPECT_FALSE(decoration()->IsVisible()); |
| 112 | 112 |
| 113 // Switch back to the previous tab. | 113 // Switch back to the previous tab. |
| 114 browser()->tab_strip_model()->ActivateTabAt(firstTab, true); | 114 browser()->tab_strip_model()->ActivateTabAt(firstTab, true); |
| 115 EXPECT_TRUE(decoration()->IsVisible()); | 115 EXPECT_TRUE(decoration()->IsVisible()); |
| 116 } | 116 } |
| OLD | NEW |