| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 virtual void OnInsufficientFormData() OVERRIDE { | 128 virtual void OnInsufficientFormData() OVERRIDE { |
| 129 OnPersonalDataChanged(); | 129 OnPersonalDataChanged(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 // content::NotificationObserver: | 132 // content::NotificationObserver: |
| 133 virtual void Observe(int type, | 133 virtual void Observe(int type, |
| 134 const content::NotificationSource& source, | 134 const content::NotificationSource& source, |
| 135 const content::NotificationDetails& details) OVERRIDE { | 135 const content::NotificationDetails& details) OVERRIDE { |
| 136 // Accept in the infobar. | 136 // Accept in the infobar. |
| 137 infobar_service_ = | 137 infobar_service_ = |
| 138 InfoBarService::ForTab(chrome::GetActiveTabContents(browser_)); | 138 InfoBarService::FromTabContents(chrome::GetActiveTabContents(browser_)); |
| 139 InfoBarDelegate* infobar = infobar_service_->GetInfoBarDelegateAt(0); | 139 InfoBarDelegate* infobar = infobar_service_->GetInfoBarDelegateAt(0); |
| 140 | 140 |
| 141 ConfirmInfoBarDelegate* confirm_infobar = | 141 ConfirmInfoBarDelegate* confirm_infobar = |
| 142 infobar->AsConfirmInfoBarDelegate(); | 142 infobar->AsConfirmInfoBarDelegate(); |
| 143 confirm_infobar->Accept(); | 143 confirm_infobar->Accept(); |
| 144 } | 144 } |
| 145 | 145 |
| 146 private: | 146 private: |
| 147 bool alerted_; | 147 bool alerted_; |
| 148 bool has_run_message_loop_; | 148 bool has_run_message_loop_; |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 " <input type=\"text\" id=\"ph\"><br>" | 834 " <input type=\"text\" id=\"ph\"><br>" |
| 835 "</form>"); | 835 "</form>"); |
| 836 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); | 836 ASSERT_TRUE(ui_test_utils::BringBrowserWindowToFront(browser())); |
| 837 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url)); | 837 ASSERT_NO_FATAL_FAILURE(ui_test_utils::NavigateToURL(browser(), url)); |
| 838 | 838 |
| 839 // Get translation bar. | 839 // Get translation bar. |
| 840 RenderViewHostTester::TestOnMessageReceived( | 840 RenderViewHostTester::TestOnMessageReceived( |
| 841 render_view_host(), | 841 render_view_host(), |
| 842 ChromeViewHostMsg_TranslateLanguageDetermined(0, "ja", true)); | 842 ChromeViewHostMsg_TranslateLanguageDetermined(0, "ja", true)); |
| 843 TranslateInfoBarDelegate* infobar = | 843 TranslateInfoBarDelegate* infobar = |
| 844 InfoBarService::ForTab(chrome::GetActiveTabContents(browser()))-> | 844 InfoBarService::FromTabContents(chrome::GetActiveTabContents(browser()))-> |
| 845 GetInfoBarDelegateAt(0)->AsTranslateInfoBarDelegate(); | 845 GetInfoBarDelegateAt(0)->AsTranslateInfoBarDelegate(); |
| 846 | 846 |
| 847 ASSERT_TRUE(infobar != NULL); | 847 ASSERT_TRUE(infobar != NULL); |
| 848 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); | 848 EXPECT_EQ(TranslateInfoBarDelegate::BEFORE_TRANSLATE, infobar->type()); |
| 849 | 849 |
| 850 // Simulate translation button press. | 850 // Simulate translation button press. |
| 851 infobar->Translate(); | 851 infobar->Translate(); |
| 852 | 852 |
| 853 // Simulate the translate script being retrieved. | 853 // Simulate the translate script being retrieved. |
| 854 // Pass fake google.translate lib as the translate script. | 854 // Pass fake google.translate lib as the translate script. |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1008 // Test credit card info with an invalid number is not aggregated. | 1008 // Test credit card info with an invalid number is not aggregated. |
| 1009 // When filling out a form with an invalid credit card number (one that does not | 1009 // When filling out a form with an invalid credit card number (one that does not |
| 1010 // pass the Luhn test) the credit card info should not be saved into Autofill | 1010 // pass the Luhn test) the credit card info should not be saved into Autofill |
| 1011 // preferences. | 1011 // preferences. |
| 1012 IN_PROC_BROWSER_TEST_F(AutofillTest, InvalidCreditCardNumberIsNotAggregated) { | 1012 IN_PROC_BROWSER_TEST_F(AutofillTest, InvalidCreditCardNumberIsNotAggregated) { |
| 1013 ASSERT_TRUE(test_server()->Start()); | 1013 ASSERT_TRUE(test_server()->Start()); |
| 1014 std::string card("4408 0412 3456 7890"); | 1014 std::string card("4408 0412 3456 7890"); |
| 1015 ASSERT_FALSE(CreditCard::IsValidCreditCardNumber(ASCIIToUTF16(card))); | 1015 ASSERT_FALSE(CreditCard::IsValidCreditCardNumber(ASCIIToUTF16(card))); |
| 1016 SubmitCreditCard("Bob Smith", card.c_str(), "12", "2014"); | 1016 SubmitCreditCard("Bob Smith", card.c_str(), "12", "2014"); |
| 1017 ASSERT_EQ(0u, | 1017 ASSERT_EQ(0u, |
| 1018 InfoBarService::ForTab(chrome::GetActiveTabContents(browser()))-> | 1018 InfoBarService::FromTabContents( |
| 1019 GetInfoBarCount()); | 1019 chrome::GetActiveTabContents(browser()))->GetInfoBarCount()); |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 // Test whitespaces and separator chars are stripped for valid CC numbers. | 1022 // Test whitespaces and separator chars are stripped for valid CC numbers. |
| 1023 // The credit card numbers used in this test pass the Luhn test. For reference: | 1023 // The credit card numbers used in this test pass the Luhn test. For reference: |
| 1024 // http://www.merriampark.com/anatomycc.htm | 1024 // http://www.merriampark.com/anatomycc.htm |
| 1025 IN_PROC_BROWSER_TEST_F(AutofillTest, | 1025 IN_PROC_BROWSER_TEST_F(AutofillTest, |
| 1026 WhitespacesAndSeparatorCharsStrippedForValidCCNums) { | 1026 WhitespacesAndSeparatorCharsStrippedForValidCCNums) { |
| 1027 ASSERT_TRUE(test_server()->Start()); | 1027 ASSERT_TRUE(test_server()->Start()); |
| 1028 SubmitCreditCard("Bob Smith", "4408 0412 3456 7893", "12", "2014"); | 1028 SubmitCreditCard("Bob Smith", "4408 0412 3456 7893", "12", "2014"); |
| 1029 SubmitCreditCard("Jane Doe", "4417-1234-5678-9113", "10", "2013"); | 1029 SubmitCreditCard("Jane Doe", "4417-1234-5678-9113", "10", "2013"); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1222 IN_PROC_BROWSER_TEST_F(AutofillTest, CCInfoNotStoredWhenAutocompleteOff) { | 1222 IN_PROC_BROWSER_TEST_F(AutofillTest, CCInfoNotStoredWhenAutocompleteOff) { |
| 1223 ASSERT_TRUE(test_server()->Start()); | 1223 ASSERT_TRUE(test_server()->Start()); |
| 1224 FormMap data; | 1224 FormMap data; |
| 1225 data["CREDIT_CARD_NAME"] = "Bob Smith"; | 1225 data["CREDIT_CARD_NAME"] = "Bob Smith"; |
| 1226 data["CREDIT_CARD_NUMBER"] = "4408041234567893"; | 1226 data["CREDIT_CARD_NUMBER"] = "4408041234567893"; |
| 1227 data["CREDIT_CARD_EXP_MONTH"] = "12"; | 1227 data["CREDIT_CARD_EXP_MONTH"] = "12"; |
| 1228 data["CREDIT_CARD_EXP_4_DIGIT_YEAR"] = "2014"; | 1228 data["CREDIT_CARD_EXP_4_DIGIT_YEAR"] = "2014"; |
| 1229 FillFormAndSubmit("cc_autocomplete_off_test.html", data); | 1229 FillFormAndSubmit("cc_autocomplete_off_test.html", data); |
| 1230 | 1230 |
| 1231 ASSERT_EQ(0u, | 1231 ASSERT_EQ(0u, |
| 1232 InfoBarService::ForTab(chrome::GetActiveTabContents(browser()))-> | 1232 InfoBarService::FromTabContents( |
| 1233 GetInfoBarCount()); | 1233 chrome::GetActiveTabContents(browser()))->GetInfoBarCount()); |
| 1234 } | 1234 } |
| 1235 | 1235 |
| 1236 // Test that Autofill does not fill in read-only fields. | 1236 // Test that Autofill does not fill in read-only fields. |
| 1237 IN_PROC_BROWSER_TEST_F(AutofillTest, NoAutofillForReadOnlyFields) { | 1237 IN_PROC_BROWSER_TEST_F(AutofillTest, NoAutofillForReadOnlyFields) { |
| 1238 ASSERT_TRUE(test_server()->Start()); | 1238 ASSERT_TRUE(test_server()->Start()); |
| 1239 | 1239 |
| 1240 std::string addr_line1("1234 H St."); | 1240 std::string addr_line1("1234 H St."); |
| 1241 | 1241 |
| 1242 AutofillProfile profile; | 1242 AutofillProfile profile; |
| 1243 profile.SetInfo(NAME_FIRST, ASCIIToUTF16("Bob")); | 1243 profile.SetInfo(NAME_FIRST, ASCIIToUTF16("Bob")); |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 | 1441 |
| 1442 // Test Autofill ability to merge duplicate profiles and throw away junk. | 1442 // Test Autofill ability to merge duplicate profiles and throw away junk. |
| 1443 // TODO(isherman): this looks redundant, consider removing. | 1443 // TODO(isherman): this looks redundant, consider removing. |
| 1444 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_MergeAggregatedDuplicatedProfiles) { | 1444 IN_PROC_BROWSER_TEST_F(AutofillTest, MAYBE_MergeAggregatedDuplicatedProfiles) { |
| 1445 int num_of_profiles = | 1445 int num_of_profiles = |
| 1446 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); | 1446 AggregateProfilesIntoAutofillPrefs("dataset_no_address.txt"); |
| 1447 | 1447 |
| 1448 ASSERT_GT(num_of_profiles, | 1448 ASSERT_GT(num_of_profiles, |
| 1449 static_cast<int>(personal_data_manager()->profiles().size())); | 1449 static_cast<int>(personal_data_manager()->profiles().size())); |
| 1450 } | 1450 } |
| OLD | NEW |