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

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

Issue 666133002: Standardize usage of virtual/override/final in components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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 <algorithm> 5 #include <algorithm>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 }; 378 };
379 379
380 class TestAutofillManager : public AutofillManager { 380 class TestAutofillManager : public AutofillManager {
381 public: 381 public:
382 TestAutofillManager(AutofillDriver* driver, 382 TestAutofillManager(AutofillDriver* driver,
383 autofill::AutofillClient* client, 383 autofill::AutofillClient* client,
384 TestPersonalDataManager* personal_data) 384 TestPersonalDataManager* personal_data)
385 : AutofillManager(driver, client, personal_data), 385 : AutofillManager(driver, client, personal_data),
386 personal_data_(personal_data), 386 personal_data_(personal_data),
387 autofill_enabled_(true) {} 387 autofill_enabled_(true) {}
388 virtual ~TestAutofillManager() {} 388 ~TestAutofillManager() override {}
389 389
390 virtual bool IsAutofillEnabled() const override { return autofill_enabled_; } 390 bool IsAutofillEnabled() const override { return autofill_enabled_; }
391 391
392 void set_autofill_enabled(bool autofill_enabled) { 392 void set_autofill_enabled(bool autofill_enabled) {
393 autofill_enabled_ = autofill_enabled; 393 autofill_enabled_ = autofill_enabled;
394 } 394 }
395 395
396 void set_expected_submitted_field_types( 396 void set_expected_submitted_field_types(
397 const std::vector<ServerFieldTypeSet>& expected_types) { 397 const std::vector<ServerFieldTypeSet>& expected_types) {
398 expected_submitted_field_types_ = expected_types; 398 expected_submitted_field_types_ = expected_types;
399 } 399 }
400 400
401 virtual void UploadFormDataAsyncCallback( 401 void UploadFormDataAsyncCallback(
402 const FormStructure* submitted_form, 402 const FormStructure* submitted_form,
403 const base::TimeTicks& load_time, 403 const base::TimeTicks& load_time,
404 const base::TimeTicks& interaction_time, 404 const base::TimeTicks& interaction_time,
405 const base::TimeTicks& submission_time) override { 405 const base::TimeTicks& submission_time) override {
406 run_loop_->Quit(); 406 run_loop_->Quit();
407 407
408 // If we have expected field types set, make sure they match. 408 // If we have expected field types set, make sure they match.
409 if (!expected_submitted_field_types_.empty()) { 409 if (!expected_submitted_field_types_.empty()) {
410 ASSERT_EQ(expected_submitted_field_types_.size(), 410 ASSERT_EQ(expected_submitted_field_types_.size(),
411 submitted_form->field_count()); 411 submitted_form->field_count());
(...skipping 21 matching lines...) Expand all
433 submission_time); 433 submission_time);
434 } 434 }
435 435
436 // Resets the run loop so that it can wait for an asynchronous form 436 // Resets the run loop so that it can wait for an asynchronous form
437 // submission to complete. 437 // submission to complete.
438 void ResetRunLoop() { run_loop_.reset(new base::RunLoop()); } 438 void ResetRunLoop() { run_loop_.reset(new base::RunLoop()); }
439 439
440 // Wait for the asynchronous OnFormSubmitted() call to complete. 440 // Wait for the asynchronous OnFormSubmitted() call to complete.
441 void WaitForAsyncFormSubmit() { run_loop_->Run(); } 441 void WaitForAsyncFormSubmit() { run_loop_->Run(); }
442 442
443 virtual void UploadFormData(const FormStructure& submitted_form) override { 443 void UploadFormData(const FormStructure& submitted_form) override {
444 submitted_form_signature_ = submitted_form.FormSignature(); 444 submitted_form_signature_ = submitted_form.FormSignature();
445 } 445 }
446 446
447 const std::string GetSubmittedFormSignature() { 447 const std::string GetSubmittedFormSignature() {
448 return submitted_form_signature_; 448 return submitted_form_signature_;
449 } 449 }
450 450
451 AutofillProfile* GetProfileWithGUID(const char* guid) { 451 AutofillProfile* GetProfileWithGUID(const char* guid) {
452 return personal_data_->GetProfileWithGUID(guid); 452 return personal_data_->GetProfileWithGUID(guid);
453 } 453 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 DISALLOW_COPY_AND_ASSIGN(TestAutofillManager); 493 DISALLOW_COPY_AND_ASSIGN(TestAutofillManager);
494 }; 494 };
495 495
496 class TestAutofillExternalDelegate : public AutofillExternalDelegate { 496 class TestAutofillExternalDelegate : public AutofillExternalDelegate {
497 public: 497 public:
498 explicit TestAutofillExternalDelegate(AutofillManager* autofill_manager, 498 explicit TestAutofillExternalDelegate(AutofillManager* autofill_manager,
499 AutofillDriver* autofill_driver) 499 AutofillDriver* autofill_driver)
500 : AutofillExternalDelegate(autofill_manager, autofill_driver), 500 : AutofillExternalDelegate(autofill_manager, autofill_driver),
501 on_query_seen_(false), 501 on_query_seen_(false),
502 on_suggestions_returned_seen_(false) {} 502 on_suggestions_returned_seen_(false) {}
503 virtual ~TestAutofillExternalDelegate() {} 503 ~TestAutofillExternalDelegate() override {}
504 504
505 virtual void OnQuery(int query_id, 505 void OnQuery(int query_id,
506 const FormData& form, 506 const FormData& form,
507 const FormFieldData& field, 507 const FormFieldData& field,
508 const gfx::RectF& bounds, 508 const gfx::RectF& bounds,
509 bool display_warning) override { 509 bool display_warning) override {
510 on_query_seen_ = true; 510 on_query_seen_ = true;
511 on_suggestions_returned_seen_ = false; 511 on_suggestions_returned_seen_ = false;
512 } 512 }
513 513
514 virtual void OnSuggestionsReturned( 514 void OnSuggestionsReturned(
515 int query_id, 515 int query_id,
516 const std::vector<base::string16>& autofill_values, 516 const std::vector<base::string16>& autofill_values,
517 const std::vector<base::string16>& autofill_labels, 517 const std::vector<base::string16>& autofill_labels,
518 const std::vector<base::string16>& autofill_icons, 518 const std::vector<base::string16>& autofill_icons,
519 const std::vector<int>& autofill_unique_ids) override { 519 const std::vector<int>& autofill_unique_ids) override {
520 on_suggestions_returned_seen_ = true; 520 on_suggestions_returned_seen_ = true;
521 521
522 query_id_ = query_id; 522 query_id_ = query_id;
523 autofill_values_ = autofill_values; 523 autofill_values_ = autofill_values;
524 autofill_labels_ = autofill_labels; 524 autofill_labels_ = autofill_labels;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 scoped_ptr<MockAutofillDriver> autofill_driver_; 673 scoped_ptr<MockAutofillDriver> autofill_driver_;
674 scoped_ptr<TestAutofillManager> autofill_manager_; 674 scoped_ptr<TestAutofillManager> autofill_manager_;
675 scoped_ptr<TestAutofillExternalDelegate> external_delegate_; 675 scoped_ptr<TestAutofillExternalDelegate> external_delegate_;
676 TestPersonalDataManager personal_data_; 676 TestPersonalDataManager personal_data_;
677 }; 677 };
678 678
679 class TestFormStructure : public FormStructure { 679 class TestFormStructure : public FormStructure {
680 public: 680 public:
681 explicit TestFormStructure(const FormData& form) 681 explicit TestFormStructure(const FormData& form)
682 : FormStructure(form) {} 682 : FormStructure(form) {}
683 virtual ~TestFormStructure() {} 683 ~TestFormStructure() override {}
684 684
685 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types, 685 void SetFieldTypes(const std::vector<ServerFieldType>& heuristic_types,
686 const std::vector<ServerFieldType>& server_types) { 686 const std::vector<ServerFieldType>& server_types) {
687 ASSERT_EQ(field_count(), heuristic_types.size()); 687 ASSERT_EQ(field_count(), heuristic_types.size());
688 ASSERT_EQ(field_count(), server_types.size()); 688 ASSERT_EQ(field_count(), server_types.size());
689 689
690 for (size_t i = 0; i < field_count(); ++i) { 690 for (size_t i = 0; i < field_count(); ++i) {
691 AutofillField* form_field = field(i); 691 AutofillField* form_field = field(i);
692 ASSERT_TRUE(form_field); 692 ASSERT_TRUE(form_field);
693 form_field->set_heuristic_type(heuristic_types[i]); 693 form_field->set_heuristic_type(heuristic_types[i]);
(...skipping 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after
2876 autofill_manager_->ShouldShowAccessAddressBookSuggestion(form, field)); 2876 autofill_manager_->ShouldShowAccessAddressBookSuggestion(form, field));
2877 } 2877 }
2878 #endif // defined(OS_MACOSX) && !defined(OS_IOS) 2878 #endif // defined(OS_MACOSX) && !defined(OS_IOS)
2879 2879
2880 namespace { 2880 namespace {
2881 2881
2882 class MockAutofillClient : public TestAutofillClient { 2882 class MockAutofillClient : public TestAutofillClient {
2883 public: 2883 public:
2884 MockAutofillClient() {} 2884 MockAutofillClient() {}
2885 2885
2886 virtual ~MockAutofillClient() {} 2886 ~MockAutofillClient() override {}
2887 2887
2888 virtual void ShowRequestAutocompleteDialog( 2888 void ShowRequestAutocompleteDialog(const FormData& form,
2889 const FormData& form, 2889 const GURL& source_url,
2890 const GURL& source_url, 2890 const ResultCallback& callback) override {
2891 const ResultCallback& callback) override {
2892 callback.Run(user_supplied_data_ ? AutocompleteResultSuccess : 2891 callback.Run(user_supplied_data_ ? AutocompleteResultSuccess :
2893 AutocompleteResultErrorDisabled, 2892 AutocompleteResultErrorDisabled,
2894 base::string16(), 2893 base::string16(),
2895 user_supplied_data_.get()); 2894 user_supplied_data_.get());
2896 } 2895 }
2897 2896
2898 void SetUserSuppliedData(scoped_ptr<FormStructure> user_supplied_data) { 2897 void SetUserSuppliedData(scoped_ptr<FormStructure> user_supplied_data) {
2899 user_supplied_data_.reset(user_supplied_data.release()); 2898 user_supplied_data_.reset(user_supplied_data.release());
2900 } 2899 }
2901 2900
(...skipping 11 matching lines...) Expand all
2913 test::CreateTestAddressFormData(&form); 2912 test::CreateTestAddressFormData(&form);
2914 std::vector<FormData> forms(1, form); 2913 std::vector<FormData> forms(1, form);
2915 FormsSeen(forms); 2914 FormsSeen(forms);
2916 const FormFieldData& field = form.fields[0]; 2915 const FormFieldData& field = form.fields[0];
2917 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery() 2916 GetAutofillSuggestions(form, field); // should call the delegate's OnQuery()
2918 2917
2919 EXPECT_TRUE(external_delegate_->on_query_seen()); 2918 EXPECT_TRUE(external_delegate_->on_query_seen());
2920 } 2919 }
2921 2920
2922 } // namespace autofill 2921 } // namespace autofill
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_manager.h ('k') | components/autofill/core/browser/autofill_merge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698