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/string16.h" | 8 #include "base/string16.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/autofill/autocomplete_history_manager.h" | 10 #include "chrome/browser/autofill/autocomplete_history_manager.h" |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 const std::vector<string16>& autofill_labels, | 165 const std::vector<string16>& autofill_labels, |
166 const std::vector<string16>& autofill_icons, | 166 const std::vector<string16>& autofill_icons, |
167 const std::vector<int>& autofill_unique_ids)); | 167 const std::vector<int>& autofill_unique_ids)); |
168 | 168 |
169 private: | 169 private: |
170 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); | 170 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); |
171 }; | 171 }; |
172 | 172 |
173 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager { | 173 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager { |
174 public: | 174 public: |
175 explicit AutocompleteHistoryManagerStubSend( | 175 AutocompleteHistoryManagerStubSend( |
176 WebContents* web_contents, | 176 WebContents* web_contents, |
177 Profile* profile, | 177 Profile* profile, |
178 scoped_ptr<AutofillWebDataService> wds) | 178 scoped_ptr<AutofillWebDataService> wds) |
179 : AutocompleteHistoryManager(web_contents, profile, wds.Pass()) {} | 179 : AutocompleteHistoryManager(web_contents, profile, wds.Pass()) {} |
180 | 180 |
181 // Intentionally swallow the message. | 181 // Intentionally swallow the message. |
182 virtual bool Send(IPC::Message* message) { delete message; return true; } | 182 virtual bool Send(IPC::Message* message) { delete message; return true; } |
183 }; | 183 }; |
184 | 184 |
185 } // namespace | 185 } // namespace |
186 | 186 |
187 // Make sure our external delegate is called at the right time. | 187 // Make sure our external delegate is called at the right time. |
188 TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { | 188 TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { |
189 // Local version with a stubbed out Send() | 189 // Local version with a stubbed out Send() |
190 AutocompleteHistoryManagerStubSend autocomplete_history_manager( | 190 AutocompleteHistoryManagerStubSend autocomplete_history_manager( |
191 web_contents(), | 191 web_contents(), |
192 &profile_, | 192 &profile_, |
193 scoped_ptr<AutofillWebDataService>( | 193 scoped_ptr<AutofillWebDataService>( |
194 new AutofillWebDataServiceImpl(web_data_service_))); | 194 new AutofillWebDataServiceImpl(web_data_service_))); |
195 | 195 |
196 MockAutofillExternalDelegate external_delegate(web_contents()); | 196 MockAutofillExternalDelegate external_delegate(web_contents()); |
197 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); | 197 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); |
198 autocomplete_history_manager.SetExternalDelegate(&external_delegate); | 198 autocomplete_history_manager.SetExternalDelegate(&external_delegate); |
199 | 199 |
200 // Should trigger a call to OnSuggestionsReturned, verified by the mock. | 200 // Should trigger a call to OnSuggestionsReturned, verified by the mock. |
201 autocomplete_history_manager.SendSuggestions(NULL); | 201 autocomplete_history_manager.SendSuggestions(NULL); |
202 } | 202 } |
OLD | NEW |