Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/config.h" | 10 #include "ash/public/cpp/config.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 int call_count_; | 96 int call_count_; |
| 97 bool is_fullscreen_; | 97 bool is_fullscreen_; |
| 98 | 98 |
| 99 DISALLOW_COPY_AND_ASSIGN(TestShellObserver); | 99 DISALLOW_COPY_AND_ASSIGN(TestShellObserver); |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 display::Display GetDisplayNearestWindow(aura::Window* window) { | 102 display::Display GetDisplayNearestWindow(aura::Window* window) { |
| 103 return display::Screen::GetScreen()->GetDisplayNearestWindow(window); | 103 return display::Screen::GetScreen()->GetDisplayNearestWindow(window); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void DisableNewVKMode() { | |
| 107 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 108 if (!command_line->HasSwitch(::switches::kDisableNewVirtualKeyboardBehavior)) | |
|
oshima
2017/05/16 12:31:30
you can just add it
yhanada
2017/05/17 01:33:37
Done.
| |
| 109 command_line->AppendSwitch(::switches::kDisableNewVirtualKeyboardBehavior); | |
| 110 } | |
| 111 | |
| 106 } // namespace | 112 } // namespace |
| 107 | 113 |
| 108 using WorkspaceLayoutManagerTest = test::AshTestBase; | 114 using WorkspaceLayoutManagerTest = test::AshTestBase; |
| 109 | 115 |
| 110 // Verifies that a window containing a restore coordinate will be restored to | 116 // Verifies that a window containing a restore coordinate will be restored to |
| 111 // to the size prior to minimize, keeping the restore rectangle in tact (if | 117 // to the size prior to minimize, keeping the restore rectangle in tact (if |
| 112 // there is one). | 118 // there is one). |
| 113 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { | 119 TEST_F(WorkspaceLayoutManagerTest, RestoreFromMinimizeKeepsRestore) { |
| 114 // See comment at top of file for why this is needed. | 120 // See comment at top of file for why this is needed. |
| 115 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; | 121 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1149 | 1155 |
| 1150 // Initializes the keyboard bounds using the bottom half of the work area. | 1156 // Initializes the keyboard bounds using the bottom half of the work area. |
| 1151 void InitKeyboardBounds() { | 1157 void InitKeyboardBounds() { |
| 1152 gfx::Rect work_area( | 1158 gfx::Rect work_area( |
| 1153 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1159 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 1154 keyboard_bounds_.SetRect(work_area.x(), | 1160 keyboard_bounds_.SetRect(work_area.x(), |
| 1155 work_area.y() + work_area.height() / 2, | 1161 work_area.y() + work_area.height() / 2, |
| 1156 work_area.width(), work_area.height() / 2); | 1162 work_area.width(), work_area.height() / 2); |
| 1157 } | 1163 } |
| 1158 | 1164 |
| 1159 void EnableNewVKMode() { | |
| 1160 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | |
| 1161 if (!command_line->HasSwitch(::switches::kUseNewVirtualKeyboardBehavior)) | |
| 1162 command_line->AppendSwitch(::switches::kUseNewVirtualKeyboardBehavior); | |
| 1163 } | |
| 1164 | |
| 1165 const gfx::Rect& keyboard_bounds() const { return keyboard_bounds_; } | 1165 const gfx::Rect& keyboard_bounds() const { return keyboard_bounds_; } |
| 1166 | 1166 |
| 1167 private: | 1167 private: |
| 1168 gfx::Insets restore_work_area_insets_; | 1168 gfx::Insets restore_work_area_insets_; |
| 1169 gfx::Rect keyboard_bounds_; | 1169 gfx::Rect keyboard_bounds_; |
| 1170 WorkspaceLayoutManager* layout_manager_; | 1170 WorkspaceLayoutManager* layout_manager_; |
| 1171 | 1171 |
| 1172 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); | 1172 DISALLOW_COPY_AND_ASSIGN(WorkspaceLayoutManagerKeyboardTest); |
| 1173 }; | 1173 }; |
| 1174 | 1174 |
| 1175 // Tests that when a child window gains focus the top level window containing it | 1175 // Tests that when a child window gains focus the top level window containing it |
| 1176 // is resized to fit the remaining workspace area. | 1176 // is resized to fit the remaining workspace area. |
| 1177 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) { | 1177 TEST_F(WorkspaceLayoutManagerKeyboardTest, ChildWindowFocused) { |
| 1178 // Append the flag to cause work area change in non-sticky mode. | |
| 1179 DisableNewVKMode(); | |
| 1180 | |
| 1178 // See comment at top of file for why this is needed. | 1181 // See comment at top of file for why this is needed. |
| 1179 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; | 1182 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; |
| 1180 | 1183 |
| 1181 InitKeyboardBounds(); | 1184 InitKeyboardBounds(); |
| 1182 | 1185 |
| 1183 gfx::Rect work_area( | 1186 gfx::Rect work_area( |
| 1184 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1187 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 1185 | 1188 |
| 1186 std::unique_ptr<aura::Window> parent_window( | 1189 std::unique_ptr<aura::Window> parent_window( |
| 1187 CreateToplevelTestWindow(work_area)); | 1190 CreateToplevelTestWindow(work_area)); |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 1200 parent_window->bounds().ToString()); | 1203 parent_window->bounds().ToString()); |
| 1201 ShowKeyboard(); | 1204 ShowKeyboard(); |
| 1202 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), | 1205 EXPECT_EQ(gfx::Rect(50, 0, 100, available_height).ToString(), |
| 1203 parent_window->bounds().ToString()); | 1206 parent_window->bounds().ToString()); |
| 1204 HideKeyboard(); | 1207 HideKeyboard(); |
| 1205 EXPECT_EQ(initial_window_bounds.ToString(), | 1208 EXPECT_EQ(initial_window_bounds.ToString(), |
| 1206 parent_window->bounds().ToString()); | 1209 parent_window->bounds().ToString()); |
| 1207 } | 1210 } |
| 1208 | 1211 |
| 1209 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) { | 1212 TEST_F(WorkspaceLayoutManagerKeyboardTest, AdjustWindowForA11yKeyboard) { |
| 1213 // Append the flag to cause work area change in non-sticky mode. | |
| 1214 DisableNewVKMode(); | |
| 1215 | |
| 1210 // See comment at top of file for why this is needed. | 1216 // See comment at top of file for why this is needed. |
| 1211 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; | 1217 WmWindowTestApi::GlobalMinimumSizeLock min_size_lock; |
| 1212 InitKeyboardBounds(); | 1218 InitKeyboardBounds(); |
| 1213 gfx::Rect work_area( | 1219 gfx::Rect work_area( |
| 1214 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); | 1220 display::Screen::GetScreen()->GetPrimaryDisplay().work_area()); |
| 1215 | 1221 |
| 1216 std::unique_ptr<aura::Window> window(CreateToplevelTestWindow(work_area)); | 1222 std::unique_ptr<aura::Window> window(CreateToplevelTestWindow(work_area)); |
| 1217 // The additional SetBounds() is needed as the aura-mus case uses Widget, | 1223 // The additional SetBounds() is needed as the aura-mus case uses Widget, |
| 1218 // which alters the supplied bounds. | 1224 // which alters the supplied bounds. |
| 1219 window->SetBounds(work_area); | 1225 window->SetBounds(work_area); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1252 EXPECT_EQ( | 1258 EXPECT_EQ( |
| 1253 gfx::Rect(50, keyboard_bounds().y() - keyboard_bounds().height() / 2, | 1259 gfx::Rect(50, keyboard_bounds().y() - keyboard_bounds().height() / 2, |
| 1254 occluded_window_bounds.width(), occluded_window_bounds.height()) | 1260 occluded_window_bounds.width(), occluded_window_bounds.height()) |
| 1255 .ToString(), | 1261 .ToString(), |
| 1256 window->bounds().ToString()); | 1262 window->bounds().ToString()); |
| 1257 HideKeyboard(); | 1263 HideKeyboard(); |
| 1258 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); | 1264 EXPECT_EQ(occluded_window_bounds.ToString(), window->bounds().ToString()); |
| 1259 } | 1265 } |
| 1260 | 1266 |
| 1261 TEST_F(WorkspaceLayoutManagerKeyboardTest, IgnoreKeyboardBoundsChange) { | 1267 TEST_F(WorkspaceLayoutManagerKeyboardTest, IgnoreKeyboardBoundsChange) { |
| 1268 // Append the flag to cause work area change in non-sticky mode. | |
| 1269 DisableNewVKMode(); | |
| 1262 InitKeyboardBounds(); | 1270 InitKeyboardBounds(); |
| 1263 | 1271 |
| 1264 std::unique_ptr<aura::Window> window(CreateTestWindow(keyboard_bounds())); | 1272 std::unique_ptr<aura::Window> window(CreateTestWindow(keyboard_bounds())); |
| 1265 // The additional SetBounds() is needed as the aura-mus case uses Widget, | 1273 // The additional SetBounds() is needed as the aura-mus case uses Widget, |
| 1266 // which alters the supplied bounds. | 1274 // which alters the supplied bounds. |
| 1267 window->SetBounds(keyboard_bounds()); | 1275 window->SetBounds(keyboard_bounds()); |
| 1268 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); | 1276 wm::GetWindowState(window.get())->set_ignore_keyboard_bounds_change(true); |
| 1269 wm::ActivateWindow(window.get()); | 1277 wm::ActivateWindow(window.get()); |
| 1270 | 1278 |
| 1271 EXPECT_EQ(keyboard_bounds(), window->bounds()); | 1279 EXPECT_EQ(keyboard_bounds(), window->bounds()); |
| 1272 ShowKeyboard(); | 1280 ShowKeyboard(); |
| 1273 EXPECT_EQ(keyboard_bounds(), window->bounds()); | 1281 EXPECT_EQ(keyboard_bounds(), window->bounds()); |
| 1274 } | 1282 } |
| 1275 | 1283 |
| 1276 } // namespace ash | 1284 } // namespace ash |
| OLD | NEW |