| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/payments/core/address_normalizer.h" | 5 #include "components/payments/core/address_normalizer_impl.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| 11 #include "base/test/scoped_task_scheduler.h" | 11 #include "base/test/scoped_task_scheduler.h" |
| 12 #include "components/autofill/core/browser/autofill_profile.h" | 12 #include "components/autofill/core/browser/autofill_profile.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/null_stora
ge.h" | 14 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/null_stora
ge.h" |
| 15 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h" | 15 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 true, key, | 72 true, key, |
| 73 new std::string("{\"data/US\": " | 73 new std::string("{\"data/US\": " |
| 74 "{\"id\":\"data/US\",\"key\":\"US\",\"name\":\"UNITED " | 74 "{\"id\":\"data/US\",\"key\":\"US\",\"name\":\"UNITED " |
| 75 "STATES\",\"lang\":\"en\",\"languages\":\"en\"}}")); | 75 "STATES\",\"lang\":\"en\",\"languages\":\"en\"}}")); |
| 76 } | 76 } |
| 77 | 77 |
| 78 private: | 78 private: |
| 79 DISALLOW_COPY_AND_ASSIGN(ChromiumTestdataSource); | 79 DISALLOW_COPY_AND_ASSIGN(ChromiumTestdataSource); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 // A test subclass of the AddressNormalizer. Used to simulate rules not being | 82 // A test subclass of the AddressNormalizerImpl. Used to simulate rules not |
| 83 // loaded. | 83 // being loaded. |
| 84 class TestAddressNormalizer : public AddressNormalizer { | 84 class TestAddressNormalizer : public AddressNormalizerImpl { |
| 85 public: | 85 public: |
| 86 TestAddressNormalizer(std::unique_ptr<::i18n::addressinput::Source> source, | 86 TestAddressNormalizer(std::unique_ptr<::i18n::addressinput::Source> source, |
| 87 std::unique_ptr<::i18n::addressinput::Storage> storage) | 87 std::unique_ptr<::i18n::addressinput::Storage> storage) |
| 88 : AddressNormalizer(std::move(source), std::move(storage)), | 88 : AddressNormalizerImpl(std::move(source), std::move(storage)), |
| 89 should_load_rules_(true) {} | 89 should_load_rules_(true) {} |
| 90 | 90 |
| 91 ~TestAddressNormalizer() override {} | 91 ~TestAddressNormalizer() override {} |
| 92 | 92 |
| 93 void ShouldLoadRules(bool should_load_rules) { | 93 void ShouldLoadRules(bool should_load_rules) { |
| 94 should_load_rules_ = should_load_rules; | 94 should_load_rules_ = should_load_rules; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void LoadRulesForRegion(const std::string& region_code) override { | 97 void LoadRulesForRegion(const std::string& region_code) override { |
| 98 if (should_load_rules_) { | 98 if (should_load_rules_) { |
| 99 AddressNormalizer::LoadRulesForRegion(region_code); | 99 AddressNormalizerImpl::LoadRulesForRegion(region_code); |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 private: | 103 private: |
| 104 bool should_load_rules_; | 104 bool should_load_rules_; |
| 105 | 105 |
| 106 DISALLOW_COPY_AND_ASSIGN(TestAddressNormalizer); | 106 DISALLOW_COPY_AND_ASSIGN(TestAddressNormalizer); |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 } // namespace | 109 } // namespace |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 | 238 |
| 239 // Make sure the address was not normalized. | 239 // Make sure the address was not normalized. |
| 240 EXPECT_TRUE(delegate.not_normalized_called()); | 240 EXPECT_TRUE(delegate.not_normalized_called()); |
| 241 | 241 |
| 242 // Expect that the phone number was formatted. | 242 // Expect that the phone number was formatted. |
| 243 EXPECT_EQ("+15151231234", base::UTF16ToUTF8(delegate.profile().GetRawInfo( | 243 EXPECT_EQ("+15151231234", base::UTF16ToUTF8(delegate.profile().GetRawInfo( |
| 244 autofill::PHONE_HOME_WHOLE_NUMBER))); | 244 autofill::PHONE_HOME_WHOLE_NUMBER))); |
| 245 } | 245 } |
| 246 | 246 |
| 247 } // namespace payments | 247 } // namespace payments |
| OLD | NEW |