| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "base/utf_string_conversions.h" | 6 #include "base/utf_string_conversions.h" |
| 7 #include "chrome/common/autofill_messages.h" | 7 #include "chrome/common/autofill_messages.h" |
| 8 #include "chrome/renderer/autofill/autofill_agent.h" | 8 #include "chrome/renderer/autofill/autofill_agent.h" |
| 9 #include "chrome/renderer/autofill/password_autofill_manager.h" | 9 #include "chrome/renderer/autofill/password_autofill_manager.h" |
| 10 #include "chrome/test/base/render_view_test.h" | 10 #include "chrome/test/base/render_view_test.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 RenderViewTest::SetUp(); | 73 RenderViewTest::SetUp(); |
| 74 | 74 |
| 75 // Add a preferred login and an additional login to the FillData. | 75 // Add a preferred login and an additional login to the FillData. |
| 76 username1_ = ASCIIToUTF16(kAliceUsername); | 76 username1_ = ASCIIToUTF16(kAliceUsername); |
| 77 password1_ = ASCIIToUTF16(kAlicePassword); | 77 password1_ = ASCIIToUTF16(kAlicePassword); |
| 78 username2_ = ASCIIToUTF16(kBobUsername); | 78 username2_ = ASCIIToUTF16(kBobUsername); |
| 79 password2_ = ASCIIToUTF16(kBobPassword); | 79 password2_ = ASCIIToUTF16(kBobPassword); |
| 80 username3_ = ASCIIToUTF16(kCarolUsername); | 80 username3_ = ASCIIToUTF16(kCarolUsername); |
| 81 password3_ = ASCIIToUTF16(kCarolPassword); | 81 password3_ = ASCIIToUTF16(kCarolPassword); |
| 82 | 82 |
| 83 fill_data_.basic_data.fields.push_back( | 83 FormField username_field; |
| 84 FormField(string16(), ASCIIToUTF16(kUsernameName), | 84 username_field.name = ASCIIToUTF16(kUsernameName); |
| 85 username1_, string16(), 0, false)); | 85 username_field.value = username1_; |
| 86 fill_data_.basic_data.fields.push_back( | 86 fill_data_.basic_data.fields.push_back(username_field); |
| 87 FormField(string16(), ASCIIToUTF16(kPasswordName), | 87 |
| 88 password1_, string16(), 0, false)); | 88 FormField password_field; |
| 89 password_field.name = ASCIIToUTF16(kPasswordName); |
| 90 password_field.value = password1_; |
| 91 fill_data_.basic_data.fields.push_back(password_field); |
| 92 |
| 89 fill_data_.additional_logins[username2_] = password2_; | 93 fill_data_.additional_logins[username2_] = password2_; |
| 90 fill_data_.additional_logins[username3_] = password3_; | 94 fill_data_.additional_logins[username3_] = password3_; |
| 91 | 95 |
| 92 // We need to set the origin so it matches the frame URL and the action so | 96 // We need to set the origin so it matches the frame URL and the action so |
| 93 // it matches the form action, otherwise we won't autocomplete. | 97 // it matches the form action, otherwise we won't autocomplete. |
| 94 std::string origin("data:text/html;charset=utf-8,"); | 98 std::string origin("data:text/html;charset=utf-8,"); |
| 95 origin += kFormHTML; | 99 origin += kFormHTML; |
| 96 fill_data_.basic_data.origin = GURL(origin); | 100 fill_data_.basic_data.origin = GURL(origin); |
| 97 fill_data_.basic_data.action = GURL("http://www.bidule.com"); | 101 fill_data_.basic_data.action = GURL("http://www.bidule.com"); |
| 98 | 102 |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 // To simulate accepting an item in the suggestion drop-down we just mimic | 415 // To simulate accepting an item in the suggestion drop-down we just mimic |
| 412 // what the WebView does: it sets the element value then calls | 416 // what the WebView does: it sets the element value then calls |
| 413 // didSelectAutofillSuggestion on the renderer. | 417 // didSelectAutofillSuggestion on the renderer. |
| 414 autofill_agent_->didSelectAutofillSuggestion(username_element_, | 418 autofill_agent_->didSelectAutofillSuggestion(username_element_, |
| 415 ASCIIToUTF16(kAliceUsername), | 419 ASCIIToUTF16(kAliceUsername), |
| 416 WebKit::WebString(), | 420 WebKit::WebString(), |
| 417 0); | 421 0); |
| 418 // Autocomplete should not have kicked in. | 422 // Autocomplete should not have kicked in. |
| 419 CheckTextFieldsState("", false, "", false); | 423 CheckTextFieldsState("", false, "", false); |
| 420 } | 424 } |
| OLD | NEW |