| 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 "base/mac/foundation_util.h" | 9 #include "base/mac/foundation_util.h" |
| 10 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 return fetchedAvatars_; | 39 return fetchedAvatars_; |
| 40 } | 40 } |
| 41 | 41 |
| 42 @end | 42 @end |
| 43 | 43 |
| 44 namespace { | 44 namespace { |
| 45 | 45 |
| 46 const char kDialogTitle[] = "Choose an account"; | 46 const char kDialogTitle[] = "Choose an account"; |
| 47 | 47 |
| 48 // Returns a PasswordForm with only a username. | 48 // Returns a PasswordForm with only a username. |
| 49 scoped_ptr<autofill::PasswordForm> Credential(const char* username) { | 49 std::unique_ptr<autofill::PasswordForm> Credential(const char* username) { |
| 50 scoped_ptr<autofill::PasswordForm> credential(new autofill::PasswordForm); | 50 std::unique_ptr<autofill::PasswordForm> credential( |
| 51 new autofill::PasswordForm); |
| 51 credential->username_value = base::ASCIIToUTF16(username); | 52 credential->username_value = base::ASCIIToUTF16(username); |
| 52 return credential; | 53 return credential; |
| 53 } | 54 } |
| 54 | 55 |
| 55 class PasswordDialogControllerMock : public PasswordDialogController { | 56 class PasswordDialogControllerMock : public PasswordDialogController { |
| 56 public: | 57 public: |
| 57 MOCK_CONST_METHOD0(GetLocalForms, const FormsVector&()); | 58 MOCK_CONST_METHOD0(GetLocalForms, const FormsVector&()); |
| 58 MOCK_CONST_METHOD0(GetFederationsForms, const FormsVector&()); | 59 MOCK_CONST_METHOD0(GetFederationsForms, const FormsVector&()); |
| 59 MOCK_CONST_METHOD0(GetAccoutChooserTitle, | 60 MOCK_CONST_METHOD0(GetAccoutChooserTitle, |
| 60 std::pair<base::string16, gfx::Range>()); | 61 std::pair<base::string16, gfx::Range>()); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 ASSERT_EQ(1u, buttons.count); | 169 ASSERT_EQ(1u, buttons.count); |
| 169 std::string title = | 170 std::string title = |
| 170 base::SysNSStringToUTF8([base::mac::ObjCCastStrict<CredentialItemButton>( | 171 base::SysNSStringToUTF8([base::mac::ObjCCastStrict<CredentialItemButton>( |
| 171 [buttons objectAtIndex:0]) title]); | 172 [buttons objectAtIndex:0]) title]); |
| 172 EXPECT_THAT(title, testing::HasSubstr(name)); | 173 EXPECT_THAT(title, testing::HasSubstr(name)); |
| 173 EXPECT_THAT(title, testing::HasSubstr(GURL(federation).host())); | 174 EXPECT_THAT(title, testing::HasSubstr(GURL(federation).host())); |
| 174 } | 175 } |
| 175 | 176 |
| 176 TEST_F(AccountChooserViewControllerTest, ForwardsAvatarFetchToManager) { | 177 TEST_F(AccountChooserViewControllerTest, ForwardsAvatarFetchToManager) { |
| 177 PasswordDialogController::FormsVector local_forms; | 178 PasswordDialogController::FormsVector local_forms; |
| 178 scoped_ptr<autofill::PasswordForm> form = Credential("taco"); | 179 std::unique_ptr<autofill::PasswordForm> form = Credential("taco"); |
| 179 form->icon_url = GURL("http://foo.com"); | 180 form->icon_url = GURL("http://foo.com"); |
| 180 local_forms.push_back(std::move(form)); | 181 local_forms.push_back(std::move(form)); |
| 181 SetUpAccountChooser(&local_forms); | 182 SetUpAccountChooser(&local_forms); |
| 182 EXPECT_FALSE(avatar_manager().fetchedAvatars.empty()); | 183 EXPECT_FALSE(avatar_manager().fetchedAvatars.empty()); |
| 183 EXPECT_TRUE(std::find(avatar_manager().fetchedAvatars.begin(), | 184 EXPECT_TRUE(std::find(avatar_manager().fetchedAvatars.begin(), |
| 184 avatar_manager().fetchedAvatars.end(), | 185 avatar_manager().fetchedAvatars.end(), |
| 185 GURL("http://foo.com")) != | 186 GURL("http://foo.com")) != |
| 186 avatar_manager().fetchedAvatars.end()); | 187 avatar_manager().fetchedAvatars.end()); |
| 187 } | 188 } |
| 188 | 189 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 local_forms.push_back(Credential("pizza")); | 225 local_forms.push_back(Credential("pizza")); |
| 225 SetUpAccountChooser(&local_forms); | 226 SetUpAccountChooser(&local_forms); |
| 226 [view_controller() setBridge:nil]; | 227 [view_controller() setBridge:nil]; |
| 227 [view_controller().titleView clickedOnLink:@"" atIndex:0]; | 228 [view_controller().titleView clickedOnLink:@"" atIndex:0]; |
| 228 [base::mac::ObjCCastStrict<CredentialItemButton>( | 229 [base::mac::ObjCCastStrict<CredentialItemButton>( |
| 229 [view_controller().credentialButtons objectAtIndex:0]) performClick:nil]; | 230 [view_controller().credentialButtons objectAtIndex:0]) performClick:nil]; |
| 230 [view_controller().cancelButton performClick:nil]; | 231 [view_controller().cancelButton performClick:nil]; |
| 231 } | 232 } |
| 232 | 233 |
| 233 } // namespace | 234 } // namespace |
| OLD | NEW |