1 // Copyright 2013 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.
5 #include "ash/display/virtual_keyboard_window_controller.h"
7 #include "ash/ash_switches.h"
8 #include "ash/display/display_controller.h"
9 #include "ash/root_window_controller.h"
10 #include "ash/shell.h"
11 #include "ash/shell_window_ids.h"
12 #include "ash/test/ash_test_base.h"
13 #include "base/command_line.h"
14 #include "ui/keyboard/keyboard_switches.h"
15 #include "ui/keyboard/keyboard_util.h"
20 class VirtualKeyboardWindowControllerTest
: public AshTestBase
{
22 VirtualKeyboardWindowControllerTest()
23 : virtual_keyboard_window_controller_(NULL
) {}
24 virtual ~VirtualKeyboardWindowControllerTest() {}
26 void set_virtual_keyboard_window_controller(
27 VirtualKeyboardWindowController
* controller
) {
28 virtual_keyboard_window_controller_
= controller
;
31 RootWindowController
* root_window_controller() {
32 return virtual_keyboard_window_controller_
->
33 root_window_controller_for_test();
37 VirtualKeyboardWindowController
* virtual_keyboard_window_controller_
;
38 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardWindowControllerTest
);
41 class VirtualKeyboardUsabilityExperimentTest
42 : public VirtualKeyboardWindowControllerTest
{
44 VirtualKeyboardUsabilityExperimentTest()
45 : VirtualKeyboardWindowControllerTest() {}
46 virtual ~VirtualKeyboardUsabilityExperimentTest() {}
48 virtual void SetUp() OVERRIDE
{
49 if (SupportsMultipleDisplays()) {
50 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
51 switches::kAshHostWindowBounds
, "1+1-300x300,1+301-300x300");
52 CommandLine::ForCurrentProcess()->AppendSwitch(
53 keyboard::switches::kKeyboardUsabilityExperiment
);
55 test::AshTestBase::SetUp();
59 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardUsabilityExperimentTest
);
62 TEST_F(VirtualKeyboardUsabilityExperimentTest
, VirtualKeyboardWindowTest
) {
63 if (!SupportsMultipleDisplays())
65 RunAllPendingInMessageLoop();
66 set_virtual_keyboard_window_controller(
67 Shell::GetInstance()->display_controller()->
68 virtual_keyboard_window_controller());
69 EXPECT_TRUE(root_window_controller());
70 // Keyboard container is added to virtual keyboard window.
71 EXPECT_TRUE(root_window_controller()->GetContainer(
72 kShellWindowId_VirtualKeyboardContainer
));
75 // Tests that the onscreen keyboard becomes enabled when maximize mode is
77 TEST_F(VirtualKeyboardWindowControllerTest
, EnabledDuringMaximizeMode
) {
78 set_virtual_keyboard_window_controller(
79 Shell::GetInstance()->display_controller()->
80 virtual_keyboard_window_controller());
82 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
83 Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
84 EXPECT_TRUE(keyboard::IsKeyboardEnabled());
85 Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
86 EXPECT_FALSE(keyboard::IsKeyboardEnabled());