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

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

Issue 137563004: libaddressinput: Add fallback data for US address validation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix fmt 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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 Retriever bad_retriever(FakeDownloader::kFakeDataUrl, 115 Retriever bad_retriever(FakeDownloader::kFakeDataUrl,
116 scoped_ptr<Downloader>(new FaultyDownloader), 116 scoped_ptr<Downloader>(new FaultyDownloader),
117 scoped_ptr<Storage>(new FakeStorage)); 117 scoped_ptr<Storage>(new FakeStorage));
118 bad_retriever.Retrieve(kKey, BuildCallback()); 118 bad_retriever.Retrieve(kKey, BuildCallback());
119 119
120 EXPECT_FALSE(success_); 120 EXPECT_FALSE(success_);
121 EXPECT_EQ(kKey, key_); 121 EXPECT_EQ(kKey, key_);
122 EXPECT_TRUE(data_.empty()); 122 EXPECT_TRUE(data_.empty());
123 } 123 }
124 124
125 TEST_F(RetrieverTest, FaultyDownloaderFallback) {
126 Retriever bad_retriever(FakeDownloader::kFakeDataUrl,
127 scoped_ptr<Downloader>(new FaultyDownloader),
128 scoped_ptr<Storage>(new FakeStorage));
129 const char kFallbackDataKey[] = "data/US";
130 bad_retriever.Retrieve(kFallbackDataKey, BuildCallback());
131
132 EXPECT_TRUE(success_);
133 EXPECT_EQ(kFallbackDataKey, key_);
134 EXPECT_FALSE(data_.empty());
please use gerrit instead 2014/01/16 00:50:15 Aslo this: EXPECT_NE(kEmptyData, data_); (kEmpty
Evan Stade 2014/01/16 01:09:10 Done.
135 }
136
125 // The downloader that doesn't get back to you. 137 // The downloader that doesn't get back to you.
126 class HangingDownloader : public Downloader { 138 class HangingDownloader : public Downloader {
127 public: 139 public:
128 HangingDownloader() {} 140 HangingDownloader() {}
129 virtual ~HangingDownloader() {} 141 virtual ~HangingDownloader() {}
130 142
131 // Downloader implementation. 143 // Downloader implementation.
132 virtual void Download(const std::string& url, 144 virtual void Download(const std::string& url,
133 scoped_ptr<Callback> downloaded) {} 145 scoped_ptr<Callback> downloaded) {}
134 }; 146 };
135 147
136 TEST_F(RetrieverTest, RequestsDontStack) { 148 TEST_F(RetrieverTest, RequestsDontStack) {
137 Retriever slow_retriever(FakeDownloader::kFakeDataUrl, 149 Retriever slow_retriever(FakeDownloader::kFakeDataUrl,
138 scoped_ptr<Downloader>(new HangingDownloader), 150 scoped_ptr<Downloader>(new HangingDownloader),
139 scoped_ptr<Storage>(new FakeStorage)); 151 scoped_ptr<Storage>(new FakeStorage));
140 152
141 slow_retriever.Retrieve(kKey, BuildCallback()); 153 slow_retriever.Retrieve(kKey, BuildCallback());
142 EXPECT_FALSE(success_); 154 EXPECT_FALSE(success_);
143 EXPECT_TRUE(key_.empty()); 155 EXPECT_TRUE(key_.empty());
144 156
145 EXPECT_NO_FATAL_FAILURE(slow_retriever.Retrieve(kKey, BuildCallback())); 157 EXPECT_NO_FATAL_FAILURE(slow_retriever.Retrieve(kKey, BuildCallback()));
146 } 158 }
147 159
148 } // namespace 160 } // namespace
149 161
150 } // namespace addressinput 162 } // namespace addressinput
151 } // namespace i18n 163 } // namespace i18n
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698