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

Side by Side Diff: device/serial/data_source_unittest.cc

Issue 1544323002: Convert Pass()→std::move() in //device (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
« no previous file with comments | « device/serial/data_source_sender.cc ('k') | device/serial/serial_connection.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stdint.h> 5 #include <stdint.h>
6 #include <utility>
6 7
7 #include "base/bind.h" 8 #include "base/bind.h"
8 #include "base/macros.h" 9 #include "base/macros.h"
9 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h" 11 #include "base/run_loop.h"
11 #include "base/strings/string_piece.h" 12 #include "base/strings/string_piece.h"
12 #include "device/serial/buffer.h" 13 #include "device/serial/buffer.h"
13 #include "device/serial/data_receiver.h" 14 #include "device/serial/data_receiver.h"
14 #include "device/serial/data_source_sender.h" 15 #include "device/serial/data_source_sender.h"
15 #include "device/serial/data_stream.mojom.h" 16 #include "device/serial/data_stream.mojom.h"
(...skipping 17 matching lines...) Expand all
33 34
34 void SetUp() override { 35 void SetUp() override {
35 message_loop_.reset(new base::MessageLoop); 36 message_loop_.reset(new base::MessageLoop);
36 mojo::InterfacePtr<serial::DataSource> source_sender_handle; 37 mojo::InterfacePtr<serial::DataSource> source_sender_handle;
37 mojo::InterfacePtr<serial::DataSourceClient> source_sender_client_handle; 38 mojo::InterfacePtr<serial::DataSourceClient> source_sender_client_handle;
38 mojo::InterfaceRequest<serial::DataSourceClient> 39 mojo::InterfaceRequest<serial::DataSourceClient>
39 source_sender_client_request = 40 source_sender_client_request =
40 mojo::GetProxy(&source_sender_client_handle); 41 mojo::GetProxy(&source_sender_client_handle);
41 source_sender_ = new DataSourceSender( 42 source_sender_ = new DataSourceSender(
42 mojo::GetProxy(&source_sender_handle), 43 mojo::GetProxy(&source_sender_handle),
43 source_sender_client_handle.Pass(), 44 std::move(source_sender_client_handle),
44 base::Bind(&DataSourceTest::CanWriteData, base::Unretained(this)), 45 base::Bind(&DataSourceTest::CanWriteData, base::Unretained(this)),
45 base::Bind(&DataSourceTest::OnError, base::Unretained(this))); 46 base::Bind(&DataSourceTest::OnError, base::Unretained(this)));
46 receiver_ = 47 receiver_ = new DataReceiver(std::move(source_sender_handle),
47 new DataReceiver(source_sender_handle.Pass(), 48 std::move(source_sender_client_request), 100,
48 source_sender_client_request.Pass(), 100, kFatalError); 49 kFatalError);
49 } 50 }
50 51
51 void TearDown() override { 52 void TearDown() override {
52 write_buffer_.reset(); 53 write_buffer_.reset();
53 buffer_.reset(); 54 buffer_.reset();
54 message_loop_.reset(); 55 message_loop_.reset();
55 } 56 }
56 57
57 void OnError() { 58 void OnError() {
58 seen_connection_error_ = true; 59 seen_connection_error_ = true;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 95
95 void ReceiveAndWait() { 96 void ReceiveAndWait() {
96 ASSERT_TRUE(Receive()); 97 ASSERT_TRUE(Receive());
97 // Run the message loop until OnDataReceived or OnReceiveError is called. 98 // Run the message loop until OnDataReceived or OnReceiveError is called.
98 WaitForEvent(EVENT_RECEIVE_COMPLETE); 99 WaitForEvent(EVENT_RECEIVE_COMPLETE);
99 } 100 }
100 101
101 void OnDataReceived(scoped_ptr<ReadOnlyBuffer> buffer) { 102 void OnDataReceived(scoped_ptr<ReadOnlyBuffer> buffer) {
102 ASSERT_TRUE(buffer); 103 ASSERT_TRUE(buffer);
103 error_ = 0; 104 error_ = 0;
104 buffer_ = buffer.Pass(); 105 buffer_ = std::move(buffer);
105 buffer_contents_ = std::string(buffer_->GetData(), buffer_->GetSize()); 106 buffer_contents_ = std::string(buffer_->GetData(), buffer_->GetSize());
106 EventReceived(EVENT_RECEIVE_COMPLETE); 107 EventReceived(EVENT_RECEIVE_COMPLETE);
107 } 108 }
108 109
109 void OnReceiveError(int32_t error) { 110 void OnReceiveError(int32_t error) {
110 buffer_contents_.clear(); 111 buffer_contents_.clear();
111 error_ = error; 112 error_ = error;
112 EventReceived(EVENT_RECEIVE_COMPLETE); 113 EventReceived(EVENT_RECEIVE_COMPLETE);
113 } 114 }
114 115
115 void CanWriteData(scoped_ptr<WritableBuffer> buffer) { 116 void CanWriteData(scoped_ptr<WritableBuffer> buffer) {
116 write_buffer_ = buffer.Pass(); 117 write_buffer_ = std::move(buffer);
117 EventReceived(EVENT_WRITE_BUFFER_READY); 118 EventReceived(EVENT_WRITE_BUFFER_READY);
118 } 119 }
119 120
120 protected: 121 protected:
121 static const int32_t kFatalError; 122 static const int32_t kFatalError;
122 scoped_ptr<base::MessageLoop> message_loop_; 123 scoped_ptr<base::MessageLoop> message_loop_;
123 base::Closure stop_run_loop_; 124 base::Closure stop_run_loop_;
124 125
125 scoped_refptr<DataSourceSender> source_sender_; 126 scoped_refptr<DataSourceSender> source_sender_;
126 scoped_refptr<DataReceiver> receiver_; 127 scoped_refptr<DataReceiver> receiver_;
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 // Test that the receiver shutting down is correctly reported to the source. 253 // Test that the receiver shutting down is correctly reported to the source.
253 TEST_F(DataSourceTest, ReceiverShutdown) { 254 TEST_F(DataSourceTest, ReceiverShutdown) {
254 Receive(); 255 Receive();
255 receiver_ = NULL; 256 receiver_ = NULL;
256 EXPECT_EQ(kFatalError, error_); 257 EXPECT_EQ(kFatalError, error_);
257 WaitForEvent(EVENT_ERROR); 258 WaitForEvent(EVENT_ERROR);
258 EXPECT_TRUE(seen_connection_error_); 259 EXPECT_TRUE(seen_connection_error_);
259 } 260 }
260 261
261 } // namespace device 262 } // namespace device
OLDNEW
« no previous file with comments | « device/serial/data_source_sender.cc ('k') | device/serial/serial_connection.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698