| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/ref_counted.h" | 7 #include "base/ref_counted.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/task.h" | 9 #include "base/task.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_; | 44 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_; |
| 45 }; | 45 }; |
| 46 | 46 |
| 47 // Tests that credit card numbers are not sent to the WebDatabase to be saved. | 47 // Tests that credit card numbers are not sent to the WebDatabase to be saved. |
| 48 TEST_F(AutocompleteHistoryManagerTest, CreditCardNumberValue) { | 48 TEST_F(AutocompleteHistoryManagerTest, CreditCardNumberValue) { |
| 49 FormData form; | 49 FormData form; |
| 50 form.name = ASCIIToUTF16("MyForm"); | 50 form.name = ASCIIToUTF16("MyForm"); |
| 51 form.method = ASCIIToUTF16("POST"); | 51 form.method = ASCIIToUTF16("POST"); |
| 52 form.origin = GURL("http://myform.com/form.html"); | 52 form.origin = GURL("http://myform.com/form.html"); |
| 53 form.action = GURL("http://myform.com/submit.html"); | 53 form.action = GURL("http://myform.com/submit.html"); |
| 54 form.user_submitted = true; |
| 54 | 55 |
| 55 // Valid Visa credit card number pulled from the paypal help site. | 56 // Valid Visa credit card number pulled from the paypal help site. |
| 56 webkit_glue::FormField valid_cc(ASCIIToUTF16("Credit Card"), | 57 webkit_glue::FormField valid_cc(ASCIIToUTF16("Credit Card"), |
| 57 ASCIIToUTF16("ccnum"), | 58 ASCIIToUTF16("ccnum"), |
| 58 ASCIIToUTF16("4012888888881881"), | 59 ASCIIToUTF16("4012888888881881"), |
| 59 ASCIIToUTF16("text"), | 60 ASCIIToUTF16("text"), |
| 60 20); | 61 20); |
| 61 form.fields.push_back(valid_cc); | 62 form.fields.push_back(valid_cc); |
| 62 | 63 |
| 63 EXPECT_CALL(*web_data_service_, AddFormFields(_)).Times(0); | 64 EXPECT_CALL(*web_data_service_, AddFormFields(_)).Times(0); |
| 64 autocomplete_manager_->FormSubmitted(form); | 65 autocomplete_manager_->FormSubmitted(form); |
| 65 } | 66 } |
| 66 | 67 |
| 67 // Contrary test to AutocompleteHistoryManagerTest.CreditCardNumberValue. The | 68 // Contrary test to AutocompleteHistoryManagerTest.CreditCardNumberValue. The |
| 68 // value being submitted is not a valid credit card number, so it will be sent | 69 // value being submitted is not a valid credit card number, so it will be sent |
| 69 // to the WebDatabase to be saved. | 70 // to the WebDatabase to be saved. |
| 70 TEST_F(AutocompleteHistoryManagerTest, NonCreditCardNumberValue) { | 71 TEST_F(AutocompleteHistoryManagerTest, NonCreditCardNumberValue) { |
| 71 FormData form; | 72 FormData form; |
| 72 form.name = ASCIIToUTF16("MyForm"); | 73 form.name = ASCIIToUTF16("MyForm"); |
| 73 form.method = ASCIIToUTF16("POST"); | 74 form.method = ASCIIToUTF16("POST"); |
| 74 form.origin = GURL("http://myform.com/form.html"); | 75 form.origin = GURL("http://myform.com/form.html"); |
| 75 form.action = GURL("http://myform.com/submit.html"); | 76 form.action = GURL("http://myform.com/submit.html"); |
| 77 form.user_submitted = true; |
| 76 | 78 |
| 77 // Invalid credit card number. | 79 // Invalid credit card number. |
| 78 webkit_glue::FormField invalid_cc(ASCIIToUTF16("Credit Card"), | 80 webkit_glue::FormField invalid_cc(ASCIIToUTF16("Credit Card"), |
| 79 ASCIIToUTF16("ccnum"), | 81 ASCIIToUTF16("ccnum"), |
| 80 ASCIIToUTF16("4580123456789012"), | 82 ASCIIToUTF16("4580123456789012"), |
| 81 ASCIIToUTF16("text"), | 83 ASCIIToUTF16("text"), |
| 82 20); | 84 20); |
| 83 form.fields.push_back(invalid_cc); | 85 form.fields.push_back(invalid_cc); |
| 84 | 86 |
| 85 EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1); | 87 EXPECT_CALL(*(web_data_service_.get()), AddFormFields(_)).Times(1); |
| 86 autocomplete_manager_->FormSubmitted(form); | 88 autocomplete_manager_->FormSubmitted(form); |
| 87 } | 89 } |
| 88 | 90 |
| 89 // Tests that SSNs are not sent to the WebDatabase to be saved. | 91 // Tests that SSNs are not sent to the WebDatabase to be saved. |
| 90 TEST_F(AutocompleteHistoryManagerTest, SSNValue) { | 92 TEST_F(AutocompleteHistoryManagerTest, SSNValue) { |
| 91 FormData form; | 93 FormData form; |
| 92 form.name = ASCIIToUTF16("MyForm"); | 94 form.name = ASCIIToUTF16("MyForm"); |
| 93 form.method = ASCIIToUTF16("POST"); | 95 form.method = ASCIIToUTF16("POST"); |
| 94 form.origin = GURL("http://myform.com/form.html"); | 96 form.origin = GURL("http://myform.com/form.html"); |
| 95 form.action = GURL("http://myform.com/submit.html"); | 97 form.action = GURL("http://myform.com/submit.html"); |
| 98 form.user_submitted = true; |
| 96 | 99 |
| 97 webkit_glue::FormField ssn(ASCIIToUTF16("Social Security Number"), | 100 webkit_glue::FormField ssn(ASCIIToUTF16("Social Security Number"), |
| 98 ASCIIToUTF16("ssn"), | 101 ASCIIToUTF16("ssn"), |
| 99 ASCIIToUTF16("078-05-1120"), | 102 ASCIIToUTF16("078-05-1120"), |
| 100 ASCIIToUTF16("text"), | 103 ASCIIToUTF16("text"), |
| 101 20); | 104 20); |
| 102 form.fields.push_back(ssn); | 105 form.fields.push_back(ssn); |
| 103 | 106 |
| 104 EXPECT_CALL(*web_data_service_, AddFormFields(_)).Times(0); | 107 EXPECT_CALL(*web_data_service_, AddFormFields(_)).Times(0); |
| 105 autocomplete_manager_->FormSubmitted(form); | 108 autocomplete_manager_->FormSubmitted(form); |
| 106 } | 109 } |
| OLD | NEW |