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