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 "components/autofill/core/browser/autofill_metrics.h" | 5 #include "components/autofill/core/browser/autofill_metrics.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 | 118 |
119 void set_autofill_enabled(bool autofill_enabled) { | 119 void set_autofill_enabled(bool autofill_enabled) { |
120 autofill_enabled_ = autofill_enabled; | 120 autofill_enabled_ = autofill_enabled; |
121 } | 121 } |
122 | 122 |
123 virtual bool IsAutofillEnabled() const OVERRIDE { | 123 virtual bool IsAutofillEnabled() const OVERRIDE { |
124 return autofill_enabled_; | 124 return autofill_enabled_; |
125 } | 125 } |
126 | 126 |
127 MOCK_METHOD1(SaveImportedCreditCard, | 127 MOCK_METHOD1(SaveImportedCreditCard, |
128 void(const CreditCard& imported_credit_card)); | 128 std::string(const CreditCard& imported_credit_card)); |
129 | 129 |
130 private: | 130 private: |
131 void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) { | 131 void CreateTestAutofillProfiles(ScopedVector<AutofillProfile>* profiles) { |
132 AutofillProfile* profile = new AutofillProfile; | 132 AutofillProfile* profile = new AutofillProfile; |
133 test::SetProfileInfo(profile, "Elvis", "Aaron", | 133 test::SetProfileInfo(profile, "Elvis", "Aaron", |
134 "Presley", "theking@gmail.com", "RCA", | 134 "Presley", "theking@gmail.com", "RCA", |
135 "3734 Elvis Presley Blvd.", "Apt. 10", | 135 "3734 Elvis Presley Blvd.", "Apt. 10", |
136 "Memphis", "Tennessee", "38116", "US", | 136 "Memphis", "Tennessee", "38116", "US", |
137 "12345678901"); | 137 "12345678901"); |
138 profile->set_guid("00000000-0000-0000-0000-000000000001"); | 138 profile->set_guid("00000000-0000-0000-0000-000000000001"); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 } | 312 } |
313 | 313 |
314 scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate( | 314 scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate( |
315 MockAutofillMetrics* metric_logger) { | 315 MockAutofillMetrics* metric_logger) { |
316 EXPECT_CALL(*metric_logger, | 316 EXPECT_CALL(*metric_logger, |
317 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); | 317 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); |
318 | 318 |
319 CreditCard credit_card; | 319 CreditCard credit_card; |
320 return AutofillCCInfoBarDelegate::Create( | 320 return AutofillCCInfoBarDelegate::Create( |
321 metric_logger, | 321 metric_logger, |
322 base::Bind(&TestPersonalDataManager::SaveImportedCreditCard, | 322 base::Bind( |
323 base::Unretained(personal_data_.get()), credit_card)); | 323 base::IgnoreResult(&TestPersonalDataManager::SaveImportedCreditCard), |
| 324 base::Unretained(personal_data_.get()), credit_card)); |
324 } | 325 } |
325 | 326 |
326 // Test that we log quality metrics appropriately. | 327 // Test that we log quality metrics appropriately. |
327 TEST_F(AutofillMetricsTest, QualityMetrics) { | 328 TEST_F(AutofillMetricsTest, QualityMetrics) { |
328 // Set up our form data. | 329 // Set up our form data. |
329 FormData form; | 330 FormData form; |
330 form.name = ASCIIToUTF16("TestForm"); | 331 form.name = ASCIIToUTF16("TestForm"); |
331 form.method = ASCIIToUTF16("POST"); | 332 form.method = ASCIIToUTF16("POST"); |
332 form.origin = GURL("http://example.com/form.html"); | 333 form.origin = GURL("http://example.com/form.html"); |
333 form.action = GURL("http://example.com/submit.html"); | 334 form.action = GURL("http://example.com/submit.html"); |
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1546 TimeTicks::FromInternalValue(5)); | 1547 TimeTicks::FromInternalValue(5)); |
1547 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 1548 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
1548 TimeTicks::FromInternalValue(3)); | 1549 TimeTicks::FromInternalValue(3)); |
1549 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1550 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
1550 autofill_manager_->Reset(); | 1551 autofill_manager_->Reset(); |
1551 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1552 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
1552 } | 1553 } |
1553 } | 1554 } |
1554 | 1555 |
1555 } // namespace autofill | 1556 } // namespace autofill |
OLD | NEW |