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