OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/string_util.h" | 5 #include "base/strings/string_util.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "chrome/test/base/chrome_render_view_test.h" | 7 #include "chrome/test/base/chrome_render_view_test.h" |
8 #include "components/autofill/content/common/autofill_messages.h" | 8 #include "components/autofill/content/common/autofill_messages.h" |
9 #include "components/autofill/content/renderer/autofill_agent.h" | 9 #include "components/autofill/content/renderer/autofill_agent.h" |
10 #include "components/autofill/content/renderer/form_autofill_util.h" | 10 #include "components/autofill/content/renderer/form_autofill_util.h" |
11 #include "components/autofill/content/renderer/password_autofill_agent.h" | 11 #include "components/autofill/content/renderer/password_autofill_agent.h" |
12 #include "components/autofill/content/renderer/test_password_autofill_agent.h" | 12 #include "components/autofill/content/renderer/test_password_autofill_agent.h" |
| 13 #include "components/autofill/core/common/autofill_constants.h" |
13 #include "components/autofill/core/common/form_data.h" | 14 #include "components/autofill/core/common/form_data.h" |
14 #include "components/autofill/core/common/form_field_data.h" | 15 #include "components/autofill/core/common/form_field_data.h" |
15 #include "content/public/renderer/render_frame.h" | 16 #include "content/public/renderer/render_frame.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/WebKit/public/platform/WebString.h" | 18 #include "third_party/WebKit/public/platform/WebString.h" |
18 #include "third_party/WebKit/public/platform/WebVector.h" | 19 #include "third_party/WebKit/public/platform/WebVector.h" |
19 #include "third_party/WebKit/public/web/WebDocument.h" | 20 #include "third_party/WebKit/public/web/WebDocument.h" |
20 #include "third_party/WebKit/public/web/WebElement.h" | 21 #include "third_party/WebKit/public/web/WebElement.h" |
21 #include "third_party/WebKit/public/web/WebFormElement.h" | 22 #include "third_party/WebKit/public/web/WebFormElement.h" |
22 #include "third_party/WebKit/public/web/WebInputElement.h" | 23 #include "third_party/WebKit/public/web/WebInputElement.h" |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 | 404 |
404 // Checks the message sent to PasswordAutofillManager to build the suggestion | 405 // Checks the message sent to PasswordAutofillManager to build the suggestion |
405 // list. |username| is the expected username field value, and |show_all| is | 406 // list. |username| is the expected username field value, and |show_all| is |
406 // the expected flag for the PasswordAutofillManager, whether to show all | 407 // the expected flag for the PasswordAutofillManager, whether to show all |
407 // suggestions, or only those starting with |username|. | 408 // suggestions, or only those starting with |username|. |
408 void CheckSuggestions(const std::string& username, bool show_all) { | 409 void CheckSuggestions(const std::string& username, bool show_all) { |
409 const IPC::Message* message = | 410 const IPC::Message* message = |
410 render_thread_->sink().GetFirstMessageMatching( | 411 render_thread_->sink().GetFirstMessageMatching( |
411 AutofillHostMsg_ShowPasswordSuggestions::ID); | 412 AutofillHostMsg_ShowPasswordSuggestions::ID); |
412 EXPECT_TRUE(message); | 413 EXPECT_TRUE(message); |
413 Tuple5<int, base::i18n::TextDirection, base::string16, bool, gfx::RectF> | 414 Tuple5<int, base::i18n::TextDirection, base::string16, int, gfx::RectF> |
414 args; | 415 args; |
415 AutofillHostMsg_ShowPasswordSuggestions::Read(message, &args); | 416 AutofillHostMsg_ShowPasswordSuggestions::Read(message, &args); |
416 EXPECT_EQ(kPasswordFillFormDataId, args.a); | 417 EXPECT_EQ(kPasswordFillFormDataId, args.a); |
417 EXPECT_EQ(ASCIIToUTF16(username), args.c); | 418 EXPECT_EQ(ASCIIToUTF16(username), args.c); |
418 EXPECT_EQ(show_all, args.d); | 419 int options = args.d; |
| 420 EXPECT_EQ(show_all, static_cast<bool>(options & autofill::SHOW_ALL)); |
419 | 421 |
420 render_thread_->sink().ClearMessages(); | 422 render_thread_->sink().ClearMessages(); |
421 } | 423 } |
422 | 424 |
423 void ExpectFormSubmittedWithUsernameAndPasswords( | 425 void ExpectFormSubmittedWithUsernameAndPasswords( |
424 const std::string& username_value, | 426 const std::string& username_value, |
425 const std::string& password_value, | 427 const std::string& password_value, |
426 const std::string& new_password_value) { | 428 const std::string& new_password_value) { |
427 const IPC::Message* message = | 429 const IPC::Message* message = |
428 render_thread_->sink().GetFirstMessageMatching( | 430 render_thread_->sink().GetFirstMessageMatching( |
(...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 password_element_, | 1539 password_element_, |
1538 /*is_user_input=*/true); | 1540 /*is_user_input=*/true); |
1539 | 1541 |
1540 // Simulate the user typing a stored username. | 1542 // Simulate the user typing a stored username. |
1541 SimulateUsernameChange(kAliceUsername, true); | 1543 SimulateUsernameChange(kAliceUsername, true); |
1542 // The autofileld password should replace the typed one. | 1544 // The autofileld password should replace the typed one. |
1543 CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true); | 1545 CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true); |
1544 } | 1546 } |
1545 | 1547 |
1546 } // namespace autofill | 1548 } // namespace autofill |
OLD | NEW |