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

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

Issue 1874313002: Convert device 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
« no previous file with comments | « device/hid/hid_connection_mac.h ('k') | device/hid/hid_service.h » ('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 "device/hid/hid_connection.h"
6
5 #include <stddef.h> 7 #include <stddef.h>
6 8
9 #include <memory>
7 #include <string> 10 #include <string>
8 #include <vector> 11 #include <vector>
9 12
10 #include "base/bind.h" 13 #include "base/bind.h"
11 #include "base/callback.h" 14 #include "base/callback.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/run_loop.h" 15 #include "base/run_loop.h"
14 #include "base/scoped_observer.h" 16 #include "base/scoped_observer.h"
15 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
16 #include "base/test/test_io_thread.h" 18 #include "base/test/test_io_thread.h"
17 #include "device/hid/hid_connection.h"
18 #include "device/hid/hid_service.h" 19 #include "device/hid/hid_service.h"
19 #include "device/test/test_device_client.h" 20 #include "device/test/test_device_client.h"
20 #include "device/test/usb_test_gadget.h" 21 #include "device/test/usb_test_gadget.h"
21 #include "device/usb/usb_device.h" 22 #include "device/usb/usb_device.h"
22 #include "net/base/io_buffer.h" 23 #include "net/base/io_buffer.h"
23 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
24 25
25 namespace device { 26 namespace device {
26 27
27 namespace { 28 namespace {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 test_gadget_ = UsbTestGadget::Claim(io_thread_->task_runner()); 162 test_gadget_ = UsbTestGadget::Claim(io_thread_->task_runner());
162 ASSERT_TRUE(test_gadget_); 163 ASSERT_TRUE(test_gadget_);
163 ASSERT_TRUE(test_gadget_->SetType(UsbTestGadget::HID_ECHO)); 164 ASSERT_TRUE(test_gadget_->SetType(UsbTestGadget::HID_ECHO));
164 165
165 DeviceCatcher device_catcher(service_, 166 DeviceCatcher device_catcher(service_,
166 test_gadget_->GetDevice()->serial_number()); 167 test_gadget_->GetDevice()->serial_number());
167 device_id_ = device_catcher.WaitForDevice(); 168 device_id_ = device_catcher.WaitForDevice();
168 ASSERT_NE(device_id_, kInvalidHidDeviceId); 169 ASSERT_NE(device_id_, kInvalidHidDeviceId);
169 } 170 }
170 171
171 scoped_ptr<base::MessageLoopForUI> message_loop_; 172 std::unique_ptr<base::MessageLoopForUI> message_loop_;
172 scoped_ptr<base::TestIOThread> io_thread_; 173 std::unique_ptr<base::TestIOThread> io_thread_;
173 scoped_ptr<TestDeviceClient> device_client_; 174 std::unique_ptr<TestDeviceClient> device_client_;
174 HidService* service_; 175 HidService* service_;
175 scoped_ptr<UsbTestGadget> test_gadget_; 176 std::unique_ptr<UsbTestGadget> test_gadget_;
176 HidDeviceId device_id_; 177 HidDeviceId device_id_;
177 }; 178 };
178 179
179 TEST_F(HidConnectionTest, ReadWrite) { 180 TEST_F(HidConnectionTest, ReadWrite) {
180 if (!UsbTestGadget::IsTestEnabled()) return; 181 if (!UsbTestGadget::IsTestEnabled()) return;
181 182
182 TestConnectCallback connect_callback; 183 TestConnectCallback connect_callback;
183 service_->Connect(device_id_, connect_callback.callback()); 184 service_->Connect(device_id_, connect_callback.callback());
184 scoped_refptr<HidConnection> conn = connect_callback.WaitForConnection(); 185 scoped_refptr<HidConnection> conn = connect_callback.WaitForConnection();
185 ASSERT_TRUE(conn.get()); 186 ASSERT_TRUE(conn.get());
(...skipping 17 matching lines...) Expand all
203 ASSERT_EQ(0, read_callback.buffer()->data()[0]); 204 ASSERT_EQ(0, read_callback.buffer()->data()[0]);
204 for (unsigned char j = 1; j < kBufferSize; ++j) { 205 for (unsigned char j = 1; j < kBufferSize; ++j) {
205 ASSERT_EQ(i + j - 1, read_callback.buffer()->data()[j]); 206 ASSERT_EQ(i + j - 1, read_callback.buffer()->data()[j]);
206 } 207 }
207 } 208 }
208 209
209 conn->Close(); 210 conn->Close();
210 } 211 }
211 212
212 } // namespace device 213 } // namespace device
OLDNEW
« no previous file with comments | « device/hid/hid_connection_mac.h ('k') | device/hid/hid_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698