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

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

Issue 2482463002: Remove DeviceMonitorLinux::WillDestroyCurrentMessageLoop(). (Closed)
Patch Set: CR achuithb #24 Created 4 years, 1 month 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/ref_counted.h" 6 #include "base/memory/ref_counted.h"
6 #include "base/run_loop.h" 7 #include "base/run_loop.h"
7 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" 8 #include "chrome/browser/chromeos/login/test/oobe_base_test.h"
8 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" 9 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h"
9 #include "chrome/browser/chromeos/login/wizard_controller.h" 10 #include "chrome/browser/chromeos/login/wizard_controller.h"
10 #include "components/pairing/bluetooth_host_pairing_controller.h" 11 #include "components/pairing/bluetooth_host_pairing_controller.h"
11 #include "components/pairing/shark_connection_listener.h" 12 #include "components/pairing/shark_connection_listener.h"
12 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
13 #include "device/hid/fake_input_service_linux.h" 14 #include "device/hid/fake_input_service_linux.h"
14 15
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 48
48 // This is the class to simulate the OOBE process for devices that don't have 49 // This is the class to simulate the OOBE process for devices that don't have
49 // sufficient input, i.e., the first screen of OOBE is the HID detection screen. 50 // sufficient input, i.e., the first screen of OOBE is the HID detection screen.
50 // The device will put itself in Bluetooth discoverable mode. 51 // The device will put itself in Bluetooth discoverable mode.
51 class BluetoothHostPairingNoInputTest : public OobeBaseTest { 52 class BluetoothHostPairingNoInputTest : public OobeBaseTest {
52 public: 53 public:
53 using InputDeviceInfo = device::InputServiceLinux::InputDeviceInfo; 54 using InputDeviceInfo = device::InputServiceLinux::InputDeviceInfo;
54 55
55 BluetoothHostPairingNoInputTest() { 56 BluetoothHostPairingNoInputTest() {
56 InputServiceProxy::SetThreadIdForTesting(content::BrowserThread::UI); 57 InputServiceProxy::SetThreadIdForTesting(content::BrowserThread::UI);
57 input_service_linux_.reset(new device::FakeInputServiceLinux); 58 device::InputServiceLinux::SetForTesting(
58 device::InputServiceLinux::SetForTesting(input_service_linux_.get()); 59 base::MakeUnique<device::FakeInputServiceLinux>());
59 } 60 }
60 ~BluetoothHostPairingNoInputTest() override {} 61 ~BluetoothHostPairingNoInputTest() override {}
61 62
62 // OobeBaseTest override: 63 // OobeBaseTest override:
63 void SetUpOnMainThread() override { 64 void SetUpOnMainThread() override {
64 OobeBaseTest::SetUpOnMainThread(); 65 OobeBaseTest::SetUpOnMainThread();
65 delegate_.reset(new TestDelegate); 66 delegate_.reset(new TestDelegate);
66 if (controller()) { 67 if (controller()) {
67 controller()->SetDelegateForTesting(delegate_.get()); 68 controller()->SetDelegateForTesting(delegate_.get());
68 bluetooth_adapter_ = controller()->GetAdapterForTesting(); 69 bluetooth_adapter_ = controller()->GetAdapterForTesting();
(...skipping 12 matching lines...) Expand all
81 } 82 }
82 83
83 TestDelegate* delegate() { return delegate_.get(); } 84 TestDelegate* delegate() { return delegate_.get(); }
84 85
85 void AddUsbMouse() { 86 void AddUsbMouse() {
86 InputDeviceInfo mouse; 87 InputDeviceInfo mouse;
87 mouse.id = "usb_mouse"; 88 mouse.id = "usb_mouse";
88 mouse.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT; 89 mouse.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT;
89 mouse.type = InputDeviceInfo::TYPE_USB; 90 mouse.type = InputDeviceInfo::TYPE_USB;
90 mouse.is_mouse = true; 91 mouse.is_mouse = true;
91 input_service_linux_->AddDeviceForTesting(mouse); 92 AddDeviceForTesting(mouse);
92 } 93 }
93 94
94 void AddUsbKeyboard() { 95 void AddUsbKeyboard() {
95 InputDeviceInfo keyboard; 96 InputDeviceInfo keyboard;
96 keyboard.id = "usb_keyboard"; 97 keyboard.id = "usb_keyboard";
97 keyboard.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT; 98 keyboard.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT;
98 keyboard.type = InputDeviceInfo::TYPE_USB; 99 keyboard.type = InputDeviceInfo::TYPE_USB;
99 keyboard.is_keyboard = true; 100 keyboard.is_keyboard = true;
100 input_service_linux_->AddDeviceForTesting(keyboard); 101 AddDeviceForTesting(keyboard);
101 } 102 }
102 103
103 void AddBluetoothMouse() { 104 void AddBluetoothMouse() {
104 InputDeviceInfo mouse; 105 InputDeviceInfo mouse;
105 mouse.id = "bluetooth_mouse"; 106 mouse.id = "bluetooth_mouse";
106 mouse.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT; 107 mouse.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT;
107 mouse.type = InputDeviceInfo::TYPE_BLUETOOTH; 108 mouse.type = InputDeviceInfo::TYPE_BLUETOOTH;
108 mouse.is_mouse = true; 109 mouse.is_mouse = true;
109 input_service_linux_->AddDeviceForTesting(mouse); 110 AddDeviceForTesting(mouse);
110 } 111 }
111 112
112 private: 113 private:
113 std::unique_ptr<device::FakeInputServiceLinux> input_service_linux_; 114 void AddDeviceForTesting(const InputDeviceInfo& info) {
115 static_cast<device::FakeInputServiceLinux*>(
116 device::InputServiceLinux::GetInstance())
117 ->AddDeviceForTesting(info);
118 }
119
114 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_; 120 scoped_refptr<device::BluetoothAdapter> bluetooth_adapter_;
115 std::unique_ptr<TestDelegate> delegate_; 121 std::unique_ptr<TestDelegate> delegate_;
116 122
117 DISALLOW_COPY_AND_ASSIGN(BluetoothHostPairingNoInputTest); 123 DISALLOW_COPY_AND_ASSIGN(BluetoothHostPairingNoInputTest);
118 }; 124 };
119 125
120 // Test that in normal user OOBE login flow for devices lacking input devices, 126 // Test that in normal user OOBE login flow for devices lacking input devices,
121 // if there is no Bluetooth device connected, the Bluetooth adapter should be 127 // if there is no Bluetooth device connected, the Bluetooth adapter should be
122 // disabled when OOBE reaches login screen (which means OOBE has been completed) 128 // disabled when OOBE reaches login screen (which means OOBE has been completed)
123 IN_PROC_BROWSER_TEST_F(BluetoothHostPairingNoInputTest, 129 IN_PROC_BROWSER_TEST_F(BluetoothHostPairingNoInputTest,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 // Test that in normal user OOBE login flow for devices that have input devices, 172 // Test that in normal user OOBE login flow for devices that have input devices,
167 // the Bluetooth is disabled by default. 173 // the Bluetooth is disabled by default.
168 IN_PROC_BROWSER_TEST_F(BluetoothHostPairingWithInputTest, 174 IN_PROC_BROWSER_TEST_F(BluetoothHostPairingWithInputTest,
169 BluetoothDisableByDefault) { 175 BluetoothDisableByDefault) {
170 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_NETWORK).Wait(); 176 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_NETWORK).Wait();
171 EXPECT_FALSE(controller()); 177 EXPECT_FALSE(controller());
172 EXPECT_FALSE(bluetooth_adapter()); 178 EXPECT_FALSE(bluetooth_adapter());
173 } 179 }
174 180
175 } // namespace chromeos 181 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698