| 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/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/scoped_vector.h" | 9 #include "base/scoped_vector.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels)); | 592 EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels)); |
| 593 EXPECT_EQ(kPageID, page_id); | 593 EXPECT_EQ(kPageID, page_id); |
| 594 ASSERT_EQ(2U, values.size()); | 594 ASSERT_EQ(2U, values.size()); |
| 595 EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]); | 595 EXPECT_EQ(ASCIIToUTF16("Elvis"), values[0]); |
| 596 EXPECT_EQ(ASCIIToUTF16("Charles"), values[1]); | 596 EXPECT_EQ(ASCIIToUTF16("Charles"), values[1]); |
| 597 ASSERT_EQ(2U, labels.size()); | 597 ASSERT_EQ(2U, labels.size()); |
| 598 EXPECT_EQ(string16(), labels[0]); | 598 EXPECT_EQ(string16(), labels[0]); |
| 599 EXPECT_EQ(string16(), labels[1]); | 599 EXPECT_EQ(string16(), labels[1]); |
| 600 } | 600 } |
| 601 | 601 |
| 602 TEST_F(AutoFillManagerTest, GetFieldSuggestionsForAutocompleteOnly) { |
| 603 FormData form; |
| 604 CreateTestFormData(&form); |
| 605 |
| 606 // Set up our FormStructures. |
| 607 std::vector<FormData> forms; |
| 608 forms.push_back(form); |
| 609 autofill_manager_->FormsSeen(forms); |
| 610 |
| 611 // The page ID sent to the AutoFillManager from the RenderView, used to send |
| 612 // an IPC message back to the renderer. |
| 613 const int kPageID = 1; |
| 614 const int kAlternatePageID = 0; |
| 615 |
| 616 webkit_glue::FormField field; |
| 617 autofill_unittest::CreateTestFormField( |
| 618 "First Name", "firstname", "", "text", &field); |
| 619 EXPECT_TRUE(autofill_manager_->GetAutoFillSuggestions(kPageID, true, field)); |
| 620 |
| 621 // No suggestions provided, so send an empty vector as the results. |
| 622 // This triggers the combined message send. |
| 623 // In this case, we're simulating a cancel of Autocomplete with a different |
| 624 // page ID and an empty vector of suggestions. |
| 625 rvh()->AutocompleteSuggestionsReturned(kAlternatePageID, |
| 626 std::vector<string16>()); |
| 627 |
| 628 // Test that we sent the right message to the renderer. |
| 629 int page_id = 0; |
| 630 std::vector<string16> values; |
| 631 std::vector<string16> labels; |
| 632 EXPECT_TRUE(GetAutoFillSuggestionsMessage(&page_id, &values, &labels)); |
| 633 EXPECT_EQ(kAlternatePageID, page_id); |
| 634 ASSERT_EQ(0U, values.size()); |
| 635 ASSERT_EQ(0U, labels.size()); |
| 636 } |
| 637 |
| 602 TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) { | 638 TEST_F(AutoFillManagerTest, GetFieldSuggestionsWithDuplicateValues) { |
| 603 FormData form; | 639 FormData form; |
| 604 CreateTestFormData(&form); | 640 CreateTestFormData(&form); |
| 605 | 641 |
| 606 // Set up our FormStructures. | 642 // Set up our FormStructures. |
| 607 std::vector<FormData> forms; | 643 std::vector<FormData> forms; |
| 608 forms.push_back(form); | 644 forms.push_back(form); |
| 609 autofill_manager_->FormsSeen(forms); | 645 autofill_manager_->FormsSeen(forms); |
| 610 | 646 |
| 611 // |profile| will be owned by the mock PersonalDataManager. | 647 // |profile| will be owned by the mock PersonalDataManager. |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1098 autofill_manager_->FormsSeen(forms); | 1134 autofill_manager_->FormsSeen(forms); |
| 1099 | 1135 |
| 1100 // Submit the form. | 1136 // Submit the form. |
| 1101 autofill_manager_->FormSubmitted(form); | 1137 autofill_manager_->FormSubmitted(form); |
| 1102 | 1138 |
| 1103 // TODO(jhawkins): We can't use the InfoBar anymore to determine if we saved | 1139 // TODO(jhawkins): We can't use the InfoBar anymore to determine if we saved |
| 1104 // fields. Need to query the PDM. | 1140 // fields. Need to query the PDM. |
| 1105 } | 1141 } |
| 1106 | 1142 |
| 1107 } // namespace | 1143 } // namespace |
| OLD | NEW |