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

Side by Side Diff: chrome/browser/chromeos/login/bluetooth_host_pairing_browsertest.cc

Issue 2937253003: cros: Replace BrowserThread::FILE in InputServiceProxy (Closed)
Patch Set: Created 3 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
OLDNEW
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 "base/memory/ptr_util.h" 5 #include "base/memory/ptr_util.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" 9 #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
10 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" 10 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 public: 60 public:
61 void OnConnectSuccess() { message_loop_.QuitWhenIdle(); } 61 void OnConnectSuccess() { message_loop_.QuitWhenIdle(); }
62 void OnConnectFailed(device::BluetoothDevice::ConnectErrorCode error) { 62 void OnConnectFailed(device::BluetoothDevice::ConnectErrorCode error) {
63 message_loop_.QuitWhenIdle(); 63 message_loop_.QuitWhenIdle();
64 } 64 }
65 65
66 protected: 66 protected:
67 using InputDeviceInfo = device::InputServiceLinux::InputDeviceInfo; 67 using InputDeviceInfo = device::InputServiceLinux::InputDeviceInfo;
68 68
69 BluetoothHostPairingNoInputTest() { 69 BluetoothHostPairingNoInputTest() {
70 InputServiceProxy::SetThreadIdForTesting(content::BrowserThread::UI); 70 task_runner_factory_ = base::Bind([]() -> scoped_refptr<base::TaskRunner> {
71 return content::BrowserThread::GetTaskRunnerForThread(
72 content::BrowserThread::UI);
73 });
74 InputServiceProxy::SetTaskRunnerFactoryForTesting(&task_runner_factory_);
71 device::InputServiceLinux::SetForTesting( 75 device::InputServiceLinux::SetForTesting(
72 base::MakeUnique<device::FakeInputServiceLinux>()); 76 base::MakeUnique<device::FakeInputServiceLinux>());
73 77
74 // Set up the fake Bluetooth environment. 78 // Set up the fake Bluetooth environment.
75 std::unique_ptr<bluez::BluezDBusManagerSetter> bluez_dbus_setter = 79 std::unique_ptr<bluez::BluezDBusManagerSetter> bluez_dbus_setter =
76 bluez::BluezDBusManager::GetSetterForTesting(); 80 bluez::BluezDBusManager::GetSetterForTesting();
77 bluez_dbus_setter->SetBluetoothAdapterClient( 81 bluez_dbus_setter->SetBluetoothAdapterClient(
78 base::MakeUnique<bluez::FakeBluetoothAdapterClient>()); 82 base::MakeUnique<bluez::FakeBluetoothAdapterClient>());
79 bluez_dbus_setter->SetBluetoothDeviceClient( 83 bluez_dbus_setter->SetBluetoothDeviceClient(
80 base::MakeUnique<bluez::FakeBluetoothDeviceClient>()); 84 base::MakeUnique<bluez::FakeBluetoothDeviceClient>());
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 device::InputServiceLinux::GetInstance()) 159 device::InputServiceLinux::GetInstance())
156 ->AddDeviceForTesting(info); 160 ->AddDeviceForTesting(info);
157 } 161 }
158 162
159 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; 163 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
160 std::unique_ptr<TestDelegate> delegate_; 164 std::unique_ptr<TestDelegate> delegate_;
161 pairing_chromeos::BluetoothHostPairingController* controller_ = nullptr; 165 pairing_chromeos::BluetoothHostPairingController* controller_ = nullptr;
162 166
163 bluez::FakeBluetoothDeviceClient* fake_bluetooth_device_client_ = nullptr; 167 bluez::FakeBluetoothDeviceClient* fake_bluetooth_device_client_ = nullptr;
164 base::MessageLoop message_loop_; 168 base::MessageLoop message_loop_;
169 InputServiceProxy::TaskRunnerFactory task_runner_factory_;
165 170
166 DISALLOW_COPY_AND_ASSIGN(BluetoothHostPairingNoInputTest); 171 DISALLOW_COPY_AND_ASSIGN(BluetoothHostPairingNoInputTest);
167 }; 172 };
168 173
169 // Test that in normal user OOBE login flow for devices lacking input devices, 174 // Test that in normal user OOBE login flow for devices lacking input devices,
170 // if there is no Bluetooth device connected, the Bluetooth adapter should be 175 // if there is no Bluetooth device connected, the Bluetooth adapter should be
171 // disabled when OOBE reaches login screen (which means OOBE has been completed) 176 // disabled when OOBE reaches login screen (which means OOBE has been completed)
172 IN_PROC_BROWSER_TEST_F(BluetoothHostPairingNoInputTest, 177 IN_PROC_BROWSER_TEST_F(BluetoothHostPairingNoInputTest,
173 NoBluetoothDeviceConnected) { 178 NoBluetoothDeviceConnected) {
174 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_HID_DETECTION).Wait(); 179 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_HID_DETECTION).Wait();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 // Test that in normal user OOBE login flow for devices that have input devices, 256 // Test that in normal user OOBE login flow for devices that have input devices,
252 // the Bluetooth is disabled by default. 257 // the Bluetooth is disabled by default.
253 IN_PROC_BROWSER_TEST_F(BluetoothHostPairingWithInputTest, 258 IN_PROC_BROWSER_TEST_F(BluetoothHostPairingWithInputTest,
254 BluetoothDisableByDefault) { 259 BluetoothDisableByDefault) {
255 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_NETWORK).Wait(); 260 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_NETWORK).Wait();
256 EXPECT_FALSE(controller()); 261 EXPECT_FALSE(controller());
257 EXPECT_FALSE(bluetooth_adapter()); 262 EXPECT_FALSE(bluetooth_adapter());
258 } 263 }
259 264
260 } // namespace chromeos 265 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698