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

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

Issue 2847283002: chromeos: convert remaining AshTest usage to AshTestBase (Closed)
Patch Set: comment Created 3 years, 7 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
« no previous file with comments | « ash/window_user_data_unittest.cc ('k') | ash/wm/workspace/workspace_layout_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/shell_port.h"
19 #include "ash/test/ash_test.h" 19 #include "ash/test/ash_test_base.h"
20 #include "ash/wm/fullscreen_window_finder.h" 20 #include "ash/wm/fullscreen_window_finder.h"
21 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h" 21 #include "ash/wm/maximize_mode/workspace_backdrop_delegate.h"
22 #include "ash/wm/window_state.h" 22 #include "ash/wm/window_state.h"
23 #include "ash/wm/window_util.h"
23 #include "ash/wm/wm_event.h" 24 #include "ash/wm/wm_event.h"
24 #include "ash/wm/wm_screen_util.h" 25 #include "ash/wm/wm_screen_util.h"
25 #include "ash/wm/workspace/workspace_window_resizer.h" 26 #include "ash/wm/workspace/workspace_window_resizer.h"
26 #include "ash/wm_window.h" 27 #include "ash/wm_window.h"
27 #include "base/command_line.h" 28 #include "base/command_line.h"
28 #include "ui/base/ui_base_switches.h" 29 #include "ui/base/ui_base_switches.h"
29 #include "ui/base/ui_base_types.h" 30 #include "ui/base/ui_base_types.h"
30 #include "ui/display/display.h" 31 #include "ui/display/display.h"
31 #include "ui/display/screen.h" 32 #include "ui/display/screen.h"
32 #include "ui/gfx/geometry/insets.h" 33 #include "ui/gfx/geometry/insets.h"
33 #include "ui/keyboard/keyboard_controller.h" 34 #include "ui/keyboard/keyboard_controller.h"
34 #include "ui/keyboard/keyboard_ui.h" 35 #include "ui/keyboard/keyboard_ui.h"
35 #include "ui/keyboard/keyboard_util.h" 36 #include "ui/keyboard/keyboard_util.h"
36 #include "ui/views/widget/widget.h" 37 #include "ui/views/widget/widget.h"
37 #include "ui/views/widget/widget_delegate.h" 38 #include "ui/views/widget/widget_delegate.h"
38 #include "ui/wm/core/window_util.h" 39 #include "ui/wm/core/window_util.h"
39 40
40 namespace ash { 41 namespace ash {
41 namespace { 42 namespace {
42 43
43 WorkspaceLayoutManager* GetWorkspaceLayoutManager(WmWindow* container) { 44 WorkspaceLayoutManager* GetWorkspaceLayoutManager(WmWindow* container) {
44 return static_cast<WorkspaceLayoutManager*>(container->GetLayoutManager()); 45 return static_cast<WorkspaceLayoutManager*>(container->GetLayoutManager());
45 } 46 }
46 47
47 } // namespace 48 } // namespace
48 49
49 class WorkspaceLayoutManagerKeyboardTest : public AshTest { 50 class WorkspaceLayoutManagerKeyboardTest2 : public test::AshTestBase {
50 public: 51 public:
51 WorkspaceLayoutManagerKeyboardTest() : layout_manager_(nullptr) {} 52 WorkspaceLayoutManagerKeyboardTest2() : layout_manager_(nullptr) {}
52 ~WorkspaceLayoutManagerKeyboardTest() override {} 53 ~WorkspaceLayoutManagerKeyboardTest2() override {}
53 54
54 void SetUp() override { 55 void SetUp() override {
55 AshTest::SetUp(); 56 test::AshTestBase::SetUp();
56 UpdateDisplay("800x600"); 57 UpdateDisplay("800x600");
57 WmWindow* default_container = 58 WmWindow* default_container =
58 ShellPort::Get()->GetPrimaryRootWindowController()->GetWmContainer( 59 ShellPort::Get()->GetPrimaryRootWindowController()->GetWmContainer(
59 kShellWindowId_DefaultContainer); 60 kShellWindowId_DefaultContainer);
60 layout_manager_ = GetWorkspaceLayoutManager(default_container); 61 layout_manager_ = GetWorkspaceLayoutManager(default_container);
61 } 62 }
62 63
63 void ShowKeyboard() { 64 void ShowKeyboard() {
64 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_); 65 layout_manager_->OnKeyboardBoundsChanging(keyboard_bounds_);
65 restore_work_area_insets_ = 66 restore_work_area_insets_ =
(...skipping 24 matching lines...) Expand all
90 command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior); 91 command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior);
91 } 92 }
92 93
93 const gfx::Rect& keyboard_bounds() const { return keyboard_bounds_; } 94 const gfx::Rect& keyboard_bounds() const { return keyboard_bounds_; }
94 95
95 private: 96 private:
96 gfx::Insets restore_work_area_insets_; 97 gfx::Insets restore_work_area_insets_;
97 gfx::Rect keyboard_bounds_; 98 gfx::Rect keyboard_bounds_;
98 WorkspaceLayoutManager* layout_manager_; 99 WorkspaceLayoutManager* layout_manager_;
99 100
100 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); 101 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest2);
101 }; 102 };
102 103
103 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChangeWorkAreaInNonStickyMode) { 104 TEST_F(WorkspaceLayoutManagerKeyboardTest2, ChangeWorkAreaInNonStickyMode) {
104 keyboard::SetAccessibilityKeyboardEnabled(true); 105 keyboard::SetAccessibilityKeyboardEnabled(true);
105 InitKeyboardBounds(); 106 InitKeyboardBounds();
106 Shell::Get()->CreateKeyboard(); 107 Shell::Get()->CreateKeyboard();
107 keyboard::KeyboardController* kb_controller = 108 keyboard::KeyboardController* kb_controller =
108 keyboard::KeyboardController::GetInstance(); 109 keyboard::KeyboardController::GetInstance();
109 110
110 gfx::Rect work_area( 111 gfx::Rect work_area(
111 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 112 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
112 113
113 gfx::Rect orig_window_bounds(0, 100, work_area.width(), 114 gfx::Rect orig_window_bounds(0, 100, work_area.width(),
114 work_area.height() - 100); 115 work_area.height() - 100);
115 std::unique_ptr<WindowOwner> window_owner( 116 std::unique_ptr<aura::Window> window(
116 CreateToplevelTestWindow(orig_window_bounds)); 117 CreateToplevelTestWindow(orig_window_bounds));
117 WmWindow* window = window_owner->window();
118 118
119 window->Activate(); 119 wm::ActivateWindow(window.get());
120 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 120 EXPECT_EQ(orig_window_bounds, window->bounds());
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 ShellPort::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->bounds());
134 134
135 kb_controller->HideKeyboard( 135 kb_controller->HideKeyboard(
136 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); 136 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
137 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 137 EXPECT_EQ(orig_window_bounds, window->bounds());
138 138
139 // Open keyboard in sticky mode. 139 // Open keyboard in sticky mode.
140 kb_controller->ShowKeyboard(true); 140 kb_controller->ShowKeyboard(true);
141 141
142 // Window should be shifted up. 142 // Window should be shifted up.
143 EXPECT_EQ(changed_window_bounds, window->GetBounds()); 143 EXPECT_EQ(changed_window_bounds, window->bounds());
144 144
145 kb_controller->HideKeyboard( 145 kb_controller->HideKeyboard(
146 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); 146 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
147 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 147 EXPECT_EQ(orig_window_bounds, window->bounds());
148 } 148 }
149 149
150 // When kAshUseNewVKWindowBehavior flag enabled, do not change accessibility 150 // When kAshUseNewVKWindowBehavior flag enabled, do not change accessibility
151 // keyboard work area in non-sticky mode. 151 // keyboard work area in non-sticky mode.
152 TEST_F(WorkspaceLayoutManagerKeyboardTest, 152 TEST_F(WorkspaceLayoutManagerKeyboardTest2,
153 IgnoreWorkAreaChangeinNonStickyMode) { 153 IgnoreWorkAreaChangeinNonStickyMode) {
154 // Append flag to ignore work area change in non-sticky mode. 154 // Append flag to ignore work area change in non-sticky mode.
155 EnableNewVKMode(); 155 EnableNewVKMode();
156 156
157 keyboard::SetAccessibilityKeyboardEnabled(true); 157 keyboard::SetAccessibilityKeyboardEnabled(true);
158 InitKeyboardBounds(); 158 InitKeyboardBounds();
159 Shell::Get()->CreateKeyboard(); 159 Shell::Get()->CreateKeyboard();
160 keyboard::KeyboardController* kb_controller = 160 keyboard::KeyboardController* kb_controller =
161 keyboard::KeyboardController::GetInstance(); 161 keyboard::KeyboardController::GetInstance();
162 162
163 gfx::Rect work_area( 163 gfx::Rect work_area(
164 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); 164 display::Screen::GetScreen()->GetPrimaryDisplay().work_area());
165 165
166 gfx::Rect orig_window_bounds(0, 100, work_area.width(), 166 gfx::Rect orig_window_bounds(0, 100, work_area.width(),
167 work_area.height() - 100); 167 work_area.height() - 100);
168 std::unique_ptr<WindowOwner> window_owner( 168 std::unique_ptr<aura::Window> window(
169 CreateToplevelTestWindow(orig_window_bounds)); 169 CreateToplevelTestWindow(orig_window_bounds));
170 WmWindow* window = window_owner->window();
171 170
172 window->Activate(); 171 wm::ActivateWindow(window.get());
173 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 172 EXPECT_EQ(orig_window_bounds, window->bounds());
174 173
175 // Open keyboard in non-sticky mode. 174 // Open keyboard in non-sticky mode.
176 kb_controller->ShowKeyboard(false); 175 kb_controller->ShowKeyboard(false);
177 kb_controller->ui()->GetKeyboardWindow()->SetBounds( 176 kb_controller->ui()->GetKeyboardWindow()->SetBounds(
178 keyboard::FullWidthKeyboardBoundsFromRootBounds( 177 keyboard::FullWidthKeyboardBoundsFromRootBounds(
179 ShellPort::Get()->GetPrimaryRootWindow()->GetBounds(), 100)); 178 ShellPort::Get()->GetPrimaryRootWindow()->GetBounds(), 100));
180 179
181 // Window should not be shifted up. 180 // Window should not be shifted up.
182 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 181 EXPECT_EQ(orig_window_bounds, window->bounds());
183 182
184 kb_controller->HideKeyboard( 183 kb_controller->HideKeyboard(
185 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); 184 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
186 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 185 EXPECT_EQ(orig_window_bounds, window->bounds());
187 186
188 // Open keyboard in sticky mode. 187 // Open keyboard in sticky mode.
189 kb_controller->ShowKeyboard(true); 188 kb_controller->ShowKeyboard(true);
190 189
191 int shift = 190 int shift =
192 work_area.height() - kb_controller->GetContainerWindow()->bounds().y(); 191 work_area.height() - kb_controller->GetContainerWindow()->bounds().y();
193 gfx::Rect changed_window_bounds(orig_window_bounds); 192 gfx::Rect changed_window_bounds(orig_window_bounds);
194 changed_window_bounds.Offset(0, -shift); 193 changed_window_bounds.Offset(0, -shift);
195 // Window should be shifted up. 194 // Window should be shifted up.
196 EXPECT_EQ(changed_window_bounds, window->GetBounds()); 195 EXPECT_EQ(changed_window_bounds, window->bounds());
197 196
198 kb_controller->HideKeyboard( 197 kb_controller->HideKeyboard(
199 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC); 198 keyboard::KeyboardController::HIDE_REASON_AUTOMATIC);
200 EXPECT_EQ(orig_window_bounds, window->GetBounds()); 199 EXPECT_EQ(orig_window_bounds, window->bounds());
201 } 200 }
202 201
203 } // namespace ash 202 } // namespace ash
OLDNEW
« no previous file with comments | « ash/window_user_data_unittest.cc ('k') | ash/wm/workspace/workspace_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698