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. 4 5 #include "ash/display/virtual_keyboard_window_controller.h" 6 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 16 namespace ash { 17 namespace test { 18 19 class VirtualKeyboardWindowControllerTest : public AshTestBase { 20 public: 21 VirtualKeyboardWindowControllerTest() 22 : virtual_keyboard_window_controller_(NULL) {} 23 virtual ~VirtualKeyboardWindowControllerTest() {} 24 25 virtual void SetUp() OVERRIDE { 26 if (SupportsMultipleDisplays()) { 27 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 28 switches::kAshHostWindowBounds, "1+1-300x300,1+301-300x300"); 29 CommandLine::ForCurrentProcess()->AppendSwitch( 30 keyboard::switches::kKeyboardUsabilityExperiment); 31 } 32 test::AshTestBase::SetUp(); 33 } 34 35 void set_virtual_keyboard_window_controller( 36 internal::VirtualKeyboardWindowController* controller) { 37 virtual_keyboard_window_controller_ = controller; 38 } 39 40 internal::RootWindowController* root_window_controller() { 41 return virtual_keyboard_window_controller_-> 42 root_window_controller_for_test(); 43 } 44 45 private: 46 internal::VirtualKeyboardWindowController* 47 virtual_keyboard_window_controller_; 48 DISALLOW_COPY_AND_ASSIGN(VirtualKeyboardWindowControllerTest); 49 }; 50 51 52 TEST_F(VirtualKeyboardWindowControllerTest, VirtualKeyboardWindowTest) { 53 if (!SupportsMultipleDisplays()) 54 return; 55 RunAllPendingInMessageLoop(); 56 set_virtual_keyboard_window_controller( 57 Shell::GetInstance()->display_controller()-> 58 virtual_keyboard_window_controller()); 59 EXPECT_TRUE(root_window_controller()); 60 // Keyboard container is added to virtual keyboard window. 61 EXPECT_TRUE(root_window_controller()->GetContainer( 62 internal::kShellWindowId_VirtualKeyboardContainer)); 63 } 64 65 } // namespace test 66 } // namespace ash 67