Change IsFieldRequired and IsFieldUsed to use statically linked region_data_constants, rather than the metadata from the server. This is possible now since region_data_constants is autogenerated and can be depended on to be up-to-date (r206).
diff --git a/cpp/include/libaddressinput/address_metadata.h b/cpp/include/libaddressinput/address_metadata.h
new file mode 100644
index 0000000..c379781
--- /dev/null
+++ b/cpp/include/libaddressinput/address_metadata.h
@@ -0,0 +1,34 @@
+// Copyright (C) 2014 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.
+
+#ifndef I18N_ADDRESSINPUT_ADDRESS_METADATA_H_
+#define I18N_ADDRESSINPUT_ADDRESS_METADATA_H_
+
+#include <libaddressinput/address_field.h>
+
+namespace i18n {
+namespace addressinput {
+
+// Checks whether |field| is a required field for |region_code|. Returns false
+// also if no data could be found for region_code.
+bool IsFieldRequired(AddressField field, const std::string& region_code);
+
+// Checks whether |field| is a field that is used for |region_code|. Returns
+// false also if no data could be found for region_code.
+bool IsFieldUsed(AddressField field, const std::string& region_code);
+
+} // namespace addressinput
+} // namespace i18n
+
+#endif // I18N_ADDRESSINPUT_ADDRESS_METADATA_H_
diff --git a/cpp/include/libaddressinput/address_validator.h b/cpp/include/libaddressinput/address_validator.h
index a7a6f1f..87ad726 100644
--- a/cpp/include/libaddressinput/address_validator.h
+++ b/cpp/include/libaddressinput/address_validator.h
@@ -72,12 +72,6 @@
public:
typedef i18n::addressinput::Callback<AddressData, FieldProblemMap> Callback;
- // Callback function for Is*() methods that answer yes/no questions. The
- // |success| parameter will tell whether an answer to the question could be
- // found, the |key| parameter will tell which item the question was answered
- // for and the |data| parameter will tell the answer.
- typedef i18n::addressinput::Callback<std::string, bool> BoolCallback;
-
// Takes ownership of |downloader| and |storage|. The |validation_data_url|
// should be a URL to an address data server that |downloader| can access.
//
@@ -117,30 +111,6 @@
FieldProblemMap* problems,
const Callback& validated) const;
- // Checks whether |field| is a required field for |region_code|.
- //
- // Calls the |answered| callback when checking is done. All objects passed
- // as parameters must be kept available until the callback has been called.
- //
- // The |success| parameter of the callback indicates whether it was possible
- // to find an answer. If |success| is true, then the |data| parameter of the
- // callback will tell the answer to the question.
- void IsFieldRequired(AddressField field,
- const std::string& region_code,
- const BoolCallback& answered) const;
-
- // Checks whether |field| is a field that is used for |region_code|.
- //
- // Calls the |answered| callback when checking is done. All objects passed
- // as parameters must be kept available until the callback has been called.
- //
- // The |success| parameter of the callback indicates whether it was possible
- // to find an answer. If |success| is true, then the |data| parameter of the
- // callback will tell the answer to the question.
- void IsFieldUsed(AddressField field,
- const std::string& region_code,
- const BoolCallback& answered) const;
-
private:
// AddressValidator objects can either use an already existing Supplier
// object, or create its own Supplier object to use.
diff --git a/cpp/libaddressinput.gypi b/cpp/libaddressinput.gypi
index 090ae64..4e0a557 100644
--- a/cpp/libaddressinput.gypi
+++ b/cpp/libaddressinput.gypi
@@ -18,6 +18,7 @@
'src/address_field.cc',
'src/address_field_util.cc',
'src/address_formatter.cc',
+ 'src/address_metadata.cc',
'src/address_problem.cc',
'src/address_ui.cc',
'src/address_validator.cc',
@@ -26,7 +27,6 @@
'src/localization.cc',
'src/lookup_key.cc',
'src/lookup_key_util.cc',
- 'src/metadata_query_task.cc',
'src/null_storage.cc',
'src/ondemand_supplier.cc',
'src/post_box_matchers.cc',
@@ -49,6 +49,7 @@
'test/address_field_test.cc',
'test/address_field_util_test.cc',
'test/address_formatter_test.cc',
+ 'test/address_metadata_test.cc',
'test/address_problem_test.cc',
'test/address_ui_test.cc',
'test/address_validator_test.cc',
@@ -61,7 +62,6 @@
'test/localization_test.cc',
'test/lookup_key_test.cc',
'test/lookup_key_util_test.cc',
- 'test/metadata_query_task_test.cc',
'test/null_storage_test.cc',
'test/ondemand_supplier_test.cc',
'test/post_box_matchers_test.cc',
diff --git a/cpp/src/address_metadata.cc b/cpp/src/address_metadata.cc
new file mode 100644
index 0000000..093ebdf
--- /dev/null
+++ b/cpp/src/address_metadata.cc
@@ -0,0 +1,54 @@
+// Copyright (C) 2014 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 <libaddressinput/address_metadata.h>
+
+#include <libaddressinput/address_field.h>
+
+#include <algorithm>
+
+#include "region_data_constants.h"
+#include "rule.h"
+
+namespace i18n {
+namespace addressinput {
+
+bool IsFieldRequired(AddressField field, const std::string& region_code) {
+ Rule rule;
+ rule.CopyFrom(Rule::GetDefault());
+ if (!rule.ParseSerializedRule(
+ RegionDataConstants::GetRegionData(region_code))) {
+ return false;
+ }
+
+ return std::find(rule.GetRequired().begin(),
+ rule.GetRequired().end(),
+ field) != rule.GetRequired().end();
+}
+
+bool IsFieldUsed(AddressField field, const std::string& region_code) {
+ Rule rule;
+ rule.CopyFrom(Rule::GetDefault());
+ if (!rule.ParseSerializedRule(
+ RegionDataConstants::GetRegionData(region_code))) {
+ return false;
+ }
+
+ return std::find(rule.GetFormat().begin(),
+ rule.GetFormat().end(),
+ FormatElement(field)) != rule.GetFormat().end();
+}
+
+} // namespace addressinput
+} // namespace i18n
diff --git a/cpp/src/address_validator.cc b/cpp/src/address_validator.cc
index 1092f8c..8f726e8 100644
--- a/cpp/src/address_validator.cc
+++ b/cpp/src/address_validator.cc
@@ -18,15 +18,10 @@
#include <libaddressinput/supplier.h>
#include <libaddressinput/util/scoped_ptr.h>
-#include <algorithm>
-#include <cassert>
-#include <cstddef>
#include <string>
-#include "metadata_query_task.h"
#include "ondemand_supplier.h"
#include "retriever.h"
-#include "rule.h"
#include "validation_task.h"
namespace i18n {
@@ -66,69 +61,5 @@
validated))->Run(supplier_);
}
-namespace {
-
-class IsFieldRequiredTask : public MetadataQueryTask {
- public:
- IsFieldRequiredTask(AddressField field,
- const std::string& region_code,
- const AddressValidator::BoolCallback& answered)
- : MetadataQueryTask(field, region_code, answered) {}
-
- virtual ~IsFieldRequiredTask() {}
-
- protected:
- virtual bool Query(const Supplier::RuleHierarchy& hierarchy) const {
- assert(hierarchy.rule_[0] != NULL);
- const Rule& country_rule = *hierarchy.rule_[0];
- return std::find(country_rule.GetRequired().begin(),
- country_rule.GetRequired().end(),
- field_) != country_rule.GetRequired().end();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(IsFieldRequiredTask);
-};
-
-class IsFieldUsedTask : public MetadataQueryTask {
- public:
- IsFieldUsedTask(AddressField field,
- const std::string& region_code,
- const AddressValidator::BoolCallback& answered)
- : MetadataQueryTask(field, region_code, answered) {}
-
- virtual ~IsFieldUsedTask() {}
-
- protected:
- virtual bool Query(const Supplier::RuleHierarchy& hierarchy) const {
- assert(hierarchy.rule_[0] != NULL);
- const Rule& country_rule = *hierarchy.rule_[0];
- return std::find(country_rule.GetFormat().begin(),
- country_rule.GetFormat().end(),
- FormatElement(field_)) != country_rule.GetFormat().end();
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(IsFieldUsedTask);
-};
-
-} // namespace
-
-void AddressValidator::IsFieldRequired(
- AddressField field,
- const std::string& region_code,
- const BoolCallback& answered) const {
- // The MetadataQueryTask object will delete itself after Run() has finished.
- (new IsFieldRequiredTask(field, region_code, answered))->Run(supplier_);
-}
-
-void AddressValidator::IsFieldUsed(
- AddressField field,
- const std::string& region_code,
- const BoolCallback& answered) const {
- // The MetadataQueryTask object will delete itself after Run() has finished.
- (new IsFieldUsedTask(field, region_code, answered))->Run(supplier_);
-}
-
} // namespace addressinput
} // namespace i18n
diff --git a/cpp/src/metadata_query_task.cc b/cpp/src/metadata_query_task.cc
deleted file mode 100644
index 13b827c..0000000
--- a/cpp/src/metadata_query_task.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (C) 2014 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 "metadata_query_task.h"
-
-#include <libaddressinput/address_data.h>
-#include <libaddressinput/address_field.h>
-#include <libaddressinput/address_validator.h>
-
-#include <cassert>
-#include <cstddef>
-#include <string>
-
-#include "lookup_key.h"
-#include "ondemand_supplier.h"
-
-namespace i18n {
-namespace addressinput {
-
-MetadataQueryTask::MetadataQueryTask(
- AddressField field,
- const std::string& region_code,
- const AddressValidator::BoolCallback& answered)
- : field_(field),
- region_code_(region_code),
- answered_(answered),
- supplied_(BuildCallback(this, &MetadataQueryTask::ExecuteQuery)),
- lookup_key_(new LookupKey) {
- AddressData address;
- address.region_code = region_code;
- lookup_key_->FromAddress(address);
-}
-
-MetadataQueryTask::~MetadataQueryTask() {
-}
-
-void MetadataQueryTask::Run(Supplier* supplier) const {
- assert(supplier != NULL);
- supplier->Supply(*lookup_key_, *supplied_);
-}
-
-void MetadataQueryTask::ExecuteQuery(
- bool success,
- const LookupKey& lookup_key,
- const Supplier::RuleHierarchy& hierarchy) {
- assert(&lookup_key == lookup_key_.get()); // Sanity check.
- bool answer = false;
-
- if (success) {
- if (hierarchy.rule_[0] == NULL) {
- success = false;
- } else {
- answer = Query(hierarchy);
- }
- }
-
- answered_(success, region_code_, answer);
- delete this;
-}
-
-} // namespace addressinput
-} // namespace i18n
diff --git a/cpp/src/metadata_query_task.h b/cpp/src/metadata_query_task.h
deleted file mode 100644
index e1c5733..0000000
--- a/cpp/src/metadata_query_task.h
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (C) 2014 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.
-
-#ifndef I18N_ADDRESSINPUT_METADATA_QUERY_TASK_H_
-#define I18N_ADDRESSINPUT_METADATA_QUERY_TASK_H_
-
-#include <libaddressinput/address_field.h>
-#include <libaddressinput/address_validator.h>
-#include <libaddressinput/supplier.h>
-#include <libaddressinput/util/basictypes.h>
-#include <libaddressinput/util/scoped_ptr.h>
-
-#include <string>
-
-namespace i18n {
-namespace addressinput {
-
-class LookupKey;
-
-// A MetadataQueryTask object encapsulates the information necessary to perform
-// the checking for an Is*() method that answers a yes/no question and call a
-// callback when that has been done. Calling the Run() method will load required
-// metadata, then perform checking, call the callback and delete the
-// MetadataQueryTask object itself.
-//
-// The logic of the different Is*() methods is implemented by the virtual
-// Query() method of subclasses of the abstract MetadataQueryTask base class.
-class MetadataQueryTask {
- public:
- MetadataQueryTask(AddressField field,
- const std::string& region_code,
- const AddressValidator::BoolCallback& answered);
-
- virtual ~MetadataQueryTask();
-
- // Calls supplier->Supply(), with ExecuteQuery() as callback.
- void Run(Supplier* supplier) const;
-
- protected:
- // Uses the address metadata of |hierarchy| to answer a yes/no question.
- virtual bool Query(const Supplier::RuleHierarchy& hierarchy) const = 0;
-
- const AddressField field_;
-
- private:
- friend class MetadataQueryTaskTest;
-
- // Executes Query(), if |success| is true and |hierarchy| contains data. Then
- // calls the |answered_| callback and deletes this MetadataQueryTask object.
- void ExecuteQuery(bool success,
- const LookupKey& lookup_key,
- const Supplier::RuleHierarchy& hierarchy);
-
- const std::string& region_code_;
- const AddressValidator::BoolCallback& answered_;
- const scoped_ptr<const Supplier::Callback> supplied_;
- const scoped_ptr<LookupKey> lookup_key_;
-
- DISALLOW_COPY_AND_ASSIGN(MetadataQueryTask);
-};
-
-} // namespace addressinput
-} // namespace i18n
-
-#endif // I18N_ADDRESSINPUT_METADATA_QUERY_TASK_H_
diff --git a/cpp/test/address_metadata_test.cc b/cpp/test/address_metadata_test.cc
new file mode 100644
index 0000000..bf17a3b
--- /dev/null
+++ b/cpp/test/address_metadata_test.cc
@@ -0,0 +1,55 @@
+// Copyright (C) 2014 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 <libaddressinput/address_metadata.h>
+
+#include <libaddressinput/address_field.h>
+
+#include <gtest/gtest.h>
+
+namespace {
+
+using i18n::addressinput::ADMIN_AREA;
+using i18n::addressinput::DEPENDENT_LOCALITY;
+
+using i18n::addressinput::IsFieldRequired;
+using i18n::addressinput::IsFieldUsed;
+
+TEST(AddressMetadataTest, IsFieldRequiredAdminAreaUS) {
+ EXPECT_TRUE(IsFieldRequired(ADMIN_AREA, "US"));
+}
+
+TEST(AddressMetadataTest, IsFieldRequiredAdminAreaAT) {
+ EXPECT_FALSE(IsFieldRequired(ADMIN_AREA, "AT"));
+}
+
+TEST(AddressMetadataTest, IsFieldRequiredAdminAreaSU) {
+ // Unsupported region.
+ EXPECT_FALSE(IsFieldRequired(ADMIN_AREA, "SU"));
+}
+
+TEST(AddressMetadataTest, IsFieldUsedDependentLocalityUS) {
+ EXPECT_FALSE(IsFieldUsed(DEPENDENT_LOCALITY, "US"));
+}
+
+TEST(AddressMetadataTest, IsFieldUsedDependentLocalityCN) {
+ EXPECT_TRUE(IsFieldUsed(DEPENDENT_LOCALITY, "CN"));
+}
+
+TEST(AddressMetadataTest, IsFieldUsedDependentLocalitySU) {
+ // Unsupported region.
+ EXPECT_FALSE(IsFieldUsed(DEPENDENT_LOCALITY, "SU"));
+}
+
+} // namespace
diff --git a/cpp/test/address_validator_test.cc b/cpp/test/address_validator_test.cc
index ae503fe..3cb1942 100644
--- a/cpp/test/address_validator_test.cc
+++ b/cpp/test/address_validator_test.cc
@@ -15,7 +15,6 @@
#include <libaddressinput/address_validator.h>
#include <libaddressinput/address_data.h>
-#include <libaddressinput/address_field.h>
#include <libaddressinput/address_problem.h>
#include <libaddressinput/callback.h>
#include <libaddressinput/null_storage.h>
@@ -329,85 +328,4 @@
EXPECT_EQ(expected_, problems_);
}
-class AddressMetadataQueryTest : public testing::Test {
- protected:
- AddressMetadataQueryTest()
- : success_(false),
- region_code_(),
- answer_(false),
- called_(false),
- validator_(FakeDownloader::kFakeDataUrl,
- new FakeDownloader,
- new NullStorage),
- answered_(BuildCallback(this, &AddressMetadataQueryTest::Answered)) {}
-
- virtual ~AddressMetadataQueryTest() {}
-
- bool success_;
- std::string region_code_;
- bool answer_;
- bool called_;
-
- const AddressValidator validator_;
- const scoped_ptr<const AddressValidator::BoolCallback> answered_;
-
- private:
- void Answered(bool success,
- const std::string& region_code,
- const bool& answer) {
- success_ = success;
- ASSERT_EQ(®ion_code_, ®ion_code);
- answer_ = answer;
- called_ = true;
- }
-
- DISALLOW_COPY_AND_ASSIGN(AddressMetadataQueryTest);
-};
-
-TEST_F(AddressMetadataQueryTest, IsFieldRequiredAdminAreaUS) {
- region_code_ = "US";
- validator_.IsFieldRequired(ADMIN_AREA, region_code_, *answered_);
- ASSERT_TRUE(called_);
- EXPECT_TRUE(success_);
- EXPECT_TRUE(answer_);
-}
-
-TEST_F(AddressMetadataQueryTest, IsFieldRequiredAdminAreaAT) {
- region_code_ = "AT";
- validator_.IsFieldRequired(ADMIN_AREA, region_code_, *answered_);
- ASSERT_TRUE(called_);
- EXPECT_TRUE(success_);
- EXPECT_FALSE(answer_);
-}
-
-TEST_F(AddressMetadataQueryTest, IsFieldRequiredAdminAreaSU) {
- region_code_ = "SU"; // Unsupported region.
- validator_.IsFieldRequired(ADMIN_AREA, region_code_, *answered_);
- ASSERT_TRUE(called_);
- EXPECT_FALSE(success_);
-}
-
-TEST_F(AddressMetadataQueryTest, IsFieldUsedDependentLocalityUS) {
- region_code_ = "US";
- validator_.IsFieldUsed(DEPENDENT_LOCALITY, region_code_, *answered_);
- ASSERT_TRUE(called_);
- EXPECT_TRUE(success_);
- EXPECT_FALSE(answer_);
-}
-
-TEST_F(AddressMetadataQueryTest, IsFieldUsedDependentLocalityCN) {
- region_code_ = "CN";
- validator_.IsFieldUsed(DEPENDENT_LOCALITY, region_code_, *answered_);
- ASSERT_TRUE(called_);
- EXPECT_TRUE(success_);
- EXPECT_TRUE(answer_);
-}
-
-TEST_F(AddressMetadataQueryTest, IsFieldUsedDependentLocalitySU) {
- region_code_ = "SU"; // Unsupported region.
- validator_.IsFieldUsed(DEPENDENT_LOCALITY, region_code_, *answered_);
- ASSERT_TRUE(called_);
- EXPECT_FALSE(success_);
-}
-
} // namespace
diff --git a/cpp/test/metadata_query_task_test.cc b/cpp/test/metadata_query_task_test.cc
deleted file mode 100644
index b5fa95a..0000000
--- a/cpp/test/metadata_query_task_test.cc
+++ /dev/null
@@ -1,150 +0,0 @@
-// Copyright (C) 2014 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 "metadata_query_task.h"
-
-#include <libaddressinput/address_field.h>
-#include <libaddressinput/address_validator.h>
-#include <libaddressinput/callback.h>
-#include <libaddressinput/util/basictypes.h>
-#include <libaddressinput/util/scoped_ptr.h>
-
-#include <string>
-
-#include <gtest/gtest.h>
-
-#include "ondemand_supplier.h"
-#include "rule.h"
-
-namespace i18n {
-namespace addressinput {
-
-class LookupKey;
-
-class MetadataQueryTaskTest : public testing::Test {
- private:
- class MockTask : public MetadataQueryTask {
- public:
- MockTask(bool answer,
- const std::string& region_code,
- const AddressValidator::BoolCallback& answered)
- : MetadataQueryTask(
- static_cast<AddressField>(-1), // The field shouldn't be used.
- region_code,
- answered),
- answer_(answer) {}
-
- virtual ~MockTask() {}
-
- protected:
- virtual bool Query(const Supplier::RuleHierarchy& hierarchy) const {
- return answer_;
- }
-
- private:
- const bool answer_;
- DISALLOW_COPY_AND_ASSIGN(MockTask);
- };
-
- protected:
- MetadataQueryTaskTest()
- : use_default_rule_(false),
- success_(true),
- region_code_(),
- answer_(),
- called_(false),
- answered_(BuildCallback(this, &MetadataQueryTaskTest::Answered)) {}
-
- virtual ~MetadataQueryTaskTest() {}
-
- void Run() {
- MetadataQueryTask* task = new MockTask(answer_, region_code_, *answered_);
-
- Supplier::RuleHierarchy* hierarchy = new Supplier::RuleHierarchy();
-
- if (use_default_rule_) {
- hierarchy->rule_[0] = &Rule::GetDefault();
- }
-
- (*task->supplied_)(success_, *task->lookup_key_, *hierarchy);
- }
-
- bool use_default_rule_;
- bool success_;
- const std::string region_code_;
- bool answer_;
- bool called_;
-
- private:
- void Answered(bool success,
- const std::string& region_code,
- const bool& answer) {
- success_ = success;
- ASSERT_EQ(®ion_code_, ®ion_code);
- answer_ = answer;
- called_ = true;
- }
-
- const scoped_ptr<const AddressValidator::BoolCallback> answered_;
-
- DISALLOW_COPY_AND_ASSIGN(MetadataQueryTaskTest);
-};
-
-namespace {
-
-TEST_F(MetadataQueryTaskTest, FailureCountryRuleNull) {
- success_ = false;
-
- ASSERT_NO_FATAL_FAILURE(Run());
- ASSERT_TRUE(called_);
- EXPECT_FALSE(success_);
-}
-
-TEST_F(MetadataQueryTaskTest, FailureCountryRuleDefault) {
- use_default_rule_ = true;
- success_ = false;
-
- ASSERT_NO_FATAL_FAILURE(Run());
- ASSERT_TRUE(called_);
- EXPECT_FALSE(success_);
-}
-
-TEST_F(MetadataQueryTaskTest, SuccessCountryRuleNull) {
- ASSERT_NO_FATAL_FAILURE(Run());
- ASSERT_TRUE(called_);
- EXPECT_FALSE(success_);
-}
-
-TEST_F(MetadataQueryTaskTest, SuccessCountryRuleDefault) {
- use_default_rule_ = true;
-
- ASSERT_NO_FATAL_FAILURE(Run());
- ASSERT_TRUE(called_);
- EXPECT_TRUE(success_);
- EXPECT_FALSE(answer_);
-}
-
-TEST_F(MetadataQueryTaskTest, SuccessCountryRuleDefaultAnswerTrue) {
- use_default_rule_ = true;
- answer_ = true;
-
- ASSERT_NO_FATAL_FAILURE(Run());
- ASSERT_TRUE(called_);
- EXPECT_TRUE(success_);
- EXPECT_TRUE(answer_);
-}
-
-} // namespace
-} // namespace addressinput
-} // namespace i18n