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

Side by Side Diff: ash/virtual_keyboard_controller_unittest.cc

Issue 970983003: Fix Virtual Keyboard not being deployed in TouchView mode on Ozone. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added suppression test. Created 5 years, 9 months 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
« no previous file with comments | « ash/virtual_keyboard_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <vector> 7 #include <vector>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h" 10 #include "ash/system/chromeos/virtual_keyboard/virtual_keyboard_observer.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 // Whether the observer method was called. 147 // Whether the observer method was called.
148 bool notified_; 148 bool notified_;
149 149
150 // Whether the keeyboard is suppressed. 150 // Whether the keeyboard is suppressed.
151 bool suppressed_; 151 bool suppressed_;
152 152
153 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerAutoTest); 153 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardControllerAutoTest);
154 }; 154 };
155 155
156 // Tests that the onscreen keyboard is disabled if an internal keyboard is 156 // Tests that the onscreen keyboard is disabled if an internal keyboard is
157 // present. 157 // present and maximized mode is disabled.
158 TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) { 158 TEST_F(VirtualKeyboardControllerAutoTest, DisabledIfInternalKeyboardPresent) {
159 std::vector<ui::TouchscreenDevice> screens; 159 std::vector<ui::TouchscreenDevice> screens;
160 screens.push_back(ui::TouchscreenDevice( 160 screens.push_back(ui::TouchscreenDevice(
161 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1024, 768), 0)); 161 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1024, 768), 0));
162 UpdateTouchscreenDevices(screens); 162 UpdateTouchscreenDevices(screens);
163 std::vector<ui::KeyboardDevice> keyboards; 163 std::vector<ui::KeyboardDevice> keyboards;
164 keyboards.push_back( 164 keyboards.push_back(
165 ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL)); 165 ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
166 UpdateKeyboardDevices(keyboards); 166 UpdateKeyboardDevices(keyboards);
167 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 167 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 keyboards.push_back( 228 keyboards.push_back(
229 ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL)); 229 ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
230 keyboards.push_back( 230 keyboards.push_back(
231 ui::KeyboardDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)); 231 ui::KeyboardDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL));
232 keyboards.push_back( 232 keyboards.push_back(
233 ui::KeyboardDevice(3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)); 233 ui::KeyboardDevice(3, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL));
234 UpdateKeyboardDevices(keyboards); 234 UpdateKeyboardDevices(keyboards);
235 ASSERT_FALSE(keyboard::IsKeyboardEnabled()); 235 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
236 } 236 }
237 237
238 // Tests maximized mode interaction without disabling the internal keyboard.
239 TEST_F(VirtualKeyboardControllerAutoTest, EnabledDuringMaximizeMode) {
240 std::vector<ui::TouchscreenDevice> screens;
241 screens.push_back(ui::TouchscreenDevice(
242 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1024, 768), 0));
243 UpdateTouchscreenDevices(screens);
244 std::vector<ui::KeyboardDevice> keyboards;
245 keyboards.push_back(
246 ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
247 UpdateKeyboardDevices(keyboards);
248 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
249 // Toggle maximized mode on.
250 Shell::GetInstance()
251 ->maximize_mode_controller()
252 ->EnableMaximizeModeWindowManager(true);
253 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
254 // Toggle maximized mode off.
255 Shell::GetInstance()
256 ->maximize_mode_controller()
257 ->EnableMaximizeModeWindowManager(false);
258 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
259 }
260
261 // Tests that keyboard gets suppressed in maximized mode.
262 TEST_F(VirtualKeyboardControllerAutoTest, SuppressedInMaximizedMode) {
263 std::vector<ui::TouchscreenDevice> screens;
264 screens.push_back(ui::TouchscreenDevice(
265 1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL, gfx::Size(1024, 768), 0));
266 UpdateTouchscreenDevices(screens);
267 std::vector<ui::KeyboardDevice> keyboards;
268 keyboards.push_back(
269 ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_INTERNAL));
270 keyboards.push_back(
271 ui::KeyboardDevice(2, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL));
272 UpdateKeyboardDevices(keyboards);
273 // Toggle maximized mode on.
274 Shell::GetInstance()
275 ->maximize_mode_controller()
276 ->EnableMaximizeModeWindowManager(true);
277 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
278 ASSERT_TRUE(notified());
279 ASSERT_TRUE(IsVirtualKeyboardSuppressed());
280 // Toggle show keyboard. Keyboard should be visible.
281 ResetObserver();
282 Shell::GetInstance()
283 ->virtual_keyboard_controller()
284 ->ToggleIgnoreExternalKeyboard();
285 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
286 ASSERT_TRUE(notified());
287 ASSERT_TRUE(IsVirtualKeyboardSuppressed());
288 // Toggle show keyboard. Keyboard should be hidden.
289 ResetObserver();
290 Shell::GetInstance()
291 ->virtual_keyboard_controller()
292 ->ToggleIgnoreExternalKeyboard();
293 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
294 ASSERT_TRUE(notified());
295 ASSERT_TRUE(IsVirtualKeyboardSuppressed());
296 // Remove external keyboard. Should be notified that the keyboard is not
297 // suppressed.
298 ResetObserver();
299 keyboards.pop_back();
300 UpdateKeyboardDevices(keyboards);
301 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
302 ASSERT_TRUE(notified());
303 ASSERT_FALSE(IsVirtualKeyboardSuppressed());
304 // Toggle maximized mode oFF.
305 Shell::GetInstance()
306 ->maximize_mode_controller()
307 ->EnableMaximizeModeWindowManager(false);
308 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
309 }
310
238 class VirtualKeyboardControllerAlwaysEnabledTest 311 class VirtualKeyboardControllerAlwaysEnabledTest
239 : public VirtualKeyboardControllerAutoTest { 312 : public VirtualKeyboardControllerAutoTest {
240 public: 313 public:
241 VirtualKeyboardControllerAlwaysEnabledTest() 314 VirtualKeyboardControllerAlwaysEnabledTest()
242 : VirtualKeyboardControllerAutoTest() {} 315 : VirtualKeyboardControllerAutoTest() {}
243 ~VirtualKeyboardControllerAlwaysEnabledTest() override {} 316 ~VirtualKeyboardControllerAlwaysEnabledTest() override {}
244 317
245 void SetUp() override { 318 void SetUp() override {
246 base::CommandLine::ForCurrentProcess()->AppendSwitch( 319 base::CommandLine::ForCurrentProcess()->AppendSwitch(
247 keyboard::switches::kEnableVirtualKeyboard); 320 keyboard::switches::kEnableVirtualKeyboard);
(...skipping 13 matching lines...) Expand all
261 UpdateTouchscreenDevices(screens); 334 UpdateTouchscreenDevices(screens);
262 std::vector<ui::KeyboardDevice> keyboards; 335 std::vector<ui::KeyboardDevice> keyboards;
263 keyboards.push_back( 336 keyboards.push_back(
264 ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL)); 337 ui::KeyboardDevice(1, ui::InputDeviceType::INPUT_DEVICE_EXTERNAL));
265 UpdateKeyboardDevices(keyboards); 338 UpdateKeyboardDevices(keyboards);
266 ASSERT_TRUE(keyboard::IsKeyboardEnabled()); 339 ASSERT_TRUE(keyboard::IsKeyboardEnabled());
267 } 340 }
268 341
269 } // namespace test 342 } // namespace test
270 } // namespace ash 343 } // namespace ash
OLDNEW
« no previous file with comments | « ash/virtual_keyboard_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698