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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 ManagePasswordsIcon* view() override { return decoration()->icon(); } | 71 ManagePasswordsIconCocoa* GetView() { return decoration()->icon(); } |
72 }; | 72 }; |
73 | 73 |
74 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest, | 74 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest, |
75 PasswordEntryShowsPendingSaveView) { | 75 PasswordEntryShowsPendingSaveView) { |
76 EXPECT_FALSE(ManagePasswordsBubbleCocoa::instance()); | 76 EXPECT_FALSE(ManagePasswordsBubbleCocoa::instance()); |
77 DoWithSwizzledNSWindow(^{ SetupPendingPassword(); }); | 77 DoWithSwizzledNSWindow(^{ SetupPendingPassword(); }); |
78 EXPECT_TRUE(ManagePasswordsBubbleCocoa::instance()); | 78 EXPECT_TRUE(ManagePasswordsBubbleCocoa::instance()); |
79 EXPECT_EQ([SavePendingPasswordViewController class], | 79 EXPECT_EQ([SavePendingPasswordViewController class], |
80 [controller().currentController class]); | 80 [controller().currentController class]); |
81 EXPECT_TRUE(view()->active()); | 81 EXPECT_TRUE(GetView()->active()); |
82 } | 82 } |
83 | 83 |
84 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest, IconClickTogglesBubble) { | 84 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest, IconClickTogglesBubble) { |
85 // Show the bubble automatically. | 85 // Show the bubble automatically. |
86 DoWithSwizzledNSWindow(^{ SetupPendingPassword(); }); | 86 DoWithSwizzledNSWindow(^{ SetupPendingPassword(); }); |
87 | 87 |
88 // Close the bubble by clicking on the decoration. | 88 // Close the bubble by clicking on the decoration. |
89 DisableAnimationsOnController(); | 89 DisableAnimationsOnController(); |
90 decoration()->OnMousePressed(NSZeroRect, NSZeroPoint); | 90 decoration()->OnMousePressed(NSZeroRect, NSZeroPoint); |
91 EXPECT_FALSE(ManagePasswordsBubbleCocoa::instance()); | 91 EXPECT_FALSE(ManagePasswordsBubbleCocoa::instance()); |
(...skipping 20 matching lines...) Expand all Loading... |
112 browser()->tab_strip_model()->ActivateTabAt(firstTab, true); | 112 browser()->tab_strip_model()->ActivateTabAt(firstTab, true); |
113 EXPECT_TRUE(decoration()->IsVisible()); | 113 EXPECT_TRUE(decoration()->IsVisible()); |
114 } | 114 } |
115 | 115 |
116 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest, DoubleOpenBubble) { | 116 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest, DoubleOpenBubble) { |
117 // Open the bubble first. | 117 // Open the bubble first. |
118 DoWithSwizzledNSWindow(^{ SetupPendingPassword(); }); | 118 DoWithSwizzledNSWindow(^{ SetupPendingPassword(); }); |
119 base::scoped_nsobject<ManagePasswordsBubbleController> bubble_controller( | 119 base::scoped_nsobject<ManagePasswordsBubbleController> bubble_controller( |
120 [controller() retain]); | 120 [controller() retain]); |
121 EXPECT_TRUE(bubble_controller); | 121 EXPECT_TRUE(bubble_controller); |
122 EXPECT_TRUE(view()->active()); | 122 EXPECT_TRUE(GetView()->active()); |
123 | 123 |
124 // Open the bubble again, the first one should be replaced. | 124 // Open the bubble again, the first one should be replaced. |
125 DoWithSwizzledNSWindow(^{ SetupPendingPassword(); }); | 125 DoWithSwizzledNSWindow(^{ SetupPendingPassword(); }); |
126 EXPECT_NSNE(bubble_controller, controller()); | 126 EXPECT_NSNE(bubble_controller, controller()); |
127 EXPECT_TRUE(controller()); | 127 EXPECT_TRUE(controller()); |
128 EXPECT_TRUE(view()->active()); | 128 EXPECT_TRUE(GetView()->active()); |
129 } | 129 } |
130 | 130 |
131 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest, DoubleOpenDifferentBubbles) { | 131 IN_PROC_BROWSER_TEST_F(ManagePasswordsBubbleTest, DoubleOpenDifferentBubbles) { |
132 // Open the autosignin bubble first. | 132 // Open the autosignin bubble first. |
133 DoWithSwizzledNSWindow(^{ | 133 DoWithSwizzledNSWindow(^{ |
134 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials; | 134 std::vector<std::unique_ptr<autofill::PasswordForm>> local_credentials; |
135 local_credentials.emplace_back(new autofill::PasswordForm(*test_form())); | 135 local_credentials.emplace_back(new autofill::PasswordForm(*test_form())); |
136 SetupAutoSignin(std::move(local_credentials)); | 136 SetupAutoSignin(std::move(local_credentials)); |
137 }); | 137 }); |
138 EXPECT_TRUE(controller()); | 138 EXPECT_TRUE(controller()); |
139 EXPECT_TRUE(view()->active()); | 139 EXPECT_TRUE(GetView()->active()); |
140 | 140 |
141 // Open the save bubble. The previous one is closed twice (with and without | 141 // Open the save bubble. The previous one is closed twice (with and without |
142 // animation). It shouldn't cause DCHECK. | 142 // animation). It shouldn't cause DCHECK. |
143 DoWithSwizzledNSWindow(^{ SetupPendingPassword(); }); | 143 DoWithSwizzledNSWindow(^{ SetupPendingPassword(); }); |
144 EXPECT_TRUE(controller()); | 144 EXPECT_TRUE(controller()); |
145 EXPECT_TRUE(view()->active()); | 145 EXPECT_TRUE(GetView()->active()); |
146 } | 146 } |
OLD | NEW |