Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: components/autofill/core/browser/autofill_external_delegate_unittest.cc

Issue 1082183002: Android - Introduce "keyboard accessory" for Autofill suggestions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 scoped_ptr<AutofillExternalDelegate> external_delegate_; 150 scoped_ptr<AutofillExternalDelegate> external_delegate_;
151 151
152 base::MessageLoop message_loop_; 152 base::MessageLoop message_loop_;
153 }; 153 };
154 154
155 // Test that our external delegate called the virtual methods at the right time. 155 // Test that our external delegate called the virtual methods at the right time.
156 TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) { 156 TEST_F(AutofillExternalDelegateUnitTest, TestExternalDelegateVirtualCalls) {
157 IssueOnQuery(kQueryId); 157 IssueOnQuery(kQueryId);
158 158
159 // The enums must be cast to ints to prevent compile errors on linux_rel. 159 // The enums must be cast to ints to prevent compile errors on linux_rel.
160 auto element_ids = testing::ElementsAre(
161 kAutofillProfileId,
162 #if !defined(OS_ANDROID)
163 static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
164 #endif
165 static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS));
160 EXPECT_CALL( 166 EXPECT_CALL(
161 autofill_client_, 167 autofill_client_,
162 ShowAutofillPopup(_, 168 ShowAutofillPopup(_, _, SuggestionVectorIdsAre(element_ids), _));
163 _,
164 SuggestionVectorIdsAre(testing::ElementsAre(
165 kAutofillProfileId,
166 static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
167 static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS))),
168 _));
169 169
170 // This should call ShowAutofillPopup. 170 // This should call ShowAutofillPopup.
171 std::vector<Suggestion> autofill_item; 171 std::vector<Suggestion> autofill_item;
172 autofill_item.push_back(Suggestion()); 172 autofill_item.push_back(Suggestion());
173 autofill_item[0].frontend_id = kAutofillProfileId; 173 autofill_item[0].frontend_id = kAutofillProfileId;
174 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item); 174 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item);
175 175
176 EXPECT_CALL(*autofill_manager_, 176 EXPECT_CALL(*autofill_manager_,
177 FillOrPreviewForm( 177 FillOrPreviewForm(
178 AutofillDriver::FORM_DATA_ACTION_FILL, _, _, _, _)); 178 AutofillDriver::FORM_DATA_ACTION_FILL, _, _, _, _));
(...skipping 13 matching lines...) Expand all
192 data_list_items.push_back(base::string16()); 192 data_list_items.push_back(base::string16());
193 193
194 EXPECT_CALL( 194 EXPECT_CALL(
195 autofill_client_, 195 autofill_client_,
196 UpdateAutofillPopupDataListValues(data_list_items, data_list_items)); 196 UpdateAutofillPopupDataListValues(data_list_items, data_list_items));
197 197
198 external_delegate_->SetCurrentDataListValues(data_list_items, 198 external_delegate_->SetCurrentDataListValues(data_list_items,
199 data_list_items); 199 data_list_items);
200 200
201 // The enums must be cast to ints to prevent compile errors on linux_rel. 201 // The enums must be cast to ints to prevent compile errors on linux_rel.
202 auto element_ids = testing::ElementsAre(
203 static_cast<int>(POPUP_ITEM_ID_DATALIST_ENTRY),
204 #if !defined(OS_ANDROID)
205 static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
206 #endif
207 kAutofillProfileId,
208 #if !defined(OS_ANDROID)
209 static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
210 #endif
211 static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS));
202 EXPECT_CALL( 212 EXPECT_CALL(
203 autofill_client_, 213 autofill_client_,
204 ShowAutofillPopup(_, 214 ShowAutofillPopup(_, _, SuggestionVectorIdsAre(element_ids), _));
205 _,
206 SuggestionVectorIdsAre(testing::ElementsAre(
207 static_cast<int>(POPUP_ITEM_ID_DATALIST_ENTRY),
208 static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
209 kAutofillProfileId,
210 static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
211 static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS))),
212 _));
213 215
214 // This should call ShowAutofillPopup. 216 // This should call ShowAutofillPopup.
215 std::vector<Suggestion> autofill_item; 217 std::vector<Suggestion> autofill_item;
216 autofill_item.push_back(Suggestion()); 218 autofill_item.push_back(Suggestion());
217 autofill_item[0].frontend_id = kAutofillProfileId; 219 autofill_item[0].frontend_id = kAutofillProfileId;
218 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item); 220 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item);
219 221
220 // Try calling OnSuggestionsReturned with no Autofill values and ensure 222 // Try calling OnSuggestionsReturned with no Autofill values and ensure
221 // the datalist items are still shown. 223 // the datalist items are still shown.
222 // The enum must be cast to an int to prevent compile errors on linux_rel. 224 // The enum must be cast to an int to prevent compile errors on linux_rel.
(...skipping 23 matching lines...) Expand all
246 data_list_items.push_back(base::string16()); 248 data_list_items.push_back(base::string16());
247 249
248 EXPECT_CALL( 250 EXPECT_CALL(
249 autofill_client_, 251 autofill_client_,
250 UpdateAutofillPopupDataListValues(data_list_items, data_list_items)); 252 UpdateAutofillPopupDataListValues(data_list_items, data_list_items));
251 253
252 external_delegate_->SetCurrentDataListValues(data_list_items, 254 external_delegate_->SetCurrentDataListValues(data_list_items,
253 data_list_items); 255 data_list_items);
254 256
255 // The enums must be cast to ints to prevent compile errors on linux_rel. 257 // The enums must be cast to ints to prevent compile errors on linux_rel.
258 auto element_ids = testing::ElementsAre(
259 static_cast<int>(POPUP_ITEM_ID_DATALIST_ENTRY),
260 #if !defined(OS_ANDROID)
261 static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
262 #endif
263 kAutofillProfileId,
264 #if !defined(OS_ANDROID)
265 static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
266 #endif
267 static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS));
256 EXPECT_CALL( 268 EXPECT_CALL(
257 autofill_client_, 269 autofill_client_,
258 ShowAutofillPopup(_, 270 ShowAutofillPopup(_, _, SuggestionVectorIdsAre(element_ids), _));
259 _,
260 SuggestionVectorIdsAre(testing::ElementsAre(
261 static_cast<int>(POPUP_ITEM_ID_DATALIST_ENTRY),
262 static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
263 kAutofillProfileId,
264 static_cast<int>(POPUP_ITEM_ID_SEPARATOR),
265 static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS))),
266 _));
267 271
268 // Ensure the popup is displayed. 272 // Ensure the popup is displayed.
269 std::vector<Suggestion> autofill_item; 273 std::vector<Suggestion> autofill_item;
270 autofill_item.push_back(Suggestion()); 274 autofill_item.push_back(Suggestion());
271 autofill_item[0].frontend_id = kAutofillProfileId; 275 autofill_item[0].frontend_id = kAutofillProfileId;
272 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item); 276 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item);
273 277
274 // This would normally get called from ShowAutofillPopup, but it is mocked so 278 // This would normally get called from ShowAutofillPopup, but it is mocked so
275 // we need to call OnPopupShown ourselves. 279 // we need to call OnPopupShown ourselves.
276 external_delegate_->OnPopupShown(); 280 external_delegate_->OnPopupShown();
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) { 487 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) {
484 EXPECT_CALL(autofill_client_, HideAutofillPopup()); 488 EXPECT_CALL(autofill_client_, HideAutofillPopup());
485 base::string16 dummy_string(ASCIIToUTF16("baz foo")); 489 base::string16 dummy_string(ASCIIToUTF16("baz foo"));
486 EXPECT_CALL(*autofill_driver_, 490 EXPECT_CALL(*autofill_driver_,
487 RendererShouldFillFieldWithValue(dummy_string)); 491 RendererShouldFillFieldWithValue(dummy_string));
488 external_delegate_->DidAcceptSuggestion(dummy_string, 492 external_delegate_->DidAcceptSuggestion(dummy_string,
489 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY); 493 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY);
490 } 494 }
491 495
492 } // namespace autofill 496 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_external_delegate.cc ('k') | components/autofill/core/common/autofill_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698