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

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

Issue 2808723004: Renames WmShell to ShellPort (Closed)
Patch Set: feedback 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 12 matching lines...) Expand all
48 48
49 class WorkspaceLayoutManagerKeyboardTest : public AshTest { 49 class WorkspaceLayoutManagerKeyboardTest : public AshTest {
50 public: 50 public:
51 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} 51 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {}
52 ~WorkspaceLayoutManagerKeyboardTest() override {} 52 ~WorkspaceLayoutManagerKeyboardTest() override {}
53 53
54 void SetUp() override { 54 void SetUp() override {
55 AshTest::SetUp(); 55 AshTest::SetUp();
56 UpdateDisplay("800x600"); 56 UpdateDisplay("800x600");
57 WmWindow* default_container = 57 WmWindow* default_container =
58 WmShell::Get()->GetPrimaryRootWindowController()->GetWmContainer( 58 ShellPort::Get()->GetPrimaryRootWindowController()->GetWmContainer(
59 kShellWindowId_DefaultContainer); 59 kShellWindowId_DefaultContainer);
60 layout_manager_ = GetWorkspaceLayoutManager(default_container); 60 layout_manager_ = GetWorkspaceLayoutManager(default_container);
61 } 61 }
62 62
63 void ShowKeyboard() { 63 void ShowKeyboard() {
64 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); 64 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_);
65 restore_work_area_insets_ = 65 restore_work_area_insets_ =
66 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets(); 66 display::Screen::GetScreen()->GetPrimaryDisplay().GetWorkAreaInsets();
67 WmShell::Get()->SetDisplayWorkAreaInsets( 67 ShellPort::Get()->SetDisplayWorkAreaInsets(
68 WmShell::Get()->GetPrimaryRootWindow(), 68 ShellPort::Get()->GetPrimaryRootWindow(),
69 gfx::Insets(0, 0, keyboard_bounds_.height(), 0)); 69 gfx::Insets(0, 0, keyboard_bounds_.height(), 0));
70 } 70 }
71 71
72 void HideKeyboard() { 72 void HideKeyboard() {
73 WmShell::Get()->SetDisplayWorkAreaInsets( 73 ShellPort::Get()->SetDisplayWorkAreaInsets(
74 WmShell::Get()->GetPrimaryRootWindow(), restore_work_area_insets_); 74 ShellPort::Get()->GetPrimaryRootWindow(), restore_work_area_insets_);
75 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect()); 75 layout_manager_->OnKeyboardBoundsChanging(gfx::Rect());
76 } 76 }
77 77
78 // Initializes the keyboard bounds using the bottom half of the work area. 78 // Initializes the keyboard bounds using the bottom half of the work area.
79 void InitKeyboardBounds() { 79 void InitKeyboardBounds() {
80 gfx::Rect work_area( 80 gfx::Rect work_area(
81 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 81 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
82 keyboard_bounds_.SetRect(work_area.x(), 82 keyboard_bounds_.SetRect(work_area.x(),
83 work_area.y() + work_area.height() / 2, 83 work_area.y() + work_area.height() / 2,
84 work_area.width(), work_area.height() / 2); 84 work_area.width(), work_area.height() / 2);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 CreateToplevelTestWindow(orig_window_bounds)); 116 CreateToplevelTestWindow(orig_window_bounds));
117 WmWindow* window = window_owner->window(); 117 WmWindow* window = window_owner->window();
118 118
119 window->Activate(); 119 window->Activate();
120 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 120 EXPECT_EQ(orig_window_bounds, window->GetBounds());
121 121
122 // Open keyboard in non-sticky mode. 122 // Open keyboard in non-sticky mode.
123 kb_controller->ShowKeyboard(false); 123 kb_controller->ShowKeyboard(false);
124 kb_controller->ui()->GetKeyboardWindow()->SetBounds( 124 kb_controller->ui()->GetKeyboardWindow()->SetBounds(
125 keyboard::FullWidthKeyboardBoundsFromRootBounds( 125 keyboard::FullWidthKeyboardBoundsFromRootBounds(
126 WmShell::Get()->GetPrimaryRootWindow()->GetBounds(), 100)); 126 ShellPort::Get()->GetPrimaryRootWindow()->GetBounds(), 100));
127 127
128 int shift = 128 int shift =
129 work_area.height() - kb_controller->GetContainerWindow()->bounds().y(); 129 work_area.height() - kb_controller->GetContainerWindow()->bounds().y();
130 gfx::Rect changed_window_bounds(orig_window_bounds); 130 gfx::Rect changed_window_bounds(orig_window_bounds);
131 changed_window_bounds.Offset(0, -shift); 131 changed_window_bounds.Offset(0, -shift);
132 // Window should be shifted up. 132 // Window should be shifted up.
133 EXPECT_EQ(changed_window_bounds, window->GetBounds()); 133 EXPECT_EQ(changed_window_bounds, window->GetBounds());
134 134
135 kb_controller->HideKeyboard( 135 kb_controller->HideKeyboard(
136 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); 136 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 CreateToplevelTestWindow(orig_window_bounds)); 169 CreateToplevelTestWindow(orig_window_bounds));
170 WmWindow* window = window_owner->window(); 170 WmWindow* window = window_owner->window();
171 171
172 window->Activate(); 172 window->Activate();
173 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 173 EXPECT_EQ(orig_window_bounds, window->GetBounds());
174 174
175 // Open keyboard in non-sticky mode. 175 // Open keyboard in non-sticky mode.
176 kb_controller->ShowKeyboard(false); 176 kb_controller->ShowKeyboard(false);
177 kb_controller->ui()->GetKeyboardWindow()->SetBounds( 177 kb_controller->ui()->GetKeyboardWindow()->SetBounds(
178 keyboard::FullWidthKeyboardBoundsFromRootBounds( 178 keyboard::FullWidthKeyboardBoundsFromRootBounds(
179 WmShell::Get()->GetPrimaryRootWindow()->GetBounds(), 100)); 179 ShellPort::Get()->GetPrimaryRootWindow()->GetBounds(), 100));
180 180
181 // Window should not be shifted up. 181 // Window should not be shifted up.
182 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 182 EXPECT_EQ(orig_window_bounds, window->GetBounds());
183 183
184 kb_controller->HideKeyboard( 184 kb_controller->HideKeyboard(
185 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); 185 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
186 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 186 EXPECT_EQ(orig_window_bounds, window->GetBounds());
187 187
188 // Open keyboard in sticky mode. 188 // Open keyboard in sticky mode.
189 kb_controller->ShowKeyboard(true); 189 kb_controller->ShowKeyboard(true);
190 190
191 int shift = 191 int shift =
192 work_area.height() - kb_controller->GetContainerWindow()->bounds().y(); 192 work_area.height() - kb_controller->GetContainerWindow()->bounds().y();
193 gfx::Rect changed_window_bounds(orig_window_bounds); 193 gfx::Rect changed_window_bounds(orig_window_bounds);
194 changed_window_bounds.Offset(0, -shift); 194 changed_window_bounds.Offset(0, -shift);
195 // Window should be shifted up. 195 // Window should be shifted up.
196 EXPECT_EQ(changed_window_bounds, window->GetBounds()); 196 EXPECT_EQ(changed_window_bounds, window->GetBounds());
197 197
198 kb_controller->HideKeyboard( 198 kb_controller->HideKeyboard(
199 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); 199 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
200 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 200 EXPECT_EQ(orig_window_bounds, window->GetBounds());
201 } 201 }
202 202
203 } // namespace ash 203 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698