Commit 19bfaa21 authored by Sammie Quon's avatar Sammie Quon Committed by Commit Bot

overview: Enable new grid layout by default.

This cl enables it in a way so that it will be easy to revert this if
needed. A follow up will clean up the file a bit once this has been
enabled for a while.

Test: ash_unittests
Bug: 978112
Change-Id: Ie648f965106e6c021c77f039af0112364006e75a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1833046
Commit-Queue: Sammie Quon <sammiequon@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702609}
parent 6f316ae4
......@@ -45,7 +45,7 @@ const base::Feature kMultiDisplayOverviewAndSplitView{
"MultiDisplayOverviewAndSplitView", base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kNewOverviewLayout{"NewOverviewLayout",
base::FEATURE_DISABLED_BY_DEFAULT};
base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kNightLight{"NightLight", base::FEATURE_ENABLED_BY_DEFAULT};
......
......@@ -2784,6 +2784,8 @@ TEST_P(OverviewSessionTest, ShelfAlignmentChangeWhileInOverview) {
EXPECT_FALSE(InOverviewSession());
}
// TODO(sammiequon): Merge this into SplitViewOverviewSessionTest and rename
// that to TabletModeOverviewSessionTest.
class OverviewSessionNewLayoutTest : public OverviewSessionTest {
public:
OverviewSessionNewLayoutTest() = default;
......@@ -2992,7 +2994,7 @@ TEST_P(OverviewSessionNewLayoutTest, HorizontalScrollingOnOverviewItem) {
}
// A unique test class for testing flings in overview as those rely on observing
// compositior animations which require a mock time task environment.
// compositor animations which require a mock time task environment.
class OverviewSessionNewLayoutFlingTest : public AshTestBase {
public:
OverviewSessionNewLayoutFlingTest()
......@@ -3359,6 +3361,11 @@ TEST_P(SplitViewOverviewSessionTest, DragOverviewWindowToSnap) {
// Verify the correct behavior when dragging windows in overview mode.
TEST_P(SplitViewOverviewSessionTest, OverviewDragControllerBehavior) {
// TODO(sammiequon): Make this work once this feature is enabled by default
// for good.
if (base::FeatureList::IsEnabled(features::kNewOverviewLayout))
return;
aura::Env::GetInstance()->set_throttle_input_on_resize_for_testing(false);
std::unique_ptr<aura::Window> window1 = CreateTestWindow();
......
......@@ -75,11 +75,10 @@ IN_PROC_BROWSER_TEST_P(LauncherDragTest, Open) {
display_bounds.bottom() - ash::ShelfConfig::Get()->shelf_size() / 2);
gfx::Point end_point(start_point);
end_point.set_y(10);
ui_test_utils::DragEventGenerator generator(
auto generator = ui_test_utils::DragEventGenerator::CreateForTouch(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_point, end_point, base::TimeDelta::FromMilliseconds(1000)),
/*touch=*/true);
generator.Wait();
start_point, end_point, base::TimeDelta::FromMilliseconds(1000)));
generator->Wait();
shell_test_api.WaitForLauncherAnimationState(
ash::AppListViewState::kFullscreenAllApps);
......@@ -102,11 +101,10 @@ IN_PROC_BROWSER_TEST_P(LauncherDragTest, Close) {
gfx::Point end_point(start_point);
end_point.set_y(display_bounds.bottom() -
ash::ShelfConfig::Get()->shelf_size() / 2);
ui_test_utils::DragEventGenerator generator(
auto generator = ui_test_utils::DragEventGenerator::CreateForTouch(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_point, end_point, base::TimeDelta::FromMilliseconds(1000)),
/*touch=*/true);
generator.Wait();
start_point, end_point, base::TimeDelta::FromMilliseconds(1000)));
generator->Wait();
shell_test_api.WaitForLauncherAnimationState(ash::AppListViewState::kClosed);
}
......
......@@ -179,14 +179,13 @@ IN_PROC_BROWSER_TEST_F(LauncherPageDragTest, Run) {
gfx::Point start_point = display_bounds.CenterPoint();
gfx::Point end_point(start_point);
end_point.set_y(10);
ui_test_utils::DragEventGenerator generator(
auto generator = ui_test_utils::DragEventGenerator::CreateForTouch(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_point, end_point, base::TimeDelta::FromMilliseconds(1000)),
/*touch=*/true);
start_point, end_point, base::TimeDelta::FromMilliseconds(1000)));
ash::PaginationModel* model = ash::ShellTestApi().GetAppListPaginationModel();
ASSERT_TRUE(model);
PageSwitchWaiter waiter(model);
generator.Wait();
generator->Wait();
waiter.Wait();
}
......@@ -82,9 +82,8 @@ IN_PROC_BROWSER_TEST_F(OverviewScrollTest, Basic) {
const gfx::Point start_point =
display_bounds.top_right() + gfx::Vector2d(-1, 1);
const gfx::Point end_point = display_bounds.origin() + gfx::Vector2d(1, 1);
ui_test_utils::DragEventGenerator generator(
auto generator = ui_test_utils::DragEventGenerator::CreateForTouch(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_point, end_point, base::TimeDelta::FromMilliseconds(1000)),
/*touch=*/true);
generator.Wait();
start_point, end_point, base::TimeDelta::FromMilliseconds(1000)));
generator->Wait();
}
......@@ -136,11 +136,11 @@ IN_PROC_BROWSER_TEST_P(OverviewWindowDragTest, NormalDrag) {
gfx::Point start_point = GetStartLocation(display_size);
gfx::Point end_point(start_point);
end_point.set_x(end_point.x() + display_size.width() / 2);
ui_test_utils::DragEventGenerator generator(
auto generator = ui_test_utils::DragEventGenerator::CreateForTouch(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_point, end_point, base::TimeDelta::FromMilliseconds(1000)),
/*touch=*/true);
generator.Wait();
/*long_press=*/true);
generator->Wait();
}
// The test is flaky because close notification is not the right singal.
......@@ -160,12 +160,11 @@ IN_PROC_BROWSER_TEST_P(OverviewWindowDragTest, DISABLED_DragToClose) {
gfx::Point end_point(start_point);
end_point.set_y(0);
end_point.set_x(end_point.x() + 10);
ui_test_utils::DragEventGenerator generator(
auto generator = ui_test_utils::DragEventGenerator::CreateForTouch(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_point, end_point, base::TimeDelta::FromMilliseconds(500),
gfx::Tween::EASE_IN_2),
/*touch=*/true);
generator.Wait();
gfx::Tween::EASE_IN_2));
generator->Wait();
ui_test_utils::WaitForBrowserToClose(chrome::FindLastActive());
}
......@@ -184,11 +183,11 @@ IN_PROC_BROWSER_TEST_P(OverviewWindowDragTest, DragToSnap) {
gfx::Point start_point = GetStartLocation(GetDisplaySize(browser_window));
gfx::Point end_point(start_point);
end_point.set_x(0);
ui_test_utils::DragEventGenerator generator(
auto generator = ui_test_utils::DragEventGenerator::CreateForTouch(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_point, end_point, base::TimeDelta::FromMilliseconds(1000)),
/*touch=*/true);
generator.Wait();
/*long_press=*/true);
generator->Wait();
Browser* active = chrome::FindLastActive();
// Wait for the window to be snapped.
......
......@@ -118,12 +118,16 @@ IN_PROC_BROWSER_TEST_P(SplitViewTest, ResizeTwoWindows) {
TRACE_EVENT_ASYNC_BEGIN0("ui", "Interaction.ui_WindowResize", this);
gfx::Point end_position(start_position);
end_position.set_x(end_position.x() - 60);
ui_test_utils::DragEventGenerator generator(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_position, end_position,
base::TimeDelta::FromMilliseconds(1000)),
use_touch());
generator.Wait();
auto generator =
use_touch() ? ui_test_utils::DragEventGenerator::CreateForTouch(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_position, end_position,
base::TimeDelta::FromMilliseconds(1000)))
: ui_test_utils::DragEventGenerator::CreateForMouse(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_position, end_position,
base::TimeDelta::FromMilliseconds(1000)));
generator->Wait();
TRACE_EVENT_ASYNC_END0("ui", "Interaction.ui_WindowResize", this);
ash::ShellTestApi().SetTabletModeEnabledForTest(false);
......@@ -150,12 +154,16 @@ IN_PROC_BROWSER_TEST_P(SplitViewTest, ResizeWithOverview) {
TRACE_EVENT_ASYNC_BEGIN0("ui", "Interaction.ui_WindowResize", this);
gfx::Point end_position(start_position);
end_position.set_x(end_position.x() - 60);
ui_test_utils::DragEventGenerator generator(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_position, end_position,
base::TimeDelta::FromMilliseconds(1000)),
use_touch());
generator.Wait();
auto generator =
use_touch() ? ui_test_utils::DragEventGenerator::CreateForTouch(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_position, end_position,
base::TimeDelta::FromMilliseconds(1000)))
: ui_test_utils::DragEventGenerator::CreateForMouse(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_position, end_position,
base::TimeDelta::FromMilliseconds(1000)));
generator->Wait();
TRACE_EVENT_ASYNC_END0("ui", "Interaction.ui_WindowResize", this);
ash::ShellTestApi().SetTabletModeEnabledForTest(false);
......
......@@ -174,9 +174,9 @@ IN_PROC_BROWSER_TEST_P(WindowResizeTest, Single) {
producer->ProducePointsTo(mid_point, base::TimeDelta::FromSeconds(1));
producer->ProducePointsTo(end_point, base::TimeDelta::FromSeconds(1));
ui_test_utils::DragEventGenerator generator(std::move(producer),
/*use_touch=*/false);
generator.Wait();
auto generator =
ui_test_utils::DragEventGenerator::CreateForMouse(std::move(producer));
generator->Wait();
}
IN_PROC_BROWSER_TEST_P(WindowResizeTest, Multi) {
......@@ -209,9 +209,9 @@ IN_PROC_BROWSER_TEST_P(WindowResizeTest, Multi) {
producer->ProducePointsTo(start_point, base::TimeDelta::FromSeconds(1));
start_point.Offset(120, 0);
producer->ProducePointsTo(start_point, base::TimeDelta::FromSeconds(1));
ui_test_utils::DragEventGenerator generator(std::move(producer),
/*use_touch=*/false);
generator.Wait();
auto generator =
ui_test_utils::DragEventGenerator::CreateForMouse(std::move(producer));
generator->Wait();
}
INSTANTIATE_TEST_SUITE_P(,
......
......@@ -105,12 +105,12 @@ IN_PROC_BROWSER_TEST_F(TabHoverTest, HoverOverMultipleTabs) {
// Slowly mouse from the start to end positions across the tab strip. Tick
// this mousemove at a high frequency (120fps) to avoid having the timer fire
// at the wrong time due to having frames without any input event.
ui_test_utils::DragEventGenerator generator(
auto generator = ui_test_utils::DragEventGenerator::CreateForMouse(
std::make_unique<ui_test_utils::InterpolatedProducer>(
start_position, end_position,
base::TimeDelta::FromMilliseconds(5000)),
/*touch=*/false, /*hover=*/true, /*high frequency=*/true);
generator.Wait();
/*hover=*/true, /*use_120fpx=*/true);
generator->Wait();
#if defined(USE_AURA)
const gfx::Point& last_mouse_loc =
......
......@@ -11,16 +11,46 @@
#include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "ui/base/test/ui_controls.h"
#include "ui/events/gesture_detection/gesture_configuration.h"
namespace ui_test_utils {
////////////////////////////////////////////////////////////////////////////////
// DragEventGenerator
DragEventGenerator::~DragEventGenerator() {
VLOG(1) << "Effective Event per seconds="
<< (count_ * 1000) / producer_->GetDuration().InMilliseconds();
}
// static
std::unique_ptr<DragEventGenerator> DragEventGenerator::CreateForMouse(
std::unique_ptr<PointProducer> producer,
bool hover,
bool use_120fps) {
return base::WrapUnique(new DragEventGenerator(
std::move(producer), /*touch=*/false, hover, use_120fps));
}
// static
std::unique_ptr<DragEventGenerator> DragEventGenerator::CreateForTouch(
std::unique_ptr<PointProducer> producer,
bool long_press,
bool use_120fps) {
return base::WrapUnique(new DragEventGenerator(
std::move(producer),
/*touch=*/true, /*hover=*/false, use_120fps, long_press));
}
void DragEventGenerator::Wait() {
run_loop_.Run();
}
DragEventGenerator::DragEventGenerator(std::unique_ptr<PointProducer> producer,
bool touch,
bool hover,
bool use_120fps)
bool use_120fps,
bool long_press)
: producer_(std::move(producer)),
use_120fps_(use_120fps),
start_(base::TimeTicks::Now()),
......@@ -39,19 +69,29 @@ DragEventGenerator::DragEventGenerator(std::unique_ptr<PointProducer> producer,
if (!hover_)
ui_controls::SendMouseEvents(ui_controls::LEFT, ui_controls::DOWN);
}
base::TimeDelta delay = GetNextFrameDuration();
if (long_press) {
DCHECK(touch_);
ui::GestureConfiguration::GetInstance()->set_show_press_delay_in_ms(1);
ui::GestureConfiguration::GetInstance()->set_long_press_time_in_ms(2);
delay = base::TimeDelta::FromMilliseconds(5);
}
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::BindOnce(&DragEventGenerator::GenerateNext, base::Unretained(this)),
GetNextFrameDuration());
}
DragEventGenerator::~DragEventGenerator() {
VLOG(1) << "Effective Event per seconds="
<< (count_ * 1000) / producer_->GetDuration().InMilliseconds();
delay);
}
void DragEventGenerator::Wait() {
run_loop_.Run();
void DragEventGenerator::Done(const gfx::Point position) {
if (touch_) {
ui_controls::SendTouchEventsNotifyWhenDone(ui_controls::RELEASE, 0,
position.x(), position.y(),
run_loop_.QuitClosure());
} else {
ui_controls::SendMouseEventsNotifyWhenDone(
ui_controls::LEFT, ui_controls::UP, run_loop_.QuitClosure());
}
}
void DragEventGenerator::GenerateNext() {
......@@ -101,17 +141,6 @@ void DragEventGenerator::GenerateNext() {
}
}
void DragEventGenerator::Done(const gfx::Point position) {
if (touch_) {
ui_controls::SendTouchEventsNotifyWhenDone(ui_controls::RELEASE, 0,
position.x(), position.y(),
run_loop_.QuitClosure());
} else {
ui_controls::SendMouseEventsNotifyWhenDone(
ui_controls::LEFT, ui_controls::UP, run_loop_.QuitClosure());
}
}
base::TimeDelta DragEventGenerator::GetNextFrameDuration() const {
return base::TimeDelta::FromMicroseconds(use_120fps_ ? 8333 : 16666);
}
......
......@@ -29,15 +29,30 @@ class DragEventGenerator {
virtual const base::TimeDelta GetDuration() const = 0;
};
DragEventGenerator(std::unique_ptr<PointProducer> producer,
bool touch = false,
bool hover = false,
bool use_120fps = false);
~DragEventGenerator();
// If |hover| is true, do not send a initial mouse press event. Generates
// events at 120 hertz if |use_120fps|.
static std::unique_ptr<DragEventGenerator> CreateForMouse(
std::unique_ptr<PointProducer> producer,
bool hover = false,
bool use_120fps = false);
// If |long_press| is true wait a bit until a long press event is sent before
// starting dragging.
static std::unique_ptr<DragEventGenerator> CreateForTouch(
std::unique_ptr<PointProducer> producer,
bool long_press = false,
bool use_120fps = false);
void Wait();
private:
DragEventGenerator(std::unique_ptr<PointProducer> producer,
bool touch = false,
bool hover = false,
bool use_120fps = false,
bool long_press = false);
void Done(const gfx::Point position);
void GenerateNext();
base::TimeDelta GetNextFrameDuration() const;
......
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