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/usb/webusb_descriptors.h" |
| 6 |
5 #include <stdint.h> | 7 #include <stdint.h> |
6 | 8 |
7 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> |
8 | 11 |
9 #include "base/bind.h" | 12 #include "base/bind.h" |
10 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
11 #include "device/usb/mock_usb_device_handle.h" | 14 #include "device/usb/mock_usb_device_handle.h" |
12 #include "device/usb/webusb_descriptors.h" | |
13 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
14 | 16 |
15 using testing::_; | 17 using testing::_; |
16 | 18 |
17 namespace device { | 19 namespace device { |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 const uint8_t kExampleBosDescriptor[] = { | 23 const uint8_t kExampleBosDescriptor[] = { |
22 // BOS descriptor. | 24 // BOS descriptor. |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 'm', 'p', 'l', 'e', '.', 'c', | 72 'm', 'p', 'l', 'e', '.', 'c', |
71 'o', 'm', ':', '8', '5'}; | 73 'o', 'm', ':', '8', '5'}; |
72 | 74 |
73 ACTION_P2(InvokeCallback, data, length) { | 75 ACTION_P2(InvokeCallback, data, length) { |
74 size_t transferred_length = std::min(length, arg7); | 76 size_t transferred_length = std::min(length, arg7); |
75 memcpy(arg6->data(), data, transferred_length); | 77 memcpy(arg6->data(), data, transferred_length); |
76 arg9.Run(USB_TRANSFER_COMPLETED, arg6, transferred_length); | 78 arg9.Run(USB_TRANSFER_COMPLETED, arg6, transferred_length); |
77 } | 79 } |
78 | 80 |
79 void ExpectAllowedOriginsAndLandingPage( | 81 void ExpectAllowedOriginsAndLandingPage( |
80 scoped_ptr<WebUsbAllowedOrigins> allowed_origins, | 82 std::unique_ptr<WebUsbAllowedOrigins> allowed_origins, |
81 const GURL& landing_page) { | 83 const GURL& landing_page) { |
82 EXPECT_EQ(GURL("https://example.com/index.html"), landing_page); | 84 EXPECT_EQ(GURL("https://example.com/index.html"), landing_page); |
83 ASSERT_TRUE(allowed_origins); | 85 ASSERT_TRUE(allowed_origins); |
84 ASSERT_EQ(2u, allowed_origins->origins.size()); | 86 ASSERT_EQ(2u, allowed_origins->origins.size()); |
85 EXPECT_EQ(GURL("https://example.com"), allowed_origins->origins[0]); | 87 EXPECT_EQ(GURL("https://example.com"), allowed_origins->origins[0]); |
86 EXPECT_EQ(GURL("https://example.com:81"), allowed_origins->origins[1]); | 88 EXPECT_EQ(GURL("https://example.com:81"), allowed_origins->origins[1]); |
87 ASSERT_EQ(1u, allowed_origins->configurations.size()); | 89 ASSERT_EQ(1u, allowed_origins->configurations.size()); |
88 EXPECT_EQ(GURL("https://example.com:82"), | 90 EXPECT_EQ(GURL("https://example.com:82"), |
89 allowed_origins->configurations[0].origins[0]); | 91 allowed_origins->configurations[0].origins[0]); |
90 EXPECT_EQ(GURL("https://example.com:83"), | 92 EXPECT_EQ(GURL("https://example.com:83"), |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 .WillOnce(InvokeCallback(kExampleUrlDescriptor6, | 457 .WillOnce(InvokeCallback(kExampleUrlDescriptor6, |
456 sizeof(kExampleUrlDescriptor6))); | 458 sizeof(kExampleUrlDescriptor6))); |
457 | 459 |
458 ReadWebUsbDescriptors(device_handle, | 460 ReadWebUsbDescriptors(device_handle, |
459 base::Bind(&ExpectAllowedOriginsAndLandingPage)); | 461 base::Bind(&ExpectAllowedOriginsAndLandingPage)); |
460 } | 462 } |
461 | 463 |
462 } // namespace | 464 } // namespace |
463 | 465 |
464 } // namespace device | 466 } // namespace device |
OLD | NEW |