OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/browser/chromeos/device/input_service_test_helper.h" | 5 #include "chrome/browser/chromeos/device/input_service_test_helper.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/memory/ptr_util.h" |
8 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
9 #include "chrome/browser/chromeos/device/input_service_proxy.h" | 10 #include "chrome/browser/chromeos/device/input_service_proxy.h" |
10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
11 #include "device/hid/fake_input_service_linux.h" | 12 #include "device/hid/fake_input_service_linux.h" |
12 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
13 | 14 |
14 using content::BrowserThread; | 15 using content::BrowserThread; |
15 using device::InputServiceLinux; | 16 using device::InputServiceLinux; |
16 using device::FakeInputServiceLinux; | 17 using device::FakeInputServiceLinux; |
17 | 18 |
18 namespace chromeos { | 19 namespace chromeos { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
22 void InitInputServiceOnFileThread() { | 23 void InitInputServiceOnFileThread() { |
23 InputServiceLinux::SetForTesting(new FakeInputServiceLinux()); | 24 InputServiceLinux::SetForTesting(base::MakeUnique<FakeInputServiceLinux>()); |
24 } | 25 } |
25 | 26 |
26 void AddDeviceOnFileThread(const InputDeviceInfo& device) { | 27 void AddDeviceOnFileThread(const InputDeviceInfo& device) { |
27 FakeInputServiceLinux* service = | 28 FakeInputServiceLinux* service = |
28 static_cast<FakeInputServiceLinux*>(InputServiceLinux::GetInstance()); | 29 static_cast<FakeInputServiceLinux*>(InputServiceLinux::GetInstance()); |
29 service->AddDeviceForTesting(device); | 30 service->AddDeviceForTesting(device); |
30 } | 31 } |
31 | 32 |
32 void RemoveDeviceOnFileThread(const std::string& id) { | 33 void RemoveDeviceOnFileThread(const std::string& id) { |
33 FakeInputServiceLinux* service = | 34 FakeInputServiceLinux* service = |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 } | 148 } |
148 | 149 |
149 void InputServiceTestHelper::RemoveDeviceFromService(bool is_mouse) { | 150 void InputServiceTestHelper::RemoveDeviceFromService(bool is_mouse) { |
150 std::string id = is_mouse ? kMouseId : kKeyboardId; | 151 std::string id = is_mouse ? kMouseId : kKeyboardId; |
151 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 152 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
152 base::Bind(&RemoveDeviceOnFileThread, id)); | 153 base::Bind(&RemoveDeviceOnFileThread, id)); |
153 observer_->WaitForDeviceRemoval(id); | 154 observer_->WaitForDeviceRemoval(id); |
154 } | 155 } |
155 | 156 |
156 } // namespace chromeos | 157 } // namespace chromeos |
OLD | NEW |