diff options
author | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-07 17:50:58 +0000 |
---|---|---|
committer | dhollowa@chromium.org <dhollowa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-07 17:50:58 +0000 |
commit | 33bd60f508a0eaa7ddfefb497b35c1627a6ff0be (patch) | |
tree | 5ccf0d1a06ce8faa8d8bba5dca828ba6485cb4bc /chrome/browser/autofill | |
parent | 3acdf835f850997396ef30c61688a9a2f55fb594 (diff) | |
download | chromium_src-33bd60f508a0eaa7ddfefb497b35c1627a6ff0be.zip chromium_src-33bd60f508a0eaa7ddfefb497b35c1627a6ff0be.tar.gz chromium_src-33bd60f508a0eaa7ddfefb497b35c1627a6ff0be.tar.bz2 |
Autocomplete and AutoFill entries are shown combined in the suggestions popup.
These changes merge popup menu suggestions for Autocomplete and AutoFill. Suggestions are collected from both sources and returned to the renderer as a single list. This combined list is given to WebKit to display in the suggestions popup. When the user selects an item in the popup the appropriate result gets filled in the fields.
BUG=41328
TEST=AutoFillManagerTest.*
Review URL: http://codereview.chromium.org/2878020
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/autofill')
-rw-r--r-- | chrome/browser/autofill/autofill_manager_unittest.cc | 75 |
1 files changed, 75 insertions, 0 deletions
diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc index e989269..1549079 100644 --- a/chrome/browser/autofill/autofill_manager_unittest.cc +++ b/chrome/browser/autofill/autofill_manager_unittest.cc @@ -285,6 +285,10 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsEmptyValue) { "First Name", "firstname", "", "text", &field); EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); + // No suggestions provided, so send an empty vector as the results. + // This triggers the combined message send. + rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); + // Test that we sent the right message to the renderer. int page_id = 0; std::vector<string16> values; @@ -317,6 +321,10 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsMatchCharacter) { "First Name", "firstname", "E", "text", &field); EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); + // No suggestions provided, so send an empty vector as the results. + // This triggers the combined message send. + rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); + // Test that we sent the right message to the renderer. int page_id = 0; std::vector<string16> values; @@ -347,6 +355,10 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) { "Card Number", "cardnumber", "", "text", &field); EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); + // No suggestions provided, so send an empty vector as the results. + // This triggers the combined message send. + rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); + // Test that we sent the right message to the renderer. int page_id = 0; std::vector<string16> values; @@ -387,6 +399,10 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) { "Card Number", "cardnumber", "1", "text", &field); EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); + // No suggestions provided, so send an empty vector as the results. + // This triggers the combined message send. + rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); + // Test that we sent the right message to the renderer. int page_id = 0; std::vector<string16> values; @@ -421,6 +437,10 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) { "Name on Card", "nameoncard", "", "text", &field); EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); + // No suggestions provided, so send an empty vector as the results. + // This triggers the combined message send. + rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); + // Test that we sent the right message to the renderer. int page_id = 0; std::vector<string16> values; @@ -470,6 +490,10 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsSemicolon) { "Name on Card", "nameoncard", "", "text", &field); EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); + // No suggestions provided, so send an empty vector as the results. + // This triggers the combined message send. + rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); + // Test that we sent the right message to the renderer. int page_id = 0; std::vector<string16> values; @@ -496,6 +520,49 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsSemicolon) { EXPECT_EQ(ASCIIToUTF16("Home; 8765; 8765"), labels[7]); } +TEST_F(AutoFillManagerTest, GetCombinedAutoFillAndAutocompleteSuggestions) { + 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; + + webkit_glue::FormField field; + autofill_unittest::CreateTestFormField( + "First Name", "firstname", "", "text", &field); + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field)); + + // Add some Autocomplete suggestions. + // This triggers the combined message send. + std::vector<string16> suggestions; + suggestions.push_back(ASCIIToUTF16("Jay")); + suggestions.push_back(ASCIIToUTF16("Jason")); + rvh()->AutocompleteSuggestionsReturned(kPageID, suggestions); + + // 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(kPageID, page_id); + ASSERT_EQ(4U, values.size()); + EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]); + EXPECT_EQ(ASCIIToUTF16("Charles"), values[1]); + EXPECT_EQ(ASCIIToUTF16("Jay"), values[2]); + EXPECT_EQ(ASCIIToUTF16("Jason"), values[3]); + ASSERT_EQ(4U, labels.size()); + EXPECT_EQ(ASCIIToUTF16("Home"), labels[0]); + EXPECT_EQ(ASCIIToUTF16("Work"), labels[1]); + EXPECT_EQ(string16(), labels[2]); + EXPECT_EQ(string16(), labels[3]); +} + TEST_F(AutoFillManagerTest, GetFieldSuggestionsFormIsAutoFilled) { FormData form; CreateTestFormData(&form); @@ -514,6 +581,10 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsFormIsAutoFilled) { "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. + rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); + // Test that we sent the right message to the renderer. int page_id = 0; std::vector<string16> values; @@ -552,6 +623,10 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) { "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. + rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>()); + // Test that we sent the right message to the renderer. int page_id = 0; std::vector<string16> values; |