OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/task.h" | 9 #include "base/task.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); | 157 DISALLOW_COPY_AND_ASSIGN(MockAutofillExternalDelegate); |
158 }; | 158 }; |
159 | 159 |
160 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager { | 160 class AutocompleteHistoryManagerStubSend : public AutocompleteHistoryManager { |
161 public: | 161 public: |
162 explicit AutocompleteHistoryManagerStubSend(TabContents* tab_contents, | 162 explicit AutocompleteHistoryManagerStubSend(TabContents* tab_contents, |
163 Profile* profile, | 163 Profile* profile, |
164 WebDataService* wds) | 164 WebDataService* wds) |
165 : AutocompleteHistoryManager(tab_contents, profile, wds) {} | 165 : AutocompleteHistoryManager(tab_contents, profile, wds) {} |
166 | 166 |
167 virtual bool Send(IPC::Message* message) { return true; } // intentional nop | 167 // Intentionally swallow the message. |
| 168 virtual bool Send(IPC::Message* message) { delete message; return true; } |
168 }; | 169 }; |
169 | 170 |
170 } // namespace | 171 } // namespace |
171 | 172 |
172 // Make sure our external delegate is called at the right time. | 173 // Make sure our external delegate is called at the right time. |
173 TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { | 174 TEST_F(AutocompleteHistoryManagerTest, ExternalDelegate) { |
174 // Local version with a stubbed out Send() | 175 // Local version with a stubbed out Send() |
175 AutocompleteHistoryManagerStubSend autocomplete_history_manager( | 176 AutocompleteHistoryManagerStubSend autocomplete_history_manager( |
176 contents(), | 177 contents(), |
177 &profile_, web_data_service_); | 178 &profile_, web_data_service_); |
178 | 179 |
179 MockAutofillExternalDelegate external_delegate( | 180 MockAutofillExternalDelegate external_delegate( |
180 TabContentsWrapper::GetCurrentWrapperForContents(contents())); | 181 TabContentsWrapper::GetCurrentWrapperForContents(contents())); |
181 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); | 182 EXPECT_CALL(external_delegate, OnSuggestionsReturned(_, _, _, _, _)); |
182 autocomplete_history_manager.SetExternalDelegate(&external_delegate); | 183 autocomplete_history_manager.SetExternalDelegate(&external_delegate); |
183 | 184 |
184 // Should trigger a call to OnSuggestionsReturned, verified by the mock. | 185 // Should trigger a call to OnSuggestionsReturned, verified by the mock. |
185 autocomplete_history_manager.SendSuggestions(NULL); | 186 autocomplete_history_manager.SendSuggestions(NULL); |
186 } | 187 } |
187 | 188 |
OLD | NEW |