| OLD | NEW |
| 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/devices_app/usb/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 <numeric> | 11 #include <numeric> |
| 12 #include <queue> | 12 #include <queue> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <utility> | 15 #include <utility> |
| 16 #include <vector> | 16 #include <vector> |
| 17 | 17 |
| 18 #include "base/bind.h" | 18 #include "base/bind.h" |
| 19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
| 21 #include "base/run_loop.h" | 21 #include "base/run_loop.h" |
| 22 #include "base/stl_util.h" | 22 #include "base/stl_util.h" |
| 23 #include "device/devices_app/usb/fake_permission_provider.h" | |
| 24 #include "device/usb/mock_usb_device.h" | 23 #include "device/usb/mock_usb_device.h" |
| 25 #include "device/usb/mock_usb_device_handle.h" | 24 #include "device/usb/mock_usb_device_handle.h" |
| 25 #include "device/usb/mojo/fake_permission_provider.h" |
| 26 #include "mojo/public/cpp/bindings/interface_request.h" | 26 #include "mojo/public/cpp/bindings/interface_request.h" |
| 27 #include "net/base/io_buffer.h" | 27 #include "net/base/io_buffer.h" |
| 28 #include "testing/gtest/include/gtest/gtest.h" | 28 #include "testing/gtest/include/gtest/gtest.h" |
| 29 | 29 |
| 30 using ::testing::Invoke; | 30 using ::testing::Invoke; |
| 31 using ::testing::_; | 31 using ::testing::_; |
| 32 | 32 |
| 33 namespace device { | 33 namespace device { |
| 34 namespace usb { | 34 namespace usb { |
| 35 | 35 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 330 callback.Run(USB_TRANSFER_COMPLETED, buffer, length); | 330 callback.Run(USB_TRANSFER_COMPLETED, buffer, length); |
| 331 } | 331 } |
| 332 | 332 |
| 333 void OutboundTransfer(scoped_refptr<net::IOBuffer> buffer, | 333 void OutboundTransfer(scoped_refptr<net::IOBuffer> buffer, |
| 334 size_t length, | 334 size_t length, |
| 335 const UsbDeviceHandle::TransferCallback& callback) { | 335 const UsbDeviceHandle::TransferCallback& callback) { |
| 336 ASSERT_GE(mock_outbound_data_.size(), 1u); | 336 ASSERT_GE(mock_outbound_data_.size(), 1u); |
| 337 const std::vector<uint8_t>& bytes = mock_outbound_data_.front(); | 337 const std::vector<uint8_t>& bytes = mock_outbound_data_.front(); |
| 338 ASSERT_EQ(bytes.size(), length); | 338 ASSERT_EQ(bytes.size(), length); |
| 339 for (size_t i = 0; i < length; ++i) { | 339 for (size_t i = 0; i < length; ++i) { |
| 340 EXPECT_EQ(bytes[i], buffer->data()[i]) | 340 EXPECT_EQ(bytes[i], buffer->data()[i]) << "Contents differ at index: " |
| 341 << "Contents differ at index: " << i; | 341 << i; |
| 342 } | 342 } |
| 343 mock_outbound_data_.pop(); | 343 mock_outbound_data_.pop(); |
| 344 callback.Run(USB_TRANSFER_COMPLETED, buffer, length); | 344 callback.Run(USB_TRANSFER_COMPLETED, buffer, length); |
| 345 } | 345 } |
| 346 | 346 |
| 347 void ControlTransfer(UsbEndpointDirection direction, | 347 void ControlTransfer(UsbEndpointDirection direction, |
| 348 UsbDeviceHandle::TransferRequestType request_type, | 348 UsbDeviceHandle::TransferRequestType request_type, |
| 349 UsbDeviceHandle::TransferRecipient recipient, | 349 UsbDeviceHandle::TransferRecipient recipient, |
| 350 uint8_t request, | 350 uint8_t request, |
| 351 uint16_t value, | 351 uint16_t value, |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 886 base::Bind(&ExpectPacketsInAndThen, fake_inbound_data, | 886 base::Bind(&ExpectPacketsInAndThen, fake_inbound_data, |
| 887 expected_transferred_lengths, loop.QuitClosure())); | 887 expected_transferred_lengths, loop.QuitClosure())); |
| 888 loop.Run(); | 888 loop.Run(); |
| 889 } | 889 } |
| 890 | 890 |
| 891 EXPECT_CALL(mock_handle(), Close()); | 891 EXPECT_CALL(mock_handle(), Close()); |
| 892 } | 892 } |
| 893 | 893 |
| 894 } // namespace usb | 894 } // namespace usb |
| 895 } // namespace device | 895 } // namespace device |
| OLD | NEW |