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 "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 Loading... | |
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 Loading... | |
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 static_cast<device::FakeInputServiceLinux*>( |
achuithb
2016/11/10 23:24:00
Could you pull this out into a helper like
void Ad
fdoray
2016/11/11 14:21:45
Done.
| |
93 device::InputServiceLinux::GetInstance()) | |
94 ->AddDeviceForTesting(mouse); | |
92 } | 95 } |
93 | 96 |
94 void AddUsbKeyboard() { | 97 void AddUsbKeyboard() { |
95 InputDeviceInfo keyboard; | 98 InputDeviceInfo keyboard; |
96 keyboard.id = "usb_keyboard"; | 99 keyboard.id = "usb_keyboard"; |
97 keyboard.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT; | 100 keyboard.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT; |
98 keyboard.type = InputDeviceInfo::TYPE_USB; | 101 keyboard.type = InputDeviceInfo::TYPE_USB; |
99 keyboard.is_keyboard = true; | 102 keyboard.is_keyboard = true; |
100 input_service_linux_->AddDeviceForTesting(keyboard); | 103 static_cast<device::FakeInputServiceLinux*>( |
104 device::InputServiceLinux::GetInstance()) | |
105 ->AddDeviceForTesting(keyboard); | |
101 } | 106 } |
102 | 107 |
103 void AddBluetoothMouse() { | 108 void AddBluetoothMouse() { |
104 InputDeviceInfo mouse; | 109 InputDeviceInfo mouse; |
105 mouse.id = "bluetooth_mouse"; | 110 mouse.id = "bluetooth_mouse"; |
106 mouse.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT; | 111 mouse.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT; |
107 mouse.type = InputDeviceInfo::TYPE_BLUETOOTH; | 112 mouse.type = InputDeviceInfo::TYPE_BLUETOOTH; |
108 mouse.is_mouse = true; | 113 mouse.is_mouse = true; |
109 input_service_linux_->AddDeviceForTesting(mouse); | 114 static_cast<device::FakeInputServiceLinux*>( |
115 device::InputServiceLinux::GetInstance()) | |
116 ->AddDeviceForTesting(mouse); | |
110 } | 117 } |
111 | 118 |
112 private: | 119 private: |
113 std::unique_ptr<device::FakeInputServiceLinux> input_service_linux_; | |
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 Loading... | |
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 |
OLD | NEW |