Commit 1ecf1ae6 authored by Sammie Quon's avatar Sammie Quon Committed by Chromium LUCI CQ

desks: Fix DCHECK with hitting accelerators while ongoing animation.

Was also causing some UI issues (but not crashing) on devices.

Bug: 1159068
Test: manual, ash_unittests DeskAcceleratorsTest.HitAcceleratorWhenAlreadyAtEdge
Change-Id: I728dd7d5fab32ef7aca8e729d1611474f6f9d875
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2596058Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837963}
parent 1864c9a8
......@@ -292,14 +292,14 @@ bool DesksController::CanCreateDesks() const {
}
Desk* DesksController::GetNextDesk() const {
int next_index = GetDeskIndex(active_desk_);
int next_index = GetDeskIndex(GetTargetActiveDesk());
if (++next_index >= static_cast<int>(desks_.size()))
return nullptr;
return desks_[next_index].get();
}
Desk* DesksController::GetPreviousDesk() const {
int previous_index = GetDeskIndex(active_desk_);
int previous_index = GetDeskIndex(GetTargetActiveDesk());
if (--previous_index < 0)
return nullptr;
return desks_[previous_index].get();
......
......@@ -29,6 +29,7 @@
#include "ash/window_factory.h"
#include "ash/wm/desks/close_desk_button.h"
#include "ash/wm/desks/desk.h"
#include "ash/wm/desks/desk_animation_base.h"
#include "ash/wm/desks/desk_mini_view.h"
#include "ash/wm/desks/desk_name_view.h"
#include "ash/wm/desks/desk_preview_view.h"
......@@ -37,6 +38,7 @@
#include "ash/wm/desks/desks_test_util.h"
#include "ash/wm/desks/desks_util.h"
#include "ash/wm/desks/new_desk_button.h"
#include "ash/wm/desks/root_window_desk_switch_animator_test_api.h"
#include "ash/wm/mru_window_tracker.h"
#include "ash/wm/overview/overview_controller.h"
#include "ash/wm/overview/overview_grid.h"
......@@ -3517,6 +3519,38 @@ TEST_F(DesksAcceleratorsTest, CannotMoveAlwaysOnTopWindows) {
EXPECT_TRUE(win0->IsVisible());
}
// Tests that hitting an acclerator to switch desks does not cause a crash if we
// are already at an edge desk. Regression test for https://crbug.com/1159068.
TEST_F(DesksAcceleratorsTest, HitAcceleratorWhenAlreadyAtEdge) {
base::test::ScopedFeatureList scoped_feature_list;
scoped_feature_list.InitAndEnableFeature(features::kEnhancedDeskAnimations);
NewDesk();
// Enable animations so that we can make sure that they occur.
ui::ScopedAnimationDurationScaleMode regular_animations(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
// First go right. Wait until the ending screenshot is taken.
const int flags = ui::EF_COMMAND_DOWN;
SendAccelerator(ui::VKEY_OEM_6, flags);
DeskAnimationBase* animation = DesksController::Get()->animation();
ASSERT_TRUE(animation);
base::RunLoop run_loop;
auto* desk_switch_animator =
animation->GetDeskSwitchAnimatorAtIndexForTesting(0);
ASSERT_TRUE(desk_switch_animator);
RootWindowDeskSwitchAnimatorTestApi(desk_switch_animator)
.SetOnEndingScreenshotTakenCallback(run_loop.QuitClosure());
run_loop.Run();
// Tap the accelerator to go left to desk 1, then tap again. There should be
// no crash.
SendAccelerator(ui::VKEY_OEM_4, flags);
SendAccelerator(ui::VKEY_OEM_4, flags);
}
class PerDeskShelfTest : public AshTestBase,
public ::testing::WithParamInterface<bool> {
public:
......
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