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/strings/string16.h" | 8 #include "base/strings/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 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 autofill::GenerateTestAutofillPopup(external_delegate_.get()); | 288 autofill::GenerateTestAutofillPopup(external_delegate_.get()); |
289 | 289 |
290 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 290 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
291 external_delegate_->DidEndTextFieldEditing(); | 291 external_delegate_->DidEndTextFieldEditing(); |
292 } | 292 } |
293 | 293 |
294 // Test that the popup is marked as visible after recieving password | 294 // Test that the popup is marked as visible after recieving password |
295 // suggestions. | 295 // suggestions. |
296 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegatePasswordSuggestions) { | 296 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegatePasswordSuggestions) { |
297 static const base::string16 kUsername = ASCIIToUTF16("username"); | 297 static const base::string16 kUsername = ASCIIToUTF16("username"); |
| 298 static const base::string16 kSignonRealm = ASCIIToUTF16("signon_realm"); |
298 std::vector<base::string16> suggestions; | 299 std::vector<base::string16> suggestions; |
299 suggestions.push_back(kUsername); | 300 suggestions.push_back(kUsername); |
| 301 std::vector<base::string16> realms; |
| 302 realms.push_back(kSignonRealm); |
300 | 303 |
301 FormFieldData field; | 304 FormFieldData field; |
302 field.is_focusable = true; | 305 field.is_focusable = true; |
303 field.should_autocomplete = true; | 306 field.should_autocomplete = true; |
304 const gfx::RectF element_bounds; | 307 const gfx::RectF element_bounds; |
305 | 308 |
306 FormFieldData username_field_data; | 309 FormFieldData username_field_data; |
307 username_field_data.value = kUsername; | 310 username_field_data.value = kUsername; |
308 PasswordFormFillData password_form_fill_data; | 311 PasswordFormFillData password_form_fill_data; |
309 password_form_fill_data.basic_data.fields.push_back(username_field_data); | 312 password_form_fill_data.basic_data.fields.push_back(username_field_data); |
310 external_delegate_->AddPasswordFormMapping(field, password_form_fill_data); | 313 external_delegate_->AddPasswordFormMapping(field, password_form_fill_data); |
311 | 314 |
312 // The enums must be cast to ints to prevent compile errors on linux_rel. | 315 // The enums must be cast to ints to prevent compile errors on linux_rel. |
313 EXPECT_CALL(manager_delegate_, | 316 EXPECT_CALL(manager_delegate_, |
314 ShowAutofillPopup( | 317 ShowAutofillPopup( |
315 _, _, _, _, _, | 318 _, _, _, _, _, |
316 testing::ElementsAre( | 319 testing::ElementsAre( |
317 static_cast<int>( | 320 static_cast<int>( |
318 WebAutofillClient::MenuItemIDPasswordEntry)), | 321 WebAutofillClient::MenuItemIDPasswordEntry)), |
319 _)); | 322 _)); |
320 | 323 |
321 external_delegate_->OnShowPasswordSuggestions(suggestions, | 324 external_delegate_->OnShowPasswordSuggestions(suggestions, |
| 325 realms, |
322 field, | 326 field, |
323 element_bounds); | 327 element_bounds); |
324 | 328 |
325 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 329 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
326 | 330 |
327 // This should trigger a call to hide the popup since | 331 // This should trigger a call to hide the popup since |
328 // we've selected an option. | 332 // we've selected an option. |
329 external_delegate_->DidAcceptSuggestion( | 333 external_delegate_->DidAcceptSuggestion( |
330 suggestions[0], | 334 suggestions[0], |
331 WebAutofillClient::MenuItemIDPasswordEntry); | 335 WebAutofillClient::MenuItemIDPasswordEntry); |
(...skipping 19 matching lines...) Expand all Loading... |
351 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); | 355 EXPECT_CALL(manager_delegate_, HideAutofillPopup()); |
352 | 356 |
353 external_delegate_->OnSuggestionsReturned(kQueryId, | 357 external_delegate_->OnSuggestionsReturned(kQueryId, |
354 autofill_items, | 358 autofill_items, |
355 autofill_items, | 359 autofill_items, |
356 autofill_items, | 360 autofill_items, |
357 autofill_ids); | 361 autofill_ids); |
358 } | 362 } |
359 | 363 |
360 } // namespace autofill | 364 } // namespace autofill |
OLD | NEW |