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

Side by Side Diff: chrome/browser/extensions/api/gcd_private/privet_v3_session_unittest.cc

Issue 1871713002: Convert //chrome/browser/extensions from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase and fix header Created 4 years, 8 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/gcd_private/privet_v3_session.h" 5 #include "chrome/browser/extensions/api/gcd_private/privet_v3_session.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/thread_task_runner_handle.h" 9 #include "base/thread_task_runner_handle.h"
10 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" 10 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 scoped_refptr<PrivetV3ContextGetter> context_getter = 71 scoped_refptr<PrivetV3ContextGetter> context_getter =
72 new PrivetV3ContextGetter(base::ThreadTaskRunnerHandle::Get()); 72 new PrivetV3ContextGetter(base::ThreadTaskRunnerHandle::Get());
73 73
74 session_.reset( 74 session_.reset(
75 new PrivetV3Session(context_getter, net::HostPortPair("host", 180))); 75 new PrivetV3Session(context_getter, net::HostPortPair("host", 180)));
76 76
77 session_->on_post_data_ = 77 session_->on_post_data_ =
78 base::Bind(&PrivetV3SessionTest::OnPostData, base::Unretained(this)); 78 base::Bind(&PrivetV3SessionTest::OnPostData, base::Unretained(this));
79 } 79 }
80 80
81 scoped_ptr<net::FakeURLFetcher> CreateFakeURLFetcher( 81 std::unique_ptr<net::FakeURLFetcher> CreateFakeURLFetcher(
82 const GURL& url, 82 const GURL& url,
83 net::URLFetcherDelegate* fetcher_delegate, 83 net::URLFetcherDelegate* fetcher_delegate,
84 const std::string& response_data, 84 const std::string& response_data,
85 net::HttpStatusCode response_code, 85 net::HttpStatusCode response_code,
86 net::URLRequestStatus::Status status) { 86 net::URLRequestStatus::Status status) {
87 scoped_ptr<net::FakeURLFetcher> fetcher(new net::FakeURLFetcher( 87 std::unique_ptr<net::FakeURLFetcher> fetcher(new net::FakeURLFetcher(
88 url, fetcher_delegate, response_data, response_code, status)); 88 url, fetcher_delegate, response_data, response_code, status));
89 scoped_refptr<net::HttpResponseHeaders> headers = 89 scoped_refptr<net::HttpResponseHeaders> headers =
90 new net::HttpResponseHeaders(""); 90 new net::HttpResponseHeaders("");
91 headers->AddHeader("Content-Type: application/json"); 91 headers->AddHeader("Content-Type: application/json");
92 fetcher->set_response_headers(headers); 92 fetcher->set_response_headers(headers);
93 return fetcher; 93 return fetcher;
94 } 94 }
95 95
96 content::TestBrowserThreadBundle thread_bundle_; 96 content::TestBrowserThreadBundle thread_bundle_;
97 net::FakeURLFetcherFactory fetcher_factory_; 97 net::FakeURLFetcherFactory fetcher_factory_;
98 base::DictionaryValue info_; 98 base::DictionaryValue info_;
99 scoped_ptr<PrivetV3Session> session_; 99 std::unique_ptr<PrivetV3Session> session_;
100 }; 100 };
101 101
102 TEST_F(PrivetV3SessionTest, InitError) { 102 TEST_F(PrivetV3SessionTest, InitError) {
103 EXPECT_CALL(*this, OnInitializedMock(Result::STATUS_CONNECTIONERROR, _)) 103 EXPECT_CALL(*this, OnInitializedMock(Result::STATUS_CONNECTIONERROR, _))
104 .Times(1); 104 .Times(1);
105 fetcher_factory_.SetFakeResponse(GURL("http://host:180/privet/info"), "", 105 fetcher_factory_.SetFakeResponse(GURL("http://host:180/privet/info"), "",
106 net::HTTP_OK, net::URLRequestStatus::FAILED); 106 net::HTTP_OK, net::URLRequestStatus::FAILED);
107 session_->Init( 107 session_->Init(
108 base::Bind(&PrivetV3SessionTest::OnInitialized, base::Unretained(this))); 108 base::Bind(&PrivetV3SessionTest::OnInitialized, base::Unretained(this)));
109 base::RunLoop().RunUntilIdle(); 109 base::RunLoop().RunUntilIdle();
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 331
332 base::DictionaryValue input; 332 base::DictionaryValue input;
333 input.SetString("id", id); 333 input.SetString("id", id);
334 session_->SendMessage( 334 session_->SendMessage(
335 "/privet/v3/commands/status", input, 335 "/privet/v3/commands/status", input,
336 base::Bind(&PrivetV3SessionTest::OnMessageSend, base::Unretained(this))); 336 base::Bind(&PrivetV3SessionTest::OnMessageSend, base::Unretained(this)));
337 base::RunLoop().RunUntilIdle(); 337 base::RunLoop().RunUntilIdle();
338 } 338 }
339 339
340 } // namespace extensions 340 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/gcd_private/privet_v3_session.cc ('k') | chrome/browser/extensions/api/gcm/gcm_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698