OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #import "chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.h" | 5 #import "chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include <Carbon/Carbon.h> | 9 #include <Carbon/Carbon.h> |
10 | 10 |
11 #include "base/mac/foundation_util.h" | 11 #include "base/mac/foundation_util.h" |
12 #include "base/mac/scoped_nsobject.h" | 12 #include "base/mac/scoped_nsobject.h" |
| 13 #include "base/stl_util.h" |
13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
14 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
15 #include "base/strings/utf_string_conversions.h" | 16 #include "base/strings/utf_string_conversions.h" |
16 #import "chrome/browser/ui/cocoa/passwords/account_avatar_fetcher_manager.h" | 17 #import "chrome/browser/ui/cocoa/passwords/account_avatar_fetcher_manager.h" |
17 #import "chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.h" | 18 #import "chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.h" |
18 #import "chrome/browser/ui/cocoa/passwords/credential_item_button.h" | 19 #import "chrome/browser/ui/cocoa/passwords/credential_item_button.h" |
19 #include "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" | 20 #include "chrome/browser/ui/cocoa/test/cocoa_test_helper.h" |
20 #include "chrome/browser/ui/passwords/password_dialog_controller_mock.h" | 21 #include "chrome/browser/ui/passwords/password_dialog_controller_mock.h" |
21 #include "components/autofill/core/common/password_form.h" | 22 #include "components/autofill/core/common/password_form.h" |
22 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 EXPECT_THAT(title, testing::HasSubstr(GURL(federation).host())); | 165 EXPECT_THAT(title, testing::HasSubstr(GURL(federation).host())); |
165 } | 166 } |
166 | 167 |
167 TEST_F(AccountChooserViewControllerTest, ForwardsAvatarFetchToManager) { | 168 TEST_F(AccountChooserViewControllerTest, ForwardsAvatarFetchToManager) { |
168 PasswordDialogController::FormsVector local_forms; | 169 PasswordDialogController::FormsVector local_forms; |
169 std::unique_ptr<autofill::PasswordForm> form = Credential("taco"); | 170 std::unique_ptr<autofill::PasswordForm> form = Credential("taco"); |
170 form->icon_url = GURL("http://foo.com"); | 171 form->icon_url = GURL("http://foo.com"); |
171 local_forms.push_back(std::move(form)); | 172 local_forms.push_back(std::move(form)); |
172 SetUpAccountChooser(&local_forms); | 173 SetUpAccountChooser(&local_forms); |
173 EXPECT_FALSE(avatar_manager().fetchedAvatars.empty()); | 174 EXPECT_FALSE(avatar_manager().fetchedAvatars.empty()); |
174 EXPECT_TRUE(std::find(avatar_manager().fetchedAvatars.begin(), | 175 EXPECT_TRUE(base::ContainsValue(avatar_manager().fetchedAvatars, |
175 avatar_manager().fetchedAvatars.end(), | 176 GURL("http://foo.com"))); |
176 GURL("http://foo.com")) != | |
177 avatar_manager().fetchedAvatars.end()); | |
178 } | 177 } |
179 | 178 |
180 TEST_F(AccountChooserViewControllerTest, | 179 TEST_F(AccountChooserViewControllerTest, |
181 SelectingCredentialInformsModelAndClosesDialog) { | 180 SelectingCredentialInformsModelAndClosesDialog) { |
182 PasswordDialogController::FormsVector local_forms; | 181 PasswordDialogController::FormsVector local_forms; |
183 local_forms.push_back(Credential("pizza")); | 182 local_forms.push_back(Credential("pizza")); |
184 local_forms.push_back(Credential("taco")); | 183 local_forms.push_back(Credential("taco")); |
185 SetUpAccountChooser(&local_forms); | 184 SetUpAccountChooser(&local_forms); |
186 EXPECT_CALL(dialog_controller(), | 185 EXPECT_CALL(dialog_controller(), |
187 OnChooseCredentials( | 186 OnChooseCredentials( |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 PasswordDialogController::FormsVector local_forms; | 235 PasswordDialogController::FormsVector local_forms; |
237 local_forms.push_back(Credential("pizza")); | 236 local_forms.push_back(Credential("pizza")); |
238 SetUpAccountChooser(&local_forms); | 237 SetUpAccountChooser(&local_forms); |
239 EXPECT_CALL(*this, OnPerformClose()); | 238 EXPECT_CALL(*this, OnPerformClose()); |
240 [[view_controller() view] | 239 [[view_controller() view] |
241 performKeyEquivalent:cocoa_test_event_utils::KeyEventWithKeyCode( | 240 performKeyEquivalent:cocoa_test_event_utils::KeyEventWithKeyCode( |
242 kVK_Escape, '\e', NSKeyDown, 0)]; | 241 kVK_Escape, '\e', NSKeyDown, 0)]; |
243 } | 242 } |
244 | 243 |
245 } // namespace | 244 } // namespace |
OLD | NEW |