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

Side by Side Diff: chrome/browser/ui/cocoa/passwords/account_chooser_view_controller_unittest.mm

Issue 1723583004: CREDENTIAL: Convert federations from URLs to origins throughout. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 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 unified diff | Download patch
OLDNEW
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"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" 14 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h"
15 #import "chrome/browser/ui/cocoa/passwords/account_avatar_fetcher_manager.h" 15 #import "chrome/browser/ui/cocoa/passwords/account_avatar_fetcher_manager.h"
16 #import "chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.h" 16 #import "chrome/browser/ui/cocoa/passwords/account_chooser_view_controller.h"
17 #import "chrome/browser/ui/cocoa/passwords/credential_item_button.h" 17 #import "chrome/browser/ui/cocoa/passwords/credential_item_button.h"
18 #include "chrome/browser/ui/passwords/password_dialog_controller.h" 18 #include "chrome/browser/ui/passwords/password_dialog_controller.h"
19 #include "components/autofill/core/common/password_form.h" 19 #include "components/autofill/core/common/password_form.h"
20 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "testing/gtest_mac.h" 22 #include "testing/gtest_mac.h"
23 #include "url/gurl.h" 23 #include "url/gurl.h"
24 24 #include "url/origin.h"
25 25
26 @interface AccountAvatarFetcherTestManager : AccountAvatarFetcherManager { 26 @interface AccountAvatarFetcherTestManager : AccountAvatarFetcherManager {
27 std::vector<GURL> fetchedAvatars_; 27 std::vector<GURL> fetchedAvatars_;
28 } 28 }
29 @property(nonatomic, readonly) const std::vector<GURL>& fetchedAvatars; 29 @property(nonatomic, readonly) const std::vector<GURL>& fetchedAvatars;
30 @end 30 @end
31 31
32 @implementation AccountAvatarFetcherTestManager 32 @implementation AccountAvatarFetcherTestManager
33 33
34 - (void)fetchAvatar:(const GURL&)avatarURL forView:(CredentialItemButton*)view { 34 - (void)fetchAvatar:(const GURL&)avatarURL forView:(CredentialItemButton*)view {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 EXPECT_NSEQ(@"taco", [base::mac::ObjCCastStrict<CredentialItemButton>( 152 EXPECT_NSEQ(@"taco", [base::mac::ObjCCastStrict<CredentialItemButton>(
153 [buttons objectAtIndex:1]) title]); 153 [buttons objectAtIndex:1]) title]);
154 EXPECT_TRUE(avatar_manager().fetchedAvatars.empty()); 154 EXPECT_TRUE(avatar_manager().fetchedAvatars.empty());
155 } 155 }
156 156
157 TEST_F(AccountChooserViewControllerTest, ConfiguresFederatedCredential) { 157 TEST_F(AccountChooserViewControllerTest, ConfiguresFederatedCredential) {
158 const char federation[] = "https://google.com/idp"; 158 const char federation[] = "https://google.com/idp";
159 const char name[] = "Peter the Great"; 159 const char name[] = "Peter the Great";
160 PasswordDialogController::FormsVector local_forms; 160 PasswordDialogController::FormsVector local_forms;
161 local_forms.push_back(Credential("pizza")); 161 local_forms.push_back(Credential("pizza"));
162 local_forms.back()->federation_url = GURL(federation); 162 local_forms.back()->federation_origin = url::Origin(GURL(federation));
163 local_forms.back()->display_name = base::ASCIIToUTF16(name); 163 local_forms.back()->display_name = base::ASCIIToUTF16(name);
164 SetUpAccountChooser(&local_forms); 164 SetUpAccountChooser(&local_forms);
165 165
166 NSArray* buttons = view_controller().credentialButtons; 166 NSArray* buttons = view_controller().credentialButtons;
167 ASSERT_NSNE(nil, buttons); 167 ASSERT_NSNE(nil, buttons);
168 ASSERT_EQ(1u, buttons.count); 168 ASSERT_EQ(1u, buttons.count);
169 std::string title = 169 std::string title =
170 base::SysNSStringToUTF8([base::mac::ObjCCastStrict<CredentialItemButton>( 170 base::SysNSStringToUTF8([base::mac::ObjCCastStrict<CredentialItemButton>(
171 [buttons objectAtIndex:0]) title]); 171 [buttons objectAtIndex:0]) title]);
172 EXPECT_THAT(title, testing::HasSubstr(name)); 172 EXPECT_THAT(title, testing::HasSubstr(name));
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 local_forms.push_back(Credential("pizza")); 224 local_forms.push_back(Credential("pizza"));
225 SetUpAccountChooser(&local_forms); 225 SetUpAccountChooser(&local_forms);
226 [view_controller() setBridge:nil]; 226 [view_controller() setBridge:nil];
227 [view_controller().titleView clickedOnLink:@"" atIndex:0]; 227 [view_controller().titleView clickedOnLink:@"" atIndex:0];
228 [base::mac::ObjCCastStrict<CredentialItemButton>( 228 [base::mac::ObjCCastStrict<CredentialItemButton>(
229 [view_controller().credentialButtons objectAtIndex:0]) performClick:nil]; 229 [view_controller().credentialButtons objectAtIndex:0]) performClick:nil];
230 [view_controller().cancelButton performClick:nil]; 230 [view_controller().cancelButton performClick:nil];
231 } 231 }
232 232
233 } // namespace 233 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698