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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/string16.h" | 8 #include "base/string16.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 10 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 autofill::GenerateTestAutofillPopup(external_delegate_.get()); | 272 autofill::GenerateTestAutofillPopup(external_delegate_.get()); |
273 | 273 |
274 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 274 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
275 external_delegate_->DidEndTextFieldEditing(); | 275 external_delegate_->DidEndTextFieldEditing(); |
276 } | 276 } |
277 | 277 |
278 // Test that the popup is marked as visible after recieving password | 278 // Test that the popup is marked as visible after recieving password |
279 // suggestions. | 279 // suggestions. |
280 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegatePasswordSuggestions) { | 280 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegatePasswordSuggestions) { |
281 static const base::string16 kUsername = ASCIIToUTF16("username"); | 281 static const base::string16 kUsername = ASCIIToUTF16("username"); |
| 282 static const base::string16 kSignonRealm = ASCIIToUTF16("signon_realm"); |
282 std::vector<base::string16> suggestions; | 283 std::vector<base::string16> suggestions; |
283 suggestions.push_back(kUsername); | 284 suggestions.push_back(kUsername); |
| 285 std::vector<base::string16> realms; |
| 286 realms.push_back(kSignonRealm); |
284 | 287 |
285 FormFieldData field; | 288 FormFieldData field; |
286 field.is_focusable = true; | 289 field.is_focusable = true; |
287 field.should_autocomplete = true; | 290 field.should_autocomplete = true; |
288 const gfx::RectF element_bounds; | 291 const gfx::RectF element_bounds; |
289 | 292 |
290 FormFieldData username_field_data; | 293 FormFieldData username_field_data; |
291 username_field_data.value = kUsername; | 294 username_field_data.value = kUsername; |
292 PasswordFormFillData password_form_fill_data; | 295 PasswordFormFillData password_form_fill_data; |
293 password_form_fill_data.basic_data.fields.push_back(username_field_data); | 296 password_form_fill_data.basic_data.fields.push_back(username_field_data); |
294 external_delegate_->AddPasswordFormMapping(field, password_form_fill_data); | 297 external_delegate_->AddPasswordFormMapping(field, password_form_fill_data); |
295 | 298 |
296 // The enums must be cast to ints to prevent compile errors on linux_rel. | 299 // The enums must be cast to ints to prevent compile errors on linux_rel. |
297 EXPECT_CALL(manager_delegate_, | 300 EXPECT_CALL(manager_delegate_, |
298 ShowAutofillPopup( | 301 ShowAutofillPopup( |
299 _, _, _, _, | 302 _, _, _, _, |
300 testing::ElementsAre( | 303 testing::ElementsAre( |
301 static_cast<int>( | 304 static_cast<int>( |
302 WebAutofillClient::MenuItemIDPasswordEntry)), | 305 WebAutofillClient::MenuItemIDPasswordEntry)), |
303 _)); | 306 _)); |
304 | 307 |
305 external_delegate_->OnShowPasswordSuggestions(suggestions, | 308 external_delegate_->OnShowPasswordSuggestions(suggestions, |
| 309 realms, |
306 field, | 310 field, |
307 element_bounds); | 311 element_bounds); |
308 | 312 |
309 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 313 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
310 | 314 |
311 // This should trigger a call to hide the popup since | 315 // This should trigger a call to hide the popup since |
312 // we've selected an option. | 316 // we've selected an option. |
313 external_delegate_->DidAcceptSuggestion( | 317 external_delegate_->DidAcceptSuggestion( |
314 suggestions[0], | 318 suggestions[0], |
315 WebAutofillClient::MenuItemIDPasswordEntry); | 319 WebAutofillClient::MenuItemIDPasswordEntry); |
(...skipping 19 matching lines...) Expand all Loading... |
335 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 339 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
336 | 340 |
337 external_delegate_->OnSuggestionsReturned(kQueryId, | 341 external_delegate_->OnSuggestionsReturned(kQueryId, |
338 autofill_items, | 342 autofill_items, |
339 autofill_items, | 343 autofill_items, |
340 autofill_items, | 344 autofill_items, |
341 autofill_ids); | 345 autofill_ids); |
342 } | 346 } |
343 | 347 |
344 } // namespace autofill | 348 } // namespace autofill |
OLD | NEW |