Fix a typo in the MB mixin for official builds.
[chromium-blink-merge.git] / device / devices_app / devices_apptest.cc
blob4416bda68a5d9881e05a700fd97dd3cb0db9741e
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.
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"
14 namespace device {
15 namespace {
17 class DevicesAppTest : public mojo::test::ApplicationTestBase {
18 public:
19 DevicesAppTest() {}
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(); }
31 private:
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) {
39 continuation.Run();
42 } // namespace
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();
56 } // namespace device