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

Side by Side Diff: chrome/browser/autofill/autofill_metrics_unittest.cc

Issue 7576001: Refactor webkit_glue::FormField to remove hacky methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix copyright header Created 9 years, 4 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 264
265 autofill_test::CreateTestFormField( 265 autofill_test::CreateTestFormField(
266 "Autofilled", "autofilled", "Elvis Aaron Presley", "text", &field); 266 "Autofilled", "autofilled", "Elvis Aaron Presley", "text", &field);
267 field.is_autofilled = true; 267 field.is_autofilled = true;
268 form.fields.push_back(field); 268 form.fields.push_back(field);
269 heuristic_types.push_back(NAME_FULL); 269 heuristic_types.push_back(NAME_FULL);
270 server_types.push_back(NAME_FIRST); 270 server_types.push_back(NAME_FIRST);
271 271
272 autofill_test::CreateTestFormField( 272 autofill_test::CreateTestFormField(
273 "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); 273 "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field);
274 field.is_autofilled = false;
274 form.fields.push_back(field); 275 form.fields.push_back(field);
275 heuristic_types.push_back(PHONE_HOME_NUMBER); 276 heuristic_types.push_back(PHONE_HOME_NUMBER);
276 server_types.push_back(EMAIL_ADDRESS); 277 server_types.push_back(EMAIL_ADDRESS);
277 278
278 autofill_test::CreateTestFormField( 279 autofill_test::CreateTestFormField(
279 "Empty", "empty", "", "text", &field); 280 "Empty", "empty", "", "text", &field);
281 field.is_autofilled = false;
280 form.fields.push_back(field); 282 form.fields.push_back(field);
281 heuristic_types.push_back(NAME_FULL); 283 heuristic_types.push_back(NAME_FULL);
282 server_types.push_back(NAME_FIRST); 284 server_types.push_back(NAME_FIRST);
283 285
284 autofill_test::CreateTestFormField( 286 autofill_test::CreateTestFormField(
285 "Unknown", "unknown", "garbage", "text", &field); 287 "Unknown", "unknown", "garbage", "text", &field);
288 field.is_autofilled = false;
286 form.fields.push_back(field); 289 form.fields.push_back(field);
287 heuristic_types.push_back(PHONE_HOME_NUMBER); 290 heuristic_types.push_back(PHONE_HOME_NUMBER);
288 server_types.push_back(EMAIL_ADDRESS); 291 server_types.push_back(EMAIL_ADDRESS);
289 292
290 autofill_test::CreateTestFormField( 293 autofill_test::CreateTestFormField(
291 "Select", "select", "USA", "select-one", &field); 294 "Select", "select", "USA", "select-one", &field);
295 field.is_autofilled = false;
292 form.fields.push_back(field); 296 form.fields.push_back(field);
293 heuristic_types.push_back(UNKNOWN_TYPE); 297 heuristic_types.push_back(UNKNOWN_TYPE);
294 server_types.push_back(NO_SERVER_DATA); 298 server_types.push_back(NO_SERVER_DATA);
295 299
296 autofill_test::CreateTestFormField( 300 autofill_test::CreateTestFormField(
297 "Phone", "phone", "2345678901", "tel", &field); 301 "Phone", "phone", "2345678901", "tel", &field);
298 field.is_autofilled = true; 302 field.is_autofilled = true;
299 form.fields.push_back(field); 303 form.fields.push_back(field);
300 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER); 304 heuristic_types.push_back(PHONE_HOME_CITY_AND_NUMBER);
301 server_types.push_back(PHONE_HOME_WHOLE_NUMBER); 305 server_types.push_back(PHONE_HOME_WHOLE_NUMBER);
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 526
523 FormField field; 527 FormField field;
524 autofill_test::CreateTestFormField( 528 autofill_test::CreateTestFormField(
525 "Both match", "match", "Elvis Aaron Presley", "text", &field); 529 "Both match", "match", "Elvis Aaron Presley", "text", &field);
526 field.is_autofilled = true; 530 field.is_autofilled = true;
527 form.fields.push_back(field); 531 form.fields.push_back(field);
528 heuristic_types.push_back(NAME_FULL); 532 heuristic_types.push_back(NAME_FULL);
529 server_types.push_back(NAME_FULL); 533 server_types.push_back(NAME_FULL);
530 autofill_test::CreateTestFormField( 534 autofill_test::CreateTestFormField(
531 "Both mismatch", "mismatch", "buddy@gmail.com", "text", &field); 535 "Both mismatch", "mismatch", "buddy@gmail.com", "text", &field);
536 field.is_autofilled = false;
532 form.fields.push_back(field); 537 form.fields.push_back(field);
533 heuristic_types.push_back(PHONE_HOME_NUMBER); 538 heuristic_types.push_back(PHONE_HOME_NUMBER);
534 server_types.push_back(PHONE_HOME_NUMBER); 539 server_types.push_back(PHONE_HOME_NUMBER);
535 autofill_test::CreateTestFormField( 540 autofill_test::CreateTestFormField(
536 "Only heuristics match", "mixed", "Memphis", "text", &field); 541 "Only heuristics match", "mixed", "Memphis", "text", &field);
542 field.is_autofilled = false;
537 form.fields.push_back(field); 543 form.fields.push_back(field);
538 heuristic_types.push_back(ADDRESS_HOME_CITY); 544 heuristic_types.push_back(ADDRESS_HOME_CITY);
539 server_types.push_back(PHONE_HOME_NUMBER); 545 server_types.push_back(PHONE_HOME_NUMBER);
540 autofill_test::CreateTestFormField( 546 autofill_test::CreateTestFormField(
541 "Unknown", "unknown", "garbage", "text", &field); 547 "Unknown", "unknown", "garbage", "text", &field);
548 field.is_autofilled = false;
542 form.fields.push_back(field); 549 form.fields.push_back(field);
543 heuristic_types.push_back(UNKNOWN_TYPE); 550 heuristic_types.push_back(UNKNOWN_TYPE);
544 server_types.push_back(UNKNOWN_TYPE); 551 server_types.push_back(UNKNOWN_TYPE);
545 552
546 // Simulate having seen this form with the desired heuristic and server types. 553 // Simulate having seen this form with the desired heuristic and server types.
547 // |form_structure| will be owned by |autofill_manager_|. 554 // |form_structure| will be owned by |autofill_manager_|.
548 autofill_manager_->AddSeenForm(form, heuristic_types, server_types, 555 autofill_manager_->AddSeenForm(form, heuristic_types, server_types,
549 std::string()); 556 std::string());
550 557
551 558
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
714 721
715 autofill_test::CreateTestFormField( 722 autofill_test::CreateTestFormField(
716 "Autofilled", "autofilled", "Elvis Aaron Presley", "text", &field); 723 "Autofilled", "autofilled", "Elvis Aaron Presley", "text", &field);
717 field.is_autofilled = true; 724 field.is_autofilled = true;
718 form.fields.push_back(field); 725 form.fields.push_back(field);
719 heuristic_types.push_back(NAME_FULL); 726 heuristic_types.push_back(NAME_FULL);
720 server_types.push_back(NAME_FIRST); 727 server_types.push_back(NAME_FIRST);
721 728
722 autofill_test::CreateTestFormField( 729 autofill_test::CreateTestFormField(
723 "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field); 730 "Autofill Failed", "autofillfailed", "buddy@gmail.com", "text", &field);
731 field.is_autofilled = false;
724 form.fields.push_back(field); 732 form.fields.push_back(field);
725 heuristic_types.push_back(PHONE_HOME_NUMBER); 733 heuristic_types.push_back(PHONE_HOME_NUMBER);
726 server_types.push_back(EMAIL_ADDRESS); 734 server_types.push_back(EMAIL_ADDRESS);
727 735
728 autofill_test::CreateTestFormField( 736 autofill_test::CreateTestFormField(
729 "Empty", "empty", "", "text", &field); 737 "Empty", "empty", "", "text", &field);
738 field.is_autofilled = false;
730 form.fields.push_back(field); 739 form.fields.push_back(field);
731 heuristic_types.push_back(NAME_FULL); 740 heuristic_types.push_back(NAME_FULL);
732 server_types.push_back(NAME_FIRST); 741 server_types.push_back(NAME_FIRST);
733 742
734 autofill_test::CreateTestFormField( 743 autofill_test::CreateTestFormField(
735 "Unknown", "unknown", "garbage", "text", &field); 744 "Unknown", "unknown", "garbage", "text", &field);
745 field.is_autofilled = false;
736 form.fields.push_back(field); 746 form.fields.push_back(field);
737 heuristic_types.push_back(PHONE_HOME_NUMBER); 747 heuristic_types.push_back(PHONE_HOME_NUMBER);
738 server_types.push_back(EMAIL_ADDRESS); 748 server_types.push_back(EMAIL_ADDRESS);
739 749
740 autofill_test::CreateTestFormField( 750 autofill_test::CreateTestFormField(
741 "Select", "select", "USA", "select-one", &field); 751 "Select", "select", "USA", "select-one", &field);
752 field.is_autofilled = false;
742 form.fields.push_back(field); 753 form.fields.push_back(field);
743 heuristic_types.push_back(UNKNOWN_TYPE); 754 heuristic_types.push_back(UNKNOWN_TYPE);
744 server_types.push_back(NO_SERVER_DATA); 755 server_types.push_back(NO_SERVER_DATA);
745 756
746 const std::string experiment_id = "ThatOughtaDoIt"; 757 const std::string experiment_id = "ThatOughtaDoIt";
747 758
748 // Simulate having seen this form on page load. 759 // Simulate having seen this form on page load.
749 // |form_structure| will be owned by |autofill_manager_|. 760 // |form_structure| will be owned by |autofill_manager_|.
750 autofill_manager_->AddSeenForm(form, heuristic_types, server_types, 761 autofill_manager_->AddSeenForm(form, heuristic_types, server_types,
751 experiment_id); 762 experiment_id);
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1008 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED)); 1019 LogServerQueryMetric(AutofillMetrics::QUERY_RESPONSE_PARSED));
1009 EXPECT_CALL(metric_logger, 1020 EXPECT_CALL(metric_logger,
1010 LogServerExperimentIdForQuery("ar1")); 1021 LogServerExperimentIdForQuery("ar1"));
1011 EXPECT_CALL(metric_logger, 1022 EXPECT_CALL(metric_logger,
1012 LogServerQueryMetric( 1023 LogServerQueryMetric(
1013 AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS)); 1024 AutofillMetrics::QUERY_RESPONSE_MATCHED_LOCAL_HEURISTICS));
1014 FormStructure::ParseQueryResponse( 1025 FormStructure::ParseQueryResponse(
1015 "<autofillqueryresponse experimentid=\"ar1\"></autofillqueryresponse>", 1026 "<autofillqueryresponse experimentid=\"ar1\"></autofillqueryresponse>",
1016 std::vector<FormStructure*>(), metric_logger); 1027 std::vector<FormStructure*>(), metric_logger);
1017 } 1028 }
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_merge_unittest.cc ('k') | chrome/browser/autofill/credit_card_field_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698