Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Side by Side Diff: third_party/libaddressinput/chromium/cpp/test/country_rules_aggregator_test.cc

Issue 145553009: rAc: use libaddressinput to validate international addresses. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (C) 2013 Google Inc. 1 // Copyright (C) 2013 Google Inc.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
(...skipping 24 matching lines...) Expand all
35 35
36 namespace i18n { 36 namespace i18n {
37 namespace addressinput { 37 namespace addressinput {
38 38
39 class CountryRulesAggregatorTest : public testing::Test { 39 class CountryRulesAggregatorTest : public testing::Test {
40 public: 40 public:
41 CountryRulesAggregatorTest() 41 CountryRulesAggregatorTest()
42 : aggregator_(scoped_ptr<Retriever>(new Retriever( 42 : aggregator_(scoped_ptr<Retriever>(new Retriever(
43 FakeDownloader::kFakeDataUrl, 43 FakeDownloader::kFakeDataUrl,
44 scoped_ptr<Downloader>(new FakeDownloader), 44 scoped_ptr<Downloader>(new FakeDownloader),
45 scoped_ptr<Storage>(new FakeStorage)))), 45 &storage_))),
46 success_(false), 46 success_(false),
47 country_code_(), 47 country_code_(),
48 ruleset_() {} 48 ruleset_() {}
49 49
50 virtual ~CountryRulesAggregatorTest() {} 50 virtual ~CountryRulesAggregatorTest() {}
51 51
52 protected: 52 protected:
53 scoped_ptr<CountryRulesAggregator::Callback> BuildCallback() { 53 scoped_ptr<CountryRulesAggregator::Callback> BuildCallback() {
54 return ::i18n::addressinput::BuildScopedPtrCallback( 54 return ::i18n::addressinput::BuildScopedPtrCallback(
55 this, &CountryRulesAggregatorTest::OnRulesetReady); 55 this, &CountryRulesAggregatorTest::OnRulesetReady);
56 } 56 }
57 57
58 CountryRulesAggregator aggregator_; 58 CountryRulesAggregator aggregator_;
59 bool success_; 59 bool success_;
60 std::string country_code_; 60 std::string country_code_;
61 scoped_ptr<Ruleset> ruleset_; 61 scoped_ptr<Ruleset> ruleset_;
62 62
63 private: 63 private:
64 void OnRulesetReady(bool success, 64 void OnRulesetReady(bool success,
65 const std::string& country_code, 65 const std::string& country_code,
66 scoped_ptr<Ruleset> ruleset) { 66 scoped_ptr<Ruleset> ruleset) {
67 success_ = success; 67 success_ = success;
68 country_code_ = country_code; 68 country_code_ = country_code;
69 ruleset_.reset(ruleset.release()); 69 ruleset_.reset(ruleset.release());
70 } 70 }
71 71
72 FakeStorage storage_;
73
72 DISALLOW_COPY_AND_ASSIGN(CountryRulesAggregatorTest); 74 DISALLOW_COPY_AND_ASSIGN(CountryRulesAggregatorTest);
73 }; 75 };
74 76
75 TEST_F(CountryRulesAggregatorTest, ValidRuleset) { 77 TEST_F(CountryRulesAggregatorTest, ValidRuleset) {
76 aggregator_.AggregateRules("CH", BuildCallback()); 78 aggregator_.AggregateRules("CH", BuildCallback());
77 EXPECT_TRUE(success_); 79 EXPECT_TRUE(success_);
78 EXPECT_EQ("CH", country_code_); 80 EXPECT_EQ("CH", country_code_);
79 ASSERT_TRUE(ruleset_ != NULL); 81 ASSERT_TRUE(ruleset_ != NULL);
80 82
81 const std::vector<std::string>& sub_keys = ruleset_->rule().GetSubKeys(); 83 const std::vector<std::string>& sub_keys = ruleset_->rule().GetSubKeys();
(...skipping 18 matching lines...) Expand all
100 lang_it = non_default_languages.begin(); 102 lang_it = non_default_languages.begin();
101 lang_it != non_default_languages.end(); 103 lang_it != non_default_languages.end();
102 ++lang_it) { 104 ++lang_it) {
103 EXPECT_TRUE(ruleset_->GetLanguageCodeRule(*lang_it).GetLanguage() != 105 EXPECT_TRUE(ruleset_->GetLanguageCodeRule(*lang_it).GetLanguage() !=
104 ruleset_->rule().GetLanguage()); 106 ruleset_->rule().GetLanguage());
105 } 107 }
106 } 108 }
107 109
108 } // namespace addressinput 110 } // namespace addressinput
109 } // namespace i18n 111 } // namespace i18n
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698