OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/panels/panel_window_resizer.h" | 5 #include "ash/wm/panels/panel_window_resizer.h" |
6 | 6 |
| 7 #include "ash/public/cpp/config.h" |
7 #include "ash/public/cpp/shelf_types.h" | 8 #include "ash/public/cpp/shelf_types.h" |
8 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
9 #include "ash/public/cpp/window_properties.h" | 10 #include "ash/public/cpp/window_properties.h" |
10 #include "ash/root_window_controller.h" | 11 #include "ash/root_window_controller.h" |
11 #include "ash/shelf/shelf_layout_manager.h" | 12 #include "ash/shelf/shelf_layout_manager.h" |
12 #include "ash/shelf/shelf_model.h" | 13 #include "ash/shelf/shelf_model.h" |
13 #include "ash/shelf/shelf_widget.h" | 14 #include "ash/shelf/shelf_widget.h" |
14 #include "ash/shelf/wm_shelf.h" | 15 #include "ash/shelf/wm_shelf.h" |
15 #include "ash/shell.h" | 16 #include "ash/shell.h" |
16 #include "ash/shell_port.h" | 17 #include "ash/shell_port.h" |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 ui::wm::WindowType transient_window_type_; | 219 ui::wm::WindowType transient_window_type_; |
219 | 220 |
220 private: | 221 private: |
221 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTransientTest); | 222 DISALLOW_COPY_AND_ASSIGN(PanelWindowResizerTransientTest); |
222 }; | 223 }; |
223 | 224 |
224 // Verifies a window can be dragged from the panel and detached and then | 225 // Verifies a window can be dragged from the panel and detached and then |
225 // reattached. | 226 // reattached. |
226 TEST_F(PanelWindowResizerTest, PanelDetachReattachBottom) { | 227 TEST_F(PanelWindowResizerTest, PanelDetachReattachBottom) { |
227 // TODO: investigate failure. http://crbug.com/698888. | 228 // TODO: investigate failure. http://crbug.com/698888. |
228 if (ShellPort::Get()->IsRunningInMash()) | 229 if (Shell::GetAshConfig() == Config::MASH) |
229 return; | 230 return; |
230 | 231 |
231 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 232 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
232 DetachReattachTest(window.get(), 0, -1); | 233 DetachReattachTest(window.get(), 0, -1); |
233 } | 234 } |
234 | 235 |
235 TEST_F(PanelWindowResizerTest, PanelDetachReattachLeft) { | 236 TEST_F(PanelWindowResizerTest, PanelDetachReattachLeft) { |
236 // TODO: investigate failure. http://crbug.com/698888. | 237 // TODO: investigate failure. http://crbug.com/698888. |
237 if (ShellPort::Get()->IsRunningInMash()) | 238 if (Shell::GetAshConfig() == Config::MASH) |
238 return; | 239 return; |
239 | 240 |
240 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT); | 241 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT); |
241 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 242 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
242 DetachReattachTest(window.get(), 1, 0); | 243 DetachReattachTest(window.get(), 1, 0); |
243 } | 244 } |
244 | 245 |
245 TEST_F(PanelWindowResizerTest, PanelDetachReattachRight) { | 246 TEST_F(PanelWindowResizerTest, PanelDetachReattachRight) { |
246 // TODO: investigate failure. http://crbug.com/698888. | 247 // TODO: investigate failure. http://crbug.com/698888. |
247 if (ShellPort::Get()->IsRunningInMash()) | 248 if (Shell::GetAshConfig() == Config::MASH) |
248 return; | 249 return; |
249 | 250 |
250 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 251 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
251 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 252 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
252 DetachReattachTest(window.get(), -1, 0); | 253 DetachReattachTest(window.get(), -1, 0); |
253 } | 254 } |
254 | 255 |
255 // Tests that a drag continues when the shelf is hidden. This occurs as part of | 256 // Tests that a drag continues when the shelf is hidden. This occurs as part of |
256 // the animation when switching profiles. http://crbug.com/393047. | 257 // the animation when switching profiles. http://crbug.com/393047. |
257 TEST_F(PanelWindowResizerTest, DetachThenHideShelf) { | 258 TEST_F(PanelWindowResizerTest, DetachThenHideShelf) { |
(...skipping 17 matching lines...) Expand all Loading... |
275 | 276 |
276 // When the drag ends the window should be detached and placed where it was | 277 // When the drag ends the window should be detached and placed where it was |
277 // dragged to. | 278 // dragged to. |
278 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 279 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
279 EXPECT_FALSE(state->IsMinimized()); | 280 EXPECT_FALSE(state->IsMinimized()); |
280 EXPECT_EQ(expected_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 281 EXPECT_EQ(expected_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
281 } | 282 } |
282 | 283 |
283 TEST_F(PanelWindowResizerTest, PanelDetachReattachMultipleDisplays) { | 284 TEST_F(PanelWindowResizerTest, PanelDetachReattachMultipleDisplays) { |
284 // TODO: investigate failure. http://crbug.com/698888. | 285 // TODO: investigate failure. http://crbug.com/698888. |
285 if (ShellPort::Get()->IsRunningInMash()) | 286 if (Shell::GetAshConfig() == Config::MASH) |
286 return; | 287 return; |
287 | 288 |
288 UpdateDisplay("600x400,600x400"); | 289 UpdateDisplay("600x400,600x400"); |
289 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 290 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
290 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(600, 0))); | 291 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(600, 0))); |
291 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 292 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
292 DetachReattachTest(window.get(), 0, -1); | 293 DetachReattachTest(window.get(), 0, -1); |
293 } | 294 } |
294 | 295 |
295 TEST_F(PanelWindowResizerTest, DetachThenDragAcrossDisplays) { | 296 TEST_F(PanelWindowResizerTest, DetachThenDragAcrossDisplays) { |
296 // TODO: investigate failure. http://crbug.com/698888. | 297 // TODO: investigate failure. http://crbug.com/698888. |
297 if (ShellPort::Get()->IsRunningInMash()) | 298 if (Shell::GetAshConfig() == Config::MASH) |
298 return; | 299 return; |
299 | 300 |
300 UpdateDisplay("600x400,600x400"); | 301 UpdateDisplay("600x400,600x400"); |
301 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 302 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
302 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 303 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
303 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 304 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
304 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 305 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
305 DragStart(window.get()); | 306 DragStart(window.get()); |
306 DragMove(0, -100); | 307 DragMove(0, -100); |
307 DragEnd(); | 308 DragEnd(); |
308 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 309 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
309 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); | 310 EXPECT_EQ(initial_bounds.x(), window->GetBoundsInScreen().x()); |
310 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); | 311 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); |
311 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); | 312 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); |
312 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 313 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
313 | 314 |
314 DragStart(window.get()); | 315 DragStart(window.get()); |
315 DragMove(500, 0); | 316 DragMove(500, 0); |
316 DragEnd(); | 317 DragEnd(); |
317 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 318 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
318 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 319 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
319 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); | 320 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); |
320 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); | 321 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); |
321 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 322 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
322 } | 323 } |
323 | 324 |
324 TEST_F(PanelWindowResizerTest, DetachAcrossDisplays) { | 325 TEST_F(PanelWindowResizerTest, DetachAcrossDisplays) { |
325 // TODO: investigate failure. http://crbug.com/698888. | 326 // TODO: investigate failure. http://crbug.com/698888. |
326 if (ShellPort::Get()->IsRunningInMash()) | 327 if (Shell::GetAshConfig() == Config::MASH) |
327 return; | 328 return; |
328 | 329 |
329 UpdateDisplay("600x400,600x400"); | 330 UpdateDisplay("600x400,600x400"); |
330 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 331 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
331 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 332 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
332 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 333 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
333 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 334 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
334 DragStart(window.get()); | 335 DragStart(window.get()); |
335 DragMove(500, -100); | 336 DragMove(500, -100); |
336 DragEnd(); | 337 DragEnd(); |
337 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 338 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
338 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 339 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
339 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); | 340 EXPECT_EQ(initial_bounds.y() - 100, window->GetBoundsInScreen().y()); |
340 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); | 341 EXPECT_FALSE(window->GetProperty(kPanelAttachedKey)); |
341 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); | 342 EXPECT_EQ(kShellWindowId_DefaultContainer, window->parent()->id()); |
342 } | 343 } |
343 | 344 |
344 TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) { | 345 TEST_F(PanelWindowResizerTest, DetachThenAttachToSecondDisplay) { |
345 // TODO: investigate failure. http://crbug.com/698888. | 346 // TODO: investigate failure. http://crbug.com/698888. |
346 if (ShellPort::Get()->IsRunningInMash()) | 347 if (Shell::GetAshConfig() == Config::MASH) |
347 return; | 348 return; |
348 | 349 |
349 UpdateDisplay("600x400,600x600"); | 350 UpdateDisplay("600x400,600x600"); |
350 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 351 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
351 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 352 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
352 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 353 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
353 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 354 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
354 | 355 |
355 // Detach the window. | 356 // Detach the window. |
356 DragStart(window.get()); | 357 DragStart(window.get()); |
(...skipping 12 matching lines...) Expand all Loading... |
369 DragEnd(); | 370 DragEnd(); |
370 | 371 |
371 // When dropped should move to second display's panel container. | 372 // When dropped should move to second display's panel container. |
372 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 373 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
373 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); | 374 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); |
374 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); | 375 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
375 } | 376 } |
376 | 377 |
377 TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) { | 378 TEST_F(PanelWindowResizerTest, AttachToSecondDisplay) { |
378 // TODO: investigate failure. http://crbug.com/698888. | 379 // TODO: investigate failure. http://crbug.com/698888. |
379 if (ShellPort::Get()->IsRunningInMash()) | 380 if (Shell::GetAshConfig() == Config::MASH) |
380 return; | 381 return; |
381 | 382 |
382 UpdateDisplay("600x400,600x600"); | 383 UpdateDisplay("600x400,600x600"); |
383 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 384 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
384 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 385 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
385 gfx::Rect initial_bounds = window->GetBoundsInScreen(); | 386 gfx::Rect initial_bounds = window->GetBoundsInScreen(); |
386 EXPECT_EQ(root_windows[0], window->GetRootWindow()); | 387 EXPECT_EQ(root_windows[0], window->GetRootWindow()); |
387 | 388 |
388 // Drag the window just above the other display's launcher. | 389 // Drag the window just above the other display's launcher. |
389 DragStart(window.get()); | 390 DragStart(window.get()); |
390 DragMove(500, 195); | 391 DragMove(500, 195); |
391 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); | 392 EXPECT_EQ(initial_bounds.x() + 500, window->GetBoundsInScreen().x()); |
392 | 393 |
393 // Should stick to other launcher. | 394 // Should stick to other launcher. |
394 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); | 395 EXPECT_EQ(initial_bounds.y() + 200, window->GetBoundsInScreen().y()); |
395 DragEnd(); | 396 DragEnd(); |
396 | 397 |
397 // When dropped should move to second display's panel container. | 398 // When dropped should move to second display's panel container. |
398 EXPECT_EQ(root_windows[1], window->GetRootWindow()); | 399 EXPECT_EQ(root_windows[1], window->GetRootWindow()); |
399 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); | 400 EXPECT_TRUE(window->GetProperty(kPanelAttachedKey)); |
400 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); | 401 EXPECT_EQ(kShellWindowId_PanelContainer, window->parent()->id()); |
401 } | 402 } |
402 | 403 |
403 TEST_F(PanelWindowResizerTest, AttachToSecondFullscreenDisplay) { | 404 TEST_F(PanelWindowResizerTest, AttachToSecondFullscreenDisplay) { |
404 // TODO: investigate failure. http://crbug.com/698888. | 405 // TODO: investigate failure. http://crbug.com/698888. |
405 if (ShellPort::Get()->IsRunningInMash()) | 406 if (Shell::GetAshConfig() == Config::MASH) |
406 return; | 407 return; |
407 | 408 |
408 UpdateDisplay("600x400,600x600"); | 409 UpdateDisplay("600x400,600x600"); |
409 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 410 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
410 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 411 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
411 std::unique_ptr<aura::Window> fullscreen( | 412 std::unique_ptr<aura::Window> fullscreen( |
412 CreateTestWindowInShellWithBounds(gfx::Rect(600, 0, 101, 101))); | 413 CreateTestWindowInShellWithBounds(gfx::Rect(600, 0, 101, 101))); |
413 wm::GetWindowState(fullscreen.get())->Activate(); | 414 wm::GetWindowState(fullscreen.get())->Activate(); |
414 const wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 415 const wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
415 wm::GetWindowState(fullscreen.get())->OnWMEvent(&event); | 416 wm::GetWindowState(fullscreen.get())->OnWMEvent(&event); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 | 486 |
486 TEST_F(PanelWindowResizerTest, DragReordersPanelsVertical) { | 487 TEST_F(PanelWindowResizerTest, DragReordersPanelsVertical) { |
487 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT); | 488 GetPrimaryShelf()->SetAlignment(SHELF_ALIGNMENT_LEFT); |
488 DragAlongShelfReorder(0, -1); | 489 DragAlongShelfReorder(0, -1); |
489 } | 490 } |
490 | 491 |
491 // Tests that panels can have transient children of different types. | 492 // Tests that panels can have transient children of different types. |
492 // The transient children should be reparented in sync with the panel. | 493 // The transient children should be reparented in sync with the panel. |
493 TEST_P(PanelWindowResizerTransientTest, PanelWithTransientChild) { | 494 TEST_P(PanelWindowResizerTransientTest, PanelWithTransientChild) { |
494 // TODO: investigate failure. http://crbug.com/698888. | 495 // TODO: investigate failure. http://crbug.com/698888. |
495 if (ShellPort::Get()->IsRunningInMash()) | 496 if (Shell::GetAshConfig() == Config::MASH) |
496 return; | 497 return; |
497 | 498 |
498 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); | 499 std::unique_ptr<aura::Window> window(CreatePanelWindow(gfx::Point(0, 0))); |
499 std::unique_ptr<aura::Window> child( | 500 std::unique_ptr<aura::Window> child( |
500 CreateTestWindowInShellWithDelegateAndType( | 501 CreateTestWindowInShellWithDelegateAndType( |
501 NULL, transient_window_type_, 0, gfx::Rect(20, 20, 150, 40))); | 502 NULL, transient_window_type_, 0, gfx::Rect(20, 20, 150, 40))); |
502 ::wm::AddTransientChild(window.get(), child.get()); | 503 ::wm::AddTransientChild(window.get(), child.get()); |
503 if (window->parent() != child->parent()) | 504 if (window->parent() != child->parent()) |
504 window->parent()->AddChild(child.get()); | 505 window->parent()->AddChild(child.get()); |
505 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); | 506 EXPECT_EQ(window.get(), ::wm::GetTransientParent(child.get())); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
555 INSTANTIATE_TEST_CASE_P(LtrRtl, | 556 INSTANTIATE_TEST_CASE_P(LtrRtl, |
556 PanelWindowResizerTextDirectionTest, | 557 PanelWindowResizerTextDirectionTest, |
557 testing::Bool()); | 558 testing::Bool()); |
558 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, | 559 INSTANTIATE_TEST_CASE_P(NormalPanelPopup, |
559 PanelWindowResizerTransientTest, | 560 PanelWindowResizerTransientTest, |
560 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, | 561 testing::Values(ui::wm::WINDOW_TYPE_NORMAL, |
561 ui::wm::WINDOW_TYPE_PANEL, | 562 ui::wm::WINDOW_TYPE_PANEL, |
562 ui::wm::WINDOW_TYPE_POPUP)); | 563 ui::wm::WINDOW_TYPE_POPUP)); |
563 | 564 |
564 } // namespace ash | 565 } // namespace ash |
OLD | NEW |