| 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" |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 AutofillDriver::FORM_DATA_ACTION_FILL, _, _, _, _)); | 188 AutofillDriver::FORM_DATA_ACTION_FILL, _, _, _, _)); |
| 189 EXPECT_CALL(autofill_client_, HideAutofillPopup()); | 189 EXPECT_CALL(autofill_client_, HideAutofillPopup()); |
| 190 | 190 |
| 191 // This should trigger a call to hide the popup since we've selected an | 191 // This should trigger a call to hide the popup since we've selected an |
| 192 // option. | 192 // option. |
| 193 external_delegate_->DidAcceptSuggestion(autofill_item[0].value, | 193 external_delegate_->DidAcceptSuggestion(autofill_item[0].value, |
| 194 autofill_item[0].frontend_id, | 194 autofill_item[0].frontend_id, |
| 195 0); | 195 0); |
| 196 } | 196 } |
| 197 | 197 |
| 198 // Test that our external delegate properly adds the signin promo and its | 198 // Test that our external delegate does not add the signin promo and its |
| 199 // separator in the popup items when there are suggestions. | 199 // separator in the popup items when there are suggestions. |
| 200 TEST_F(AutofillExternalDelegateUnitTest, | 200 TEST_F(AutofillExternalDelegateUnitTest, |
| 201 TestSigninPromoIsAdded_WithSuggestions) { | 201 TestSigninPromoIsNotAdded_WithSuggestions) { |
| 202 EXPECT_CALL(*autofill_manager_, ShouldShowCreditCardSigninPromo(_, _)) | 202 EXPECT_CALL(*autofill_manager_, ShouldShowCreditCardSigninPromo(_, _)) |
| 203 .WillOnce(testing::Return(true)); | 203 .WillOnce(testing::Return(true)); |
| 204 | 204 |
| 205 IssueOnQuery(kQueryId); | 205 IssueOnQuery(kQueryId); |
| 206 | 206 |
| 207 // The enums must be cast to ints to prevent compile errors on linux_rel. | 207 // The enums must be cast to ints to prevent compile errors on linux_rel. |
| 208 auto element_ids = testing::ElementsAre( | 208 auto element_ids = |
| 209 kAutofillProfileId, | 209 testing::ElementsAre(kAutofillProfileId, |
| 210 #if !defined(OS_ANDROID) | 210 #if !defined(OS_ANDROID) |
| 211 static_cast<int>(POPUP_ITEM_ID_SEPARATOR), | 211 static_cast<int>(POPUP_ITEM_ID_SEPARATOR), |
| 212 #endif | 212 #endif |
| 213 static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS), | 213 static_cast<int>(POPUP_ITEM_ID_AUTOFILL_OPTIONS)); |
| 214 #if !defined(OS_ANDROID) | |
| 215 static_cast<int>(POPUP_ITEM_ID_SEPARATOR), | |
| 216 #endif | |
| 217 static_cast<int>(POPUP_ITEM_ID_CREDIT_CARD_SIGNIN_PROMO)); | |
| 218 | 214 |
| 219 EXPECT_CALL(autofill_client_, | 215 EXPECT_CALL(autofill_client_, |
| 220 ShowAutofillPopup(_, _, SuggestionVectorIdsAre(element_ids), _)); | 216 ShowAutofillPopup(_, _, SuggestionVectorIdsAre(element_ids), _)); |
| 221 | 217 |
| 222 base::UserActionTester user_action_tester; | 218 base::UserActionTester user_action_tester; |
| 223 | 219 |
| 224 // This should call ShowAutofillPopup. | 220 // This should call ShowAutofillPopup. |
| 225 std::vector<Suggestion> autofill_item; | 221 std::vector<Suggestion> autofill_item; |
| 226 autofill_item.push_back(Suggestion()); | 222 autofill_item.push_back(Suggestion()); |
| 227 autofill_item[0].frontend_id = kAutofillProfileId; | 223 autofill_item[0].frontend_id = kAutofillProfileId; |
| 228 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item); | 224 external_delegate_->OnSuggestionsReturned(kQueryId, autofill_item); |
| 229 EXPECT_EQ(1, user_action_tester.GetActionCount( | 225 EXPECT_EQ(0, user_action_tester.GetActionCount( |
| 230 "Signin_Impression_FromAutofillDropdown")); | 226 "Signin_Impression_FromAutofillDropdown")); |
| 231 | 227 |
| 232 EXPECT_CALL( | 228 EXPECT_CALL( |
| 233 *autofill_manager_, | 229 *autofill_manager_, |
| 234 FillOrPreviewForm(AutofillDriver::FORM_DATA_ACTION_FILL, _, _, _, _)); | 230 FillOrPreviewForm(AutofillDriver::FORM_DATA_ACTION_FILL, _, _, _, _)); |
| 235 EXPECT_CALL(autofill_client_, HideAutofillPopup()); | 231 EXPECT_CALL(autofill_client_, HideAutofillPopup()); |
| 236 | 232 |
| 237 // This should trigger a call to hide the popup since we've selected an | 233 // This should trigger a call to hide the popup since we've selected an |
| 238 // option. | 234 // option. |
| 239 external_delegate_->DidAcceptSuggestion(autofill_item[0].value, | 235 external_delegate_->DidAcceptSuggestion(autofill_item[0].value, |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 689 RendererShouldFillFieldWithValue(dummy_string)); | 685 RendererShouldFillFieldWithValue(dummy_string)); |
| 690 base::HistogramTester histogram_tester; | 686 base::HistogramTester histogram_tester; |
| 691 external_delegate_->DidAcceptSuggestion(dummy_string, | 687 external_delegate_->DidAcceptSuggestion(dummy_string, |
| 692 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, | 688 POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY, |
| 693 0); | 689 0); |
| 694 histogram_tester.ExpectUniqueSample( | 690 histogram_tester.ExpectUniqueSample( |
| 695 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); | 691 "Autofill.SuggestionAcceptedIndex.Autocomplete", 0, 1); |
| 696 } | 692 } |
| 697 | 693 |
| 698 } // namespace autofill | 694 } // namespace autofill |
| OLD | NEW |