| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include <utility> | |
| 6 | |
| 7 #include "base/bind.h" | |
| 8 #include "base/callback.h" | |
| 9 #include "base/macros.h" | |
| 10 #include "base/run_loop.h" | |
| 11 #include "device/devices_app/devices_app.h" | |
| 12 #include "device/devices_app/usb/public/interfaces/device_manager.mojom.h" | |
| 13 #include "mojo/shell/public/cpp/application_test_base.h" | |
| 14 | |
| 15 namespace device { | |
| 16 namespace { | |
| 17 | |
| 18 class DevicesAppTest : public mojo::test::ApplicationTestBase { | |
| 19 public: | |
| 20 DevicesAppTest() {} | |
| 21 ~DevicesAppTest() override {} | |
| 22 | |
| 23 void SetUp() override { | |
| 24 ApplicationTestBase::SetUp(); | |
| 25 shell()->ConnectToInterface("mojo:devices", &usb_device_manager_); | |
| 26 } | |
| 27 | |
| 28 usb::DeviceManager* usb_device_manager() { return usb_device_manager_.get(); } | |
| 29 | |
| 30 private: | |
| 31 usb::DeviceManagerPtr usb_device_manager_; | |
| 32 | |
| 33 DISALLOW_COPY_AND_ASSIGN(DevicesAppTest); | |
| 34 }; | |
| 35 | |
| 36 void OnGetDevices(const base::Closure& continuation, | |
| 37 mojo::Array<usb::DeviceInfoPtr> devices) { | |
| 38 continuation.Run(); | |
| 39 } | |
| 40 | |
| 41 } // namespace | |
| 42 | |
| 43 // Simple test to verify that we can connect to the USB DeviceManager and get | |
| 44 // a response. | |
| 45 TEST_F(DevicesAppTest, GetUSBDevices) { | |
| 46 base::RunLoop loop; | |
| 47 usb::EnumerationOptionsPtr options = usb::EnumerationOptions::New(); | |
| 48 options->filters = mojo::Array<usb::DeviceFilterPtr>(1); | |
| 49 options->filters[0] = usb::DeviceFilter::New(); | |
| 50 usb_device_manager()->GetDevices( | |
| 51 std::move(options), base::Bind(&OnGetDevices, loop.QuitClosure())); | |
| 52 loop.Run(); | |
| 53 } | |
| 54 | |
| 55 } // namespace device | |
| OLD | NEW |