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/common/wm/always_on_top_controller.h" | 5 #include "ash/common/wm/always_on_top_controller.h" |
6 | 6 |
| 7 #include "ash/aura/wm_root_window_controller_aura.h" |
7 #include "ash/aura/wm_window_aura.h" | 8 #include "ash/aura/wm_window_aura.h" |
8 #include "ash/common/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
9 #include "ash/common/wm/workspace/workspace_layout_manager.h" | 10 #include "ash/common/wm/workspace/workspace_layout_manager.h" |
10 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
12 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
13 #include "base/command_line.h" | 14 #include "base/command_line.h" |
14 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
15 #include "ui/keyboard/keyboard_controller.h" | 16 #include "ui/keyboard/keyboard_controller.h" |
16 #include "ui/keyboard/keyboard_switches.h" | 17 #include "ui/keyboard/keyboard_switches.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 keyboard::KeyboardController* keyboard_controller = | 61 keyboard::KeyboardController* keyboard_controller = |
61 keyboard::KeyboardController::GetInstance(); | 62 keyboard::KeyboardController::GetInstance(); |
62 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 63 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
63 aura::Window* always_on_top_container = | 64 aura::Window* always_on_top_container = |
64 Shell::GetContainer(root_window, kShellWindowId_AlwaysOnTopContainer); | 65 Shell::GetContainer(root_window, kShellWindowId_AlwaysOnTopContainer); |
65 // Install test layout manager. | 66 // Install test layout manager. |
66 TestLayoutManager* manager = | 67 TestLayoutManager* manager = |
67 new TestLayoutManager(WmWindowAura::Get(always_on_top_container)); | 68 new TestLayoutManager(WmWindowAura::Get(always_on_top_container)); |
68 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); | 69 RootWindowController* controller = Shell::GetPrimaryRootWindowController(); |
69 AlwaysOnTopController* always_on_top_controller = | 70 AlwaysOnTopController* always_on_top_controller = |
70 controller->always_on_top_controller(); | 71 controller->wm_root_window_controller()->always_on_top_controller(); |
71 always_on_top_controller->SetLayoutManagerForTest(base::WrapUnique(manager)); | 72 always_on_top_controller->SetLayoutManagerForTest(base::WrapUnique(manager)); |
72 // Activate keyboard. This triggers keyboard listeners to be registered. | 73 // Activate keyboard. This triggers keyboard listeners to be registered. |
73 controller->ActivateKeyboard(keyboard_controller); | 74 controller->ActivateKeyboard(keyboard_controller); |
74 | 75 |
75 // Mock a keyboard appearing. | 76 // Mock a keyboard appearing. |
76 aura::Window* keyboard_container = | 77 aura::Window* keyboard_container = |
77 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); | 78 Shell::GetContainer(root_window, kShellWindowId_VirtualKeyboardContainer); |
78 ASSERT_TRUE(keyboard_container); | 79 ASSERT_TRUE(keyboard_container); |
79 keyboard_container->Show(); | 80 keyboard_container->Show(); |
80 aura::Window* keyboard_window = | 81 aura::Window* keyboard_window = |
81 keyboard_controller->ui()->GetKeyboardWindow(); | 82 keyboard_controller->ui()->GetKeyboardWindow(); |
82 keyboard_container->AddChild(keyboard_window); | 83 keyboard_container->AddChild(keyboard_window); |
83 keyboard_window->set_owned_by_parent(false); | 84 keyboard_window->set_owned_by_parent(false); |
84 const int kKeyboardHeight = 200; | 85 const int kKeyboardHeight = 200; |
85 gfx::Rect keyboard_bounds = keyboard::FullWidthKeyboardBoundsFromRootBounds( | 86 gfx::Rect keyboard_bounds = keyboard::FullWidthKeyboardBoundsFromRootBounds( |
86 root_window->bounds(), kKeyboardHeight); | 87 root_window->bounds(), kKeyboardHeight); |
87 keyboard_window->SetBounds(keyboard_bounds); | 88 keyboard_window->SetBounds(keyboard_bounds); |
88 keyboard_window->Show(); | 89 keyboard_window->Show(); |
89 keyboard_controller->NotifyKeyboardBoundsChanging(keyboard_bounds); | 90 keyboard_controller->NotifyKeyboardBoundsChanging(keyboard_bounds); |
90 // Verify that test manager was notified of bounds change. | 91 // Verify that test manager was notified of bounds change. |
91 ASSERT_TRUE(manager->keyboard_bounds_changed()); | 92 ASSERT_TRUE(manager->keyboard_bounds_changed()); |
92 } | 93 } |
93 | 94 |
94 } // namespace test | 95 } // namespace test |
95 } // namespace ash | 96 } // namespace ash |
OLD | NEW |