| 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 <memory> | 5 #include <memory> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/test/histogram_tester.h" | 14 #include "base/test/histogram_tester.h" |
| 15 #include "base/test/user_action_tester.h" |
| 15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
| 16 #include "components/autofill/core/browser/autofill_manager.h" | 17 #include "components/autofill/core/browser/autofill_manager.h" |
| 17 #include "components/autofill/core/browser/autofill_metrics.h" | 18 #include "components/autofill/core/browser/autofill_metrics.h" |
| 18 #include "components/autofill/core/browser/popup_item_ids.h" | 19 #include "components/autofill/core/browser/popup_item_ids.h" |
| 19 #include "components/autofill/core/browser/suggestion_test_helpers.h" | 20 #include "components/autofill/core/browser/suggestion_test_helpers.h" |
| 20 #include "components/autofill/core/browser/test_autofill_client.h" | 21 #include "components/autofill/core/browser/test_autofill_client.h" |
| 21 #include "components/autofill/core/browser/test_autofill_driver.h" | 22 #include "components/autofill/core/browser/test_autofill_driver.h" |
| 22 #include "components/autofill/core/browser/test_autofill_external_delegate.h" | 23 #include "components/autofill/core/browser/test_autofill_external_delegate.h" |
| 23 #include "components/autofill/core/common/autofill_switches.h" | 24 #include "components/autofill/core/common/autofill_switches.h" |
| 24 #include "components/autofill/core/common/form_data.h" | 25 #include "components/autofill/core/common/form_data.h" |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 #endif | 210 #endif |
| 210 static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS), | 211 static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS), |
| 211 #if !defined(OS_ANDROID) | 212 #if !defined(OS_ANDROID) |
| 212 static_cast<int>(POPUP_ITEM_ID_SEPARATOR), | 213 static_cast<int>(POPUP_ITEM_ID_SEPARATOR), |
| 213 #endif | 214 #endif |
| 214 static_cast<int>(POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO)); | 215 static_cast<int>(POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO)); |
| 215 | 216 |
| 216 EXPECT_CALL(autofill_client_, | 217 EXPECT_CALL(autofill_client_, |
| 217 ShowAutofillPopup(_, _, SuggestionVectorIdsAre(element_ids), _)); | 218 ShowAutofillPopup(_, _, SuggestionVectorIdsAre(element_ids), _)); |
| 218 | 219 |
| 220 base::UserActionTester user_action_tester; |
| 221 |
| 219 // This should call ShowAutofillPopup. | 222 // This should call ShowAutofillPopup. |
| 220 std::vector<Suggestion> autofill_item; | 223 std::vector<Suggestion> autofill_item; |
| 221 autofill_item.push_back(Suggestion()); | 224 autofill_item.push_back(Suggestion()); |
| 222 autofill_item[0].frontend_id = kAutofillProfileId; | 225 autofill_item[0].frontend_id = kAutofillProfileId; |
| 223 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item); | 226 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item); |
| 227 EXPECT_EQ(1, user_action_tester.GetActionCount( |
| 228 "Signin_Impression_FromAutofillDropdown")); |
| 224 | 229 |
| 225 EXPECT_CALL( | 230 EXPECT_CALL( |
| 226 *autofill_manager_, | 231 *autofill_manager_, |
| 227 FillOrPreviewForm(AutofillDriver::FORM_DATA_ACTION_FILL, _, _, _, _)); | 232 FillOrPreviewForm(AutofillDriver::FORM_DATA_ACTION_FILL, _, _, _, _)); |
| 228 EXPECT_CALL(autofill_client_, HideAutofillPopup()); | 233 EXPECT_CALL(autofill_client_, HideAutofillPopup()); |
| 229 | 234 |
| 230 // This should trigger a call to hide the popup since we've selected an | 235 // This should trigger a call to hide the popup since we've selected an |
| 231 // option. | 236 // option. |
| 232 external_delegate_->DidAcceptSuggestion(autofill_item[0].value, | 237 external_delegate_->DidAcceptSuggestion(autofill_item[0].value, |
| 233 autofill_item[0].frontend_id, 0); | 238 autofill_item[0].frontend_id, 0); |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 RendererShouldFillFieldWithValue(dummy_string)); | 664 RendererShouldFillFieldWithValue(dummy_string)); |
| 660 base::HistogramTester histogram_tester; | 665 base::HistogramTester histogram_tester; |
| 661 external_delegate_->DidAcceptSuggestion(dummy_string, | 666 external_delegate_->DidAcceptSuggestion(dummy_string, |
| 662 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, | 667 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, |
| 663 0); | 668 0); |
| 664 histogram_tester.ExpectUniqueSample( | 669 histogram_tester.ExpectUniqueSample( |
| 665 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); | 670 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); |
| 666 } | 671 } |
| 667 | 672 |
| 668 } // namespace autofill | 673 } // namespace autofill |
| OLD | NEW |