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

Side by Side Diff: extensions/browser/api/cast_channel/cast_transport_unittest.cc

Issue 1902873002: Convert //extensions/browser/api from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 "extensions/browser/api/cast_channel/cast_transport.h" 5 #include "extensions/browser/api/cast_channel/cast_transport.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9
9 #include <queue> 10 #include <queue>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h"
12 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
13 #include "base/run_loop.h" 15 #include "base/run_loop.h"
14 #include "base/test/simple_test_clock.h" 16 #include "base/test/simple_test_clock.h"
15 #include "extensions/browser/api/cast_channel/cast_framer.h" 17 #include "extensions/browser/api/cast_channel/cast_framer.h"
16 #include "extensions/browser/api/cast_channel/cast_socket.h" 18 #include "extensions/browser/api/cast_channel/cast_socket.h"
17 #include "extensions/browser/api/cast_channel/cast_test_util.h" 19 #include "extensions/browser/api/cast_channel/cast_test_util.h"
18 #include "extensions/browser/api/cast_channel/logger.h" 20 #include "extensions/browser/api/cast_channel/logger.h"
19 #include "extensions/browser/api/cast_channel/logger_util.h" 21 #include "extensions/browser/api/cast_channel/logger_util.h"
20 #include "extensions/common/api/cast_channel/cast_channel.pb.h" 22 #include "extensions/common/api/cast_channel/cast_channel.pb.h"
21 #include "net/base/completion_callback.h" 23 #include "net/base/completion_callback.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 virtual int SetSendBufferSize(int32_t size) { 142 virtual int SetSendBufferSize(int32_t size) {
141 NOTREACHED(); 143 NOTREACHED();
142 return 0; 144 return 0;
143 } 145 }
144 }; 146 };
145 147
146 class CastTransportTest : public testing::Test { 148 class CastTransportTest : public testing::Test {
147 public: 149 public:
148 CastTransportTest() 150 CastTransportTest()
149 : logger_( 151 : logger_(
150 new Logger(make_scoped_ptr<base::Clock>(new base::SimpleTestClock), 152 new Logger(base::WrapUnique<base::Clock>(new base::SimpleTestClock),
151 base::Time())) { 153 base::Time())) {
152 delegate_ = new MockCastTransportDelegate; 154 delegate_ = new MockCastTransportDelegate;
153 transport_.reset(new CastTransportImpl(&mock_socket_, kChannelId, 155 transport_.reset(new CastTransportImpl(&mock_socket_, kChannelId,
154 CreateIPEndPointForTest(), 156 CreateIPEndPointForTest(),
155 auth_type_, logger_)); 157 auth_type_, logger_));
156 transport_->SetReadDelegate(make_scoped_ptr(delegate_)); 158 transport_->SetReadDelegate(base::WrapUnique(delegate_));
157 } 159 }
158 ~CastTransportTest() override {} 160 ~CastTransportTest() override {}
159 161
160 protected: 162 protected:
161 // Runs all pending tasks in the message loop. 163 // Runs all pending tasks in the message loop.
162 void RunPendingTasks() { 164 void RunPendingTasks() {
163 base::RunLoop run_loop; 165 base::RunLoop run_loop;
164 run_loop.RunUntilIdle(); 166 run_loop.RunUntilIdle();
165 } 167 }
166 168
167 base::MessageLoop message_loop_; 169 base::MessageLoop message_loop_;
168 MockCastTransportDelegate* delegate_; 170 MockCastTransportDelegate* delegate_;
169 MockSocket mock_socket_; 171 MockSocket mock_socket_;
170 ChannelAuthType auth_type_; 172 ChannelAuthType auth_type_;
171 Logger* logger_; 173 Logger* logger_;
172 scoped_ptr<CastTransport> transport_; 174 std::unique_ptr<CastTransport> transport_;
173 }; 175 };
174 176
175 // ---------------------------------------------------------------------------- 177 // ----------------------------------------------------------------------------
176 // Asynchronous write tests 178 // Asynchronous write tests
177 TEST_F(CastTransportTest, TestFullWriteAsync) { 179 TEST_F(CastTransportTest, TestFullWriteAsync) {
178 CompletionQueue socket_cbs; 180 CompletionQueue socket_cbs;
179 CompleteHandler write_handler; 181 CompleteHandler write_handler;
180 std::string output; 182 std::string output;
181 183
182 CastMessage message = CreateCastMessage(); 184 CastMessage message = CreateCastMessage();
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 MessageFramer::MessageHeader::header_size() - 1)), 679 MessageFramer::MessageHeader::header_size() - 1)),
678 Return(serialized_message.size() - 680 Return(serialized_message.size() -
679 MessageFramer::MessageHeader::header_size()))) 681 MessageFramer::MessageHeader::header_size())))
680 .RetiresOnSaturation(); 682 .RetiresOnSaturation();
681 EXPECT_CALL(*delegate_, OnError(CHANNEL_ERROR_INVALID_MESSAGE)); 683 EXPECT_CALL(*delegate_, OnError(CHANNEL_ERROR_INVALID_MESSAGE));
682 transport_->Start(); 684 transport_->Start();
683 } 685 }
684 } // namespace cast_channel 686 } // namespace cast_channel
685 } // namespace api 687 } // namespace api
686 } // namespace extensions 688 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/cast_channel/cast_transport.cc ('k') | extensions/browser/api/cast_channel/keep_alive_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698