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

Unified Diff: third_party/libaddressinput/chromium/chrome_downloader_impl_unittest.cc

Issue 386873002: Reland "Use upstream libaddressinput in Chrome." (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix iOS compile. Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: third_party/libaddressinput/chromium/chrome_downloader_impl_unittest.cc
diff --git a/third_party/libaddressinput/chromium/chrome_downloader_impl_unittest.cc b/third_party/libaddressinput/chromium/chrome_downloader_impl_unittest.cc
index 2bf1e01a2079dcebc3cb2c871908f0baeb4fb706..5fee4d623df4900aa170c524e59b8f1807f4f3e0 100644
--- a/third_party/libaddressinput/chromium/chrome_downloader_impl_unittest.cc
+++ b/third_party/libaddressinput/chromium/chrome_downloader_impl_unittest.cc
@@ -35,27 +35,31 @@ class ChromeDownloaderImplTest : public testing::Test {
scoped_refptr<net::TestURLRequestContextGetter> getter(
new net::TestURLRequestContextGetter(
base::MessageLoopProxy::current()));
- ChromeDownloaderImpl impl(getter);
- impl.Download(url_.spec(), BuildCallback());
+ ChromeDownloaderImpl impl(getter.get());
+ scoped_ptr< ::i18n::addressinput::Downloader::Callback> callback(
+ ::i18n::addressinput::BuildCallback(
+ this, &ChromeDownloaderImplTest::OnDownloaded));
+ impl.Download(url_.spec(), *callback);
base::MessageLoop::current()->RunUntilIdle();
}
void set_url(const GURL& url) { url_ = url; }
- const std::string& data() { return *data_; }
- bool success() { return success_; }
+ bool success() const { return success_; }
+ bool has_data() const { return !!data_; }
- private:
- scoped_ptr<ChromeDownloaderImpl::Callback> BuildCallback() {
- return ::i18n::addressinput::BuildScopedPtrCallback(
- this, &ChromeDownloaderImplTest::OnDownloaded);
+ const std::string& data() const {
+ DCHECK(data_);
+ return *data_;
}
+ private:
// Callback for when download is finished.
void OnDownloaded(bool success,
const std::string& url,
- scoped_ptr<std::string> data) {
+ std::string* data) {
+ ASSERT_FALSE(success && data == NULL);
success_ = success;
- data_ = data.Pass();
+ data_.reset(data);
}
base::MessageLoop loop_;
@@ -81,7 +85,7 @@ TEST_F(ChromeDownloaderImplTest, Failure) {
SetFakeResponse(kFakePayload, net::HTTP_INTERNAL_SERVER_ERROR);
Download();
EXPECT_FALSE(success());
- EXPECT_EQ(std::string(), data());
+ EXPECT_TRUE(!has_data() || data().empty());
}
TEST_F(ChromeDownloaderImplTest, RejectsInsecureScheme) {
@@ -90,7 +94,7 @@ TEST_F(ChromeDownloaderImplTest, RejectsInsecureScheme) {
SetFakeResponse(kFakePayload, net::HTTP_OK);
Download();
EXPECT_FALSE(success());
- EXPECT_EQ(std::string(), data());
+ EXPECT_TRUE(!has_data() || data().empty());
}
} // namespace autofill

Powered by Google App Engine
This is Rietveld 408576698