OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/prefs/testing_pref_service.h" | 8 #include "base/prefs/testing_pref_service.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
95 | 95 |
96 class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness { | 96 class AutocompleteHistoryManagerTest : public ChromeRenderViewHostTestHarness { |
97 protected: | 97 protected: |
98 virtual void SetUp() OVERRIDE { | 98 virtual void SetUp() OVERRIDE { |
99 ChromeRenderViewHostTestHarness::SetUp(); | 99 ChromeRenderViewHostTestHarness::SetUp(); |
100 web_data_service_ = new MockWebDataService(); | 100 web_data_service_ = new MockWebDataService(); |
101 WebDataServiceFactory::GetInstance()->SetTestingFactory( | 101 WebDataServiceFactory::GetInstance()->SetTestingFactory( |
102 profile(), MockWebDataServiceWrapperCurrent::Build); | 102 profile(), MockWebDataServiceWrapperCurrent::Build); |
103 autofill_driver_.reset(new TestAutofillDriver(web_contents())); | 103 autofill_driver_.reset(new TestAutofillDriver(web_contents())); |
104 autocomplete_manager_.reset( | 104 autocomplete_manager_.reset( |
105 new AutocompleteHistoryManager(autofill_driver_.get())); | 105 new AutocompleteHistoryManager(autofill_driver_.get(), |
106 &manager_delegate)); | |
106 } | 107 } |
107 | 108 |
108 virtual void TearDown() OVERRIDE { | 109 virtual void TearDown() OVERRIDE { |
109 autocomplete_manager_.reset(); | 110 autocomplete_manager_.reset(); |
110 web_data_service_ = NULL; | 111 web_data_service_ = NULL; |
111 ChromeRenderViewHostTestHarness::TearDown(); | 112 ChromeRenderViewHostTestHarness::TearDown(); |
112 } | 113 } |
113 | 114 |
114 scoped_refptr<MockWebDataService> web_data_service_; | 115 scoped_refptr<MockWebDataService> web_data_service_; |
115 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_; | 116 scoped_ptr<AutocompleteHistoryManager> autocomplete_manager_; |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
217 const std::vector<base::string16>& autofill_labels, | 218 const std::vector<base::string16>& autofill_labels, |
218 const std::vector<base::string16>& autofill_icons, | 219 const std::vector<base::string16>& autofill_icons, |
219 const std::vector<int>& autofill_unique_ids)); | 220 const std::vector<int>& autofill_unique_ids)); |
220 | 221 |
221 private: | 222 private: |
222 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); | 223 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); |
223 }; | 224 }; |
224 | 225 |
225 class AutocompleteHistoryManagerNoIPC : public AutocompleteHistoryManager { | 226 class AutocompleteHistoryManagerNoIPC : public AutocompleteHistoryManager { |
226 public: | 227 public: |
227 explicit AutocompleteHistoryManagerNoIPC(AutofillDriver* driver) | 228 explicit AutocompleteHistoryManagerNoIPC(AutofillDriver* driver, |
Ilya Sherman
2013/06/19 00:38:27
nit: No longer a need for explicit here.
sgurun-gerrit only
2013/06/19 17:56:23
Done.
| |
228 : AutocompleteHistoryManager(driver) { | 229 AutofillManagerDelegate* delegate) |
230 : AutocompleteHistoryManager(driver, delegate) { | |
229 // Ensure that IPC is not sent during the test. | 231 // Ensure that IPC is not sent during the test. |
230 set_send_ipc(false); | 232 set_send_ipc(false); |
231 } | 233 } |
232 | 234 |
233 using AutocompleteHistoryManager::SendSuggestions; | 235 using AutocompleteHistoryManager::SendSuggestions; |
234 }; | 236 }; |
235 | 237 |
236 } // namespace | 238 } // namespace |
237 | 239 |
238 // Make sure our external delegate is called at the right time. | 240 // Make sure our external delegate is called at the right time. |
239 TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { | 241 TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { |
240 AutocompleteHistoryManagerNoIPC autocomplete_history_manager( | 242 AutocompleteHistoryManagerNoIPC autocomplete_history_manager( |
241 autofill_driver_.get()); | 243 autofill_driver_.get(), &manager_delegate); |
242 | 244 |
243 scoped_ptr<AutofillManager> autofill_manager(new AutofillManager( | 245 scoped_ptr<AutofillManager> autofill_manager(new AutofillManager( |
244 autofill_driver_.get(), | 246 autofill_driver_.get(), |
245 &manager_delegate, | 247 &manager_delegate, |
246 "en-US", | 248 "en-US", |
247 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER)); | 249 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER)); |
248 | 250 |
249 MockAutofillExternalDelegate external_delegate(web_contents(), | 251 MockAutofillExternalDelegate external_delegate(web_contents(), |
250 autofill_manager.get()); | 252 autofill_manager.get()); |
251 autocomplete_history_manager.SetExternalDelegate(&external_delegate); | 253 autocomplete_history_manager.SetExternalDelegate(&external_delegate); |
252 | 254 |
253 // Should trigger a call to OnSuggestionsReturned, verified by the mock. | 255 // Should trigger a call to OnSuggestionsReturned, verified by the mock. |
254 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); | 256 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); |
255 autocomplete_history_manager.SendSuggestions(NULL); | 257 autocomplete_history_manager.SendSuggestions(NULL); |
256 } | 258 } |
257 | 259 |
258 } // namespace autofill | 260 } // namespace autofill |
OLD | NEW |