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

Side by Side Diff: ash/wm/window_cycle_controller_unittest.cc

Issue 2642273002: CrOS - Make it possible to Alt+Tab while dragging a tab (Closed)
Patch Set: fix tests Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ash/common/wm/window_cycle_list.cc ('k') | ash/wm/window_cycle_event_filter_aura.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/wm/window_cycle_controller.h" 5 #include "ash/common/wm/window_cycle_controller.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/common/focus_cycler.h" 10 #include "ash/common/focus_cycler.h"
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 643
644 // Events get through. 644 // Events get through.
645 generator.MoveMouseToCenterOf(w0.get()); 645 generator.MoveMouseToCenterOf(w0.get());
646 generator.ClickLeftButton(); 646 generator.ClickLeftButton();
647 EXPECT_LT(0, event_count.GetMouseEventCountAndReset()); 647 EXPECT_LT(0, event_count.GetMouseEventCountAndReset());
648 648
649 // Start cycling. 649 // Start cycling.
650 WindowCycleController* controller = WmShell::Get()->window_cycle_controller(); 650 WindowCycleController* controller = WmShell::Get()->window_cycle_controller();
651 controller->HandleCycleWindow(WindowCycleController::FORWARD); 651 controller->HandleCycleWindow(WindowCycleController::FORWARD);
652 652
653 // Events don't get through. 653 // Most mouse events don't get through.
654 generator.ClickLeftButton(); 654 generator.PressLeftButton();
655 EXPECT_EQ(0, event_count.GetMouseEventCountAndReset()); 655 EXPECT_EQ(0, event_count.GetMouseEventCountAndReset());
656 656
657 // Although releases do.
658 generator.ReleaseLeftButton();
659 EXPECT_LT(0, event_count.GetMouseEventCountAndReset());
660
657 // Stop cycling: once again, events get through. 661 // Stop cycling: once again, events get through.
658 controller->CompleteCycling(); 662 controller->CompleteCycling();
659 generator.ClickLeftButton(); 663 generator.ClickLeftButton();
660 EXPECT_LT(0, event_count.GetMouseEventCountAndReset()); 664 EXPECT_LT(0, event_count.GetMouseEventCountAndReset());
661 } 665 }
662 666
663 // If mouse capture is lost, the UI closes.
664 TEST_F(WindowCycleControllerTest, MouseCaptureLost) {
665 // This delegate allows the window to receive mouse events.
666 aura::test::TestWindowDelegate delegate;
667 std::unique_ptr<Window> w0(CreateTestWindowInShellWithDelegate(
668 &delegate, 0, gfx::Rect(0, 0, 100, 100)));
669 std::unique_ptr<Window> w1(CreateTestWindowInShellWithId(1));
670
671 // Start cycling.
672 WindowCycleController* controller = WmShell::Get()->window_cycle_controller();
673 controller->HandleCycleWindow(WindowCycleController::FORWARD);
674
675 // Some other widget grabs capture and this causes Alt+Tab to cease.
676 std::unique_ptr<views::Widget> widget = CreateTestWidget(
677 nullptr, kShellWindowId_DefaultContainer, gfx::Rect(1, 2, 3, 4));
678 widget->SetCapture(nullptr);
679 EXPECT_FALSE(controller->IsCycling());
680 }
681
682 // Tests that we can cycle past fullscreen windows: https://crbug.com/622396. 667 // Tests that we can cycle past fullscreen windows: https://crbug.com/622396.
683 // Fullscreen windows are special in that they are allowed to handle alt+tab 668 // Fullscreen windows are special in that they are allowed to handle alt+tab
684 // keypresses, which means the window cycle event filter should not handle 669 // keypresses, which means the window cycle event filter should not handle
685 // the tab press else it prevents cycling past that window. 670 // the tab press else it prevents cycling past that window.
686 TEST_F(WindowCycleControllerTest, TabPastFullscreenWindow) { 671 TEST_F(WindowCycleControllerTest, TabPastFullscreenWindow) {
687 std::unique_ptr<Window> w0(CreateTestWindowInShellWithId(0)); 672 std::unique_ptr<Window> w0(CreateTestWindowInShellWithId(0));
688 std::unique_ptr<Window> w1(CreateTestWindowInShellWithId(1)); 673 std::unique_ptr<Window> w1(CreateTestWindowInShellWithId(1));
689 wm::WMEvent maximize_event(wm::WM_EVENT_FULLSCREEN); 674 wm::WMEvent maximize_event(wm::WM_EVENT_FULLSCREEN);
690 675
691 // To make this test work with or without the new alt+tab selector we make 676 // To make this test work with or without the new alt+tab selector we make
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 // Base case sets the expectation for other cases. 749 // Base case sets the expectation for other cases.
765 if (expected_bounds.IsEmpty()) 750 if (expected_bounds.IsEmpty())
766 expected_bounds = display_relative_bounds; 751 expected_bounds = display_relative_bounds;
767 else 752 else
768 EXPECT_EQ(expected_bounds, display_relative_bounds); 753 EXPECT_EQ(expected_bounds, display_relative_bounds);
769 controller->CompleteCycling(); 754 controller->CompleteCycling();
770 } 755 }
771 } 756 }
772 757
773 } // namespace ash 758 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/wm/window_cycle_list.cc ('k') | ash/wm/window_cycle_event_filter_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698