| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/strings/string16.h" | 5 #include "base/strings/string16.h" |
| 6 #include "base/strings/string_util.h" | 6 #include "base/strings/string_util.h" |
| 7 #include "base/strings/stringprintf.h" | 7 #include "base/strings/stringprintf.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "components/autofill/content/renderer/password_form_conversion_utils.h" | 9 #include "components/autofill/content/renderer/password_form_conversion_utils.h" |
| 10 #include "components/autofill/core/common/password_form.h" | 10 #include "components/autofill/core/common/password_form.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 TEST_F(MAYBE_PasswordFormConversionUtilsTest, IdentifyingTwoPasswordFields) { | 285 TEST_F(MAYBE_PasswordFormConversionUtilsTest, IdentifyingTwoPasswordFields) { |
| 286 // Each test case consists of a set of parameters to be plugged into the | 286 // Each test case consists of a set of parameters to be plugged into the |
| 287 // PasswordFormBuilder below, plus the corresponding expectations. | 287 // PasswordFormBuilder below, plus the corresponding expectations. |
| 288 struct TestCase { | 288 struct TestCase { |
| 289 const char* password_values[2]; | 289 const char* password_values[2]; |
| 290 const char* expected_password_element; | 290 const char* expected_password_element; |
| 291 const char* expected_password_value; | 291 const char* expected_password_value; |
| 292 const char* expected_new_password_element; | 292 const char* expected_new_password_element; |
| 293 const char* expected_new_password_value; | 293 const char* expected_new_password_value; |
| 294 } cases[] = { | 294 } cases[] = { |
| 295 // Twp non-empty fields with the same value should be treated as a new | 295 // Two non-empty fields with the same value should be treated as a new |
| 296 // password field plus a confirmation field for the new password. | 296 // password field plus a confirmation field for the new password. |
| 297 {{"alpha", "alpha"}, "", "", "password1", "alpha"}, | 297 {{"alpha", "alpha"}, "", "", "password1", "alpha"}, |
| 298 // The same goes if the fields are yet empty: we speculate that we will | 298 // The same goes if the fields are yet empty: we speculate that we will |
| 299 // identify them as new password fields once they are filled out, and we | 299 // identify them as new password fields once they are filled out, and we |
| 300 // want to keep our abstract interpretation of the form less flaky. | 300 // want to keep our abstract interpretation of the form less flaky. |
| 301 {{"", ""}, "", "", "password1", ""}, | 301 {{"", ""}, "password1", "", "password2", ""}, |
| 302 // Two different values should be treated as a password change form, one | 302 // Two different values should be treated as a password change form, one |
| 303 // that also asks for the current password, but only once for the new. | 303 // that also asks for the current password, but only once for the new. |
| 304 {{"alpha", ""}, "password1", "alpha", "password2", ""}, | 304 {{"alpha", ""}, "password1", "alpha", "password2", ""}, |
| 305 {{"", "beta"}, "password1", "", "password2", "beta"}, | 305 {{"", "beta"}, "password1", "", "password2", "beta"}, |
| 306 {{"alpha", "beta"}, "password1", "alpha", "password2", "beta"}}; | 306 {{"alpha", "beta"}, "password1", "alpha", "password2", "beta"}}; |
| 307 | 307 |
| 308 for (size_t i = 0; i < arraysize(cases); ++i) { | 308 for (size_t i = 0; i < arraysize(cases); ++i) { |
| 309 SCOPED_TRACE(testing::Message() << "Iteration " << i); | 309 SCOPED_TRACE(testing::Message() << "Iteration " << i); |
| 310 | 310 |
| 311 PasswordFormBuilder builder(kTestFormActionURL); | 311 PasswordFormBuilder builder(kTestFormActionURL); |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 | 692 |
| 693 scoped_ptr<PasswordForm> login_plus_signup_form; | 693 scoped_ptr<PasswordForm> login_plus_signup_form; |
| 694 ASSERT_NO_FATAL_FAILURE( | 694 ASSERT_NO_FATAL_FAILURE( |
| 695 LoadHTMLAndConvertForm(login_plus_signup_html, &login_plus_signup_form)); | 695 LoadHTMLAndConvertForm(login_plus_signup_html, &login_plus_signup_form)); |
| 696 ASSERT_TRUE(login_plus_signup_form); | 696 ASSERT_TRUE(login_plus_signup_form); |
| 697 EXPECT_EQ(PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP, | 697 EXPECT_EQ(PasswordForm::Layout::LAYOUT_LOGIN_AND_SIGNUP, |
| 698 login_plus_signup_form->layout); | 698 login_plus_signup_form->layout); |
| 699 } | 699 } |
| 700 | 700 |
| 701 } // namespace autofill | 701 } // namespace autofill |
| OLD | NEW |