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