OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <algorithm> | 5 #include <algorithm> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
584 std::vector<base::string16> autofill_icons_; | 584 std::vector<base::string16> autofill_icons_; |
585 std::vector<int> autofill_unique_ids_; | 585 std::vector<int> autofill_unique_ids_; |
586 | 586 |
587 DISALLOW_COPY_AND_ASSIGN(TestAutofillExternalDelegate); | 587 DISALLOW_COPY_AND_ASSIGN(TestAutofillExternalDelegate); |
588 }; | 588 }; |
589 | 589 |
590 } // namespace | 590 } // namespace |
591 | 591 |
592 class AutofillManagerTest : public testing::Test { | 592 class AutofillManagerTest : public testing::Test { |
593 public: | 593 public: |
594 virtual void SetUp() override { | 594 void SetUp() override { |
595 autofill_client_.SetPrefs(test::PrefServiceForTesting()); | 595 autofill_client_.SetPrefs(test::PrefServiceForTesting()); |
596 personal_data_.set_database(autofill_client_.GetDatabase()); | 596 personal_data_.set_database(autofill_client_.GetDatabase()); |
597 personal_data_.SetPrefService(autofill_client_.GetPrefs()); | 597 personal_data_.SetPrefService(autofill_client_.GetPrefs()); |
598 autofill_driver_.reset(new MockAutofillDriver()); | 598 autofill_driver_.reset(new MockAutofillDriver()); |
599 autofill_manager_.reset(new TestAutofillManager( | 599 autofill_manager_.reset(new TestAutofillManager( |
600 autofill_driver_.get(), &autofill_client_, &personal_data_)); | 600 autofill_driver_.get(), &autofill_client_, &personal_data_)); |
601 | 601 |
602 external_delegate_.reset(new TestAutofillExternalDelegate( | 602 external_delegate_.reset(new TestAutofillExternalDelegate( |
603 autofill_manager_.get(), | 603 autofill_manager_.get(), |
604 autofill_driver_.get())); | 604 autofill_driver_.get())); |
605 autofill_manager_->SetExternalDelegate(external_delegate_.get()); | 605 autofill_manager_->SetExternalDelegate(external_delegate_.get()); |
606 } | 606 } |
607 | 607 |
608 virtual void TearDown() override { | 608 void TearDown() override { |
609 // Order of destruction is important as AutofillManager relies on | 609 // Order of destruction is important as AutofillManager relies on |
610 // PersonalDataManager to be around when it gets destroyed. | 610 // PersonalDataManager to be around when it gets destroyed. |
611 autofill_manager_.reset(); | 611 autofill_manager_.reset(); |
612 autofill_driver_.reset(); | 612 autofill_driver_.reset(); |
613 | 613 |
614 // Remove the AutofillWebDataService so TestPersonalDataManager does not | 614 // Remove the AutofillWebDataService so TestPersonalDataManager does not |
615 // need to care about removing self as an observer in destruction. | 615 // need to care about removing self as an observer in destruction. |
616 personal_data_.set_database(scoped_refptr<AutofillWebDataService>(NULL)); | 616 personal_data_.set_database(scoped_refptr<AutofillWebDataService>(NULL)); |
617 personal_data_.SetPrefService(NULL); | 617 personal_data_.SetPrefService(NULL); |
618 } | 618 } |
(...skipping 2363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2982 test::CreateTestAddressFormData(&form); | 2982 test::CreateTestAddressFormData(&form); |
2983 std::vector<FormData> forms(1, form); | 2983 std::vector<FormData> forms(1, form); |
2984 FormsSeen(forms); | 2984 FormsSeen(forms); |
2985 const FormFieldData& field = form.fields[0]; | 2985 const FormFieldData& field = form.fields[0]; |
2986 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() | 2986 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() |
2987 | 2987 |
2988 EXPECT_TRUE(external_delegate_->on_query_seen()); | 2988 EXPECT_TRUE(external_delegate_->on_query_seen()); |
2989 } | 2989 } |
2990 | 2990 |
2991 } // namespace autofill | 2991 } // namespace autofill |
OLD | NEW |