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

Side by Side Diff: device/hid/hid_connection_unittest.cc

Issue 507053002: Remove implicit conversions from scoped_refptr to T* in device/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Regenerate Created 6 years, 3 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/bluetooth/bluetooth_socket_thread.cc ('k') | device/serial/data_sink_receiver.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 (c) 2014 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <string> 5 #include <string>
6 #include <vector> 6 #include <vector>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 scoped_ptr<base::MessageLoopForIO> message_loop_; 120 scoped_ptr<base::MessageLoopForIO> message_loop_;
121 scoped_ptr<HidService> service_; 121 scoped_ptr<HidService> service_;
122 scoped_ptr<UsbTestGadget> test_gadget_; 122 scoped_ptr<UsbTestGadget> test_gadget_;
123 HidDeviceId device_id_; 123 HidDeviceId device_id_;
124 }; 124 };
125 125
126 TEST_F(HidConnectionTest, ReadWrite) { 126 TEST_F(HidConnectionTest, ReadWrite) {
127 if (!UsbTestGadget::IsTestEnabled()) return; 127 if (!UsbTestGadget::IsTestEnabled()) return;
128 128
129 scoped_refptr<HidConnection> conn = service_->Connect(device_id_); 129 scoped_refptr<HidConnection> conn = service_->Connect(device_id_);
130 ASSERT_TRUE(conn); 130 ASSERT_TRUE(conn.get());
131 131
132 for (int i = 0; i < 8; ++i) { 132 for (int i = 0; i < 8; ++i) {
133 scoped_refptr<IOBufferWithSize> buffer(new IOBufferWithSize(9)); 133 scoped_refptr<IOBufferWithSize> buffer(new IOBufferWithSize(9));
134 buffer->data()[0] = 0; 134 buffer->data()[0] = 0;
135 for (int j = 1; j < buffer->size(); ++j) { 135 for (int j = 1; j < buffer->size(); ++j) {
136 buffer->data()[j] = i + j - 1; 136 buffer->data()[j] = i + j - 1;
137 } 137 }
138 138
139 TestCompletionCallback write_callback; 139 TestCompletionCallback write_callback;
140 conn->Write(buffer, buffer->size(), write_callback.write_callback()); 140 conn->Write(buffer, buffer->size(), write_callback.write_callback());
141 ASSERT_TRUE(write_callback.WaitForResult()); 141 ASSERT_TRUE(write_callback.WaitForResult());
142 142
143 TestCompletionCallback read_callback; 143 TestCompletionCallback read_callback;
144 conn->Read(read_callback.read_callback()); 144 conn->Read(read_callback.read_callback());
145 ASSERT_TRUE(read_callback.WaitForResult()); 145 ASSERT_TRUE(read_callback.WaitForResult());
146 ASSERT_EQ(9UL, read_callback.size()); 146 ASSERT_EQ(9UL, read_callback.size());
147 ASSERT_EQ(0, read_callback.buffer()->data()[0]); 147 ASSERT_EQ(0, read_callback.buffer()->data()[0]);
148 for (int j = 1; j < buffer->size(); ++j) { 148 for (int j = 1; j < buffer->size(); ++j) {
149 ASSERT_EQ(i + j - 1, read_callback.buffer()->data()[j]); 149 ASSERT_EQ(i + j - 1, read_callback.buffer()->data()[j]);
150 } 150 }
151 } 151 }
152 } 152 }
153 153
154 } // namespace device 154 } // namespace device
OLDNEW
« no previous file with comments | « device/bluetooth/bluetooth_socket_thread.cc ('k') | device/serial/data_sink_receiver.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698