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" |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 389 |
390 // Checks the message sent to PasswordAutofillManager to build the suggestion | 390 // Checks the message sent to PasswordAutofillManager to build the suggestion |
391 // list. |username| is the expected username field value, and |show_all| is | 391 // list. |username| is the expected username field value, and |show_all| is |
392 // the expected flag for the PasswordAutofillManager, whether to show all | 392 // the expected flag for the PasswordAutofillManager, whether to show all |
393 // suggestions, or only those starting with |username|. | 393 // suggestions, or only those starting with |username|. |
394 void CheckSuggestions(const std::string& username, bool show_all) { | 394 void CheckSuggestions(const std::string& username, bool show_all) { |
395 const IPC::Message* message = | 395 const IPC::Message* message = |
396 render_thread_->sink().GetFirstMessageMatching( | 396 render_thread_->sink().GetFirstMessageMatching( |
397 AutofillHostMsg_ShowPasswordSuggestions::ID); | 397 AutofillHostMsg_ShowPasswordSuggestions::ID); |
398 EXPECT_TRUE(message); | 398 EXPECT_TRUE(message); |
399 Tuple5<int, base::i18n::TextDirection, base::string16, bool, gfx::RectF> | 399 Tuple5<int, base::i18n::TextDirection, base::string16, int, gfx::RectF> |
400 args; | 400 args; |
401 AutofillHostMsg_ShowPasswordSuggestions::Read(message, &args); | 401 AutofillHostMsg_ShowPasswordSuggestions::Read(message, &args); |
402 EXPECT_EQ(kPasswordFillFormDataId, args.a); | 402 EXPECT_EQ(kPasswordFillFormDataId, args.a); |
403 EXPECT_EQ(ASCIIToUTF16(username), args.c); | 403 EXPECT_EQ(ASCIIToUTF16(username), args.c); |
404 EXPECT_EQ(show_all, args.d); | 404 int options = args.d; |
| 405 EXPECT_EQ(show_all, options & ShowPasswordSuggestionsOptions::SHOW_ALL); |
405 | 406 |
406 render_thread_->sink().ClearMessages(); | 407 render_thread_->sink().ClearMessages(); |
407 } | 408 } |
408 | 409 |
409 void ExpectFormSubmittedWithPasswords(const std::string& password_value, | 410 void ExpectFormSubmittedWithPasswords(const std::string& password_value, |
410 const std::string& new_password_value) { | 411 const std::string& new_password_value) { |
411 const IPC::Message* message = | 412 const IPC::Message* message = |
412 render_thread_->sink().GetFirstMessageMatching( | 413 render_thread_->sink().GetFirstMessageMatching( |
413 AutofillHostMsg_PasswordFormSubmitted::ID); | 414 AutofillHostMsg_PasswordFormSubmitted::ID); |
414 ASSERT_TRUE(message); | 415 ASSERT_TRUE(message); |
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1513 password_element_, | 1514 password_element_, |
1514 /*is_user_input=*/true); | 1515 /*is_user_input=*/true); |
1515 | 1516 |
1516 // Simulate the user typing a stored username. | 1517 // Simulate the user typing a stored username. |
1517 SimulateUsernameChange(kAliceUsername, true); | 1518 SimulateUsernameChange(kAliceUsername, true); |
1518 // The autofileld password should replace the typed one. | 1519 // The autofileld password should replace the typed one. |
1519 CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true); | 1520 CheckTextFieldsDOMState(kAliceUsername, true, kAlicePassword, true); |
1520 } | 1521 } |
1521 | 1522 |
1522 } // namespace autofill | 1523 } // namespace autofill |
OLD | NEW |