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

Side by Side Diff: third_party/libaddressinput/chromium/chrome_address_validator_unittest.cc

Issue 638243002: replace OVERRIDE with override in third_party/libaddressinput/chromium/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove addition to README.chromium 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
« no previous file with comments | « no previous file | third_party/libaddressinput/chromium/chrome_metadata_source.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "third_party/libaddressinput/chromium/chrome_address_validator.h" 5 #include "third_party/libaddressinput/chromium/chrome_address_validator.h"
6 6
7 #include <cstddef> 7 #include <cstddef>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 validator_->LoadRules("US"); 59 validator_->LoadRules("US");
60 } 60 }
61 61
62 virtual ~AddressValidatorTest() {} 62 virtual ~AddressValidatorTest() {}
63 63
64 const scoped_ptr<AddressValidator> validator_; 64 const scoped_ptr<AddressValidator> validator_;
65 65
66 private: 66 private:
67 // LoadRulesListener implementation. 67 // LoadRulesListener implementation.
68 virtual void OnAddressValidationRulesLoaded(const std::string& country_code, 68 virtual void OnAddressValidationRulesLoaded(const std::string& country_code,
69 bool success) OVERRIDE { 69 bool success) override {
70 AddressData address_data; 70 AddressData address_data;
71 address_data.region_code = country_code; 71 address_data.region_code = country_code;
72 FieldProblemMap dummy; 72 FieldProblemMap dummy;
73 AddressValidator::Status status = 73 AddressValidator::Status status =
74 validator_->ValidateAddress(address_data, NULL, &dummy); 74 validator_->ValidateAddress(address_data, NULL, &dummy);
75 ASSERT_EQ(success, status == AddressValidator::SUCCESS); 75 ASSERT_EQ(success, status == AddressValidator::SUCCESS);
76 } 76 }
77 77
78 DISALLOW_COPY_AND_ASSIGN(AddressValidatorTest); 78 DISALLOW_COPY_AND_ASSIGN(AddressValidatorTest);
79 }; 79 };
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 scoped_ptr< ::i18n::addressinput::Source> source, 742 scoped_ptr< ::i18n::addressinput::Source> source,
743 scoped_ptr< ::i18n::addressinput::Storage> storage, 743 scoped_ptr< ::i18n::addressinput::Storage> storage,
744 LoadRulesListener* load_rules_listener) 744 LoadRulesListener* load_rules_listener)
745 : AddressValidator(source.Pass(), 745 : AddressValidator(source.Pass(),
746 storage.Pass(), 746 storage.Pass(),
747 load_rules_listener) {} 747 load_rules_listener) {}
748 748
749 virtual ~TestAddressValidator() {} 749 virtual ~TestAddressValidator() {}
750 750
751 protected: 751 protected:
752 virtual base::TimeDelta GetBaseRetryPeriod() const OVERRIDE { 752 virtual base::TimeDelta GetBaseRetryPeriod() const override {
753 return base::TimeDelta::FromSeconds(0); 753 return base::TimeDelta::FromSeconds(0);
754 } 754 }
755 755
756 private: 756 private:
757 DISALLOW_COPY_AND_ASSIGN(TestAddressValidator); 757 DISALLOW_COPY_AND_ASSIGN(TestAddressValidator);
758 }; 758 };
759 759
760 // A source that always fails |failures_number| times before downloading 760 // A source that always fails |failures_number| times before downloading
761 // data. 761 // data.
762 class FailingSource : public Source { 762 class FailingSource : public Source {
763 public: 763 public:
764 explicit FailingSource() 764 explicit FailingSource()
765 : failures_number_(0), attempts_number_(0), actual_source_(true) {} 765 : failures_number_(0), attempts_number_(0), actual_source_(true) {}
766 virtual ~FailingSource() {} 766 virtual ~FailingSource() {}
767 767
768 // Sets the number of times to fail before downloading data. 768 // Sets the number of times to fail before downloading data.
769 void set_failures_number(int failures_number) { 769 void set_failures_number(int failures_number) {
770 failures_number_ = failures_number; 770 failures_number_ = failures_number;
771 } 771 }
772 772
773 // Source implementation. 773 // Source implementation.
774 // Always fails for the first |failures_number| times. 774 // Always fails for the first |failures_number| times.
775 virtual void Get(const std::string& url, 775 virtual void Get(const std::string& url,
776 const Callback& callback) const OVERRIDE { 776 const Callback& callback) const override {
777 ++attempts_number_; 777 ++attempts_number_;
778 // |callback| takes ownership of the |new std::string|. 778 // |callback| takes ownership of the |new std::string|.
779 if (failures_number_-- > 0) 779 if (failures_number_-- > 0)
780 callback(false, url, new std::string); 780 callback(false, url, new std::string);
781 else 781 else
782 actual_source_.Get(url, callback); 782 actual_source_.Get(url, callback);
783 } 783 }
784 784
785 // Returns the number of download attempts. 785 // Returns the number of download attempts.
786 int attempts_number() const { return attempts_number_; } 786 int attempts_number() const { return attempts_number_; }
(...skipping 21 matching lines...) Expand all
808 808
809 virtual ~FailingAddressValidatorTest() {} 809 virtual ~FailingAddressValidatorTest() {}
810 810
811 FailingSource* source_; // Owned by |validator_|. 811 FailingSource* source_; // Owned by |validator_|.
812 scoped_ptr<AddressValidator> validator_; 812 scoped_ptr<AddressValidator> validator_;
813 bool load_rules_success_; 813 bool load_rules_success_;
814 814
815 private: 815 private:
816 // LoadRulesListener implementation. 816 // LoadRulesListener implementation.
817 virtual void OnAddressValidationRulesLoaded(const std::string&, 817 virtual void OnAddressValidationRulesLoaded(const std::string&,
818 bool success) OVERRIDE { 818 bool success) override {
819 load_rules_success_ = success; 819 load_rules_success_ = success;
820 } 820 }
821 821
822 base::MessageLoop ui_; 822 base::MessageLoop ui_;
823 823
824 DISALLOW_COPY_AND_ASSIGN(FailingAddressValidatorTest); 824 DISALLOW_COPY_AND_ASSIGN(FailingAddressValidatorTest);
825 }; 825 };
826 826
827 // The validator will attempt to load rules at most 8 times. 827 // The validator will attempt to load rules at most 8 times.
828 TEST_F(FailingAddressValidatorTest, RetryLoadingRulesHasLimit) { 828 TEST_F(FailingAddressValidatorTest, RetryLoadingRulesHasLimit) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 source_->set_failures_number(99); 882 source_->set_failures_number(99);
883 validator_->LoadRules("CH"); 883 validator_->LoadRules("CH");
884 validator_->LoadRules("GB"); 884 validator_->LoadRules("GB");
885 base::RunLoop().RunUntilIdle(); 885 base::RunLoop().RunUntilIdle();
886 886
887 EXPECT_FALSE(load_rules_success_); 887 EXPECT_FALSE(load_rules_success_);
888 EXPECT_EQ(16, source_->attempts_number()); 888 EXPECT_EQ(16, source_->attempts_number());
889 } 889 }
890 890
891 } // namespace autofill 891 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | third_party/libaddressinput/chromium/chrome_metadata_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698