OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | |
9 #include <string> | 8 #include <string> |
| 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
14 #include "base/run_loop.h" | 14 #include "base/run_loop.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" | 17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" |
18 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_pr
oblem.h" | 18 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_pr
oblem.h" |
19 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
.h" | 19 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
.h" |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 } | 733 } |
734 | 734 |
735 // Use this test fixture for configuring the number of failed attempts to load | 735 // Use this test fixture for configuring the number of failed attempts to load |
736 // rules. | 736 // rules. |
737 class FailingAddressValidatorTest : public testing::Test, LoadRulesListener { | 737 class FailingAddressValidatorTest : public testing::Test, LoadRulesListener { |
738 protected: | 738 protected: |
739 // A validator that retries loading rules without delay. | 739 // A validator that retries loading rules without delay. |
740 class TestAddressValidator : public AddressValidator { | 740 class TestAddressValidator : public AddressValidator { |
741 public: | 741 public: |
742 // Takes ownership of |source| and |storage|. | 742 // Takes ownership of |source| and |storage|. |
743 TestAddressValidator( | 743 TestAddressValidator(scoped_ptr<::i18n::addressinput::Source> source, |
744 scoped_ptr< ::i18n::addressinput::Source> source, | 744 scoped_ptr<::i18n::addressinput::Storage> storage, |
745 scoped_ptr< ::i18n::addressinput::Storage> storage, | 745 LoadRulesListener* load_rules_listener) |
746 LoadRulesListener* load_rules_listener) | 746 : AddressValidator(std::move(source), |
747 : AddressValidator(source.Pass(), | 747 std::move(storage), |
748 storage.Pass(), | |
749 load_rules_listener) {} | 748 load_rules_listener) {} |
750 | 749 |
751 virtual ~TestAddressValidator() {} | 750 virtual ~TestAddressValidator() {} |
752 | 751 |
753 protected: | 752 protected: |
754 virtual base::TimeDelta GetBaseRetryPeriod() const override { | 753 virtual base::TimeDelta GetBaseRetryPeriod() const override { |
755 return base::TimeDelta::FromSeconds(0); | 754 return base::TimeDelta::FromSeconds(0); |
756 } | 755 } |
757 | 756 |
758 private: | 757 private: |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 source_->set_failures_number(99); | 883 source_->set_failures_number(99); |
885 validator_->LoadRules("CH"); | 884 validator_->LoadRules("CH"); |
886 validator_->LoadRules("GB"); | 885 validator_->LoadRules("GB"); |
887 base::RunLoop().RunUntilIdle(); | 886 base::RunLoop().RunUntilIdle(); |
888 | 887 |
889 EXPECT_FALSE(load_rules_success_); | 888 EXPECT_FALSE(load_rules_success_); |
890 EXPECT_EQ(16, source_->attempts_number()); | 889 EXPECT_EQ(16, source_->attempts_number()); |
891 } | 890 } |
892 | 891 |
893 } // namespace autofill | 892 } // namespace autofill |
OLD | NEW |