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

Unified Diff: net/url_request/url_request_http_job_unittest.cc

Issue 2904643002: Remove some naked |new| statements in favor of MakeUnique. (Closed)
Patch Set: Re: #11. Created 3 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
« no previous file with comments | « net/http/http_stream_factory_impl_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_http_job_unittest.cc
diff --git a/net/url_request/url_request_http_job_unittest.cc b/net/url_request/url_request_http_job_unittest.cc
index a0f5fb976b8f30cbda609606ecab40a2d81847e3..564ce257b2c12f19f533b4e18ed186edafd5232f 100644
--- a/net/url_request/url_request_http_job_unittest.cc
+++ b/net/url_request/url_request_http_job_unittest.cc
@@ -8,6 +8,8 @@
#include <cstddef>
#include <memory>
+#include <utility>
+#include <vector>
#include "base/compiler_specific.h"
#include "base/macros.h"
@@ -134,8 +136,7 @@ TEST_F(URLRequestHttpJobSetUpSourceTest, SetUpSourceFails) {
std::unique_ptr<URLRequest> request =
context_.CreateRequest(GURL("http://www.example.com"), DEFAULT_PRIORITY,
&delegate_, TRAFFIC_ANNOTATION_FOR_TESTS);
- std::unique_ptr<TestURLRequestHttpJob> job(
- new TestURLRequestHttpJob(request.get()));
+ auto job = base::MakeUnique<TestURLRequestHttpJob>(request.get());
job->set_use_null_source_stream(true);
test_job_interceptor_->set_main_intercept_job(std::move(job));
request->Start();
@@ -160,8 +161,7 @@ TEST_F(URLRequestHttpJobSetUpSourceTest, UnknownEncoding) {
std::unique_ptr<URLRequest> request =
context_.CreateRequest(GURL("http://www.example.com"), DEFAULT_PRIORITY,
&delegate_, TRAFFIC_ANNOTATION_FOR_TESTS);
- std::unique_ptr<TestURLRequestHttpJob> job(
- new TestURLRequestHttpJob(request.get()));
+ auto job = base::MakeUnique<TestURLRequestHttpJob>(request.get());
test_job_interceptor_->set_main_intercept_job(std::move(job));
request->Start();
@@ -188,8 +188,7 @@ TEST_F(URLRequestHttpJobSetUpSourceTest, SdchNotAdvertisedGotSdchResponse) {
std::unique_ptr<URLRequest> request =
context_.CreateRequest(GURL("http://www.example.com"), DEFAULT_PRIORITY,
&delegate_, TRAFFIC_ANNOTATION_FOR_TESTS);
- std::unique_ptr<TestURLRequestHttpJob> job(
- new TestURLRequestHttpJob(request.get()));
+ auto job = base::MakeUnique<TestURLRequestHttpJob>(request.get());
test_job_interceptor_->set_main_intercept_job(std::move(job));
request->Start();
@@ -243,7 +242,7 @@ class URLRequestHttpJobTest : public ::testing::Test {
}
void EnableSdch() {
- context_.SetSdchManager(std::unique_ptr<SdchManager>(new SdchManager));
+ context_.SetSdchManager(base::MakeUnique<SdchManager>());
}
MockNetworkLayer network_layer_;
@@ -701,8 +700,7 @@ TEST_F(URLRequestHttpJobTest, TestCancelWhileReadingCookies) {
// Make sure that SetPriority actually sets the URLRequestHttpJob's
// priority, before start. Other tests handle the after start case.
TEST_F(URLRequestHttpJobTest, SetPriorityBasic) {
- std::unique_ptr<TestURLRequestHttpJob> job(
- new TestURLRequestHttpJob(req_.get()));
+ auto job = base::MakeUnique<TestURLRequestHttpJob>(req_.get());
EXPECT_EQ(DEFAULT_PRIORITY, job->priority());
job->SetPriority(LOWEST);
@@ -716,7 +714,7 @@ TEST_F(URLRequestHttpJobTest, SetPriorityBasic) {
// transaction on start.
TEST_F(URLRequestHttpJobTest, SetTransactionPriorityOnStart) {
test_job_interceptor_->set_main_intercept_job(
- base::WrapUnique(new TestURLRequestHttpJob(req_.get())));
+ base::MakeUnique<TestURLRequestHttpJob>(req_.get()));
req_->SetPriority(LOW);
EXPECT_FALSE(network_layer_.last_transaction());
@@ -731,7 +729,7 @@ TEST_F(URLRequestHttpJobTest, SetTransactionPriorityOnStart) {
// its transaction.
TEST_F(URLRequestHttpJobTest, SetTransactionPriority) {
test_job_interceptor_->set_main_intercept_job(
- base::WrapUnique(new TestURLRequestHttpJob(req_.get())));
+ base::MakeUnique<TestURLRequestHttpJob>(req_.get()));
req_->SetPriority(LOW);
req_->Start();
ASSERT_TRUE(network_layer_.last_transaction());
@@ -746,7 +744,7 @@ TEST_F(URLRequestHttpJobTest, SdchAdvertisementGet) {
EnableSdch();
req_->set_method("GET"); // Redundant with default.
test_job_interceptor_->set_main_intercept_job(
- base::WrapUnique(new TestURLRequestHttpJob(req_.get())));
+ base::MakeUnique<TestURLRequestHttpJob>(req_.get()));
req_->Start();
EXPECT_TRUE(TransactionAcceptsSdchEncoding());
}
@@ -756,7 +754,7 @@ TEST_F(URLRequestHttpJobTest, SdchAdvertisementPost) {
EnableSdch();
req_->set_method("POST");
test_job_interceptor_->set_main_intercept_job(
- base::WrapUnique(new TestURLRequestHttpJob(req_.get())));
+ base::MakeUnique<TestURLRequestHttpJob>(req_.get()));
req_->Start();
EXPECT_FALSE(TransactionAcceptsSdchEncoding());
}
@@ -837,8 +835,7 @@ class MockSdchObserver : public SdchObserver {
class URLRequestHttpJobWithSdchSupportTest : public ::testing::Test {
protected:
URLRequestHttpJobWithSdchSupportTest() : context_(true) {
- std::unique_ptr<HttpNetworkSession::Params> params(
- new HttpNetworkSession::Params);
+ auto params = base::MakeUnique<HttpNetworkSession::Params>();
context_.set_http_network_session_params(std::move(params));
context_.set_client_socket_factory(&socket_factory_);
context_.Init();
@@ -940,8 +937,7 @@ class URLRequestHttpJobWithBrotliSupportTest : public ::testing::Test {
protected:
URLRequestHttpJobWithBrotliSupportTest()
: context_(new TestURLRequestContext(true)) {
- std::unique_ptr<HttpNetworkSession::Params> params(
- new HttpNetworkSession::Params);
+ auto params = base::MakeUnique<HttpNetworkSession::Params>();
context_->set_enable_brotli(true);
context_->set_http_network_session_params(std::move(params));
context_->set_client_socket_factory(&socket_factory_);
@@ -1197,8 +1193,8 @@ TEST_F(URLRequestHttpJobWebSocketTest, RejectedWithoutCreateHelper) {
}
TEST_F(URLRequestHttpJobWebSocketTest, CreateHelperPassedThrough) {
- std::unique_ptr<MockCreateHelper> create_helper(
- new ::testing::StrictMock<MockCreateHelper>());
+ std::unique_ptr<MockCreateHelper> create_helper =
+ base::MakeUnique<::testing::StrictMock<MockCreateHelper>>();
FakeWebSocketHandshakeStream* fake_handshake_stream(
new FakeWebSocketHandshakeStream);
// Ownership of fake_handshake_stream is transferred when CreateBasicStream()
« no previous file with comments | « net/http/http_stream_factory_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698