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.
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"
17 class DevicesAppTest
: public mojo::test::ApplicationTestBase
{
20 ~DevicesAppTest() override
{}
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_
);
29 usb::DeviceManager
* usb_device_manager() { return usb_device_manager_
.get(); }
32 usb::DeviceManagerPtr usb_device_manager_
;
34 DISALLOW_COPY_AND_ASSIGN(DevicesAppTest
);
37 void OnGetDevices(const base::Closure
& continuation
,
38 mojo::Array
<usb::DeviceInfoPtr
> devices
) {
44 // Simple test to verify that we can connect to the USB DeviceManager and get
46 TEST_F(DevicesAppTest
, GetUSBDevices
) {
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()));