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

Side by Side Diff: ash/wm/overview/window_selector_unittest.cc

Issue 2401473002: [ash-md] Erases the pre-MD code path for Overview Mode (Closed)
Patch Set: [ash-md] Erases the pre-MD code path for Overview Mode (comments) Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 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/aura/wm_window_aura.h" 8 #include "ash/aura/wm_window_aura.h"
9 #include "ash/common/accessibility_delegate.h" 9 #include "ash/common/accessibility_delegate.h"
10 #include "ash/common/accessibility_types.h" 10 #include "ash/common/accessibility_types.h"
11 #include "ash/common/ash_switches.h" 11 #include "ash/common/ash_switches.h"
12 #include "ash/common/material_design/material_design_controller.h"
13 #include "ash/common/shelf/shelf_widget.h" 12 #include "ash/common/shelf/shelf_widget.h"
14 #include "ash/common/shelf/wm_shelf.h" 13 #include "ash/common/shelf/wm_shelf.h"
15 #include "ash/common/shell_window_ids.h" 14 #include "ash/common/shell_window_ids.h"
16 #include "ash/common/system/tray/system_tray.h" 15 #include "ash/common/system/tray/system_tray.h"
17 #include "ash/common/test/material_design_controller_test_api.h"
18 #include "ash/common/wm/dock/docked_window_layout_manager.h" 16 #include "ash/common/wm/dock/docked_window_layout_manager.h"
19 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 17 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
20 #include "ash/common/wm/mru_window_tracker.h" 18 #include "ash/common/wm/mru_window_tracker.h"
21 #include "ash/common/wm/overview/scoped_transform_overview_window.h" 19 #include "ash/common/wm/overview/scoped_transform_overview_window.h"
22 #include "ash/common/wm/overview/window_grid.h" 20 #include "ash/common/wm/overview/window_grid.h"
23 #include "ash/common/wm/overview/window_selector.h" 21 #include "ash/common/wm/overview/window_selector.h"
24 #include "ash/common/wm/overview/window_selector_controller.h" 22 #include "ash/common/wm/overview/window_selector_controller.h"
25 #include "ash/common/wm/overview/window_selector_item.h" 23 #include "ash/common/wm/overview/window_selector_item.h"
26 #include "ash/common/wm/panels/panel_layout_manager.h" 24 #include "ash/common/wm/panels/panel_layout_manager.h"
27 #include "ash/common/wm/window_state.h" 25 #include "ash/common/wm/window_state.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 #include "ui/views/controls/button/image_button.h" 67 #include "ui/views/controls/button/image_button.h"
70 #include "ui/views/controls/button/label_button.h" 68 #include "ui/views/controls/button/label_button.h"
71 #include "ui/views/widget/native_widget_aura.h" 69 #include "ui/views/widget/native_widget_aura.h"
72 #include "ui/views/widget/widget_delegate.h" 70 #include "ui/views/widget/widget_delegate.h"
73 #include "ui/wm/core/window_util.h" 71 #include "ui/wm/core/window_util.h"
74 #include "ui/wm/public/activation_delegate.h" 72 #include "ui/wm/public/activation_delegate.h"
75 73
76 namespace ash { 74 namespace ash {
77 namespace { 75 namespace {
78 76
79 // With Material Design the label covers selector item windows with a padding 77 // The label covers selector item windows with a padding in order to prevent
80 // in order to prevent them from receiving user input events while in overview. 78 // them from receiving user input events while in overview.
81 static const int kWindowMarginMD = 5; 79 static const int kWindowMargin = 5;
82 80
83 // With Material Design the overview mode header overlaps original window 81 // The overview mode header overlaps original window header. This value is used
84 // header. This value is used to set top inset property on the windows. 82 // to set top inset property on the windows.
85 static const int kHeaderHeight = 32; 83 static const int kHeaderHeight = 32;
86 84
87 const char kActiveWindowChangedFromOverview[] = 85 const char kActiveWindowChangedFromOverview[] =
88 "WindowSelector_ActiveWindowChanged"; 86 "WindowSelector_ActiveWindowChanged";
89 87
90 class NonActivatableActivationDelegate 88 class NonActivatableActivationDelegate
91 : public aura::client::ActivationDelegate { 89 : public aura::client::ActivationDelegate {
92 public: 90 public:
93 bool ShouldActivate() const override { return false; } 91 bool ShouldActivate() const override { return false; }
94 }; 92 };
(...skipping 10 matching lines...) Expand all
105 int top_view_inset, 103 int top_view_inset,
106 int title_height) { 104 int title_height) {
107 return ScopedTransformOverviewWindow::GetItemScale( 105 return ScopedTransformOverviewWindow::GetItemScale(
108 source.size(), target.size(), top_view_inset, title_height); 106 source.size(), target.size(), top_view_inset, title_height);
109 } 107 }
110 108
111 } // namespace 109 } // namespace
112 110
113 // TODO(bruthig): Move all non-simple method definitions out of class 111 // TODO(bruthig): Move all non-simple method definitions out of class
114 // declaration. 112 // declaration.
115 class WindowSelectorTest 113 class WindowSelectorTest : public test::AshTestBase {
116 : public test::AshTestBase,
117 public testing::WithParamInterface<ash::MaterialDesignController::Mode> {
118 public: 114 public:
119 WindowSelectorTest() {} 115 WindowSelectorTest() {}
120 ~WindowSelectorTest() override {} 116 ~WindowSelectorTest() override {}
121 117
122 void SetUp() override { 118 void SetUp() override {
123 set_material_mode(GetParam());
124 test::AshTestBase::SetUp(); 119 test::AshTestBase::SetUp();
125 if (!ash::MaterialDesignController::IsOverviewMaterial()) {
126 base::CommandLine::ForCurrentProcess()->AppendSwitch(
127 switches::kAshEnableStableOverviewOrder);
128 }
129 ASSERT_TRUE(test::TestShelfDelegate::instance()); 120 ASSERT_TRUE(test::TestShelfDelegate::instance());
130 121
131 shelf_view_test_.reset(new test::ShelfViewTestAPI( 122 shelf_view_test_.reset(new test::ShelfViewTestAPI(
132 GetPrimaryShelf()->GetShelfViewForTesting())); 123 GetPrimaryShelf()->GetShelfViewForTesting()));
133 shelf_view_test_->SetAnimationDuration(1); 124 shelf_view_test_->SetAnimationDuration(1);
134 ScopedTransformOverviewWindow::SetImmediateCloseForTests(); 125 ScopedTransformOverviewWindow::SetImmediateCloseForTests();
135 } 126 }
136 127
137 aura::Window* CreateWindow(const gfx::Rect& bounds) { 128 aura::Window* CreateWindow(const gfx::Rect& bounds) {
138 aura::Window* window = 129 aura::Window* window =
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 } 344 }
354 345
355 private: 346 private:
356 aura::test::TestWindowDelegate delegate_; 347 aura::test::TestWindowDelegate delegate_;
357 NonActivatableActivationDelegate non_activatable_activation_delegate_; 348 NonActivatableActivationDelegate non_activatable_activation_delegate_;
358 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_; 349 std::unique_ptr<test::ShelfViewTestAPI> shelf_view_test_;
359 350
360 DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest); 351 DISALLOW_COPY_AND_ASSIGN(WindowSelectorTest);
361 }; 352 };
362 353
363 // Note: First argument is optional and intentionally left blank.
364 // (it's a prefix for the generated test cases)
365 INSTANTIATE_TEST_CASE_P(
366 ,
367 WindowSelectorTest,
368 testing::Values(ash::MaterialDesignController::NON_MATERIAL,
369 ash::MaterialDesignController::MATERIAL_NORMAL,
370 ash::MaterialDesignController::MATERIAL_EXPERIMENTAL));
371
372 #if !defined(OS_WIN) || defined(USE_ASH) 354 #if !defined(OS_WIN) || defined(USE_ASH)
373 // TODO(msw): Broken on Windows. http://crbug.com/584038 355 // TODO(msw): Broken on Windows. http://crbug.com/584038
374 // Tests that the text field in the overview menu is repositioned and resized 356 // Tests that the text field in the overview menu is repositioned and resized
375 // after a screen rotation. 357 // after a screen rotation.
376 TEST_P(WindowSelectorTest, OverviewScreenRotation) { 358 TEST_F(WindowSelectorTest, OverviewScreenRotation) {
377 gfx::Rect bounds(0, 0, 400, 300); 359 gfx::Rect bounds(0, 0, 400, 300);
378 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 360 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
379 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); 361 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds));
380 362
381 // In overview mode the windows should no longer overlap and the text filter 363 // In overview mode the windows should no longer overlap and the text filter
382 // widget should be focused. 364 // widget should be focused.
383 ToggleOverview(); 365 ToggleOverview();
384 366
385 views::Widget* text_filter = text_filter_widget(); 367 views::Widget* text_filter = text_filter_widget();
386 UpdateDisplay("400x300"); 368 UpdateDisplay("400x300");
387 369
388 // Formula for initial placement found in window_selector.cc using 370 // The text filter position is calculated as:
389 // width = 400, height = 300: 371 // x: 0.5 * (total_bounds.width() -
390 // x: 0.5 * root_window->bounds().width() * (1 - kTextFilterScreenProportion). 372 // std::min(kTextFilterWidth, total_bounds.width())).
391 // y: -kTextFilterHeight (since there's no text in the filter). 373 // y: -kTextFilterHeight (since there's no text in the filter).
392 // w: root_window->bounds().width() * kTextFilterScreenProportion. 374 // w: std::min(kTextFilterWidth, total_bounds.width()).
393 // h: kTextFilterHeight. 375 // h: kTextFilterHeight.
394 // 376 gfx::Rect expected_bounds(60, -40, 280, 40);
395 // With Material Design the text filter position is calculated as: 377 EXPECT_EQ(expected_bounds.ToString(),
396 // x: 0.5 * (total_bounds.width() -
397 // std::min(kTextFilterWidthMD, total_bounds.width())).
398 // y: -kTextFilterHeightMD (since there's no text in the filter).
399 // w: std::min(kTextFilterWidthMD, total_bounds.width()).
400 // h: kTextFilterHeightMD.
401 const bool material = ash::MaterialDesignController::IsOverviewMaterial();
402 gfx::Rect expected_bounds(150, -32, 100, 32);
403 gfx::Rect expected_bounds_MD(60, -40, 280, 40);
404 EXPECT_EQ((material ? expected_bounds_MD : expected_bounds).ToString(),
405 text_filter->GetClientAreaBoundsInScreen().ToString()); 378 text_filter->GetClientAreaBoundsInScreen().ToString());
406 379
407 // Rotates the display, which triggers the WindowSelector's 380 // Rotates the display, which triggers the WindowSelector's
408 // RepositionTextFilterOnDisplayMetricsChange method. 381 // RepositionTextFilterOnDisplayMetricsChange method.
409 UpdateDisplay("400x300/r"); 382 UpdateDisplay("400x300/r");
410 383
411 // Uses the same formulas as above using width = 300, height = 400. 384 // Uses the same formulas as above using width = 300, height = 400.
412 expected_bounds = gfx::Rect(112, -32, 75, 32); 385 expected_bounds = gfx::Rect(10, -40, 280, 40);
413 expected_bounds_MD = gfx::Rect(10, -40, 280, 40); 386 EXPECT_EQ(expected_bounds.ToString(),
414 EXPECT_EQ((material ? expected_bounds_MD : expected_bounds).ToString(),
415 text_filter->GetClientAreaBoundsInScreen().ToString()); 387 text_filter->GetClientAreaBoundsInScreen().ToString());
416 } 388 }
417 #endif 389 #endif
418 390
419 // Tests that an a11y alert is sent on entering overview mode. 391 // Tests that an a11y alert is sent on entering overview mode.
420 TEST_P(WindowSelectorTest, A11yAlertOnOverviewMode) { 392 TEST_F(WindowSelectorTest, A11yAlertOnOverviewMode) {
421 gfx::Rect bounds(0, 0, 400, 400); 393 gfx::Rect bounds(0, 0, 400, 400);
422 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); 394 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate();
423 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 395 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
424 EXPECT_NE(delegate->GetLastAccessibilityAlert(), 396 EXPECT_NE(delegate->GetLastAccessibilityAlert(),
425 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); 397 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED);
426 ToggleOverview(); 398 ToggleOverview();
427 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), 399 EXPECT_EQ(delegate->GetLastAccessibilityAlert(),
428 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); 400 A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED);
429 } 401 }
430 402
431 // Tests that there are no crashes when there is not enough screen space 403 // Tests that there are no crashes when there is not enough screen space
432 // available to show all of the windows. 404 // available to show all of the windows.
433 TEST_P(WindowSelectorTest, SmallDisplay) { 405 TEST_F(WindowSelectorTest, SmallDisplay) {
434 UpdateDisplay("3x1"); 406 UpdateDisplay("3x1");
435 gfx::Rect bounds(0, 0, 1, 1); 407 gfx::Rect bounds(0, 0, 1, 1);
436 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 408 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
437 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 409 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
438 std::unique_ptr<aura::Window> window3(CreateWindow(bounds)); 410 std::unique_ptr<aura::Window> window3(CreateWindow(bounds));
439 std::unique_ptr<aura::Window> window4(CreateWindow(bounds)); 411 std::unique_ptr<aura::Window> window4(CreateWindow(bounds));
440 window1->SetProperty(aura::client::kTopViewInset, 0); 412 window1->SetProperty(aura::client::kTopViewInset, 0);
441 window2->SetProperty(aura::client::kTopViewInset, 0); 413 window2->SetProperty(aura::client::kTopViewInset, 0);
442 window3->SetProperty(aura::client::kTopViewInset, 0); 414 window3->SetProperty(aura::client::kTopViewInset, 0);
443 window4->SetProperty(aura::client::kTopViewInset, 0); 415 window4->SetProperty(aura::client::kTopViewInset, 0);
444 ToggleOverview(); 416 ToggleOverview();
445 } 417 }
446 418
447 // Tests entering overview mode with two windows and selecting one by clicking. 419 // Tests entering overview mode with two windows and selecting one by clicking.
448 TEST_P(WindowSelectorTest, Basic) { 420 TEST_F(WindowSelectorTest, Basic) {
449 gfx::Rect bounds(0, 0, 400, 400); 421 gfx::Rect bounds(0, 0, 400, 400);
450 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 422 aura::Window* root_window = Shell::GetPrimaryRootWindow();
451 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 423 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
452 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 424 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
453 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); 425 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds));
454 std::unique_ptr<aura::Window> panel2(CreatePanelWindow(bounds)); 426 std::unique_ptr<aura::Window> panel2(CreatePanelWindow(bounds));
455 427
456 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get())); 428 EXPECT_TRUE(WindowsOverlapping(window1.get(), window2.get()));
457 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get())); 429 EXPECT_TRUE(WindowsOverlapping(panel1.get(), panel2.get()));
458 wm::ActivateWindow(window2.get()); 430 wm::ActivateWindow(window2.get());
(...skipping 16 matching lines...) Expand all
475 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 447 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
476 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); 448 EXPECT_FALSE(wm::IsActiveWindow(window2.get()));
477 EXPECT_EQ(window1.get(), GetFocusedWindow()); 449 EXPECT_EQ(window1.get(), GetFocusedWindow());
478 450
479 // Cursor should have been unlocked. 451 // Cursor should have been unlocked.
480 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked()); 452 EXPECT_FALSE(aura::client::GetCursorClient(root_window)->IsCursorLocked());
481 } 453 }
482 454
483 // Tests that entering overview mode with an App-list active properly focuses 455 // Tests that entering overview mode with an App-list active properly focuses
484 // and activates the overview text filter window. 456 // and activates the overview text filter window.
485 TEST_P(WindowSelectorTest, TextFilterActive) { 457 TEST_F(WindowSelectorTest, TextFilterActive) {
486 gfx::Rect bounds(0, 0, 400, 400); 458 gfx::Rect bounds(0, 0, 400, 400);
487 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 459 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
488 wm::ActivateWindow(window1.get()); 460 wm::ActivateWindow(window1.get());
489 461
490 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 462 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
491 EXPECT_EQ(window1.get(), GetFocusedWindow()); 463 EXPECT_EQ(window1.get(), GetFocusedWindow());
492 464
493 WmShell::Get()->ToggleAppList(); 465 WmShell::Get()->ToggleAppList();
494 466
495 // Activating overview cancels the App-list which normally would activate the 467 // Activating overview cancels the App-list which normally would activate the
496 // previously active |window1|. Overview mode should properly transfer focus 468 // previously active |window1|. Overview mode should properly transfer focus
497 // and activation to the text filter widget. 469 // and activation to the text filter widget.
498 ToggleOverview(); 470 ToggleOverview();
499 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); 471 EXPECT_FALSE(wm::IsActiveWindow(window1.get()));
500 EXPECT_TRUE(wm::IsActiveWindow(GetFocusedWindow())); 472 EXPECT_TRUE(wm::IsActiveWindow(GetFocusedWindow()));
501 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); 473 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow());
502 } 474 }
503 475
504 // Tests that the ordering of windows is near the windows' original positions.
505 TEST_P(WindowSelectorTest, MinimizeMovement) {
506 // With Material Design the order of windows in overview mode is MRU.
507 if (ash::MaterialDesignController::IsOverviewMaterial())
508 return;
509 aura::Window* root_window = Shell::GetPrimaryRootWindow();
510 gfx::Rect left_bounds(0, 0, root_window->bounds().width() / 2,
511 root_window->bounds().height());
512 gfx::Rect right_bounds(root_window->bounds().width() / 2, 0,
513 root_window->bounds().width() / 2,
514 root_window->bounds().height());
515 std::unique_ptr<aura::Window> left_window(CreateWindow(left_bounds));
516 WmWindow* left_window_wm = WmWindowAura::Get(left_window.get());
517 std::unique_ptr<aura::Window> right_window(CreateWindow(right_bounds));
518 WmWindow* right_window_wm = WmWindowAura::Get(right_window.get());
519
520 // The window should stay on the same side of the screen regardless of which
521 // one was active on entering overview mode.
522 wm::GetWindowState(left_window.get())->Activate();
523 ToggleOverview();
524 const std::vector<WindowSelectorItem*>& overview1(GetWindowItemsForRoot(0));
525 EXPECT_EQ(overview1[0]->GetWindow(), left_window_wm);
526 EXPECT_EQ(overview1[1]->GetWindow(), right_window_wm);
527 ToggleOverview();
528
529 // Active the right window, the order should be the same.
530 wm::GetWindowState(right_window.get())->Activate();
531 ToggleOverview();
532 const std::vector<WindowSelectorItem*>& overview2(GetWindowItemsForRoot(0));
533 EXPECT_EQ(overview2[0]->GetWindow(), left_window_wm);
534 EXPECT_EQ(overview2[1]->GetWindow(), right_window_wm);
535 ToggleOverview();
536
537 // Switch the window positions, and the order should be switched.
538 left_window->SetBounds(right_bounds);
539 right_window->SetBounds(left_bounds);
540 ToggleOverview();
541 const std::vector<WindowSelectorItem*>& overview3(GetWindowItemsForRoot(0));
542 EXPECT_EQ(overview3[0]->GetWindow(), right_window_wm);
543 EXPECT_EQ(overview3[1]->GetWindow(), left_window_wm);
544 ToggleOverview();
545 }
546
547 // Tests that the ordering of windows is near the windows' original positions
548 // on a second display.
549 TEST_P(WindowSelectorTest, MinimizeMovementSecondDisplay) {
550 // With Material Design the order of windows in overview mode is MRU.
551 if (ash::MaterialDesignController::IsOverviewMaterial() ||
552 !SupportsMultipleDisplays()) {
553 return;
554 }
555 // Verify the same works on the second display
556 UpdateDisplay("400x400,400x400");
557 gfx::Rect left_bounds(400, 0, 200, 400);
558 gfx::Rect right_bounds(600, 0, 200, 400);
559 std::unique_ptr<aura::Window> left_window(CreateWindow(left_bounds));
560 WmWindow* left_window_wm = WmWindowAura::Get(left_window.get());
561 std::unique_ptr<aura::Window> right_window(CreateWindow(right_bounds));
562 WmWindow* right_window_wm = WmWindowAura::Get(right_window.get());
563
564 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
565 EXPECT_EQ(root_windows[1], left_window->GetRootWindow());
566 EXPECT_EQ(root_windows[1], right_window->GetRootWindow());
567
568 wm::GetWindowState(left_window.get())->Activate();
569 ToggleOverview();
570 const std::vector<WindowSelectorItem*>& overview1(GetWindowItemsForRoot(0));
571 EXPECT_EQ(overview1[0]->GetWindow(), left_window_wm);
572 EXPECT_EQ(overview1[1]->GetWindow(), right_window_wm);
573 ToggleOverview();
574
575 // Active the right window, the order should be the same.
576 wm::GetWindowState(right_window.get())->Activate();
577 ToggleOverview();
578 const std::vector<WindowSelectorItem*>& overview2(GetWindowItemsForRoot(0));
579 EXPECT_EQ(overview2[0]->GetWindow(), left_window_wm);
580 EXPECT_EQ(overview2[1]->GetWindow(), right_window_wm);
581 ToggleOverview();
582 }
583
584 // Tests that the ordering of windows is stable across different overview 476 // Tests that the ordering of windows is stable across different overview
585 // sessions even when the windows have the same bounds. 477 // sessions even when the windows have the same bounds.
586 TEST_P(WindowSelectorTest, WindowsOrder) { 478 TEST_F(WindowSelectorTest, WindowsOrder) {
587 gfx::Rect bounds(0, 0, 400, 400); 479 gfx::Rect bounds(0, 0, 400, 400);
588 std::unique_ptr<aura::Window> window1(CreateWindowWithId(bounds, 1)); 480 std::unique_ptr<aura::Window> window1(CreateWindowWithId(bounds, 1));
589 std::unique_ptr<aura::Window> window2(CreateWindowWithId(bounds, 2)); 481 std::unique_ptr<aura::Window> window2(CreateWindowWithId(bounds, 2));
590 std::unique_ptr<aura::Window> window3(CreateWindowWithId(bounds, 3)); 482 std::unique_ptr<aura::Window> window3(CreateWindowWithId(bounds, 3));
591 483
592 // Before Material Design the initial ordering is not defined, but should 484 // The order of windows in overview mode is MRU.
593 // remain consistent the next time overview is started.
594 // With Material Design the order of windows in overview mode is MRU.
595 wm::GetWindowState(window1.get())->Activate(); 485 wm::GetWindowState(window1.get())->Activate();
596 ToggleOverview(); 486 ToggleOverview();
597 const std::vector<WindowSelectorItem*>& overview1(GetWindowItemsForRoot(0)); 487 const std::vector<WindowSelectorItem*>& overview1(GetWindowItemsForRoot(0));
598 int initial_order[3] = {overview1[0]->GetWindow()->GetShellWindowId(), 488 EXPECT_EQ(1, overview1[0]->GetWindow()->GetShellWindowId());
599 overview1[1]->GetWindow()->GetShellWindowId(), 489 EXPECT_EQ(3, overview1[1]->GetWindow()->GetShellWindowId());
600 overview1[2]->GetWindow()->GetShellWindowId()}; 490 EXPECT_EQ(2, overview1[2]->GetWindow()->GetShellWindowId());
601 if (ash::MaterialDesignController::IsOverviewMaterial()) {
602 // With Material Design the order should be MRU.
603 EXPECT_EQ(1, overview1[0]->GetWindow()->GetShellWindowId());
604 EXPECT_EQ(3, overview1[1]->GetWindow()->GetShellWindowId());
605 EXPECT_EQ(2, overview1[2]->GetWindow()->GetShellWindowId());
606 }
607 ToggleOverview(); 491 ToggleOverview();
608 492
609 // Activate the second window. 493 // Activate the second window.
610 wm::GetWindowState(window2.get())->Activate(); 494 wm::GetWindowState(window2.get())->Activate();
611 ToggleOverview(); 495 ToggleOverview();
612 const std::vector<WindowSelectorItem*>& overview2(GetWindowItemsForRoot(0)); 496 const std::vector<WindowSelectorItem*>& overview2(GetWindowItemsForRoot(0));
613 497
614 if (ash::MaterialDesignController::IsOverviewMaterial()) { 498 // The order should be MRU.
615 // With Material Design the order should be MRU. 499 EXPECT_EQ(2, overview2[0]->GetWindow()->GetShellWindowId());
616 EXPECT_EQ(2, overview2[0]->GetWindow()->GetShellWindowId()); 500 EXPECT_EQ(1, overview2[1]->GetWindow()->GetShellWindowId());
617 EXPECT_EQ(1, overview2[1]->GetWindow()->GetShellWindowId()); 501 EXPECT_EQ(3, overview2[2]->GetWindow()->GetShellWindowId());
618 EXPECT_EQ(3, overview2[2]->GetWindow()->GetShellWindowId());
619 } else {
620 // Before Material Design the order should be the same as the first time.
621 EXPECT_EQ(initial_order[0], overview2[0]->GetWindow()->GetShellWindowId());
622 EXPECT_EQ(initial_order[1], overview2[1]->GetWindow()->GetShellWindowId());
623 EXPECT_EQ(initial_order[2], overview2[2]->GetWindow()->GetShellWindowId());
624 }
625 ToggleOverview(); 502 ToggleOverview();
626 } 503 }
627 504
628 // Tests entering overview mode with docked windows 505 // Tests entering overview mode with docked windows
629 TEST_P(WindowSelectorTest, BasicWithDocked) { 506 TEST_F(WindowSelectorTest, BasicWithDocked) {
630 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 507 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
631 gfx::Rect bounds(300, 0, 200, 200); 508 gfx::Rect bounds(300, 0, 200, 200);
632 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 509 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
633 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 510 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
634 std::unique_ptr<aura::Window> docked1(CreateWindow(bounds)); 511 std::unique_ptr<aura::Window> docked1(CreateWindow(bounds));
635 std::unique_ptr<aura::Window> docked2(CreateWindow(bounds)); 512 std::unique_ptr<aura::Window> docked2(CreateWindow(bounds));
636 513
637 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); 514 wm::WMEvent dock_event(wm::WM_EVENT_DOCK);
638 wm::GetWindowState(docked1.get())->OnWMEvent(&dock_event); 515 wm::GetWindowState(docked1.get())->OnWMEvent(&dock_event);
639 516
(...skipping 17 matching lines...) Expand all
657 534
658 ToggleOverview(); 535 ToggleOverview();
659 536
660 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get())); 537 EXPECT_FALSE(WindowsOverlapping(window1.get(), window2.get()));
661 538
662 gfx::Rect container_bounds = docked1->parent()->bounds(); 539 gfx::Rect container_bounds = docked1->parent()->bounds();
663 ShelfWidget* shelf = GetPrimaryShelf()->shelf_widget(); 540 ShelfWidget* shelf = GetPrimaryShelf()->shelf_widget();
664 DockedWindowLayoutManager* manager = 541 DockedWindowLayoutManager* manager =
665 DockedWindowLayoutManager::Get(WmWindowAura::Get(docked1.get())); 542 DockedWindowLayoutManager::Get(WmWindowAura::Get(docked1.get()));
666 543
667 if (ash::MaterialDesignController::IsOverviewMaterial()) { 544 // Docked windows get shown and transformed.
668 // Docked windows get shown and transformed. 545 EXPECT_TRUE(docked2->IsVisible());
669 EXPECT_TRUE(docked2->IsVisible());
670 546
671 // Docked area shrinks. 547 // Docked area shrinks.
672 DockedWindowLayoutManager* manager = 548 EXPECT_EQ(0, manager->docked_bounds().width());
673 DockedWindowLayoutManager::Get(WmWindowAura::Get(docked1.get()));
674 EXPECT_EQ(0, manager->docked_bounds().width());
675 549
676 // Work area takes the whole screen minus the shelf. 550 // Work area takes the whole screen minus the shelf.
677 gfx::Rect work_area = display::Screen::GetScreen() 551 gfx::Rect work_area = display::Screen::GetScreen()
678 ->GetDisplayNearestWindow(docked1.get()) 552 ->GetDisplayNearestWindow(docked1.get())
679 .work_area(); 553 .work_area();
680 gfx::Size expected_work_area_bounds(container_bounds.size()); 554 gfx::Size expected_work_area_bounds(container_bounds.size());
681 expected_work_area_bounds.Enlarge( 555 expected_work_area_bounds.Enlarge(0,
682 0, -shelf->GetWindowBoundsInScreen().height()); 556 -shelf->GetWindowBoundsInScreen().height());
683 EXPECT_EQ(expected_work_area_bounds.ToString(), 557 EXPECT_EQ(expected_work_area_bounds.ToString(), work_area.size().ToString());
684 work_area.size().ToString()); 558
685 } else {
686 // Docked windows stays the same.
687 EXPECT_EQ(docked_bounds.ToString(),
688 docked1->GetBoundsInScreen().ToString());
689 EXPECT_FALSE(docked2->IsVisible());
690 }
691 // Docked window can still be activated, which will exit the overview mode. 559 // Docked window can still be activated, which will exit the overview mode.
692 ClickWindow(docked1.get()); 560 ClickWindow(docked1.get());
693 EXPECT_TRUE(wm::IsActiveWindow(docked1.get())); 561 EXPECT_TRUE(wm::IsActiveWindow(docked1.get()));
694 EXPECT_FALSE(window_selector_controller()->IsSelecting()); 562 EXPECT_FALSE(window_selector_controller()->IsSelecting());
695 563
696 // Docked area has a window in it. 564 // Docked area has a window in it.
697 EXPECT_GT(manager->docked_bounds().width(), 0); 565 EXPECT_GT(manager->docked_bounds().width(), 0);
698 566
699 // Work area takes the whole screen minus the shelf and the docked area. 567 // Work area takes the whole screen minus the shelf and the docked area.
700 gfx::Rect work_area = display::Screen::GetScreen() 568 work_area = display::Screen::GetScreen()
701 ->GetDisplayNearestWindow(docked1.get()) 569 ->GetDisplayNearestWindow(docked1.get())
702 .work_area(); 570 .work_area();
703 gfx::Size expected_work_area_bounds(container_bounds.size()); 571 expected_work_area_bounds = container_bounds.size();
704 expected_work_area_bounds.Enlarge(-manager->docked_bounds().width(), 572 expected_work_area_bounds.Enlarge(-manager->docked_bounds().width(),
705 -shelf->GetWindowBoundsInScreen().height()); 573 -shelf->GetWindowBoundsInScreen().height());
706 EXPECT_EQ(expected_work_area_bounds.ToString(), work_area.size().ToString()); 574 EXPECT_EQ(expected_work_area_bounds.ToString(), work_area.size().ToString());
707 } 575 }
708 576
709 // Tests that selecting a docked window updates docked layout pushing another 577 // Tests that selecting a docked window updates docked layout pushing another
710 // window to get docked-minimized. 578 // window to get docked-minimized.
711 TEST_P(WindowSelectorTest, ActivateDockedWindow) { 579 TEST_F(WindowSelectorTest, ActivateDockedWindow) {
712 if (!ash::MaterialDesignController::IsOverviewMaterial())
713 return;
714
715 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 580 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
716 gfx::Rect bounds(300, 0, 200, 200); 581 gfx::Rect bounds(300, 0, 200, 200);
717 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds); 582 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds);
718 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds); 583 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds);
719 584
720 aura::test::TestWindowDelegate delegate; 585 aura::test::TestWindowDelegate delegate;
721 delegate.set_minimum_size(gfx::Size(200, 500)); 586 delegate.set_minimum_size(gfx::Size(200, 500));
722 std::unique_ptr<aura::Window> docked_window1( 587 std::unique_ptr<aura::Window> docked_window1(
723 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 588 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
724 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight); 589 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
760 625
761 // |docked_window1| is docked-minimized and hidden. 626 // |docked_window1| is docked-minimized and hidden.
762 EXPECT_FALSE(docked_window1->IsVisible()); 627 EXPECT_FALSE(docked_window1->IsVisible());
763 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType()); 628 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType());
764 // |docked_window2| is docked and visible. 629 // |docked_window2| is docked and visible.
765 EXPECT_TRUE(docked_window2->IsVisible()); 630 EXPECT_TRUE(docked_window2->IsVisible());
766 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType()); 631 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state2->GetStateType());
767 } 632 }
768 633
769 // Tests that clicking on the close button closes the docked window. 634 // Tests that clicking on the close button closes the docked window.
770 TEST_P(WindowSelectorTest, CloseDockedWindow) { 635 TEST_F(WindowSelectorTest, CloseDockedWindow) {
771 if (!ash::MaterialDesignController::IsOverviewMaterial())
772 return;
773
774 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 636 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
775 gfx::Rect bounds(300, 0, 200, 200); 637 gfx::Rect bounds(300, 0, 200, 200);
776 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds); 638 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds);
777 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds); 639 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds);
778 640
779 aura::test::TestWindowDelegate delegate; 641 aura::test::TestWindowDelegate delegate;
780 delegate.set_minimum_size(gfx::Size(200, 500)); 642 delegate.set_minimum_size(gfx::Size(200, 500));
781 std::unique_ptr<aura::Window> docked_window1( 643 std::unique_ptr<aura::Window> docked_window1(
782 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 644 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
783 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight); 645 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 684
823 // Window bounds are still the same. 685 // Window bounds are still the same.
824 EXPECT_EQ(expected_bounds1.ToString(), docked_window1->bounds().ToString()); 686 EXPECT_EQ(expected_bounds1.ToString(), docked_window1->bounds().ToString());
825 687
826 // |docked_window1| returns to docked-minimized and hidden state. 688 // |docked_window1| returns to docked-minimized and hidden state.
827 EXPECT_FALSE(docked_window1->IsVisible()); 689 EXPECT_FALSE(docked_window1->IsVisible());
828 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType()); 690 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED, state1->GetStateType());
829 } 691 }
830 692
831 // Tests that clicking on the close button closes the docked-minimized window. 693 // Tests that clicking on the close button closes the docked-minimized window.
832 TEST_P(WindowSelectorTest, CloseDockedMinimizedWindow) { 694 TEST_F(WindowSelectorTest, CloseDockedMinimizedWindow) {
833 if (!ash::MaterialDesignController::IsOverviewMaterial())
834 return;
835
836 // aura::Window* root_window = Shell::GetPrimaryRootWindow(); 695 // aura::Window* root_window = Shell::GetPrimaryRootWindow();
837 gfx::Rect bounds(300, 0, 200, 200); 696 gfx::Rect bounds(300, 0, 200, 200);
838 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds); 697 std::unique_ptr<views::Widget> widget1 = CreateWindowWidget(bounds);
839 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds); 698 std::unique_ptr<views::Widget> widget2 = CreateWindowWidget(bounds);
840 699
841 aura::test::TestWindowDelegate delegate; 700 aura::test::TestWindowDelegate delegate;
842 delegate.set_minimum_size(gfx::Size(200, 500)); 701 delegate.set_minimum_size(gfx::Size(200, 500));
843 std::unique_ptr<aura::Window> docked_window1( 702 std::unique_ptr<aura::Window> docked_window1(
844 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds)); 703 CreateTestWindowInShellWithDelegate(&delegate, -1, bounds));
845 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight); 704 docked_window1->SetProperty(aura::client::kTopViewInset, kHeaderHeight);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 // Window bounds are still the same. 744 // Window bounds are still the same.
886 EXPECT_EQ(expected_bounds1.ToString(), 745 EXPECT_EQ(expected_bounds1.ToString(),
887 docked_window1->GetTargetBounds().ToString()); 746 docked_window1->GetTargetBounds().ToString());
888 747
889 // |docked_window1| returns to docked and visible state. 748 // |docked_window1| returns to docked and visible state.
890 EXPECT_TRUE(docked_window1->IsVisible()); 749 EXPECT_TRUE(docked_window1->IsVisible());
891 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType()); 750 EXPECT_EQ(wm::WINDOW_STATE_TYPE_DOCKED, state1->GetStateType());
892 } 751 }
893 752
894 // Tests selecting a window by tapping on it. 753 // Tests selecting a window by tapping on it.
895 TEST_P(WindowSelectorTest, BasicGesture) { 754 TEST_F(WindowSelectorTest, BasicGesture) {
896 gfx::Rect bounds(0, 0, 400, 400); 755 gfx::Rect bounds(0, 0, 400, 400);
897 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 756 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
898 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 757 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
899 wm::ActivateWindow(window1.get()); 758 wm::ActivateWindow(window1.get());
900 EXPECT_EQ(window1.get(), GetFocusedWindow()); 759 EXPECT_EQ(window1.get(), GetFocusedWindow());
901 ToggleOverview(); 760 ToggleOverview();
902 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); 761 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow());
903 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 762 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
904 window2.get()); 763 window2.get());
905 generator.GestureTapAt( 764 generator.GestureTapAt(
906 gfx::ToEnclosingRect(GetTransformedTargetBounds(window2.get())) 765 gfx::ToEnclosingRect(GetTransformedTargetBounds(window2.get()))
907 .CenterPoint()); 766 .CenterPoint());
908 EXPECT_EQ(window2.get(), GetFocusedWindow()); 767 EXPECT_EQ(window2.get(), GetFocusedWindow());
909 } 768 }
910 769
911 // Tests that the user action WindowSelector_ActiveWindowChanged is 770 // Tests that the user action WindowSelector_ActiveWindowChanged is
912 // recorded when the mouse/touchscreen/keyboard are used to select a window 771 // recorded when the mouse/touchscreen/keyboard are used to select a window
913 // in overview mode which is different from the previously-active window. 772 // in overview mode which is different from the previously-active window.
914 TEST_P(WindowSelectorTest, ActiveWindowChangedUserActionRecorded) { 773 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionRecorded) {
915 base::UserActionTester user_action_tester; 774 base::UserActionTester user_action_tester;
916 gfx::Rect bounds(0, 0, 400, 400); 775 gfx::Rect bounds(0, 0, 400, 400);
917 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 776 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
918 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 777 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
919 778
920 // Tap on |window2| to activate it and exit overview. 779 // Tap on |window2| to activate it and exit overview.
921 wm::ActivateWindow(window1.get()); 780 wm::ActivateWindow(window1.get());
922 ToggleOverview(); 781 ToggleOverview();
923 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(), 782 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow(),
924 window2.get()); 783 window2.get());
(...skipping 17 matching lines...) Expand all
942 ASSERT_TRUE(SelectWindow(window2.get())); 801 ASSERT_TRUE(SelectWindow(window2.get()));
943 SendKey(ui::VKEY_RETURN); 802 SendKey(ui::VKEY_RETURN);
944 EXPECT_EQ( 803 EXPECT_EQ(
945 3, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); 804 3, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview));
946 } 805 }
947 806
948 // Tests that the user action WindowSelector_ActiveWindowChanged is not 807 // Tests that the user action WindowSelector_ActiveWindowChanged is not
949 // recorded when the mouse/touchscreen/keyboard are used to select the 808 // recorded when the mouse/touchscreen/keyboard are used to select the
950 // already-active window from overview mode. Also verifies that entering and 809 // already-active window from overview mode. Also verifies that entering and
951 // exiting overview without selecting a window does not record the action. 810 // exiting overview without selecting a window does not record the action.
952 TEST_P(WindowSelectorTest, ActiveWindowChangedUserActionNotRecorded) { 811 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionNotRecorded) {
953 base::UserActionTester user_action_tester; 812 base::UserActionTester user_action_tester;
954 gfx::Rect bounds(0, 0, 400, 400); 813 gfx::Rect bounds(0, 0, 400, 400);
955 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 814 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
956 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 815 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
957 816
958 // Set |window1| to be initially active. 817 // Set |window1| to be initially active.
959 wm::ActivateWindow(window1.get()); 818 wm::ActivateWindow(window1.get());
960 ToggleOverview(); 819 ToggleOverview();
961 820
962 // Tap on |window1| to exit overview. 821 // Tap on |window1| to exit overview.
(...skipping 23 matching lines...) Expand all
986 // Entering and exiting overview without user input should not record 845 // Entering and exiting overview without user input should not record
987 // the action. 846 // the action.
988 ToggleOverview(); 847 ToggleOverview();
989 ToggleOverview(); 848 ToggleOverview();
990 EXPECT_EQ( 849 EXPECT_EQ(
991 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); 850 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview));
992 } 851 }
993 852
994 // Tests that the user action WindowSelector_ActiveWindowChanged is not 853 // Tests that the user action WindowSelector_ActiveWindowChanged is not
995 // recorded when overview mode exits as a result of closing its only window. 854 // recorded when overview mode exits as a result of closing its only window.
996 TEST_P(WindowSelectorTest, ActiveWindowChangedUserActionWindowClose) { 855 TEST_F(WindowSelectorTest, ActiveWindowChangedUserActionWindowClose) {
997 base::UserActionTester user_action_tester; 856 base::UserActionTester user_action_tester;
998 std::unique_ptr<views::Widget> widget = 857 std::unique_ptr<views::Widget> widget =
999 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); 858 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
1000 859
1001 ToggleOverview(); 860 ToggleOverview();
1002 861
1003 aura::Window* window = widget->GetNativeWindow(); 862 aura::Window* window = widget->GetNativeWindow();
1004 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window); 863 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window);
1005 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5); 864 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5);
1006 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); 865 ui::test::EventGenerator event_generator(window->GetRootWindow(), point);
1007 866
1008 ASSERT_FALSE(widget->IsClosed()); 867 ASSERT_FALSE(widget->IsClosed());
1009 event_generator.ClickLeftButton(); 868 event_generator.ClickLeftButton();
1010 ASSERT_TRUE(widget->IsClosed()); 869 ASSERT_TRUE(widget->IsClosed());
1011 EXPECT_EQ( 870 EXPECT_EQ(
1012 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview)); 871 0, user_action_tester.GetActionCount(kActiveWindowChangedFromOverview));
1013 } 872 }
1014 873
1015 // Tests that we do not crash and overview mode remains engaged if the desktop 874 // Tests that we do not crash and overview mode remains engaged if the desktop
1016 // is tapped while a finger is already down over a window. 875 // is tapped while a finger is already down over a window.
1017 TEST_P(WindowSelectorTest, NoCrashWithDesktopTap) { 876 TEST_F(WindowSelectorTest, NoCrashWithDesktopTap) {
1018 std::unique_ptr<aura::Window> window( 877 std::unique_ptr<aura::Window> window(
1019 CreateWindow(gfx::Rect(200, 300, 250, 450))); 878 CreateWindow(gfx::Rect(200, 300, 250, 450)));
1020 879
1021 ToggleOverview(); 880 ToggleOverview();
1022 881
1023 gfx::Rect bounds = 882 gfx::Rect bounds =
1024 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(window.get())); 883 gfx::ToEnclosingRect(GetTransformedBoundsInRootWindow(window.get()));
1025 ui::test::EventGenerator event_generator(window->GetRootWindow(), 884 ui::test::EventGenerator event_generator(window->GetRootWindow(),
1026 bounds.CenterPoint()); 885 bounds.CenterPoint());
1027 886
1028 // Press down on the window. 887 // Press down on the window.
1029 const int kTouchId = 19; 888 const int kTouchId = 19;
1030 event_generator.PressTouchId(kTouchId); 889 event_generator.PressTouchId(kTouchId);
1031 890
1032 // Tap on the desktop, which should not cause a crash. Overview mode should 891 // Tap on the desktop, which should not cause a crash. Overview mode should
1033 // be disengaged. 892 // be disengaged.
1034 event_generator.GestureTapAt(gfx::Point(0, 0)); 893 event_generator.GestureTapAt(gfx::Point(0, 0));
1035 EXPECT_FALSE(IsSelecting()); 894 EXPECT_FALSE(IsSelecting());
1036 895
1037 event_generator.ReleaseTouchId(kTouchId); 896 event_generator.ReleaseTouchId(kTouchId);
1038 } 897 }
1039 898
1040 // Tests that we do not crash and a window is selected when appropriate when 899 // Tests that we do not crash and a window is selected when appropriate when
1041 // we click on a window during touch. 900 // we click on a window during touch.
1042 TEST_P(WindowSelectorTest, ClickOnWindowDuringTouch) { 901 TEST_F(WindowSelectorTest, ClickOnWindowDuringTouch) {
1043 gfx::Rect bounds(0, 0, 400, 400); 902 gfx::Rect bounds(0, 0, 400, 400);
1044 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 903 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1045 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 904 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1046 wm::ActivateWindow(window2.get()); 905 wm::ActivateWindow(window2.get());
1047 EXPECT_FALSE(wm::IsActiveWindow(window1.get())); 906 EXPECT_FALSE(wm::IsActiveWindow(window1.get()));
1048 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); 907 EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
1049 908
1050 ToggleOverview(); 909 ToggleOverview();
1051 910
1052 gfx::Rect window1_bounds = 911 gfx::Rect window1_bounds =
(...skipping 19 matching lines...) Expand all
1072 event_generator.MoveMouseToCenterOf(window1.get()); 931 event_generator.MoveMouseToCenterOf(window1.get());
1073 event_generator.PressTouchId(kTouchId); 932 event_generator.PressTouchId(kTouchId);
1074 event_generator.ClickLeftButton(); 933 event_generator.ClickLeftButton();
1075 EXPECT_FALSE(IsSelecting()); 934 EXPECT_FALSE(IsSelecting());
1076 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 935 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
1077 EXPECT_FALSE(wm::IsActiveWindow(window2.get())); 936 EXPECT_FALSE(wm::IsActiveWindow(window2.get()));
1078 event_generator.ReleaseTouchId(kTouchId); 937 event_generator.ReleaseTouchId(kTouchId);
1079 } 938 }
1080 939
1081 // Tests that a window does not receive located events when in overview mode. 940 // Tests that a window does not receive located events when in overview mode.
1082 TEST_P(WindowSelectorTest, WindowDoesNotReceiveEvents) { 941 TEST_F(WindowSelectorTest, WindowDoesNotReceiveEvents) {
1083 gfx::Rect window_bounds(20, 10, 200, 300); 942 gfx::Rect window_bounds(20, 10, 200, 300);
1084 aura::Window* root_window = Shell::GetPrimaryRootWindow(); 943 aura::Window* root_window = Shell::GetPrimaryRootWindow();
1085 std::unique_ptr<aura::Window> window(CreateWindow(window_bounds)); 944 std::unique_ptr<aura::Window> window(CreateWindow(window_bounds));
1086 945
1087 gfx::Point point1(window_bounds.x() + 10, window_bounds.y() + 10); 946 gfx::Point point1(window_bounds.x() + 10, window_bounds.y() + 10);
1088 947
1089 ui::MouseEvent event1(ui::ET_MOUSE_PRESSED, point1, point1, 948 ui::MouseEvent event1(ui::ET_MOUSE_PRESSED, point1, point1,
1090 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 949 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
1091 950
1092 ui::EventTarget* root_target = root_window; 951 ui::EventTarget* root_target = root_window;
1093 ui::EventTargeter* targeter = root_target->GetEventTargeter(); 952 ui::EventTargeter* targeter = root_target->GetEventTargeter();
1094 953
1095 // The event should target the window because we are still not in overview 954 // The event should target the window because we are still not in overview
1096 // mode. 955 // mode.
1097 EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root_target, &event1)); 956 EXPECT_EQ(window.get(), targeter->FindTargetForEvent(root_target, &event1));
1098 957
1099 ToggleOverview(); 958 ToggleOverview();
1100 959
1101 // The bounds have changed, take that into account. 960 // The bounds have changed, take that into account.
1102 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window.get()); 961 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window.get());
1103 gfx::Point point2(bounds.x() + 10, bounds.y() + 10); 962 gfx::Point point2(bounds.x() + 10, bounds.y() + 10);
1104 ui::MouseEvent event2(ui::ET_MOUSE_PRESSED, point2, point2, 963 ui::MouseEvent event2(ui::ET_MOUSE_PRESSED, point2, point2,
1105 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE); 964 ui::EventTimeForNow(), ui::EF_NONE, ui::EF_NONE);
1106 965
1107 // Now the transparent window should be intercepting this event. 966 // Now the transparent window should be intercepting this event.
1108 EXPECT_NE(window.get(), targeter->FindTargetForEvent(root_target, &event2)); 967 EXPECT_NE(window.get(), targeter->FindTargetForEvent(root_target, &event2));
1109 } 968 }
1110 969
1111 // Tests that clicking on the close button effectively closes the window. 970 // Tests that clicking on the close button effectively closes the window.
1112 TEST_P(WindowSelectorTest, CloseButton) { 971 TEST_F(WindowSelectorTest, CloseButton) {
1113 std::unique_ptr<views::Widget> widget = 972 std::unique_ptr<views::Widget> widget =
1114 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); 973 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
1115 974
1116 ToggleOverview(); 975 ToggleOverview();
1117 976
1118 aura::Window* window = widget->GetNativeWindow(); 977 aura::Window* window = widget->GetNativeWindow();
1119 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window); 978 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window);
1120 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5); 979 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5);
1121 ui::test::EventGenerator event_generator(window->GetRootWindow(), point); 980 ui::test::EventGenerator event_generator(window->GetRootWindow(), point);
1122 981
1123 EXPECT_FALSE(widget->IsClosed()); 982 EXPECT_FALSE(widget->IsClosed());
1124 event_generator.ClickLeftButton(); 983 event_generator.ClickLeftButton();
1125 EXPECT_TRUE(widget->IsClosed()); 984 EXPECT_TRUE(widget->IsClosed());
1126 } 985 }
1127 986
1128 // Tests that clicking on the close button on a secondary display effectively 987 // Tests that clicking on the close button on a secondary display effectively
1129 // closes the window. 988 // closes the window.
1130 TEST_P(WindowSelectorTest, CloseButtonOnMultipleDisplay) { 989 TEST_F(WindowSelectorTest, CloseButtonOnMultipleDisplay) {
1131 if (!SupportsMultipleDisplays()) 990 if (!SupportsMultipleDisplays())
1132 return; 991 return;
1133 992
1134 UpdateDisplay("600x400,600x400"); 993 UpdateDisplay("600x400,600x400");
1135 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 994 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1136 995
1137 std::unique_ptr<aura::Window> window1( 996 std::unique_ptr<aura::Window> window1(
1138 CreateWindow(gfx::Rect(650, 300, 250, 450))); 997 CreateWindow(gfx::Rect(650, 300, 250, 450)));
1139 998
1140 // We need a widget for the close button to work because windows are closed 999 // We need a widget for the close button to work because windows are closed
(...skipping 18 matching lines...) Expand all
1159 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window2); 1018 gfx::RectF bounds = GetTransformedBoundsInRootWindow(window2);
1160 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5); 1019 gfx::Point point(bounds.top_right().x() - 1, bounds.top_right().y() + 5);
1161 ui::test::EventGenerator event_generator(window2->GetRootWindow(), point); 1020 ui::test::EventGenerator event_generator(window2->GetRootWindow(), point);
1162 1021
1163 EXPECT_FALSE(widget->IsClosed()); 1022 EXPECT_FALSE(widget->IsClosed());
1164 event_generator.ClickLeftButton(); 1023 event_generator.ClickLeftButton();
1165 EXPECT_TRUE(widget->IsClosed()); 1024 EXPECT_TRUE(widget->IsClosed());
1166 } 1025 }
1167 1026
1168 // Tests entering overview mode with two windows and selecting one. 1027 // Tests entering overview mode with two windows and selecting one.
1169 TEST_P(WindowSelectorTest, FullscreenWindow) { 1028 TEST_F(WindowSelectorTest, FullscreenWindow) {
1170 gfx::Rect bounds(0, 0, 400, 400); 1029 gfx::Rect bounds(0, 0, 400, 400);
1171 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1030 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1172 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1031 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1173 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds)); 1032 std::unique_ptr<aura::Window> panel1(CreatePanelWindow(bounds));
1174 wm::ActivateWindow(window1.get()); 1033 wm::ActivateWindow(window1.get());
1175 1034
1176 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1035 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1177 wm::GetWindowState(window1.get())->OnWMEvent(&toggle_fullscreen_event); 1036 wm::GetWindowState(window1.get())->OnWMEvent(&toggle_fullscreen_event);
1178 // The panel is hidden in fullscreen mode. 1037 // The panel is hidden in fullscreen mode.
1179 EXPECT_FALSE(panel1->IsVisible()); 1038 EXPECT_FALSE(panel1->IsVisible());
(...skipping 15 matching lines...) Expand all
1195 // fullscreen. 1054 // fullscreen.
1196 // TODO(flackr): Currently the panel remains hidden, but should become visible 1055 // TODO(flackr): Currently the panel remains hidden, but should become visible
1197 // again. 1056 // again.
1198 ToggleOverview(); 1057 ToggleOverview();
1199 ClickWindow(window2.get()); 1058 ClickWindow(window2.get());
1200 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen()); 1059 EXPECT_TRUE(wm::GetWindowState(window1.get())->IsFullscreen());
1201 } 1060 }
1202 1061
1203 // Tests that the shelf dimming state is removed while in overview and restored 1062 // Tests that the shelf dimming state is removed while in overview and restored
1204 // on exiting overview. 1063 // on exiting overview.
1205 TEST_P(WindowSelectorTest, OverviewUndimsShelf) { 1064 TEST_F(WindowSelectorTest, OverviewUndimsShelf) {
1206 gfx::Rect bounds(0, 0, 400, 400); 1065 gfx::Rect bounds(0, 0, 400, 400);
1207 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1066 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1208 wm::WindowState* window_state = wm::GetWindowState(window1.get()); 1067 wm::WindowState* window_state = wm::GetWindowState(window1.get());
1209 window_state->Maximize(); 1068 window_state->Maximize();
1210 ShelfWidget* shelf = GetPrimaryShelf()->shelf_widget(); 1069 ShelfWidget* shelf = GetPrimaryShelf()->shelf_widget();
1211 EXPECT_TRUE(shelf->GetDimsShelf()); 1070 EXPECT_TRUE(shelf->GetDimsShelf());
1212 ToggleOverview(); 1071 ToggleOverview();
1213 EXPECT_FALSE(shelf->GetDimsShelf()); 1072 EXPECT_FALSE(shelf->GetDimsShelf());
1214 ToggleOverview(); 1073 ToggleOverview();
1215 EXPECT_TRUE(shelf->GetDimsShelf()); 1074 EXPECT_TRUE(shelf->GetDimsShelf());
1216 } 1075 }
1217 1076
1218 // Tests that entering overview when a fullscreen window is active in maximized 1077 // Tests that entering overview when a fullscreen window is active in maximized
1219 // mode correctly applies the transformations to the window and correctly 1078 // mode correctly applies the transformations to the window and correctly
1220 // updates the window bounds on exiting overview mode: http://crbug.com/401664. 1079 // updates the window bounds on exiting overview mode: http://crbug.com/401664.
1221 TEST_P(WindowSelectorTest, FullscreenWindowMaximizeMode) { 1080 TEST_F(WindowSelectorTest, FullscreenWindowMaximizeMode) {
1222 gfx::Rect bounds(0, 0, 400, 400); 1081 gfx::Rect bounds(0, 0, 400, 400);
1223 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1082 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1224 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1083 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1225 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 1084 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
1226 true); 1085 true);
1227 wm::ActivateWindow(window2.get()); 1086 wm::ActivateWindow(window2.get());
1228 wm::ActivateWindow(window1.get()); 1087 wm::ActivateWindow(window1.get());
1229 gfx::Rect normal_window_bounds(window1->bounds()); 1088 gfx::Rect normal_window_bounds(window1->bounds());
1230 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1089 const wm::WMEvent toggle_fullscreen_event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1231 wm::GetWindowState(window1.get())->OnWMEvent(&toggle_fullscreen_event); 1090 wm::GetWindowState(window1.get())->OnWMEvent(&toggle_fullscreen_event);
(...skipping 17 matching lines...) Expand all
1249 1108
1250 // Enter overview again and select window 2. Selecting window 2 should show 1109 // Enter overview again and select window 2. Selecting window 2 should show
1251 // the shelf bringing window2 back to the normal bounds. 1110 // the shelf bringing window2 back to the normal bounds.
1252 ToggleOverview(); 1111 ToggleOverview();
1253 ClickWindow(window2.get()); 1112 ClickWindow(window2.get());
1254 EXPECT_EQ(normal_window_bounds.ToString(), 1113 EXPECT_EQ(normal_window_bounds.ToString(),
1255 window2->GetTargetBounds().ToString()); 1114 window2->GetTargetBounds().ToString());
1256 } 1115 }
1257 1116
1258 // Tests that beginning window selection hides the app list. 1117 // Tests that beginning window selection hides the app list.
1259 TEST_P(WindowSelectorTest, SelectingHidesAppList) { 1118 TEST_F(WindowSelectorTest, SelectingHidesAppList) {
1260 gfx::Rect bounds(0, 0, 400, 400); 1119 gfx::Rect bounds(0, 0, 400, 400);
1261 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1120 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1262 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1121 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1263 WmShell::Get()->ShowAppList(); 1122 WmShell::Get()->ShowAppList();
1264 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); 1123 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility());
1265 ToggleOverview(); 1124 ToggleOverview();
1266 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); 1125 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility());
1267 ToggleOverview(); 1126 ToggleOverview();
1268 } 1127 }
1269 1128
1270 // Tests that a minimized window's visibility and layer visibility is correctly 1129 // Tests that a minimized window's visibility and layer visibility is correctly
1271 // changed when entering overview and restored when leaving overview mode. 1130 // changed when entering overview and restored when leaving overview mode.
1272 // Crashes after the skia roll in http://crrev.com/274114. 1131 // Crashes after the skia roll in http://crrev.com/274114.
1273 // http://crbug.com/379570 1132 // http://crbug.com/379570
1274 TEST_P(WindowSelectorTest, DISABLED_MinimizedWindowVisibility) { 1133 TEST_F(WindowSelectorTest, DISABLED_MinimizedWindowVisibility) {
1275 gfx::Rect bounds(0, 0, 400, 400); 1134 gfx::Rect bounds(0, 0, 400, 400);
1276 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1135 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1277 wm::WindowState* window_state = wm::GetWindowState(window1.get()); 1136 wm::WindowState* window_state = wm::GetWindowState(window1.get());
1278 window_state->Minimize(); 1137 window_state->Minimize();
1279 EXPECT_FALSE(window1->IsVisible()); 1138 EXPECT_FALSE(window1->IsVisible());
1280 EXPECT_FALSE(window1->layer()->GetTargetVisibility()); 1139 EXPECT_FALSE(window1->layer()->GetTargetVisibility());
1281 { 1140 {
1282 ui::ScopedAnimationDurationScaleMode test_duration_mode( 1141 ui::ScopedAnimationDurationScaleMode test_duration_mode(
1283 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); 1142 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
1284 ToggleOverview(); 1143 ToggleOverview();
1285 EXPECT_TRUE(window1->IsVisible()); 1144 EXPECT_TRUE(window1->IsVisible());
1286 EXPECT_TRUE(window1->layer()->GetTargetVisibility()); 1145 EXPECT_TRUE(window1->layer()->GetTargetVisibility());
1287 } 1146 }
1288 { 1147 {
1289 ui::ScopedAnimationDurationScaleMode test_duration_mode( 1148 ui::ScopedAnimationDurationScaleMode test_duration_mode(
1290 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); 1149 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
1291 ToggleOverview(); 1150 ToggleOverview();
1292 EXPECT_FALSE(window1->IsVisible()); 1151 EXPECT_FALSE(window1->IsVisible());
1293 EXPECT_FALSE(window1->layer()->GetTargetVisibility()); 1152 EXPECT_FALSE(window1->layer()->GetTargetVisibility());
1294 } 1153 }
1295 } 1154 }
1296 1155
1297 // Tests that it is safe to destroy a window while the overview header animation 1156 // Tests that it is safe to destroy a window while the overview header animation
1298 // is still active. See http://crbug.com/646350. 1157 // is still active. See http://crbug.com/646350.
1299 TEST_P(WindowSelectorTest, SafeToDestroyWindowDuringAnimation) { 1158 TEST_F(WindowSelectorTest, SafeToDestroyWindowDuringAnimation) {
1300 gfx::Rect bounds(0, 0, 400, 400); 1159 gfx::Rect bounds(0, 0, 400, 400);
1301 { 1160 {
1302 // Quickly enter and exit overview mode to activate header animations. 1161 // Quickly enter and exit overview mode to activate header animations.
1303 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); 1162 std::unique_ptr<aura::Window> window(CreateWindow(bounds));
1304 ui::ScopedAnimationDurationScaleMode test_duration_mode( 1163 ui::ScopedAnimationDurationScaleMode test_duration_mode(
1305 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); 1164 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
1306 ToggleOverview(); 1165 ToggleOverview();
1307 EXPECT_TRUE(IsSelecting()); 1166 EXPECT_TRUE(IsSelecting());
1308 1167
1309 gfx::SlideAnimation* animation = 1168 gfx::SlideAnimation* animation =
1310 GetBackgroundViewAnimationForWindow(0, window.get()); 1169 GetBackgroundViewAnimationForWindow(0, window.get());
1311 if (ash::MaterialDesignController::IsOverviewMaterial()) 1170 ASSERT_NE(nullptr, animation);
1312 ASSERT_NE(nullptr, animation);
1313 ToggleOverview(); 1171 ToggleOverview();
1314 EXPECT_FALSE(IsSelecting()); 1172 EXPECT_FALSE(IsSelecting());
1315 if (animation) 1173 if (animation)
1316 EXPECT_TRUE(animation->is_animating()); 1174 EXPECT_TRUE(animation->is_animating());
1317 1175
1318 // Close the window while the overview header animation is active. 1176 // Close the window while the overview header animation is active.
1319 window.reset(); 1177 window.reset();
1320 1178
1321 // Progress animation to the end - should not crash. 1179 // Progress animation to the end - should not crash.
1322 if (animation) { 1180 if (animation) {
1323 animation->SetCurrentValue(1.0); 1181 animation->SetCurrentValue(1.0);
1324 animation->Reset(1.0); 1182 animation->Reset(1.0);
1325 } 1183 }
1326 } 1184 }
1327 } 1185 }
1328 1186
1329 // Tests that a bounds change during overview is corrected for. 1187 // Tests that a bounds change during overview is corrected for.
1330 TEST_P(WindowSelectorTest, BoundsChangeDuringOverview) { 1188 TEST_F(WindowSelectorTest, BoundsChangeDuringOverview) {
1331 std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400))); 1189 std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 400, 400)));
1332 // Use overview headers above the window in this test. 1190 // Use overview headers above the window in this test.
1333 window->SetProperty(aura::client::kTopViewInset, 0); 1191 window->SetProperty(aura::client::kTopViewInset, 0);
1334 ToggleOverview(); 1192 ToggleOverview();
1335 gfx::Rect overview_bounds = 1193 gfx::Rect overview_bounds =
1336 ToEnclosingRect(GetTransformedTargetBounds(window.get())); 1194 ToEnclosingRect(GetTransformedTargetBounds(window.get()));
1337 window->SetBounds(gfx::Rect(200, 0, 200, 200)); 1195 window->SetBounds(gfx::Rect(200, 0, 200, 200));
1338 gfx::Rect new_overview_bounds = 1196 gfx::Rect new_overview_bounds =
1339 ToEnclosingRect(GetTransformedTargetBounds(window.get())); 1197 ToEnclosingRect(GetTransformedTargetBounds(window.get()));
1340 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x()); 1198 EXPECT_EQ(overview_bounds.x(), new_overview_bounds.x());
1341 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y()); 1199 EXPECT_EQ(overview_bounds.y(), new_overview_bounds.y());
1342 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width()); 1200 EXPECT_EQ(overview_bounds.width(), new_overview_bounds.width());
1343 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height()); 1201 EXPECT_EQ(overview_bounds.height(), new_overview_bounds.height());
1344 ToggleOverview(); 1202 ToggleOverview();
1345 } 1203 }
1346 1204
1347 // Tests that a newly created window aborts overview. 1205 // Tests that a newly created window aborts overview.
1348 TEST_P(WindowSelectorTest, NewWindowCancelsOveriew) { 1206 TEST_F(WindowSelectorTest, NewWindowCancelsOveriew) {
1349 gfx::Rect bounds(0, 0, 400, 400); 1207 gfx::Rect bounds(0, 0, 400, 400);
1350 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1208 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1351 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1209 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1352 ToggleOverview(); 1210 ToggleOverview();
1353 EXPECT_TRUE(IsSelecting()); 1211 EXPECT_TRUE(IsSelecting());
1354 1212
1355 // A window being created should exit overview mode. 1213 // A window being created should exit overview mode.
1356 std::unique_ptr<aura::Window> window3(CreateWindow(bounds)); 1214 std::unique_ptr<aura::Window> window3(CreateWindow(bounds));
1357 EXPECT_FALSE(IsSelecting()); 1215 EXPECT_FALSE(IsSelecting());
1358 } 1216 }
1359 1217
1360 // Tests that a window activation exits overview mode. 1218 // Tests that a window activation exits overview mode.
1361 TEST_P(WindowSelectorTest, ActivationCancelsOveriew) { 1219 TEST_F(WindowSelectorTest, ActivationCancelsOveriew) {
1362 gfx::Rect bounds(0, 0, 400, 400); 1220 gfx::Rect bounds(0, 0, 400, 400);
1363 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1221 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1364 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1222 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1365 window2->Focus(); 1223 window2->Focus();
1366 ToggleOverview(); 1224 ToggleOverview();
1367 EXPECT_TRUE(IsSelecting()); 1225 EXPECT_TRUE(IsSelecting());
1368 1226
1369 // A window being activated should exit overview mode. 1227 // A window being activated should exit overview mode.
1370 window1->Focus(); 1228 window1->Focus();
1371 EXPECT_FALSE(IsSelecting()); 1229 EXPECT_FALSE(IsSelecting());
1372 1230
1373 // window1 should be focused after exiting even though window2 was focused on 1231 // window1 should be focused after exiting even though window2 was focused on
1374 // entering overview because we exited due to an activation. 1232 // entering overview because we exited due to an activation.
1375 EXPECT_EQ(window1.get(), GetFocusedWindow()); 1233 EXPECT_EQ(window1.get(), GetFocusedWindow());
1376 } 1234 }
1377 1235
1378 // Tests that exiting overview mode without selecting a window restores focus 1236 // Tests that exiting overview mode without selecting a window restores focus
1379 // to the previously focused window. 1237 // to the previously focused window.
1380 TEST_P(WindowSelectorTest, CancelRestoresFocus) { 1238 TEST_F(WindowSelectorTest, CancelRestoresFocus) {
1381 gfx::Rect bounds(0, 0, 400, 400); 1239 gfx::Rect bounds(0, 0, 400, 400);
1382 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); 1240 std::unique_ptr<aura::Window> window(CreateWindow(bounds));
1383 wm::ActivateWindow(window.get()); 1241 wm::ActivateWindow(window.get());
1384 EXPECT_EQ(window.get(), GetFocusedWindow()); 1242 EXPECT_EQ(window.get(), GetFocusedWindow());
1385 1243
1386 // In overview mode, the text filter widget should be focused. 1244 // In overview mode, the text filter widget should be focused.
1387 ToggleOverview(); 1245 ToggleOverview();
1388 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow()); 1246 EXPECT_EQ(text_filter_widget()->GetNativeWindow(), GetFocusedWindow());
1389 1247
1390 // If canceling overview mode, focus should be restored. 1248 // If canceling overview mode, focus should be restored.
1391 ToggleOverview(); 1249 ToggleOverview();
1392 EXPECT_EQ(window.get(), GetFocusedWindow()); 1250 EXPECT_EQ(window.get(), GetFocusedWindow());
1393 } 1251 }
1394 1252
1395 // Tests that overview mode is exited if the last remaining window is destroyed. 1253 // Tests that overview mode is exited if the last remaining window is destroyed.
1396 TEST_P(WindowSelectorTest, LastWindowDestroyed) { 1254 TEST_F(WindowSelectorTest, LastWindowDestroyed) {
1397 gfx::Rect bounds(0, 0, 400, 400); 1255 gfx::Rect bounds(0, 0, 400, 400);
1398 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1256 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1399 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1257 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1400 ToggleOverview(); 1258 ToggleOverview();
1401 1259
1402 window1.reset(); 1260 window1.reset();
1403 window2.reset(); 1261 window2.reset();
1404 EXPECT_FALSE(IsSelecting()); 1262 EXPECT_FALSE(IsSelecting());
1405 } 1263 }
1406 1264
1407 // Tests that entering overview mode restores a window to its original 1265 // Tests that entering overview mode restores a window to its original
1408 // target location. 1266 // target location.
1409 TEST_P(WindowSelectorTest, QuickReentryRestoresInitialTransform) { 1267 TEST_F(WindowSelectorTest, QuickReentryRestoresInitialTransform) {
1410 gfx::Rect bounds(0, 0, 400, 400); 1268 gfx::Rect bounds(0, 0, 400, 400);
1411 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); 1269 std::unique_ptr<aura::Window> window(CreateWindow(bounds));
1412 gfx::Rect initial_bounds = 1270 gfx::Rect initial_bounds =
1413 ToEnclosingRect(GetTransformedBounds(window.get())); 1271 ToEnclosingRect(GetTransformedBounds(window.get()));
1414 ToggleOverview(); 1272 ToggleOverview();
1415 // Quickly exit and reenter overview mode. The window should still be 1273 // Quickly exit and reenter overview mode. The window should still be
1416 // animating when we reenter. We cannot short circuit animations for this but 1274 // animating when we reenter. We cannot short circuit animations for this but
1417 // we also don't have to wait for them to complete. 1275 // we also don't have to wait for them to complete.
1418 { 1276 {
1419 ui::ScopedAnimationDurationScaleMode test_duration_mode( 1277 ui::ScopedAnimationDurationScaleMode test_duration_mode(
1420 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION); 1278 ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
1421 ToggleOverview(); 1279 ToggleOverview();
1422 ToggleOverview(); 1280 ToggleOverview();
1423 } 1281 }
1424 EXPECT_NE(initial_bounds, 1282 EXPECT_NE(initial_bounds,
1425 ToEnclosingRect(GetTransformedTargetBounds(window.get()))); 1283 ToEnclosingRect(GetTransformedTargetBounds(window.get())));
1426 ToggleOverview(); 1284 ToggleOverview();
1427 EXPECT_FALSE(IsSelecting()); 1285 EXPECT_FALSE(IsSelecting());
1428 EXPECT_EQ(initial_bounds, 1286 EXPECT_EQ(initial_bounds,
1429 ToEnclosingRect(GetTransformedTargetBounds(window.get()))); 1287 ToEnclosingRect(GetTransformedTargetBounds(window.get())));
1430 } 1288 }
1431 1289
1432 // Tests that windows with modal child windows are transformed with the modal 1290 // Tests that windows with modal child windows are transformed with the modal
1433 // child even though not activatable themselves. 1291 // child even though not activatable themselves.
1434 TEST_P(WindowSelectorTest, ModalChild) { 1292 TEST_F(WindowSelectorTest, ModalChild) {
1435 gfx::Rect bounds(0, 0, 400, 400); 1293 gfx::Rect bounds(0, 0, 400, 400);
1436 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1294 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1437 std::unique_ptr<aura::Window> child1(CreateWindow(bounds)); 1295 std::unique_ptr<aura::Window> child1(CreateWindow(bounds));
1438 child1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 1296 child1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
1439 ::wm::AddTransientChild(window1.get(), child1.get()); 1297 ::wm::AddTransientChild(window1.get(), child1.get());
1440 EXPECT_EQ(window1->parent(), child1->parent()); 1298 EXPECT_EQ(window1->parent(), child1->parent());
1441 ToggleOverview(); 1299 ToggleOverview();
1442 EXPECT_TRUE(window1->IsVisible()); 1300 EXPECT_TRUE(window1->IsVisible());
1443 EXPECT_TRUE(child1->IsVisible()); 1301 EXPECT_TRUE(child1->IsVisible());
1444 EXPECT_EQ(ToEnclosingRect(GetTransformedTargetBounds(child1.get())), 1302 EXPECT_EQ(ToEnclosingRect(GetTransformedTargetBounds(child1.get())),
1445 ToEnclosingRect(GetTransformedTargetBounds(window1.get()))); 1303 ToEnclosingRect(GetTransformedTargetBounds(window1.get())));
1446 ToggleOverview(); 1304 ToggleOverview();
1447 } 1305 }
1448 1306
1449 // Tests that clicking a modal window's parent activates the modal window in 1307 // Tests that clicking a modal window's parent activates the modal window in
1450 // overview. 1308 // overview.
1451 TEST_P(WindowSelectorTest, ClickModalWindowParent) { 1309 TEST_F(WindowSelectorTest, ClickModalWindowParent) {
1452 std::unique_ptr<aura::Window> window1( 1310 std::unique_ptr<aura::Window> window1(
1453 CreateWindow(gfx::Rect(0, 0, 180, 180))); 1311 CreateWindow(gfx::Rect(0, 0, 180, 180)));
1454 std::unique_ptr<aura::Window> child1( 1312 std::unique_ptr<aura::Window> child1(
1455 CreateWindow(gfx::Rect(200, 0, 180, 180))); 1313 CreateWindow(gfx::Rect(200, 0, 180, 180)));
1456 child1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW); 1314 child1->SetProperty(aura::client::kModalKey, ui::MODAL_TYPE_WINDOW);
1457 ::wm::AddTransientChild(window1.get(), child1.get()); 1315 ::wm::AddTransientChild(window1.get(), child1.get());
1458 EXPECT_FALSE(WindowsOverlapping(window1.get(), child1.get())); 1316 EXPECT_FALSE(WindowsOverlapping(window1.get(), child1.get()));
1459 EXPECT_EQ(window1->parent(), child1->parent()); 1317 EXPECT_EQ(window1->parent(), child1->parent());
1460 ToggleOverview(); 1318 ToggleOverview();
1461 // Given that their relative positions are preserved, the windows should still 1319 // Given that their relative positions are preserved, the windows should still
1462 // not overlap. 1320 // not overlap.
1463 EXPECT_FALSE(WindowsOverlapping(window1.get(), child1.get())); 1321 EXPECT_FALSE(WindowsOverlapping(window1.get(), child1.get()));
1464 ClickWindow(window1.get()); 1322 ClickWindow(window1.get());
1465 EXPECT_FALSE(IsSelecting()); 1323 EXPECT_FALSE(IsSelecting());
1466 1324
1467 // Clicking on window1 should activate child1. 1325 // Clicking on window1 should activate child1.
1468 EXPECT_TRUE(wm::IsActiveWindow(child1.get())); 1326 EXPECT_TRUE(wm::IsActiveWindow(child1.get()));
1469 } 1327 }
1470 1328
1471 // Tests that windows remain on the display they are currently on in overview 1329 // Tests that windows remain on the display they are currently on in overview
1472 // mode, and that the close buttons are on matching displays. 1330 // mode, and that the close buttons are on matching displays.
1473 TEST_P(WindowSelectorTest, MultipleDisplays) { 1331 TEST_F(WindowSelectorTest, MultipleDisplays) {
1474 if (!SupportsMultipleDisplays()) 1332 if (!SupportsMultipleDisplays())
1475 return; 1333 return;
1476 1334
1477 UpdateDisplay("600x400,600x400"); 1335 UpdateDisplay("600x400,600x400");
1478 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1336 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1479 gfx::Rect bounds1(0, 0, 400, 400); 1337 gfx::Rect bounds1(0, 0, 400, 400);
1480 gfx::Rect bounds2(650, 0, 400, 400); 1338 gfx::Rect bounds2(650, 0, 400, 400);
1481 1339
1482 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); 1340 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1));
1483 std::unique_ptr<aura::Window> window2(CreateWindow(bounds1)); 1341 std::unique_ptr<aura::Window> window2(CreateWindow(bounds1));
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1522 GetWindowItemForWindow(0, panel1.get())); 1380 GetWindowItemForWindow(0, panel1.get()));
1523 IsWindowAndCloseButtonInScreen(panel2.get(), 1381 IsWindowAndCloseButtonInScreen(panel2.get(),
1524 GetWindowItemForWindow(0, panel2.get())); 1382 GetWindowItemForWindow(0, panel2.get()));
1525 IsWindowAndCloseButtonInScreen(panel3.get(), 1383 IsWindowAndCloseButtonInScreen(panel3.get(),
1526 GetWindowItemForWindow(1, panel3.get())); 1384 GetWindowItemForWindow(1, panel3.get()));
1527 IsWindowAndCloseButtonInScreen(panel4.get(), 1385 IsWindowAndCloseButtonInScreen(panel4.get(),
1528 GetWindowItemForWindow(1, panel4.get())); 1386 GetWindowItemForWindow(1, panel4.get()));
1529 } 1387 }
1530 1388
1531 // Tests shutting down during overview. 1389 // Tests shutting down during overview.
1532 TEST_P(WindowSelectorTest, Shutdown) { 1390 TEST_F(WindowSelectorTest, Shutdown) {
1533 gfx::Rect bounds(0, 0, 400, 400); 1391 gfx::Rect bounds(0, 0, 400, 400);
1534 // These windows will be deleted when the test exits and the Shell instance 1392 // These windows will be deleted when the test exits and the Shell instance
1535 // is shut down. 1393 // is shut down.
1536 aura::Window* window1(CreateWindow(bounds)); 1394 aura::Window* window1(CreateWindow(bounds));
1537 aura::Window* window2(CreateWindow(bounds)); 1395 aura::Window* window2(CreateWindow(bounds));
1538 aura::Window* window3(CreatePanelWindow(bounds)); 1396 aura::Window* window3(CreatePanelWindow(bounds));
1539 aura::Window* window4(CreatePanelWindow(bounds)); 1397 aura::Window* window4(CreatePanelWindow(bounds));
1540 1398
1541 wm::ActivateWindow(window4); 1399 wm::ActivateWindow(window4);
1542 wm::ActivateWindow(window3); 1400 wm::ActivateWindow(window3);
1543 wm::ActivateWindow(window2); 1401 wm::ActivateWindow(window2);
1544 wm::ActivateWindow(window1); 1402 wm::ActivateWindow(window1);
1545 1403
1546 ToggleOverview(); 1404 ToggleOverview();
1547 } 1405 }
1548 1406
1549 // Tests removing a display during overview. 1407 // Tests removing a display during overview.
1550 TEST_P(WindowSelectorTest, RemoveDisplay) { 1408 TEST_F(WindowSelectorTest, RemoveDisplay) {
1551 if (!SupportsMultipleDisplays()) 1409 if (!SupportsMultipleDisplays())
1552 return; 1410 return;
1553 1411
1554 UpdateDisplay("400x400,400x400"); 1412 UpdateDisplay("400x400,400x400");
1555 gfx::Rect bounds1(0, 0, 100, 100); 1413 gfx::Rect bounds1(0, 0, 100, 100);
1556 gfx::Rect bounds2(450, 0, 100, 100); 1414 gfx::Rect bounds2(450, 0, 100, 100);
1557 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); 1415 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1));
1558 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); 1416 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2));
1559 std::unique_ptr<aura::Window> window3(CreatePanelWindow(bounds1)); 1417 std::unique_ptr<aura::Window> window3(CreatePanelWindow(bounds1));
1560 std::unique_ptr<aura::Window> window4(CreatePanelWindow(bounds2)); 1418 std::unique_ptr<aura::Window> window4(CreatePanelWindow(bounds2));
(...skipping 11 matching lines...) Expand all
1572 1430
1573 ToggleOverview(); 1431 ToggleOverview();
1574 EXPECT_TRUE(IsSelecting()); 1432 EXPECT_TRUE(IsSelecting());
1575 UpdateDisplay("400x400"); 1433 UpdateDisplay("400x400");
1576 EXPECT_FALSE(IsSelecting()); 1434 EXPECT_FALSE(IsSelecting());
1577 } 1435 }
1578 1436
1579 // Tests starting overview during a drag and drop tracking operation. 1437 // Tests starting overview during a drag and drop tracking operation.
1580 // TODO(flackr): Fix memory corruption crash when running locally (not failing 1438 // TODO(flackr): Fix memory corruption crash when running locally (not failing
1581 // on bots). See http://crbug.com/342528. 1439 // on bots). See http://crbug.com/342528.
1582 TEST_P(WindowSelectorTest, DISABLED_DragDropInProgress) { 1440 TEST_F(WindowSelectorTest, DISABLED_DragDropInProgress) {
1583 bool drag_canceled_by_test = false; 1441 bool drag_canceled_by_test = false;
1584 gfx::Rect bounds(0, 0, 400, 400); 1442 gfx::Rect bounds(0, 0, 400, 400);
1585 std::unique_ptr<aura::Window> window(CreateWindow(bounds)); 1443 std::unique_ptr<aura::Window> window(CreateWindow(bounds));
1586 test::ShellTestApi shell_test_api(Shell::GetInstance()); 1444 test::ShellTestApi shell_test_api(Shell::GetInstance());
1587 DragDropController* drag_drop_controller = 1445 DragDropController* drag_drop_controller =
1588 shell_test_api.drag_drop_controller(); 1446 shell_test_api.drag_drop_controller();
1589 ui::OSExchangeData data; 1447 ui::OSExchangeData data;
1590 base::ThreadTaskRunnerHandle::Get()->PostTask( 1448 base::ThreadTaskRunnerHandle::Get()->PostTask(
1591 FROM_HERE, 1449 FROM_HERE,
1592 base::Bind(&WindowSelectorTest::ToggleOverview, base::Unretained(this))); 1450 base::Bind(&WindowSelectorTest::ToggleOverview, base::Unretained(this)));
1593 base::ThreadTaskRunnerHandle::Get()->PostTask( 1451 base::ThreadTaskRunnerHandle::Get()->PostTask(
1594 FROM_HERE, 1452 FROM_HERE,
1595 base::Bind(&CancelDrag, drag_drop_controller, &drag_canceled_by_test)); 1453 base::Bind(&CancelDrag, drag_drop_controller, &drag_canceled_by_test));
1596 data.SetString(base::UTF8ToUTF16("I am being dragged")); 1454 data.SetString(base::UTF8ToUTF16("I am being dragged"));
1597 drag_drop_controller->StartDragAndDrop( 1455 drag_drop_controller->StartDragAndDrop(
1598 data, window->GetRootWindow(), window.get(), gfx::Point(5, 5), 1456 data, window->GetRootWindow(), window.get(), gfx::Point(5, 5),
1599 ui::DragDropTypes::DRAG_MOVE, ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE); 1457 ui::DragDropTypes::DRAG_MOVE, ui::DragDropTypes::DRAG_EVENT_SOURCE_MOUSE);
1600 RunAllPendingInMessageLoop(); 1458 RunAllPendingInMessageLoop();
1601 EXPECT_FALSE(drag_canceled_by_test); 1459 EXPECT_FALSE(drag_canceled_by_test);
1602 ASSERT_TRUE(IsSelecting()); 1460 ASSERT_TRUE(IsSelecting());
1603 RunAllPendingInMessageLoop(); 1461 RunAllPendingInMessageLoop();
1604 } 1462 }
1605 1463
1606 // Test that a label is created under the window on entering overview mode. 1464 // Test that a label is created under the window on entering overview mode.
1607 TEST_P(WindowSelectorTest, CreateLabelUnderWindow) { 1465 TEST_F(WindowSelectorTest, CreateLabelUnderWindow) {
1608 std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 300, 500))); 1466 std::unique_ptr<aura::Window> window(CreateWindow(gfx::Rect(0, 0, 300, 500)));
1609 base::string16 window_title = base::UTF8ToUTF16("My window"); 1467 base::string16 window_title = base::UTF8ToUTF16("My window");
1610 window->SetTitle(window_title); 1468 window->SetTitle(window_title);
1611 ToggleOverview(); 1469 ToggleOverview();
1612 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back(); 1470 WindowSelectorItem* window_item = GetWindowItemsForRoot(0).back();
1613 views::LabelButton* label = GetLabelButtonView(window_item); 1471 views::LabelButton* label = GetLabelButtonView(window_item);
1614 // Has the label view been created? 1472 // Has the label view been created?
1615 ASSERT_TRUE(label); 1473 ASSERT_TRUE(label);
1616 1474
1617 // Verify the label matches the window title. 1475 // Verify the label matches the window title.
1618 EXPECT_EQ(label->GetText(), window_title); 1476 EXPECT_EQ(label->GetText(), window_title);
1619 1477
1620 // Update the window title and check that the label is updated, too. 1478 // Update the window title and check that the label is updated, too.
1621 base::string16 updated_title = base::UTF8ToUTF16("Updated title"); 1479 base::string16 updated_title = base::UTF8ToUTF16("Updated title");
1622 window->SetTitle(updated_title); 1480 window->SetTitle(updated_title);
1623 EXPECT_EQ(label->GetText(), updated_title); 1481 EXPECT_EQ(label->GetText(), updated_title);
1624 1482
1625 // Labels are located based on target_bounds, not the actual window item 1483 // Labels are located based on target_bounds, not the actual window item
1626 // bounds. 1484 // bounds.
1627 gfx::Rect label_bounds = label->GetWidget()->GetWindowBoundsInScreen(); 1485 gfx::Rect label_bounds = label->GetWidget()->GetWindowBoundsInScreen();
1628 if (ash::MaterialDesignController::IsOverviewMaterial()) 1486 label_bounds.Inset(kWindowMargin, kWindowMargin);
1629 label_bounds.Inset(kWindowMarginMD, kWindowMarginMD);
1630 EXPECT_EQ(window_item->target_bounds(), label_bounds); 1487 EXPECT_EQ(window_item->target_bounds(), label_bounds);
1631 } 1488 }
1632 1489
1633 // Tests that overview updates the window positions if the display orientation 1490 // Tests that overview updates the window positions if the display orientation
1634 // changes. 1491 // changes.
1635 TEST_P(WindowSelectorTest, DisplayOrientationChanged) { 1492 TEST_F(WindowSelectorTest, DisplayOrientationChanged) {
1636 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow(); 1493 aura::Window* root_window = Shell::GetInstance()->GetPrimaryRootWindow();
1637 UpdateDisplay("600x200"); 1494 UpdateDisplay("600x200");
1638 EXPECT_EQ("0,0 600x200", root_window->bounds().ToString()); 1495 EXPECT_EQ("0,0 600x200", root_window->bounds().ToString());
1639 gfx::Rect window_bounds(0, 0, 150, 150); 1496 gfx::Rect window_bounds(0, 0, 150, 150);
1640 ScopedVector<aura::Window> windows; 1497 ScopedVector<aura::Window> windows;
1641 for (int i = 0; i < 3; i++) { 1498 for (int i = 0; i < 3; i++) {
1642 windows.push_back(CreateWindow(window_bounds)); 1499 windows.push_back(CreateWindow(window_bounds));
1643 } 1500 }
1644 1501
1645 ToggleOverview(); 1502 ToggleOverview();
1646 for (ScopedVector<aura::Window>::iterator iter = windows.begin(); 1503 for (ScopedVector<aura::Window>::iterator iter = windows.begin();
1647 iter != windows.end(); ++iter) { 1504 iter != windows.end(); ++iter) {
1648 EXPECT_TRUE(root_window->bounds().Contains( 1505 EXPECT_TRUE(root_window->bounds().Contains(
1649 ToEnclosingRect(GetTransformedTargetBounds(*iter)))); 1506 ToEnclosingRect(GetTransformedTargetBounds(*iter))));
1650 } 1507 }
1651 1508
1652 // Rotate the display, windows should be repositioned to be within the screen 1509 // Rotate the display, windows should be repositioned to be within the screen
1653 // bounds. 1510 // bounds.
1654 UpdateDisplay("600x200/r"); 1511 UpdateDisplay("600x200/r");
1655 EXPECT_EQ("0,0 200x600", root_window->bounds().ToString()); 1512 EXPECT_EQ("0,0 200x600", root_window->bounds().ToString());
1656 for (ScopedVector<aura::Window>::iterator iter = windows.begin(); 1513 for (ScopedVector<aura::Window>::iterator iter = windows.begin();
1657 iter != windows.end(); ++iter) { 1514 iter != windows.end(); ++iter) {
1658 EXPECT_TRUE(root_window->bounds().Contains( 1515 EXPECT_TRUE(root_window->bounds().Contains(
1659 ToEnclosingRect(GetTransformedTargetBounds(*iter)))); 1516 ToEnclosingRect(GetTransformedTargetBounds(*iter))));
1660 } 1517 }
1661 } 1518 }
1662 1519
1663 // Tests traversing some windows in overview mode with the tab key. 1520 // Tests traversing some windows in overview mode with the tab key.
1664 TEST_P(WindowSelectorTest, BasicTabKeyNavigation) { 1521 TEST_F(WindowSelectorTest, BasicTabKeyNavigation) {
1665 gfx::Rect bounds(0, 0, 100, 100); 1522 gfx::Rect bounds(0, 0, 100, 100);
1666 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1523 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1667 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1524 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1668 ToggleOverview(); 1525 ToggleOverview();
1669 1526
1670 const std::vector<WindowSelectorItem*>& overview_windows = 1527 const std::vector<WindowSelectorItem*>& overview_windows =
1671 GetWindowItemsForRoot(0); 1528 GetWindowItemsForRoot(0);
1672 SendKey(ui::VKEY_TAB); 1529 SendKey(ui::VKEY_TAB);
1673 EXPECT_EQ(GetSelectedWindow(), 1530 EXPECT_EQ(GetSelectedWindow(),
1674 WmWindowAura::GetAuraWindow(overview_windows[0]->GetWindow())); 1531 WmWindowAura::GetAuraWindow(overview_windows[0]->GetWindow()));
1675 SendKey(ui::VKEY_TAB); 1532 SendKey(ui::VKEY_TAB);
1676 EXPECT_EQ(GetSelectedWindow(), 1533 EXPECT_EQ(GetSelectedWindow(),
1677 WmWindowAura::GetAuraWindow(overview_windows[1]->GetWindow())); 1534 WmWindowAura::GetAuraWindow(overview_windows[1]->GetWindow()));
1678 SendKey(ui::VKEY_TAB); 1535 SendKey(ui::VKEY_TAB);
1679 EXPECT_EQ(GetSelectedWindow(), 1536 EXPECT_EQ(GetSelectedWindow(),
1680 WmWindowAura::GetAuraWindow(overview_windows[0]->GetWindow())); 1537 WmWindowAura::GetAuraWindow(overview_windows[0]->GetWindow()));
1681 } 1538 }
1682 1539
1683 // Tests that pressing Ctrl+W while a window is selected in overview closes it. 1540 // Tests that pressing Ctrl+W while a window is selected in overview closes it.
1684 TEST_P(WindowSelectorTest, CloseWindowWithKey) { 1541 TEST_F(WindowSelectorTest, CloseWindowWithKey) {
1685 gfx::Rect bounds(0, 0, 100, 100); 1542 gfx::Rect bounds(0, 0, 100, 100);
1686 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1543 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1687 std::unique_ptr<views::Widget> widget = 1544 std::unique_ptr<views::Widget> widget =
1688 CreateWindowWidget(gfx::Rect(0, 0, 400, 400)); 1545 CreateWindowWidget(gfx::Rect(0, 0, 400, 400));
1689 aura::Window* window1 = widget->GetNativeWindow(); 1546 aura::Window* window1 = widget->GetNativeWindow();
1690 ToggleOverview(); 1547 ToggleOverview();
1691 1548
1692 SendKey(ui::VKEY_RIGHT); 1549 SendKey(ui::VKEY_RIGHT);
1693 EXPECT_EQ(window1, GetSelectedWindow()); 1550 EXPECT_EQ(window1, GetSelectedWindow());
1694 SendCtrlKey(ui::VKEY_W); 1551 SendCtrlKey(ui::VKEY_W);
1695 EXPECT_TRUE(widget->IsClosed()); 1552 EXPECT_TRUE(widget->IsClosed());
1696 } 1553 }
1697 1554
1698 // Tests traversing some windows in overview mode with the arrow keys in every 1555 // Tests traversing some windows in overview mode with the arrow keys in every
1699 // possible direction. 1556 // possible direction.
1700 TEST_P(WindowSelectorTest, BasicArrowKeyNavigation) { 1557 TEST_F(WindowSelectorTest, BasicArrowKeyNavigation) {
1701 const size_t test_windows = 9; 1558 const size_t test_windows = 9;
1702 UpdateDisplay("800x600"); 1559 UpdateDisplay("800x600");
1703 ScopedVector<aura::Window> windows; 1560 ScopedVector<aura::Window> windows;
1704 for (size_t i = test_windows; i > 0; i--) 1561 for (size_t i = test_windows; i > 0; i--)
1705 windows.push_back(CreateWindowWithId(gfx::Rect(0, 0, 100, 100), i)); 1562 windows.push_back(CreateWindowWithId(gfx::Rect(0, 0, 100, 100), i));
1706 1563
1707 ui::KeyboardCode arrow_keys[] = {ui::VKEY_RIGHT, ui::VKEY_DOWN, ui::VKEY_LEFT, 1564 ui::KeyboardCode arrow_keys[] = {ui::VKEY_RIGHT, ui::VKEY_DOWN, ui::VKEY_LEFT,
1708 ui::VKEY_UP}; 1565 ui::VKEY_UP};
1709 // Expected window layout, assuming that the text filtering feature is 1566 // The rows contain variable number of items making vertical navigation not
1710 // enabled by default (i.e., --ash-disable-text-filtering-in-overview-mode 1567 // feasible. [Down] is equivalent to [Right] and [Up] is equivalent to [Left].
1711 // is not being used).
1712 // +-------+ +-------+ +-------+ +-------+
1713 // | 1 | | 2 | | 3 | | 4 |
1714 // +-------+ +-------+ +-------+ +-------+
1715 // +-------+ +-------+ +-------+ +-------+
1716 // | 5 | | 6 | | 7 | | 8 |
1717 // +-------+ +-------+ +-------+ +-------+
1718 // +-------+
1719 // | 9 |
1720 // +-------+
1721 // Index for each window during a full loop plus wrapping around.
1722 int index_path_for_direction[][test_windows + 1] = { 1568 int index_path_for_direction[][test_windows + 1] = {
1723 {1, 2, 3, 4, 5, 6, 7, 8, 9, 1}, // Right 1569 {1, 2, 3, 4, 5, 6, 7, 8, 9, 1}, // Right
1724 {1, 5, 9, 2, 6, 3, 7, 4, 8, 1}, // Down
1725 {9, 8, 7, 6, 5, 4, 3, 2, 1, 9}, // Left
1726 {8, 4, 7, 3, 6, 2, 9, 5, 1, 8} // Up
1727 };
1728 // With Material Design the rows contain variable number of items making
1729 // vertical navigation not feasible. [Down] key is equivalent to [Right].
1730 // [Up] is equivalent to [Left].
1731 int index_path_for_direction_MD[][test_windows + 1] = {
1732 {1, 2, 3, 4, 5, 6, 7, 8, 9, 1}, // Right
1733 {1, 2, 3, 4, 5, 6, 7, 8, 9, 1}, // Down (same as Right) 1570 {1, 2, 3, 4, 5, 6, 7, 8, 9, 1}, // Down (same as Right)
1734 {9, 8, 7, 6, 5, 4, 3, 2, 1, 9}, // Left 1571 {9, 8, 7, 6, 5, 4, 3, 2, 1, 9}, // Left
1735 {9, 8, 7, 6, 5, 4, 3, 2, 1, 9} // Up (same as Left) 1572 {9, 8, 7, 6, 5, 4, 3, 2, 1, 9} // Up (same as Left)
1736 }; 1573 };
1737 1574
1738 for (size_t key_index = 0; key_index < arraysize(arrow_keys); key_index++) { 1575 for (size_t key_index = 0; key_index < arraysize(arrow_keys); key_index++) {
1739 ToggleOverview(); 1576 ToggleOverview();
1740 const std::vector<WindowSelectorItem*>& overview_windows = 1577 const std::vector<WindowSelectorItem*>& overview_windows =
1741 GetWindowItemsForRoot(0); 1578 GetWindowItemsForRoot(0);
1742 for (size_t i = 0; i < test_windows + 1; i++) { 1579 for (size_t i = 0; i < test_windows + 1; i++) {
1743 SendKey(arrow_keys[key_index]); 1580 SendKey(arrow_keys[key_index]);
1744 // TODO(flackr): Add a more readable error message by constructing a 1581 // TODO(flackr): Add a more readable error message by constructing a
1745 // string from the window IDs. 1582 // string from the window IDs.
1746 const int index = ash::MaterialDesignController::IsOverviewMaterial() 1583 const int index = index_path_for_direction[key_index][i];
1747 ? index_path_for_direction_MD[key_index][i]
1748 : index_path_for_direction[key_index][i];
1749 EXPECT_EQ(GetSelectedWindow()->id(), 1584 EXPECT_EQ(GetSelectedWindow()->id(),
1750 overview_windows[index - 1]->GetWindow()->GetShellWindowId()); 1585 overview_windows[index - 1]->GetWindow()->GetShellWindowId());
1751 } 1586 }
1752 ToggleOverview(); 1587 ToggleOverview();
1753 } 1588 }
1754 } 1589 }
1755 1590
1756 // Tests basic selection across multiple monitors. 1591 // Tests basic selection across multiple monitors.
1757 TEST_P(WindowSelectorTest, BasicMultiMonitorArrowKeyNavigation) { 1592 TEST_F(WindowSelectorTest, BasicMultiMonitorArrowKeyNavigation) {
1758 if (!SupportsMultipleDisplays()) 1593 if (!SupportsMultipleDisplays())
1759 return; 1594 return;
1760 1595
1761 UpdateDisplay("400x400,400x400"); 1596 UpdateDisplay("400x400,400x400");
1762 gfx::Rect bounds1(0, 0, 100, 100); 1597 gfx::Rect bounds1(0, 0, 100, 100);
1763 gfx::Rect bounds2(450, 0, 100, 100); 1598 gfx::Rect bounds2(450, 0, 100, 100);
1764 std::unique_ptr<aura::Window> window4(CreateWindow(bounds2)); 1599 std::unique_ptr<aura::Window> window4(CreateWindow(bounds2));
1765 std::unique_ptr<aura::Window> window3(CreateWindow(bounds2)); 1600 std::unique_ptr<aura::Window> window3(CreateWindow(bounds2));
1766 std::unique_ptr<aura::Window> window2(CreateWindow(bounds1)); 1601 std::unique_ptr<aura::Window> window2(CreateWindow(bounds1));
1767 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1)); 1602 std::unique_ptr<aura::Window> window1(CreateWindow(bounds1));
(...skipping 13 matching lines...) Expand all
1781 SendKey(ui::VKEY_RIGHT); 1616 SendKey(ui::VKEY_RIGHT);
1782 EXPECT_EQ(GetSelectedWindow(), 1617 EXPECT_EQ(GetSelectedWindow(),
1783 WmWindowAura::GetAuraWindow(overview_root2[0]->GetWindow())); 1618 WmWindowAura::GetAuraWindow(overview_root2[0]->GetWindow()));
1784 SendKey(ui::VKEY_RIGHT); 1619 SendKey(ui::VKEY_RIGHT);
1785 EXPECT_EQ(GetSelectedWindow(), 1620 EXPECT_EQ(GetSelectedWindow(),
1786 WmWindowAura::GetAuraWindow(overview_root2[1]->GetWindow())); 1621 WmWindowAura::GetAuraWindow(overview_root2[1]->GetWindow()));
1787 } 1622 }
1788 1623
1789 // Tests first monitor when display order doesn't match left to right screen 1624 // Tests first monitor when display order doesn't match left to right screen
1790 // positions. 1625 // positions.
1791 TEST_P(WindowSelectorTest, MultiMonitorReversedOrder) { 1626 TEST_F(WindowSelectorTest, MultiMonitorReversedOrder) {
1792 if (!SupportsMultipleDisplays()) 1627 if (!SupportsMultipleDisplays())
1793 return; 1628 return;
1794 1629
1795 UpdateDisplay("400x400,400x400"); 1630 UpdateDisplay("400x400,400x400");
1796 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays( 1631 Shell::GetInstance()->display_manager()->SetLayoutForCurrentDisplays(
1797 test::CreateDisplayLayout(display::DisplayPlacement::LEFT, 0)); 1632 test::CreateDisplayLayout(display::DisplayPlacement::LEFT, 0));
1798 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1633 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1799 gfx::Rect bounds1(-350, 0, 100, 100); 1634 gfx::Rect bounds1(-350, 0, 100, 100);
1800 gfx::Rect bounds2(0, 0, 100, 100); 1635 gfx::Rect bounds2(0, 0, 100, 100);
1801 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); 1636 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2));
(...skipping 11 matching lines...) Expand all
1813 ToggleOverview(); 1648 ToggleOverview();
1814 ToggleOverview(); 1649 ToggleOverview();
1815 1650
1816 // Coming from right to left, we should select window2 first being on the 1651 // Coming from right to left, we should select window2 first being on the
1817 // display on the right. 1652 // display on the right.
1818 SendKey(ui::VKEY_LEFT); 1653 SendKey(ui::VKEY_LEFT);
1819 EXPECT_EQ(GetSelectedWindow(), window2.get()); 1654 EXPECT_EQ(GetSelectedWindow(), window2.get());
1820 } 1655 }
1821 1656
1822 // Tests three monitors where the grid becomes empty on one of the monitors. 1657 // Tests three monitors where the grid becomes empty on one of the monitors.
1823 TEST_P(WindowSelectorTest, ThreeMonitor) { 1658 TEST_F(WindowSelectorTest, ThreeMonitor) {
1824 if (!SupportsMultipleDisplays()) 1659 if (!SupportsMultipleDisplays())
1825 return; 1660 return;
1826 1661
1827 UpdateDisplay("400x400,400x400,400x400"); 1662 UpdateDisplay("400x400,400x400,400x400");
1828 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); 1663 aura::Window::Windows root_windows = Shell::GetAllRootWindows();
1829 gfx::Rect bounds1(0, 0, 100, 100); 1664 gfx::Rect bounds1(0, 0, 100, 100);
1830 gfx::Rect bounds2(400, 0, 100, 100); 1665 gfx::Rect bounds2(400, 0, 100, 100);
1831 gfx::Rect bounds3(800, 0, 100, 100); 1666 gfx::Rect bounds3(800, 0, 100, 100);
1832 std::unique_ptr<aura::Window> window3(CreateWindow(bounds3)); 1667 std::unique_ptr<aura::Window> window3(CreateWindow(bounds3));
1833 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2)); 1668 std::unique_ptr<aura::Window> window2(CreateWindow(bounds2));
(...skipping 22 matching lines...) Expand all
1856 SendKey(ui::VKEY_RIGHT); 1691 SendKey(ui::VKEY_RIGHT);
1857 1692
1858 // If the window on the second display is removed, the selected window should 1693 // If the window on the second display is removed, the selected window should
1859 // remain window3. 1694 // remain window3.
1860 EXPECT_EQ(GetSelectedWindow(), window3.get()); 1695 EXPECT_EQ(GetSelectedWindow(), window3.get());
1861 window2.reset(); 1696 window2.reset();
1862 EXPECT_EQ(GetSelectedWindow(), window3.get()); 1697 EXPECT_EQ(GetSelectedWindow(), window3.get());
1863 } 1698 }
1864 1699
1865 // Tests selecting a window in overview mode with the return key. 1700 // Tests selecting a window in overview mode with the return key.
1866 TEST_P(WindowSelectorTest, SelectWindowWithReturnKey) { 1701 TEST_F(WindowSelectorTest, SelectWindowWithReturnKey) {
1867 gfx::Rect bounds(0, 0, 100, 100); 1702 gfx::Rect bounds(0, 0, 100, 100);
1868 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1703 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1869 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1704 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1870 ToggleOverview(); 1705 ToggleOverview();
1871 1706
1872 // Pressing the return key without a selection widget should not do anything. 1707 // Pressing the return key without a selection widget should not do anything.
1873 SendKey(ui::VKEY_RETURN); 1708 SendKey(ui::VKEY_RETURN);
1874 EXPECT_TRUE(IsSelecting()); 1709 EXPECT_TRUE(IsSelecting());
1875 1710
1876 // Select the first window. 1711 // Select the first window.
1877 ASSERT_TRUE(SelectWindow(window1.get())); 1712 ASSERT_TRUE(SelectWindow(window1.get()));
1878 SendKey(ui::VKEY_RETURN); 1713 SendKey(ui::VKEY_RETURN);
1879 ASSERT_FALSE(IsSelecting()); 1714 ASSERT_FALSE(IsSelecting());
1880 EXPECT_TRUE(wm::IsActiveWindow(window1.get())); 1715 EXPECT_TRUE(wm::IsActiveWindow(window1.get()));
1881 1716
1882 // Select the second window. 1717 // Select the second window.
1883 ToggleOverview(); 1718 ToggleOverview();
1884 ASSERT_TRUE(SelectWindow(window2.get())); 1719 ASSERT_TRUE(SelectWindow(window2.get()));
1885 SendKey(ui::VKEY_RETURN); 1720 SendKey(ui::VKEY_RETURN);
1886 EXPECT_FALSE(IsSelecting()); 1721 EXPECT_FALSE(IsSelecting());
1887 EXPECT_TRUE(wm::IsActiveWindow(window2.get())); 1722 EXPECT_TRUE(wm::IsActiveWindow(window2.get()));
1888 } 1723 }
1889 1724
1890 // Tests that overview mode hides the callout widget. 1725 // Tests that overview mode hides the callout widget.
1891 TEST_P(WindowSelectorTest, WindowOverviewHidesCalloutWidgets) { 1726 TEST_F(WindowSelectorTest, WindowOverviewHidesCalloutWidgets) {
1892 std::unique_ptr<aura::Window> panel1( 1727 std::unique_ptr<aura::Window> panel1(
1893 CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); 1728 CreatePanelWindow(gfx::Rect(0, 0, 100, 100)));
1894 WmWindow* wm_panel1 = WmWindowAura::Get(panel1.get()); 1729 WmWindow* wm_panel1 = WmWindowAura::Get(panel1.get());
1895 std::unique_ptr<aura::Window> panel2( 1730 std::unique_ptr<aura::Window> panel2(
1896 CreatePanelWindow(gfx::Rect(0, 0, 100, 100))); 1731 CreatePanelWindow(gfx::Rect(0, 0, 100, 100)));
1897 WmWindow* wm_panel2 = WmWindowAura::Get(panel2.get()); 1732 WmWindow* wm_panel2 = WmWindowAura::Get(panel2.get());
1898 PanelLayoutManager* panel_manager = PanelLayoutManager::Get(wm_panel1); 1733 PanelLayoutManager* panel_manager = PanelLayoutManager::Get(wm_panel1);
1899 1734
1900 // By default, panel callout widgets are visible. 1735 // By default, panel callout widgets are visible.
1901 EXPECT_TRUE(panel_manager->GetCalloutWidgetForPanel(wm_panel1)->IsVisible()); 1736 EXPECT_TRUE(panel_manager->GetCalloutWidgetForPanel(wm_panel1)->IsVisible());
1902 EXPECT_TRUE(panel_manager->GetCalloutWidgetForPanel(wm_panel2)->IsVisible()); 1737 EXPECT_TRUE(panel_manager->GetCalloutWidgetForPanel(wm_panel2)->IsVisible());
1903 1738
1904 // Toggling the overview should hide the callout widgets. 1739 // Toggling the overview should hide the callout widgets.
1905 ToggleOverview(); 1740 ToggleOverview();
1906 EXPECT_FALSE(panel_manager->GetCalloutWidgetForPanel(wm_panel1)->IsVisible()); 1741 EXPECT_FALSE(panel_manager->GetCalloutWidgetForPanel(wm_panel1)->IsVisible());
1907 EXPECT_FALSE(panel_manager->GetCalloutWidgetForPanel(wm_panel2)->IsVisible()); 1742 EXPECT_FALSE(panel_manager->GetCalloutWidgetForPanel(wm_panel2)->IsVisible());
1908 1743
1909 // Ending the overview should show them again. 1744 // Ending the overview should show them again.
1910 ToggleOverview(); 1745 ToggleOverview();
1911 EXPECT_TRUE(panel_manager->GetCalloutWidgetForPanel(wm_panel1)->IsVisible()); 1746 EXPECT_TRUE(panel_manager->GetCalloutWidgetForPanel(wm_panel1)->IsVisible());
1912 EXPECT_TRUE(panel_manager->GetCalloutWidgetForPanel(wm_panel2)->IsVisible()); 1747 EXPECT_TRUE(panel_manager->GetCalloutWidgetForPanel(wm_panel2)->IsVisible());
1913 } 1748 }
1914 1749
1915 // Creates three windows and tests filtering them by title. 1750 // Creates three windows and tests filtering them by title.
1916 TEST_P(WindowSelectorTest, BasicTextFiltering) { 1751 TEST_F(WindowSelectorTest, BasicTextFiltering) {
1917 gfx::Rect bounds(0, 0, 100, 100); 1752 gfx::Rect bounds(0, 0, 100, 100);
1918 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1753 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1919 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1754 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1920 std::unique_ptr<aura::Window> window0(CreateWindow(bounds)); 1755 std::unique_ptr<aura::Window> window0(CreateWindow(bounds));
1921 base::string16 window2_title = base::UTF8ToUTF16("Highway to test"); 1756 base::string16 window2_title = base::UTF8ToUTF16("Highway to test");
1922 base::string16 window1_title = base::UTF8ToUTF16("For those about to test"); 1757 base::string16 window1_title = base::UTF8ToUTF16("For those about to test");
1923 base::string16 window0_title = base::UTF8ToUTF16("We salute you"); 1758 base::string16 window0_title = base::UTF8ToUTF16("We salute you");
1924 window0->SetTitle(window0_title); 1759 window0->SetTitle(window0_title);
1925 window1->SetTitle(window1_title); 1760 window1->SetTitle(window1_title);
1926 window2->SetTitle(window2_title); 1761 window2->SetTitle(window2_title);
(...skipping 26 matching lines...) Expand all
1953 // All the items should match the empty string. The filter widget should also 1788 // All the items should match the empty string. The filter widget should also
1954 // disappear. 1789 // disappear.
1955 FilterItems(""); 1790 FilterItems("");
1956 EXPECT_FALSE(showing_filter_widget()); 1791 EXPECT_FALSE(showing_filter_widget());
1957 EXPECT_FALSE(GetWindowItemForWindow(grid_index, window0.get())->dimmed()); 1792 EXPECT_FALSE(GetWindowItemForWindow(grid_index, window0.get())->dimmed());
1958 EXPECT_FALSE(GetWindowItemForWindow(grid_index, window1.get())->dimmed()); 1793 EXPECT_FALSE(GetWindowItemForWindow(grid_index, window1.get())->dimmed());
1959 EXPECT_FALSE(GetWindowItemForWindow(grid_index, window2.get())->dimmed()); 1794 EXPECT_FALSE(GetWindowItemForWindow(grid_index, window2.get())->dimmed());
1960 } 1795 }
1961 1796
1962 // Tests selecting in the overview with dimmed and undimmed items. 1797 // Tests selecting in the overview with dimmed and undimmed items.
1963 TEST_P(WindowSelectorTest, TextFilteringSelection) { 1798 TEST_F(WindowSelectorTest, TextFilteringSelection) {
1964 gfx::Rect bounds(0, 0, 100, 100); 1799 gfx::Rect bounds(0, 0, 100, 100);
1965 std::unique_ptr<aura::Window> window2(CreateWindow(bounds)); 1800 std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
1966 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1801 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
1967 std::unique_ptr<aura::Window> window0(CreateWindow(bounds)); 1802 std::unique_ptr<aura::Window> window0(CreateWindow(bounds));
1968 base::string16 window2_title = base::UTF8ToUTF16("Rock and roll"); 1803 base::string16 window2_title = base::UTF8ToUTF16("Rock and roll");
1969 base::string16 window1_title = base::UTF8ToUTF16("Rock and"); 1804 base::string16 window1_title = base::UTF8ToUTF16("Rock and");
1970 base::string16 window0_title = base::UTF8ToUTF16("Rock"); 1805 base::string16 window0_title = base::UTF8ToUTF16("Rock");
1971 window0->SetTitle(window0_title); 1806 window0->SetTitle(window0_title);
1972 window1->SetTitle(window1_title); 1807 window1->SetTitle(window1_title);
1973 window2->SetTitle(window2_title); 1808 window2->SetTitle(window2_title);
(...skipping 13 matching lines...) Expand all
1987 FilterItems("Pop"); 1822 FilterItems("Pop");
1988 EXPECT_FALSE(selection_widget_active()); 1823 EXPECT_FALSE(selection_widget_active());
1989 1824
1990 // Undimming one window should automatically select it. 1825 // Undimming one window should automatically select it.
1991 FilterItems("Rock and roll"); 1826 FilterItems("Rock and roll");
1992 EXPECT_EQ(GetSelectedWindow(), window2.get()); 1827 EXPECT_EQ(GetSelectedWindow(), window2.get());
1993 } 1828 }
1994 1829
1995 // Tests that transferring focus from the text filter to a window that is not a 1830 // Tests that transferring focus from the text filter to a window that is not a
1996 // top level window does not cancel overview mode. 1831 // top level window does not cancel overview mode.
1997 TEST_P(WindowSelectorTest, ShowTextFilterMenu) { 1832 TEST_F(WindowSelectorTest, ShowTextFilterMenu) {
1998 gfx::Rect bounds(0, 0, 100, 100); 1833 gfx::Rect bounds(0, 0, 100, 100);
1999 std::unique_ptr<aura::Window> window0(CreateWindow(bounds)); 1834 std::unique_ptr<aura::Window> window0(CreateWindow(bounds));
2000 base::string16 window0_title = base::UTF8ToUTF16("Test"); 1835 base::string16 window0_title = base::UTF8ToUTF16("Test");
2001 window0->SetTitle(window0_title); 1836 window0->SetTitle(window0_title);
2002 wm::GetWindowState(window0.get())->Minimize(); 1837 wm::GetWindowState(window0.get())->Minimize();
2003 ToggleOverview(); 1838 ToggleOverview();
2004 1839
2005 EXPECT_FALSE(selection_widget_active()); 1840 EXPECT_FALSE(selection_widget_active());
2006 EXPECT_FALSE(showing_filter_widget()); 1841 EXPECT_FALSE(showing_filter_widget());
2007 FilterItems("Test"); 1842 FilterItems("Test");
(...skipping 18 matching lines...) Expand all
2026 generator.MoveMouseTo(point_in_text_filter); 1861 generator.MoveMouseTo(point_in_text_filter);
2027 generator.ClickLeftButton(); 1862 generator.ClickLeftButton();
2028 EXPECT_TRUE(IsSelecting()); 1863 EXPECT_TRUE(IsSelecting());
2029 1864
2030 // Cancel overview mode. 1865 // Cancel overview mode.
2031 ToggleOverview(); 1866 ToggleOverview();
2032 ASSERT_FALSE(IsSelecting()); 1867 ASSERT_FALSE(IsSelecting());
2033 } 1868 }
2034 1869
2035 // Tests clicking on the desktop itself to cancel overview mode. 1870 // Tests clicking on the desktop itself to cancel overview mode.
2036 TEST_P(WindowSelectorTest, CancelOverviewOnMouseClick) { 1871 TEST_F(WindowSelectorTest, CancelOverviewOnMouseClick) {
2037 // Overview disabled by default. 1872 // Overview disabled by default.
2038 EXPECT_FALSE(IsSelecting()); 1873 EXPECT_FALSE(IsSelecting());
2039 1874
2040 // Point and bounds selected so that they don't intersect. This causes 1875 // Point and bounds selected so that they don't intersect. This causes
2041 // events located at the point to be passed to WallpaperController, 1876 // events located at the point to be passed to WallpaperController,
2042 // and not the window. 1877 // and not the window.
2043 gfx::Point point_in_background_page(0, 0); 1878 gfx::Point point_in_background_page(0, 0);
2044 gfx::Rect bounds(10, 10, 100, 100); 1879 gfx::Rect bounds(10, 10, 100, 100);
2045 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1880 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
2046 ui::test::EventGenerator& generator = GetEventGenerator(); 1881 ui::test::EventGenerator& generator = GetEventGenerator();
2047 // Move mouse to point in the background page. Sending an event here will pass 1882 // Move mouse to point in the background page. Sending an event here will pass
2048 // it to the WallpaperController in both regular and overview mode. 1883 // it to the WallpaperController in both regular and overview mode.
2049 generator.MoveMouseTo(point_in_background_page); 1884 generator.MoveMouseTo(point_in_background_page);
2050 1885
2051 // Clicking on the background page while not in overview should not toggle 1886 // Clicking on the background page while not in overview should not toggle
2052 // overview. 1887 // overview.
2053 generator.ClickLeftButton(); 1888 generator.ClickLeftButton();
2054 EXPECT_FALSE(IsSelecting()); 1889 EXPECT_FALSE(IsSelecting());
2055 1890
2056 // Switch to overview mode. 1891 // Switch to overview mode.
2057 ToggleOverview(); 1892 ToggleOverview();
2058 ASSERT_TRUE(IsSelecting()); 1893 ASSERT_TRUE(IsSelecting());
2059 1894
2060 // Click should now exit overview mode. 1895 // Click should now exit overview mode.
2061 generator.ClickLeftButton(); 1896 generator.ClickLeftButton();
2062 EXPECT_FALSE(IsSelecting()); 1897 EXPECT_FALSE(IsSelecting());
2063 } 1898 }
2064 1899
2065 // Tests tapping on the desktop itself to cancel overview mode. 1900 // Tests tapping on the desktop itself to cancel overview mode.
2066 TEST_P(WindowSelectorTest, CancelOverviewOnTap) { 1901 TEST_F(WindowSelectorTest, CancelOverviewOnTap) {
2067 // Overview disabled by default. 1902 // Overview disabled by default.
2068 EXPECT_FALSE(IsSelecting()); 1903 EXPECT_FALSE(IsSelecting());
2069 1904
2070 // Point and bounds selected so that they don't intersect. This causes 1905 // Point and bounds selected so that they don't intersect. This causes
2071 // events located at the point to be passed to WallpaperController, 1906 // events located at the point to be passed to WallpaperController,
2072 // and not the window. 1907 // and not the window.
2073 gfx::Point point_in_background_page(0, 0); 1908 gfx::Point point_in_background_page(0, 0);
2074 gfx::Rect bounds(10, 10, 100, 100); 1909 gfx::Rect bounds(10, 10, 100, 100);
2075 std::unique_ptr<aura::Window> window1(CreateWindow(bounds)); 1910 std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
2076 ui::test::EventGenerator& generator = GetEventGenerator(); 1911 ui::test::EventGenerator& generator = GetEventGenerator();
2077 1912
2078 // Tapping on the background page while not in overview should not toggle 1913 // Tapping on the background page while not in overview should not toggle
2079 // overview. 1914 // overview.
2080 generator.GestureTapAt(point_in_background_page); 1915 generator.GestureTapAt(point_in_background_page);
2081 EXPECT_FALSE(IsSelecting()); 1916 EXPECT_FALSE(IsSelecting());
2082 1917
2083 // Switch to overview mode. 1918 // Switch to overview mode.
2084 ToggleOverview(); 1919 ToggleOverview();
2085 ASSERT_TRUE(IsSelecting()); 1920 ASSERT_TRUE(IsSelecting());
2086 1921
2087 // Tap should now exit overview mode. 1922 // Tap should now exit overview mode.
2088 generator.GestureTapAt(point_in_background_page); 1923 generator.GestureTapAt(point_in_background_page);
2089 EXPECT_FALSE(IsSelecting()); 1924 EXPECT_FALSE(IsSelecting());
2090 } 1925 }
2091 1926
2092 // Tests that transformed Rect scaling preserves its aspect ratio. 1927 // Tests that transformed Rect scaling preserves its aspect ratio.
2093 // With Material Design the window scale is determined by the target height and 1928 // The window scale is determined by the target height and so the test is
2094 // so the test is actually testing that the width is calculated correctly. 1929 // actually testing that the width is calculated correctly. Since all
2095 // Since all calculations are done with floating point values and then safely 1930 // calculations are done with floating point values and then safely converted to
2096 // converted to integers (using ceiled and floored values where appropriate), 1931 // integers (using ceiled and floored values where appropriate), the
2097 // the expectations are forgiving (use *_NEAR) within a single pixel. 1932 // expectations are forgiving (use *_NEAR) within a single pixel.
2098 TEST_P(WindowSelectorTest, TransformedRectMaintainsAspect) { 1933 TEST_F(WindowSelectorTest, TransformedRectMaintainsAspect) {
2099 gfx::Rect rect(50, 50, 200, 400); 1934 gfx::Rect rect(50, 50, 200, 400);
2100 gfx::Rect bounds(100, 100, 50, 50); 1935 gfx::Rect bounds(100, 100, 50, 50);
2101 gfx::Rect transformed_rect = 1936 gfx::Rect transformed_rect =
2102 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( 1937 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio(
2103 rect, bounds, 0, 0); 1938 rect, bounds, 0, 0);
2104 float scale = GetItemScale(rect, bounds, 0, 0); 1939 float scale = GetItemScale(rect, bounds, 0, 0);
2105 EXPECT_NEAR(scale * rect.width(), transformed_rect.width(), 1); 1940 EXPECT_NEAR(scale * rect.width(), transformed_rect.width(), 1);
2106 EXPECT_NEAR(scale * rect.height(), transformed_rect.height(), 1); 1941 EXPECT_NEAR(scale * rect.height(), transformed_rect.height(), 1);
2107 1942
2108 rect = gfx::Rect(50, 50, 400, 200); 1943 rect = gfx::Rect(50, 50, 400, 200);
(...skipping 23 matching lines...) Expand all
2132 rect = gfx::Rect(50, 50, 50, 25); 1967 rect = gfx::Rect(50, 50, 50, 25);
2133 scale = GetItemScale(rect, bounds, 0, 0); 1968 scale = GetItemScale(rect, bounds, 0, 0);
2134 transformed_rect = 1969 transformed_rect =
2135 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( 1970 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio(
2136 rect, bounds, 0, 0); 1971 rect, bounds, 0, 0);
2137 EXPECT_NEAR(scale * rect.width(), transformed_rect.width(), 1); 1972 EXPECT_NEAR(scale * rect.width(), transformed_rect.width(), 1);
2138 EXPECT_NEAR(scale * rect.height(), transformed_rect.height(), 1); 1973 EXPECT_NEAR(scale * rect.height(), transformed_rect.height(), 1);
2139 } 1974 }
2140 1975
2141 // Tests that transformed Rect fits in target bounds and is vertically centered. 1976 // Tests that transformed Rect fits in target bounds and is vertically centered.
2142 TEST_P(WindowSelectorTest, TransformedRectIsCentered) { 1977 TEST_F(WindowSelectorTest, TransformedRectIsCentered) {
2143 gfx::Rect rect(50, 50, 200, 400); 1978 gfx::Rect rect(50, 50, 200, 400);
2144 gfx::Rect bounds(100, 100, 50, 50); 1979 gfx::Rect bounds(100, 100, 50, 50);
2145 gfx::Rect transformed_rect = 1980 gfx::Rect transformed_rect =
2146 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( 1981 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio(
2147 rect, bounds, 0, 0); 1982 rect, bounds, 0, 0);
2148 EXPECT_GE(transformed_rect.x(), bounds.x()); 1983 EXPECT_GE(transformed_rect.x(), bounds.x());
2149 EXPECT_LE(transformed_rect.right(), bounds.right()); 1984 EXPECT_LE(transformed_rect.right(), bounds.right());
2150 EXPECT_GE(transformed_rect.y(), bounds.y()); 1985 EXPECT_GE(transformed_rect.y(), bounds.y());
2151 EXPECT_LE(transformed_rect.bottom(), bounds.bottom()); 1986 EXPECT_LE(transformed_rect.bottom(), bounds.bottom());
2152 EXPECT_NEAR(transformed_rect.x() - bounds.x(), 1987 EXPECT_NEAR(transformed_rect.x() - bounds.x(),
2153 bounds.right() - transformed_rect.right(), 1); 1988 bounds.right() - transformed_rect.right(), 1);
2154 EXPECT_NEAR(transformed_rect.y() - bounds.y(), 1989 EXPECT_NEAR(transformed_rect.y() - bounds.y(),
2155 bounds.bottom() - transformed_rect.bottom(), 1); 1990 bounds.bottom() - transformed_rect.bottom(), 1);
2156 } 1991 }
2157 1992
2158 // Tests that transformed Rect fits in target bounds and is vertically centered 1993 // Tests that transformed Rect fits in target bounds and is vertically centered
2159 // when inset and header height are specified. 1994 // when inset and header height are specified.
2160 TEST_P(WindowSelectorTest, TransformedRectIsCenteredWithInset) { 1995 TEST_F(WindowSelectorTest, TransformedRectIsCenteredWithInset) {
2161 gfx::Rect rect(50, 50, 400, 200); 1996 gfx::Rect rect(50, 50, 400, 200);
2162 gfx::Rect bounds(100, 100, 50, 50); 1997 gfx::Rect bounds(100, 100, 50, 50);
2163 const int inset = 20; 1998 const int inset = 20;
2164 const int header_height = 10; 1999 const int header_height = 10;
2165 const float scale = GetItemScale(rect, bounds, inset, header_height); 2000 const float scale = GetItemScale(rect, bounds, inset, header_height);
2166 gfx::Rect transformed_rect = 2001 gfx::Rect transformed_rect =
2167 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio( 2002 ScopedTransformOverviewWindow::ShrinkRectToFitPreservingAspectRatio(
2168 rect, bounds, inset, header_height); 2003 rect, bounds, inset, header_height);
2169 if (ash::MaterialDesignController::IsOverviewMaterial()) { 2004 // The |rect| width does not fit and therefore it gets centered outside
2170 // With Material Design the |rect| width does not fit and therefore it gets 2005 // |bounds| starting before |bounds.x()| and ending after |bounds.right()|.
2171 // centered outside |bounds| starting before |bounds.x()| and ending after 2006 EXPECT_LE(transformed_rect.x(), bounds.x());
2172 // |bounds.right()|. 2007 EXPECT_GE(transformed_rect.right(), bounds.right());
2173 EXPECT_LE(transformed_rect.x(), bounds.x());
2174 EXPECT_GE(transformed_rect.right(), bounds.right());
2175 } else {
2176 EXPECT_GE(transformed_rect.x(), bounds.x());
2177 EXPECT_LE(transformed_rect.right(), bounds.right());
2178 }
2179 EXPECT_GE( 2008 EXPECT_GE(
2180 transformed_rect.y() + gfx::ToCeiledInt(scale * inset) - header_height, 2009 transformed_rect.y() + gfx::ToCeiledInt(scale * inset) - header_height,
2181 bounds.y()); 2010 bounds.y());
2182 EXPECT_LE(transformed_rect.bottom(), bounds.bottom()); 2011 EXPECT_LE(transformed_rect.bottom(), bounds.bottom());
2183 EXPECT_NEAR(transformed_rect.x() - bounds.x(), 2012 EXPECT_NEAR(transformed_rect.x() - bounds.x(),
2184 bounds.right() - transformed_rect.right(), 1); 2013 bounds.right() - transformed_rect.right(), 1);
2185 EXPECT_NEAR( 2014 EXPECT_NEAR(
2186 transformed_rect.y() + (int)(scale * inset) - header_height - bounds.y(), 2015 transformed_rect.y() + (int)(scale * inset) - header_height - bounds.y(),
2187 bounds.bottom() - transformed_rect.bottom(), 1); 2016 bounds.bottom() - transformed_rect.bottom(), 1);
2188 } 2017 }
2189 2018
2190 } // namespace ash 2019 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/overview/scoped_overview_animation_settings_aura.cc ('k') | ash/wm/panels/panel_frame_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698