OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <memory> | 5 #include <memory> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "base/test/scoped_feature_list.h" | 10 #include "base/test/scoped_feature_list.h" |
11 #include "base/test/scoped_task_environment.h" | 11 #include "base/test/scoped_task_environment.h" |
12 #include "base/test/test_io_thread.h" | 12 #include "base/test/test_io_thread.h" |
13 #include "device/base/features.h" | 13 #include "device/base/features.h" |
14 #include "device/test/test_device_client.h" | 14 #include "device/test/test_device_client.h" |
15 #include "device/test/usb_test_gadget.h" | 15 #include "device/test/usb_test_gadget.h" |
16 #include "device/usb/usb_device.h" | 16 #include "device/usb/usb_device.h" |
17 #include "device/usb/usb_device_handle.h" | 17 #include "device/usb/usb_device_handle.h" |
18 #include "device/usb/usb_service.h" | 18 #include "device/usb/usb_service.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 namespace device { | 21 namespace device { |
22 | 22 |
23 namespace { | 23 namespace { |
24 | 24 |
25 class UsbServiceTest : public ::testing::Test { | 25 class UsbServiceTest : public ::testing::Test { |
26 public: | 26 public: |
27 UsbServiceTest() | 27 UsbServiceTest() |
28 : scoped_task_environment_( | 28 : scoped_task_environment_( |
29 base::test::ScopedTaskEnvironment::MainThreadType::UI), | 29 base::test::ScopedTaskEnvironment::MainThreadType::UI), |
30 io_thread_(base::TestIOThread::kAutoStart) {} | 30 io_thread_(base::TestIOThread::kAutoStart), |
31 | 31 device_client_(new TestDeviceClient()) {} |
32 void SetUp() override { | |
33 device_client_.reset(new TestDeviceClient(io_thread_.task_runner())); | |
34 } | |
35 | 32 |
36 protected: | 33 protected: |
37 base::test::ScopedTaskEnvironment scoped_task_environment_; | 34 base::test::ScopedTaskEnvironment scoped_task_environment_; |
38 base::TestIOThread io_thread_; | 35 base::TestIOThread io_thread_; |
mcasas
2017/05/16 21:24:24
nit: probably const, and |scoped_task_environment_
| |
39 std::unique_ptr<TestDeviceClient> device_client_; | 36 std::unique_ptr<TestDeviceClient> device_client_; |
40 }; | 37 }; |
41 | 38 |
42 void OnGetDevices(const base::Closure& quit_closure, | 39 void OnGetDevices(const base::Closure& quit_closure, |
43 const std::vector<scoped_refptr<UsbDevice>>& devices) { | 40 const std::vector<scoped_refptr<UsbDevice>>& devices) { |
44 quit_closure.Run(); | 41 quit_closure.Run(); |
45 } | 42 } |
46 | 43 |
47 void OnOpen(scoped_refptr<UsbDeviceHandle>* output, | 44 void OnOpen(scoped_refptr<UsbDeviceHandle>* output, |
48 const base::Closure& quit_closure, | 45 const base::Closure& quit_closure, |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 ASSERT_TRUE(device_handle); | 112 ASSERT_TRUE(device_handle); |
116 | 113 |
117 // Shut down the USB service while the device handle is still open. | 114 // Shut down the USB service while the device handle is still open. |
118 device_client_.reset(); | 115 device_client_.reset(); |
119 EXPECT_FALSE(device_handle->GetDevice()); | 116 EXPECT_FALSE(device_handle->GetDevice()); |
120 } | 117 } |
121 | 118 |
122 } // namespace | 119 } // namespace |
123 | 120 |
124 } // namespace device | 121 } // namespace device |
OLD | NEW |