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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/autofill/autocomplete_history_manager.h" | 10 #include "chrome/browser/autofill/autocomplete_history_manager.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 form.user_submitted = true; | 69 form.user_submitted = true; |
70 | 70 |
71 // Valid Visa credit card number pulled from the paypal help site. | 71 // Valid Visa credit card number pulled from the paypal help site. |
72 FormFieldData valid_cc; | 72 FormFieldData valid_cc; |
73 valid_cc.label = ASCIIToUTF16("Credit Card"); | 73 valid_cc.label = ASCIIToUTF16("Credit Card"); |
74 valid_cc.name = ASCIIToUTF16("ccnum"); | 74 valid_cc.name = ASCIIToUTF16("ccnum"); |
75 valid_cc.value = ASCIIToUTF16("4012888888881881"); | 75 valid_cc.value = ASCIIToUTF16("4012888888881881"); |
76 valid_cc.form_control_type = "text"; | 76 valid_cc.form_control_type = "text"; |
77 form.fields.push_back(valid_cc); | 77 form.fields.push_back(valid_cc); |
78 | 78 |
79 EXPECT_CALL(*web_data_service_, AddFormFields(_)).Times(0); | 79 EXPECT_CALL(*web_data_service_.get(), AddFormFields(_)).Times(0); |
80 autocomplete_manager_->OnFormSubmitted(form); | 80 autocomplete_manager_->OnFormSubmitted(form); |
81 } | 81 } |
82 | 82 |
83 // Contrary test to AutocompleteHistoryManagerTest.CreditCardNumberValue. The | 83 // Contrary test to AutocompleteHistoryManagerTest.CreditCardNumberValue. The |
84 // value being submitted is not a valid credit card number, so it will be sent | 84 // value being submitted is not a valid credit card number, so it will be sent |
85 // to the WebDatabase to be saved. | 85 // to the WebDatabase to be saved. |
86 TEST_F(AutocompleteHistoryManagerTest, NonCreditCardNumberValue) { | 86 TEST_F(AutocompleteHistoryManagerTest, NonCreditCardNumberValue) { |
87 FormData form; | 87 FormData form; |
88 form.name = ASCIIToUTF16("MyForm"); | 88 form.name = ASCIIToUTF16("MyForm"); |
89 form.method = ASCIIToUTF16("POST"); | 89 form.method = ASCIIToUTF16("POST"); |
(...skipping 22 matching lines...) Expand all Loading... |
112 form.action = GURL("http://myform.com/submit.html"); | 112 form.action = GURL("http://myform.com/submit.html"); |
113 form.user_submitted = true; | 113 form.user_submitted = true; |
114 | 114 |
115 FormFieldData ssn; | 115 FormFieldData ssn; |
116 ssn.label = ASCIIToUTF16("Social Security Number"); | 116 ssn.label = ASCIIToUTF16("Social Security Number"); |
117 ssn.name = ASCIIToUTF16("ssn"); | 117 ssn.name = ASCIIToUTF16("ssn"); |
118 ssn.value = ASCIIToUTF16("078-05-1120"); | 118 ssn.value = ASCIIToUTF16("078-05-1120"); |
119 ssn.form_control_type = "text"; | 119 ssn.form_control_type = "text"; |
120 form.fields.push_back(ssn); | 120 form.fields.push_back(ssn); |
121 | 121 |
122 EXPECT_CALL(*web_data_service_, AddFormFields(_)).Times(0); | 122 EXPECT_CALL(*web_data_service_.get(), AddFormFields(_)).Times(0); |
123 autocomplete_manager_->OnFormSubmitted(form); | 123 autocomplete_manager_->OnFormSubmitted(form); |
124 } | 124 } |
125 | 125 |
126 // Verify that autocomplete text is saved for search fields. | 126 // Verify that autocomplete text is saved for search fields. |
127 TEST_F(AutocompleteHistoryManagerTest, SearchField) { | 127 TEST_F(AutocompleteHistoryManagerTest, SearchField) { |
128 FormData form; | 128 FormData form; |
129 form.name = ASCIIToUTF16("MyForm"); | 129 form.name = ASCIIToUTF16("MyForm"); |
130 form.method = ASCIIToUTF16("POST"); | 130 form.method = ASCIIToUTF16("POST"); |
131 form.origin = GURL("http://myform.com/form.html"); | 131 form.origin = GURL("http://myform.com/form.html"); |
132 form.action = GURL("http://myform.com/submit.html"); | 132 form.action = GURL("http://myform.com/submit.html"); |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 scoped_ptr<AutofillWebDataService>( | 192 scoped_ptr<AutofillWebDataService>( |
193 new AutofillWebDataServiceImpl(web_data_service_))); | 193 new AutofillWebDataServiceImpl(web_data_service_))); |
194 | 194 |
195 MockAutofillExternalDelegate external_delegate(web_contents()); | 195 MockAutofillExternalDelegate external_delegate(web_contents()); |
196 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); | 196 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); |
197 autocomplete_history_manager.SetExternalDelegate(&external_delegate); | 197 autocomplete_history_manager.SetExternalDelegate(&external_delegate); |
198 | 198 |
199 // Should trigger a call to OnSuggestionsReturned, verified by the mock. | 199 // Should trigger a call to OnSuggestionsReturned, verified by the mock. |
200 autocomplete_history_manager.SendSuggestions(NULL); | 200 autocomplete_history_manager.SendSuggestions(NULL); |
201 } | 201 } |
OLD | NEW |