| 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/api/infobars/infobar_service.h" | 11 #include "chrome/browser/api/infobars/infobar_service.h" |
| 12 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" | 12 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" |
| 13 #include "chrome/browser/autofill/autofill_common_test.h" | 13 #include "chrome/browser/autofill/autofill_common_test.h" |
| 14 #include "chrome/browser/autofill/autofill_manager.h" | 14 #include "chrome/browser/autofill/autofill_manager.h" |
| 15 #include "chrome/browser/autofill/autofill_manager_delegate.h" | 15 #include "chrome/browser/autofill/autofill_manager_delegate.h" |
| 16 #include "chrome/browser/autofill/autofill_metrics.h" | 16 #include "chrome/browser/autofill/autofill_metrics.h" |
| 17 #include "chrome/browser/autofill/personal_data_manager.h" | 17 #include "chrome/browser/autofill/personal_data_manager.h" |
| 18 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 18 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 19 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" | 19 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" |
| 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 21 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" | 21 #include "chrome/browser/ui/tab_contents/test_tab_contents.h" |
| 22 #include "chrome/browser/webdata/web_data_service.h" | 22 #include "chrome/browser/webdata/web_data_service.h" |
| 23 #include "chrome/common/form_data.h" |
| 24 #include "chrome/common/form_field_data.h" |
| 23 #include "chrome/test/base/testing_profile.h" | 25 #include "chrome/test/base/testing_profile.h" |
| 24 #include "content/public/test/test_browser_thread.h" | 26 #include "content/public/test/test_browser_thread.h" |
| 25 #include "testing/gmock/include/gmock/gmock.h" | 27 #include "testing/gmock/include/gmock/gmock.h" |
| 26 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 27 #include "ui/gfx/rect.h" | 29 #include "ui/gfx/rect.h" |
| 28 #include "webkit/forms/form_data.h" | |
| 29 #include "webkit/forms/form_field.h" | |
| 30 | 30 |
| 31 using content::BrowserThread; | 31 using content::BrowserThread; |
| 32 using ::testing::_; | 32 using ::testing::_; |
| 33 using ::testing::AnyNumber; | 33 using ::testing::AnyNumber; |
| 34 using ::testing::Mock; | 34 using ::testing::Mock; |
| 35 using base::TimeTicks; | 35 using base::TimeTicks; |
| 36 using base::TimeDelta; | 36 using base::TimeDelta; |
| 37 using webkit::forms::FormData; | |
| 38 using webkit::forms::FormField; | |
| 39 | 37 |
| 40 namespace { | 38 namespace { |
| 41 | 39 |
| 42 class MockAutofillMetrics : public AutofillMetrics { | 40 class MockAutofillMetrics : public AutofillMetrics { |
| 43 public: | 41 public: |
| 44 MockAutofillMetrics() {} | 42 MockAutofillMetrics() {} |
| 45 MOCK_CONST_METHOD1(LogCreditCardInfoBarMetric, void(InfoBarMetric metric)); | 43 MOCK_CONST_METHOD1(LogCreditCardInfoBarMetric, void(InfoBarMetric metric)); |
| 46 MOCK_CONST_METHOD3(LogHeuristicTypePrediction, | 44 MOCK_CONST_METHOD3(LogHeuristicTypePrediction, |
| 47 void(FieldTypeQualityMetric metric, | 45 void(FieldTypeQualityMetric metric, |
| 48 AutofillFieldType field_type, | 46 AutofillFieldType field_type, |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 TEST_F(AutofillMetricsTest, QualityMetrics) { | 330 TEST_F(AutofillMetricsTest, QualityMetrics) { |
| 333 // Set up our form data. | 331 // Set up our form data. |
| 334 FormData form; | 332 FormData form; |
| 335 form.name = ASCIIToUTF16("TestForm"); | 333 form.name = ASCIIToUTF16("TestForm"); |
| 336 form.method = ASCIIToUTF16("POST"); | 334 form.method = ASCIIToUTF16("POST"); |
| 337 form.origin = GURL("http://example.com/form.html"); | 335 form.origin = GURL("http://example.com/form.html"); |
| 338 form.action = GURL("http://example.com/submit.html"); | 336 form.action = GURL("http://example.com/submit.html"); |
| 339 form.user_submitted = true; | 337 form.user_submitted = true; |
| 340 | 338 |
| 341 std::vector<AutofillFieldType> heuristic_types, server_types; | 339 std::vector<AutofillFieldType> heuristic_types, server_types; |
| 342 FormField field; | 340 FormFieldData field; |
| 343 | 341 |
| 344 autofill_test::CreateTestFormField( | 342 autofill_test::CreateTestFormField( |
| 345 "Autofilled", "autofilled", "Elvis Aaron Presley", "text", &field); | 343 "Autofilled", "autofilled", "Elvis Aaron Presley", "text", &field); |
| 346 field.is_autofilled = true; | 344 field.is_autofilled = true; |
| 347 form.fields.push_back(field); | 345 form.fields.push_back(field); |
| 348 heuristic_types.push_back(NAME_FULL); | 346 heuristic_types.push_back(NAME_FULL); |
| 349 server_types.push_back(NAME_FIRST); | 347 server_types.push_back(NAME_FIRST); |
| 350 | 348 |
| 351 autofill_test::CreateTestFormField( | 349 autofill_test::CreateTestFormField( |
| 352 "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); | 350 "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 { | 545 { |
| 548 "Heuristics mismatch, server mismatch", "2,2", "38116", | 546 "Heuristics mismatch, server mismatch", "2,2", "38116", |
| 549 PHONE_HOME_NUMBER, PHONE_HOME_NUMBER, | 547 PHONE_HOME_NUMBER, PHONE_HOME_NUMBER, |
| 550 AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MISMATCH, | 548 AutofillMetrics::NOT_AUTOFILLED_HEURISTIC_TYPE_MISMATCH, |
| 551 AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MISMATCH | 549 AutofillMetrics::NOT_AUTOFILLED_SERVER_TYPE_MISMATCH |
| 552 } | 550 } |
| 553 }; | 551 }; |
| 554 | 552 |
| 555 std::vector<AutofillFieldType> heuristic_types, server_types; | 553 std::vector<AutofillFieldType> heuristic_types, server_types; |
| 556 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(failure_cases); ++i) { | 554 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(failure_cases); ++i) { |
| 557 FormField field; | 555 FormFieldData field; |
| 558 autofill_test::CreateTestFormField(failure_cases[i].label, | 556 autofill_test::CreateTestFormField(failure_cases[i].label, |
| 559 failure_cases[i].name, | 557 failure_cases[i].name, |
| 560 failure_cases[i].value, "text", &field); | 558 failure_cases[i].value, "text", &field); |
| 561 form.fields.push_back(field); | 559 form.fields.push_back(field); |
| 562 heuristic_types.push_back(failure_cases[i].heuristic_type); | 560 heuristic_types.push_back(failure_cases[i].heuristic_type); |
| 563 server_types.push_back(failure_cases[i].server_type); | 561 server_types.push_back(failure_cases[i].server_type); |
| 564 | 562 |
| 565 } | 563 } |
| 566 | 564 |
| 567 // Simulate having seen this form with the desired heuristic and server types. | 565 // Simulate having seen this form with the desired heuristic and server types. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 // Set up our form data. | 599 // Set up our form data. |
| 602 FormData form; | 600 FormData form; |
| 603 form.name = ASCIIToUTF16("TestForm"); | 601 form.name = ASCIIToUTF16("TestForm"); |
| 604 form.method = ASCIIToUTF16("POST"); | 602 form.method = ASCIIToUTF16("POST"); |
| 605 form.origin = GURL("http://example.com/form.html"); | 603 form.origin = GURL("http://example.com/form.html"); |
| 606 form.action = GURL("http://example.com/submit.html"); | 604 form.action = GURL("http://example.com/submit.html"); |
| 607 form.user_submitted = true; | 605 form.user_submitted = true; |
| 608 | 606 |
| 609 std::vector<AutofillFieldType> heuristic_types, server_types; | 607 std::vector<AutofillFieldType> heuristic_types, server_types; |
| 610 | 608 |
| 611 FormField field; | 609 FormFieldData field; |
| 612 autofill_test::CreateTestFormField( | 610 autofill_test::CreateTestFormField( |
| 613 "Both match", "match", "Elvis Aaron Presley", "text", &field); | 611 "Both match", "match", "Elvis Aaron Presley", "text", &field); |
| 614 field.is_autofilled = true; | 612 field.is_autofilled = true; |
| 615 form.fields.push_back(field); | 613 form.fields.push_back(field); |
| 616 heuristic_types.push_back(NAME_FULL); | 614 heuristic_types.push_back(NAME_FULL); |
| 617 server_types.push_back(NAME_FULL); | 615 server_types.push_back(NAME_FULL); |
| 618 autofill_test::CreateTestFormField( | 616 autofill_test::CreateTestFormField( |
| 619 "Both mismatch", "mismatch", "buddy@gmail.com", "text", &field); | 617 "Both mismatch", "mismatch", "buddy@gmail.com", "text", &field); |
| 620 field.is_autofilled = false; | 618 field.is_autofilled = false; |
| 621 form.fields.push_back(field); | 619 form.fields.push_back(field); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 634 heuristic_types.push_back(UNKNOWN_TYPE); | 632 heuristic_types.push_back(UNKNOWN_TYPE); |
| 635 server_types.push_back(UNKNOWN_TYPE); | 633 server_types.push_back(UNKNOWN_TYPE); |
| 636 | 634 |
| 637 // Simulate having seen this form with the desired heuristic and server types. | 635 // Simulate having seen this form with the desired heuristic and server types. |
| 638 // |form_structure| will be owned by |autofill_manager_|. | 636 // |form_structure| will be owned by |autofill_manager_|. |
| 639 autofill_manager_->AddSeenForm(form, heuristic_types, server_types, | 637 autofill_manager_->AddSeenForm(form, heuristic_types, server_types, |
| 640 std::string()); | 638 std::string()); |
| 641 | 639 |
| 642 | 640 |
| 643 // Add a field and re-arrange the remaining form fields before submitting. | 641 // Add a field and re-arrange the remaining form fields before submitting. |
| 644 std::vector<FormField> cached_fields = form.fields; | 642 std::vector<FormFieldData> cached_fields = form.fields; |
| 645 form.fields.clear(); | 643 form.fields.clear(); |
| 646 autofill_test::CreateTestFormField( | 644 autofill_test::CreateTestFormField( |
| 647 "New field", "new field", "Tennessee", "text", &field); | 645 "New field", "new field", "Tennessee", "text", &field); |
| 648 form.fields.push_back(field); | 646 form.fields.push_back(field); |
| 649 form.fields.push_back(cached_fields[2]); | 647 form.fields.push_back(cached_fields[2]); |
| 650 form.fields.push_back(cached_fields[1]); | 648 form.fields.push_back(cached_fields[1]); |
| 651 form.fields.push_back(cached_fields[3]); | 649 form.fields.push_back(cached_fields[3]); |
| 652 form.fields.push_back(cached_fields[0]); | 650 form.fields.push_back(cached_fields[0]); |
| 653 | 651 |
| 654 // Establish our expectations. | 652 // Establish our expectations. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 // Test that we don't log quality metrics for non-autofillable forms. | 754 // Test that we don't log quality metrics for non-autofillable forms. |
| 757 TEST_F(AutofillMetricsTest, NoQualityMetricsForNonAutofillableForms) { | 755 TEST_F(AutofillMetricsTest, NoQualityMetricsForNonAutofillableForms) { |
| 758 // Forms must include at least three fields to be auto-fillable. | 756 // Forms must include at least three fields to be auto-fillable. |
| 759 FormData form; | 757 FormData form; |
| 760 form.name = ASCIIToUTF16("TestForm"); | 758 form.name = ASCIIToUTF16("TestForm"); |
| 761 form.method = ASCIIToUTF16("POST"); | 759 form.method = ASCIIToUTF16("POST"); |
| 762 form.origin = GURL("http://example.com/form.html"); | 760 form.origin = GURL("http://example.com/form.html"); |
| 763 form.action = GURL("http://example.com/submit.html"); | 761 form.action = GURL("http://example.com/submit.html"); |
| 764 form.user_submitted = true; | 762 form.user_submitted = true; |
| 765 | 763 |
| 766 FormField field; | 764 FormFieldData field; |
| 767 autofill_test::CreateTestFormField( | 765 autofill_test::CreateTestFormField( |
| 768 "Autofilled", "autofilled", "Elvis Presley", "text", &field); | 766 "Autofilled", "autofilled", "Elvis Presley", "text", &field); |
| 769 field.is_autofilled = true; | 767 field.is_autofilled = true; |
| 770 form.fields.push_back(field); | 768 form.fields.push_back(field); |
| 771 autofill_test::CreateTestFormField( | 769 autofill_test::CreateTestFormField( |
| 772 "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); | 770 "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); |
| 773 form.fields.push_back(field); | 771 form.fields.push_back(field); |
| 774 | 772 |
| 775 // Simulate form submission. | 773 // Simulate form submission. |
| 776 EXPECT_CALL(*autofill_manager_->metric_logger(), | 774 EXPECT_CALL(*autofill_manager_->metric_logger(), |
| (...skipping 20 matching lines...) Expand all Loading... |
| 797 TEST_F(AutofillMetricsTest, QualityMetricsWithExperimentId) { | 795 TEST_F(AutofillMetricsTest, QualityMetricsWithExperimentId) { |
| 798 // Set up our form data. | 796 // Set up our form data. |
| 799 FormData form; | 797 FormData form; |
| 800 form.name = ASCIIToUTF16("TestForm"); | 798 form.name = ASCIIToUTF16("TestForm"); |
| 801 form.method = ASCIIToUTF16("POST"); | 799 form.method = ASCIIToUTF16("POST"); |
| 802 form.origin = GURL("http://example.com/form.html"); | 800 form.origin = GURL("http://example.com/form.html"); |
| 803 form.action = GURL("http://example.com/submit.html"); | 801 form.action = GURL("http://example.com/submit.html"); |
| 804 form.user_submitted = true; | 802 form.user_submitted = true; |
| 805 | 803 |
| 806 std::vector<AutofillFieldType> heuristic_types, server_types; | 804 std::vector<AutofillFieldType> heuristic_types, server_types; |
| 807 FormField field; | 805 FormFieldData field; |
| 808 | 806 |
| 809 autofill_test::CreateTestFormField( | 807 autofill_test::CreateTestFormField( |
| 810 "Autofilled", "autofilled", "Elvis Aaron Presley", "text", &field); | 808 "Autofilled", "autofilled", "Elvis Aaron Presley", "text", &field); |
| 811 field.is_autofilled = true; | 809 field.is_autofilled = true; |
| 812 form.fields.push_back(field); | 810 form.fields.push_back(field); |
| 813 heuristic_types.push_back(NAME_FULL); | 811 heuristic_types.push_back(NAME_FULL); |
| 814 server_types.push_back(NAME_FIRST); | 812 server_types.push_back(NAME_FIRST); |
| 815 | 813 |
| 816 autofill_test::CreateTestFormField( | 814 autofill_test::CreateTestFormField( |
| 817 "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); | 815 "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 // Test that we log the number of Autofill suggestions when filling a form. | 947 // Test that we log the number of Autofill suggestions when filling a form. |
| 950 TEST_F(AutofillMetricsTest, AddressSuggestionsCount) { | 948 TEST_F(AutofillMetricsTest, AddressSuggestionsCount) { |
| 951 // Set up our form data. | 949 // Set up our form data. |
| 952 FormData form; | 950 FormData form; |
| 953 form.name = ASCIIToUTF16("TestForm"); | 951 form.name = ASCIIToUTF16("TestForm"); |
| 954 form.method = ASCIIToUTF16("POST"); | 952 form.method = ASCIIToUTF16("POST"); |
| 955 form.origin = GURL("http://example.com/form.html"); | 953 form.origin = GURL("http://example.com/form.html"); |
| 956 form.action = GURL("http://example.com/submit.html"); | 954 form.action = GURL("http://example.com/submit.html"); |
| 957 form.user_submitted = true; | 955 form.user_submitted = true; |
| 958 | 956 |
| 959 FormField field; | 957 FormFieldData field; |
| 960 std::vector<AutofillFieldType> field_types; | 958 std::vector<AutofillFieldType> field_types; |
| 961 autofill_test::CreateTestFormField("Name", "name", "", "text", &field); | 959 autofill_test::CreateTestFormField("Name", "name", "", "text", &field); |
| 962 form.fields.push_back(field); | 960 form.fields.push_back(field); |
| 963 field_types.push_back(NAME_FULL); | 961 field_types.push_back(NAME_FULL); |
| 964 autofill_test::CreateTestFormField("Email", "email", "", "email", &field); | 962 autofill_test::CreateTestFormField("Email", "email", "", "email", &field); |
| 965 form.fields.push_back(field); | 963 form.fields.push_back(field); |
| 966 field_types.push_back(EMAIL_ADDRESS); | 964 field_types.push_back(EMAIL_ADDRESS); |
| 967 autofill_test::CreateTestFormField("Phone", "phone", "", "tel", &field); | 965 autofill_test::CreateTestFormField("Phone", "phone", "", "tel", &field); |
| 968 form.fields.push_back(field); | 966 form.fields.push_back(field); |
| 969 field_types.push_back(PHONE_HOME_NUMBER); | 967 field_types.push_back(PHONE_HOME_NUMBER); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 // and form submission. | 1121 // and form submission. |
| 1124 TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) { | 1122 TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) { |
| 1125 // Start with a form with insufficiently many fields. | 1123 // Start with a form with insufficiently many fields. |
| 1126 FormData form; | 1124 FormData form; |
| 1127 form.name = ASCIIToUTF16("TestForm"); | 1125 form.name = ASCIIToUTF16("TestForm"); |
| 1128 form.method = ASCIIToUTF16("POST"); | 1126 form.method = ASCIIToUTF16("POST"); |
| 1129 form.origin = GURL("http://example.com/form.html"); | 1127 form.origin = GURL("http://example.com/form.html"); |
| 1130 form.action = GURL("http://example.com/submit.html"); | 1128 form.action = GURL("http://example.com/submit.html"); |
| 1131 form.user_submitted = true; | 1129 form.user_submitted = true; |
| 1132 | 1130 |
| 1133 FormField field; | 1131 FormFieldData field; |
| 1134 autofill_test::CreateTestFormField("Name", "name", "", "text", &field); | 1132 autofill_test::CreateTestFormField("Name", "name", "", "text", &field); |
| 1135 form.fields.push_back(field); | 1133 form.fields.push_back(field); |
| 1136 autofill_test::CreateTestFormField("Email", "email", "", "text", &field); | 1134 autofill_test::CreateTestFormField("Email", "email", "", "text", &field); |
| 1137 form.fields.push_back(field); | 1135 form.fields.push_back(field); |
| 1138 | 1136 |
| 1139 std::vector<FormData> forms(1, form); | 1137 std::vector<FormData> forms(1, form); |
| 1140 | 1138 |
| 1141 // Expect no notifications when the form is first seen. | 1139 // Expect no notifications when the form is first seen. |
| 1142 { | 1140 { |
| 1143 EXPECT_CALL(*autofill_manager_->metric_logger(), | 1141 EXPECT_CALL(*autofill_manager_->metric_logger(), |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 // interaction. | 1255 // interaction. |
| 1258 TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) { | 1256 TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) { |
| 1259 // Load a fillable form. | 1257 // Load a fillable form. |
| 1260 FormData form; | 1258 FormData form; |
| 1261 form.name = ASCIIToUTF16("TestForm"); | 1259 form.name = ASCIIToUTF16("TestForm"); |
| 1262 form.method = ASCIIToUTF16("POST"); | 1260 form.method = ASCIIToUTF16("POST"); |
| 1263 form.origin = GURL("http://example.com/form.html"); | 1261 form.origin = GURL("http://example.com/form.html"); |
| 1264 form.action = GURL("http://example.com/submit.html"); | 1262 form.action = GURL("http://example.com/submit.html"); |
| 1265 form.user_submitted = true; | 1263 form.user_submitted = true; |
| 1266 | 1264 |
| 1267 FormField field; | 1265 FormFieldData field; |
| 1268 autofill_test::CreateTestFormField("Name", "name", "", "text", &field); | 1266 autofill_test::CreateTestFormField("Name", "name", "", "text", &field); |
| 1269 form.fields.push_back(field); | 1267 form.fields.push_back(field); |
| 1270 autofill_test::CreateTestFormField("Email", "email", "", "text", &field); | 1268 autofill_test::CreateTestFormField("Email", "email", "", "text", &field); |
| 1271 form.fields.push_back(field); | 1269 form.fields.push_back(field); |
| 1272 autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field); | 1270 autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field); |
| 1273 form.fields.push_back(field); | 1271 form.fields.push_back(field); |
| 1274 | 1272 |
| 1275 std::vector<FormData> forms(1, form); | 1273 std::vector<FormData> forms(1, form); |
| 1276 | 1274 |
| 1277 // Expect a notification when the form is first seen. | 1275 // Expect a notification when the form is first seen. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1362 // Verify that we correctly log metrics tracking the duration of form fill. | 1360 // Verify that we correctly log metrics tracking the duration of form fill. |
| 1363 TEST_F(AutofillMetricsTest, FormFillDuration) { | 1361 TEST_F(AutofillMetricsTest, FormFillDuration) { |
| 1364 // Load a fillable form. | 1362 // Load a fillable form. |
| 1365 FormData form; | 1363 FormData form; |
| 1366 form.name = ASCIIToUTF16("TestForm"); | 1364 form.name = ASCIIToUTF16("TestForm"); |
| 1367 form.method = ASCIIToUTF16("POST"); | 1365 form.method = ASCIIToUTF16("POST"); |
| 1368 form.origin = GURL("http://example.com/form.html"); | 1366 form.origin = GURL("http://example.com/form.html"); |
| 1369 form.action = GURL("http://example.com/submit.html"); | 1367 form.action = GURL("http://example.com/submit.html"); |
| 1370 form.user_submitted = true; | 1368 form.user_submitted = true; |
| 1371 | 1369 |
| 1372 FormField field; | 1370 FormFieldData field; |
| 1373 autofill_test::CreateTestFormField("Name", "name", "", "text", &field); | 1371 autofill_test::CreateTestFormField("Name", "name", "", "text", &field); |
| 1374 form.fields.push_back(field); | 1372 form.fields.push_back(field); |
| 1375 autofill_test::CreateTestFormField("Email", "email", "", "text", &field); | 1373 autofill_test::CreateTestFormField("Email", "email", "", "text", &field); |
| 1376 form.fields.push_back(field); | 1374 form.fields.push_back(field); |
| 1377 autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field); | 1375 autofill_test::CreateTestFormField("Phone", "phone", "", "text", &field); |
| 1378 form.fields.push_back(field); | 1376 form.fields.push_back(field); |
| 1379 | 1377 |
| 1380 std::vector<FormData> forms(1, form); | 1378 std::vector<FormData> forms(1, form); |
| 1381 | 1379 |
| 1382 // Fill the field values for form submission. | 1380 // Fill the field values for form submission. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1468 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), | 1466 autofill_manager_->OnTextFieldDidChange(form, form.fields.front(), |
| 1469 TimeTicks::FromInternalValue(3)); | 1467 TimeTicks::FromInternalValue(3)); |
| 1470 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); | 1468 autofill_manager_->FormSubmitted(form, TimeTicks::FromInternalValue(17)); |
| 1471 autofill_manager_->Reset(); | 1469 autofill_manager_->Reset(); |
| 1472 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); | 1470 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); |
| 1473 } | 1471 } |
| 1474 | 1472 |
| 1475 // Restore the global Gmock verbosity level to its default value. | 1473 // Restore the global Gmock verbosity level to its default value. |
| 1476 ::testing::FLAGS_gmock_verbose = "warning"; | 1474 ::testing::FLAGS_gmock_verbose = "warning"; |
| 1477 } | 1475 } |
| OLD | NEW |