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

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

Issue 5703002: Add some basic success/failure UMA logging for autofill. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Forbid copying, assignments (just like in, school) Created 10 years 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
« no previous file with comments | « chrome/browser/autofill/autofill_manager.cc ('k') | chrome/browser/autofill/autofill_metrics.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/ref_counted.h" 8 #include "base/ref_counted.h"
9 #include "base/scoped_ptr.h" 9 #include "base/scoped_ptr.h"
10 #include "base/scoped_vector.h" 10 #include "base/scoped_vector.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 "Phone Number", "phonenumber", "", "text", &field); 176 "Phone Number", "phonenumber", "", "text", &field);
177 form->fields.push_back(field); 177 form->fields.push_back(field);
178 autofill_test::CreateTestFormField( 178 autofill_test::CreateTestFormField(
179 "Fax", "fax", "", "text", &field); 179 "Fax", "fax", "", "text", &field);
180 form->fields.push_back(field); 180 form->fields.push_back(field);
181 autofill_test::CreateTestFormField( 181 autofill_test::CreateTestFormField(
182 "Email", "email", "", "text", &field); 182 "Email", "email", "", "text", &field);
183 form->fields.push_back(field); 183 form->fields.push_back(field);
184 } 184 }
185 185
186 // Populates |form| with data corresponding to a simple credit card form, with. 186 // Populates |form| with data corresponding to a simple credit card form.
187 // Note that this actually appends fields to the form data, which can be useful 187 // Note that this actually appends fields to the form data, which can be useful
188 // for building up more complex test forms. 188 // for building up more complex test forms.
189 void CreateTestCreditCardFormData(FormData* form, bool is_https) { 189 void CreateTestCreditCardFormData(FormData* form, bool is_https) {
190 form->name = ASCIIToUTF16("MyForm"); 190 form->name = ASCIIToUTF16("MyForm");
191 form->method = ASCIIToUTF16("POST"); 191 form->method = ASCIIToUTF16("POST");
192 if (is_https) { 192 if (is_https) {
193 form->origin = GURL("https://myform.com/form.html"); 193 form->origin = GURL("https://myform.com/form.html");
194 form->action = GURL("https://myform.com/submit.html"); 194 form->action = GURL("https://myform.com/submit.html");
195 } else { 195 } else {
196 form->origin = GURL("http://myform.com/form.html"); 196 form->origin = GURL("http://myform.com/form.html");
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 void ExpectFilledCreditCardFormElvis(int page_id, 357 void ExpectFilledCreditCardFormElvis(int page_id,
358 const FormData& filled_form, 358 const FormData& filled_form,
359 int expected_page_id, 359 int expected_page_id,
360 bool has_address_fields) { 360 bool has_address_fields) {
361 ExpectFilledForm(page_id, filled_form, expected_page_id, 361 ExpectFilledForm(page_id, filled_form, expected_page_id,
362 "", "", "", "", "", "", "", "", "", "", "", "", 362 "", "", "", "", "", "", "", "", "", "", "", "",
363 "Elvis Presley", "4234567890123456", "04", "2012", 363 "Elvis Presley", "4234567890123456", "04", "2012",
364 has_address_fields, true); 364 has_address_fields, true);
365 } 365 }
366 366
367 } // namespace
368
369 class TestAutoFillManager : public AutoFillManager { 367 class TestAutoFillManager : public AutoFillManager {
370 public: 368 public:
371 TestAutoFillManager(TabContents* tab_contents, 369 TestAutoFillManager(TabContents* tab_contents,
372 TestPersonalDataManager* personal_manager) 370 TestPersonalDataManager* personal_manager)
373 : AutoFillManager(tab_contents, NULL), 371 : AutoFillManager(tab_contents, personal_manager),
374 autofill_enabled_(true) { 372 autofill_enabled_(true) {
375 test_personal_data_ = personal_manager; 373 test_personal_data_ = personal_manager;
376 set_personal_data_manager(personal_manager);
377 // Download manager requests are disabled for purposes of this unit test.
378 // These requests are tested in autofill_download_unittest.cc.
379 set_disable_download_manager_requests(true);
380 } 374 }
381 375
382 virtual bool IsAutoFillEnabled() const { return autofill_enabled_; } 376 virtual bool IsAutoFillEnabled() const { return autofill_enabled_; }
383 377
384 void set_autofill_enabled(bool autofill_enabled) { 378 void set_autofill_enabled(bool autofill_enabled) {
385 autofill_enabled_ = autofill_enabled; 379 autofill_enabled_ = autofill_enabled;
386 } 380 }
387 381
388 AutoFillProfile* GetLabeledProfile(const char* label) { 382 AutoFillProfile* GetLabeledProfile(const char* label) {
389 return test_personal_data_->GetLabeledProfile(label); 383 return test_personal_data_->GetLabeledProfile(label);
(...skipping 28 matching lines...) Expand all
418 return base::StringPrintf("00000000-0000-0000-0000-%012d", id); 412 return base::StringPrintf("00000000-0000-0000-0000-%012d", id);
419 } 413 }
420 414
421 private: 415 private:
422 TestPersonalDataManager* test_personal_data_; 416 TestPersonalDataManager* test_personal_data_;
423 bool autofill_enabled_; 417 bool autofill_enabled_;
424 418
425 DISALLOW_COPY_AND_ASSIGN(TestAutoFillManager); 419 DISALLOW_COPY_AND_ASSIGN(TestAutoFillManager);
426 }; 420 };
427 421
422 } // namespace
423
428 class AutoFillManagerTest : public RenderViewHostTestHarness { 424 class AutoFillManagerTest : public RenderViewHostTestHarness {
429 public: 425 public:
430 AutoFillManagerTest() {} 426 AutoFillManagerTest() {}
431 virtual ~AutoFillManagerTest() { 427 virtual ~AutoFillManagerTest() {
432 // Order of destruction is important as AutoFillManager relies on 428 // Order of destruction is important as AutoFillManager relies on
433 // PersonalDataManager to be around when it gets destroyed. 429 // PersonalDataManager to be around when it gets destroyed.
434 autofill_manager_.reset(NULL); 430 autofill_manager_.reset(NULL);
435 test_personal_data_ = NULL; 431 test_personal_data_ = NULL;
436 } 432 }
437 433
(...skipping 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( 1518 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean(
1523 prefs::kAutoFillAuxiliaryProfilesEnabled)); 1519 prefs::kAutoFillAuxiliaryProfilesEnabled));
1524 profile()->GetPrefs()->SetBoolean( 1520 profile()->GetPrefs()->SetBoolean(
1525 prefs::kAutoFillAuxiliaryProfilesEnabled, true); 1521 prefs::kAutoFillAuxiliaryProfilesEnabled, true);
1526 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled); 1522 profile()->GetPrefs()->ClearPref(prefs::kAutoFillAuxiliaryProfilesEnabled);
1527 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean( 1523 ASSERT_FALSE(profile()->GetPrefs()->GetBoolean(
1528 prefs::kAutoFillAuxiliaryProfilesEnabled)); 1524 prefs::kAutoFillAuxiliaryProfilesEnabled));
1529 #endif 1525 #endif
1530 } 1526 }
1531 1527
OLDNEW
« no previous file with comments | « chrome/browser/autofill/autofill_manager.cc ('k') | chrome/browser/autofill/autofill_metrics.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698