OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "ash/virtual_keyboard_controller.h" | 5 #include "ash/virtual_keyboard_controller.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h" | 8 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 10 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 bool suppressed_; | 109 bool suppressed_; |
110 | 110 |
111 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerAutoTest); | 111 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerAutoTest); |
112 }; | 112 }; |
113 | 113 |
114 // Tests that the onscreen keyboard is disabled if an internal keyboard is | 114 // Tests that the onscreen keyboard is disabled if an internal keyboard is |
115 // present. | 115 // present. |
116 TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) { | 116 TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) { |
117 std::vector<ui::TouchscreenDevice> screens; | 117 std::vector<ui::TouchscreenDevice> screens; |
118 screens.push_back( | 118 screens.push_back( |
119 ui::TouchscreenDevice(1, | 119 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, |
120 ui::InputDeviceType::INPUT_DEVICE_INTERNAL, | 120 "Touchscreen", gfx::Size(1024, 768), 0)); |
121 "Touchscreen", | |
122 gfx::Size(1024, 768))); | |
123 UpdateTouchscreenDevices(screens); | 121 UpdateTouchscreenDevices(screens); |
124 std::vector<ui::KeyboardDevice> keyboards; | 122 std::vector<ui::KeyboardDevice> keyboards; |
125 keyboards.push_back(ui::KeyboardDevice( | 123 keyboards.push_back(ui::KeyboardDevice( |
126 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); | 124 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, "keyboard")); |
127 UpdateKeyboardDevices(keyboards); | 125 UpdateKeyboardDevices(keyboards); |
128 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); | 126 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
129 // Remove the internal keyboard. Virtual keyboard should now show. | 127 // Remove the internal keyboard. Virtual keyboard should now show. |
130 UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>()); | 128 UpdateKeyboardDevices(std::vector<ui::KeyboardDevice>()); |
131 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 129 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
132 // Replug in the internal keyboard. Virtual keyboard should hide. | 130 // Replug in the internal keyboard. Virtual keyboard should hide. |
133 UpdateKeyboardDevices(keyboards); | 131 UpdateKeyboardDevices(keyboards); |
134 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 132 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
135 } | 133 } |
136 | 134 |
137 TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfNoTouchScreen) { | 135 TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfNoTouchScreen) { |
138 std::vector<ui::TouchscreenDevice> devices; | 136 std::vector<ui::TouchscreenDevice> devices; |
139 // Add a touchscreen. Keyboard should deploy. | 137 // Add a touchscreen. Keyboard should deploy. |
140 devices.push_back( | 138 devices.push_back( |
141 ui::TouchscreenDevice(1, | 139 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, |
142 ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, | 140 "Touchscreen", gfx::Size(800, 600), 0)); |
143 "Touchscreen", | |
144 gfx::Size(800, 600))); | |
145 UpdateTouchscreenDevices(devices); | 141 UpdateTouchscreenDevices(devices); |
146 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); | 142 EXPECT_TRUE(keyboard::IsKeyboardEnabled()); |
147 // Remove touchscreen. Keyboard should hide. | 143 // Remove touchscreen. Keyboard should hide. |
148 UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); | 144 UpdateTouchscreenDevices(std::vector<ui::TouchscreenDevice>()); |
149 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); | 145 EXPECT_FALSE(keyboard::IsKeyboardEnabled()); |
150 } | 146 } |
151 | 147 |
152 TEST_F(VirtualKeyboardControllerAutoTest, SuppressedIfExternalKeyboardPresent) { | 148 TEST_F(VirtualKeyboardControllerAutoTest, SuppressedIfExternalKeyboardPresent) { |
153 std::vector<ui::TouchscreenDevice> screens; | 149 std::vector<ui::TouchscreenDevice> screens; |
154 screens.push_back( | 150 screens.push_back( |
155 ui::TouchscreenDevice(1, | 151 ui::TouchscreenDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, |
156 ui::InputDeviceType::INPUT_DEVICE_INTERNAL, | 152 "Touchscreen", gfx::Size(1024, 768), 0)); |
157 "Touchscreen", | |
158 gfx::Size(1024, 768))); | |
159 UpdateTouchscreenDevices(screens); | 153 UpdateTouchscreenDevices(screens); |
160 std::vector<ui::KeyboardDevice> keyboards; | 154 std::vector<ui::KeyboardDevice> keyboards; |
161 keyboards.push_back(ui::KeyboardDevice( | 155 keyboards.push_back(ui::KeyboardDevice( |
162 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); | 156 1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); |
163 UpdateKeyboardDevices(keyboards); | 157 UpdateKeyboardDevices(keyboards); |
164 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); | 158 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
165 ASSERT_TRUE(notified()); | 159 ASSERT_TRUE(notified()); |
166 ASSERT_TRUE(IsVirtualKeyboardSuppressed()); | 160 ASSERT_TRUE(IsVirtualKeyboardSuppressed()); |
167 // Toggle show keyboard. Keyboard should be visible. | 161 // Toggle show keyboard. Keyboard should be visible. |
168 ResetObserver(); | 162 ResetObserver(); |
(...skipping 28 matching lines...) Expand all Loading... |
197 keyboards.push_back(ui::KeyboardDevice( | 191 keyboards.push_back(ui::KeyboardDevice( |
198 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); | 192 2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); |
199 keyboards.push_back(ui::KeyboardDevice( | 193 keyboards.push_back(ui::KeyboardDevice( |
200 3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); | 194 3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL, "keyboard")); |
201 UpdateKeyboardDevices(keyboards); | 195 UpdateKeyboardDevices(keyboards); |
202 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); | 196 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); |
203 } | 197 } |
204 | 198 |
205 } // namespace test | 199 } // namespace test |
206 } // namespace ash | 200 } // namespace ash |
OLD | NEW |