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 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 static AddressValidator* validator_; | 113 static AddressValidator* validator_; |
114 | 114 |
115 private: | 115 private: |
116 DISALLOW_COPY_AND_ASSIGN(LargeAddressValidatorTest); | 116 DISALLOW_COPY_AND_ASSIGN(LargeAddressValidatorTest); |
117 }; | 117 }; |
118 | 118 |
119 AddressValidator* LargeAddressValidatorTest::validator_ = NULL; | 119 AddressValidator* LargeAddressValidatorTest::validator_ = NULL; |
120 | 120 |
121 TEST_F(AddressValidatorTest, SubKeysLoaded) { | 121 TEST_F(AddressValidatorTest, SubKeysLoaded) { |
122 const std::string country_code = "US"; | 122 const std::string country_code = "US"; |
123 const std::string first_state = "AL"; | 123 const std::string state_code = "AA"; |
| 124 const std::string state_name = "Armed Forces (AA)"; |
124 | 125 |
125 validator_->LoadRules(country_code); | 126 validator_->LoadRules(country_code); |
126 std::vector<std::string> sub_keys = | 127 std::vector<std::pair<std::string, std::string>> sub_keys = |
127 validator_->GetRegionSubKeys(country_code); | 128 validator_->GetRegionSubKeys(country_code); |
128 ASSERT_FALSE(sub_keys.empty()); | 129 ASSERT_FALSE(sub_keys.empty()); |
129 ASSERT_EQ(sub_keys[0], first_state); | 130 ASSERT_EQ(state_code, sub_keys[0].first); |
| 131 ASSERT_EQ(state_name, sub_keys[0].second); |
130 } | 132 } |
131 | 133 |
132 TEST_F(AddressValidatorTest, SubKeysNotExist) { | 134 TEST_F(AddressValidatorTest, SubKeysNotExist) { |
133 const std::string country_code = "OZ"; | 135 const std::string country_code = "OZ"; |
134 | 136 |
135 set_expected_status(AddressValidator::RULES_UNAVAILABLE); | 137 set_expected_status(AddressValidator::RULES_UNAVAILABLE); |
136 | 138 |
137 validator_->LoadRules(country_code); | 139 validator_->LoadRules(country_code); |
138 std::vector<std::string> sub_keys = | 140 std::vector<std::pair<std::string, std::string>> sub_keys = |
139 validator_->GetRegionSubKeys(country_code); | 141 validator_->GetRegionSubKeys(country_code); |
140 ASSERT_TRUE(sub_keys.empty()); | 142 ASSERT_TRUE(sub_keys.empty()); |
141 } | 143 } |
142 | 144 |
143 TEST_F(AddressValidatorTest, RegionHasRules) { | 145 TEST_F(AddressValidatorTest, RegionHasRules) { |
144 const std::vector<std::string>& region_codes = GetRegionCodes(); | 146 const std::vector<std::string>& region_codes = GetRegionCodes(); |
145 AddressData address; | 147 AddressData address; |
146 for (size_t i = 0; i < region_codes.size(); ++i) { | 148 for (size_t i = 0; i < region_codes.size(); ++i) { |
147 SCOPED_TRACE("For region: " + region_codes[i]); | 149 SCOPED_TRACE("For region: " + region_codes[i]); |
148 validator_->LoadRules(region_codes[i]); | 150 validator_->LoadRules(region_codes[i]); |
(...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
919 source_->set_failures_number(99); | 921 source_->set_failures_number(99); |
920 validator_->LoadRules("CH"); | 922 validator_->LoadRules("CH"); |
921 validator_->LoadRules("GB"); | 923 validator_->LoadRules("GB"); |
922 base::RunLoop().RunUntilIdle(); | 924 base::RunLoop().RunUntilIdle(); |
923 | 925 |
924 EXPECT_FALSE(load_rules_success_); | 926 EXPECT_FALSE(load_rules_success_); |
925 EXPECT_EQ(16, source_->attempts_number()); | 927 EXPECT_EQ(16, source_->attempts_number()); |
926 } | 928 } |
927 | 929 |
928 } // namespace autofill | 930 } // namespace autofill |
OLD | NEW |