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

Unified Diff: third_party/libaddressinput/chromium/cpp/test/rule_retriever_test.cc

Issue 109323011: [rac] Download all rules for a country code in libaddressinput. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge smaller patches. Created 7 years 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 side-by-side diff with in-line comments
Download patch
Index: third_party/libaddressinput/chromium/cpp/test/rule_retriever_test.cc
diff --git a/third_party/libaddressinput/chromium/cpp/test/rule_retriever_test.cc b/third_party/libaddressinput/chromium/cpp/test/rule_retriever_test.cc
index b20c9fb5d6734fd7115cbc033ac9cc5897c16b75..52896a5b78a5bd743fd091b8bc9e811bbd0dc3e5 100644
--- a/third_party/libaddressinput/chromium/cpp/test/rule_retriever_test.cc
+++ b/third_party/libaddressinput/chromium/cpp/test/rule_retriever_test.cc
@@ -23,6 +23,7 @@
#include "fake_downloader.h"
#include "fake_storage.h"
+#include "lookup_key.h"
#include "retriever.h"
#include "rule.h"
@@ -30,6 +31,7 @@ namespace {
using i18n::addressinput::FakeDownloader;
using i18n::addressinput::FakeStorage;
+using i18n::addressinput::LookupKey;
using i18n::addressinput::Retriever;
using i18n::addressinput::Rule;
using i18n::addressinput::RuleRetriever;
@@ -43,7 +45,6 @@ class RuleRetrieverTest : public testing::Test {
new FakeDownloader,
new FakeStorage)),
success_(false),
- key_(),
rule_() {}
virtual ~RuleRetrieverTest() {}
@@ -55,39 +56,25 @@ class RuleRetrieverTest : public testing::Test {
RuleRetriever rule_retriever_;
bool success_;
- std::string key_;
Rule rule_;
private:
void OnRuleReady(bool success,
- const std::string& key,
+ const LookupKey& key,
const Rule& rule) {
success_ = success;
- key_ = key;
rule_.CopyFrom(rule);
}
};
-TEST_F(RuleRetrieverTest, ExistingRule) {
- static const char kExistingKey[] = "data/CA";
+TEST_F(RuleRetrieverTest, Basic) {
+ LookupKey key("CA");
scoped_ptr<RuleRetriever::Callback> callback(BuildCallback());
- rule_retriever_.RetrieveRule(kExistingKey, *callback);
+ rule_retriever_.RetrieveRule(key, *callback);
EXPECT_TRUE(success_);
- EXPECT_EQ(kExistingKey, key_);
EXPECT_FALSE(rule_.GetFormat().empty());
}
-TEST_F(RuleRetrieverTest, MissingRule) {
- static const char kMissingKey[] = "junk";
-
- scoped_ptr<RuleRetriever::Callback> callback(BuildCallback());
- rule_retriever_.RetrieveRule(kMissingKey, *callback);
-
- EXPECT_TRUE(success_); // The server returns "{}" for bad keys.
- EXPECT_EQ(kMissingKey, key_);
- EXPECT_TRUE(rule_.GetFormat().empty());
-}
-
} // namespace

Powered by Google App Engine
This is Rietveld 408576698