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 "ash/wm/maximize_mode/maximize_mode_controller.h"
14 #include "base/command_line.h"
15 #include "ui/keyboard/keyboard_switches.h"
16 #include "ui/keyboard/keyboard_util.h"
21 class VirtualKeyboardWindowControllerTest
: public AshTestBase
{
23 VirtualKeyboardWindowControllerTest()
24 : virtual_keyboard_window_controller_(NULL
) {}
25 virtual ~VirtualKeyboardWindowControllerTest() {}
27 void set_virtual_keyboard_window_controller(
28 VirtualKeyboardWindowController
* controller
) {
29 virtual_keyboard_window_controller_
= controller
;
32 RootWindowController
* root_window_controller() {
33 return virtual_keyboard_window_controller_
->
34 root_window_controller_for_test();
38 VirtualKeyboardWindowController
* virtual_keyboard_window_controller_
;
39 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardWindowControllerTest
);
42 class VirtualKeyboardUsabilityExperimentTest
43 : public VirtualKeyboardWindowControllerTest
{
45 VirtualKeyboardUsabilityExperimentTest()
46 : VirtualKeyboardWindowControllerTest() {}
47 virtual ~VirtualKeyboardUsabilityExperimentTest() {}
49 virtual void SetUp() OVERRIDE
{
50 if (SupportsMultipleDisplays()) {
51 CommandLine::ForCurrentProcess()->AppendSwitchASCII(
52 switches::kAshHostWindowBounds
, "1+1-300x300,1+301-300x300");
53 CommandLine::ForCurrentProcess()->AppendSwitch(
54 keyboard::switches::kKeyboardUsabilityExperiment
);
56 test::AshTestBase::SetUp();
60 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardUsabilityExperimentTest
);
63 TEST_F(VirtualKeyboardUsabilityExperimentTest
, VirtualKeyboardWindowTest
) {
64 if (!SupportsMultipleDisplays())
66 RunAllPendingInMessageLoop();
67 set_virtual_keyboard_window_controller(
68 Shell::GetInstance()->display_controller()->
69 virtual_keyboard_window_controller());
70 EXPECT_TRUE(root_window_controller());
71 aura::Window
* container
= root_window_controller()->GetContainer(
72 kShellWindowId_VirtualKeyboardContainer
);
73 // Keyboard container is added to virtual keyboard window and its bounds is
74 // the same as root window.
75 EXPECT_TRUE(container
);
76 EXPECT_EQ(container
->bounds(),
77 root_window_controller()->GetRootWindow()->bounds());
80 // Tests that the onscreen keyboard becomes enabled when maximize mode is
82 TEST_F(VirtualKeyboardWindowControllerTest
, EnabledDuringMaximizeMode
) {
83 set_virtual_keyboard_window_controller(
84 Shell::GetInstance()->display_controller()->
85 virtual_keyboard_window_controller());
87 ASSERT_FALSE(keyboard::IsKeyboardEnabled());
88 Shell::GetInstance()->maximize_mode_controller()->
89 EnableMaximizeModeWindowManager(true);
90 EXPECT_TRUE(keyboard::IsKeyboardEnabled());
91 Shell::GetInstance()->maximize_mode_controller()->
92 EnableMaximizeModeWindowManager(false);
93 EXPECT_FALSE(keyboard::IsKeyboardEnabled());