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

Side by Side Diff: ash/wm/workspace/workspace_layout_manager_keyboard_unittest.cc

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: cleanup Created 3 years, 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/wm/workspace/workspace_layout_manager.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/public/cpp/shell_window_ids.h" 10 #include "ash/public/cpp/shell_window_ids.h"
11 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
12 #include "ash/session/session_state_delegate.h" 12 #include "ash/session/session_state_delegate.h"
13 #include "ash/shelf/shelf_constants.h" 13 #include "ash/shelf/shelf_constants.h"
14 #include "ash/shelf/shelf_layout_manager.h" 14 #include "ash/shelf/shelf_layout_manager.h"
15 #include "ash/shelf/wm_shelf.h" 15 #include "ash/shelf/wm_shelf.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/shell_observer.h" 17 #include "ash/shell_observer.h"
18 #include "ash/shell_port.h"
18 #include "ash/test/ash_test.h" 19 #include "ash/test/ash_test.h"
19 #include "ash/wm/fullscreen_window_finder.h" 20 #include "ash/wm/fullscreen_window_finder.h"
20 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" 21 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h"
21 #include "ash/wm/window_state.h" 22 #include "ash/wm/window_state.h"
22 #include "ash/wm/wm_event.h" 23 #include "ash/wm/wm_event.h"
23 #include "ash/wm/wm_screen_util.h" 24 #include "ash/wm/wm_screen_util.h"
24 #include "ash/wm/workspace/workspace_window_resizer.h" 25 #include "ash/wm/workspace/workspace_window_resizer.h"
25 #include "ash/wm_shell.h"
26 #include "ash/wm_window.h" 26 #include "ash/wm_window.h"
27 #include "base/command_line.h" 27 #include "base/command_line.h"
28 #include "ui/base/ui_base_switches.h" 28 #include "ui/base/ui_base_switches.h"
29 #include "ui/base/ui_base_types.h" 29 #include "ui/base/ui_base_types.h"
30 #include "ui/display/display.h" 30 #include "ui/display/display.h"
31 #include "ui/display/screen.h" 31 #include "ui/display/screen.h"
32 #include "ui/gfx/geometry/insets.h" 32 #include "ui/gfx/geometry/insets.h"
33 #include "ui/keyboard/keyboard_controller.h" 33 #include "ui/keyboard/keyboard_controller.h"
34 #include "ui/keyboard/keyboard_ui.h" 34 #include "ui/keyboard/keyboard_ui.h"
35 #include "ui/keyboard/keyboard_util.h" 35 #include "ui/keyboard/keyboard_util.h"
(...skipping 14 matching lines...) Expand all
50 // keyboard is refactored to work in mash. 50 // keyboard is refactored to work in mash.
51 class WorkspaceLayoutManagerKeyboardTest : public AshTest { 51 class WorkspaceLayoutManagerKeyboardTest : public AshTest {
52 public: 52 public:
53 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} 53 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {}
54 ~WorkspaceLayoutManagerKeyboardTest() override {} 54 ~WorkspaceLayoutManagerKeyboardTest() override {}
55 55
56 void SetUp() override { 56 void SetUp() override {
57 AshTest::SetUp(); 57 AshTest::SetUp();
58 UpdateDisplay("800x600"); 58 UpdateDisplay("800x600");
59 WmWindow* default_container = 59 WmWindow* default_container =
60 WmShell::Get()->GetPrimaryRootWindowController()->GetWmContainer( 60 ShellPort::Get()->GetPrimaryRootWindowController()->GetWmContainer(
61 kShellWindowId_DefaultContainer); 61 kShellWindowId_DefaultContainer);
62 layout_manager_ = GetWorkspaceLayoutManager(default_container); 62 layout_manager_ = GetWorkspaceLayoutManager(default_container);
63 } 63 }
64 64
65 void ShowKeyboard() { 65 void ShowKeyboard() {
66 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); 66 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_);
67 restore_work_area_insets_ = 67 restore_work_area_insets_ =
68 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); 68 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets();
69 WmShell::Get()->SetDisplayWorkAreaInsets( 69 ShellPort::Get()->SetDisplayWorkAreaInsets(
70 WmShell::Get()->GetPrimaryRootWindow(), 70 ShellPort::Get()->GetPrimaryRootWindow(),
71 gfx::Insets(0, 0, keyboard_bounds_.height(), 0)); 71 gfx::Insets(0, 0, keyboard_bounds_.height(), 0));
72 } 72 }
73 73
74 void HideKeyboard() { 74 void HideKeyboard() {
75 WmShell::Get()->SetDisplayWorkAreaInsets( 75 ShellPort::Get()->SetDisplayWorkAreaInsets(
76 WmShell::Get()->GetPrimaryRootWindow(), restore_work_area_insets_); 76 ShellPort::Get()->GetPrimaryRootWindow(), restore_work_area_insets_);
77 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); 77 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect());
78 } 78 }
79 79
80 // Initializes the keyboard bounds using the bottom half of the work area. 80 // Initializes the keyboard bounds using the bottom half of the work area.
81 void InitKeyboardBounds() { 81 void InitKeyboardBounds() {
82 gfx::Rect work_area( 82 gfx::Rect work_area(
83 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 83 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
84 keyboard_bounds_.SetRect(work_area.x(), 84 keyboard_bounds_.SetRect(work_area.x(),
85 work_area.y() + work_area.height() / 2, 85 work_area.y() + work_area.height() / 2,
86 work_area.width(), work_area.height() / 2); 86 work_area.width(), work_area.height() / 2);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 CreateToplevelTestWindow(orig_window_bounds)); 118 CreateToplevelTestWindow(orig_window_bounds));
119 WmWindow* window = window_owner->window(); 119 WmWindow* window = window_owner->window();
120 120
121 window->Activate(); 121 window->Activate();
122 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 122 EXPECT_EQ(orig_window_bounds, window->GetBounds());
123 123
124 // Open keyboard in non-sticky mode. 124 // Open keyboard in non-sticky mode.
125 kb_controller->ShowKeyboard(false); 125 kb_controller->ShowKeyboard(false);
126 kb_controller->ui()->GetKeyboardWindow()->SetBounds( 126 kb_controller->ui()->GetKeyboardWindow()->SetBounds(
127 keyboard::FullWidthKeyboardBoundsFromRootBounds( 127 keyboard::FullWidthKeyboardBoundsFromRootBounds(
128 WmShell::Get()->GetPrimaryRootWindow()->GetBounds(), 100)); 128 ShellPort::Get()->GetPrimaryRootWindow()->GetBounds(), 100));
129 129
130 int shift = 130 int shift =
131 work_area.height() - kb_controller->GetContainerWindow()->bounds().y(); 131 work_area.height() - kb_controller->GetContainerWindow()->bounds().y();
132 gfx::Rect changed_window_bounds(orig_window_bounds); 132 gfx::Rect changed_window_bounds(orig_window_bounds);
133 changed_window_bounds.Offset(0, -shift); 133 changed_window_bounds.Offset(0, -shift);
134 // Window should be shifted up. 134 // Window should be shifted up.
135 EXPECT_EQ(changed_window_bounds, window->GetBounds()); 135 EXPECT_EQ(changed_window_bounds, window->GetBounds());
136 136
137 kb_controller->HideKeyboard( 137 kb_controller->HideKeyboard(
138 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); 138 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 CreateToplevelTestWindow(orig_window_bounds)); 171 CreateToplevelTestWindow(orig_window_bounds));
172 WmWindow* window = window_owner->window(); 172 WmWindow* window = window_owner->window();
173 173
174 window->Activate(); 174 window->Activate();
175 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 175 EXPECT_EQ(orig_window_bounds, window->GetBounds());
176 176
177 // Open keyboard in non-sticky mode. 177 // Open keyboard in non-sticky mode.
178 kb_controller->ShowKeyboard(false); 178 kb_controller->ShowKeyboard(false);
179 kb_controller->ui()->GetKeyboardWindow()->SetBounds( 179 kb_controller->ui()->GetKeyboardWindow()->SetBounds(
180 keyboard::FullWidthKeyboardBoundsFromRootBounds( 180 keyboard::FullWidthKeyboardBoundsFromRootBounds(
181 WmShell::Get()->GetPrimaryRootWindow()->GetBounds(), 100)); 181 ShellPort::Get()->GetPrimaryRootWindow()->GetBounds(), 100));
182 182
183 // Window should not be shifted up. 183 // Window should not be shifted up.
184 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 184 EXPECT_EQ(orig_window_bounds, window->GetBounds());
185 185
186 kb_controller->HideKeyboard( 186 kb_controller->HideKeyboard(
187 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); 187 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
188 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 188 EXPECT_EQ(orig_window_bounds, window->GetBounds());
189 189
190 // Open keyboard in sticky mode. 190 // Open keyboard in sticky mode.
191 kb_controller->ShowKeyboard(true); 191 kb_controller->ShowKeyboard(true);
192 192
193 int shift = 193 int shift =
194 work_area.height() - kb_controller->GetContainerWindow()->bounds().y(); 194 work_area.height() - kb_controller->GetContainerWindow()->bounds().y();
195 gfx::Rect changed_window_bounds(orig_window_bounds); 195 gfx::Rect changed_window_bounds(orig_window_bounds);
196 changed_window_bounds.Offset(0, -shift); 196 changed_window_bounds.Offset(0, -shift);
197 // Window should be shifted up. 197 // Window should be shifted up.
198 EXPECT_EQ(changed_window_bounds, window->GetBounds()); 198 EXPECT_EQ(changed_window_bounds, window->GetBounds());
199 199
200 kb_controller->HideKeyboard( 200 kb_controller->HideKeyboard(
201 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); 201 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
202 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 202 EXPECT_EQ(orig_window_bounds, window->GetBounds());
203 } 203 }
204 204
205 } // namespace ash 205 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698