| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 12 #include "chrome/browser/usb/usb_chooser_controller.h" | 12 #include "chrome/browser/usb/usb_chooser_controller.h" |
| 13 #include "chrome/test/base/in_process_browser_test.h" | 13 #include "chrome/test/base/in_process_browser_test.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/public/browser/render_frame_host.h" | 15 #include "content/public/browser/render_frame_host.h" |
| 16 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
| 17 #include "content/public/test/browser_test_utils.h" | 17 #include "content/public/test/browser_test_utils.h" |
| 18 #include "device/base/mock_device_client.h" | 18 #include "device/base/mock_device_client.h" |
| 19 #include "device/usb/mock_usb_device.h" | 19 #include "device/usb/mock_usb_device.h" |
| 20 #include "device/usb/mock_usb_service.h" | 20 #include "device/usb/mock_usb_service.h" |
| 21 #include "device/usb/public/interfaces/chooser_service.mojom.h" | 21 #include "device/usb/public/interfaces/chooser_service.mojom.h" |
| 22 #include "device/usb/webusb_descriptors.h" | 22 #include "device/usb/webusb_descriptors.h" |
| 23 #include "mojo/public/cpp/bindings/strong_binding.h" | 23 #include "mojo/public/cpp/bindings/strong_binding.h" |
| 24 #include "services/service_manager/public/cpp/bind_source_info.h" |
| 24 #include "services/service_manager/public/cpp/binder_registry.h" | 25 #include "services/service_manager/public/cpp/binder_registry.h" |
| 25 | 26 |
| 26 using content::RenderFrameHost; | 27 using content::RenderFrameHost; |
| 27 using device::MockDeviceClient; | 28 using device::MockDeviceClient; |
| 28 using device::MockUsbDevice; | 29 using device::MockUsbDevice; |
| 29 | 30 |
| 30 namespace { | 31 namespace { |
| 31 | 32 |
| 32 class FakeChooserView : public ChooserController::View { | 33 class FakeChooserView : public ChooserController::View { |
| 33 public: | 34 public: |
| (...skipping 20 matching lines...) Expand all Loading... |
| 54 | 55 |
| 55 private: | 56 private: |
| 56 std::unique_ptr<ChooserController> controller_; | 57 std::unique_ptr<ChooserController> controller_; |
| 57 | 58 |
| 58 DISALLOW_COPY_AND_ASSIGN(FakeChooserView); | 59 DISALLOW_COPY_AND_ASSIGN(FakeChooserView); |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 class FakeChooserService : public device::mojom::UsbChooserService { | 62 class FakeChooserService : public device::mojom::UsbChooserService { |
| 62 public: | 63 public: |
| 63 static void Create(RenderFrameHost* render_frame_host, | 64 static void Create(RenderFrameHost* render_frame_host, |
| 65 const service_manager::BindSourceInfo& source_info, |
| 64 device::mojom::UsbChooserServiceRequest request) { | 66 device::mojom::UsbChooserServiceRequest request) { |
| 65 mojo::MakeStrongBinding( | 67 mojo::MakeStrongBinding( |
| 66 base::MakeUnique<FakeChooserService>(render_frame_host), | 68 base::MakeUnique<FakeChooserService>(render_frame_host), |
| 67 std::move(request)); | 69 std::move(request)); |
| 68 } | 70 } |
| 69 | 71 |
| 70 explicit FakeChooserService(RenderFrameHost* render_frame_host) | 72 explicit FakeChooserService(RenderFrameHost* render_frame_host) |
| 71 : render_frame_host_(render_frame_host) {} | 73 : render_frame_host_(render_frame_host) {} |
| 72 | 74 |
| 73 ~FakeChooserService() override {} | 75 ~FakeChooserService() override {} |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 embedded_frame, | 194 embedded_frame, |
| 193 "navigator.usb.getDevices()" | 195 "navigator.usb.getDevices()" |
| 194 " .then(devices => {" | 196 " .then(devices => {" |
| 195 " domAutomationController.send(devices.length.toString());" | 197 " domAutomationController.send(devices.length.toString());" |
| 196 " });", | 198 " });", |
| 197 &result)); | 199 &result)); |
| 198 EXPECT_EQ("1", result); | 200 EXPECT_EQ("1", result); |
| 199 } | 201 } |
| 200 | 202 |
| 201 } // namespace | 203 } // namespace |
| OLD | NEW |