Commit 802ccbc0 authored by minch's avatar minch Committed by Commit Bot

back_gesture: Cancel going back during screen rotation.

Bug: 1002733
Change-Id: I78e0e3218c56764ea8f751defc94f0b7e819efdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1880169Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709558}
parent 8f0c8d83
...@@ -280,6 +280,12 @@ ToplevelWindowEventHandler::~ToplevelWindowEventHandler() { ...@@ -280,6 +280,12 @@ ToplevelWindowEventHandler::~ToplevelWindowEventHandler() {
void ToplevelWindowEventHandler::OnDisplayMetricsChanged( void ToplevelWindowEventHandler::OnDisplayMetricsChanged(
const display::Display& display, const display::Display& display,
uint32_t metrics) { uint32_t metrics) {
// Cancel the left edge swipe back during screen rotation.
if (metrics & DISPLAY_METRIC_ROTATION) {
back_gesture_affordance_.reset();
going_back_started_ = false;
}
if (!window_resizer_ || !(metrics & DISPLAY_METRIC_ROTATION)) if (!window_resizer_ || !(metrics & DISPLAY_METRIC_ROTATION))
return; return;
......
...@@ -1197,6 +1197,43 @@ TEST_F(ToplevelWindowEventHandlerBackGestureTest, DonotStartGoingBack) { ...@@ -1197,6 +1197,43 @@ TEST_F(ToplevelWindowEventHandlerBackGestureTest, DonotStartGoingBack) {
GetAppListTestHelper()->CheckState(AppListViewState::kFullscreenAllApps); GetAppListTestHelper()->CheckState(AppListViewState::kFullscreenAllApps);
} }
TEST_F(ToplevelWindowEventHandlerBackGestureTest, CancelOnScreenRotation) {
UpdateDisplay("807x407");
int64_t display_id = display::Screen::GetScreen()->GetPrimaryDisplay().id();
display::DisplayManager* display_manager = Shell::Get()->display_manager();
display::test::ScopedSetInternalDisplayId set_internal(display_manager,
display_id);
ScreenOrientationControllerTestApi test_api(
Shell::Get()->screen_orientation_controller());
ui::TestAcceleratorTarget target_back_press, target_back_release;
RegisterBackPressAndRelease(&target_back_press, &target_back_release);
// Set the screen orientation to LANDSCAPE_PRIMARY.
test_api.SetDisplayRotation(display::Display::ROTATE_0,
display::Display::RotationSource::ACTIVE);
EXPECT_EQ(test_api.GetCurrentOrientation(),
OrientationLockType::kLandscapePrimary);
gfx::Point start(0, 100);
gfx::Point update_and_end(200, 100);
SendGestureEvent(start, 0, 0, ui::ET_GESTURE_SCROLL_BEGIN);
SendGestureEvent(update_and_end, update_and_end.x() - start.x(), 0,
ui::ET_GESTURE_SCROLL_UPDATE);
// Rotate the screen by 270 degree during drag.
test_api.SetDisplayRotation(display::Display::ROTATE_270,
display::Display::RotationSource::ACTIVE);
EXPECT_EQ(test_api.GetCurrentOrientation(),
OrientationLockType::kPortraitPrimary);
SendGestureEvent(update_and_end,
ToplevelWindowEventHandler::kFlingVelocityForGoingBack + 10,
0, ui::ET_SCROLL_FLING_START);
// Left edge swipe back should be cancelled due to screen rotation, so the
// fling event with velocity larger than |kFlingVelocityForGoingBack| above
// will not trigger actual going back.
EXPECT_EQ(0, target_back_press.accelerator_count());
EXPECT_EQ(0, target_back_release.accelerator_count());
}
namespace { namespace {
void SendMouseReleaseAndReleaseCapture(ui::test::EventGenerator* generator, void SendMouseReleaseAndReleaseCapture(ui::test::EventGenerator* generator,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment