summaryrefslogtreecommitdiffstats
path: root/chrome/browser/autofill
diff options
context:
space:
mode:
authordhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-09 15:34:39 +0000
committerdhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-07-09 15:34:39 +0000
commit51c418ffb35b1fa51368e69f3ecad1c4039f41ab (patch)
treea0be9a109e3afc9d901ffef824a6a47a06fbece1 /chrome/browser/autofill
parentc14a8311a11ab8a06f71cd14362498494b56cb39 (diff)
downloadchromium_src-51c418ffb35b1fa51368e69f3ecad1c4039f41ab.zip
chromium_src-51c418ffb35b1fa51368e69f3ecad1c4039f41ab.tar.gz
chromium_src-51c418ffb35b1fa51368e69f3ecad1c4039f41ab.tar.bz2
AutoFill DCHECK in RenderViewHost::AutocompleteSuggestionsReturned fails.
Fixes case where DCHECK was failing in presence of Autocomplete cancel logic. The DCHECK in this case was erroneous. The new logic handles the cancel case appropriately. BUG=none TEST=AutoFillManagerTest.GetFieldSuggestionsForAutocompleteOnly Review URL: http://codereview.chromium.org/2945003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51962 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r--chrome/browser/autofill/autofill_manager_unittest.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
index 1549079..8aeeb25 100644
--- a/chrome/browser/autofill/autofill_manager_unittest.cc
+++ b/chrome/browser/autofill/autofill_manager_unittest.cc
@@ -599,6 +599,42 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsFormIsAutoFilled) {
EXPECT_EQ(string16(), labels[1]);
}
+TEST_F(AutoFillManagerTest, GetFieldSuggestionsForAutocompleteOnly) {
+ FormData form;
+ CreateTestFormData(&form);
+
+ // Set up our FormStructures.
+ std::vector<FormData> forms;
+ forms.push_back(form);
+ autofill_manager_->FormsSeen(forms);
+
+ // The page ID sent to the AutoFillManager from the RenderView, used to send
+ // an IPC message back to the renderer.
+ const int kPageID = 1;
+ const int kAlternatePageID = 0;
+
+ webkit_glue::FormField field;
+ autofill_unittest::CreateTestFormField(
+ "First Name", "firstname", "", "text", &field);
+ EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, true, field));
+
+ // No suggestions provided, so send an empty vector as the results.
+ // This triggers the combined message send.
+ // In this case, we're simulating a cancel of Autocomplete with a different
+ // page ID and an empty vector of suggestions.
+ rvh()->AutocompleteSuggestionsReturned(kAlternatePageID,
+ std::vector<string16>());
+
+ // Test that we sent the right message to the renderer.
+ int page_id = 0;
+ std::vector<string16> values;
+ std::vector<string16> labels;
+ EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels));
+ EXPECT_EQ(kAlternatePageID, page_id);
+ ASSERT_EQ(0U, values.size());
+ ASSERT_EQ(0U, labels.size());
+}
+
TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) {
FormData form;
CreateTestFormData(&form);