Skip to content

Commit

Permalink
Don't mark event handled unless it's handled.
Browse files Browse the repository at this point in the history
in OverviewSession::OnKeyEvent

Bug: 925878
Test: covered by unittest
Change-Id: I712acfcc7127e86e30d5d1be3ef8f86831c12368
Reviewed-on: https://chromium-review.googlesource.com/c/1440913
Reviewed-by: Sammie Quon <[email protected]>
Commit-Queue: Mitsuru Oshima <[email protected]>
Cr-Original-Commit-Position: refs/heads/master@{#626807}(cherry picked from commit 8d4ae6d)
Reviewed-on: https://chromium-review.googlesource.com/c/1446404
Reviewed-by: Mitsuru Oshima <[email protected]>
Cr-Commit-Position: refs/branch-heads/3683@{#72}
Cr-Branched-From: e510299-refs/heads/master@{#625896}
  • Loading branch information
mitoshima committed Jan 30, 2019
1 parent 9171772 commit 971df88
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions ash/accelerators/exit_warning_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ASH_EXPORT ExitWarningHandler {

private:
friend class AcceleratorControllerTest;
friend class OverviewSessionTest;

enum State { IDLE, WAIT_FOR_DOUBLE_PRESS, EXITING };

Expand Down
2 changes: 1 addition & 1 deletion ash/wm/overview/overview_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -755,7 +755,7 @@ void OverviewSession::OnKeyEvent(ui::KeyEvent* event) {
SelectWindow(grid_list_[selected_grid_index_]->SelectedWindow());
break;
default:
break;
return;
}

event->SetHandled();
Expand Down
23 changes: 23 additions & 0 deletions ash/wm/overview/overview_session_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <memory>
#include <vector>

#include "ash/accelerators/accelerator_controller.h"
#include "ash/accelerators/exit_warning_handler.h"
#include "ash/accessibility/accessibility_controller.h"
#include "ash/accessibility/test_accessibility_controller_client.h"
#include "ash/app_list/app_list_controller_impl.h"
Expand Down Expand Up @@ -314,6 +316,11 @@ class OverviewSessionTest : public AshTestBase {
return !!item->transform_window_.mask_;
}

static void StubForTest(ExitWarningHandler* ewh) {
ewh->stub_timer_for_test_ = true;
}
static bool is_ui_shown(ExitWarningHandler* ewh) { return !!ewh->widget_; }

private:
std::unique_ptr<ShelfViewTestAPI> shelf_view_test_api_;

Expand Down Expand Up @@ -1197,6 +1204,22 @@ TEST_F(OverviewSessionTest, BasicTabKeyNavigation) {
EXPECT_EQ(GetSelectedWindow(), overview_windows[0]->GetWindow());
}

TEST_F(OverviewSessionTest, AcceleratorInOverviewSession) {
ToggleOverview();
auto* accelerator_controller = Shell::Get()->accelerator_controller();
auto* ewh = accelerator_controller->GetExitWarningHandlerForTest();
ASSERT_TRUE(ewh);
StubForTest(ewh);
EXPECT_FALSE(is_ui_shown(ewh));

ui::test::EventGenerator event_generator(Shell::GetPrimaryRootWindow());
event_generator.PressKey(ui::VKEY_Q, ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN);
event_generator.ReleaseKey(ui::VKEY_Q,
ui::EF_CONTROL_DOWN | ui::EF_SHIFT_DOWN);

EXPECT_TRUE(is_ui_shown(ewh));
}

// Tests that pressing Ctrl+W while a window is selected in overview closes it.
TEST_F(OverviewSessionTest, CloseWindowWithKey) {
std::unique_ptr<views::Widget> widget(CreateTestWidget());
Expand Down

0 comments on commit 971df88

Please sign in to comment.