| Index: chrome/browser/autofill/autofill_manager_unittest.cc
|
| diff --git a/chrome/browser/autofill/autofill_manager_unittest.cc b/chrome/browser/autofill/autofill_manager_unittest.cc
|
| index 264dc808f15d1f7cc1ab1b488d056fdba511a5e2..20cf0e673cf0797fb439b830808462df71be3497 100644
|
| --- a/chrome/browser/autofill/autofill_manager_unittest.cc
|
| +++ b/chrome/browser/autofill/autofill_manager_unittest.cc
|
| @@ -4,6 +4,7 @@
|
|
|
| #include <vector>
|
|
|
| +#include "app/l10n_util.h"
|
| #include "base/ref_counted.h"
|
| #include "base/scoped_ptr.h"
|
| #include "base/scoped_vector.h"
|
| @@ -23,6 +24,7 @@
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/render_messages.h"
|
| #include "googleurl/src/gurl.h"
|
| +#include "grit/generated_resources.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| #include "webkit/glue/form_data.h"
|
| #include "webkit/glue/form_field.h"
|
| @@ -59,6 +61,14 @@ class TestPersonalDataManager : public PersonalDataManager {
|
| web_profiles_->push_back(profile);
|
| }
|
|
|
| + void ClearAutoFillProfiles() {
|
| + web_profiles_.clear();
|
| + }
|
| +
|
| + void ClearCreditCards() {
|
| + credit_cards_.clear();
|
| + }
|
| +
|
| private:
|
| void CreateTestAutoFillProfiles(ScopedVector<AutoFillProfile>* profiles) {
|
| AutoFillProfile* profile = new AutoFillProfile;
|
| @@ -293,11 +303,12 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsEmptyValue) {
|
| webkit_glue::FormField field;
|
| autofill_test::CreateTestFormField(
|
| "First Name", "firstname", "", "text", &field);
|
| - EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
|
|
| // No suggestions provided, so send an empty vector as the results.
|
| // This triggers the combined message send.
|
| - rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
|
| + rvh()->AutocompleteSuggestionsReturned(std::vector<string16>());
|
|
|
| // Test that we sent the right message to the renderer.
|
| int page_id = 0;
|
| @@ -338,11 +349,12 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsMatchCharacter) {
|
| webkit_glue::FormField field;
|
| autofill_test::CreateTestFormField(
|
| "First Name", "firstname", "E", "text", &field);
|
| - EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
|
|
| // No suggestions provided, so send an empty vector as the results.
|
| // This triggers the combined message send.
|
| - rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
|
| + rvh()->AutocompleteSuggestionsReturned(std::vector<string16>());
|
|
|
| // Test that we sent the right message to the renderer.
|
| int page_id = 0;
|
| @@ -394,8 +406,148 @@ TEST_F(AutoFillManagerTest, GetProfileSuggestionsUnknownFields) {
|
|
|
| autofill_test::CreateTestFormField(
|
| "Username", "username", "", "text", &field);
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| EXPECT_FALSE(
|
| - autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
|
| + autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
| +}
|
| +
|
| +// Test that we return a warning explaining that autofill suggestions are
|
| +// unavailable when the website specifies autocomplete="off".
|
| +TEST_F(AutoFillManagerTest, GetProfileSuggestionsAutofillDisabled) {
|
| + FormData form;
|
| + CreateTestAddressFormData(&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_test::CreateTestFormField(
|
| + "First Name", "firstname", "", "text", &field);
|
| + rvh()->ResetAutoFillState(kPageID, true);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, true));
|
| +
|
| + // No suggestions provided, so send an empty vector as the results.
|
| + // This triggers the combined message send.
|
| + rvh()->AutocompleteSuggestionsReturned(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;
|
| + std::vector<string16> icons;
|
| + EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
|
| + &icons));
|
| + EXPECT_EQ(kPageID, page_id);
|
| + ASSERT_EQ(1U, values.size());
|
| + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_AUTOFILL_DISABLED),
|
| + values[0]);
|
| + ASSERT_EQ(1U, labels.size());
|
| + EXPECT_EQ(string16(), labels[0]);
|
| + ASSERT_EQ(1U, icons.size());
|
| + EXPECT_EQ(string16(), icons[0]);
|
| +
|
| + // Clear the test profiles and try again -- we shouldn't return a warning.
|
| + process()->sink().ClearMessages();
|
| + const int kPageID2 = 2;
|
| + rvh()->ResetAutoFillState(kPageID2, true);
|
| +
|
| + test_personal_data_->ClearAutoFillProfiles();
|
| + EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field, true));
|
| +
|
| + // Now add some Autocomplete suggestions. We should now return the same
|
| + // warning as before.
|
| + std::vector<string16> suggestions;
|
| + suggestions.push_back(ASCIIToUTF16("Jay"));
|
| + suggestions.push_back(ASCIIToUTF16("Jason"));
|
| + rvh()->AutocompleteSuggestionsReturned(suggestions);
|
| +
|
| + EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
|
| + &icons));
|
| + EXPECT_EQ(kPageID2, page_id);
|
| + ASSERT_EQ(1U, values.size());
|
| + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_AUTOFILL_DISABLED),
|
| + values[0]);
|
| + ASSERT_EQ(1U, labels.size());
|
| + EXPECT_EQ(string16(), labels[0]);
|
| + ASSERT_EQ(1U, icons.size());
|
| + EXPECT_EQ(string16(), icons[0]);
|
| +}
|
| +
|
| +// Test that we return a warning explaining that autofill suggestions are
|
| +// unavailable when the form method is GET rather than POST.
|
| +TEST_F(AutoFillManagerTest, GetProfileSuggestionsMethodGet) {
|
| + FormData form;
|
| + CreateTestAddressFormData(&form);
|
| + form.method = ASCIIToUTF16("GET");
|
| +
|
| + // 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_test::CreateTestFormField(
|
| + "First Name", "firstname", "", "text", &field);
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
| +
|
| + // No suggestions provided, so send an empty vector as the results.
|
| + // This triggers the combined message send.
|
| + rvh()->AutocompleteSuggestionsReturned(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;
|
| + std::vector<string16> icons;
|
| + EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
|
| + &icons));
|
| + EXPECT_EQ(kPageID, page_id);
|
| + ASSERT_EQ(1U, values.size());
|
| + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_AUTOFILL_DISABLED),
|
| + values[0]);
|
| + ASSERT_EQ(1U, labels.size());
|
| + EXPECT_EQ(string16(), labels[0]);
|
| + ASSERT_EQ(1U, icons.size());
|
| + EXPECT_EQ(string16(), icons[0]);
|
| +
|
| + // Clear the test profiles and try again -- we shouldn't return a warning.
|
| + process()->sink().ClearMessages();
|
| + const int kPageID2 = 2;
|
| + rvh()->ResetAutoFillState(kPageID2, false);
|
| +
|
| + test_personal_data_->ClearAutoFillProfiles();
|
| + EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
| +
|
| + // Now add some Autocomplete suggestions. We should show the autocomplete
|
| + // suggestions rather than the warning.
|
| + std::vector<string16> suggestions;
|
| + suggestions.push_back(ASCIIToUTF16("Jay"));
|
| + suggestions.push_back(ASCIIToUTF16("Jason"));
|
| + rvh()->AutocompleteSuggestionsReturned(suggestions);
|
| +
|
| + EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
|
| + &icons));
|
| + EXPECT_EQ(kPageID2, page_id);
|
| + ASSERT_EQ(2U, values.size());
|
| + EXPECT_EQ(ASCIIToUTF16("Jay"), values[0]);
|
| + EXPECT_EQ(ASCIIToUTF16("Jason"), values[1]);
|
| + ASSERT_EQ(2U, labels.size());
|
| + EXPECT_EQ(string16(), labels[0]);
|
| + EXPECT_EQ(string16(), labels[1]);
|
| + ASSERT_EQ(2U, icons.size());
|
| + EXPECT_EQ(string16(), icons[0]);
|
| + EXPECT_EQ(string16(), icons[1]);
|
| }
|
|
|
| // Test that we return all credit card profile suggestions when all form fields
|
| @@ -416,11 +568,12 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsEmptyValue) {
|
| webkit_glue::FormField field;
|
| autofill_test::CreateTestFormField(
|
| "Card Number", "cardnumber", "", "text", &field);
|
| - EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
|
|
| // No suggestions provided, so send an empty vector as the results.
|
| // This triggers the combined message send.
|
| - rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
|
| + rvh()->AutocompleteSuggestionsReturned(std::vector<string16>());
|
|
|
| // Test that we sent the right message to the renderer.
|
| int page_id = 0;
|
| @@ -459,11 +612,12 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsMatchCharacter) {
|
| webkit_glue::FormField field;
|
| autofill_test::CreateTestFormField(
|
| "Card Number", "cardnumber", "4", "text", &field);
|
| - EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
|
|
| // No suggestions provided, so send an empty vector as the results.
|
| // This triggers the combined message send.
|
| - rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
|
| + rvh()->AutocompleteSuggestionsReturned(std::vector<string16>());
|
|
|
| // Test that we sent the right message to the renderer.
|
| int page_id = 0;
|
| @@ -499,11 +653,12 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) {
|
| webkit_glue::FormField field;
|
| autofill_test::CreateTestFormField(
|
| "Name on Card", "nameoncard", "", "text", &field);
|
| - EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
|
|
| // No suggestions provided, so send an empty vector as the results.
|
| // This triggers the combined message send.
|
| - rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
|
| + rvh()->AutocompleteSuggestionsReturned(std::vector<string16>());
|
|
|
| // Test that we sent the right message to the renderer.
|
| int page_id = 0;
|
| @@ -524,8 +679,8 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonCCNumber) {
|
| EXPECT_EQ(ASCIIToUTF16("masterCardCC"), icons[1]);
|
| }
|
|
|
| -// Test that we return no credit card profile suggestions when the form is not
|
| -// https.
|
| +// Test that we return a warning explaining that credit card profile suggestions
|
| +// are unavailable when the form is not https.
|
| TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) {
|
| FormData form;
|
| CreateTestCreditCardFormData(&form, false);
|
| @@ -542,8 +697,56 @@ TEST_F(AutoFillManagerTest, GetCreditCardSuggestionsNonHTTPS) {
|
| webkit_glue::FormField field;
|
| autofill_test::CreateTestFormField(
|
| "Card Number", "cardnumber", "", "text", &field);
|
| - EXPECT_FALSE(
|
| - autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
| +
|
| + // No suggestions provided, so send an empty vector as the results.
|
| + // This triggers the combined message send.
|
| + rvh()->AutocompleteSuggestionsReturned(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;
|
| + std::vector<string16> icons;
|
| + EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
|
| + &icons));
|
| + EXPECT_EQ(kPageID, page_id);
|
| + ASSERT_EQ(1U, values.size());
|
| + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION),
|
| + values[0]);
|
| + ASSERT_EQ(1U, labels.size());
|
| + EXPECT_EQ(string16(), labels[0]);
|
| + ASSERT_EQ(1U, icons.size());
|
| + EXPECT_EQ(string16(), icons[0]);
|
| +
|
| + // Clear the test credit cards and try again -- we shouldn't return a warning.
|
| + process()->sink().ClearMessages();
|
| + const int kPageID2 = 2;
|
| + rvh()->ResetAutoFillState(kPageID2, false);
|
| +
|
| + test_personal_data_->ClearCreditCards();
|
| + EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
| +
|
| + // Now add some Autocomplete suggestions. We should show the autocomplete
|
| + // suggestions rather than the warning.
|
| + std::vector<string16> suggestions;
|
| + suggestions.push_back(ASCIIToUTF16("Jay"));
|
| + suggestions.push_back(ASCIIToUTF16("Jason"));
|
| + rvh()->AutocompleteSuggestionsReturned(suggestions);
|
| +
|
| + EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
|
| + &icons));
|
| + EXPECT_EQ(kPageID2, page_id);
|
| + ASSERT_EQ(2U, values.size());
|
| + EXPECT_EQ(ASCIIToUTF16("Jay"), values[0]);
|
| + EXPECT_EQ(ASCIIToUTF16("Jason"), values[1]);
|
| + ASSERT_EQ(2U, labels.size());
|
| + EXPECT_EQ(string16(), labels[0]);
|
| + EXPECT_EQ(string16(), labels[1]);
|
| + ASSERT_EQ(2U, icons.size());
|
| + EXPECT_EQ(string16(), icons[0]);
|
| + EXPECT_EQ(string16(), icons[1]);
|
| }
|
|
|
| // Test that we return profile and credit card suggestions for combined forms.
|
| @@ -564,11 +767,12 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) {
|
| webkit_glue::FormField field;
|
| autofill_test::CreateTestFormField(
|
| "First Name", "firstname", "", "text", &field);
|
| - EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
|
|
| // No suggestions provided, so send an empty vector as the results.
|
| // This triggers the combined message send.
|
| - rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
|
| + rvh()->AutocompleteSuggestionsReturned(std::vector<string16>());
|
|
|
| // Test that we sent the right address suggestions to the renderer.
|
| int page_id = 0;
|
| @@ -593,11 +797,12 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) {
|
| process()->sink().ClearMessages();
|
| autofill_test::CreateTestFormField(
|
| "Card Number", "cardnumber", "", "text", &field);
|
| - EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
|
|
| // No suggestions provided, so send an empty vector as the results.
|
| // This triggers the combined message send.
|
| - rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
|
| + rvh()->AutocompleteSuggestionsReturned(std::vector<string16>());
|
|
|
| // Test that we sent the credit card suggestions to the renderer.
|
| page_id = 0;
|
| @@ -616,7 +821,9 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestions) {
|
| }
|
|
|
| // Test that for non-https forms with both address and credit card fields, we
|
| -// only return address suggestions.
|
| +// only return address suggestions. Instead of credit card suggestions, we
|
| +// should return a warning explaining that credit card profile suggestions are
|
| +// unavailable when the form is not https.
|
| TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) {
|
| FormData form;
|
| CreateTestAddressFormData(&form);
|
| @@ -634,11 +841,12 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) {
|
| webkit_glue::FormField field;
|
| autofill_test::CreateTestFormField(
|
| "First Name", "firstname", "", "text", &field);
|
| - EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
|
|
| // No suggestions provided, so send an empty vector as the results.
|
| // This triggers the combined message send.
|
| - rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
|
| + rvh()->AutocompleteSuggestionsReturned(std::vector<string16>());
|
|
|
| // Test that we sent the right address suggestions to the renderer.
|
| int page_id = 0;
|
| @@ -660,10 +868,31 @@ TEST_F(AutoFillManagerTest, GetAddressAndCreditCardSuggestionsNonHttps) {
|
| EXPECT_EQ(string16(), icons[0]);
|
| EXPECT_EQ(string16(), icons[1]);
|
|
|
| + process()->sink().ClearMessages();
|
| autofill_test::CreateTestFormField(
|
| "Card Number", "cardnumber", "", "text", &field);
|
| - EXPECT_FALSE(
|
| - autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
| +
|
| + // No suggestions provided, so send an empty vector as the results.
|
| + // This triggers the combined message send.
|
| + rvh()->AutocompleteSuggestionsReturned(std::vector<string16>());
|
| +
|
| + // Test that we sent the right message to the renderer.
|
| + EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels,
|
| + &icons));
|
| + EXPECT_EQ(kPageID, page_id);
|
| + ASSERT_EQ(1U, values.size());
|
| + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_AUTOFILL_WARNING_INSECURE_CONNECTION),
|
| + values[0]);
|
| + ASSERT_EQ(1U, labels.size());
|
| + EXPECT_EQ(string16(), labels[0]);
|
| + ASSERT_EQ(1U, icons.size());
|
| + EXPECT_EQ(string16(), icons[0]);
|
| +
|
| + // Clear the test credit cards and try again -- we shouldn't return a warning.
|
| + test_personal_data_->ClearCreditCards();
|
| + EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
| }
|
|
|
| // Test that we correctly combine autofill and autocomplete suggestions.
|
| @@ -683,14 +912,15 @@ TEST_F(AutoFillManagerTest, GetCombinedAutoFillAndAutocompleteSuggestions) {
|
| webkit_glue::FormField field;
|
| autofill_test::CreateTestFormField(
|
| "First Name", "firstname", "", "text", &field);
|
| - EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, false, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(false, field, false));
|
|
|
| // 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);
|
| + rvh()->AutocompleteSuggestionsReturned(suggestions);
|
|
|
| // Test that we sent the right message to the renderer.
|
| int page_id = 0;
|
| @@ -735,11 +965,12 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsFieldIsAutoFilled) {
|
| webkit_glue::FormField field;
|
| autofill_test::CreateTestFormField(
|
| "First Name", "firstname", "", "text", &field);
|
| - EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, true, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(true, field, false));
|
|
|
| // No suggestions provided, so send an empty vector as the results.
|
| // This triggers the combined message send.
|
| - rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
|
| + rvh()->AutocompleteSuggestionsReturned(std::vector<string16>());
|
|
|
| // Test that we sent the right message to the renderer.
|
| int page_id = 0;
|
| @@ -778,14 +1009,15 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsForAutocompleteOnly) {
|
| webkit_glue::FormField field;
|
| autofill_test::CreateTestFormField(
|
| "Some Field", "somefield", "", "text", &field);
|
| - EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(kPageID, true, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_FALSE(autofill_manager_->GetAutoFillSuggestions(true, field, false));
|
|
|
| // Add some Autocomplete suggestions.
|
| // This triggers the combined message send.
|
| std::vector<string16> suggestions;
|
| suggestions.push_back(ASCIIToUTF16("one"));
|
| suggestions.push_back(ASCIIToUTF16("two"));
|
| - rvh()->AutocompleteSuggestionsReturned(kPageID, suggestions);
|
| + rvh()->AutocompleteSuggestionsReturned(suggestions);
|
|
|
| // Test that we sent the right message to the renderer.
|
| int page_id = 0;
|
| @@ -830,11 +1062,12 @@ TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) {
|
| webkit_glue::FormField field;
|
| autofill_test::CreateTestFormField(
|
| "First Name", "firstname", "", "text", &field);
|
| - EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, true, field));
|
| + rvh()->ResetAutoFillState(kPageID, false);
|
| + EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(true, field, false));
|
|
|
| // No suggestions provided, so send an empty vector as the results.
|
| // This triggers the combined message send.
|
| - rvh()->AutocompleteSuggestionsReturned(kPageID, std::vector<string16>());
|
| + rvh()->AutocompleteSuggestionsReturned(std::vector<string16>());
|
|
|
| // Test that we sent the right message to the renderer.
|
| int page_id = 0;
|
|
|