| 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/credential_item_view.h" | 5 #import "chrome/browser/ui/cocoa/passwords/credential_item_view.h" |
| 6 | 6 |
| 7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 9 #include "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 10 #include "testing/gtest_mac.h" | 10 #include "testing/gtest_mac.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 } | 106 } |
| 107 | 107 |
| 108 // Returns a delegate for testing. | 108 // Returns a delegate for testing. |
| 109 CredentialItemTestDelegate* delegate() { return delegate_.get(); } | 109 CredentialItemTestDelegate* delegate() { return delegate_.get(); } |
| 110 | 110 |
| 111 // Returns an autoreleased view populated from |form|. | 111 // Returns an autoreleased view populated from |form|. |
| 112 CredentialItemView* view(const autofill::PasswordForm& form) { | 112 CredentialItemView* view(const autofill::PasswordForm& form) { |
| 113 return [[[CredentialItemView alloc] | 113 return [[[CredentialItemView alloc] |
| 114 initWithPasswordForm:form | 114 initWithPasswordForm:form |
| 115 credentialType:password_manager::CredentialType:: | 115 credentialType:password_manager::CredentialType:: |
| 116 CREDENTIAL_TYPE_LOCAL | 116 CREDENTIAL_TYPE_PASSWORD |
| 117 style:password_manager_mac::CredentialItemStyle:: | 117 style:password_manager_mac::CredentialItemStyle:: |
| 118 ACCOUNT_CHOOSER | 118 ACCOUNT_CHOOSER |
| 119 delegate:delegate()] autorelease]; | 119 delegate:delegate()] autorelease]; |
| 120 } | 120 } |
| 121 | 121 |
| 122 private: | 122 private: |
| 123 base::scoped_nsobject<CredentialItemTestDelegate> delegate_; | 123 base::scoped_nsobject<CredentialItemTestDelegate> delegate_; |
| 124 }; | 124 }; |
| 125 | 125 |
| 126 TEST_F(CredentialItemViewTest, BasicCredential) { | 126 TEST_F(CredentialItemViewTest, BasicCredential) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 EXPECT_EQ(form.avatar_url, [delegate() fetchedAvatarURL]); | 177 EXPECT_EQ(form.avatar_url, [delegate() fetchedAvatarURL]); |
| 178 EXPECT_EQ(item, [delegate() viewForFetchedAvatar]); | 178 EXPECT_EQ(item, [delegate() viewForFetchedAvatar]); |
| 179 EXPECT_TRUE( | 179 EXPECT_TRUE( |
| 180 ImagesEqual([CredentialItemView defaultAvatar], [item avatarView].image)); | 180 ImagesEqual([CredentialItemView defaultAvatar], [item avatarView].image)); |
| 181 | 181 |
| 182 [item updateAvatar:nil]; | 182 [item updateAvatar:nil]; |
| 183 EXPECT_FALSE([item avatarView].image); | 183 EXPECT_FALSE([item avatarView].image); |
| 184 } | 184 } |
| 185 | 185 |
| 186 } // namespace | 186 } // namespace |
| OLD | NEW |