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 #include "ios/chrome/browser/passwords/credential_manager.h" | 5 #include "ios/chrome/browser/passwords/credential_manager.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/mac/bind_objc_block.h" | 10 #include "base/mac/bind_objc_block.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 @end | 54 @end |
55 | 55 |
56 namespace { | 56 namespace { |
57 | 57 |
58 // Returns a test credential. | 58 // Returns a test credential. |
59 autofill::PasswordForm GetTestPasswordForm1(bool zero_click_allowed) { | 59 autofill::PasswordForm GetTestPasswordForm1(bool zero_click_allowed) { |
60 autofill::PasswordForm form; | 60 autofill::PasswordForm form; |
61 form.username_value = base::ASCIIToUTF16("foo"); | 61 form.username_value = base::ASCIIToUTF16("foo"); |
62 form.password_value = base::ASCIIToUTF16("bar"); | 62 form.password_value = base::ASCIIToUTF16("bar"); |
63 form.skip_zero_click = !zero_click_allowed; | 63 form.skip_zero_click = !zero_click_allowed; |
64 form.ssl_valid = true; | |
65 form.type = autofill::PasswordForm::Type::TYPE_API; | 64 form.type = autofill::PasswordForm::Type::TYPE_API; |
66 return form; | 65 return form; |
67 } | 66 } |
68 | 67 |
69 // Returns a test credential matching |GetTestPasswordForm1()|. | 68 // Returns a test credential matching |GetTestPasswordForm1()|. |
70 web::Credential GetTestWebCredential1(bool zero_click_allowed) { | 69 web::Credential GetTestWebCredential1(bool zero_click_allowed) { |
71 web::Credential credential; | 70 web::Credential credential; |
72 autofill::PasswordForm form(GetTestPasswordForm1(zero_click_allowed)); | 71 autofill::PasswordForm form(GetTestPasswordForm1(zero_click_allowed)); |
73 credential.type = web::CredentialType::CREDENTIAL_TYPE_PASSWORD; | 72 credential.type = web::CredentialType::CREDENTIAL_TYPE_PASSWORD; |
74 credential.id = form.username_value; | 73 credential.id = form.username_value; |
75 credential.password = form.password_value; | 74 credential.password = form.password_value; |
76 return credential; | 75 return credential; |
77 } | 76 } |
78 | 77 |
79 // Returns a different test credential. | 78 // Returns a different test credential. |
80 autofill::PasswordForm GetTestPasswordForm2(bool zero_click_allowed) { | 79 autofill::PasswordForm GetTestPasswordForm2(bool zero_click_allowed) { |
81 autofill::PasswordForm form; | 80 autofill::PasswordForm form; |
82 form.username_value = base::ASCIIToUTF16("baz"); | 81 form.username_value = base::ASCIIToUTF16("baz"); |
83 form.password_value = base::ASCIIToUTF16("bah"); | 82 form.password_value = base::ASCIIToUTF16("bah"); |
84 form.skip_zero_click = !zero_click_allowed; | 83 form.skip_zero_click = !zero_click_allowed; |
85 form.ssl_valid = true; | |
86 return form; | 84 return form; |
87 } | 85 } |
88 | 86 |
89 // Returns a test credential matching |GetTestPasswordForm2()|. | 87 // Returns a test credential matching |GetTestPasswordForm2()|. |
90 web::Credential GetTestWebCredential2(bool zero_click_allowed) { | 88 web::Credential GetTestWebCredential2(bool zero_click_allowed) { |
91 web::Credential credential; | 89 web::Credential credential; |
92 autofill::PasswordForm form(GetTestPasswordForm2(zero_click_allowed)); | 90 autofill::PasswordForm form(GetTestPasswordForm2(zero_click_allowed)); |
93 credential.type = web::CredentialType::CREDENTIAL_TYPE_PASSWORD; | 91 credential.type = web::CredentialType::CREDENTIAL_TYPE_PASSWORD; |
94 credential.id = form.username_value; | 92 credential.id = form.username_value; |
95 credential.password = form.password_value; | 93 credential.password = form.password_value; |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 WaitForBackgroundTasks(); | 599 WaitForBackgroundTasks(); |
602 EXPECT_EQ(1U, store->stored_passwords().size()); | 600 EXPECT_EQ(1U, store->stored_passwords().size()); |
603 const std::vector<autofill::PasswordForm>& passwords_after_signout = | 601 const std::vector<autofill::PasswordForm>& passwords_after_signout = |
604 store->stored_passwords().find(current_origin)->second; | 602 store->stored_passwords().find(current_origin)->second; |
605 EXPECT_EQ(2U, passwords_after_signout.size()); | 603 EXPECT_EQ(2U, passwords_after_signout.size()); |
606 for (const autofill::PasswordForm& form : passwords_after_signout) | 604 for (const autofill::PasswordForm& form : passwords_after_signout) |
607 EXPECT_TRUE(form.skip_zero_click); | 605 EXPECT_TRUE(form.skip_zero_click); |
608 } | 606 } |
609 | 607 |
610 } // namespace | 608 } // namespace |
OLD | NEW |