| 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/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 } // namespace | 45 } // namespace |
| 46 | 46 |
| 47 namespace chromeos { | 47 namespace chromeos { |
| 48 | 48 |
| 49 class HidDetectionTest : public OobeBaseTest { | 49 class HidDetectionTest : public OobeBaseTest { |
| 50 public: | 50 public: |
| 51 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo; | 51 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo; |
| 52 | 52 |
| 53 HidDetectionTest() : weak_ptr_factory_(this) { | 53 HidDetectionTest() : weak_ptr_factory_(this) { |
| 54 InputServiceProxy::SetThreadIdForTesting(content::BrowserThread::UI); | 54 task_runner_factory_ = base::Bind([]() -> scoped_refptr<base::TaskRunner> { |
| 55 return content::BrowserThread::GetTaskRunnerForThread( |
| 56 content::BrowserThread::UI); |
| 57 }); |
| 58 InputServiceProxy::SetTaskRunnerFactoryForTesting(&task_runner_factory_); |
| 55 HidDetectionTest::InitInputService(); | 59 HidDetectionTest::InitInputService(); |
| 56 } | 60 } |
| 57 | 61 |
| 58 ~HidDetectionTest() override {} | 62 ~HidDetectionTest() override {} |
| 59 | 63 |
| 60 void InitInputService() { | 64 void InitInputService() { |
| 61 InputServiceLinux::SetForTesting( | 65 InputServiceLinux::SetForTesting( |
| 62 base::MakeUnique<device::FakeInputServiceLinux>()); | 66 base::MakeUnique<device::FakeInputServiceLinux>()); |
| 63 } | 67 } |
| 64 | 68 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 93 | 97 |
| 94 private: | 98 private: |
| 95 void AddDeviceForTesting(const InputDeviceInfo& info) { | 99 void AddDeviceForTesting(const InputDeviceInfo& info) { |
| 96 static_cast<device::FakeInputServiceLinux*>( | 100 static_cast<device::FakeInputServiceLinux*>( |
| 97 device::InputServiceLinux::GetInstance()) | 101 device::InputServiceLinux::GetInstance()) |
| 98 ->AddDeviceForTesting(info); | 102 ->AddDeviceForTesting(info); |
| 99 } | 103 } |
| 100 | 104 |
| 101 scoped_refptr< | 105 scoped_refptr< |
| 102 testing::NiceMock<device::MockBluetoothAdapter> > mock_adapter_; | 106 testing::NiceMock<device::MockBluetoothAdapter> > mock_adapter_; |
| 103 | 107 InputServiceProxy::TaskRunnerFactory task_runner_factory_; |
| 104 base::WeakPtrFactory<HidDetectionTest> weak_ptr_factory_; | 108 base::WeakPtrFactory<HidDetectionTest> weak_ptr_factory_; |
| 105 | 109 |
| 106 DISALLOW_COPY_AND_ASSIGN(HidDetectionTest); | 110 DISALLOW_COPY_AND_ASSIGN(HidDetectionTest); |
| 107 }; | 111 }; |
| 108 | 112 |
| 109 class HidDetectionSkipTest : public HidDetectionTest { | 113 class HidDetectionSkipTest : public HidDetectionTest { |
| 110 public: | 114 public: |
| 111 HidDetectionSkipTest() { | 115 HidDetectionSkipTest() { |
| 112 AddUsbMouse("mouse"); | 116 AddUsbMouse("mouse"); |
| 113 AddUsbKeyboard("keyboard"); | 117 AddUsbKeyboard("keyboard"); |
| 114 } | 118 } |
| 115 | 119 |
| 116 void SetUpOnMainThread() override { | 120 void SetUpOnMainThread() override { |
| 117 HidDetectionTest::SetUpOnMainThread(); | 121 HidDetectionTest::SetUpOnMainThread(); |
| 118 } | 122 } |
| 119 }; | 123 }; |
| 120 | 124 |
| 121 IN_PROC_BROWSER_TEST_F(HidDetectionTest, NoDevicesConnected) { | 125 IN_PROC_BROWSER_TEST_F(HidDetectionTest, NoDevicesConnected) { |
| 122 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_HID_DETECTION).Wait(); | 126 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_HID_DETECTION).Wait(); |
| 123 } | 127 } |
| 124 | 128 |
| 125 IN_PROC_BROWSER_TEST_F(HidDetectionSkipTest, BothDevicesPreConnected) { | 129 IN_PROC_BROWSER_TEST_F(HidDetectionSkipTest, BothDevicesPreConnected) { |
| 126 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_NETWORK).Wait(); | 130 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_NETWORK).Wait(); |
| 127 } | 131 } |
| 128 | 132 |
| 129 } // namespace chromeos | 133 } // namespace chromeos |
| OLD | NEW |