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

Side by Side Diff: device/usb/mojo/device_impl_unittest.cc

Issue 2326913003: Privatize StrongBinding lifetime management (Closed)
Patch Set: rebase Created 4 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/usb/mojo/device_impl.cc ('k') | device/usb/mojo/device_manager_impl.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/usb/mojo/device_impl.h" 5 #include "device/usb/mojo/device_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <numeric> 12 #include <numeric>
13 #include <queue> 13 #include <queue>
14 #include <set> 14 #include <set>
15 #include <string> 15 #include <string>
16 #include <utility> 16 #include <utility>
17 #include <vector> 17 #include <vector>
18 18
19 #include "base/bind.h" 19 #include "base/bind.h"
20 #include "base/macros.h" 20 #include "base/macros.h"
21 #include "base/message_loop/message_loop.h" 21 #include "base/message_loop/message_loop.h"
22 #include "base/run_loop.h" 22 #include "base/run_loop.h"
23 #include "base/stl_util.h" 23 #include "base/stl_util.h"
24 #include "device/usb/mock_usb_device.h" 24 #include "device/usb/mock_usb_device.h"
25 #include "device/usb/mock_usb_device_handle.h" 25 #include "device/usb/mock_usb_device_handle.h"
26 #include "device/usb/mojo/mock_permission_provider.h" 26 #include "device/usb/mojo/mock_permission_provider.h"
27 #include "device/usb/mojo/type_converters.h" 27 #include "device/usb/mojo/type_converters.h"
28 #include "mojo/public/cpp/bindings/interface_request.h" 28 #include "mojo/public/cpp/bindings/interface_request.h"
29 #include "mojo/public/cpp/bindings/strong_binding.h"
29 #include "net/base/io_buffer.h" 30 #include "net/base/io_buffer.h"
30 #include "testing/gtest/include/gtest/gtest.h" 31 #include "testing/gtest/include/gtest/gtest.h"
31 32
32 using ::testing::Invoke; 33 using ::testing::Invoke;
33 using ::testing::_; 34 using ::testing::_;
34 35
35 namespace device { 36 namespace device {
36 namespace usb { 37 namespace usb {
37 38
38 namespace { 39 namespace {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 DevicePtr GetMockDeviceProxy(uint16_t vendor_id, 169 DevicePtr GetMockDeviceProxy(uint16_t vendor_id,
169 uint16_t product_id, 170 uint16_t product_id,
170 const std::string& manufacturer, 171 const std::string& manufacturer,
171 const std::string& product, 172 const std::string& product,
172 const std::string& serial) { 173 const std::string& serial) {
173 mock_device_ = 174 mock_device_ =
174 new MockUsbDevice(vendor_id, product_id, manufacturer, product, serial); 175 new MockUsbDevice(vendor_id, product_id, manufacturer, product, serial);
175 mock_handle_ = new MockUsbDeviceHandle(mock_device_.get()); 176 mock_handle_ = new MockUsbDeviceHandle(mock_device_.get());
176 177
177 DevicePtr proxy; 178 DevicePtr proxy;
179
180 // Owns itself.
178 new DeviceImpl( 181 new DeviceImpl(
179 mock_device_, 182 mock_device_,
180 DeviceInfo::From(static_cast<const UsbDevice&>(*mock_device_)), 183 DeviceInfo::From(static_cast<const UsbDevice&>(*mock_device_)),
181 permission_provider_.GetWeakPtr(), mojo::GetProxy(&proxy)); 184 permission_provider_.GetWeakPtr(), mojo::GetProxy(&proxy));
182 185
183 // Set up mock handle calls to respond based on mock device configs 186 // Set up mock handle calls to respond based on mock device configs
184 // established by the test. 187 // established by the test.
185 ON_CALL(mock_device(), Open(_)) 188 ON_CALL(mock_device(), Open(_))
186 .WillByDefault(Invoke(this, &USBDeviceImplTest::OpenMockHandle)); 189 .WillByDefault(Invoke(this, &USBDeviceImplTest::OpenMockHandle));
187 ON_CALL(mock_handle(), Close()) 190 ON_CALL(mock_handle(), Close())
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 base::Bind(&ExpectPacketsInAndThen, fake_inbound_data, 895 base::Bind(&ExpectPacketsInAndThen, fake_inbound_data,
893 expected_transferred_lengths, loop.QuitClosure())); 896 expected_transferred_lengths, loop.QuitClosure()));
894 loop.Run(); 897 loop.Run();
895 } 898 }
896 899
897 EXPECT_CALL(mock_handle(), Close()); 900 EXPECT_CALL(mock_handle(), Close());
898 } 901 }
899 902
900 } // namespace usb 903 } // namespace usb
901 } // namespace device 904 } // namespace device
OLDNEW
« no previous file with comments | « device/usb/mojo/device_impl.cc ('k') | device/usb/mojo/device_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698