| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/macros.h" | 5 #include "base/macros.h" |
| 6 #include "chrome/browser/chromeos/device/input_service_test_helper.h" | 6 #include "chrome/browser/chromeos/device/input_service_test_helper.h" |
| 7 #include "chrome/browser/chromeos/login/screens/base_screen.h" | 7 #include "chrome/browser/chromeos/login/screens/base_screen.h" |
| 8 #include "chrome/browser/chromeos/login/screens/hid_detection_screen.h" | 8 #include "chrome/browser/chromeos/login/screens/hid_detection_screen.h" |
| 9 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" | 9 #include "chrome/browser/chromeos/login/test/oobe_screen_waiter.h" |
| 10 #include "chrome/browser/chromeos/login/test/wizard_in_process_browser_test.h" | 10 #include "chrome/browser/chromeos/login/test/wizard_in_process_browser_test.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 HIDDetectionScreen* hid_detection_screen_; | 56 HIDDetectionScreen* hid_detection_screen_; |
| 57 std::unique_ptr<InputServiceTestHelper> helper_; | 57 std::unique_ptr<InputServiceTestHelper> helper_; |
| 58 | 58 |
| 59 DISALLOW_COPY_AND_ASSIGN(HIDDetectionScreenTest); | 59 DISALLOW_COPY_AND_ASSIGN(HIDDetectionScreenTest); |
| 60 }; | 60 }; |
| 61 | 61 |
| 62 IN_PROC_BROWSER_TEST_F(HIDDetectionScreenTest, MouseKeyboardStates) { | 62 IN_PROC_BROWSER_TEST_F(HIDDetectionScreenTest, MouseKeyboardStates) { |
| 63 // NOTE: State strings match those in hid_detection_screen.cc. | 63 // NOTE: State strings match those in hid_detection_screen.cc. |
| 64 // No devices added yet | 64 // No devices added yet |
| 65 EXPECT_EQ("searching", | 65 EXPECT_EQ("searching", |
| 66 context()->GetString(HIDDetectionModel::kContextKeyMouseState)); | 66 context()->GetString(HIDDetectionScreen::kContextKeyMouseState)); |
| 67 EXPECT_EQ("searching", | 67 EXPECT_EQ("searching", |
| 68 context()->GetString(HIDDetectionModel::kContextKeyKeyboardState)); | 68 context()->GetString(HIDDetectionScreen::kContextKeyKeyboardState)); |
| 69 EXPECT_FALSE(context()->GetBoolean( | 69 EXPECT_FALSE(context()->GetBoolean( |
| 70 HIDDetectionModel::kContextKeyContinueButtonEnabled)); | 70 HIDDetectionScreen::kContextKeyContinueButtonEnabled)); |
| 71 | 71 |
| 72 // Generic connection types. Unlike the pointing device, which may be a tablet | 72 // Generic connection types. Unlike the pointing device, which may be a tablet |
| 73 // or touchscreen, the keyboard only reports usb and bluetooth states. | 73 // or touchscreen, the keyboard only reports usb and bluetooth states. |
| 74 helper()->AddDeviceToService(true, InputDeviceInfo::TYPE_SERIO); | 74 helper()->AddDeviceToService(true, InputDeviceInfo::TYPE_SERIO); |
| 75 EXPECT_TRUE(context()->GetBoolean( | 75 EXPECT_TRUE(context()->GetBoolean( |
| 76 HIDDetectionModel::kContextKeyContinueButtonEnabled)); | 76 HIDDetectionScreen::kContextKeyContinueButtonEnabled)); |
| 77 | 77 |
| 78 helper()->AddDeviceToService(false, InputDeviceInfo::TYPE_SERIO); | 78 helper()->AddDeviceToService(false, InputDeviceInfo::TYPE_SERIO); |
| 79 EXPECT_EQ("connected", | 79 EXPECT_EQ("connected", |
| 80 context()->GetString(HIDDetectionModel::kContextKeyMouseState)); | 80 context()->GetString(HIDDetectionScreen::kContextKeyMouseState)); |
| 81 EXPECT_EQ("usb", | 81 EXPECT_EQ("usb", |
| 82 context()->GetString(HIDDetectionModel::kContextKeyKeyboardState)); | 82 context()->GetString(HIDDetectionScreen::kContextKeyKeyboardState)); |
| 83 EXPECT_TRUE(context()->GetBoolean( | 83 EXPECT_TRUE(context()->GetBoolean( |
| 84 HIDDetectionModel::kContextKeyContinueButtonEnabled)); | 84 HIDDetectionScreen::kContextKeyContinueButtonEnabled)); |
| 85 | 85 |
| 86 // Remove generic devices, add usb devices. | 86 // Remove generic devices, add usb devices. |
| 87 helper()->RemoveDeviceFromService(true); | 87 helper()->RemoveDeviceFromService(true); |
| 88 helper()->RemoveDeviceFromService(false); | 88 helper()->RemoveDeviceFromService(false); |
| 89 EXPECT_FALSE(context()->GetBoolean( | 89 EXPECT_FALSE(context()->GetBoolean( |
| 90 HIDDetectionModel::kContextKeyContinueButtonEnabled)); | 90 HIDDetectionScreen::kContextKeyContinueButtonEnabled)); |
| 91 | 91 |
| 92 helper()->AddDeviceToService(true, InputDeviceInfo::TYPE_USB); | 92 helper()->AddDeviceToService(true, InputDeviceInfo::TYPE_USB); |
| 93 helper()->AddDeviceToService(false, InputDeviceInfo::TYPE_USB); | 93 helper()->AddDeviceToService(false, InputDeviceInfo::TYPE_USB); |
| 94 EXPECT_EQ("usb", | 94 EXPECT_EQ("usb", |
| 95 context()->GetString(HIDDetectionModel::kContextKeyMouseState)); | 95 context()->GetString(HIDDetectionScreen::kContextKeyMouseState)); |
| 96 EXPECT_EQ("usb", | 96 EXPECT_EQ("usb", |
| 97 context()->GetString(HIDDetectionModel::kContextKeyKeyboardState)); | 97 context()->GetString(HIDDetectionScreen::kContextKeyKeyboardState)); |
| 98 EXPECT_TRUE(context()->GetBoolean( | 98 EXPECT_TRUE(context()->GetBoolean( |
| 99 HIDDetectionModel::kContextKeyContinueButtonEnabled)); | 99 HIDDetectionScreen::kContextKeyContinueButtonEnabled)); |
| 100 | 100 |
| 101 // Remove usb devices, add bluetooth devices. | 101 // Remove usb devices, add bluetooth devices. |
| 102 helper()->RemoveDeviceFromService(true); | 102 helper()->RemoveDeviceFromService(true); |
| 103 helper()->RemoveDeviceFromService(false); | 103 helper()->RemoveDeviceFromService(false); |
| 104 EXPECT_FALSE(context()->GetBoolean( | 104 EXPECT_FALSE(context()->GetBoolean( |
| 105 HIDDetectionModel::kContextKeyContinueButtonEnabled)); | 105 HIDDetectionScreen::kContextKeyContinueButtonEnabled)); |
| 106 | 106 |
| 107 helper()->AddDeviceToService(true, InputDeviceInfo::TYPE_BLUETOOTH); | 107 helper()->AddDeviceToService(true, InputDeviceInfo::TYPE_BLUETOOTH); |
| 108 helper()->AddDeviceToService(false, InputDeviceInfo::TYPE_BLUETOOTH); | 108 helper()->AddDeviceToService(false, InputDeviceInfo::TYPE_BLUETOOTH); |
| 109 EXPECT_EQ("paired", | 109 EXPECT_EQ("paired", |
| 110 context()->GetString(HIDDetectionModel::kContextKeyMouseState)); | 110 context()->GetString(HIDDetectionScreen::kContextKeyMouseState)); |
| 111 EXPECT_EQ("paired", | 111 EXPECT_EQ("paired", |
| 112 context()->GetString(HIDDetectionModel::kContextKeyKeyboardState)); | 112 context()->GetString(HIDDetectionScreen::kContextKeyKeyboardState)); |
| 113 EXPECT_TRUE(context()->GetBoolean( | 113 EXPECT_TRUE(context()->GetBoolean( |
| 114 HIDDetectionModel::kContextKeyContinueButtonEnabled)); | 114 HIDDetectionScreen::kContextKeyContinueButtonEnabled)); |
| 115 } | 115 } |
| 116 | 116 |
| 117 // Test that if there is any Bluetooth device connected on HID screen, the | 117 // Test that if there is any Bluetooth device connected on HID screen, the |
| 118 // Bluetooth adapter should not be disabled after advancing to the next screen. | 118 // Bluetooth adapter should not be disabled after advancing to the next screen. |
| 119 IN_PROC_BROWSER_TEST_F(HIDDetectionScreenTest, BluetoothDeviceConnected) { | 119 IN_PROC_BROWSER_TEST_F(HIDDetectionScreenTest, BluetoothDeviceConnected) { |
| 120 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_HID_DETECTION).Wait(); | 120 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_HID_DETECTION).Wait(); |
| 121 EXPECT_TRUE(adapter()->IsPowered()); | 121 EXPECT_TRUE(adapter()->IsPowered()); |
| 122 | 122 |
| 123 // Add a pair of USB mouse/keyboard so that |pointing_device_connect_type_| | 123 // Add a pair of USB mouse/keyboard so that |pointing_device_connect_type_| |
| 124 // and |keyboard_device_connect_type_| are InputDeviceInfo::TYPE_USB. | 124 // and |keyboard_device_connect_type_| are InputDeviceInfo::TYPE_USB. |
| (...skipping 23 matching lines...) Expand all Loading... |
| 148 | 148 |
| 149 // Simulate the user's click on "Continue" button. | 149 // Simulate the user's click on "Continue" button. |
| 150 hid_detection_screen()->OnContinueButtonClicked(); | 150 hid_detection_screen()->OnContinueButtonClicked(); |
| 151 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_NETWORK).Wait(); | 151 OobeScreenWaiter(OobeScreen::SCREEN_OOBE_NETWORK).Wait(); |
| 152 | 152 |
| 153 // The adapter should be powered off at this moment. | 153 // The adapter should be powered off at this moment. |
| 154 EXPECT_FALSE(adapter()->IsPowered()); | 154 EXPECT_FALSE(adapter()->IsPowered()); |
| 155 } | 155 } |
| 156 | 156 |
| 157 } // namespace chromeos | 157 } // namespace chromeos |
| OLD | NEW |