| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/bind.h" |
| 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "chrome/browser/chromeos/login/test/oobe_base_test.h" |
| 9 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
| 10 #include "chrome/browser/chromeos/login/ui/oobe_display.h" |
| 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "device/bluetooth/bluetooth_adapter_factory.h" |
| 13 #include "device/bluetooth/test/mock_bluetooth_adapter.h" |
| 14 #include "device/hid/fake_input_service_linux.h" |
| 15 #include "device/hid/input_service_linux.h" |
| 16 #include "testing/gmock/include/gmock/gmock.h" |
| 17 |
| 18 using device::InputServiceLinux; |
| 19 using testing::_; |
| 20 |
| 21 typedef InputServiceLinux::InputDeviceInfo InputDeviceInfo; |
| 22 |
| 23 namespace { |
| 24 |
| 25 void SetUpBluetoothMock( |
| 26 scoped_refptr< |
| 27 testing::NiceMock<device::MockBluetoothAdapter> > mock_adapter, |
| 28 bool is_present) { |
| 29 device::BluetoothAdapterFactory::SetAdapterForTesting(mock_adapter); |
| 30 |
| 31 EXPECT_CALL(*mock_adapter, IsPresent()) |
| 32 .WillRepeatedly(testing::Return(is_present)); |
| 33 |
| 34 EXPECT_CALL(*mock_adapter, IsPowered()) |
| 35 .WillRepeatedly(testing::Return(true)); |
| 36 EXPECT_CALL(*mock_adapter, GetDevices()).WillRepeatedly( |
| 37 testing::Return(device::BluetoothAdapter::ConstDeviceList())); |
| 38 } |
| 39 |
| 40 } // namespace |
| 41 |
| 42 namespace chromeos { |
| 43 |
| 44 class HidDetectionTest : public OobeBaseTest { |
| 45 public: |
| 46 typedef device::InputServiceLinux::InputDeviceInfo InputDeviceInfo; |
| 47 |
| 48 HidDetectionTest() { |
| 49 device::InputServiceLinux::SetForTesting(&input_service_linux_); |
| 50 } |
| 51 |
| 52 ~HidDetectionTest() override {} |
| 53 |
| 54 void SetUpInProcessBrowserTestFixture() override { |
| 55 OobeBaseTest::SetUpInProcessBrowserTestFixture(); |
| 56 |
| 57 mock_adapter_ = new testing::NiceMock<device::MockBluetoothAdapter>(); |
| 58 SetUpBluetoothMock(mock_adapter_, true); |
| 59 } |
| 60 |
| 61 void AddUsbMouse(const std::string& mouse_id) { |
| 62 InputDeviceInfo mouse; |
| 63 mouse.id = mouse_id; |
| 64 mouse.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT; |
| 65 mouse.type = InputDeviceInfo::TYPE_USB; |
| 66 mouse.is_mouse = true; |
| 67 input_service_linux_.AddDeviceForTesting(mouse); |
| 68 } |
| 69 |
| 70 void AddUsbKeyboard(const std::string& keyboard_id) { |
| 71 InputDeviceInfo keyboard; |
| 72 keyboard.id = keyboard_id; |
| 73 keyboard.subsystem = InputDeviceInfo::SUBSYSTEM_INPUT; |
| 74 keyboard.type = InputDeviceInfo::TYPE_USB; |
| 75 keyboard.is_keyboard = true; |
| 76 input_service_linux_.AddDeviceForTesting(keyboard); |
| 77 } |
| 78 |
| 79 private: |
| 80 scoped_refptr< |
| 81 testing::NiceMock<device::MockBluetoothAdapter> > mock_adapter_; |
| 82 |
| 83 device::FakeInputServiceLinux input_service_linux_; |
| 84 |
| 85 DISALLOW_COPY_AND_ASSIGN(HidDetectionTest); |
| 86 }; |
| 87 |
| 88 class HidDetectionSkipTest : public HidDetectionTest { |
| 89 public: |
| 90 HidDetectionSkipTest() { |
| 91 AddUsbMouse("mouse"); |
| 92 AddUsbKeyboard("keyboard"); |
| 93 } |
| 94 }; |
| 95 |
| 96 IN_PROC_BROWSER_TEST_F(HidDetectionTest, NoDevicesConnected) { |
| 97 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_HID_DETECTION).Wait(); |
| 98 } |
| 99 |
| 100 IN_PROC_BROWSER_TEST_F(HidDetectionSkipTest, BothDevicesPreConnected) { |
| 101 OobeScreenWaiter(OobeDisplay::SCREEN_OOBE_NETWORK).Wait(); |
| 102 |
| 103 } |
| 104 |
| 105 } // namespace chromeos |
| OLD | NEW |