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

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: 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
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 581 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 EXPECT_EQ(1u, key_count.GetCountAndReset()); 609 EXPECT_EQ(1u, key_count.GetCountAndReset());
609 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 610 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
610 EXPECT_EQ(0u, key_count.GetCountAndReset()); 611 EXPECT_EQ(0u, key_count.GetCountAndReset());
611 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); 612 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
612 EXPECT_EQ(0u, key_count.GetCountAndReset()); 613 EXPECT_EQ(0u, key_count.GetCountAndReset());
613 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE); 614 generator.ReleaseKey(ui::VKEY_MENU, ui::EF_NONE);
614 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive()); 615 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive());
615 EXPECT_EQ(0u, key_count.GetCountAndReset()); 616 EXPECT_EQ(0u, key_count.GetCountAndReset());
616 } 617 }
617 618
619 // Tests that we can cycle past fullscreen windows: https://crbug.com/622396.
620 // Fullscreen windows are special in that they are allowed to handle alt+tab
621 // keypresses, which means the window cycle event filter should not handle
622 // the tab press else it prevents cycling past that window.
623 TEST_F(WindowCycleControllerTest, TabPastFullscreenWindow) {
624 std::unique_ptr<Window> w0(CreateTestWindowInShellWithId(0));
625 std::unique_ptr<Window> w1(CreateTestWindowInShellWithId(1));
626 wm::WMEvent maximize_event(wm::WM_EVENT_FULLSCREEN);
627 wm::GetWindowState(w1.get())->Activate();
628 wm::GetWindowState(w1.get())->OnWMEvent(&maximize_event);
629 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsFullscreen());
630 wm::GetWindowState(w0.get())->Activate();
631
632 ui::test::EventGenerator& generator = GetEventGenerator();
varkha 2016/08/17 18:06:57 nit: Could swap the line before and above this com
flackr 2016/08/17 19:07:19 Done.
633 EXPECT_TRUE(wm::GetWindowState(w0.get())->IsActive());
634 generator.PressKey(ui::VKEY_MENU, ui::EF_NONE);
635
636 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
637 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
638 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsActive());
639
640 // Because w1 is full-screen, the event should be passed to the browser
641 // window to handle it (which if the browser doesn't handle it will pass on
642 // the alt+tab to continue cycling).
643 KeyEventCounter key_count;
644 w1->AddPreTargetHandler(&key_count);
645 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN);
646 EXPECT_EQ(1u, key_count.GetCountAndReset());
647 }
648
618 } // namespace ash 649 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | ash/wm/window_cycle_event_filter_aura.cc » ('j') | ash/wm/window_cycle_event_filter_aura.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698