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

Unified Diff: net/url_request/url_fetcher_impl_unittest.cc

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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: net/url_request/url_fetcher_impl_unittest.cc
diff --git a/net/url_request/url_fetcher_impl_unittest.cc b/net/url_request/url_fetcher_impl_unittest.cc
index 39e2bb286a9d434c9347422c520a006e16688422..2637b95f46315699a8a3ca52fd8f7b31bee448e9 100644
--- a/net/url_request/url_fetcher_impl_unittest.cc
+++ b/net/url_request/url_fetcher_impl_unittest.cc
@@ -63,8 +63,7 @@ class ThrottlingTestURLRequestContextGetter
base::MessageLoopProxy* io_message_loop_proxy,
TestURLRequestContext* request_context)
: TestURLRequestContextGetter(io_message_loop_proxy),
- context_(request_context) {
- }
+ context_(request_context) {}
// TestURLRequestContextGetter:
virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE {
@@ -79,8 +78,7 @@ class ThrottlingTestURLRequestContextGetter
} // namespace
-class URLFetcherTest : public testing::Test,
- public URLFetcherDelegate {
+class URLFetcherTest : public testing::Test, public URLFetcherDelegate {
public:
URLFetcherTest() : fetcher_(NULL) {}
@@ -104,9 +102,7 @@ class URLFetcherTest : public testing::Test,
return io_message_loop_proxy_;
}
- TestURLRequestContext* request_context() {
- return context_.get();
- }
+ TestURLRequestContext* request_context() { return context_.get(); }
protected:
// testing::Test:
@@ -205,9 +201,8 @@ void URLFetcherMockDnsTest::SetUp() {
// test_server_.GetURL() returns a URL with 127.0.0.1 (kLocalhost), that is
// immediately resolved by the MockHostResolver. Use a hostname instead to
// trigger an async resolve.
- test_url_ = GURL(
- base::StringPrintf("http://example.com:%d/defaultresponse",
- test_server_->host_port_pair().port()));
+ test_url_ = GURL(base::StringPrintf("http://example.com:%d/defaultresponse",
+ test_server_->host_port_pair().port()));
ASSERT_TRUE(test_url_.is_valid());
}
@@ -274,9 +269,7 @@ class URLFetcherEmptyPostTest : public URLFetcherTest {
class URLFetcherDownloadProgressTest : public URLFetcherTest {
public:
URLFetcherDownloadProgressTest()
- : previous_progress_(0),
- expected_total_(0) {
- }
+ : previous_progress_(0), expected_total_(0) {}
// URLFetcherTest:
virtual void CreateFetcher(const GURL& url) OVERRIDE;
@@ -305,6 +298,7 @@ class URLFetcherDownloadProgressCancelTest : public URLFetcherTest {
virtual void OnURLFetchDownloadProgress(const URLFetcher* source,
int64 current,
int64 total) OVERRIDE;
+
protected:
bool cancelled_;
};
@@ -319,6 +313,7 @@ class URLFetcherUploadProgressTest : public URLFetcherTest {
virtual void OnURLFetchUploadProgress(const URLFetcher* source,
int64 current,
int64 total) OVERRIDE;
+
protected:
int64 previous_progress_;
std::string chunk_;
@@ -337,6 +332,7 @@ class URLFetcherSocketAddressTest : public URLFetcherTest {
public:
// URLFetcherDelegate:
virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
+
protected:
std::string expected_host_;
uint16 expected_port_;
@@ -369,6 +365,7 @@ class URLFetcherProtectTest : public URLFetcherTest {
// URLFetcherDelegate:
virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
+
private:
Time start_time_;
};
@@ -382,6 +379,7 @@ class URLFetcherProtectTestPassedThrough : public URLFetcherTest {
// URLFetcherDelegate:
virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
+
private:
Time start_time_;
};
@@ -414,8 +412,7 @@ class URLFetcherCancelTest : public URLFetcherTest {
// thread once it is deleted.
class CancelTestURLRequestContext : public ThrottlingTestURLRequestContext {
public:
- explicit CancelTestURLRequestContext() {
- }
+ explicit CancelTestURLRequestContext() {}
private:
virtual ~CancelTestURLRequestContext() {
@@ -426,8 +423,7 @@ class CancelTestURLRequestContext : public ThrottlingTestURLRequestContext {
}
};
-class CancelTestURLRequestContextGetter
- : public TestURLRequestContextGetter {
+class CancelTestURLRequestContextGetter : public TestURLRequestContextGetter {
public:
CancelTestURLRequestContextGetter(
base::MessageLoopProxy* io_message_loop_proxy,
@@ -435,8 +431,7 @@ class CancelTestURLRequestContextGetter
: TestURLRequestContextGetter(io_message_loop_proxy),
io_message_loop_proxy_(io_message_loop_proxy),
context_created_(false, false),
- throttle_for_url_(throttle_for_url) {
- }
+ throttle_for_url_(throttle_for_url) {}
// TestURLRequestContextGetter:
virtual TestURLRequestContext* GetURLRequestContext() OVERRIDE {
@@ -457,8 +452,8 @@ class CancelTestURLRequestContextGetter
2.0,
0.0,
4000));
- context_->throttler_manager()
- ->OverrideEntryForTests(throttle_for_url_, entry.get());
+ context_->throttler_manager()->OverrideEntryForTests(throttle_for_url_,
+ entry.get());
context_created_.Signal();
}
@@ -469,9 +464,7 @@ class CancelTestURLRequestContextGetter
return io_message_loop_proxy_;
}
- void WaitForContextCreation() {
- context_created_.Wait();
- }
+ void WaitForContextCreation() { context_created_.Wait(); }
protected:
virtual ~CancelTestURLRequestContextGetter() {}
@@ -488,14 +481,15 @@ class URLFetcherMultipleAttemptTest : public URLFetcherTest {
public:
// URLFetcherDelegate:
virtual void OnURLFetchComplete(const URLFetcher* source) OVERRIDE;
+
private:
std::string data_;
};
class URLFetcherFileTest : public URLFetcherTest {
public:
- URLFetcherFileTest() : take_ownership_of_file_(false),
- expected_file_error_(OK) {}
+ URLFetcherFileTest()
+ : take_ownership_of_file_(false), expected_file_error_(OK) {}
void CreateFetcherForFile(const GURL& url, const base::FilePath& file_path);
void CreateFetcherForTempFile(const GURL& url);
@@ -532,8 +526,7 @@ void URLFetcherPostTest::OnURLFetchComplete(const URLFetcher* source) {
}
URLFetcherPostFileTest::URLFetcherPostFileTest()
- : range_offset_(0),
- range_length_(kuint64max) {
+ : range_offset_(0), range_length_(kuint64max) {
PathService::Get(base::DIR_SOURCE_ROOT, &path_);
path_ = path_.Append(FILE_PATH_LITERAL("net"));
path_ = path_.Append(FILE_PATH_LITERAL("data"));
@@ -568,8 +561,8 @@ void URLFetcherPostFileTest::OnURLFetchComplete(const URLFetcher* source) {
void URLFetcherEmptyPostTest::CreateFetcher(const GURL& url) {
fetcher_ = new URLFetcherImpl(url, URLFetcher::POST, this);
- fetcher_->SetRequestContext(new TestURLRequestContextGetter(
- io_message_loop_proxy()));
+ fetcher_->SetRequestContext(
+ new TestURLRequestContextGetter(io_message_loop_proxy()));
fetcher_->SetUploadData("text/plain", std::string());
fetcher_->Start();
}
@@ -595,7 +588,9 @@ void URLFetcherDownloadProgressTest::CreateFetcher(const GURL& url) {
}
void URLFetcherDownloadProgressTest::OnURLFetchDownloadProgress(
- const URLFetcher* source, int64 progress, int64 total) {
+ const URLFetcher* source,
+ int64 progress,
+ int64 total) {
// Increasing between 0 and total.
EXPECT_LE(0, progress);
EXPECT_GE(total, progress);
@@ -613,7 +608,9 @@ void URLFetcherDownloadProgressCancelTest::CreateFetcher(const GURL& url) {
}
void URLFetcherDownloadProgressCancelTest::OnURLFetchDownloadProgress(
- const URLFetcher* source, int64 current, int64 total) {
+ const URLFetcher* source,
+ int64 current,
+ int64 total) {
EXPECT_FALSE(cancelled_);
if (!cancelled_) {
cancelled_ = true;
@@ -634,7 +631,7 @@ void URLFetcherUploadProgressTest::CreateFetcher(const GURL& url) {
io_message_loop_proxy().get(), request_context()));
previous_progress_ = 0;
// Large enough data to require more than one read from UploadDataStream.
- chunk_.assign(1<<16, 'a');
+ chunk_.assign(1 << 16, 'a');
// Use chunked upload to wait for a timer event of progress notification.
fetcher_->SetChunkedUpload("application/x-www-form-urlencoded");
fetcher_->Start();
@@ -643,7 +640,9 @@ void URLFetcherUploadProgressTest::CreateFetcher(const GURL& url) {
}
void URLFetcherUploadProgressTest::OnURLFetchUploadProgress(
- const URLFetcher* source, int64 current, int64 total) {
+ const URLFetcher* source,
+ int64 current,
+ int64 total) {
// Increasing between 0 and total.
EXPECT_LE(0, current);
EXPECT_GE(static_cast<int64>(chunk_.size()) * number_of_chunks_added_,
@@ -658,8 +657,7 @@ void URLFetcherUploadProgressTest::OnURLFetchUploadProgress(
}
}
-void URLFetcherHeadersTest::OnURLFetchComplete(
- const URLFetcher* source) {
+void URLFetcherHeadersTest::OnURLFetchComplete(const URLFetcher* source) {
std::string header;
EXPECT_TRUE(source->GetResponseHeaders()->GetNormalizedHeader("cache-control",
&header));
@@ -667,8 +665,7 @@ void URLFetcherHeadersTest::OnURLFetchComplete(
URLFetcherTest::OnURLFetchComplete(source);
}
-void URLFetcherSocketAddressTest::OnURLFetchComplete(
- const URLFetcher* source) {
+void URLFetcherSocketAddressTest::OnURLFetchComplete(const URLFetcher* source) {
EXPECT_EQ("127.0.0.1", source->GetSocketAddress().host());
EXPECT_EQ(expected_port_, source->GetSocketAddress().port());
URLFetcherTest::OnURLFetchComplete(source);
@@ -772,7 +769,6 @@ void URLFetcherProtectTestPassedThrough::OnURLFetchComplete(
CleanupAfterFetchComplete();
}
-
URLFetcherBadHTTPSTest::URLFetcherBadHTTPSTest() {
PathService::Get(base::DIR_SOURCE_ROOT, &cert_dir_);
cert_dir_ = cert_dir_.AppendASCII("chrome");
@@ -785,8 +781,7 @@ URLFetcherBadHTTPSTest::URLFetcherBadHTTPSTest() {
// The "server certificate expired" error should result in automatic
// cancellation of the request by
// URLRequest::Delegate::OnSSLCertificateError.
-void URLFetcherBadHTTPSTest::OnURLFetchComplete(
- const URLFetcher* source) {
+void URLFetcherBadHTTPSTest::OnURLFetchComplete(const URLFetcher* source) {
// This part is different from URLFetcherTest::OnURLFetchComplete
// because this test expects the request to be cancelled.
EXPECT_EQ(URLRequestStatus::CANCELED, source->GetStatus().status());
@@ -812,8 +807,7 @@ void URLFetcherCancelTest::CreateFetcher(const GURL& url) {
CancelRequest();
}
-void URLFetcherCancelTest::OnURLFetchComplete(
- const URLFetcher* source) {
+void URLFetcherCancelTest::OnURLFetchComplete(const URLFetcher* source) {
// We should have cancelled the request before completion.
ADD_FAILURE();
CleanupAfterFetchComplete();
@@ -871,8 +865,8 @@ void URLFetcherFileTest::OnURLFetchComplete(const URLFetcher* source) {
EXPECT_EQ(OK, source->GetStatus().error());
EXPECT_EQ(200, source->GetResponseCode());
- EXPECT_TRUE(source->GetResponseAsFilePath(
- take_ownership_of_file_, &file_path_));
+ EXPECT_TRUE(
+ source->GetResponseAsFilePath(take_ownership_of_file_, &file_path_));
EXPECT_TRUE(base::ContentsEqual(expected_file_, file_path_));
} else {
@@ -909,11 +903,10 @@ TEST_F(URLFetcherTest, DifferentThreadsTest) {
// scope.
base::Thread t("URLFetcher test thread");
ASSERT_TRUE(t.Start());
- t.message_loop()->PostTask(
- FROM_HERE,
- base::Bind(&URLFetcherTest::CreateFetcher,
- base::Unretained(this),
- test_server.GetURL("defaultresponse")));
+ t.message_loop()->PostTask(FROM_HERE,
+ base::Bind(&URLFetcherTest::CreateFetcher,
+ base::Unretained(this),
+ test_server.GetURL("defaultresponse")));
base::MessageLoop::current()->Run();
}
@@ -1115,8 +1108,8 @@ TEST_F(URLFetcherDownloadProgressTest, Basic) {
expected_total_ = kFileSize;
- CreateFetcher(test_server.GetURL(
- std::string(kTestServerFilePrefix) + kFileToFetch));
+ CreateFetcher(
+ test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch));
base::MessageLoop::current()->Run();
}
@@ -1130,8 +1123,8 @@ TEST_F(URLFetcherDownloadProgressCancelTest, CancelWhileProgressReport) {
// Get a file large enough to require more than one read into
// URLFetcher::Core's IOBuffer.
static const char kFileToFetch[] = "animate1.gif";
- CreateFetcher(test_server.GetURL(
- std::string(kTestServerFilePrefix) + kFileToFetch));
+ CreateFetcher(
+ test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch));
base::MessageLoop::current()->Run();
}
@@ -1193,8 +1186,8 @@ TEST_F(URLFetcherProtectTest, Overload) {
2.0,
0.0,
256));
- request_context()->throttler_manager()
- ->OverrideEntryForTests(url, entry.get());
+ request_context()->throttler_manager()->OverrideEntryForTests(url,
+ entry.get());
CreateFetcher(url);
@@ -1222,8 +1215,8 @@ TEST_F(URLFetcherProtectTest, ServerUnavailable) {
2.0,
0.0,
256));
- request_context()->throttler_manager()
- ->OverrideEntryForTests(url, entry.get());
+ request_context()->throttler_manager()->OverrideEntryForTests(url,
+ entry.get());
CreateFetcher(url);
@@ -1253,8 +1246,8 @@ TEST_F(URLFetcherProtectTestPassedThrough, ServerUnavailablePropagateResponse) {
150000));
// Total time if *not* for not doing automatic backoff would be 150s.
// In reality it should be "as soon as server responds".
- request_context()->throttler_manager()
- ->OverrideEntryForTests(url, entry.get());
+ request_context()->throttler_manager()->OverrideEntryForTests(url,
+ entry.get());
CreateFetcher(url);
@@ -1264,9 +1257,8 @@ TEST_F(URLFetcherProtectTestPassedThrough, ServerUnavailablePropagateResponse) {
TEST_F(URLFetcherBadHTTPSTest, BadHTTPSTest) {
SpawnedTestServer::SSLOptions ssl_options(
SpawnedTestServer::SSLOptions::CERT_EXPIRED);
- SpawnedTestServer test_server(SpawnedTestServer::TYPE_HTTPS,
- ssl_options,
- base::FilePath(kDocRoot));
+ SpawnedTestServer test_server(
+ SpawnedTestServer::TYPE_HTTPS, ssl_options, base::FilePath(kDocRoot));
ASSERT_TRUE(test_server.Start());
CreateFetcher(test_server.GetURL("defaultresponse"));
@@ -1290,8 +1282,8 @@ TEST_F(URLFetcherCancelTest, ReleasesContext) {
ASSERT_TRUE(t.Start());
t.message_loop()->PostTask(
FROM_HERE,
- base::Bind(&URLFetcherCancelTest::CreateFetcher,
- base::Unretained(this), url));
+ base::Bind(
+ &URLFetcherCancelTest::CreateFetcher, base::Unretained(this), url));
base::MessageLoop::current()->Run();
}
@@ -1316,8 +1308,8 @@ TEST_F(URLFetcherCancelTest, CancelWhileDelayedStartTaskPending) {
2.0,
0.0,
4000));
- request_context()->throttler_manager()
- ->OverrideEntryForTests(url, entry.get());
+ request_context()->throttler_manager()->OverrideEntryForTests(url,
+ entry.get());
// Fake that a request has just started.
entry->ReserveSendingTimeForNextRequest(base::TimeTicks());
@@ -1366,8 +1358,8 @@ TEST_F(URLFetcherFileTest, SmallGet) {
base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit().
- ASSERT_FALSE(base::PathExists(file_path_))
- << file_path_.value() << " not removed.";
+ ASSERT_FALSE(base::PathExists(file_path_)) << file_path_.value()
+ << " not removed.";
}
TEST_F(URLFetcherFileTest, LargeGet) {
@@ -1414,8 +1406,8 @@ TEST_F(URLFetcherFileTest, SavedOutputFileOwnerhisp) {
base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit().
base::MessageLoop::current()->RunUntilIdle();
- ASSERT_EQ(kTake[i], base::PathExists(file_path_)) <<
- "FilePath: " << file_path_.value();
+ ASSERT_EQ(kTake[i], base::PathExists(file_path_))
+ << "FilePath: " << file_path_.value();
}
}
@@ -1487,8 +1479,8 @@ TEST_F(URLFetcherFileTest, SmallGetToTempFile) {
base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit().
- ASSERT_FALSE(base::PathExists(file_path_))
- << file_path_.value() << " not removed.";
+ ASSERT_FALSE(base::PathExists(file_path_)) << file_path_.value()
+ << " not removed.";
}
TEST_F(URLFetcherFileTest, LargeGetToTempFile) {
@@ -1501,8 +1493,8 @@ TEST_F(URLFetcherFileTest, LargeGetToTempFile) {
// URLFetcher::Core's IOBuffer.
static const char kFileToFetch[] = "animate1.gif";
expected_file_ = test_server.GetDocumentRoot().AppendASCII(kFileToFetch);
- CreateFetcherForTempFile(test_server.GetURL(
- std::string(kTestServerFilePrefix) + kFileToFetch));
+ CreateFetcherForTempFile(
+ test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch));
base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit().
}
@@ -1522,14 +1514,14 @@ TEST_F(URLFetcherFileTest, SavedOutputTempFileOwnerhisp) {
// Get a small file.
static const char kFileToFetch[] = "simple.html";
expected_file_ = test_server.GetDocumentRoot().AppendASCII(kFileToFetch);
- CreateFetcherForTempFile(test_server.GetURL(
- std::string(kTestServerFilePrefix) + kFileToFetch));
+ CreateFetcherForTempFile(
+ test_server.GetURL(std::string(kTestServerFilePrefix) + kFileToFetch));
base::MessageLoop::current()->Run(); // OnURLFetchComplete() will Quit().
base::MessageLoop::current()->RunUntilIdle();
- ASSERT_EQ(kTake[i], base::PathExists(file_path_)) <<
- "FilePath: " << file_path_.value();
+ ASSERT_EQ(kTake[i], base::PathExists(file_path_))
+ << "FilePath: " << file_path_.value();
}
}

Powered by Google App Engine
This is Rietveld 408576698