OLD | NEW |
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/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
8 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
10 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
11 #include "components/autofill/core/browser/autofill_manager.h" | 12 #include "components/autofill/core/browser/autofill_manager.h" |
12 #include "components/autofill/core/browser/popup_item_ids.h" | 13 #include "components/autofill/core/browser/popup_item_ids.h" |
13 #include "components/autofill/core/browser/test_autofill_client.h" | 14 #include "components/autofill/core/browser/test_autofill_client.h" |
14 #include "components/autofill/core/browser/test_autofill_driver.h" | 15 #include "components/autofill/core/browser/test_autofill_driver.h" |
15 #include "components/autofill/core/browser/test_autofill_external_delegate.h" | 16 #include "components/autofill/core/browser/test_autofill_external_delegate.h" |
| 17 #include "components/autofill/core/common/autofill_switches.h" |
16 #include "components/autofill/core/common/form_data.h" | 18 #include "components/autofill/core/common/form_data.h" |
17 #include "components/autofill/core/common/form_field_data.h" | 19 #include "components/autofill/core/common/form_field_data.h" |
18 #include "components/autofill/core/common/password_form_fill_data.h" | 20 #include "components/autofill/core/common/password_form_fill_data.h" |
19 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "ui/gfx/rect.h" | 23 #include "ui/gfx/rect.h" |
22 | 24 |
23 using base::ASCIIToUTF16; | 25 using base::ASCIIToUTF16; |
24 using testing::_; | 26 using testing::_; |
25 | 27 |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 // anything. | 443 // anything. |
442 EXPECT_CALL(autofill_client_, HideAutofillPopup()); | 444 EXPECT_CALL(autofill_client_, HideAutofillPopup()); |
443 | 445 |
444 external_delegate_->OnSuggestionsReturned(kQueryId, | 446 external_delegate_->OnSuggestionsReturned(kQueryId, |
445 autofill_items, | 447 autofill_items, |
446 autofill_items, | 448 autofill_items, |
447 autofill_items, | 449 autofill_items, |
448 autofill_ids); | 450 autofill_ids); |
449 } | 451 } |
450 | 452 |
| 453 TEST_F(AutofillExternalDelegateUnitTest, IgnoreAutocompleteOffForAutofill) { |
| 454 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 455 switches::kIgnoreAutocompleteOffForAutofill); |
| 456 |
| 457 const FormData form; |
| 458 FormFieldData field; |
| 459 field.is_focusable = true; |
| 460 field.should_autocomplete = false; |
| 461 const gfx::RectF element_bounds; |
| 462 |
| 463 external_delegate_->OnQuery(kQueryId, form, field, element_bounds, false); |
| 464 |
| 465 std::vector<base::string16> autofill_items; |
| 466 autofill_items.push_back(base::string16()); |
| 467 std::vector<int> autofill_ids; |
| 468 autofill_ids.push_back(POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY); |
| 469 |
| 470 // Ensure the popup tries to show itself, despite autocomplete="off". |
| 471 EXPECT_CALL(autofill_client_, ShowAutofillPopup(_, _, _, _, _, _, _)); |
| 472 EXPECT_CALL(autofill_client_, HideAutofillPopup()).Times(0); |
| 473 |
| 474 external_delegate_->OnSuggestionsReturned(kQueryId, |
| 475 autofill_items, |
| 476 autofill_items, |
| 477 autofill_items, |
| 478 autofill_ids); |
| 479 } |
| 480 |
451 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) { | 481 TEST_F(AutofillExternalDelegateUnitTest, ExternalDelegateFillFieldWithValue) { |
452 EXPECT_CALL(autofill_client_, HideAutofillPopup()); | 482 EXPECT_CALL(autofill_client_, HideAutofillPopup()); |
453 base::string16 dummy_string(ASCIIToUTF16("baz foo")); | 483 base::string16 dummy_string(ASCIIToUTF16("baz foo")); |
454 EXPECT_CALL(*autofill_driver_, | 484 EXPECT_CALL(*autofill_driver_, |
455 RendererShouldFillFieldWithValue(dummy_string)); | 485 RendererShouldFillFieldWithValue(dummy_string)); |
456 external_delegate_->DidAcceptSuggestion(dummy_string, | 486 external_delegate_->DidAcceptSuggestion(dummy_string, |
457 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY); | 487 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY); |
458 } | 488 } |
459 | 489 |
460 } // namespace autofill | 490 } // namespace autofill |
OLD | NEW |