diff options
author | Primiano Tucci <primiano@google.com> | 2014-09-30 14:46:32 +0100 |
---|---|---|
committer | Primiano Tucci <primiano@google.com> | 2014-09-30 14:46:32 +0100 |
commit | c29dd2308a9beb970579e2a38ff1d02f218565a7 (patch) | |
tree | c1fbdd207e801fc46f417a230898a7e5d2040a5d | |
parent | 495e03c1b62b0b9471886d826c706deb97335436 (diff) | |
parent | 6297c0d67cb357c7d10e1708d5d3a0103afa04b5 (diff) | |
download | src-c29dd2308a9beb970579e2a38ff1d02f218565a7.tar.gz |
Merge from Chromium at DEPS revision 267aeeb8d85candroid-cts-5.1_r9android-cts-5.1_r8android-cts-5.1_r7android-cts-5.1_r6android-cts-5.1_r5android-cts-5.1_r4android-cts-5.1_r3android-cts-5.1_r28android-cts-5.1_r27android-cts-5.1_r26android-cts-5.1_r25android-cts-5.1_r24android-cts-5.1_r23android-cts-5.1_r22android-cts-5.1_r21android-cts-5.1_r20android-cts-5.1_r2android-cts-5.1_r19android-cts-5.1_r18android-cts-5.1_r17android-cts-5.1_r16android-cts-5.1_r15android-cts-5.1_r14android-cts-5.1_r13android-cts-5.1_r10android-cts-5.1_r1android-5.1.1_r9android-5.1.1_r8android-5.1.1_r7android-5.1.1_r6android-5.1.1_r5android-5.1.1_r4android-5.1.1_r38android-5.1.1_r37android-5.1.1_r36android-5.1.1_r35android-5.1.1_r34android-5.1.1_r33android-5.1.1_r30android-5.1.1_r3android-5.1.1_r29android-5.1.1_r28android-5.1.1_r26android-5.1.1_r25android-5.1.1_r24android-5.1.1_r23android-5.1.1_r22android-5.1.1_r20android-5.1.1_r2android-5.1.1_r19android-5.1.1_r18android-5.1.1_r17android-5.1.1_r16android-5.1.1_r15android-5.1.1_r14android-5.1.1_r13android-5.1.1_r12android-5.1.1_r10android-5.1.1_r1android-5.1.0_r5android-5.1.0_r4android-5.1.0_r3android-5.1.0_r1lollipop-mr1-wfc-releaselollipop-mr1-releaselollipop-mr1-fi-releaselollipop-mr1-devlollipop-mr1-cts-release
This commit was generated by merge_to_master.py.
Change-Id: Iaefacfbaf2c0ada6291fa03d6f3ff648e2d21956
39 files changed, 171 insertions, 90 deletions
diff --git a/cpp/include/libaddressinput/address_data.h b/cpp/include/libaddressinput/address_data.h index e2d057a..89d3273 100644 --- a/cpp/include/libaddressinput/address_data.h +++ b/cpp/include/libaddressinput/address_data.h @@ -55,6 +55,10 @@ struct AddressData { // Language code of the address. Should be in BCP-47 format. std::string language_code; + // The organization, firm, company, or institution at this address. This + // corresponds to the FirmName sub-element of the xAL FirmType element. + std::string organization; + // Name of recipient or contact person. Not present in xAL. std::string recipient; diff --git a/cpp/include/libaddressinput/address_field.h b/cpp/include/libaddressinput/address_field.h index 1adc97b..8f2ee05 100644 --- a/cpp/include/libaddressinput/address_field.h +++ b/cpp/include/libaddressinput/address_field.h @@ -31,6 +31,7 @@ enum AddressField { SORTING_CODE, // Sorting code. POSTAL_CODE, // Zip or postal code. STREET_ADDRESS, // Street address lines. + ORGANIZATION, // Organization, company, firm, institution, etc. RECIPIENT // Name. }; diff --git a/cpp/include/libaddressinput/localization.h b/cpp/include/libaddressinput/localization.h index 9d31265..5e7896d 100644 --- a/cpp/include/libaddressinput/localization.h +++ b/cpp/include/libaddressinput/localization.h @@ -17,6 +17,7 @@ #include <libaddressinput/address_field.h> #include <libaddressinput/address_problem.h> +#include <libaddressinput/util/basictypes.h> #include <string> @@ -83,6 +84,8 @@ class Localization { // The string getter. std::string (*get_string_)(int); + + DISALLOW_COPY_AND_ASSIGN(Localization); }; } // namespace addressinput diff --git a/cpp/res/messages.grdp b/cpp/res/messages.grdp index c04449a..7ca2000 100644 --- a/cpp/res/messages.grdp +++ b/cpp/res/messages.grdp @@ -113,6 +113,13 @@ limitations under the License. State </message> <message + name="IDS_LIBADDRESSINPUT_ORGANIZATION_LABEL" + desc="Label for the field of organization, firm, company, or institution + in an address. Examples of values in this field: Google, + Department of Transportation, University of Cambridge."> + Organization + </message> + <message name="IDS_LIBADDRESSINPUT_RECIPIENT_LABEL" desc="Label for the field for a person's name in an address."> Name diff --git a/cpp/src/address_data.cc b/cpp/src/address_data.cc index 644000e..40d3ee7 100644 --- a/cpp/src/address_data.cc +++ b/cpp/src/address_data.cc @@ -41,6 +41,7 @@ std::string AddressData::*kStringField[] = { &AddressData::sorting_code, &AddressData::postal_code, NULL, + &AddressData::organization, &AddressData::recipient }; @@ -53,6 +54,7 @@ const std::vector<std::string> AddressData::*kVectorStringField[] = { NULL, NULL, &AddressData::address_line, + NULL, NULL }; @@ -111,7 +113,9 @@ bool AddressData::operator==(const AddressData& other) const { dependent_locality == other.dependent_locality && postal_code == other.postal_code && sorting_code == other.sorting_code && - language_code == other.language_code && recipient == other.recipient; + language_code == other.language_code && + organization == other.organization && + recipient == other.recipient; } // static @@ -142,6 +146,7 @@ std::ostream& operator<<(std::ostream& o, } o << "language_code: \"" << address.language_code << "\"\n" + "organization: \"" << address.organization << "\"\n" "recipient: \"" << address.recipient << "\"\n"; return o; diff --git a/cpp/src/address_field.cc b/cpp/src/address_field.cc index 7d57e06..c5c96d8 100644 --- a/cpp/src/address_field.cc +++ b/cpp/src/address_field.cc @@ -32,6 +32,7 @@ std::ostream& operator<<(std::ostream& o, AddressField field) { "SORTING_CODE", "POSTAL_CODE", "STREET_ADDRESS", + "ORGANIZATION", "RECIPIENT" }; COMPILE_ASSERT(COUNTRY == 0, bad_base); diff --git a/cpp/src/address_field_util.cc b/cpp/src/address_field_util.cc index 1cac289..26de3c0 100644 --- a/cpp/src/address_field_util.cc +++ b/cpp/src/address_field_util.cc @@ -40,6 +40,7 @@ std::map<char, AddressField> InitFields() { fields.insert(std::make_pair('X', SORTING_CODE)); fields.insert(std::make_pair('Z', POSTAL_CODE)); fields.insert(std::make_pair('A', STREET_ADDRESS)); + fields.insert(std::make_pair('O', ORGANIZATION)); fields.insert(std::make_pair('N', RECIPIENT)); return fields; } diff --git a/cpp/src/address_ui.cc b/cpp/src/address_ui.cc index bf76cfd..33f0797 100644 --- a/cpp/src/address_ui.cc +++ b/cpp/src/address_ui.cc @@ -63,6 +63,9 @@ std::string GetLabelForField(const Localization& localization, case STREET_ADDRESS: messageId = IDS_LIBADDRESSINPUT_ADDRESS_LINE_1_LABEL; break; + case ORGANIZATION: + messageId = IDS_LIBADDRESSINPUT_ORGANIZATION_LABEL; + break; case RECIPIENT: messageId = IDS_LIBADDRESSINPUT_RECIPIENT_LABEL; break; diff --git a/cpp/src/localization.cc b/cpp/src/localization.cc index 737d8c9..b544cd9 100644 --- a/cpp/src/localization.cc +++ b/cpp/src/localization.cc @@ -31,10 +31,11 @@ namespace { -void PushBackUrl(std::vector<std::string>& parameters, const std::string url) { +void PushBackUrl(const std::string& url, std::vector<std::string>* parameters) { + assert(parameters != NULL); // TODO: HTML-escape the "url". - parameters.push_back("<a href=\"" + url + "\">"); - parameters.push_back("</a>"); + parameters->push_back("<a href=\"" + url + "\">"); + parameters->push_back("</a>"); } } // namespace @@ -137,7 +138,7 @@ std::string Localization::GetErrorMessageForPostalCode( IDS_LIBADDRESSINPUT_MISSING_REQUIRED_POSTAL_CODE_EXAMPLE_AND_URL : IDS_LIBADDRESSINPUT_MISSING_REQUIRED_ZIP_CODE_EXAMPLE_AND_URL; parameters.push_back(postal_code_example); - PushBackUrl(parameters, post_service_url); + PushBackUrl(post_service_url, ¶meters); } else if (!postal_code_example.empty()) { message_id = uses_postal_code_as_label ? IDS_LIBADDRESSINPUT_MISSING_REQUIRED_POSTAL_CODE_EXAMPLE : @@ -153,7 +154,7 @@ std::string Localization::GetErrorMessageForPostalCode( IDS_LIBADDRESSINPUT_UNRECOGNIZED_FORMAT_POSTAL_CODE_EXAMPLE_AND_URL : IDS_LIBADDRESSINPUT_UNRECOGNIZED_FORMAT_ZIP_CODE_EXAMPLE_AND_URL; parameters.push_back(postal_code_example); - PushBackUrl(parameters, post_service_url); + PushBackUrl(post_service_url, ¶meters); } else if (!postal_code_example.empty()) { message_id = uses_postal_code_as_label ? IDS_LIBADDRESSINPUT_UNRECOGNIZED_FORMAT_POSTAL_CODE_EXAMPLE : @@ -170,7 +171,7 @@ std::string Localization::GetErrorMessageForPostalCode( message_id = uses_postal_code_as_label ? IDS_LIBADDRESSINPUT_MISMATCHING_VALUE_POSTAL_CODE_URL : IDS_LIBADDRESSINPUT_MISMATCHING_VALUE_ZIP_URL; - PushBackUrl(parameters, post_service_url); + PushBackUrl(post_service_url, ¶meters); } else { message_id = uses_postal_code_as_label ? IDS_LIBADDRESSINPUT_MISMATCHING_VALUE_POSTAL_CODE : diff --git a/cpp/src/ondemand_supply_task.cc b/cpp/src/ondemand_supply_task.cc index f46d475..a4f6a12 100644 --- a/cpp/src/ondemand_supply_task.cc +++ b/cpp/src/ondemand_supply_task.cc @@ -63,7 +63,7 @@ void OndemandSupplyTask::Retrieve(const Retriever& retriever) { } else { // When the final pending rule has been retrieved, the retrieved_ callback, // implemented by Load(), will finish by calling Loaded(), which will finish - // by delete'ing this RuleHierarchy object. So after the final call to + // by delete'ing this OndemandSupplyTask object. So after the final call to // retriever.Retrieve() no attributes of this object can be accessed (as the // object then no longer will exist, if the final callback has finished by // then), and the condition statement of the loop must therefore not use the diff --git a/cpp/src/post_box_matchers.h b/cpp/src/post_box_matchers.h index c269f11..9924a2c 100644 --- a/cpp/src/post_box_matchers.h +++ b/cpp/src/post_box_matchers.h @@ -17,6 +17,8 @@ #ifndef I18N_ADDRESSINPUT_POST_BOX_MATCHERS_H_ #define I18N_ADDRESSINPUT_POST_BOX_MATCHERS_H_ +#include <libaddressinput/util/basictypes.h> + #include <vector> namespace i18n { @@ -30,6 +32,9 @@ class PostBoxMatchers { // Returns pointers to RE2 regular expression objects to test address lines // for those languages that are relevant for |country_rule|. static std::vector<const RE2ptr*> GetMatchers(const Rule& country_rule); + + private: + DISALLOW_COPY_AND_ASSIGN(PostBoxMatchers); }; } // namespace addressinput diff --git a/cpp/src/region_data_constants.h b/cpp/src/region_data_constants.h index 7a2c133..4159e72 100644 --- a/cpp/src/region_data_constants.h +++ b/cpp/src/region_data_constants.h @@ -15,6 +15,8 @@ #ifndef I18N_ADDRESSINPUT_REGION_DATA_CONSTANTS_H_ #define I18N_ADDRESSINPUT_REGION_DATA_CONSTANTS_H_ +#include <libaddressinput/util/basictypes.h> + #include <cstddef> #include <string> #include <vector> @@ -29,6 +31,9 @@ class RegionDataConstants { static const std::string& GetRegionData(const std::string& region_code); static const std::string& GetDefaultRegionData(); static size_t GetMaxLookupKeyDepth(const std::string& region_code); + + private: + DISALLOW_COPY_AND_ASSIGN(RegionDataConstants); }; } // namespace addressinput diff --git a/cpp/src/validating_util.cc b/cpp/src/validating_util.cc index 084c09c..9356689 100644 --- a/cpp/src/validating_util.cc +++ b/cpp/src/validating_util.cc @@ -84,7 +84,8 @@ bool UnwrapHeader(const char* header_prefix, void ValidatingUtil::Wrap(time_t timestamp, std::string* data) { assert(data != NULL); char timestamp_string[2 + 3 * sizeof timestamp]; - int size = std::sprintf(timestamp_string, "%ld", timestamp); + int size = + std::sprintf(timestamp_string, "%ld", static_cast<long>(timestamp)); assert(size > 0); assert(size < sizeof timestamp_string); (void)size; diff --git a/cpp/src/validating_util.h b/cpp/src/validating_util.h index 1357651..20d541b 100644 --- a/cpp/src/validating_util.h +++ b/cpp/src/validating_util.h @@ -19,6 +19,8 @@ #ifndef I18N_ADDRESSINPUT_VALIDATING_UTIL_H_ #define I18N_ADDRESSINPUT_VALIDATING_UTIL_H_ +#include <libaddressinput/util/basictypes.h> + #include <ctime> #include <string> @@ -47,6 +49,9 @@ class ValidatingUtil { // Strips out the checksum from |data|. Returns |true| if the checksum is // present, formatted correctly, and valid for this data. static bool UnwrapChecksum(std::string* data); + + private: + DISALLOW_COPY_AND_ASSIGN(ValidatingUtil); }; } // namespace addressinput diff --git a/cpp/src/validation_task.cc b/cpp/src/validation_task.cc index 727de6a..1e7911a 100644 --- a/cpp/src/validation_task.cc +++ b/cpp/src/validation_task.cc @@ -110,6 +110,7 @@ void ValidationTask::CheckUnexpectedField( SORTING_CODE, POSTAL_CODE, STREET_ADDRESS, + ORGANIZATION, RECIPIENT }; @@ -132,7 +133,8 @@ void ValidationTask::CheckMissingRequiredField( DEPENDENT_LOCALITY, SORTING_CODE, POSTAL_CODE, - STREET_ADDRESS, + STREET_ADDRESS + // ORGANIZATION is never required. // RECIPIENT is handled separately. }; diff --git a/cpp/test/address_data_test.cc b/cpp/test/address_data_test.cc index 8ba0f4b..46491c9 100644 --- a/cpp/test/address_data_test.cc +++ b/cpp/test/address_data_test.cc @@ -32,6 +32,7 @@ using i18n::addressinput::DEPENDENT_LOCALITY; using i18n::addressinput::SORTING_CODE; using i18n::addressinput::POSTAL_CODE; using i18n::addressinput::STREET_ADDRESS; +using i18n::addressinput::ORGANIZATION; using i18n::addressinput::RECIPIENT; TEST(AddressDataTest, GetFieldValue) { @@ -42,6 +43,7 @@ TEST(AddressDataTest, GetFieldValue) { address.dependent_locality = "ddd"; address.sorting_code = "xxx"; address.postal_code = "zzz"; + address.organization = "ooo"; address.recipient = "nnn"; EXPECT_EQ(address.region_code, @@ -56,6 +58,8 @@ TEST(AddressDataTest, GetFieldValue) { address.GetFieldValue(SORTING_CODE)); EXPECT_EQ(address.postal_code, address.GetFieldValue(POSTAL_CODE)); + EXPECT_EQ(address.organization, + address.GetFieldValue(ORGANIZATION)); EXPECT_EQ(address.recipient, address.GetFieldValue(RECIPIENT)); } @@ -78,6 +82,7 @@ TEST(AddressDataTest, IsFieldEmpty) { EXPECT_TRUE(address.IsFieldEmpty(SORTING_CODE)); EXPECT_TRUE(address.IsFieldEmpty(POSTAL_CODE)); EXPECT_TRUE(address.IsFieldEmpty(STREET_ADDRESS)); + EXPECT_TRUE(address.IsFieldEmpty(ORGANIZATION)); EXPECT_TRUE(address.IsFieldEmpty(RECIPIENT)); address.region_code = "rrr"; @@ -87,6 +92,7 @@ TEST(AddressDataTest, IsFieldEmpty) { address.sorting_code = "xxx"; address.postal_code = "zzz"; address.address_line.push_back("aaa"); + address.organization = "ooo"; address.recipient = "nnn"; EXPECT_FALSE(address.IsFieldEmpty(COUNTRY)); @@ -96,6 +102,7 @@ TEST(AddressDataTest, IsFieldEmpty) { EXPECT_FALSE(address.IsFieldEmpty(SORTING_CODE)); EXPECT_FALSE(address.IsFieldEmpty(POSTAL_CODE)); EXPECT_FALSE(address.IsFieldEmpty(STREET_ADDRESS)); + EXPECT_FALSE(address.IsFieldEmpty(ORGANIZATION)); EXPECT_FALSE(address.IsFieldEmpty(RECIPIENT)); } @@ -149,6 +156,7 @@ TEST(AddressDataTest, StreamFunction) { address.dependent_locality = "D"; address.sorting_code = "X"; address.language_code = "zh-Hant"; + address.organization = "O"; oss << address; EXPECT_EQ("region_code: \"R\"\n" "administrative_area: \"S\"\n" @@ -159,6 +167,7 @@ TEST(AddressDataTest, StreamFunction) { "address_line: \"Line 1\"\n" "address_line: \"Line 2\"\n" "language_code: \"zh-Hant\"\n" + "organization: \"O\"\n" "recipient: \"N\"\n", oss.str()); } @@ -173,6 +182,7 @@ TEST(AddressDataTest, TestEquals) { address.locality = "C"; address.dependent_locality = "D"; address.sorting_code = "X"; + address.organization = "O"; address.language_code = "zh-Hant"; AddressData clone = address; diff --git a/cpp/test/address_field_util_test.cc b/cpp/test/address_field_util_test.cc index 0db6bf5..0cde367 100644 --- a/cpp/test/address_field_util_test.cc +++ b/cpp/test/address_field_util_test.cc @@ -26,20 +26,22 @@ namespace { using i18n::addressinput::AddressField; -using i18n::addressinput::COUNTRY; using i18n::addressinput::FormatElement; -using i18n::addressinput::LOCALITY; using i18n::addressinput::ParseFormatRule; + +using i18n::addressinput::COUNTRY; +using i18n::addressinput::LOCALITY; using i18n::addressinput::POSTAL_CODE; -using i18n::addressinput::RECIPIENT; using i18n::addressinput::STREET_ADDRESS; +using i18n::addressinput::ORGANIZATION; +using i18n::addressinput::RECIPIENT; TEST(AddressFieldUtilTest, FormatParseNewline) { std::vector<FormatElement> actual; ParseFormatRule("%O%n%N%n%A%nAX-%Z %C%n\xC3\x85LAND", &actual); /* "Ă…LAND" */ std::vector<FormatElement> expected; - // Organization is skipped. + expected.push_back(FormatElement(ORGANIZATION)); expected.push_back(FormatElement()); expected.push_back(FormatElement(RECIPIENT)); expected.push_back(FormatElement()); diff --git a/cpp/test/address_input_helper_test.cc b/cpp/test/address_input_helper_test.cc index cfae3f3..4014c91 100644 --- a/cpp/test/address_input_helper_test.cc +++ b/cpp/test/address_input_helper_test.cc @@ -49,8 +49,6 @@ class AddressInputHelperTest : public testing::Test { address_input_helper_(&supplier_), loaded_(BuildCallback(this, &AddressInputHelperTest::Loaded)) {} - ~AddressInputHelperTest() {} - // Helper method to test FillAddress that ensures the PreloadSupplier has the // necessary data preloaded. void FillAddress(AddressData* address) { @@ -249,8 +247,6 @@ class AddressInputHelperMockDataTest : public testing::Test { address_input_helper_(&supplier_), loaded_(BuildCallback(this, &AddressInputHelperMockDataTest::Loaded)) {} - ~AddressInputHelperMockDataTest() {} - // Helper method to test FillAddress that ensures the PreloadSupplier has the // necessary data preloaded. void FillAddress(AddressData* address) { diff --git a/cpp/test/address_normalizer_test.cc b/cpp/test/address_normalizer_test.cc index 7a01d38..3a7acf2 100644 --- a/cpp/test/address_normalizer_test.cc +++ b/cpp/test/address_normalizer_test.cc @@ -44,8 +44,6 @@ class AddressNormalizerTest : public testing::Test { loaded_(BuildCallback(this, &AddressNormalizerTest::OnLoaded)), normalizer_(&supplier_) {} - virtual ~AddressNormalizerTest() {} - PreloadSupplier supplier_; const scoped_ptr<const PreloadSupplier::Callback> loaded_; const AddressNormalizer normalizer_; diff --git a/cpp/test/address_ui_test.cc b/cpp/test/address_ui_test.cc index ccfd437..d2e512f 100644 --- a/cpp/test/address_ui_test.cc +++ b/cpp/test/address_ui_test.cc @@ -17,6 +17,7 @@ #include <libaddressinput/address_field.h> #include <libaddressinput/address_ui_component.h> #include <libaddressinput/localization.h> +#include <libaddressinput/util/basictypes.h> #include <set> #include <string> @@ -28,14 +29,16 @@ namespace { using i18n::addressinput::AddressField; using i18n::addressinput::AddressUiComponent; -using i18n::addressinput::ADMIN_AREA; using i18n::addressinput::BuildComponents; -using i18n::addressinput::COUNTRY; using i18n::addressinput::GetRegionCodes; using i18n::addressinput::Localization; + +using i18n::addressinput::COUNTRY; +using i18n::addressinput::ADMIN_AREA; using i18n::addressinput::POSTAL_CODE; -using i18n::addressinput::RECIPIENT; using i18n::addressinput::STREET_ADDRESS; +using i18n::addressinput::ORGANIZATION; +using i18n::addressinput::RECIPIENT; static const char kUiLanguageTag[] = "en"; @@ -70,8 +73,12 @@ testing::AssertionResult ComponentsAreValid( // Tests for address UI functions. class AddressUiTest : public testing::TestWithParam<std::string> { protected: + AddressUiTest() {} Localization localization_; std::string best_address_language_tag_; + + private: + DISALLOW_COPY_AND_ASSIGN(AddressUiTest); }; // Verifies that a region code consists of two characters, for example "TW". @@ -142,8 +149,12 @@ struct LanguageTestCase { class BestAddressLanguageTagTest : public testing::TestWithParam<LanguageTestCase> { protected: + BestAddressLanguageTagTest() {} Localization localization_; std::string best_address_language_tag_; + + private: + DISALLOW_COPY_AND_ASSIGN(BestAddressLanguageTagTest); }; std::string GetterStub(int) { return std::string(); } @@ -210,12 +221,12 @@ INSTANTIATE_TEST_CASE_P( LanguageTestCase("MO", "en", "zh-Latn", RECIPIENT), // Switzerland supports de, fr, and it. - LanguageTestCase("CH", "de", "de", RECIPIENT), - LanguageTestCase("CH", "de-DE", "de", RECIPIENT), - LanguageTestCase("CH", "de-Latn-DE", "de", RECIPIENT), - LanguageTestCase("CH", "fr", "fr", RECIPIENT), - LanguageTestCase("CH", "it", "it", RECIPIENT), - LanguageTestCase("CH", "en", "de", RECIPIENT), + LanguageTestCase("CH", "de", "de", ORGANIZATION), + LanguageTestCase("CH", "de-DE", "de", ORGANIZATION), + LanguageTestCase("CH", "de-Latn-DE", "de", ORGANIZATION), + LanguageTestCase("CH", "fr", "fr", ORGANIZATION), + LanguageTestCase("CH", "it", "it", ORGANIZATION), + LanguageTestCase("CH", "en", "de", ORGANIZATION), // Antarctica does not have language information. LanguageTestCase("AQ", "en", "en", RECIPIENT), diff --git a/cpp/test/address_validator_test.cc b/cpp/test/address_validator_test.cc index 0b4b025..3177b01 100644 --- a/cpp/test/address_validator_test.cc +++ b/cpp/test/address_validator_test.cc @@ -70,8 +70,6 @@ class OndemandValidatorWrapper : public ValidatorWrapper { public: static ValidatorWrapper* Build() { return new OndemandValidatorWrapper; } - virtual ~OndemandValidatorWrapper() {} - virtual void Validate(const AddressData& address, bool allow_postal, bool require_name, @@ -101,8 +99,6 @@ class PreloadValidatorWrapper : public ValidatorWrapper { public: static ValidatorWrapper* Build() { return new PreloadValidatorWrapper; } - virtual ~PreloadValidatorWrapper() {} - virtual void Validate(const AddressData& address, bool allow_postal, bool require_name, @@ -150,8 +146,6 @@ class AddressValidatorTest validator_wrapper_((*GetParam())()), validated_(BuildCallback(this, &AddressValidatorTest::Validated)) {} - virtual ~AddressValidatorTest() {} - void Validate() { validator_wrapper_->Validate( address_, diff --git a/cpp/test/fake_storage.h b/cpp/test/fake_storage.h index 55273c6..3a164c4 100644 --- a/cpp/test/fake_storage.h +++ b/cpp/test/fake_storage.h @@ -19,6 +19,7 @@ #define I18N_ADDRESSINPUT_FAKE_STORAGE_H_ #include <libaddressinput/storage.h> +#include <libaddressinput/util/basictypes.h> #include <map> #include <string> @@ -66,6 +67,7 @@ class FakeStorage : public Storage { private: std::map<std::string, std::string*> data_; + DISALLOW_COPY_AND_ASSIGN(FakeStorage); }; } // namespace addressinput diff --git a/cpp/test/fake_storage_test.cc b/cpp/test/fake_storage_test.cc index 275c9fc..5905f02 100644 --- a/cpp/test/fake_storage_test.cc +++ b/cpp/test/fake_storage_test.cc @@ -41,8 +41,6 @@ class FakeStorageTest : public testing::Test { data_(), data_ready_(BuildCallback(this, &FakeStorageTest::OnDataReady)) {} - virtual ~FakeStorageTest() {} - FakeStorage storage_; bool success_; std::string key_; diff --git a/cpp/test/language_test.cc b/cpp/test/language_test.cc index 197459e..502031b 100644 --- a/cpp/test/language_test.cc +++ b/cpp/test/language_test.cc @@ -14,6 +14,8 @@ #include "language.h" +#include <libaddressinput/util/basictypes.h> + #include <string> #include <gtest/gtest.h> @@ -40,7 +42,13 @@ struct LanguageTestCase { const bool expected_has_latin_script; }; -class LanguageTest : public testing::TestWithParam<LanguageTestCase> {}; +class LanguageTest : public testing::TestWithParam<LanguageTestCase> { + protected: + LanguageTest() {} + + private: + DISALLOW_COPY_AND_ASSIGN(LanguageTest); +}; TEST_P(LanguageTest, ExtractedDataIsCorrect) { Language language(GetParam().input_language_tag); diff --git a/cpp/test/localization_test.cc b/cpp/test/localization_test.cc index b47d5c8..1eba5b8 100644 --- a/cpp/test/localization_test.cc +++ b/cpp/test/localization_test.cc @@ -17,6 +17,7 @@ #include <libaddressinput/address_data.h> #include <libaddressinput/address_field.h> #include <libaddressinput/address_problem.h> +#include <libaddressinput/util/basictypes.h> #include <string> #include <vector> @@ -40,6 +41,7 @@ using i18n::addressinput::DEPENDENT_LOCALITY; using i18n::addressinput::SORTING_CODE; using i18n::addressinput::POSTAL_CODE; using i18n::addressinput::STREET_ADDRESS; +using i18n::addressinput::ORGANIZATION; using i18n::addressinput::RECIPIENT; using i18n::addressinput::MISSING_REQUIRED_FIELD; @@ -51,7 +53,11 @@ using i18n::addressinput::USES_P_O_BOX; // Tests for Localization object. class LocalizationTest : public testing::TestWithParam<int> { protected: + LocalizationTest() {} Localization localization_; + + private: + DISALLOW_COPY_AND_ASSIGN(LocalizationTest); }; // Verifies that a custom message getter can be used. @@ -98,6 +104,7 @@ INSTANTIATE_TEST_CASE_P( IDS_LIBADDRESSINPUT_PREFECTURE, IDS_LIBADDRESSINPUT_PROVINCE, IDS_LIBADDRESSINPUT_STATE, + IDS_LIBADDRESSINPUT_ORGANIZATION_LABEL, IDS_LIBADDRESSINPUT_RECIPIENT_LABEL, IDS_LIBADDRESSINPUT_MISSING_REQUIRED_FIELD, IDS_LIBADDRESSINPUT_MISSING_REQUIRED_POSTAL_CODE_EXAMPLE_AND_URL, @@ -176,6 +183,7 @@ TEST(LocalizationGetErrorMessageTest, MissingRequiredOtherFields) { other_fields.push_back(DEPENDENT_LOCALITY); other_fields.push_back(SORTING_CODE); other_fields.push_back(STREET_ADDRESS); + other_fields.push_back(ORGANIZATION); other_fields.push_back(RECIPIENT); for (std::vector<AddressField>::iterator it = other_fields.begin(); it != other_fields.end(); it++) { @@ -206,6 +214,7 @@ TEST(LocalizationGetErrorMessageTest, UnknownValueOtherFields) { address_line.push_back("bad address line 1"); address_line.push_back("bad address line 2"); address.address_line = address_line; + address.organization = "bad organization"; address.recipient = "bad recipient"; EXPECT_EQ("US " "is not recognized as a known value for this field.", @@ -303,6 +312,22 @@ TEST(LocalizationGetErrorMessageTest, UnknownValueOtherFields) { "is not recognized as a known value for this field.", localization.GetErrorMessage( address, STREET_ADDRESS, UNKNOWN_VALUE, false, true)); + EXPECT_EQ("bad organization " + "is not recognized as a known value for this field.", + localization.GetErrorMessage( + address, ORGANIZATION, UNKNOWN_VALUE, true, true)); + EXPECT_EQ("bad organization " + "is not recognized as a known value for this field.", + localization.GetErrorMessage( + address, ORGANIZATION, UNKNOWN_VALUE, true, false)); + EXPECT_EQ("bad organization " + "is not recognized as a known value for this field.", + localization.GetErrorMessage( + address, ORGANIZATION, UNKNOWN_VALUE, false, false)); + EXPECT_EQ("bad organization " + "is not recognized as a known value for this field.", + localization.GetErrorMessage( + address, ORGANIZATION, UNKNOWN_VALUE, false, true)); EXPECT_EQ("bad recipient " "is not recognized as a known value for this field.", localization.GetErrorMessage( @@ -434,6 +459,7 @@ TEST(LocalizationGetErrorMessageTest, UsesPOBoxOtherFields) { other_fields.push_back(DEPENDENT_LOCALITY); other_fields.push_back(SORTING_CODE); other_fields.push_back(STREET_ADDRESS); + other_fields.push_back(ORGANIZATION); other_fields.push_back(RECIPIENT); for (std::vector<AddressField>::iterator it = other_fields.begin(); it != other_fields.end(); it++) { diff --git a/cpp/test/null_storage_test.cc b/cpp/test/null_storage_test.cc index 8284554..3669ea9 100644 --- a/cpp/test/null_storage_test.cc +++ b/cpp/test/null_storage_test.cc @@ -36,8 +36,6 @@ class NullStorageTest : public testing::Test { NullStorageTest() : data_ready_(BuildCallback(this, &NullStorageTest::OnDataReady)) {} - virtual ~NullStorageTest() {} - NullStorage storage_; bool success_; std::string key_; diff --git a/cpp/test/preload_supplier_test.cc b/cpp/test/preload_supplier_test.cc index bf04a85..8612e98 100644 --- a/cpp/test/preload_supplier_test.cc +++ b/cpp/test/preload_supplier_test.cc @@ -46,8 +46,6 @@ class PreloadSupplierTest : public testing::Test { : supplier_(new TestdataSource(true), new NullStorage), loaded_callback_(BuildCallback(this, &PreloadSupplierTest::OnLoaded)) {} - virtual ~PreloadSupplierTest() {} - PreloadSupplier supplier_; const scoped_ptr<const PreloadSupplier::Callback> loaded_callback_; diff --git a/cpp/test/region_data_builder_test.cc b/cpp/test/region_data_builder_test.cc index a60189f..fe2f2e1 100644 --- a/cpp/test/region_data_builder_test.cc +++ b/cpp/test/region_data_builder_test.cc @@ -46,8 +46,6 @@ class RegionDataBuilderTest : public testing::Test { loaded_callback_(BuildCallback(this, &RegionDataBuilderTest::OnLoaded)), best_language_() {} - virtual ~RegionDataBuilderTest() {} - PreloadSupplier supplier_; RegionDataBuilder builder_; const scoped_ptr<const PreloadSupplier::Callback> loaded_callback_; diff --git a/cpp/test/region_data_constants_test.cc b/cpp/test/region_data_constants_test.cc index 8942445..63e6ae2 100644 --- a/cpp/test/region_data_constants_test.cc +++ b/cpp/test/region_data_constants_test.cc @@ -14,6 +14,8 @@ #include "region_data_constants.h" +#include <libaddressinput/util/basictypes.h> + #include <string> #include <gtest/gtest.h> @@ -23,7 +25,13 @@ namespace { using i18n::addressinput::RegionDataConstants; // Tests for region codes, for example "ZA". -class RegionCodeTest : public testing::TestWithParam<std::string> {}; +class RegionCodeTest : public testing::TestWithParam<std::string> { + protected: + RegionCodeTest() {} + + private: + DISALLOW_COPY_AND_ASSIGN(RegionCodeTest); +}; // Verifies that a region code consists of two characters, for example "ZA". TEST_P(RegionCodeTest, RegionCodeHasTwoCharacters) { @@ -57,9 +65,14 @@ TEST(DefaultRegionDataTest, DefaultRegionHasCurlyBraces) { // Tests for region data, for example "{\"fmt\":\"%C%S\"}". class RegionDataTest : public testing::TestWithParam<std::string> { protected: + RegionDataTest() {} + const std::string& GetData() const { return RegionDataConstants::GetRegionData(GetParam()); } + + private: + DISALLOW_COPY_AND_ASSIGN(RegionDataTest); }; // Verifies that a region data value begins with '{' and end with '}', for diff --git a/cpp/test/retriever_test.cc b/cpp/test/retriever_test.cc index 5b884b0..00c2ea4 100644 --- a/cpp/test/retriever_test.cc +++ b/cpp/test/retriever_test.cc @@ -65,8 +65,6 @@ class RetrieverTest : public testing::Test { data_(), data_ready_(BuildCallback(this, &RetrieverTest::OnDataReady)) {} - virtual ~RetrieverTest() {} - Retriever retriever_; bool success_; std::string key_; diff --git a/cpp/test/rule_retriever_test.cc b/cpp/test/rule_retriever_test.cc index 656b23b..ecf3af7 100644 --- a/cpp/test/rule_retriever_test.cc +++ b/cpp/test/rule_retriever_test.cc @@ -48,8 +48,6 @@ class RuleRetrieverTest : public testing::Test { rule_(), rule_ready_(BuildCallback(this, &RuleRetrieverTest::OnRuleReady)) {} - virtual ~RuleRetrieverTest() {} - RuleRetriever rule_retriever_; bool success_; std::string key_; diff --git a/cpp/test/rule_test.cc b/cpp/test/rule_test.cc index c291cfd..7c5a0c5 100644 --- a/cpp/test/rule_test.cc +++ b/cpp/test/rule_test.cc @@ -16,6 +16,7 @@ #include <libaddressinput/address_field.h> #include <libaddressinput/localization.h> +#include <libaddressinput/util/basictypes.h> #include <cstddef> #include <string> @@ -241,7 +242,11 @@ TEST(RuleTest, EmptyDictionaryIsValid) { class PostalCodeNameParseTest : public testing::TestWithParam<std::pair<std::string, int> > { protected: + PostalCodeNameParseTest() {} Rule rule_; + + private: + DISALLOW_COPY_AND_ASSIGN(PostalCodeNameParseTest); }; // Verifies that a postal code name is parsed correctly. @@ -263,7 +268,11 @@ INSTANTIATE_TEST_CASE_P( class AdminAreaNameParseTest : public testing::TestWithParam<std::pair<std::string, int> > { protected: + AdminAreaNameParseTest() {} Rule rule_; + + private: + DISALLOW_COPY_AND_ASSIGN(AdminAreaNameParseTest); }; // Verifies that an administrative area name is parsed correctly. @@ -302,6 +311,8 @@ INSTANTIATE_TEST_CASE_P( // Tests for rule parsing. class RuleParseTest : public testing::TestWithParam<std::string> { protected: + RuleParseTest() {} + const std::string& GetRegionData() const { // GetParam() is either a region code or the region data itself. // RegionDataContants::GetRegionData() returns an empty string for anything @@ -312,6 +323,9 @@ class RuleParseTest : public testing::TestWithParam<std::string> { Rule rule_; Localization localization_; + + private: + DISALLOW_COPY_AND_ASSIGN(RuleParseTest); }; // Verifies that a region data can be parsed successfully. diff --git a/cpp/test/supplier_test.cc b/cpp/test/supplier_test.cc index bb783db..e55c0c1 100644 --- a/cpp/test/supplier_test.cc +++ b/cpp/test/supplier_test.cc @@ -73,8 +73,6 @@ class OndemandSupplierWrapper : public SupplierWrapper { public: static SupplierWrapper* Build() { return new OndemandSupplierWrapper; } - virtual ~OndemandSupplierWrapper() {} - virtual void Supply(const LookupKey& lookup_key, const Supplier::Callback& supplied) { ondemand_supplier_.Supply(lookup_key, supplied); @@ -92,8 +90,6 @@ class PreloadSupplierWrapper : public SupplierWrapper { public: static SupplierWrapper* Build() { return new PreloadSupplierWrapper; } - virtual ~PreloadSupplierWrapper() {} - virtual void Supply(const LookupKey& lookup_key, const Supplier::Callback& supplied) { const std::string& region_code = lookup_key.GetRegionCode(); @@ -125,8 +121,6 @@ class SupplierTest : public testing::TestWithParam<SupplierWrapper* (*)()> { supplier_wrapper_((*GetParam())()), supplied_(BuildCallback(this, &SupplierTest::Supplied)) {} - virtual ~SupplierTest() {} - void Supply() { lookup_key_.FromAddress(address_); supplier_wrapper_->Supply(lookup_key_, *supplied_); diff --git a/cpp/test/testdata_source_test.cc b/cpp/test/testdata_source_test.cc index 095b503..58468a9 100644 --- a/cpp/test/testdata_source_test.cc +++ b/cpp/test/testdata_source_test.cc @@ -45,8 +45,6 @@ class TestdataSourceTest : public testing::TestWithParam<std::string> { data_(), data_ready_(BuildCallback(this, &TestdataSourceTest::OnDataReady)) {} - virtual ~TestdataSourceTest() {} - TestdataSource source_; TestdataSource aggregate_source_; bool success_; diff --git a/cpp/test/util/string_compare_test.cc b/cpp/test/util/string_compare_test.cc index cad36c1..b35b7df 100644 --- a/cpp/test/util/string_compare_test.cc +++ b/cpp/test/util/string_compare_test.cc @@ -14,6 +14,8 @@ #include "util/string_compare.h" +#include <libaddressinput/util/basictypes.h> + #include <string> #include <gtest/gtest.h> @@ -42,7 +44,11 @@ struct TestCase { class StringCompareTest : public testing::TestWithParam<TestCase> { protected: + StringCompareTest() {} StringCompare compare_; + + private: + DISALLOW_COPY_AND_ASSIGN(StringCompareTest); }; TEST_P(StringCompareTest, CorrectComparison) { diff --git a/cpp/test/validating_storage_test.cc b/cpp/test/validating_storage_test.cc index 36f85d9..3c8aa53 100644 --- a/cpp/test/validating_storage_test.cc +++ b/cpp/test/validating_storage_test.cc @@ -56,8 +56,6 @@ class ValidatingStorageTest : public testing::Test { data_(), data_ready_(BuildCallback(this, &ValidatingStorageTest::OnDataReady)) {} - virtual ~ValidatingStorageTest() {} - Storage* const wrapped_storage_; // Owned by |storage_|. ValidatingStorage storage_; bool success_; diff --git a/cpp/test/validation_task_test.cc b/cpp/test/validation_task_test.cc index e3900bd..9caf996 100644 --- a/cpp/test/validation_task_test.cc +++ b/cpp/test/validation_task_test.cc @@ -57,6 +57,7 @@ class ValidationTaskTest : public testing::Test { SORTING_CODE, POSTAL_CODE, STREET_ADDRESS, + ORGANIZATION, RECIPIENT }; @@ -83,8 +84,6 @@ class ValidationTaskTest : public testing::Test { filter_.insert(std::make_pair(RECIPIENT, MISSING_REQUIRED_FIELD)); } - virtual ~ValidationTaskTest() {} - void Validate() { Rule rule[arraysize(json_)]; @@ -215,12 +214,14 @@ TEST_F(ValidationTaskTest, MissingNoRequiredFieldsUS) { address_.locality = "ccc"; address_.postal_code = "zzz"; address_.address_line.push_back("aaa"); + address_.organization = "ooo"; address_.recipient = "nnn"; filter_.insert(std::make_pair(ADMIN_AREA, MISSING_REQUIRED_FIELD)); filter_.insert(std::make_pair(LOCALITY, MISSING_REQUIRED_FIELD)); filter_.insert(std::make_pair(POSTAL_CODE, MISSING_REQUIRED_FIELD)); filter_.insert(std::make_pair(STREET_ADDRESS, MISSING_REQUIRED_FIELD)); + filter_.insert(std::make_pair(ORGANIZATION, MISSING_REQUIRED_FIELD)); ASSERT_NO_FATAL_FAILURE(Validate()); ASSERT_TRUE(called_); diff --git a/java/src/com/android/i18n/addressinput/AddressField.java b/java/src/com/android/i18n/addressinput/AddressField.java index b951021..17b1817 100644 --- a/java/src/com/android/i18n/addressinput/AddressField.java +++ b/java/src/com/android/i18n/addressinput/AddressField.java @@ -24,14 +24,14 @@ import java.util.Map; * formatting. Note that the metadata also has a character for newlines, which is not defined here. */ public enum AddressField { - ADMIN_AREA('S', "state"), - LOCALITY('C', "city"), - RECIPIENT('N', "name"), - ORGANIZATION('O', "organization"), + ADMIN_AREA('S'), + LOCALITY('C'), + RECIPIENT('N'), + ORGANIZATION('O'), // Deprecated - use A instead. - ADDRESS_LINE_1('1', "street1"), + ADDRESS_LINE_1('1'), // Deprecated - use A instead. - ADDRESS_LINE_2('2', "street2"), + ADDRESS_LINE_2('2'), DEPENDENT_LOCALITY('D'), POSTAL_CODE('Z'), SORTING_CODE('X'), @@ -58,15 +58,8 @@ public enum AddressField { private final char mField; - private final String mAttributeName; - - private AddressField(char field, String attributeName) { - mField = field; - mAttributeName = attributeName; - } - private AddressField(char field) { - this(field, null); + mField = field; } /** @@ -78,17 +71,6 @@ public enum AddressField { } /** - * Gets attribute name. Attribute names are used as keys to JSON address data returned from the - * server. Returns null if the field does not have a corresponding attribute name. - * - * Note: Not all address fields have attribute names. Fields like postal code, country, sorting - * code, or street address do not have attribute names. - */ - String getAttributeName() { - return mAttributeName; - } - - /** * Gets the field's identification character, as used in the metadata. * * @return identification char. diff --git a/java/test/com/android/i18n/addressinput/AddressFieldTest.java b/java/test/com/android/i18n/addressinput/AddressFieldTest.java index 3419097..aa0a741 100644 --- a/java/test/com/android/i18n/addressinput/AddressFieldTest.java +++ b/java/test/com/android/i18n/addressinput/AddressFieldTest.java @@ -30,8 +30,4 @@ public class AddressFieldTest extends TestCase { public void testGetChar() throws Exception { assertEquals('R', AddressField.COUNTRY.getChar()); } - - public void testGetAttributeName() throws Exception { - assertEquals("name", AddressField.RECIPIENT.getAttributeName()); - } } |