| 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 <cstddef> | 7 #include <cstddef> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
| 13 #include "base/strings/utf_string_conversions.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" | 15 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_da
ta.h" |
| 15 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_pr
oblem.h" | 16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_pr
oblem.h" |
| 16 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
.h" | 17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
.h" |
| 17 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/downloader
.h" | 18 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/downloader
.h" |
| 18 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/null_stora
ge.h" | 19 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/null_stora
ge.h" |
| 19 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h" | 20 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/storage.h" |
| 20 #include "third_party/libaddressinput/src/cpp/test/fake_downloader.h" | 21 #include "third_party/libaddressinput/src/cpp/test/fake_downloader.h" |
| 21 | 22 |
| 22 namespace autofill { | 23 namespace autofill { |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 EXPECT_TRUE(problems.empty()); | 241 EXPECT_TRUE(problems.empty()); |
| 241 | 242 |
| 242 // Ignore capitalization. | 243 // Ignore capitalization. |
| 243 address.administrative_area = "teXas"; | 244 address.administrative_area = "teXas"; |
| 244 problems.clear(); | 245 problems.clear(); |
| 245 EXPECT_EQ(AddressValidator::SUCCESS, | 246 EXPECT_EQ(AddressValidator::SUCCESS, |
| 246 validator_->ValidateAddress(address, NULL, &problems)); | 247 validator_->ValidateAddress(address, NULL, &problems)); |
| 247 EXPECT_TRUE(problems.empty()); | 248 EXPECT_TRUE(problems.empty()); |
| 248 | 249 |
| 249 // Ignore diacriticals. | 250 // Ignore diacriticals. |
| 250 address.administrative_area = "T\u00E9xas"; | 251 address.administrative_area = base::WideToUTF8(L"T\u00E9xas"); |
| 251 problems.clear(); | 252 problems.clear(); |
| 252 EXPECT_EQ(AddressValidator::SUCCESS, | 253 EXPECT_EQ(AddressValidator::SUCCESS, |
| 253 validator_->ValidateAddress(address, NULL, &problems)); | 254 validator_->ValidateAddress(address, NULL, &problems)); |
| 254 EXPECT_TRUE(problems.empty()); | 255 EXPECT_TRUE(problems.empty()); |
| 255 } | 256 } |
| 256 | 257 |
| 257 TEST_F(AddressValidatorTest, BasicValidationFailure) { | 258 TEST_F(AddressValidatorTest, BasicValidationFailure) { |
| 258 // US rules should always be available, even though this load call fails. | 259 // US rules should always be available, even though this load call fails. |
| 259 validator_->LoadRules("US"); | 260 validator_->LoadRules("US"); |
| 260 AddressData address; | 261 AddressData address; |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 885 downloader_->set_failures_number(99); | 886 downloader_->set_failures_number(99); |
| 886 validator_->LoadRules("CH"); | 887 validator_->LoadRules("CH"); |
| 887 validator_->LoadRules("GB"); | 888 validator_->LoadRules("GB"); |
| 888 base::RunLoop().RunUntilIdle(); | 889 base::RunLoop().RunUntilIdle(); |
| 889 | 890 |
| 890 EXPECT_FALSE(load_rules_success_); | 891 EXPECT_FALSE(load_rules_success_); |
| 891 EXPECT_EQ(16, downloader_->attempts_number()); | 892 EXPECT_EQ(16, downloader_->attempts_number()); |
| 892 } | 893 } |
| 893 | 894 |
| 894 } // namespace autofill | 895 } // namespace autofill |
| OLD | NEW |