Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(342)

Side by Side Diff: device/devices_app/devices_apptest.cc

Issue 1165223004: Introduce the devices Mojo app (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: move mojo USB sources into devices_app to keep mojo dependencies separated from device/usb Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « device/devices_app/devices_app.gyp ('k') | device/devices_app/main.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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
OLDNEW
« no previous file with comments | « device/devices_app/devices_app.gyp ('k') | device/devices_app/main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698