Commit 7c0e7461 authored by Xiaoqian Dai's avatar Xiaoqian Dai Committed by Commit Bot

[reland] In tablet mode, tap on overview background should go to home screen.

Clamshell mode behavior will remain the same, i.e., tapping on the
overview background will return to its previous state, it can either be
in-app or home screen.

Bug: 997885
Change-Id: I5006c69081157b30f695a05642d20e3d7f505822
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1867375Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#707169}
parent f4c78188
......@@ -4,6 +4,8 @@
#include "ash/wm/overview/overview_grid_event_handler.h"
#include "ash/home_screen/home_screen_controller.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/root_window_controller.h"
#include "ash/shell.h"
#include "ash/wallpaper/wallpaper_view.h"
......@@ -12,8 +14,10 @@
#include "ash/wm/overview/overview_grid.h"
#include "ash/wm/overview/overview_utils.h"
#include "ui/compositor/compositor.h"
#include "ui/display/screen.h"
#include "ui/events/event.h"
#include "ui/events/gestures/fling_curve.h"
#include "ui/views/widget/widget.h"
namespace ash {
......@@ -128,8 +132,21 @@ void OverviewGridEventHandler::HandleClickOrTap(ui::Event* event) {
CHECK_EQ(ui::EP_PRETARGET, event->phase());
// Events that happen while app list is sliding out during overview should
// be ignored to prevent overview from disappearing out from under the user.
if (!IsSlidingOutOverviewFromShelf())
Shell::Get()->overview_controller()->EndOverview();
if (!IsSlidingOutOverviewFromShelf()) {
if (Shell::Get()->tablet_mode_controller()->InTabletMode() &&
features::IsDragFromShelfToHomeOrOverviewEnabled()) {
// In tablet mode, clicking on tapping on the wallpaper background will
// always head back to home launcher screen.
aura::Window* window = static_cast<views::View*>(event->target())
->GetWidget()
->GetNativeWindow();
int64_t display_id =
display::Screen::GetScreen()->GetDisplayNearestWindow(window).id();
Shell::Get()->home_screen_controller()->GoHome(display_id);
} else {
Shell::Get()->overview_controller()->EndOverview();
}
}
event->StopPropagation();
}
......
......@@ -17,11 +17,13 @@
#include "ash/display/screen_orientation_controller.h"
#include "ash/display/screen_orientation_controller_test_api.h"
#include "ash/drag_drop/drag_drop_controller.h"
#include "ash/home_screen/home_screen_controller.h"
#include "ash/magnifier/docked_magnifier_controller_impl.h"
#include "ash/public/cpp/app_types.h"
#include "ash/public/cpp/ash_features.h"
#include "ash/public/cpp/fps_counter.h"
#include "ash/public/cpp/shelf_config.h"
#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/public/cpp/window_properties.h"
#include "ash/screen_util.h"
#include "ash/shelf/shelf.h"
......@@ -2790,6 +2792,50 @@ TEST_P(OverviewSessionTest, ShelfAlignmentChangeWhileInOverview) {
EXPECT_FALSE(InOverviewSession());
}
// The class to test overview behavior with kDragFromShelfToHomeOrOverview flag
// enabled.
class OverviewSessionWithDragFromShelfFeatureTest : public OverviewSessionTest {
public:
OverviewSessionWithDragFromShelfFeatureTest() = default;
~OverviewSessionWithDragFromShelfFeatureTest() override = default;
void SetUp() override {
scoped_feature_list_.InitAndEnableFeature(
features::kDragFromShelfToHomeOrOverview);
OverviewSessionTest::SetUp();
EnterTabletMode();
}
private:
base::test::ScopedFeatureList scoped_feature_list_;
DISALLOW_COPY_AND_ASSIGN(OverviewSessionWithDragFromShelfFeatureTest);
};
// Tests that in tablet mode, tapping on the background will always go to home
// screen.
TEST_P(OverviewSessionWithDragFromShelfFeatureTest, TapOnBackgroundGoToHome) {
UpdateDisplay("800x600");
std::unique_ptr<aura::Window> window(CreateTestWindow());
WindowState* window_state = WindowState::Get(window.get());
EXPECT_FALSE(window_state->IsMinimized());
EXPECT_FALSE(Shell::Get()->home_screen_controller()->IsHomeScreenVisible());
ToggleOverview();
EXPECT_TRUE(InOverviewSession());
// Tap on the background.
ui::ScopedAnimationDurationScaleMode test_duration_mode(
ui::ScopedAnimationDurationScaleMode::NON_ZERO_DURATION);
GetEventGenerator()->GestureTapAt(gfx::Point(10, 10));
ShellTestApi().WaitForOverviewAnimationState(
OverviewAnimationState::kExitAnimationComplete);
EXPECT_FALSE(InOverviewSession());
EXPECT_TRUE(window_state->IsMinimized());
EXPECT_TRUE(Shell::Get()->home_screen_controller()->IsHomeScreenVisible());
}
// TODO(sammiequon): Merge this into SplitViewOverviewSessionTest and rename
// that to TabletModeOverviewSessionTest.
class OverviewSessionNewLayoutTest : public OverviewSessionTest {
......@@ -5251,5 +5297,8 @@ INSTANTIATE_TEST_SUITE_P(
,
SplitViewOverviewSessionInClamshellTestMultiDisplayOnly,
testing::Values(true));
INSTANTIATE_TEST_SUITE_P(,
OverviewSessionWithDragFromShelfFeatureTest,
testing::Bool());
} // namespace ash
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