| 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/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/string16.h" | 8 #include "base/string16.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "chrome/browser/autofill/autocheckout_page_meta_data.h" | 11 #include "chrome/browser/autofill/autocheckout_page_meta_data.h" |
| 12 #include "chrome/browser/autofill/autofill_cc_import_confirmation_delegate.h" |
| 13 #include "chrome/browser/autofill/autofill_cc_import_confirmation_handler.h" |
| 12 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" | 14 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" |
| 13 #include "chrome/browser/autofill/autofill_common_test.h" | 15 #include "chrome/browser/autofill/autofill_common_test.h" |
| 14 #include "chrome/browser/autofill/autofill_manager.h" | 16 #include "chrome/browser/autofill/autofill_manager.h" |
| 15 #include "chrome/browser/autofill/autofill_manager_delegate.h" | 17 #include "chrome/browser/autofill/autofill_manager_delegate.h" |
| 16 #include "chrome/browser/autofill/autofill_metrics.h" | 18 #include "chrome/browser/autofill/autofill_metrics.h" |
| 17 #include "chrome/browser/autofill/personal_data_manager.h" | 19 #include "chrome/browser/autofill/personal_data_manager.h" |
| 18 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 20 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 19 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" | 21 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" |
| 20 #include "chrome/browser/webdata/web_data_service.h" | 22 #include "chrome/browser/webdata/web_data_service.h" |
| 21 #include "chrome/common/form_data.h" | 23 #include "chrome/common/form_data.h" |
| 22 #include "chrome/common/form_field_data.h" | 24 #include "chrome/common/form_field_data.h" |
| 23 #include "chrome/test/base/chrome_render_view_host_test_harness.h" | 25 #include "chrome/test/base/chrome_render_view_host_test_harness.h" |
| 24 #include "chrome/test/base/testing_profile.h" | 26 #include "chrome/test/base/testing_profile.h" |
| 25 #include "content/public/test/test_browser_thread.h" | 27 #include "content/public/test/test_browser_thread.h" |
| 26 #include "googleurl/src/gurl.h" | 28 #include "googleurl/src/gurl.h" |
| 27 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
| 29 #include "ui/gfx/rect.h" | 31 #include "ui/gfx/rect.h" |
| 30 | 32 |
| 33 using autofill::AutofillCCImportConfirmationDelegate; |
| 34 using autofill::AutofillCCImportConfirmationHandler; |
| 31 using content::BrowserThread; | 35 using content::BrowserThread; |
| 32 using ::testing::_; | 36 using ::testing::_; |
| 33 using ::testing::AnyNumber; | 37 using ::testing::AnyNumber; |
| 34 using ::testing::Mock; | 38 using ::testing::Mock; |
| 35 using base::TimeTicks; | 39 using base::TimeTicks; |
| 36 using base::TimeDelta; | 40 using base::TimeDelta; |
| 37 | 41 |
| 38 namespace { | 42 namespace { |
| 39 | 43 |
| 40 class MockAutofillMetrics : public AutofillMetrics { | 44 class MockAutofillMetrics : public AutofillMetrics { |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 | 347 |
| 344 scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate( | 348 scoped_ptr<ConfirmInfoBarDelegate> AutofillMetricsTest::CreateDelegate( |
| 345 MockAutofillMetrics* metric_logger, | 349 MockAutofillMetrics* metric_logger, |
| 346 CreditCard** created_card) { | 350 CreditCard** created_card) { |
| 347 EXPECT_CALL(*metric_logger, | 351 EXPECT_CALL(*metric_logger, |
| 348 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); | 352 LogCreditCardInfoBarMetric(AutofillMetrics::INFOBAR_SHOWN)); |
| 349 // The delegate created below will take ownership of this object. | 353 // The delegate created below will take ownership of this object. |
| 350 CreditCard* credit_card = new CreditCard(); | 354 CreditCard* credit_card = new CreditCard(); |
| 351 if (created_card) | 355 if (created_card) |
| 352 *created_card = credit_card; | 356 *created_card = credit_card; |
| 353 return AutofillCCInfoBarDelegate::Create(credit_card, &personal_data_, | 357 |
| 354 metric_logger); | 358 scoped_ptr<AutofillCCImportConfirmationDelegate> confirmation_delegate( |
| 359 new AutofillCCImportConfirmationHandler( |
| 360 scoped_ptr<const CreditCard>(credit_card), |
| 361 &personal_data_, |
| 362 metric_logger)); |
| 363 return AutofillCCInfoBarDelegate::Create(confirmation_delegate.Pass()); |
| 355 } | 364 } |
| 356 | 365 |
| 357 // Test that we log quality metrics appropriately. | 366 // Test that we log quality metrics appropriately. |
| 358 TEST_F(AutofillMetricsTest, QualityMetrics) { | 367 TEST_F(AutofillMetricsTest, QualityMetrics) { |
| 359 // Set up our form data. | 368 // Set up our form data. |
| 360 FormData form; | 369 FormData form; |
| 361 form.name = ASCIIToUTF16("TestForm"); | 370 form.name = ASCIIToUTF16("TestForm"); |
| 362 form.method = ASCIIToUTF16("POST"); | 371 form.method = ASCIIToUTF16("POST"); |
| 363 form.origin = GURL("http://example.com/form.html"); | 372 form.origin = GURL("http://example.com/form.html"); |
| 364 form.action = GURL("http://example.com/submit.html"); | 373 form.action = GURL("http://example.com/submit.html"); |
| (...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); | 1585 autofill_manager_->OnFormsSeen(forms, TimeTicks::FromInternalValue(1)); |
| 1577 autofill_manager_->OnDidFillAutofillFormData( | 1586 autofill_manager_->OnDidFillAutofillFormData( |
| 1578 TimeTicks::FromInternalValue(5)); | 1587 TimeTicks::FromInternalValue(5)); |
| 1579 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 1588 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
| 1580 TimeTicks::FromInternalValue(3)); | 1589 TimeTicks::FromInternalValue(3)); |
| 1581 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1590 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
| 1582 autofill_manager_->Reset(); | 1591 autofill_manager_->Reset(); |
| 1583 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1592 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
| 1584 } | 1593 } |
| 1585 } | 1594 } |
| OLD | NEW |