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

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

Issue 2252673002: Don't handle the tab press event in the window cycle event filter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge and fix test for new alt+tab UI. Created 4 years, 4 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 | « no previous file | ash/wm/window_cycle_event_filter_aura.cc » ('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/aura/wm_window_aura.h" 10 #include "ash/aura/wm_window_aura.h"
11 #include "ash/common/focus_cycler.h" 11 #include "ash/common/focus_cycler.h"
12 #include "ash/common/scoped_root_window_for_new_windows.h" 12 #include "ash/common/scoped_root_window_for_new_windows.h"
13 #include "ash/common/session/session_state_delegate.h" 13 #include "ash/common/session/session_state_delegate.h"
14 #include "ash/common/shell_window_ids.h" 14 #include "ash/common/shell_window_ids.h"
15 #include "ash/common/wm/window_cycle_list.h" 15 #include "ash/common/wm/window_cycle_list.h"
16 #include "ash/common/wm/window_state.h" 16 #include "ash/common/wm/window_state.h"
17 #include "ash/common/wm/wm_event.h"
17 #include "ash/common/wm_shell.h" 18 #include "ash/common/wm_shell.h"
18 #include "ash/shelf/shelf.h" 19 #include "ash/shelf/shelf.h"
19 #include "ash/shelf/shelf_widget.h" 20 #include "ash/shelf/shelf_widget.h"
20 #include "ash/shell.h" 21 #include "ash/shell.h"
21 #include "ash/test/ash_test_base.h" 22 #include "ash/test/ash_test_base.h"
22 #include "ash/test/shelf_test_api.h" 23 #include "ash/test/shelf_test_api.h"
23 #include "ash/test/shelf_view_test_api.h" 24 #include "ash/test/shelf_view_test_api.h"
24 #include "ash/test/test_shelf_delegate.h" 25 #include "ash/test/test_shelf_delegate.h"
25 #include "ash/test/test_shell_delegate.h" 26 #include "ash/test/test_shell_delegate.h"
26 #include "ash/wm/window_state_aura.h" 27 #include "ash/wm/window_state_aura.h"
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 EXPECT_EQ(1u, key_count.GetCountAndReset()); 567 EXPECT_EQ(1u, key_count.GetCountAndReset());
567 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 568 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
568 EXPECT_EQ(0u, key_count.GetCountAndReset()); 569 EXPECT_EQ(0u, key_count.GetCountAndReset());
569 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 570 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
570 EXPECT_EQ(0u, key_count.GetCountAndReset()); 571 EXPECT_EQ(0u, key_count.GetCountAndReset());
571 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE); 572 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE);
572 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive()); 573 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive());
573 EXPECT_EQ(0u, key_count.GetCountAndReset()); 574 EXPECT_EQ(0u, key_count.GetCountAndReset());
574 } 575 }
575 576
577 // Tests that we can cycle past fullscreen windows: https://crbug.com/622396.
578 // Fullscreen windows are special in that they are allowed to handle alt+tab
579 // keypresses, which means the window cycle event filter should not handle
580 // the tab press else it prevents cycling past that window.
581 TEST_F(WindowCycleControllerTest, TabPastFullscreenWindow) {
582 std::unique_ptr<Window> w0(CreateTestWindowInShellWithId(0));
583 std::unique_ptr<Window> w1(CreateTestWindowInShellWithId(1));
584 wm::WMEvent maximize_event(wm::WM_EVENT_FULLSCREEN);
585
586 // To make this test work with or without the new alt+tab selector we make
587 // both the initial window and the second window fullscreen.
588 wm::GetWindowState(w0.get())->OnWMEvent(&maximize_event);
589 wm::GetWindowState(w1.get())->Activate();
590 wm::GetWindowState(w1.get())->OnWMEvent(&maximize_event);
591 EXPECT_TRUE(wm::GetWindowState(w0.get())->IsFullscreen());
592 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsFullscreen());
593 wm::GetWindowState(w0.get())->Activate();
594 EXPECT_TRUE(wm::GetWindowState(w0.get())->IsActive());
595
596 ui::test::EventGenerator& generator = GetEventGenerator();
597 generator.PressKey(ui::VKEY_MENU, ui::EF_NONE);
598
599 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
600 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
601
602 // Because w0 and w1 are full-screen, the event should be passed to the
603 // browser window to handle it (which if the browser doesn't handle it will
604 // pass on the alt+tab to continue cycling). To make this test work with or
605 // without the new alt+tab selector we check for the event on either
606 // fullscreen window.
607 KeyEventCounter key_count;
608 w0->AddPreTargetHandler(&key_count);
609 w1->AddPreTargetHandler(&key_count);
610 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
611 EXPECT_EQ(1u, key_count.GetCountAndReset());
612 }
613
576 } // namespace ash 614 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/window_cycle_event_filter_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698