| Index: third_party/libaddressinput/chromium/cpp/test/country_rules_aggregator_test.cc
 | 
| diff --git a/third_party/libaddressinput/chromium/cpp/test/country_rules_aggregator_test.cc b/third_party/libaddressinput/chromium/cpp/test/country_rules_aggregator_test.cc
 | 
| new file mode 100644
 | 
| index 0000000000000000000000000000000000000000..6dec90ccddb8b81457b3615e2ba0c0ae72e14e8f
 | 
| --- /dev/null
 | 
| +++ b/third_party/libaddressinput/chromium/cpp/test/country_rules_aggregator_test.cc
 | 
| @@ -0,0 +1,89 @@
 | 
| +// Copyright (C) 2013 Google Inc.
 | 
| +//
 | 
| +// Licensed under the Apache License, Version 2.0 (the "License");
 | 
| +// you may not use this file except in compliance with the License.
 | 
| +// You may obtain a copy of the License at
 | 
| +//
 | 
| +// http://www.apache.org/licenses/LICENSE-2.0
 | 
| +//
 | 
| +// Unless required by applicable law or agreed to in writing, software
 | 
| +// distributed under the License is distributed on an "AS IS" BASIS,
 | 
| +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 | 
| +// See the License for the specific language governing permissions and
 | 
| +// limitations under the License.
 | 
| +
 | 
| +#include "country_rules_aggregator.h"
 | 
| +
 | 
| +#include <libaddressinput/callback.h>
 | 
| +#include <libaddressinput/downloader.h>
 | 
| +#include <libaddressinput/storage.h>
 | 
| +#include <libaddressinput/util/basictypes.h>
 | 
| +#include <libaddressinput/util/scoped_ptr.h>
 | 
| +
 | 
| +#include <cstddef>
 | 
| +#include <string>
 | 
| +#include <vector>
 | 
| +
 | 
| +#include <gtest/gtest.h>
 | 
| +
 | 
| +#include "fake_downloader.h"
 | 
| +#include "fake_storage.h"
 | 
| +#include "retriever.h"
 | 
| +#include "rule.h"
 | 
| +#include "ruleset.h"
 | 
| +
 | 
| +namespace i18n {
 | 
| +namespace addressinput {
 | 
| +
 | 
| +class CountryRulesAggregatorTest : public testing::Test {
 | 
| + public:
 | 
| +  CountryRulesAggregatorTest()
 | 
| +      : aggregator_(scoped_ptr<Retriever>(new Retriever(
 | 
| +            FakeDownloader::kFakeDataUrl,
 | 
| +            scoped_ptr<Downloader>(new FakeDownloader),
 | 
| +            scoped_ptr<Storage>(new FakeStorage)))),
 | 
| +        success_(false),
 | 
| +        country_code_(),
 | 
| +        ruleset_() {}
 | 
| +
 | 
| +  virtual ~CountryRulesAggregatorTest() {}
 | 
| +
 | 
| + protected:
 | 
| +  scoped_ptr<CountryRulesAggregator::Callback> BuildCallback() {
 | 
| +    return ::i18n::addressinput::BuildScopedPtrCallback(
 | 
| +        this, &CountryRulesAggregatorTest::OnRulesetReady);
 | 
| +  }
 | 
| +
 | 
| +  CountryRulesAggregator aggregator_;
 | 
| +  bool success_;
 | 
| +  std::string country_code_;
 | 
| +  scoped_ptr<Ruleset> ruleset_;
 | 
| +
 | 
| + private:
 | 
| +  void OnRulesetReady(bool success,
 | 
| +                      const std::string& country_code,
 | 
| +                      scoped_ptr<Ruleset> ruleset) {
 | 
| +    success_ = success;
 | 
| +    country_code_ = country_code;
 | 
| +    ruleset_.reset(ruleset.release());
 | 
| +  }
 | 
| +
 | 
| +  DISALLOW_COPY_AND_ASSIGN(CountryRulesAggregatorTest);
 | 
| +};
 | 
| +
 | 
| +TEST_F(CountryRulesAggregatorTest, ValidRuleset) {
 | 
| +  aggregator_.AggregateRules("US", BuildCallback());
 | 
| +  EXPECT_TRUE(success_);
 | 
| +  EXPECT_EQ("US", country_code_);
 | 
| +  ASSERT_TRUE(ruleset_ != NULL);
 | 
| +  EXPECT_LT(0, ruleset_->rule().GetSubKeys().size());
 | 
| +  for (std::vector<std::string>::const_iterator
 | 
| +           sub_key_it = ruleset_->rule().GetSubKeys().begin();
 | 
| +       sub_key_it != ruleset_->rule().GetSubKeys().end();
 | 
| +       ++sub_key_it) {
 | 
| +    EXPECT_TRUE(ruleset_->GetSubRegionRuleset(*sub_key_it) != NULL);
 | 
| +  }
 | 
| +}
 | 
| +
 | 
| +}  // namespace addressinput
 | 
| +}  // namespace i18n
 | 
| 
 |