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 <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/files/scoped_temp_dir.h" | 11 #include "base/files/scoped_temp_dir.h" |
12 #include "base/guid.h" | 12 #include "base/guid.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/message_loop/message_loop.h" | |
15 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
16 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
17 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 17 #include "base/thread_task_runner_handle.h" |
18 #include "components/autofill/core/browser/autofill_experiments.h" | 18 #include "components/autofill/core/browser/autofill_experiments.h" |
19 #include "components/autofill/core/browser/autofill_profile.h" | 19 #include "components/autofill/core/browser/autofill_profile.h" |
20 #include "components/autofill/core/browser/autofill_test_utils.h" | 20 #include "components/autofill/core/browser/autofill_test_utils.h" |
21 #include "components/autofill/core/browser/form_structure.h" | 21 #include "components/autofill/core/browser/form_structure.h" |
22 #include "components/autofill/core/browser/personal_data_manager.h" | 22 #include "components/autofill/core/browser/personal_data_manager.h" |
23 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 23 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
24 #include "components/autofill/core/browser/webdata/autofill_table.h" | 24 #include "components/autofill/core/browser/webdata/autofill_table.h" |
25 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" | 25 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h" |
26 #include "components/autofill/core/common/autofill_pref_names.h" | 26 #include "components/autofill/core/common/autofill_pref_names.h" |
27 #include "components/autofill/core/common/autofill_switches.h" | 27 #include "components/autofill/core/common/autofill_switches.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 } // anonymous namespace | 88 } // anonymous namespace |
89 | 89 |
90 class PersonalDataManagerTest : public testing::Test { | 90 class PersonalDataManagerTest : public testing::Test { |
91 protected: | 91 protected: |
92 PersonalDataManagerTest() : autofill_table_(nullptr) {} | 92 PersonalDataManagerTest() : autofill_table_(nullptr) {} |
93 | 93 |
94 void SetUp() override { | 94 void SetUp() override { |
95 prefs_ = test::PrefServiceForTesting(); | 95 prefs_ = test::PrefServiceForTesting(); |
96 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 96 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
97 base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB"); | 97 base::FilePath path = temp_dir_.path().AppendASCII("TestWebDB"); |
98 web_database_ = new WebDatabaseService(path, | 98 web_database_ = |
99 base::MessageLoopProxy::current(), | 99 new WebDatabaseService(path, base::ThreadTaskRunnerHandle::Get(), |
100 base::MessageLoopProxy::current()); | 100 base::ThreadTaskRunnerHandle::Get()); |
101 | 101 |
102 // Setup account tracker. | 102 // Setup account tracker. |
103 signin_client_.reset(new TestSigninClient(prefs_.get())); | 103 signin_client_.reset(new TestSigninClient(prefs_.get())); |
104 fake_oauth2_token_service_.reset(new FakeOAuth2TokenService()); | 104 fake_oauth2_token_service_.reset(new FakeOAuth2TokenService()); |
105 account_tracker_.reset(new AccountTrackerService()); | 105 account_tracker_.reset(new AccountTrackerService()); |
106 account_tracker_->Initialize(fake_oauth2_token_service_.get(), | 106 account_tracker_->Initialize(fake_oauth2_token_service_.get(), |
107 signin_client_.get()); | 107 signin_client_.get()); |
108 | 108 |
109 // Hacky: hold onto a pointer but pass ownership. | 109 // Hacky: hold onto a pointer but pass ownership. |
110 autofill_table_ = new AutofillTable("en-US"); | 110 autofill_table_ = new AutofillTable("en-US"); |
111 web_database_->AddTable(scoped_ptr<WebDatabaseTable>(autofill_table_)); | 111 web_database_->AddTable(scoped_ptr<WebDatabaseTable>(autofill_table_)); |
112 web_database_->LoadDatabase(); | 112 web_database_->LoadDatabase(); |
113 autofill_database_service_ = | 113 autofill_database_service_ = new AutofillWebDataService( |
114 new AutofillWebDataService(web_database_, | 114 web_database_, base::ThreadTaskRunnerHandle::Get(), |
115 base::MessageLoopProxy::current(), | 115 base::ThreadTaskRunnerHandle::Get(), |
116 base::MessageLoopProxy::current(), | 116 WebDataServiceBase::ProfileErrorCallback()); |
117 WebDataServiceBase::ProfileErrorCallback()); | |
118 autofill_database_service_->Init(); | 117 autofill_database_service_->Init(); |
119 | 118 |
120 test::DisableSystemServices(prefs_.get()); | 119 test::DisableSystemServices(prefs_.get()); |
121 ResetPersonalDataManager(USER_MODE_NORMAL); | 120 ResetPersonalDataManager(USER_MODE_NORMAL); |
122 } | 121 } |
123 | 122 |
124 void TearDown() override { | 123 void TearDown() override { |
125 // Order of destruction is important as AutofillManager relies on | 124 // Order of destruction is important as AutofillManager relies on |
126 // PersonalDataManager to be around when it gets destroyed. | 125 // PersonalDataManager to be around when it gets destroyed. |
127 account_tracker_->Shutdown(); | 126 account_tracker_->Shutdown(); |
(...skipping 3047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3175 form2.fields.push_back(field); | 3174 form2.fields.push_back(field); |
3176 | 3175 |
3177 FormStructure form_structure2(form2); | 3176 FormStructure form_structure2(form2); |
3178 form_structure2.DetermineHeuristicTypes(); | 3177 form_structure2.DetermineHeuristicTypes(); |
3179 EXPECT_FALSE( | 3178 EXPECT_FALSE( |
3180 personal_data_->ImportFormData(form_structure2, &imported_credit_card)); | 3179 personal_data_->ImportFormData(form_structure2, &imported_credit_card)); |
3181 EXPECT_FALSE(imported_credit_card); | 3180 EXPECT_FALSE(imported_credit_card); |
3182 } | 3181 } |
3183 | 3182 |
3184 } // namespace autofill | 3183 } // namespace autofill |
OLD | NEW |