| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "ash/accessibility_delegate.h" | 8 #include "ash/accessibility_delegate.h" |
| 9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
| 10 #include "ash/drag_drop/drag_drop_controller.h" | 10 #include "ash/drag_drop/drag_drop_controller.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 aura::client::SetActivationDelegate(window, | 110 aura::client::SetActivationDelegate(window, |
| 111 &non_activatable_activation_delegate_); | 111 &non_activatable_activation_delegate_); |
| 112 EXPECT_FALSE(ash::wm::CanActivateWindow(window)); | 112 EXPECT_FALSE(ash::wm::CanActivateWindow(window)); |
| 113 return window; | 113 return window; |
| 114 } | 114 } |
| 115 | 115 |
| 116 // Creates a Widget containing a Window with the given |bounds|. This should | 116 // Creates a Widget containing a Window with the given |bounds|. This should |
| 117 // be used when the test requires a Widget. For example any test that will | 117 // be used when the test requires a Widget. For example any test that will |
| 118 // cause a window to be closed via | 118 // cause a window to be closed via |
| 119 // views::Widget::GetWidgetForNativeView(window)->Close(). | 119 // views::Widget::GetWidgetForNativeView(window)->Close(). |
| 120 scoped_ptr<views::Widget> CreateWindowWidget(const gfx::Rect& bounds) { | 120 std::unique_ptr<views::Widget> CreateWindowWidget(const gfx::Rect& bounds) { |
| 121 scoped_ptr<views::Widget> widget(new views::Widget); | 121 std::unique_ptr<views::Widget> widget(new views::Widget); |
| 122 views::Widget::InitParams params; | 122 views::Widget::InitParams params; |
| 123 params.bounds = bounds; | 123 params.bounds = bounds; |
| 124 params.type = views::Widget::InitParams::TYPE_WINDOW; | 124 params.type = views::Widget::InitParams::TYPE_WINDOW; |
| 125 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 125 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 126 widget->Init(params); | 126 widget->Init(params); |
| 127 widget->Show(); | 127 widget->Show(); |
| 128 ParentWindowInPrimaryRootWindow(widget->GetNativeWindow()); | 128 ParentWindowInPrimaryRootWindow(widget->GetNativeWindow()); |
| 129 return widget; | 129 return widget; |
| 130 } | 130 } |
| 131 | 131 |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 294 |
| 295 views::Widget* text_filter_widget() { | 295 views::Widget* text_filter_widget() { |
| 296 return ash::Shell::GetInstance()-> | 296 return ash::Shell::GetInstance()-> |
| 297 window_selector_controller()->window_selector_.get()-> | 297 window_selector_controller()->window_selector_.get()-> |
| 298 text_filter_widget_.get(); | 298 text_filter_widget_.get(); |
| 299 } | 299 } |
| 300 | 300 |
| 301 private: | 301 private: |
| 302 aura::test::TestWindowDelegate delegate_; | 302 aura::test::TestWindowDelegate delegate_; |
| 303 NonActivatableActivationDelegate non_activatable_activation_delegate_; | 303 NonActivatableActivationDelegate non_activatable_activation_delegate_; |
| 304 scoped_ptr<test::ShelfViewTestAPI> shelf_view_test_; | 304 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; |
| 305 | 305 |
| 306 DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest); | 306 DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest); |
| 307 }; | 307 }; |
| 308 | 308 |
| 309 // Tests that the text field in the overview menu is repositioned and resized | 309 // Tests that the text field in the overview menu is repositioned and resized |
| 310 // after a screen rotation. | 310 // after a screen rotation. |
| 311 #if defined(OS_WIN) && !defined(USE_ASH) | 311 #if defined(OS_WIN) && !defined(USE_ASH) |
| 312 // TODO(msw): Broken on Windows. http://crbug.com/584038 | 312 // TODO(msw): Broken on Windows. http://crbug.com/584038 |
| 313 #define MAYBE_OverviewScreenRotation DISABLED_OverviewScreenRotation | 313 #define MAYBE_OverviewScreenRotation DISABLED_OverviewScreenRotation |
| 314 #else | 314 #else |
| 315 #define MAYBE_OverviewScreenRotation OverviewScreenRotation | 315 #define MAYBE_OverviewScreenRotation OverviewScreenRotation |
| 316 #endif | 316 #endif |
| 317 TEST_F(WindowSelectorTest, MAYBE_OverviewScreenRotation) { | 317 TEST_F(WindowSelectorTest, MAYBE_OverviewScreenRotation) { |
| 318 gfx::Rect bounds(0, 0, 400, 300); | 318 gfx::Rect bounds(0, 0, 400, 300); |
| 319 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 319 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 320 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); | 320 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); |
| 321 | 321 |
| 322 // In overview mode the windows should no longer overlap and the text filter | 322 // In overview mode the windows should no longer overlap and the text filter |
| 323 // widget should be focused. | 323 // widget should be focused. |
| 324 ToggleOverview(); | 324 ToggleOverview(); |
| 325 | 325 |
| 326 views::Widget* text_filter = text_filter_widget(); | 326 views::Widget* text_filter = text_filter_widget(); |
| 327 UpdateDisplay("400x300"); | 327 UpdateDisplay("400x300"); |
| 328 | 328 |
| 329 // Formula for initial placement found in window_selector.cc using | 329 // Formula for initial placement found in window_selector.cc using |
| 330 // width = 400, height = 300: | 330 // width = 400, height = 300: |
| (...skipping 11 matching lines...) Expand all Loading... |
| 342 // Uses the same formulas as abuve using width = 300, height = 400. | 342 // Uses the same formulas as abuve using width = 300, height = 400. |
| 343 EXPECT_EQ("112,-32 75x32", | 343 EXPECT_EQ("112,-32 75x32", |
| 344 text_filter->GetClientAreaBoundsInScreen().ToString()); | 344 text_filter->GetClientAreaBoundsInScreen().ToString()); |
| 345 } | 345 } |
| 346 | 346 |
| 347 // Tests that an a11y alert is sent on entering overview mode. | 347 // Tests that an a11y alert is sent on entering overview mode. |
| 348 TEST_F(WindowSelectorTest, A11yAlertOnOverviewMode) { | 348 TEST_F(WindowSelectorTest, A11yAlertOnOverviewMode) { |
| 349 gfx::Rect bounds(0, 0, 400, 400); | 349 gfx::Rect bounds(0, 0, 400, 400); |
| 350 AccessibilityDelegate* delegate = | 350 AccessibilityDelegate* delegate = |
| 351 ash::Shell::GetInstance()->accessibility_delegate(); | 351 ash::Shell::GetInstance()->accessibility_delegate(); |
| 352 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 352 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 353 EXPECT_NE(delegate->GetLastAccessibilityAlert(), | 353 EXPECT_NE(delegate->GetLastAccessibilityAlert(), |
| 354 ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); | 354 ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); |
| 355 ToggleOverview(); | 355 ToggleOverview(); |
| 356 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), | 356 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), |
| 357 ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); | 357 ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); |
| 358 } | 358 } |
| 359 | 359 |
| 360 // Tests that there are no crashes when there is not enough screen space | 360 // Tests that there are no crashes when there is not enough screen space |
| 361 // available to show all of the windows. | 361 // available to show all of the windows. |
| 362 TEST_F(WindowSelectorTest, SmallDisplay) { | 362 TEST_F(WindowSelectorTest, SmallDisplay) { |
| 363 UpdateDisplay("3x1"); | 363 UpdateDisplay("3x1"); |
| 364 gfx::Rect bounds(0, 0, 1, 1); | 364 gfx::Rect bounds(0, 0, 1, 1); |
| 365 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 365 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 366 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 366 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 367 scoped_ptr<aura::Window> window3(CreateWindow(bounds)); | 367 std::unique_ptr<aura::Window> window3(CreateWindow(bounds)); |
| 368 scoped_ptr<aura::Window> window4(CreateWindow(bounds)); | 368 std::unique_ptr<aura::Window> window4(CreateWindow(bounds)); |
| 369 ToggleOverview(); | 369 ToggleOverview(); |
| 370 } | 370 } |
| 371 | 371 |
| 372 // Tests entering overview mode with two windows and selecting one by clicking. | 372 // Tests entering overview mode with two windows and selecting one by clicking. |
| 373 TEST_F(WindowSelectorTest, Basic) { | 373 TEST_F(WindowSelectorTest, Basic) { |
| 374 gfx::Rect bounds(0, 0, 400, 400); | 374 gfx::Rect bounds(0, 0, 400, 400); |
| 375 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 375 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 376 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 376 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 377 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 377 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 378 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); | 378 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); |
| 379 scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds)); | 379 std::unique_ptr<aura::Window> panel2(CreatePanelWindow(bounds)); |
| 380 | 380 |
| 381 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get())); | 381 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get())); |
| 382 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get())); | 382 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get())); |
| 383 wm::ActivateWindow(window2.get()); | 383 wm::ActivateWindow(window2.get()); |
| 384 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | 384 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
| 385 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 385 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
| 386 EXPECT_EQ(window2.get(), GetFocusedWindow()); | 386 EXPECT_EQ(window2.get(), GetFocusedWindow()); |
| 387 // Hide the cursor before entering overview to test that it will be shown. | 387 // Hide the cursor before entering overview to test that it will be shown. |
| 388 aura::client::GetCursorClient(root_window)->HideCursor(); | 388 aura::client::GetCursorClient(root_window)->HideCursor(); |
| 389 | 389 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 406 } | 406 } |
| 407 | 407 |
| 408 // Tests that the ordering of windows is near the windows' original positions. | 408 // Tests that the ordering of windows is near the windows' original positions. |
| 409 TEST_F(WindowSelectorTest, MinimizeMovement) { | 409 TEST_F(WindowSelectorTest, MinimizeMovement) { |
| 410 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 410 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 411 gfx::Rect left_bounds(0, 0, root_window->bounds().width() / 2, | 411 gfx::Rect left_bounds(0, 0, root_window->bounds().width() / 2, |
| 412 root_window->bounds().height()); | 412 root_window->bounds().height()); |
| 413 gfx::Rect right_bounds(root_window->bounds().width() / 2, 0, | 413 gfx::Rect right_bounds(root_window->bounds().width() / 2, 0, |
| 414 root_window->bounds().width() / 2, | 414 root_window->bounds().width() / 2, |
| 415 root_window->bounds().height()); | 415 root_window->bounds().height()); |
| 416 scoped_ptr<aura::Window> left_window(CreateWindow(left_bounds)); | 416 std::unique_ptr<aura::Window> left_window(CreateWindow(left_bounds)); |
| 417 scoped_ptr<aura::Window> right_window(CreateWindow(right_bounds)); | 417 std::unique_ptr<aura::Window> right_window(CreateWindow(right_bounds)); |
| 418 | 418 |
| 419 // The window should stay on the same side of the screen regardless of which | 419 // The window should stay on the same side of the screen regardless of which |
| 420 // one was active on entering overview mode. | 420 // one was active on entering overview mode. |
| 421 wm::GetWindowState(left_window.get())->Activate(); | 421 wm::GetWindowState(left_window.get())->Activate(); |
| 422 ToggleOverview(); | 422 ToggleOverview(); |
| 423 const std::vector<WindowSelectorItem*>& overview1(GetWindowItemsForRoot(0)); | 423 const std::vector<WindowSelectorItem*>& overview1(GetWindowItemsForRoot(0)); |
| 424 EXPECT_EQ(overview1[0]->GetWindow(), left_window.get()); | 424 EXPECT_EQ(overview1[0]->GetWindow(), left_window.get()); |
| 425 EXPECT_EQ(overview1[1]->GetWindow(), right_window.get()); | 425 EXPECT_EQ(overview1[1]->GetWindow(), right_window.get()); |
| 426 ToggleOverview(); | 426 ToggleOverview(); |
| 427 | 427 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 446 // Tests that the ordering of windows is near the windows' original positions | 446 // Tests that the ordering of windows is near the windows' original positions |
| 447 // on a second display. | 447 // on a second display. |
| 448 TEST_F(WindowSelectorTest, MinimizeMovementSecondDisplay) { | 448 TEST_F(WindowSelectorTest, MinimizeMovementSecondDisplay) { |
| 449 if (!SupportsMultipleDisplays()) | 449 if (!SupportsMultipleDisplays()) |
| 450 return; | 450 return; |
| 451 | 451 |
| 452 // Verify the same works on the second display | 452 // Verify the same works on the second display |
| 453 UpdateDisplay("400x400,400x400"); | 453 UpdateDisplay("400x400,400x400"); |
| 454 gfx::Rect left_bounds(400, 0, 200, 400); | 454 gfx::Rect left_bounds(400, 0, 200, 400); |
| 455 gfx::Rect right_bounds(600, 0, 200, 400); | 455 gfx::Rect right_bounds(600, 0, 200, 400); |
| 456 scoped_ptr<aura::Window> left_window(CreateWindow(left_bounds)); | 456 std::unique_ptr<aura::Window> left_window(CreateWindow(left_bounds)); |
| 457 scoped_ptr<aura::Window> right_window(CreateWindow(right_bounds)); | 457 std::unique_ptr<aura::Window> right_window(CreateWindow(right_bounds)); |
| 458 | 458 |
| 459 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 459 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 460 EXPECT_EQ(root_windows[1], left_window->GetRootWindow()); | 460 EXPECT_EQ(root_windows[1], left_window->GetRootWindow()); |
| 461 EXPECT_EQ(root_windows[1], right_window->GetRootWindow()); | 461 EXPECT_EQ(root_windows[1], right_window->GetRootWindow()); |
| 462 | 462 |
| 463 wm::GetWindowState(left_window.get())->Activate(); | 463 wm::GetWindowState(left_window.get())->Activate(); |
| 464 ToggleOverview(); | 464 ToggleOverview(); |
| 465 const std::vector<WindowSelectorItem*>& overview1(GetWindowItemsForRoot(0)); | 465 const std::vector<WindowSelectorItem*>& overview1(GetWindowItemsForRoot(0)); |
| 466 EXPECT_EQ(overview1[0]->GetWindow(), left_window.get()); | 466 EXPECT_EQ(overview1[0]->GetWindow(), left_window.get()); |
| 467 EXPECT_EQ(overview1[1]->GetWindow(), right_window.get()); | 467 EXPECT_EQ(overview1[1]->GetWindow(), right_window.get()); |
| 468 ToggleOverview(); | 468 ToggleOverview(); |
| 469 | 469 |
| 470 // Active the right window, the order should be the same. | 470 // Active the right window, the order should be the same. |
| 471 wm::GetWindowState(right_window.get())->Activate(); | 471 wm::GetWindowState(right_window.get())->Activate(); |
| 472 ToggleOverview(); | 472 ToggleOverview(); |
| 473 const std::vector<WindowSelectorItem*>& overview2(GetWindowItemsForRoot(0)); | 473 const std::vector<WindowSelectorItem*>& overview2(GetWindowItemsForRoot(0)); |
| 474 EXPECT_EQ(overview2[0]->GetWindow(), left_window.get()); | 474 EXPECT_EQ(overview2[0]->GetWindow(), left_window.get()); |
| 475 EXPECT_EQ(overview2[1]->GetWindow(), right_window.get()); | 475 EXPECT_EQ(overview2[1]->GetWindow(), right_window.get()); |
| 476 ToggleOverview(); | 476 ToggleOverview(); |
| 477 } | 477 } |
| 478 | 478 |
| 479 // Tests that the ordering of windows is stable across different overview | 479 // Tests that the ordering of windows is stable across different overview |
| 480 // sessions even when the windows have the same bounds. | 480 // sessions even when the windows have the same bounds. |
| 481 TEST_F(WindowSelectorTest, StableOrder) { | 481 TEST_F(WindowSelectorTest, StableOrder) { |
| 482 gfx::Rect bounds(0, 0, 400, 400); | 482 gfx::Rect bounds(0, 0, 400, 400); |
| 483 scoped_ptr<aura::Window> window1(CreateWindowWithId(bounds, 1)); | 483 std::unique_ptr<aura::Window> window1(CreateWindowWithId(bounds, 1)); |
| 484 scoped_ptr<aura::Window> window2(CreateWindowWithId(bounds, 2)); | 484 std::unique_ptr<aura::Window> window2(CreateWindowWithId(bounds, 2)); |
| 485 | 485 |
| 486 // The initial ordering is not defined, but should remain consistent the next | 486 // The initial ordering is not defined, but should remain consistent the next |
| 487 // time overview is started. | 487 // time overview is started. |
| 488 wm::GetWindowState(window1.get())->Activate(); | 488 wm::GetWindowState(window1.get())->Activate(); |
| 489 ToggleOverview(); | 489 ToggleOverview(); |
| 490 const std::vector<WindowSelectorItem*>& overview1(GetWindowItemsForRoot(0)); | 490 const std::vector<WindowSelectorItem*>& overview1(GetWindowItemsForRoot(0)); |
| 491 int initial_order[2] = {overview1[0]->GetWindow()->id(), | 491 int initial_order[2] = {overview1[0]->GetWindow()->id(), |
| 492 overview1[1]->GetWindow()->id()}; | 492 overview1[1]->GetWindow()->id()}; |
| 493 ToggleOverview(); | 493 ToggleOverview(); |
| 494 | 494 |
| 495 // Activate the other window, the order should be the same. | 495 // Activate the other window, the order should be the same. |
| 496 wm::GetWindowState(window2.get())->Activate(); | 496 wm::GetWindowState(window2.get())->Activate(); |
| 497 ToggleOverview(); | 497 ToggleOverview(); |
| 498 const std::vector<WindowSelectorItem*>& overview2(GetWindowItemsForRoot(0)); | 498 const std::vector<WindowSelectorItem*>& overview2(GetWindowItemsForRoot(0)); |
| 499 EXPECT_EQ(initial_order[0], overview2[0]->GetWindow()->id()); | 499 EXPECT_EQ(initial_order[0], overview2[0]->GetWindow()->id()); |
| 500 EXPECT_EQ(initial_order[1], overview2[1]->GetWindow()->id()); | 500 EXPECT_EQ(initial_order[1], overview2[1]->GetWindow()->id()); |
| 501 ToggleOverview(); | 501 ToggleOverview(); |
| 502 } | 502 } |
| 503 | 503 |
| 504 // Tests entering overview mode with docked windows | 504 // Tests entering overview mode with docked windows |
| 505 TEST_F(WindowSelectorTest, BasicWithDocked) { | 505 TEST_F(WindowSelectorTest, BasicWithDocked) { |
| 506 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 506 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 507 gfx::Rect bounds(300, 0, 200, 200); | 507 gfx::Rect bounds(300, 0, 200, 200); |
| 508 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 508 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 509 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 509 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 510 scoped_ptr<aura::Window> docked1(CreateWindow(bounds)); | 510 std::unique_ptr<aura::Window> docked1(CreateWindow(bounds)); |
| 511 scoped_ptr<aura::Window> docked2(CreateWindow(bounds)); | 511 std::unique_ptr<aura::Window> docked2(CreateWindow(bounds)); |
| 512 | 512 |
| 513 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); | 513 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); |
| 514 wm::GetWindowState(docked1.get())->OnWMEvent(&dock_event); | 514 wm::GetWindowState(docked1.get())->OnWMEvent(&dock_event); |
| 515 | 515 |
| 516 wm::WindowState* docked_state2 = wm::GetWindowState(docked2.get()); | 516 wm::WindowState* docked_state2 = wm::GetWindowState(docked2.get()); |
| 517 docked_state2->OnWMEvent(&dock_event); | 517 docked_state2->OnWMEvent(&dock_event); |
| 518 wm::WMEvent minimize_event(wm::WM_EVENT_MINIMIZE); | 518 wm::WMEvent minimize_event(wm::WM_EVENT_MINIMIZE); |
| 519 docked_state2->OnWMEvent(&minimize_event); | 519 docked_state2->OnWMEvent(&minimize_event); |
| 520 | 520 |
| 521 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get())); | 521 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get())); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 541 // Docked window can still be activated, which will exit the overview mode. | 541 // Docked window can still be activated, which will exit the overview mode. |
| 542 ClickWindow(docked1.get()); | 542 ClickWindow(docked1.get()); |
| 543 EXPECT_TRUE(wm::IsActiveWindow(docked1.get())); | 543 EXPECT_TRUE(wm::IsActiveWindow(docked1.get())); |
| 544 EXPECT_FALSE( | 544 EXPECT_FALSE( |
| 545 ash::Shell::GetInstance()->window_selector_controller()->IsSelecting()); | 545 ash::Shell::GetInstance()->window_selector_controller()->IsSelecting()); |
| 546 } | 546 } |
| 547 | 547 |
| 548 // Tests selecting a window by tapping on it. | 548 // Tests selecting a window by tapping on it. |
| 549 TEST_F(WindowSelectorTest, BasicGesture) { | 549 TEST_F(WindowSelectorTest, BasicGesture) { |
| 550 gfx::Rect bounds(0, 0, 400, 400); | 550 gfx::Rect bounds(0, 0, 400, 400); |
| 551 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 551 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 552 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 552 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 553 wm::ActivateWindow(window1.get()); | 553 wm::ActivateWindow(window1.get()); |
| 554 EXPECT_EQ(window1.get(), GetFocusedWindow()); | 554 EXPECT_EQ(window1.get(), GetFocusedWindow()); |
| 555 ToggleOverview(); | 555 ToggleOverview(); |
| 556 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); | 556 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); |
| 557 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 557 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 558 window2.get()); | 558 window2.get()); |
| 559 generator.GestureTapAt(gfx::ToEnclosingRect( | 559 generator.GestureTapAt(gfx::ToEnclosingRect( |
| 560 GetTransformedTargetBounds(window2.get())).CenterPoint()); | 560 GetTransformedTargetBounds(window2.get())).CenterPoint()); |
| 561 EXPECT_EQ(window2.get(), GetFocusedWindow()); | 561 EXPECT_EQ(window2.get(), GetFocusedWindow()); |
| 562 } | 562 } |
| 563 | 563 |
| 564 // Tests that the user action WindowSelector_ActiveWindowChanged is | 564 // Tests that the user action WindowSelector_ActiveWindowChanged is |
| 565 // recorded when the mouse/touchscreen/keyboard are used to select a window | 565 // recorded when the mouse/touchscreen/keyboard are used to select a window |
| 566 // in overview mode which is different from the previously-active window. | 566 // in overview mode which is different from the previously-active window. |
| 567 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionRecorded) { | 567 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionRecorded) { |
| 568 base::UserActionTester user_action_tester; | 568 base::UserActionTester user_action_tester; |
| 569 gfx::Rect bounds(0, 0, 400, 400); | 569 gfx::Rect bounds(0, 0, 400, 400); |
| 570 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 570 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 571 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 571 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 572 | 572 |
| 573 // Tap on |window2| to activate it and exit overview. | 573 // Tap on |window2| to activate it and exit overview. |
| 574 wm::ActivateWindow(window1.get()); | 574 wm::ActivateWindow(window1.get()); |
| 575 ToggleOverview(); | 575 ToggleOverview(); |
| 576 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 576 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 577 window2.get()); | 577 window2.get()); |
| 578 generator.GestureTapAt( | 578 generator.GestureTapAt( |
| 579 gfx::ToEnclosingRect(GetTransformedTargetBounds(window2.get())) | 579 gfx::ToEnclosingRect(GetTransformedTargetBounds(window2.get())) |
| 580 .CenterPoint()); | 580 .CenterPoint()); |
| 581 EXPECT_EQ( | 581 EXPECT_EQ( |
| (...skipping 16 matching lines...) Expand all Loading... |
| 598 3, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); | 598 3, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); |
| 599 } | 599 } |
| 600 | 600 |
| 601 // Tests that the user action WindowSelector_ActiveWindowChanged is not | 601 // Tests that the user action WindowSelector_ActiveWindowChanged is not |
| 602 // recorded when the mouse/touchscreen/keyboard are used to select the | 602 // recorded when the mouse/touchscreen/keyboard are used to select the |
| 603 // already-active window from overview mode. Also verifies that entering and | 603 // already-active window from overview mode. Also verifies that entering and |
| 604 // exiting overview without selecting a window does not record the action. | 604 // exiting overview without selecting a window does not record the action. |
| 605 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionNotRecorded) { | 605 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionNotRecorded) { |
| 606 base::UserActionTester user_action_tester; | 606 base::UserActionTester user_action_tester; |
| 607 gfx::Rect bounds(0, 0, 400, 400); | 607 gfx::Rect bounds(0, 0, 400, 400); |
| 608 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 608 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 609 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 609 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 610 | 610 |
| 611 // Set |window1| to be initially active. | 611 // Set |window1| to be initially active. |
| 612 wm::ActivateWindow(window1.get()); | 612 wm::ActivateWindow(window1.get()); |
| 613 ToggleOverview(); | 613 ToggleOverview(); |
| 614 | 614 |
| 615 // Tap on |window1| to exit overview. | 615 // Tap on |window1| to exit overview. |
| 616 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), | 616 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), |
| 617 window1.get()); | 617 window1.get()); |
| 618 generator.GestureTapAt( | 618 generator.GestureTapAt( |
| 619 gfx::ToEnclosingRect(GetTransformedTargetBounds(window1.get())) | 619 gfx::ToEnclosingRect(GetTransformedTargetBounds(window1.get())) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 641 ToggleOverview(); | 641 ToggleOverview(); |
| 642 ToggleOverview(); | 642 ToggleOverview(); |
| 643 EXPECT_EQ( | 643 EXPECT_EQ( |
| 644 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); | 644 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); |
| 645 } | 645 } |
| 646 | 646 |
| 647 // Tests that the user action WindowSelector_ActiveWindowChanged is not | 647 // Tests that the user action WindowSelector_ActiveWindowChanged is not |
| 648 // recorded when overview mode exits as a result of closing its only window. | 648 // recorded when overview mode exits as a result of closing its only window. |
| 649 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionWindowClose) { | 649 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionWindowClose) { |
| 650 base::UserActionTester user_action_tester; | 650 base::UserActionTester user_action_tester; |
| 651 scoped_ptr<views::Widget> widget = | 651 std::unique_ptr<views::Widget> widget = |
| 652 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); | 652 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); |
| 653 | 653 |
| 654 ToggleOverview(); | 654 ToggleOverview(); |
| 655 | 655 |
| 656 aura::Window* window = widget->GetNativeWindow(); | 656 aura::Window* window = widget->GetNativeWindow(); |
| 657 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window); | 657 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window); |
| 658 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1); | 658 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1); |
| 659 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); | 659 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); |
| 660 | 660 |
| 661 ASSERT_FALSE(widget->IsClosed()); | 661 ASSERT_FALSE(widget->IsClosed()); |
| 662 event_generator.ClickLeftButton(); | 662 event_generator.ClickLeftButton(); |
| 663 ASSERT_TRUE(widget->IsClosed()); | 663 ASSERT_TRUE(widget->IsClosed()); |
| 664 EXPECT_EQ( | 664 EXPECT_EQ( |
| 665 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); | 665 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); |
| 666 } | 666 } |
| 667 | 667 |
| 668 // Tests that we do not crash and overview mode remains engaged if the desktop | 668 // Tests that we do not crash and overview mode remains engaged if the desktop |
| 669 // is tapped while a finger is already down over a window. | 669 // is tapped while a finger is already down over a window. |
| 670 TEST_F(WindowSelectorTest, NoCrashWithDesktopTap) { | 670 TEST_F(WindowSelectorTest, NoCrashWithDesktopTap) { |
| 671 scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(200, 300, 250, 450))); | 671 std::unique_ptr<aura::Window> window( |
| 672 CreateWindow(gfx::Rect(200, 300, 250, 450))); |
| 672 | 673 |
| 673 ToggleOverview(); | 674 ToggleOverview(); |
| 674 | 675 |
| 675 gfx::Rect bounds = | 676 gfx::Rect bounds = |
| 676 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(window.get())); | 677 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(window.get())); |
| 677 ui::test::EventGenerator event_generator(window->GetRootWindow(), | 678 ui::test::EventGenerator event_generator(window->GetRootWindow(), |
| 678 bounds.CenterPoint()); | 679 bounds.CenterPoint()); |
| 679 | 680 |
| 680 // Press down on the window. | 681 // Press down on the window. |
| 681 const int kTouchId = 19; | 682 const int kTouchId = 19; |
| 682 event_generator.PressTouchId(kTouchId); | 683 event_generator.PressTouchId(kTouchId); |
| 683 | 684 |
| 684 // Tap on the desktop, which should not cause a crash. Overview mode should | 685 // Tap on the desktop, which should not cause a crash. Overview mode should |
| 685 // be disengaged. | 686 // be disengaged. |
| 686 event_generator.GestureTapAt(gfx::Point(0, 0)); | 687 event_generator.GestureTapAt(gfx::Point(0, 0)); |
| 687 EXPECT_FALSE(IsSelecting()); | 688 EXPECT_FALSE(IsSelecting()); |
| 688 | 689 |
| 689 event_generator.ReleaseTouchId(kTouchId); | 690 event_generator.ReleaseTouchId(kTouchId); |
| 690 } | 691 } |
| 691 | 692 |
| 692 // Tests that we do not crash and a window is selected when appropriate when | 693 // Tests that we do not crash and a window is selected when appropriate when |
| 693 // we click on a window during touch. | 694 // we click on a window during touch. |
| 694 TEST_F(WindowSelectorTest, ClickOnWindowDuringTouch) { | 695 TEST_F(WindowSelectorTest, ClickOnWindowDuringTouch) { |
| 695 gfx::Rect bounds(0, 0, 400, 400); | 696 gfx::Rect bounds(0, 0, 400, 400); |
| 696 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 697 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 697 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 698 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 698 wm::ActivateWindow(window2.get()); | 699 wm::ActivateWindow(window2.get()); |
| 699 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); | 700 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); |
| 700 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 701 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
| 701 | 702 |
| 702 ToggleOverview(); | 703 ToggleOverview(); |
| 703 | 704 |
| 704 gfx::Rect window1_bounds = | 705 gfx::Rect window1_bounds = |
| 705 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(window1.get())); | 706 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(window1.get())); |
| 706 ui::test::EventGenerator event_generator(window1->GetRootWindow(), | 707 ui::test::EventGenerator event_generator(window1->GetRootWindow(), |
| 707 window1_bounds.CenterPoint()); | 708 window1_bounds.CenterPoint()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 727 EXPECT_FALSE(IsSelecting()); | 728 EXPECT_FALSE(IsSelecting()); |
| 728 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 729 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
| 729 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); | 730 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); |
| 730 event_generator.ReleaseTouchId(kTouchId); | 731 event_generator.ReleaseTouchId(kTouchId); |
| 731 } | 732 } |
| 732 | 733 |
| 733 // Tests that a window does not receive located events when in overview mode. | 734 // Tests that a window does not receive located events when in overview mode. |
| 734 TEST_F(WindowSelectorTest, WindowDoesNotReceiveEvents) { | 735 TEST_F(WindowSelectorTest, WindowDoesNotReceiveEvents) { |
| 735 gfx::Rect window_bounds(20, 10, 200, 300); | 736 gfx::Rect window_bounds(20, 10, 200, 300); |
| 736 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 737 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
| 737 scoped_ptr<aura::Window> window(CreateWindow(window_bounds)); | 738 std::unique_ptr<aura::Window> window(CreateWindow(window_bounds)); |
| 738 | 739 |
| 739 gfx::Point point1(window_bounds.x() + 10, window_bounds.y() + 10); | 740 gfx::Point point1(window_bounds.x() + 10, window_bounds.y() + 10); |
| 740 | 741 |
| 741 ui::MouseEvent event1(ui::ET_MOUSE_PRESSED, point1, point1, | 742 ui::MouseEvent event1(ui::ET_MOUSE_PRESSED, point1, point1, |
| 742 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 743 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 743 | 744 |
| 744 ui::EventTarget* root_target = root_window; | 745 ui::EventTarget* root_target = root_window; |
| 745 ui::EventTargeter* targeter = root_target->GetEventTargeter(); | 746 ui::EventTargeter* targeter = root_target->GetEventTargeter(); |
| 746 | 747 |
| 747 // The event should target the window because we are still not in overview | 748 // The event should target the window because we are still not in overview |
| 748 // mode. | 749 // mode. |
| 749 EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root_target, &event1)); | 750 EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root_target, &event1)); |
| 750 | 751 |
| 751 ToggleOverview(); | 752 ToggleOverview(); |
| 752 | 753 |
| 753 // The bounds have changed, take that into account. | 754 // The bounds have changed, take that into account. |
| 754 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window.get()); | 755 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window.get()); |
| 755 gfx::Point point2(bounds.x() + 10, bounds.y() + 10); | 756 gfx::Point point2(bounds.x() + 10, bounds.y() + 10); |
| 756 ui::MouseEvent event2(ui::ET_MOUSE_PRESSED, point2, point2, | 757 ui::MouseEvent event2(ui::ET_MOUSE_PRESSED, point2, point2, |
| 757 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); | 758 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); |
| 758 | 759 |
| 759 // Now the transparent window should be intercepting this event. | 760 // Now the transparent window should be intercepting this event. |
| 760 EXPECT_NE(window.get(), targeter->FindTargetForEvent(root_target, &event2)); | 761 EXPECT_NE(window.get(), targeter->FindTargetForEvent(root_target, &event2)); |
| 761 } | 762 } |
| 762 | 763 |
| 763 // Tests that clicking on the close button effectively closes the window. | 764 // Tests that clicking on the close button effectively closes the window. |
| 764 TEST_F(WindowSelectorTest, CloseButton) { | 765 TEST_F(WindowSelectorTest, CloseButton) { |
| 765 scoped_ptr<views::Widget> widget = | 766 std::unique_ptr<views::Widget> widget = |
| 766 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); | 767 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); |
| 767 | 768 |
| 768 ToggleOverview(); | 769 ToggleOverview(); |
| 769 | 770 |
| 770 aura::Window* window = widget->GetNativeWindow(); | 771 aura::Window* window = widget->GetNativeWindow(); |
| 771 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window); | 772 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window); |
| 772 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1); | 773 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1); |
| 773 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); | 774 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); |
| 774 | 775 |
| 775 EXPECT_FALSE(widget->IsClosed()); | 776 EXPECT_FALSE(widget->IsClosed()); |
| 776 event_generator.ClickLeftButton(); | 777 event_generator.ClickLeftButton(); |
| 777 EXPECT_TRUE(widget->IsClosed()); | 778 EXPECT_TRUE(widget->IsClosed()); |
| 778 } | 779 } |
| 779 | 780 |
| 780 // Tests that clicking on the close button on a secondary display effectively | 781 // Tests that clicking on the close button on a secondary display effectively |
| 781 // closes the window. | 782 // closes the window. |
| 782 TEST_F(WindowSelectorTest, CloseButtonOnMultipleDisplay) { | 783 TEST_F(WindowSelectorTest, CloseButtonOnMultipleDisplay) { |
| 783 if (!SupportsMultipleDisplays()) | 784 if (!SupportsMultipleDisplays()) |
| 784 return; | 785 return; |
| 785 | 786 |
| 786 UpdateDisplay("600x400,600x400"); | 787 UpdateDisplay("600x400,600x400"); |
| 787 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 788 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 788 | 789 |
| 789 scoped_ptr<aura::Window> window1(CreateWindow(gfx::Rect(650, 300, 250, 450))); | 790 std::unique_ptr<aura::Window> window1( |
| 791 CreateWindow(gfx::Rect(650, 300, 250, 450))); |
| 790 | 792 |
| 791 // We need a widget for the close button to work because windows are closed | 793 // We need a widget for the close button to work because windows are closed |
| 792 // via the widget. We also use the widget to determine if the window has been | 794 // via the widget. We also use the widget to determine if the window has been |
| 793 // closed or not. We explicity create the widget so that the window can be | 795 // closed or not. We explicity create the widget so that the window can be |
| 794 // parented to a non-primary root window. | 796 // parented to a non-primary root window. |
| 795 scoped_ptr<views::Widget> widget(new views::Widget); | 797 std::unique_ptr<views::Widget> widget(new views::Widget); |
| 796 views::Widget::InitParams params; | 798 views::Widget::InitParams params; |
| 797 params.bounds = gfx::Rect(650, 0, 400, 400); | 799 params.bounds = gfx::Rect(650, 0, 400, 400); |
| 798 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 800 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 799 params.parent = window1->parent(); | 801 params.parent = window1->parent(); |
| 800 widget->Init(params); | 802 widget->Init(params); |
| 801 widget->Show(); | 803 widget->Show(); |
| 802 | 804 |
| 803 ASSERT_EQ(root_windows[1], window1->GetRootWindow()); | 805 ASSERT_EQ(root_windows[1], window1->GetRootWindow()); |
| 804 | 806 |
| 805 ToggleOverview(); | 807 ToggleOverview(); |
| 806 | 808 |
| 807 aura::Window* window2 = widget->GetNativeWindow(); | 809 aura::Window* window2 = widget->GetNativeWindow(); |
| 808 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window2); | 810 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window2); |
| 809 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1); | 811 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() - 1); |
| 810 ui::test::EventGenerator event_generator(window2->GetRootWindow(), point); | 812 ui::test::EventGenerator event_generator(window2->GetRootWindow(), point); |
| 811 | 813 |
| 812 EXPECT_FALSE(widget->IsClosed()); | 814 EXPECT_FALSE(widget->IsClosed()); |
| 813 event_generator.ClickLeftButton(); | 815 event_generator.ClickLeftButton(); |
| 814 EXPECT_TRUE(widget->IsClosed()); | 816 EXPECT_TRUE(widget->IsClosed()); |
| 815 } | 817 } |
| 816 | 818 |
| 817 // Tests entering overview mode with two windows and selecting one. | 819 // Tests entering overview mode with two windows and selecting one. |
| 818 TEST_F(WindowSelectorTest, FullscreenWindow) { | 820 TEST_F(WindowSelectorTest, FullscreenWindow) { |
| 819 gfx::Rect bounds(0, 0, 400, 400); | 821 gfx::Rect bounds(0, 0, 400, 400); |
| 820 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 822 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 821 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 823 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 822 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); | 824 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); |
| 823 wm::ActivateWindow(window1.get()); | 825 wm::ActivateWindow(window1.get()); |
| 824 | 826 |
| 825 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 827 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 826 wm::GetWindowState(window1.get())->OnWMEvent(&toggle_fullscreen_event); | 828 wm::GetWindowState(window1.get())->OnWMEvent(&toggle_fullscreen_event); |
| 827 // The panel is hidden in fullscreen mode. | 829 // The panel is hidden in fullscreen mode. |
| 828 EXPECT_FALSE(panel1->IsVisible()); | 830 EXPECT_FALSE(panel1->IsVisible()); |
| 829 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); | 831 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); |
| 830 | 832 |
| 831 // Enter overview and select the fullscreen window. | 833 // Enter overview and select the fullscreen window. |
| 832 ToggleOverview(); | 834 ToggleOverview(); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 846 // again. | 848 // again. |
| 847 ToggleOverview(); | 849 ToggleOverview(); |
| 848 ClickWindow(window2.get()); | 850 ClickWindow(window2.get()); |
| 849 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); | 851 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); |
| 850 } | 852 } |
| 851 | 853 |
| 852 // Tests that the shelf dimming state is removed while in overview and restored | 854 // Tests that the shelf dimming state is removed while in overview and restored |
| 853 // on exiting overview. | 855 // on exiting overview. |
| 854 TEST_F(WindowSelectorTest, OverviewUndimsShelf) { | 856 TEST_F(WindowSelectorTest, OverviewUndimsShelf) { |
| 855 gfx::Rect bounds(0, 0, 400, 400); | 857 gfx::Rect bounds(0, 0, 400, 400); |
| 856 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 858 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 857 wm::WindowState* window_state = wm::GetWindowState(window1.get()); | 859 wm::WindowState* window_state = wm::GetWindowState(window1.get()); |
| 858 window_state->Maximize(); | 860 window_state->Maximize(); |
| 859 ash::ShelfWidget* shelf = Shell::GetPrimaryRootWindowController()->shelf(); | 861 ash::ShelfWidget* shelf = Shell::GetPrimaryRootWindowController()->shelf(); |
| 860 EXPECT_TRUE(shelf->GetDimsShelf()); | 862 EXPECT_TRUE(shelf->GetDimsShelf()); |
| 861 ToggleOverview(); | 863 ToggleOverview(); |
| 862 EXPECT_FALSE(shelf->GetDimsShelf()); | 864 EXPECT_FALSE(shelf->GetDimsShelf()); |
| 863 ToggleOverview(); | 865 ToggleOverview(); |
| 864 EXPECT_TRUE(shelf->GetDimsShelf()); | 866 EXPECT_TRUE(shelf->GetDimsShelf()); |
| 865 } | 867 } |
| 866 | 868 |
| 867 // Tests that entering overview when a fullscreen window is active in maximized | 869 // Tests that entering overview when a fullscreen window is active in maximized |
| 868 // mode correctly applies the transformations to the window and correctly | 870 // mode correctly applies the transformations to the window and correctly |
| 869 // updates the window bounds on exiting overview mode: http://crbug.com/401664. | 871 // updates the window bounds on exiting overview mode: http://crbug.com/401664. |
| 870 TEST_F(WindowSelectorTest, FullscreenWindowMaximizeMode) { | 872 TEST_F(WindowSelectorTest, FullscreenWindowMaximizeMode) { |
| 871 gfx::Rect bounds(0, 0, 400, 400); | 873 gfx::Rect bounds(0, 0, 400, 400); |
| 872 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 874 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 873 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 875 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 874 Shell::GetInstance()->maximize_mode_controller()-> | 876 Shell::GetInstance()->maximize_mode_controller()-> |
| 875 EnableMaximizeModeWindowManager(true); | 877 EnableMaximizeModeWindowManager(true); |
| 876 wm::ActivateWindow(window2.get()); | 878 wm::ActivateWindow(window2.get()); |
| 877 wm::ActivateWindow(window1.get()); | 879 wm::ActivateWindow(window1.get()); |
| 878 gfx::Rect normal_window_bounds(window1->bounds()); | 880 gfx::Rect normal_window_bounds(window1->bounds()); |
| 879 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 881 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 880 wm::GetWindowState(window1.get())->OnWMEvent(&toggle_fullscreen_event); | 882 wm::GetWindowState(window1.get())->OnWMEvent(&toggle_fullscreen_event); |
| 881 gfx::Rect fullscreen_window_bounds(window1->bounds()); | 883 gfx::Rect fullscreen_window_bounds(window1->bounds()); |
| 882 EXPECT_NE(normal_window_bounds.ToString(), | 884 EXPECT_NE(normal_window_bounds.ToString(), |
| 883 fullscreen_window_bounds.ToString()); | 885 fullscreen_window_bounds.ToString()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 900 // the shelf bringing window2 back to the normal bounds. | 902 // the shelf bringing window2 back to the normal bounds. |
| 901 ToggleOverview(); | 903 ToggleOverview(); |
| 902 ClickWindow(window2.get()); | 904 ClickWindow(window2.get()); |
| 903 EXPECT_EQ(normal_window_bounds.ToString(), | 905 EXPECT_EQ(normal_window_bounds.ToString(), |
| 904 window2->GetTargetBounds().ToString()); | 906 window2->GetTargetBounds().ToString()); |
| 905 } | 907 } |
| 906 | 908 |
| 907 // Tests that beginning window selection hides the app list. | 909 // Tests that beginning window selection hides the app list. |
| 908 TEST_F(WindowSelectorTest, SelectingHidesAppList) { | 910 TEST_F(WindowSelectorTest, SelectingHidesAppList) { |
| 909 gfx::Rect bounds(0, 0, 400, 400); | 911 gfx::Rect bounds(0, 0, 400, 400); |
| 910 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 912 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 911 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 913 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 912 Shell::GetInstance()->ShowAppList(nullptr); | 914 Shell::GetInstance()->ShowAppList(nullptr); |
| 913 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 915 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); |
| 914 ToggleOverview(); | 916 ToggleOverview(); |
| 915 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | 917 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); |
| 916 ToggleOverview(); | 918 ToggleOverview(); |
| 917 } | 919 } |
| 918 | 920 |
| 919 // Tests that a minimized window's visibility and layer visibility is correctly | 921 // Tests that a minimized window's visibility and layer visibility is correctly |
| 920 // changed when entering overview and restored when leaving overview mode. | 922 // changed when entering overview and restored when leaving overview mode. |
| 921 // Crashes after the skia roll in http://crrev.com/274114. | 923 // Crashes after the skia roll in http://crrev.com/274114. |
| 922 // http://crbug.com/379570 | 924 // http://crbug.com/379570 |
| 923 TEST_F(WindowSelectorTest, DISABLED_MinimizedWindowVisibility) { | 925 TEST_F(WindowSelectorTest, DISABLED_MinimizedWindowVisibility) { |
| 924 gfx::Rect bounds(0, 0, 400, 400); | 926 gfx::Rect bounds(0, 0, 400, 400); |
| 925 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 927 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 926 wm::WindowState* window_state = wm::GetWindowState(window1.get()); | 928 wm::WindowState* window_state = wm::GetWindowState(window1.get()); |
| 927 window_state->Minimize(); | 929 window_state->Minimize(); |
| 928 EXPECT_FALSE(window1->IsVisible()); | 930 EXPECT_FALSE(window1->IsVisible()); |
| 929 EXPECT_FALSE(window1->layer()->GetTargetVisibility()); | 931 EXPECT_FALSE(window1->layer()->GetTargetVisibility()); |
| 930 { | 932 { |
| 931 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 933 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 932 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 934 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 933 ToggleOverview(); | 935 ToggleOverview(); |
| 934 EXPECT_TRUE(window1->IsVisible()); | 936 EXPECT_TRUE(window1->IsVisible()); |
| 935 EXPECT_TRUE(window1->layer()->GetTargetVisibility()); | 937 EXPECT_TRUE(window1->layer()->GetTargetVisibility()); |
| 936 } | 938 } |
| 937 { | 939 { |
| 938 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 940 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 939 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 941 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 940 ToggleOverview(); | 942 ToggleOverview(); |
| 941 EXPECT_FALSE(window1->IsVisible()); | 943 EXPECT_FALSE(window1->IsVisible()); |
| 942 EXPECT_FALSE(window1->layer()->GetTargetVisibility()); | 944 EXPECT_FALSE(window1->layer()->GetTargetVisibility()); |
| 943 } | 945 } |
| 944 } | 946 } |
| 945 | 947 |
| 946 // Tests that a bounds change during overview is corrected for. | 948 // Tests that a bounds change during overview is corrected for. |
| 947 TEST_F(WindowSelectorTest, BoundsChangeDuringOverview) { | 949 TEST_F(WindowSelectorTest, BoundsChangeDuringOverview) { |
| 948 scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400))); | 950 std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400))); |
| 949 ToggleOverview(); | 951 ToggleOverview(); |
| 950 gfx::Rect overview_bounds = | 952 gfx::Rect overview_bounds = |
| 951 ToEnclosingRect(GetTransformedTargetBounds(window.get())); | 953 ToEnclosingRect(GetTransformedTargetBounds(window.get())); |
| 952 window->SetBounds(gfx::Rect(200, 0, 200, 200)); | 954 window->SetBounds(gfx::Rect(200, 0, 200, 200)); |
| 953 gfx::Rect new_overview_bounds = | 955 gfx::Rect new_overview_bounds = |
| 954 ToEnclosingRect(GetTransformedTargetBounds(window.get())); | 956 ToEnclosingRect(GetTransformedTargetBounds(window.get())); |
| 955 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x()); | 957 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x()); |
| 956 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y()); | 958 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y()); |
| 957 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width()); | 959 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width()); |
| 958 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height()); | 960 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height()); |
| 959 ToggleOverview(); | 961 ToggleOverview(); |
| 960 } | 962 } |
| 961 | 963 |
| 962 // Tests that a newly created window aborts overview. | 964 // Tests that a newly created window aborts overview. |
| 963 TEST_F(WindowSelectorTest, NewWindowCancelsOveriew) { | 965 TEST_F(WindowSelectorTest, NewWindowCancelsOveriew) { |
| 964 gfx::Rect bounds(0, 0, 400, 400); | 966 gfx::Rect bounds(0, 0, 400, 400); |
| 965 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 967 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 966 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 968 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 967 ToggleOverview(); | 969 ToggleOverview(); |
| 968 EXPECT_TRUE(IsSelecting()); | 970 EXPECT_TRUE(IsSelecting()); |
| 969 | 971 |
| 970 // A window being created should exit overview mode. | 972 // A window being created should exit overview mode. |
| 971 scoped_ptr<aura::Window> window3(CreateWindow(bounds)); | 973 std::unique_ptr<aura::Window> window3(CreateWindow(bounds)); |
| 972 EXPECT_FALSE(IsSelecting()); | 974 EXPECT_FALSE(IsSelecting()); |
| 973 } | 975 } |
| 974 | 976 |
| 975 // Tests that a window activation exits overview mode. | 977 // Tests that a window activation exits overview mode. |
| 976 TEST_F(WindowSelectorTest, ActivationCancelsOveriew) { | 978 TEST_F(WindowSelectorTest, ActivationCancelsOveriew) { |
| 977 gfx::Rect bounds(0, 0, 400, 400); | 979 gfx::Rect bounds(0, 0, 400, 400); |
| 978 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 980 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 979 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 981 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 980 window2->Focus(); | 982 window2->Focus(); |
| 981 ToggleOverview(); | 983 ToggleOverview(); |
| 982 EXPECT_TRUE(IsSelecting()); | 984 EXPECT_TRUE(IsSelecting()); |
| 983 | 985 |
| 984 // A window being activated should exit overview mode. | 986 // A window being activated should exit overview mode. |
| 985 window1->Focus(); | 987 window1->Focus(); |
| 986 EXPECT_FALSE(IsSelecting()); | 988 EXPECT_FALSE(IsSelecting()); |
| 987 | 989 |
| 988 // window1 should be focused after exiting even though window2 was focused on | 990 // window1 should be focused after exiting even though window2 was focused on |
| 989 // entering overview because we exited due to an activation. | 991 // entering overview because we exited due to an activation. |
| 990 EXPECT_EQ(window1.get(), GetFocusedWindow()); | 992 EXPECT_EQ(window1.get(), GetFocusedWindow()); |
| 991 } | 993 } |
| 992 | 994 |
| 993 // Tests that exiting overview mode without selecting a window restores focus | 995 // Tests that exiting overview mode without selecting a window restores focus |
| 994 // to the previously focused window. | 996 // to the previously focused window. |
| 995 TEST_F(WindowSelectorTest, CancelRestoresFocus) { | 997 TEST_F(WindowSelectorTest, CancelRestoresFocus) { |
| 996 gfx::Rect bounds(0, 0, 400, 400); | 998 gfx::Rect bounds(0, 0, 400, 400); |
| 997 scoped_ptr<aura::Window> window(CreateWindow(bounds)); | 999 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); |
| 998 wm::ActivateWindow(window.get()); | 1000 wm::ActivateWindow(window.get()); |
| 999 EXPECT_EQ(window.get(), GetFocusedWindow()); | 1001 EXPECT_EQ(window.get(), GetFocusedWindow()); |
| 1000 | 1002 |
| 1001 // In overview mode, the text filter widget should be focused. | 1003 // In overview mode, the text filter widget should be focused. |
| 1002 ToggleOverview(); | 1004 ToggleOverview(); |
| 1003 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); | 1005 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); |
| 1004 | 1006 |
| 1005 // If canceling overview mode, focus should be restored. | 1007 // If canceling overview mode, focus should be restored. |
| 1006 ToggleOverview(); | 1008 ToggleOverview(); |
| 1007 EXPECT_EQ(window.get(), GetFocusedWindow()); | 1009 EXPECT_EQ(window.get(), GetFocusedWindow()); |
| 1008 } | 1010 } |
| 1009 | 1011 |
| 1010 // Tests that overview mode is exited if the last remaining window is destroyed. | 1012 // Tests that overview mode is exited if the last remaining window is destroyed. |
| 1011 TEST_F(WindowSelectorTest, LastWindowDestroyed) { | 1013 TEST_F(WindowSelectorTest, LastWindowDestroyed) { |
| 1012 gfx::Rect bounds(0, 0, 400, 400); | 1014 gfx::Rect bounds(0, 0, 400, 400); |
| 1013 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 1015 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 1014 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 1016 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 1015 ToggleOverview(); | 1017 ToggleOverview(); |
| 1016 | 1018 |
| 1017 window1.reset(); | 1019 window1.reset(); |
| 1018 window2.reset(); | 1020 window2.reset(); |
| 1019 EXPECT_FALSE(IsSelecting()); | 1021 EXPECT_FALSE(IsSelecting()); |
| 1020 } | 1022 } |
| 1021 | 1023 |
| 1022 // Tests that entering overview mode restores a window to its original | 1024 // Tests that entering overview mode restores a window to its original |
| 1023 // target location. | 1025 // target location. |
| 1024 TEST_F(WindowSelectorTest, QuickReentryRestoresInitialTransform) { | 1026 TEST_F(WindowSelectorTest, QuickReentryRestoresInitialTransform) { |
| 1025 gfx::Rect bounds(0, 0, 400, 400); | 1027 gfx::Rect bounds(0, 0, 400, 400); |
| 1026 scoped_ptr<aura::Window> window(CreateWindow(bounds)); | 1028 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); |
| 1027 gfx::Rect initial_bounds = ToEnclosingRect( | 1029 gfx::Rect initial_bounds = ToEnclosingRect( |
| 1028 GetTransformedBounds(window.get())); | 1030 GetTransformedBounds(window.get())); |
| 1029 ToggleOverview(); | 1031 ToggleOverview(); |
| 1030 // Quickly exit and reenter overview mode. The window should still be | 1032 // Quickly exit and reenter overview mode. The window should still be |
| 1031 // animating when we reenter. We cannot short circuit animations for this but | 1033 // animating when we reenter. We cannot short circuit animations for this but |
| 1032 // we also don't have to wait for them to complete. | 1034 // we also don't have to wait for them to complete. |
| 1033 { | 1035 { |
| 1034 ui::ScopedAnimationDurationScaleMode test_duration_mode( | 1036 ui::ScopedAnimationDurationScaleMode test_duration_mode( |
| 1035 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); | 1037 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); |
| 1036 ToggleOverview(); | 1038 ToggleOverview(); |
| 1037 ToggleOverview(); | 1039 ToggleOverview(); |
| 1038 } | 1040 } |
| 1039 EXPECT_NE(initial_bounds, ToEnclosingRect( | 1041 EXPECT_NE(initial_bounds, ToEnclosingRect( |
| 1040 GetTransformedTargetBounds(window.get()))); | 1042 GetTransformedTargetBounds(window.get()))); |
| 1041 ToggleOverview(); | 1043 ToggleOverview(); |
| 1042 EXPECT_FALSE(IsSelecting()); | 1044 EXPECT_FALSE(IsSelecting()); |
| 1043 EXPECT_EQ(initial_bounds, ToEnclosingRect( | 1045 EXPECT_EQ(initial_bounds, ToEnclosingRect( |
| 1044 GetTransformedTargetBounds(window.get()))); | 1046 GetTransformedTargetBounds(window.get()))); |
| 1045 } | 1047 } |
| 1046 | 1048 |
| 1047 // Tests that windows with modal child windows are transformed with the modal | 1049 // Tests that windows with modal child windows are transformed with the modal |
| 1048 // child even though not activatable themselves. | 1050 // child even though not activatable themselves. |
| 1049 TEST_F(WindowSelectorTest, ModalChild) { | 1051 TEST_F(WindowSelectorTest, ModalChild) { |
| 1050 gfx::Rect bounds(0, 0, 400, 400); | 1052 gfx::Rect bounds(0, 0, 400, 400); |
| 1051 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 1053 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 1052 scoped_ptr<aura::Window> child1(CreateWindow(bounds)); | 1054 std::unique_ptr<aura::Window> child1(CreateWindow(bounds)); |
| 1053 child1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); | 1055 child1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); |
| 1054 ::wm::AddTransientChild(window1.get(), child1.get()); | 1056 ::wm::AddTransientChild(window1.get(), child1.get()); |
| 1055 EXPECT_EQ(window1->parent(), child1->parent()); | 1057 EXPECT_EQ(window1->parent(), child1->parent()); |
| 1056 ToggleOverview(); | 1058 ToggleOverview(); |
| 1057 EXPECT_TRUE(window1->IsVisible()); | 1059 EXPECT_TRUE(window1->IsVisible()); |
| 1058 EXPECT_TRUE(child1->IsVisible()); | 1060 EXPECT_TRUE(child1->IsVisible()); |
| 1059 EXPECT_EQ(ToEnclosingRect(GetTransformedTargetBounds(child1.get())), | 1061 EXPECT_EQ(ToEnclosingRect(GetTransformedTargetBounds(child1.get())), |
| 1060 ToEnclosingRect(GetTransformedTargetBounds(window1.get()))); | 1062 ToEnclosingRect(GetTransformedTargetBounds(window1.get()))); |
| 1061 ToggleOverview(); | 1063 ToggleOverview(); |
| 1062 } | 1064 } |
| 1063 | 1065 |
| 1064 // Tests that clicking a modal window's parent activates the modal window in | 1066 // Tests that clicking a modal window's parent activates the modal window in |
| 1065 // overview. | 1067 // overview. |
| 1066 TEST_F(WindowSelectorTest, ClickModalWindowParent) { | 1068 TEST_F(WindowSelectorTest, ClickModalWindowParent) { |
| 1067 scoped_ptr<aura::Window> window1(CreateWindow(gfx::Rect(0, 0, 180, 180))); | 1069 std::unique_ptr<aura::Window> window1( |
| 1068 scoped_ptr<aura::Window> child1(CreateWindow(gfx::Rect(200, 0, 180, 180))); | 1070 CreateWindow(gfx::Rect(0, 0, 180, 180))); |
| 1071 std::unique_ptr<aura::Window> child1( |
| 1072 CreateWindow(gfx::Rect(200, 0, 180, 180))); |
| 1069 child1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); | 1073 child1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); |
| 1070 ::wm::AddTransientChild(window1.get(), child1.get()); | 1074 ::wm::AddTransientChild(window1.get(), child1.get()); |
| 1071 EXPECT_FALSE(WindowsOverlapping(window1.get(), child1.get())); | 1075 EXPECT_FALSE(WindowsOverlapping(window1.get(), child1.get())); |
| 1072 EXPECT_EQ(window1->parent(), child1->parent()); | 1076 EXPECT_EQ(window1->parent(), child1->parent()); |
| 1073 ToggleOverview(); | 1077 ToggleOverview(); |
| 1074 // Given that their relative positions are preserved, the windows should still | 1078 // Given that their relative positions are preserved, the windows should still |
| 1075 // not overlap. | 1079 // not overlap. |
| 1076 EXPECT_FALSE(WindowsOverlapping(window1.get(), child1.get())); | 1080 EXPECT_FALSE(WindowsOverlapping(window1.get(), child1.get())); |
| 1077 ClickWindow(window1.get()); | 1081 ClickWindow(window1.get()); |
| 1078 EXPECT_FALSE(IsSelecting()); | 1082 EXPECT_FALSE(IsSelecting()); |
| 1079 | 1083 |
| 1080 // Clicking on window1 should activate child1. | 1084 // Clicking on window1 should activate child1. |
| 1081 EXPECT_TRUE(wm::IsActiveWindow(child1.get())); | 1085 EXPECT_TRUE(wm::IsActiveWindow(child1.get())); |
| 1082 } | 1086 } |
| 1083 | 1087 |
| 1084 // Tests that windows remain on the display they are currently on in overview | 1088 // Tests that windows remain on the display they are currently on in overview |
| 1085 // mode, and that the close buttons are on matching displays. | 1089 // mode, and that the close buttons are on matching displays. |
| 1086 TEST_F(WindowSelectorTest, MultipleDisplays) { | 1090 TEST_F(WindowSelectorTest, MultipleDisplays) { |
| 1087 if (!SupportsMultipleDisplays()) | 1091 if (!SupportsMultipleDisplays()) |
| 1088 return; | 1092 return; |
| 1089 | 1093 |
| 1090 UpdateDisplay("600x400,600x400"); | 1094 UpdateDisplay("600x400,600x400"); |
| 1091 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1095 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1092 gfx::Rect bounds1(0, 0, 400, 400); | 1096 gfx::Rect bounds1(0, 0, 400, 400); |
| 1093 gfx::Rect bounds2(650, 0, 400, 400); | 1097 gfx::Rect bounds2(650, 0, 400, 400); |
| 1094 | 1098 |
| 1095 scoped_ptr<aura::Window> window1(CreateWindow(bounds1)); | 1099 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); |
| 1096 scoped_ptr<aura::Window> window2(CreateWindow(bounds1)); | 1100 std::unique_ptr<aura::Window> window2(CreateWindow(bounds1)); |
| 1097 scoped_ptr<aura::Window> window3(CreateWindow(bounds2)); | 1101 std::unique_ptr<aura::Window> window3(CreateWindow(bounds2)); |
| 1098 scoped_ptr<aura::Window> window4(CreateWindow(bounds2)); | 1102 std::unique_ptr<aura::Window> window4(CreateWindow(bounds2)); |
| 1099 scoped_ptr<aura::Window> panel1(CreatePanelWindow(bounds1)); | 1103 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds1)); |
| 1100 scoped_ptr<aura::Window> panel2(CreatePanelWindow(bounds1)); | 1104 std::unique_ptr<aura::Window> panel2(CreatePanelWindow(bounds1)); |
| 1101 scoped_ptr<aura::Window> panel3(CreatePanelWindow(bounds2)); | 1105 std::unique_ptr<aura::Window> panel3(CreatePanelWindow(bounds2)); |
| 1102 scoped_ptr<aura::Window> panel4(CreatePanelWindow(bounds2)); | 1106 std::unique_ptr<aura::Window> panel4(CreatePanelWindow(bounds2)); |
| 1103 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | 1107 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
| 1104 EXPECT_EQ(root_windows[0], window2->GetRootWindow()); | 1108 EXPECT_EQ(root_windows[0], window2->GetRootWindow()); |
| 1105 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); | 1109 EXPECT_EQ(root_windows[1], window3->GetRootWindow()); |
| 1106 EXPECT_EQ(root_windows[1], window4->GetRootWindow()); | 1110 EXPECT_EQ(root_windows[1], window4->GetRootWindow()); |
| 1107 | 1111 |
| 1108 EXPECT_EQ(root_windows[0], panel1->GetRootWindow()); | 1112 EXPECT_EQ(root_windows[0], panel1->GetRootWindow()); |
| 1109 EXPECT_EQ(root_windows[0], panel2->GetRootWindow()); | 1113 EXPECT_EQ(root_windows[0], panel2->GetRootWindow()); |
| 1110 EXPECT_EQ(root_windows[1], panel3->GetRootWindow()); | 1114 EXPECT_EQ(root_windows[1], panel3->GetRootWindow()); |
| 1111 EXPECT_EQ(root_windows[1], panel4->GetRootWindow()); | 1115 EXPECT_EQ(root_windows[1], panel4->GetRootWindow()); |
| 1112 | 1116 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1160 } | 1164 } |
| 1161 | 1165 |
| 1162 // Tests removing a display during overview. | 1166 // Tests removing a display during overview. |
| 1163 TEST_F(WindowSelectorTest, RemoveDisplay) { | 1167 TEST_F(WindowSelectorTest, RemoveDisplay) { |
| 1164 if (!SupportsMultipleDisplays()) | 1168 if (!SupportsMultipleDisplays()) |
| 1165 return; | 1169 return; |
| 1166 | 1170 |
| 1167 UpdateDisplay("400x400,400x400"); | 1171 UpdateDisplay("400x400,400x400"); |
| 1168 gfx::Rect bounds1(0, 0, 100, 100); | 1172 gfx::Rect bounds1(0, 0, 100, 100); |
| 1169 gfx::Rect bounds2(450, 0, 100, 100); | 1173 gfx::Rect bounds2(450, 0, 100, 100); |
| 1170 scoped_ptr<aura::Window> window1(CreateWindow(bounds1)); | 1174 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); |
| 1171 scoped_ptr<aura::Window> window2(CreateWindow(bounds2)); | 1175 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); |
| 1172 scoped_ptr<aura::Window> window3(CreatePanelWindow(bounds1)); | 1176 std::unique_ptr<aura::Window> window3(CreatePanelWindow(bounds1)); |
| 1173 scoped_ptr<aura::Window> window4(CreatePanelWindow(bounds2)); | 1177 std::unique_ptr<aura::Window> window4(CreatePanelWindow(bounds2)); |
| 1174 | 1178 |
| 1175 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1179 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1176 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | 1180 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
| 1177 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); | 1181 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); |
| 1178 EXPECT_EQ(root_windows[0], window3->GetRootWindow()); | 1182 EXPECT_EQ(root_windows[0], window3->GetRootWindow()); |
| 1179 EXPECT_EQ(root_windows[1], window4->GetRootWindow()); | 1183 EXPECT_EQ(root_windows[1], window4->GetRootWindow()); |
| 1180 | 1184 |
| 1181 wm::ActivateWindow(window4.get()); | 1185 wm::ActivateWindow(window4.get()); |
| 1182 wm::ActivateWindow(window3.get()); | 1186 wm::ActivateWindow(window3.get()); |
| 1183 wm::ActivateWindow(window2.get()); | 1187 wm::ActivateWindow(window2.get()); |
| 1184 wm::ActivateWindow(window1.get()); | 1188 wm::ActivateWindow(window1.get()); |
| 1185 | 1189 |
| 1186 ToggleOverview(); | 1190 ToggleOverview(); |
| 1187 EXPECT_TRUE(IsSelecting()); | 1191 EXPECT_TRUE(IsSelecting()); |
| 1188 UpdateDisplay("400x400"); | 1192 UpdateDisplay("400x400"); |
| 1189 EXPECT_FALSE(IsSelecting()); | 1193 EXPECT_FALSE(IsSelecting()); |
| 1190 } | 1194 } |
| 1191 | 1195 |
| 1192 // Tests starting overview during a drag and drop tracking operation. | 1196 // Tests starting overview during a drag and drop tracking operation. |
| 1193 // TODO(flackr): Fix memory corruption crash when running locally (not failing | 1197 // TODO(flackr): Fix memory corruption crash when running locally (not failing |
| 1194 // on bots). See http://crbug.com/342528. | 1198 // on bots). See http://crbug.com/342528. |
| 1195 TEST_F(WindowSelectorTest, DISABLED_DragDropInProgress) { | 1199 TEST_F(WindowSelectorTest, DISABLED_DragDropInProgress) { |
| 1196 bool drag_canceled_by_test = false; | 1200 bool drag_canceled_by_test = false; |
| 1197 gfx::Rect bounds(0, 0, 400, 400); | 1201 gfx::Rect bounds(0, 0, 400, 400); |
| 1198 scoped_ptr<aura::Window> window(CreateWindow(bounds)); | 1202 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); |
| 1199 test::ShellTestApi shell_test_api(Shell::GetInstance()); | 1203 test::ShellTestApi shell_test_api(Shell::GetInstance()); |
| 1200 ash::DragDropController* drag_drop_controller = | 1204 ash::DragDropController* drag_drop_controller = |
| 1201 shell_test_api.drag_drop_controller(); | 1205 shell_test_api.drag_drop_controller(); |
| 1202 ui::OSExchangeData data; | 1206 ui::OSExchangeData data; |
| 1203 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1207 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1204 FROM_HERE, | 1208 FROM_HERE, |
| 1205 base::Bind(&WindowSelectorTest::ToggleOverview, base::Unretained(this))); | 1209 base::Bind(&WindowSelectorTest::ToggleOverview, base::Unretained(this))); |
| 1206 base::ThreadTaskRunnerHandle::Get()->PostTask( | 1210 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 1207 FROM_HERE, | 1211 FROM_HERE, |
| 1208 base::Bind(&CancelDrag, drag_drop_controller, &drag_canceled_by_test)); | 1212 base::Bind(&CancelDrag, drag_drop_controller, &drag_canceled_by_test)); |
| 1209 data.SetString(base::UTF8ToUTF16("I am being dragged")); | 1213 data.SetString(base::UTF8ToUTF16("I am being dragged")); |
| 1210 drag_drop_controller->StartDragAndDrop(data, window->GetRootWindow(), | 1214 drag_drop_controller->StartDragAndDrop(data, window->GetRootWindow(), |
| 1211 window.get(), gfx::Point(5, 5), ui::DragDropTypes::DRAG_MOVE, | 1215 window.get(), gfx::Point(5, 5), ui::DragDropTypes::DRAG_MOVE, |
| 1212 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); | 1216 ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); |
| 1213 RunAllPendingInMessageLoop(); | 1217 RunAllPendingInMessageLoop(); |
| 1214 EXPECT_FALSE(drag_canceled_by_test); | 1218 EXPECT_FALSE(drag_canceled_by_test); |
| 1215 ASSERT_TRUE(IsSelecting()); | 1219 ASSERT_TRUE(IsSelecting()); |
| 1216 RunAllPendingInMessageLoop(); | 1220 RunAllPendingInMessageLoop(); |
| 1217 } | 1221 } |
| 1218 | 1222 |
| 1219 // Test that a label is created under the window on entering overview mode. | 1223 // Test that a label is created under the window on entering overview mode. |
| 1220 TEST_F(WindowSelectorTest, CreateLabelUnderWindow) { | 1224 TEST_F(WindowSelectorTest, CreateLabelUnderWindow) { |
| 1221 scoped_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 100, 100))); | 1225 std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 100, 100))); |
| 1222 base::string16 window_title = base::UTF8ToUTF16("My window"); | 1226 base::string16 window_title = base::UTF8ToUTF16("My window"); |
| 1223 window->SetTitle(window_title); | 1227 window->SetTitle(window_title); |
| 1224 ToggleOverview(); | 1228 ToggleOverview(); |
| 1225 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back(); | 1229 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back(); |
| 1226 views::LabelButton* label = GetLabelButtonView(window_item); | 1230 views::LabelButton* label = GetLabelButtonView(window_item); |
| 1227 // Has the label view been created? | 1231 // Has the label view been created? |
| 1228 ASSERT_TRUE(label); | 1232 ASSERT_TRUE(label); |
| 1229 | 1233 |
| 1230 // Verify the label matches the window title. | 1234 // Verify the label matches the window title. |
| 1231 EXPECT_EQ(label->GetText(), window_title); | 1235 EXPECT_EQ(label->GetText(), window_title); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1270 for (ScopedVector<aura::Window>::iterator iter = windows.begin(); | 1274 for (ScopedVector<aura::Window>::iterator iter = windows.begin(); |
| 1271 iter != windows.end(); ++iter) { | 1275 iter != windows.end(); ++iter) { |
| 1272 EXPECT_TRUE(root_window->bounds().Contains( | 1276 EXPECT_TRUE(root_window->bounds().Contains( |
| 1273 ToEnclosingRect(GetTransformedTargetBounds(*iter)))); | 1277 ToEnclosingRect(GetTransformedTargetBounds(*iter)))); |
| 1274 } | 1278 } |
| 1275 } | 1279 } |
| 1276 | 1280 |
| 1277 // Tests traversing some windows in overview mode with the tab key. | 1281 // Tests traversing some windows in overview mode with the tab key. |
| 1278 TEST_F(WindowSelectorTest, BasicTabKeyNavigation) { | 1282 TEST_F(WindowSelectorTest, BasicTabKeyNavigation) { |
| 1279 gfx::Rect bounds(0, 0, 100, 100); | 1283 gfx::Rect bounds(0, 0, 100, 100); |
| 1280 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 1284 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 1281 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 1285 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 1282 ToggleOverview(); | 1286 ToggleOverview(); |
| 1283 | 1287 |
| 1284 const std::vector<WindowSelectorItem*>& overview_windows = | 1288 const std::vector<WindowSelectorItem*>& overview_windows = |
| 1285 GetWindowItemsForRoot(0); | 1289 GetWindowItemsForRoot(0); |
| 1286 SendKey(ui::VKEY_TAB); | 1290 SendKey(ui::VKEY_TAB); |
| 1287 EXPECT_EQ(GetSelectedWindow(), overview_windows[0]->GetWindow()); | 1291 EXPECT_EQ(GetSelectedWindow(), overview_windows[0]->GetWindow()); |
| 1288 SendKey(ui::VKEY_TAB); | 1292 SendKey(ui::VKEY_TAB); |
| 1289 EXPECT_EQ(GetSelectedWindow(), overview_windows[1]->GetWindow()); | 1293 EXPECT_EQ(GetSelectedWindow(), overview_windows[1]->GetWindow()); |
| 1290 SendKey(ui::VKEY_TAB); | 1294 SendKey(ui::VKEY_TAB); |
| 1291 EXPECT_EQ(GetSelectedWindow(), overview_windows[0]->GetWindow()); | 1295 EXPECT_EQ(GetSelectedWindow(), overview_windows[0]->GetWindow()); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1346 } | 1350 } |
| 1347 | 1351 |
| 1348 // Tests basic selection across multiple monitors. | 1352 // Tests basic selection across multiple monitors. |
| 1349 TEST_F(WindowSelectorTest, BasicMultiMonitorArrowKeyNavigation) { | 1353 TEST_F(WindowSelectorTest, BasicMultiMonitorArrowKeyNavigation) { |
| 1350 if (!SupportsMultipleDisplays()) | 1354 if (!SupportsMultipleDisplays()) |
| 1351 return; | 1355 return; |
| 1352 | 1356 |
| 1353 UpdateDisplay("400x400,400x400"); | 1357 UpdateDisplay("400x400,400x400"); |
| 1354 gfx::Rect bounds1(0, 0, 100, 100); | 1358 gfx::Rect bounds1(0, 0, 100, 100); |
| 1355 gfx::Rect bounds2(450, 0, 100, 100); | 1359 gfx::Rect bounds2(450, 0, 100, 100); |
| 1356 scoped_ptr<aura::Window> window4(CreateWindow(bounds2)); | 1360 std::unique_ptr<aura::Window> window4(CreateWindow(bounds2)); |
| 1357 scoped_ptr<aura::Window> window3(CreateWindow(bounds2)); | 1361 std::unique_ptr<aura::Window> window3(CreateWindow(bounds2)); |
| 1358 scoped_ptr<aura::Window> window2(CreateWindow(bounds1)); | 1362 std::unique_ptr<aura::Window> window2(CreateWindow(bounds1)); |
| 1359 scoped_ptr<aura::Window> window1(CreateWindow(bounds1)); | 1363 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); |
| 1360 | |
| 1361 | 1364 |
| 1362 ToggleOverview(); | 1365 ToggleOverview(); |
| 1363 | 1366 |
| 1364 const std::vector<WindowSelectorItem*>& overview_root1 = | 1367 const std::vector<WindowSelectorItem*>& overview_root1 = |
| 1365 GetWindowItemsForRoot(0); | 1368 GetWindowItemsForRoot(0); |
| 1366 const std::vector<WindowSelectorItem*>& overview_root2 = | 1369 const std::vector<WindowSelectorItem*>& overview_root2 = |
| 1367 GetWindowItemsForRoot(1); | 1370 GetWindowItemsForRoot(1); |
| 1368 SendKey(ui::VKEY_RIGHT); | 1371 SendKey(ui::VKEY_RIGHT); |
| 1369 EXPECT_EQ(GetSelectedWindow(), overview_root1[0]->GetWindow()); | 1372 EXPECT_EQ(GetSelectedWindow(), overview_root1[0]->GetWindow()); |
| 1370 SendKey(ui::VKEY_RIGHT); | 1373 SendKey(ui::VKEY_RIGHT); |
| 1371 EXPECT_EQ(GetSelectedWindow(), overview_root1[1]->GetWindow()); | 1374 EXPECT_EQ(GetSelectedWindow(), overview_root1[1]->GetWindow()); |
| 1372 SendKey(ui::VKEY_RIGHT); | 1375 SendKey(ui::VKEY_RIGHT); |
| 1373 EXPECT_EQ(GetSelectedWindow(), overview_root2[0]->GetWindow()); | 1376 EXPECT_EQ(GetSelectedWindow(), overview_root2[0]->GetWindow()); |
| 1374 SendKey(ui::VKEY_RIGHT); | 1377 SendKey(ui::VKEY_RIGHT); |
| 1375 EXPECT_EQ(GetSelectedWindow(), overview_root2[1]->GetWindow()); | 1378 EXPECT_EQ(GetSelectedWindow(), overview_root2[1]->GetWindow()); |
| 1376 } | 1379 } |
| 1377 | 1380 |
| 1378 // Tests first monitor when display order doesn't match left to right screen | 1381 // Tests first monitor when display order doesn't match left to right screen |
| 1379 // positions. | 1382 // positions. |
| 1380 TEST_F(WindowSelectorTest, MultiMonitorReversedOrder) { | 1383 TEST_F(WindowSelectorTest, MultiMonitorReversedOrder) { |
| 1381 if (!SupportsMultipleDisplays()) | 1384 if (!SupportsMultipleDisplays()) |
| 1382 return; | 1385 return; |
| 1383 | 1386 |
| 1384 UpdateDisplay("400x400,400x400"); | 1387 UpdateDisplay("400x400,400x400"); |
| 1385 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( | 1388 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( |
| 1386 test::CreateDisplayLayout(display::DisplayPlacement::LEFT, 0)); | 1389 test::CreateDisplayLayout(display::DisplayPlacement::LEFT, 0)); |
| 1387 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1390 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1388 gfx::Rect bounds1(-350, 0, 100, 100); | 1391 gfx::Rect bounds1(-350, 0, 100, 100); |
| 1389 gfx::Rect bounds2(0, 0, 100, 100); | 1392 gfx::Rect bounds2(0, 0, 100, 100); |
| 1390 scoped_ptr<aura::Window> window2(CreateWindow(bounds2)); | 1393 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); |
| 1391 scoped_ptr<aura::Window> window1(CreateWindow(bounds1)); | 1394 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); |
| 1392 EXPECT_EQ(root_windows[1], window1->GetRootWindow()); | 1395 EXPECT_EQ(root_windows[1], window1->GetRootWindow()); |
| 1393 EXPECT_EQ(root_windows[0], window2->GetRootWindow()); | 1396 EXPECT_EQ(root_windows[0], window2->GetRootWindow()); |
| 1394 | 1397 |
| 1395 ToggleOverview(); | 1398 ToggleOverview(); |
| 1396 | 1399 |
| 1397 // Coming from the left to right, we should select window1 first being on the | 1400 // Coming from the left to right, we should select window1 first being on the |
| 1398 // display to the left. | 1401 // display to the left. |
| 1399 SendKey(ui::VKEY_RIGHT); | 1402 SendKey(ui::VKEY_RIGHT); |
| 1400 EXPECT_EQ(GetSelectedWindow(), window1.get()); | 1403 EXPECT_EQ(GetSelectedWindow(), window1.get()); |
| 1401 | 1404 |
| 1402 ToggleOverview(); | 1405 ToggleOverview(); |
| 1403 ToggleOverview(); | 1406 ToggleOverview(); |
| 1404 | 1407 |
| 1405 // Coming from right to left, we should select window2 first being on the | 1408 // Coming from right to left, we should select window2 first being on the |
| 1406 // display on the right. | 1409 // display on the right. |
| 1407 SendKey(ui::VKEY_LEFT); | 1410 SendKey(ui::VKEY_LEFT); |
| 1408 EXPECT_EQ(GetSelectedWindow(), window2.get()); | 1411 EXPECT_EQ(GetSelectedWindow(), window2.get()); |
| 1409 } | 1412 } |
| 1410 | 1413 |
| 1411 // Tests three monitors where the grid becomes empty on one of the monitors. | 1414 // Tests three monitors where the grid becomes empty on one of the monitors. |
| 1412 TEST_F(WindowSelectorTest, ThreeMonitor) { | 1415 TEST_F(WindowSelectorTest, ThreeMonitor) { |
| 1413 if (!SupportsMultipleDisplays()) | 1416 if (!SupportsMultipleDisplays()) |
| 1414 return; | 1417 return; |
| 1415 | 1418 |
| 1416 UpdateDisplay("400x400,400x400,400x400"); | 1419 UpdateDisplay("400x400,400x400,400x400"); |
| 1417 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 1420 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
| 1418 gfx::Rect bounds1(0, 0, 100, 100); | 1421 gfx::Rect bounds1(0, 0, 100, 100); |
| 1419 gfx::Rect bounds2(400, 0, 100, 100); | 1422 gfx::Rect bounds2(400, 0, 100, 100); |
| 1420 gfx::Rect bounds3(800, 0, 100, 100); | 1423 gfx::Rect bounds3(800, 0, 100, 100); |
| 1421 scoped_ptr<aura::Window> window3(CreateWindow(bounds3)); | 1424 std::unique_ptr<aura::Window> window3(CreateWindow(bounds3)); |
| 1422 scoped_ptr<aura::Window> window2(CreateWindow(bounds2)); | 1425 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); |
| 1423 scoped_ptr<aura::Window> window1(CreateWindow(bounds1)); | 1426 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); |
| 1424 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); | 1427 EXPECT_EQ(root_windows[0], window1->GetRootWindow()); |
| 1425 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); | 1428 EXPECT_EQ(root_windows[1], window2->GetRootWindow()); |
| 1426 EXPECT_EQ(root_windows[2], window3->GetRootWindow()); | 1429 EXPECT_EQ(root_windows[2], window3->GetRootWindow()); |
| 1427 | 1430 |
| 1428 ToggleOverview(); | 1431 ToggleOverview(); |
| 1429 | 1432 |
| 1430 SendKey(ui::VKEY_RIGHT); | 1433 SendKey(ui::VKEY_RIGHT); |
| 1431 SendKey(ui::VKEY_RIGHT); | 1434 SendKey(ui::VKEY_RIGHT); |
| 1432 SendKey(ui::VKEY_RIGHT); | 1435 SendKey(ui::VKEY_RIGHT); |
| 1433 EXPECT_EQ(GetSelectedWindow(), window3.get()); | 1436 EXPECT_EQ(GetSelectedWindow(), window3.get()); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1447 // If the window on the second display is removed, the selected window should | 1450 // If the window on the second display is removed, the selected window should |
| 1448 // remain window3. | 1451 // remain window3. |
| 1449 EXPECT_EQ(GetSelectedWindow(), window3.get()); | 1452 EXPECT_EQ(GetSelectedWindow(), window3.get()); |
| 1450 window2.reset(); | 1453 window2.reset(); |
| 1451 EXPECT_EQ(GetSelectedWindow(), window3.get()); | 1454 EXPECT_EQ(GetSelectedWindow(), window3.get()); |
| 1452 } | 1455 } |
| 1453 | 1456 |
| 1454 // Tests selecting a window in overview mode with the return key. | 1457 // Tests selecting a window in overview mode with the return key. |
| 1455 TEST_F(WindowSelectorTest, SelectWindowWithReturnKey) { | 1458 TEST_F(WindowSelectorTest, SelectWindowWithReturnKey) { |
| 1456 gfx::Rect bounds(0, 0, 100, 100); | 1459 gfx::Rect bounds(0, 0, 100, 100); |
| 1457 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 1460 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 1458 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 1461 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 1459 ToggleOverview(); | 1462 ToggleOverview(); |
| 1460 | 1463 |
| 1461 // Pressing the return key without a selection widget should not do anything. | 1464 // Pressing the return key without a selection widget should not do anything. |
| 1462 SendKey(ui::VKEY_RETURN); | 1465 SendKey(ui::VKEY_RETURN); |
| 1463 EXPECT_TRUE(IsSelecting()); | 1466 EXPECT_TRUE(IsSelecting()); |
| 1464 | 1467 |
| 1465 // Select the first window. | 1468 // Select the first window. |
| 1466 ASSERT_TRUE(SelectWindow(window1.get())); | 1469 ASSERT_TRUE(SelectWindow(window1.get())); |
| 1467 SendKey(ui::VKEY_RETURN); | 1470 SendKey(ui::VKEY_RETURN); |
| 1468 ASSERT_FALSE(IsSelecting()); | 1471 ASSERT_FALSE(IsSelecting()); |
| 1469 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); | 1472 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); |
| 1470 | 1473 |
| 1471 // Select the second window. | 1474 // Select the second window. |
| 1472 ToggleOverview(); | 1475 ToggleOverview(); |
| 1473 ASSERT_TRUE(SelectWindow(window2.get())); | 1476 ASSERT_TRUE(SelectWindow(window2.get())); |
| 1474 SendKey(ui::VKEY_RETURN); | 1477 SendKey(ui::VKEY_RETURN); |
| 1475 EXPECT_FALSE(IsSelecting()); | 1478 EXPECT_FALSE(IsSelecting()); |
| 1476 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); | 1479 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); |
| 1477 } | 1480 } |
| 1478 | 1481 |
| 1479 // Tests that overview mode hides the callout widget. | 1482 // Tests that overview mode hides the callout widget. |
| 1480 TEST_F(WindowSelectorTest, WindowOverviewHidesCalloutWidgets) { | 1483 TEST_F(WindowSelectorTest, WindowOverviewHidesCalloutWidgets) { |
| 1481 scoped_ptr<aura::Window> panel1(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); | 1484 std::unique_ptr<aura::Window> panel1( |
| 1482 scoped_ptr<aura::Window> panel2(CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); | 1485 CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); |
| 1486 std::unique_ptr<aura::Window> panel2( |
| 1487 CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); |
| 1483 PanelLayoutManager* panel_manager = | 1488 PanelLayoutManager* panel_manager = |
| 1484 static_cast<PanelLayoutManager*>(panel1->parent()->layout_manager()); | 1489 static_cast<PanelLayoutManager*>(panel1->parent()->layout_manager()); |
| 1485 | 1490 |
| 1486 // By default, panel callout widgets are visible. | 1491 // By default, panel callout widgets are visible. |
| 1487 EXPECT_TRUE( | 1492 EXPECT_TRUE( |
| 1488 panel_manager->GetCalloutWidgetForPanel(panel1.get())->IsVisible()); | 1493 panel_manager->GetCalloutWidgetForPanel(panel1.get())->IsVisible()); |
| 1489 EXPECT_TRUE( | 1494 EXPECT_TRUE( |
| 1490 panel_manager->GetCalloutWidgetForPanel(panel2.get())->IsVisible()); | 1495 panel_manager->GetCalloutWidgetForPanel(panel2.get())->IsVisible()); |
| 1491 | 1496 |
| 1492 // Toggling the overview should hide the callout widgets. | 1497 // Toggling the overview should hide the callout widgets. |
| 1493 ToggleOverview(); | 1498 ToggleOverview(); |
| 1494 EXPECT_FALSE( | 1499 EXPECT_FALSE( |
| 1495 panel_manager->GetCalloutWidgetForPanel(panel1.get())->IsVisible()); | 1500 panel_manager->GetCalloutWidgetForPanel(panel1.get())->IsVisible()); |
| 1496 EXPECT_FALSE( | 1501 EXPECT_FALSE( |
| 1497 panel_manager->GetCalloutWidgetForPanel(panel2.get())->IsVisible()); | 1502 panel_manager->GetCalloutWidgetForPanel(panel2.get())->IsVisible()); |
| 1498 | 1503 |
| 1499 // Ending the overview should show them again. | 1504 // Ending the overview should show them again. |
| 1500 ToggleOverview(); | 1505 ToggleOverview(); |
| 1501 EXPECT_TRUE( | 1506 EXPECT_TRUE( |
| 1502 panel_manager->GetCalloutWidgetForPanel(panel1.get())->IsVisible()); | 1507 panel_manager->GetCalloutWidgetForPanel(panel1.get())->IsVisible()); |
| 1503 EXPECT_TRUE( | 1508 EXPECT_TRUE( |
| 1504 panel_manager->GetCalloutWidgetForPanel(panel2.get())->IsVisible()); | 1509 panel_manager->GetCalloutWidgetForPanel(panel2.get())->IsVisible()); |
| 1505 } | 1510 } |
| 1506 | 1511 |
| 1507 // Creates three windows and tests filtering them by title. | 1512 // Creates three windows and tests filtering them by title. |
| 1508 TEST_F(WindowSelectorTest, BasicTextFiltering) { | 1513 TEST_F(WindowSelectorTest, BasicTextFiltering) { |
| 1509 gfx::Rect bounds(0, 0, 100, 100); | 1514 gfx::Rect bounds(0, 0, 100, 100); |
| 1510 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 1515 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 1511 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 1516 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 1512 scoped_ptr<aura::Window> window0(CreateWindow(bounds)); | 1517 std::unique_ptr<aura::Window> window0(CreateWindow(bounds)); |
| 1513 base::string16 window2_title = base::UTF8ToUTF16("Highway to test"); | 1518 base::string16 window2_title = base::UTF8ToUTF16("Highway to test"); |
| 1514 base::string16 window1_title = base::UTF8ToUTF16("For those about to test"); | 1519 base::string16 window1_title = base::UTF8ToUTF16("For those about to test"); |
| 1515 base::string16 window0_title = base::UTF8ToUTF16("We salute you"); | 1520 base::string16 window0_title = base::UTF8ToUTF16("We salute you"); |
| 1516 window0->SetTitle(window0_title); | 1521 window0->SetTitle(window0_title); |
| 1517 window1->SetTitle(window1_title); | 1522 window1->SetTitle(window1_title); |
| 1518 window2->SetTitle(window2_title); | 1523 window2->SetTitle(window2_title); |
| 1519 ToggleOverview(); | 1524 ToggleOverview(); |
| 1520 | 1525 |
| 1521 EXPECT_FALSE(selection_widget_active()); | 1526 EXPECT_FALSE(selection_widget_active()); |
| 1522 EXPECT_FALSE(showing_filter_widget()); | 1527 EXPECT_FALSE(showing_filter_widget()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1547 FilterItems(""); | 1552 FilterItems(""); |
| 1548 EXPECT_FALSE(showing_filter_widget()); | 1553 EXPECT_FALSE(showing_filter_widget()); |
| 1549 EXPECT_FALSE(GetWindowItemForWindow(grid_index, window0.get())->dimmed()); | 1554 EXPECT_FALSE(GetWindowItemForWindow(grid_index, window0.get())->dimmed()); |
| 1550 EXPECT_FALSE(GetWindowItemForWindow(grid_index, window1.get())->dimmed()); | 1555 EXPECT_FALSE(GetWindowItemForWindow(grid_index, window1.get())->dimmed()); |
| 1551 EXPECT_FALSE(GetWindowItemForWindow(grid_index, window2.get())->dimmed()); | 1556 EXPECT_FALSE(GetWindowItemForWindow(grid_index, window2.get())->dimmed()); |
| 1552 } | 1557 } |
| 1553 | 1558 |
| 1554 // Tests selecting in the overview with dimmed and undimmed items. | 1559 // Tests selecting in the overview with dimmed and undimmed items. |
| 1555 TEST_F(WindowSelectorTest, TextFilteringSelection) { | 1560 TEST_F(WindowSelectorTest, TextFilteringSelection) { |
| 1556 gfx::Rect bounds(0, 0, 100, 100); | 1561 gfx::Rect bounds(0, 0, 100, 100); |
| 1557 scoped_ptr<aura::Window> window2(CreateWindow(bounds)); | 1562 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); |
| 1558 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 1563 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 1559 scoped_ptr<aura::Window> window0(CreateWindow(bounds)); | 1564 std::unique_ptr<aura::Window> window0(CreateWindow(bounds)); |
| 1560 base::string16 window2_title = base::UTF8ToUTF16("Rock and roll"); | 1565 base::string16 window2_title = base::UTF8ToUTF16("Rock and roll"); |
| 1561 base::string16 window1_title = base::UTF8ToUTF16("Rock and"); | 1566 base::string16 window1_title = base::UTF8ToUTF16("Rock and"); |
| 1562 base::string16 window0_title = base::UTF8ToUTF16("Rock"); | 1567 base::string16 window0_title = base::UTF8ToUTF16("Rock"); |
| 1563 window0->SetTitle(window0_title); | 1568 window0->SetTitle(window0_title); |
| 1564 window1->SetTitle(window1_title); | 1569 window1->SetTitle(window1_title); |
| 1565 window2->SetTitle(window2_title); | 1570 window2->SetTitle(window2_title); |
| 1566 ToggleOverview(); | 1571 ToggleOverview(); |
| 1567 EXPECT_TRUE(SelectWindow(window0.get())); | 1572 EXPECT_TRUE(SelectWindow(window0.get())); |
| 1568 EXPECT_TRUE(selection_widget_active()); | 1573 EXPECT_TRUE(selection_widget_active()); |
| 1569 | 1574 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1587 // Tests clicking on the desktop itself to cancel overview mode. | 1592 // Tests clicking on the desktop itself to cancel overview mode. |
| 1588 TEST_F(WindowSelectorTest, CancelOverviewOnMouseClick) { | 1593 TEST_F(WindowSelectorTest, CancelOverviewOnMouseClick) { |
| 1589 // Overview disabled by default. | 1594 // Overview disabled by default. |
| 1590 EXPECT_FALSE(IsSelecting()); | 1595 EXPECT_FALSE(IsSelecting()); |
| 1591 | 1596 |
| 1592 // Point and bounds selected so that they don't intersect. This causes | 1597 // Point and bounds selected so that they don't intersect. This causes |
| 1593 // events located at the point to be passed to DesktopBackgroundController, | 1598 // events located at the point to be passed to DesktopBackgroundController, |
| 1594 // and not the window. | 1599 // and not the window. |
| 1595 gfx::Point point_in_background_page(0, 0); | 1600 gfx::Point point_in_background_page(0, 0); |
| 1596 gfx::Rect bounds(10, 10, 100, 100); | 1601 gfx::Rect bounds(10, 10, 100, 100); |
| 1597 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 1602 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 1598 ui::test::EventGenerator& generator = GetEventGenerator(); | 1603 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 1599 // Move mouse to point in the background page. Sending an event here will pass | 1604 // Move mouse to point in the background page. Sending an event here will pass |
| 1600 // it to the DesktopBackgroundController in both regular and overview mode. | 1605 // it to the DesktopBackgroundController in both regular and overview mode. |
| 1601 generator.MoveMouseTo(point_in_background_page); | 1606 generator.MoveMouseTo(point_in_background_page); |
| 1602 | 1607 |
| 1603 // Clicking on the background page while not in overview should not toggle | 1608 // Clicking on the background page while not in overview should not toggle |
| 1604 // overview. | 1609 // overview. |
| 1605 generator.ClickLeftButton(); | 1610 generator.ClickLeftButton(); |
| 1606 EXPECT_FALSE(IsSelecting()); | 1611 EXPECT_FALSE(IsSelecting()); |
| 1607 | 1612 |
| 1608 // Switch to overview mode. | 1613 // Switch to overview mode. |
| 1609 ToggleOverview(); | 1614 ToggleOverview(); |
| 1610 ASSERT_TRUE(IsSelecting()); | 1615 ASSERT_TRUE(IsSelecting()); |
| 1611 | 1616 |
| 1612 // Click should now exit overview mode. | 1617 // Click should now exit overview mode. |
| 1613 generator.ClickLeftButton(); | 1618 generator.ClickLeftButton(); |
| 1614 EXPECT_FALSE(IsSelecting()); | 1619 EXPECT_FALSE(IsSelecting()); |
| 1615 } | 1620 } |
| 1616 | 1621 |
| 1617 // Tests tapping on the desktop itself to cancel overview mode. | 1622 // Tests tapping on the desktop itself to cancel overview mode. |
| 1618 TEST_F(WindowSelectorTest, CancelOverviewOnTap) { | 1623 TEST_F(WindowSelectorTest, CancelOverviewOnTap) { |
| 1619 // Overview disabled by default. | 1624 // Overview disabled by default. |
| 1620 EXPECT_FALSE(IsSelecting()); | 1625 EXPECT_FALSE(IsSelecting()); |
| 1621 | 1626 |
| 1622 // Point and bounds selected so that they don't intersect. This causes | 1627 // Point and bounds selected so that they don't intersect. This causes |
| 1623 // events located at the point to be passed to DesktopBackgroundController, | 1628 // events located at the point to be passed to DesktopBackgroundController, |
| 1624 // and not the window. | 1629 // and not the window. |
| 1625 gfx::Point point_in_background_page(0, 0); | 1630 gfx::Point point_in_background_page(0, 0); |
| 1626 gfx::Rect bounds(10, 10, 100, 100); | 1631 gfx::Rect bounds(10, 10, 100, 100); |
| 1627 scoped_ptr<aura::Window> window1(CreateWindow(bounds)); | 1632 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); |
| 1628 ui::test::EventGenerator& generator = GetEventGenerator(); | 1633 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 1629 | 1634 |
| 1630 // Tapping on the background page while not in overview should not toggle | 1635 // Tapping on the background page while not in overview should not toggle |
| 1631 // overview. | 1636 // overview. |
| 1632 generator.GestureTapAt(point_in_background_page); | 1637 generator.GestureTapAt(point_in_background_page); |
| 1633 EXPECT_FALSE(IsSelecting()); | 1638 EXPECT_FALSE(IsSelecting()); |
| 1634 | 1639 |
| 1635 // Switch to overview mode. | 1640 // Switch to overview mode. |
| 1636 ToggleOverview(); | 1641 ToggleOverview(); |
| 1637 ASSERT_TRUE(IsSelecting()); | 1642 ASSERT_TRUE(IsSelecting()); |
| 1638 | 1643 |
| 1639 // Tap should now exit overview mode. | 1644 // Tap should now exit overview mode. |
| 1640 generator.GestureTapAt(point_in_background_page); | 1645 generator.GestureTapAt(point_in_background_page); |
| 1641 EXPECT_FALSE(IsSelecting()); | 1646 EXPECT_FALSE(IsSelecting()); |
| 1642 } | 1647 } |
| 1643 | 1648 |
| 1644 } // namespace ash | 1649 } // namespace ash |
| OLD | NEW |