| 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/string16.h" | 9 #include "base/string16.h" |
| 10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 void(int query_id, | 222 void(int query_id, |
| 223 const std::vector<base::string16>& autofill_values, | 223 const std::vector<base::string16>& autofill_values, |
| 224 const std::vector<base::string16>& autofill_labels, | 224 const std::vector<base::string16>& autofill_labels, |
| 225 const std::vector<base::string16>& autofill_icons, | 225 const std::vector<base::string16>& autofill_icons, |
| 226 const std::vector<int>& autofill_unique_ids)); | 226 const std::vector<int>& autofill_unique_ids)); |
| 227 | 227 |
| 228 private: | 228 private: |
| 229 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); | 229 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); |
| 230 }; | 230 }; |
| 231 | 231 |
| 232 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager { | |
| 233 public: | |
| 234 explicit AutocompleteHistoryManagerStubSend(WebContents* web_contents) | |
| 235 : AutocompleteHistoryManager(web_contents) {} | |
| 236 | |
| 237 // Increase visibility for testing. | |
| 238 void SendSuggestions(const std::vector<base::string16>* suggestions) { | |
| 239 AutocompleteHistoryManager::SendSuggestions(suggestions); | |
| 240 } | |
| 241 | |
| 242 // Intentionally swallow the message. | |
| 243 virtual bool Send(IPC::Message* message) OVERRIDE { | |
| 244 delete message; | |
| 245 return true; | |
| 246 } | |
| 247 }; | |
| 248 | |
| 249 } // namespace | 232 } // namespace |
| 250 | 233 |
| 251 // Make sure our external delegate is called at the right time. | 234 // Make sure our external delegate is called at the right time. |
| 252 TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { | 235 TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { |
| 253 // Local version with a stubbed out Send() | 236 AutocompleteHistoryManager autocomplete_history_manager(web_contents()); |
| 254 AutocompleteHistoryManagerStubSend autocomplete_history_manager( | 237 autocomplete_history_manager.send_IPC_ = false; |
| 255 web_contents()); | |
| 256 | 238 |
| 257 AutofillManager::CreateForWebContentsAndDelegate( | 239 AutofillManager::CreateForWebContentsAndDelegate( |
| 258 web_contents(), | 240 web_contents(), |
| 259 &manager_delegate, | 241 &manager_delegate, |
| 260 "en-US", | 242 "en-US", |
| 261 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER); | 243 AutofillManager::ENABLE_AUTOFILL_DOWNLOAD_MANAGER); |
| 262 | 244 |
| 263 MockAutofillExternalDelegate external_delegate(web_contents()); | 245 MockAutofillExternalDelegate external_delegate(web_contents()); |
| 264 autocomplete_history_manager.SetExternalDelegate(&external_delegate); | 246 autocomplete_history_manager.SetExternalDelegate(&external_delegate); |
| 265 | 247 |
| 266 // Should trigger a call to OnSuggestionsReturned, verified by the mock. | 248 // Should trigger a call to OnSuggestionsReturned, verified by the mock. |
| 267 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); | 249 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); |
| 268 autocomplete_history_manager.SendSuggestions(NULL); | 250 autocomplete_history_manager.SendSuggestions(NULL); |
| 269 } | 251 } |
| 270 | 252 |
| 271 } // namespace autofill | 253 } // namespace autofill |
| OLD | NEW |