Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(53)

Side by Side Diff: components/autofill/core/browser/autofill_metrics_unittest.cc

Issue 365783002: Autofill: don't require POST method. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove method_ member Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
276 autofill_manager_.reset(); 276 autofill_manager_.reset();
277 autofill_driver_.reset(); 277 autofill_driver_.reset();
278 personal_data_.reset(); 278 personal_data_.reset();
279 } 279 }
280 280
281 // Test that we log quality metrics appropriately. 281 // Test that we log quality metrics appropriately.
282 TEST_F(AutofillMetricsTest, QualityMetrics) { 282 TEST_F(AutofillMetricsTest, QualityMetrics) {
283 // Set up our form data. 283 // Set up our form data.
284 FormData form; 284 FormData form;
285 form.name = ASCIIToUTF16("TestForm"); 285 form.name = ASCIIToUTF16("TestForm");
286 form.method = ASCIIToUTF16("POST");
287 form.origin = GURL("http://example.com/form.html"); 286 form.origin = GURL("http://example.com/form.html");
288 form.action = GURL("http://example.com/submit.html"); 287 form.action = GURL("http://example.com/submit.html");
289 form.user_submitted = true; 288 form.user_submitted = true;
290 289
291 std::vector<ServerFieldType> heuristic_types, server_types; 290 std::vector<ServerFieldType> heuristic_types, server_types;
292 FormFieldData field; 291 FormFieldData field;
293 292
294 test::CreateTestFormField( 293 test::CreateTestFormField(
295 "Autofilled", "autofilled", "Elvis Aaron Presley", "text", &field); 294 "Autofilled", "autofilled", "Elvis Aaron Presley", "text", &field);
296 field.is_autofilled = true; 295 field.is_autofilled = true;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 EXPECT_NO_FATAL_FAILURE(autofill_manager_->FormSubmitted(form, 383 EXPECT_NO_FATAL_FAILURE(autofill_manager_->FormSubmitted(form,
385 TimeTicks::Now())); 384 TimeTicks::Now()));
386 } 385 }
387 386
388 // Test that we behave sanely when the cached form differs from the submitted 387 // Test that we behave sanely when the cached form differs from the submitted
389 // one. 388 // one.
390 TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) { 389 TEST_F(AutofillMetricsTest, SaneMetricsWithCacheMismatch) {
391 // Set up our form data. 390 // Set up our form data.
392 FormData form; 391 FormData form;
393 form.name = ASCIIToUTF16("TestForm"); 392 form.name = ASCIIToUTF16("TestForm");
394 form.method = ASCIIToUTF16("POST");
395 form.origin = GURL("http://example.com/form.html"); 393 form.origin = GURL("http://example.com/form.html");
396 form.action = GURL("http://example.com/submit.html"); 394 form.action = GURL("http://example.com/submit.html");
397 form.user_submitted = true; 395 form.user_submitted = true;
398 396
399 std::vector<ServerFieldType> heuristic_types, server_types; 397 std::vector<ServerFieldType> heuristic_types, server_types;
400 398
401 FormFieldData field; 399 FormFieldData field;
402 test::CreateTestFormField( 400 test::CreateTestFormField(
403 "Both match", "match", "Elvis Aaron Presley", "text", &field); 401 "Both match", "match", "Elvis Aaron Presley", "text", &field);
404 field.is_autofilled = true; 402 field.is_autofilled = true;
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 // Simulate form submission. 484 // Simulate form submission.
487 EXPECT_NO_FATAL_FAILURE(autofill_manager_->FormSubmitted(form, 485 EXPECT_NO_FATAL_FAILURE(autofill_manager_->FormSubmitted(form,
488 TimeTicks::Now())); 486 TimeTicks::Now()));
489 } 487 }
490 488
491 // Verify that we correctly log metrics regarding developer engagement. 489 // Verify that we correctly log metrics regarding developer engagement.
492 TEST_F(AutofillMetricsTest, DeveloperEngagement) { 490 TEST_F(AutofillMetricsTest, DeveloperEngagement) {
493 // Start with a non-fillable form. 491 // Start with a non-fillable form.
494 FormData form; 492 FormData form;
495 form.name = ASCIIToUTF16("TestForm"); 493 form.name = ASCIIToUTF16("TestForm");
496 form.method = ASCIIToUTF16("POST");
497 form.origin = GURL("http://example.com/form.html"); 494 form.origin = GURL("http://example.com/form.html");
498 form.action = GURL("http://example.com/submit.html"); 495 form.action = GURL("http://example.com/submit.html");
499 496
500 FormFieldData field; 497 FormFieldData field;
501 test::CreateTestFormField("Name", "name", "", "text", &field); 498 test::CreateTestFormField("Name", "name", "", "text", &field);
502 form.fields.push_back(field); 499 form.fields.push_back(field);
503 test::CreateTestFormField("Email", "email", "", "text", &field); 500 test::CreateTestFormField("Email", "email", "", "text", &field);
504 form.fields.push_back(field); 501 form.fields.push_back(field);
505 502
506 std::vector<FormData> forms(1, form); 503 std::vector<FormData> forms(1, form);
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 LogIsAutofillEnabledAtStartup(false)).Times(1); 592 LogIsAutofillEnabledAtStartup(false)).Times(1);
596 personal_data_->Init( 593 personal_data_->Init(
597 autofill_client_.GetDatabase(), autofill_client_.GetPrefs(), false); 594 autofill_client_.GetDatabase(), autofill_client_.GetPrefs(), false);
598 } 595 }
599 596
600 // Test that we log the number of Autofill suggestions when filling a form. 597 // Test that we log the number of Autofill suggestions when filling a form.
601 TEST_F(AutofillMetricsTest, AddressSuggestionsCount) { 598 TEST_F(AutofillMetricsTest, AddressSuggestionsCount) {
602 // Set up our form data. 599 // Set up our form data.
603 FormData form; 600 FormData form;
604 form.name = ASCIIToUTF16("TestForm"); 601 form.name = ASCIIToUTF16("TestForm");
605 form.method = ASCIIToUTF16("POST");
606 form.origin = GURL("http://example.com/form.html"); 602 form.origin = GURL("http://example.com/form.html");
607 form.action = GURL("http://example.com/submit.html"); 603 form.action = GURL("http://example.com/submit.html");
608 form.user_submitted = true; 604 form.user_submitted = true;
609 605
610 FormFieldData field; 606 FormFieldData field;
611 std::vector<ServerFieldType> field_types; 607 std::vector<ServerFieldType> field_types;
612 test::CreateTestFormField("Name", "name", "", "text", &field); 608 test::CreateTestFormField("Name", "name", "", "text", &field);
613 form.fields.push_back(field); 609 form.fields.push_back(field);
614 field_types.push_back(NAME_FULL); 610 field_types.push_back(NAME_FULL);
615 test::CreateTestFormField("Email", "email", "", "email", &field); 611 test::CreateTestFormField("Email", "email", "", "email", &field);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
684 autofill_manager_->set_autofill_enabled(false); 680 autofill_manager_->set_autofill_enabled(false);
685 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks()); 681 autofill_manager_->OnFormsSeen(std::vector<FormData>(), TimeTicks());
686 } 682 }
687 683
688 // Verify that we correctly log user happiness metrics dealing with form loading 684 // Verify that we correctly log user happiness metrics dealing with form loading
689 // and form submission. 685 // and form submission.
690 TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) { 686 TEST_F(AutofillMetricsTest, UserHappinessFormLoadAndSubmission) {
691 // Start with a form with insufficiently many fields. 687 // Start with a form with insufficiently many fields.
692 FormData form; 688 FormData form;
693 form.name = ASCIIToUTF16("TestForm"); 689 form.name = ASCIIToUTF16("TestForm");
694 form.method = ASCIIToUTF16("POST");
695 form.origin = GURL("http://example.com/form.html"); 690 form.origin = GURL("http://example.com/form.html");
696 form.action = GURL("http://example.com/submit.html"); 691 form.action = GURL("http://example.com/submit.html");
697 form.user_submitted = true; 692 form.user_submitted = true;
698 693
699 FormFieldData field; 694 FormFieldData field;
700 test::CreateTestFormField("Name", "name", "", "text", &field); 695 test::CreateTestFormField("Name", "name", "", "text", &field);
701 form.fields.push_back(field); 696 form.fields.push_back(field);
702 test::CreateTestFormField("Email", "email", "", "text", &field); 697 test::CreateTestFormField("Email", "email", "", "text", &field);
703 form.fields.push_back(field); 698 form.fields.push_back(field);
704 699
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
818 autofill_manager_->FormSubmitted(form, TimeTicks::Now()); 813 autofill_manager_->FormSubmitted(form, TimeTicks::Now());
819 } 814 }
820 } 815 }
821 816
822 // Verify that we correctly log user happiness metrics dealing with form 817 // Verify that we correctly log user happiness metrics dealing with form
823 // interaction. 818 // interaction.
824 TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) { 819 TEST_F(AutofillMetricsTest, UserHappinessFormInteraction) {
825 // Load a fillable form. 820 // Load a fillable form.
826 FormData form; 821 FormData form;
827 form.name = ASCIIToUTF16("TestForm"); 822 form.name = ASCIIToUTF16("TestForm");
828 form.method = ASCIIToUTF16("POST");
829 form.origin = GURL("http://example.com/form.html"); 823 form.origin = GURL("http://example.com/form.html");
830 form.action = GURL("http://example.com/submit.html"); 824 form.action = GURL("http://example.com/submit.html");
831 form.user_submitted = true; 825 form.user_submitted = true;
832 826
833 FormFieldData field; 827 FormFieldData field;
834 test::CreateTestFormField("Name", "name", "", "text", &field); 828 test::CreateTestFormField("Name", "name", "", "text", &field);
835 form.fields.push_back(field); 829 form.fields.push_back(field);
836 test::CreateTestFormField("Email", "email", "", "text", &field); 830 test::CreateTestFormField("Email", "email", "", "text", &field);
837 form.fields.push_back(field); 831 form.fields.push_back(field);
838 test::CreateTestFormField("Phone", "phone", "", "text", &field); 832 test::CreateTestFormField("Phone", "phone", "", "text", &field);
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
925 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD)); 919 AutofillMetrics::USER_DID_EDIT_AUTOFILLED_FIELD));
926 autofill_manager_->OnTextFieldDidChange(form, form.fields[1], TimeTicks()); 920 autofill_manager_->OnTextFieldDidChange(form, form.fields[1], TimeTicks());
927 } 921 }
928 } 922 }
929 923
930 // Verify that we correctly log metrics tracking the duration of form fill. 924 // Verify that we correctly log metrics tracking the duration of form fill.
931 TEST_F(AutofillMetricsTest, FormFillDuration) { 925 TEST_F(AutofillMetricsTest, FormFillDuration) {
932 // Load a fillable form. 926 // Load a fillable form.
933 FormData form; 927 FormData form;
934 form.name = ASCIIToUTF16("TestForm"); 928 form.name = ASCIIToUTF16("TestForm");
935 form.method = ASCIIToUTF16("POST");
936 form.origin = GURL("http://example.com/form.html"); 929 form.origin = GURL("http://example.com/form.html");
937 form.action = GURL("http://example.com/submit.html"); 930 form.action = GURL("http://example.com/submit.html");
938 form.user_submitted = true; 931 form.user_submitted = true;
939 932
940 FormFieldData field; 933 FormFieldData field;
941 test::CreateTestFormField("Name", "name", "", "text", &field); 934 test::CreateTestFormField("Name", "name", "", "text", &field);
942 form.fields.push_back(field); 935 form.fields.push_back(field);
943 test::CreateTestFormField("Email", "email", "", "text", &field); 936 test::CreateTestFormField("Email", "email", "", "text", &field);
944 form.fields.push_back(field); 937 form.fields.push_back(field);
945 test::CreateTestFormField("Phone", "phone", "", "text", &field); 938 test::CreateTestFormField("Phone", "phone", "", "text", &field);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 autofill_manager_->OnFormsSeen(second_forms, 1082 autofill_manager_->OnFormsSeen(second_forms,
1090 TimeTicks::FromInternalValue(5)); 1083 TimeTicks::FromInternalValue(5));
1091 autofill_manager_->FormSubmitted(second_form, 1084 autofill_manager_->FormSubmitted(second_form,
1092 TimeTicks::FromInternalValue(17)); 1085 TimeTicks::FromInternalValue(17));
1093 autofill_manager_->Reset(); 1086 autofill_manager_->Reset();
1094 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger()); 1087 Mock::VerifyAndClearExpectations(autofill_manager_->metric_logger());
1095 } 1088 }
1096 } 1089 }
1097 1090
1098 } // namespace autofill 1091 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_merge_unittest.cc ('k') | components/autofill/core/browser/autofill_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698