Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(347)

Side by Side Diff: chrome/renderer/autofill/password_autofill_agent_browsertest.cc

Issue 1159553007: Move Tuple to base namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 383
384 // Checks the message sent to PasswordAutofillManager to build the suggestion 384 // Checks the message sent to PasswordAutofillManager to build the suggestion
385 // list. |username| is the expected username field value, and |show_all| is 385 // list. |username| is the expected username field value, and |show_all| is
386 // the expected flag for the PasswordAutofillManager, whether to show all 386 // the expected flag for the PasswordAutofillManager, whether to show all
387 // suggestions, or only those starting with |username|. 387 // suggestions, or only those starting with |username|.
388 void CheckSuggestions(const std::string& username, bool show_all) { 388 void CheckSuggestions(const std::string& username, bool show_all) {
389 const IPC::Message* message = 389 const IPC::Message* message =
390 render_thread_->sink().GetFirstMessageMatching( 390 render_thread_->sink().GetFirstMessageMatching(
391 AutofillHostMsg_ShowPasswordSuggestions::ID); 391 AutofillHostMsg_ShowPasswordSuggestions::ID);
392 EXPECT_TRUE(message); 392 EXPECT_TRUE(message);
393 Tuple<int, base::i18n::TextDirection, base::string16, int, gfx::RectF> 393 base::Tuple<int, base::i18n::TextDirection, base::string16, int, gfx::RectF>
394 args; 394 args;
395 AutofillHostMsg_ShowPasswordSuggestions::Read(message, &args); 395 AutofillHostMsg_ShowPasswordSuggestions::Read(message, &args);
396 EXPECT_EQ(kPasswordFillFormDataId, get<0>(args)); 396 EXPECT_EQ(kPasswordFillFormDataId, base::get<0>(args));
397 EXPECT_EQ(ASCIIToUTF16(username), get<2>(args)); 397 EXPECT_EQ(ASCIIToUTF16(username), base::get<2>(args));
398 EXPECT_EQ(show_all, static_cast<bool>(get<3>(args) & autofill::SHOW_ALL)); 398 EXPECT_EQ(show_all,
399 static_cast<bool>(base::get<3>(args) & autofill::SHOW_ALL));
399 400
400 render_thread_->sink().ClearMessages(); 401 render_thread_->sink().ClearMessages();
401 } 402 }
402 403
403 void ExpectFormSubmittedWithUsernameAndPasswords( 404 void ExpectFormSubmittedWithUsernameAndPasswords(
404 const std::string& username_value, 405 const std::string& username_value,
405 const std::string& password_value, 406 const std::string& password_value,
406 const std::string& new_password_value) { 407 const std::string& new_password_value) {
407 const IPC::Message* message = 408 const IPC::Message* message =
408 render_thread_->sink().GetFirstMessageMatching( 409 render_thread_->sink().GetFirstMessageMatching(
409 AutofillHostMsg_PasswordFormSubmitted::ID); 410 AutofillHostMsg_PasswordFormSubmitted::ID);
410 ASSERT_TRUE(message); 411 ASSERT_TRUE(message);
411 Tuple<autofill::PasswordForm> args; 412 base::Tuple<autofill::PasswordForm> args;
412 AutofillHostMsg_PasswordFormSubmitted::Read(message, &args); 413 AutofillHostMsg_PasswordFormSubmitted::Read(message, &args);
413 EXPECT_EQ(ASCIIToUTF16(username_value), get<0>(args).username_value); 414 EXPECT_EQ(ASCIIToUTF16(username_value), base::get<0>(args).username_value);
414 EXPECT_EQ(ASCIIToUTF16(password_value), get<0>(args).password_value); 415 EXPECT_EQ(ASCIIToUTF16(password_value), base::get<0>(args).password_value);
415 EXPECT_EQ(ASCIIToUTF16(new_password_value), 416 EXPECT_EQ(ASCIIToUTF16(new_password_value),
416 get<0>(args).new_password_value); 417 base::get<0>(args).new_password_value);
417 } 418 }
418 419
419 base::string16 username1_; 420 base::string16 username1_;
420 base::string16 username2_; 421 base::string16 username2_;
421 base::string16 username3_; 422 base::string16 username3_;
422 base::string16 password1_; 423 base::string16 password1_;
423 base::string16 password2_; 424 base::string16 password2_;
424 base::string16 password3_; 425 base::string16 password3_;
425 base::string16 alternate_username3_; 426 base::string16 alternate_username3_;
426 PasswordFormFillData fill_data_; 427 PasswordFormFillData fill_data_;
(...skipping 14 matching lines...) Expand all
441 * returns false. May be we should mock URL loading to cirmcuvent this? 442 * returns false. May be we should mock URL loading to cirmcuvent this?
442 TODO(jcivelli): find a way to make the security origin not deny access to the 443 TODO(jcivelli): find a way to make the security origin not deny access to the
443 password manager and then reenable this code. 444 password manager and then reenable this code.
444 445
445 // The form has been loaded, we should have sent the browser a message about 446 // The form has been loaded, we should have sent the browser a message about
446 // the form. 447 // the form.
447 const IPC::Message* msg = render_thread_.sink().GetFirstMessageMatching( 448 const IPC::Message* msg = render_thread_.sink().GetFirstMessageMatching(
448 AutofillHostMsg_PasswordFormsParsed::ID); 449 AutofillHostMsg_PasswordFormsParsed::ID);
449 ASSERT_TRUE(msg != NULL); 450 ASSERT_TRUE(msg != NULL);
450 451
451 Tuple1<std::vector<PasswordForm> > forms; 452 base::Tuple1<std::vector<PasswordForm> > forms;
452 AutofillHostMsg_PasswordFormsParsed::Read(msg, &forms); 453 AutofillHostMsg_PasswordFormsParsed::Read(msg, &forms);
453 ASSERT_EQ(1U, forms.a.size()); 454 ASSERT_EQ(1U, forms.a.size());
454 PasswordForm password_form = forms.a[0]; 455 PasswordForm password_form = forms.a[0];
455 EXPECT_EQ(PasswordForm::SCHEME_HTML, password_form.scheme); 456 EXPECT_EQ(PasswordForm::SCHEME_HTML, password_form.scheme);
456 EXPECT_EQ(ASCIIToUTF16(kUsernameName), password_form.username_element); 457 EXPECT_EQ(ASCIIToUTF16(kUsernameName), password_form.username_element);
457 EXPECT_EQ(ASCIIToUTF16(kPasswordName), password_form.password_element); 458 EXPECT_EQ(ASCIIToUTF16(kPasswordName), password_form.password_element);
458 */ 459 */
459 460
460 // Simulate the browser sending back the login info, it triggers the 461 // Simulate the browser sending back the login info, it triggers the
461 // autocomplete. 462 // autocomplete.
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 ASSERT_EQ(1u, forms3.size()); 769 ASSERT_EQ(1u, forms3.size());
769 EXPECT_FALSE(IsWebNodeVisible(forms3[0])); 770 EXPECT_FALSE(IsWebNodeVisible(forms3[0]));
770 } 771 }
771 772
772 TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest) { 773 TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest) {
773 render_thread_->sink().ClearMessages(); 774 render_thread_->sink().ClearMessages();
774 LoadHTML(kVisibleFormWithNoUsernameHTML); 775 LoadHTML(kVisibleFormWithNoUsernameHTML);
775 const IPC::Message* message = render_thread_->sink() 776 const IPC::Message* message = render_thread_->sink()
776 .GetFirstMessageMatching(AutofillHostMsg_PasswordFormsRendered::ID); 777 .GetFirstMessageMatching(AutofillHostMsg_PasswordFormsRendered::ID);
777 EXPECT_TRUE(message); 778 EXPECT_TRUE(message);
778 Tuple<std::vector<autofill::PasswordForm>, bool> param; 779 base::Tuple<std::vector<autofill::PasswordForm>, bool> param;
779 AutofillHostMsg_PasswordFormsRendered::Read(message, &param); 780 AutofillHostMsg_PasswordFormsRendered::Read(message, &param);
780 EXPECT_TRUE(get<0>(param).size()); 781 EXPECT_TRUE(base::get<0>(param).size());
781 782
782 render_thread_->sink().ClearMessages(); 783 render_thread_->sink().ClearMessages();
783 LoadHTML(kEmptyFormHTML); 784 LoadHTML(kEmptyFormHTML);
784 message = render_thread_->sink().GetFirstMessageMatching( 785 message = render_thread_->sink().GetFirstMessageMatching(
785 AutofillHostMsg_PasswordFormsRendered::ID); 786 AutofillHostMsg_PasswordFormsRendered::ID);
786 EXPECT_TRUE(message); 787 EXPECT_TRUE(message);
787 AutofillHostMsg_PasswordFormsRendered::Read(message, &param); 788 AutofillHostMsg_PasswordFormsRendered::Read(message, &param);
788 EXPECT_FALSE(get<0>(param).size()); 789 EXPECT_FALSE(base::get<0>(param).size());
789 790
790 render_thread_->sink().ClearMessages(); 791 render_thread_->sink().ClearMessages();
791 LoadHTML(kNonVisibleFormHTML); 792 LoadHTML(kNonVisibleFormHTML);
792 message = render_thread_->sink().GetFirstMessageMatching( 793 message = render_thread_->sink().GetFirstMessageMatching(
793 AutofillHostMsg_PasswordFormsRendered::ID); 794 AutofillHostMsg_PasswordFormsRendered::ID);
794 EXPECT_TRUE(message); 795 EXPECT_TRUE(message);
795 AutofillHostMsg_PasswordFormsRendered::Read(message, &param); 796 AutofillHostMsg_PasswordFormsRendered::Read(message, &param);
796 EXPECT_FALSE(get<0>(param).size()); 797 EXPECT_FALSE(base::get<0>(param).size());
797 } 798 }
798 799
799 TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest_Redirection) { 800 TEST_F(PasswordAutofillAgentTest, SendPasswordFormsTest_Redirection) {
800 render_thread_->sink().ClearMessages(); 801 render_thread_->sink().ClearMessages();
801 LoadHTML(kEmptyWebpage); 802 LoadHTML(kEmptyWebpage);
802 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching( 803 EXPECT_FALSE(render_thread_->sink().GetFirstMessageMatching(
803 AutofillHostMsg_PasswordFormsRendered::ID)); 804 AutofillHostMsg_PasswordFormsRendered::ID));
804 805
805 render_thread_->sink().ClearMessages(); 806 render_thread_->sink().ClearMessages();
806 LoadHTML(kRedirectionWebpage); 807 LoadHTML(kRedirectionWebpage);
(...skipping 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 SetElementReadOnly(password_element_, true); 1877 SetElementReadOnly(password_element_, true);
1877 static_cast<content::RenderFrameObserver*>(password_autofill_agent_) 1878 static_cast<content::RenderFrameObserver*>(password_autofill_agent_)
1878 ->WillSubmitForm(username_element_.form()); 1879 ->WillSubmitForm(username_element_.form());
1879 1880
1880 // Observe that the PasswordAutofillAgent can correctly process submitted 1881 // Observe that the PasswordAutofillAgent can correctly process submitted
1881 // form. 1882 // form.
1882 ExpectFormSubmittedWithUsernameAndPasswords("temp", "random", ""); 1883 ExpectFormSubmittedWithUsernameAndPasswords("temp", "random", "");
1883 } 1884 }
1884 1885
1885 } // namespace autofill 1886 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698