Commit cc417be0 authored by Min Chen's avatar Min Chen Committed by Commit Bot

Clean up useless arguments in SplitViewControllerTest*.

Bug: None
Change-Id: I9635ede393d0390633b316030b2b0496d361d845
Reviewed-on: https://chromium-review.googlesource.com/c/1474993Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Commit-Queue: Min Chen <minch@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632790}
parent 7eada9b4
...@@ -3649,24 +3649,18 @@ class SplitViewAppDraggingTest : public SplitViewControllerTest { ...@@ -3649,24 +3649,18 @@ class SplitViewAppDraggingTest : public SplitViewControllerTest {
} }
// Sends a gesture scroll sequence to TabletModeAppWindowDragController. // Sends a gesture scroll sequence to TabletModeAppWindowDragController.
void SendGestureEvents(const gfx::Point& start, float scroll_delta) { void SendGestureEvents(const gfx::Point& location) {
base::TimeTicks timestamp = base::TimeTicks::Now(); SendScrollStartAndUpdate(location);
SendScrollStartAndUpdate(start, scroll_delta, timestamp);
EndScrollSequence(); EndScrollSequence();
} }
void SendScrollStartAndUpdate(const gfx::Point& start, void SendScrollStartAndUpdate(const gfx::Point& location) {
float scroll_y,
base::TimeTicks& timestamp,
float scroll_x = 0.f) {
wm::WindowState* window_state = wm::GetWindowState(window()); wm::WindowState* window_state = wm::GetWindowState(window());
window_state->CreateDragDetails(start, HTCAPTION, window_state->CreateDragDetails(location, HTCAPTION,
::wm::WINDOW_MOVE_SOURCE_TOUCH); ::wm::WINDOW_MOVE_SOURCE_TOUCH);
controller_ = std::make_unique<TabletModeWindowDragController>( controller_ = std::make_unique<TabletModeWindowDragController>(
window_state, std::make_unique<TabletModeBrowserWindowDragDelegate>()); window_state, std::make_unique<TabletModeBrowserWindowDragDelegate>());
controller_->Drag(location, 0);
timestamp += base::TimeDelta::FromMilliseconds(100);
controller_->Drag(start + gfx::Vector2d(scroll_x, scroll_y), 0);
} }
void EndScrollSequence() { void EndScrollSequence() {
...@@ -3674,16 +3668,11 @@ class SplitViewAppDraggingTest : public SplitViewControllerTest { ...@@ -3674,16 +3668,11 @@ class SplitViewAppDraggingTest : public SplitViewControllerTest {
wm::GetWindowState(window())->DeleteDragDetails(); wm::GetWindowState(window())->DeleteDragDetails();
} }
void Fling(const gfx::Point& start, void Fling(const gfx::Point& location, float velocity_y, float velocity_x) {
float scroll_delta, ui::GestureEvent event = ui::GestureEvent(
base::TimeTicks& timestamp, location.x(), location.y(), ui::EF_NONE, base::TimeTicks::Now(),
float velocity_y, ui::GestureEventDetails(ui::ET_SCROLL_FLING_START, velocity_x,
float velocity_x) { velocity_y));
timestamp += base::TimeDelta::FromMilliseconds(100);
ui::GestureEvent event =
ui::GestureEvent(start.x(), start.y(), ui::EF_NONE, timestamp,
ui::GestureEventDetails(ui::ET_SCROLL_FLING_START,
velocity_x, velocity_y));
ui::Event::DispatcherApi(&event).set_target(window()); ui::Event::DispatcherApi(&event).set_target(window());
controller_->FlingOrSwipe(&event); controller_->FlingOrSwipe(&event);
wm::GetWindowState(window())->DeleteDragDetails(); wm::GetWindowState(window())->DeleteDragDetails();
...@@ -3716,11 +3705,10 @@ TEST_F(SplitViewAppDraggingTest, DragNonActiveMaximizedWindow) { ...@@ -3716,11 +3705,10 @@ TEST_F(SplitViewAppDraggingTest, DragNonActiveMaximizedWindow) {
window()); window());
const float long_scroll_delta = display_bounds.height() / 4 + 5; const float long_scroll_delta = display_bounds.height() / 4 + 5;
const gfx::Point start; const gfx::Point location(0, long_scroll_delta);
// Drag the window that cannot be snapped long enough, the window will be // Drag the window that cannot be snapped long enough, the window will be
// dropped into overview. // dropped into overview.
base::TimeTicks timestamp = base::TimeTicks::Now(); SendScrollStartAndUpdate(location);
SendScrollStartAndUpdate(start, long_scroll_delta, timestamp);
OverviewController* overview_controller = Shell::Get()->overview_controller(); OverviewController* overview_controller = Shell::Get()->overview_controller();
EXPECT_TRUE(overview_controller->IsSelecting()); EXPECT_TRUE(overview_controller->IsSelecting());
EXPECT_FALSE( EXPECT_FALSE(
...@@ -3744,15 +3732,15 @@ TEST_F(SplitViewAppDraggingTest, DragActiveMaximizedWindow) { ...@@ -3744,15 +3732,15 @@ TEST_F(SplitViewAppDraggingTest, DragActiveMaximizedWindow) {
// Move the window by a small amount of distance will maximize the window // Move the window by a small amount of distance will maximize the window
// again. // again.
const gfx::Point start; gfx::Point location(0, 10);
SendGestureEvents(start, 10); SendGestureEvents(location);
EXPECT_TRUE(wm::GetWindowState(window())->IsMaximized()); EXPECT_TRUE(wm::GetWindowState(window())->IsMaximized());
// Drag the window long enough (pass one fourth of the screen vertical // Drag the window long enough (pass one fourth of the screen vertical
// height) to snap the window to splitscreen. // height) to snap the window to splitscreen.
const float long_scroll_delta = display_bounds.height() / 4 + 5; const float long_scroll_delta = display_bounds.height() / 4 + 5;
base::TimeTicks timestamp = base::TimeTicks::Now(); location.set_y(long_scroll_delta);
SendScrollStartAndUpdate(start, long_scroll_delta, timestamp); SendScrollStartAndUpdate(location);
OverviewController* overview_controller = Shell::Get()->overview_controller(); OverviewController* overview_controller = Shell::Get()->overview_controller();
EXPECT_TRUE(overview_controller->IsSelecting()); EXPECT_TRUE(overview_controller->IsSelecting());
EXPECT_FALSE( EXPECT_FALSE(
...@@ -3767,21 +3755,20 @@ TEST_F(SplitViewAppDraggingTest, DragActiveMaximizedWindow) { ...@@ -3767,21 +3755,20 @@ TEST_F(SplitViewAppDraggingTest, DragActiveMaximizedWindow) {
// FLING the window with small velocity (smaller than // FLING the window with small velocity (smaller than
// kFlingToOverviewThreshold) will not able to drop the window into overview. // kFlingToOverviewThreshold) will not able to drop the window into overview.
timestamp = base::TimeTicks::Now(); location.set_y(10);
SendScrollStartAndUpdate(start, 10, timestamp); SendScrollStartAndUpdate(location);
overview_controller = Shell::Get()->overview_controller(); overview_controller = Shell::Get()->overview_controller();
EXPECT_TRUE(overview_controller->IsSelecting()); EXPECT_TRUE(overview_controller->IsSelecting());
Fling(start, 10, timestamp, Fling(location,
TabletModeWindowDragDelegate::kFlingToOverviewThreshold - 10.f, 0); TabletModeWindowDragDelegate::kFlingToOverviewThreshold - 10.f, 0);
EXPECT_FALSE(overview_controller->IsSelecting()); EXPECT_FALSE(overview_controller->IsSelecting());
// FLING the window with large velocity (larger than // FLING the window with large velocity (larger than
// kFlingToOverviewThreshold) will drop the window into overview. // kFlingToOverviewThreshold) will drop the window into overview.
timestamp = base::TimeTicks::Now(); SendScrollStartAndUpdate(location);
SendScrollStartAndUpdate(start, 10, timestamp);
overview_controller = Shell::Get()->overview_controller(); overview_controller = Shell::Get()->overview_controller();
EXPECT_TRUE(overview_controller->IsSelecting()); EXPECT_TRUE(overview_controller->IsSelecting());
Fling(start, 10, timestamp, Fling(location,
TabletModeWindowDragDelegate::kFlingToOverviewThreshold + 10.f, 0); TabletModeWindowDragDelegate::kFlingToOverviewThreshold + 10.f, 0);
EXPECT_TRUE(overview_controller->IsSelecting()); EXPECT_TRUE(overview_controller->IsSelecting());
} }
...@@ -3808,16 +3795,15 @@ TEST_F(SplitViewAppDraggingTest, ShelfVisibilityIfDraggingFullscreenedWindow) { ...@@ -3808,16 +3795,15 @@ TEST_F(SplitViewAppDraggingTest, ShelfVisibilityIfDraggingFullscreenedWindow) {
// Drag the window by a small amount of distance, the window will back to // Drag the window by a small amount of distance, the window will back to
// fullscreened, and shelf will be hidden again. // fullscreened, and shelf will be hidden again.
const gfx::Point start; gfx::Point location(0, 10);
SendGestureEvents(start, 10); SendGestureEvents(location);
shelf_layout_manager->UpdateVisibilityState(); shelf_layout_manager->UpdateVisibilityState();
EXPECT_TRUE(window_state->IsFullscreen()); EXPECT_TRUE(window_state->IsFullscreen());
EXPECT_FALSE(shelf_layout_manager->IsVisible()); EXPECT_FALSE(shelf_layout_manager->IsVisible());
// Shelf is visible during dragging. // Shelf is visible during dragging.
base::TimeTicks timestamp = base::TimeTicks::Now(); location.set_y(display_bounds.height() / 4 + 5);
const float long_scroll_delta = display_bounds.height() / 4 + 5; SendScrollStartAndUpdate(location);
SendScrollStartAndUpdate(start, long_scroll_delta, timestamp);
EXPECT_TRUE(shelf_layout_manager->IsVisible()); EXPECT_TRUE(shelf_layout_manager->IsVisible());
EndScrollSequence(); EndScrollSequence();
EXPECT_TRUE(split_view_controller()->IsSplitViewModeActive()); EXPECT_TRUE(split_view_controller()->IsSplitViewModeActive());
...@@ -3844,10 +3830,8 @@ TEST_F(SplitViewAppDraggingTest, AutoHideShelf) { ...@@ -3844,10 +3830,8 @@ TEST_F(SplitViewAppDraggingTest, AutoHideShelf) {
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
base::TimeTicks timestamp = base::TimeTicks::Now(); const gfx::Point location(0, display_bounds.height() / 4 + 5);
const gfx::Point start; SendScrollStartAndUpdate(location);
const float long_scroll_delta = display_bounds.height() / 4 + 5;
SendScrollStartAndUpdate(start, long_scroll_delta, timestamp);
EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior()); EXPECT_EQ(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, shelf->auto_hide_behavior());
EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
// Shelf should be shown during drag. // Shelf should be shown during drag.
...@@ -3881,16 +3865,13 @@ TEST_F(SplitViewAppDraggingTest, FlingWhenPreviewAreaIsShown) { ...@@ -3881,16 +3865,13 @@ TEST_F(SplitViewAppDraggingTest, FlingWhenPreviewAreaIsShown) {
float small_velocity = float small_velocity =
TabletModeWindowDragDelegate::kFlingToOverviewFromSnappingAreaThreshold - TabletModeWindowDragDelegate::kFlingToOverviewFromSnappingAreaThreshold -
10.f; 10.f;
gfx::Point start;
base::TimeTicks timestamp = base::TimeTicks::Now();
// Fling to the right with large enough velocity when trying to snap the // Fling to the right with large enough velocity when trying to snap the
// window to the left should drop the window to overview. // window to the left should drop the window to overview.
SendScrollStartAndUpdate(start, long_scroll_delta, timestamp); gfx::Point location(0, long_scroll_delta);
SendScrollStartAndUpdate(location);
EXPECT_EQ(IndicatorState::kPreviewAreaLeft, GetIndicatorState()); EXPECT_EQ(IndicatorState::kPreviewAreaLeft, GetIndicatorState());
Fling(start, long_scroll_delta, timestamp, Fling(location, /*velocity_y*/ 0, /*velocity_x=*/large_velocity);
/*velocity_y*/ 0,
/*velocity_x=*/large_velocity);
OverviewController* overview_controller = Shell::Get()->overview_controller(); OverviewController* overview_controller = Shell::Get()->overview_controller();
OverviewSession* overview_session = overview_controller->overview_session(); OverviewSession* overview_session = overview_controller->overview_session();
EXPECT_TRUE(overview_controller->IsSelecting()); EXPECT_TRUE(overview_controller->IsSelecting());
...@@ -3900,22 +3881,19 @@ TEST_F(SplitViewAppDraggingTest, FlingWhenPreviewAreaIsShown) { ...@@ -3900,22 +3881,19 @@ TEST_F(SplitViewAppDraggingTest, FlingWhenPreviewAreaIsShown) {
// Fling to the right with small velocity when trying to snap the // Fling to the right with small velocity when trying to snap the
// window to the left should still snap the window to left. // window to the left should still snap the window to left.
SendScrollStartAndUpdate(start, long_scroll_delta, timestamp); SendScrollStartAndUpdate(location);
EXPECT_EQ(IndicatorState::kPreviewAreaLeft, GetIndicatorState()); EXPECT_EQ(IndicatorState::kPreviewAreaLeft, GetIndicatorState());
Fling(start, long_scroll_delta, timestamp, Fling(location, /*velocity_y*/ 0, /*velocity_x=*/small_velocity);
/*velocity_y*/ 0,
/*velocity_x=*/small_velocity);
EXPECT_TRUE(wm::GetWindowState(window())->IsSnapped()); EXPECT_TRUE(wm::GetWindowState(window())->IsSnapped());
EndSplitView(); EndSplitView();
EXPECT_TRUE(wm::GetWindowState(window())->IsMaximized()); EXPECT_TRUE(wm::GetWindowState(window())->IsMaximized());
// Fling to the left with large enough velocity when trying to snap the window // Fling to the left with large enough velocity when trying to snap the window
// to the right should drop the window to overvie. // to the right should drop the window to overvie.
start = gfx::Point(display_bounds.right(), 0); location = gfx::Point(display_bounds.right(), long_scroll_delta);
SendScrollStartAndUpdate(start, long_scroll_delta, timestamp); SendScrollStartAndUpdate(location);
EXPECT_EQ(IndicatorState::kPreviewAreaRight, GetIndicatorState()); EXPECT_EQ(IndicatorState::kPreviewAreaRight, GetIndicatorState());
Fling(start, long_scroll_delta, timestamp, /*velocity_y*/ 0, Fling(location, /*velocity_y*/ 0, /*velocity_x=*/-large_velocity);
/*velocity_x=*/-large_velocity);
overview_session = overview_controller->overview_session(); overview_session = overview_controller->overview_session();
EXPECT_TRUE(overview_controller->IsSelecting()); EXPECT_TRUE(overview_controller->IsSelecting());
EXPECT_TRUE(overview_session->IsWindowInOverview(window())); EXPECT_TRUE(overview_session->IsWindowInOverview(window()));
...@@ -3923,11 +3901,9 @@ TEST_F(SplitViewAppDraggingTest, FlingWhenPreviewAreaIsShown) { ...@@ -3923,11 +3901,9 @@ TEST_F(SplitViewAppDraggingTest, FlingWhenPreviewAreaIsShown) {
// Fling to the left with small velocity when trying to snap the // Fling to the left with small velocity when trying to snap the
// window to the right should still snap the window to right. // window to the right should still snap the window to right.
SendScrollStartAndUpdate(start, long_scroll_delta, timestamp); SendScrollStartAndUpdate(location);
EXPECT_EQ(IndicatorState::kPreviewAreaRight, GetIndicatorState()); EXPECT_EQ(IndicatorState::kPreviewAreaRight, GetIndicatorState());
Fling(start, long_scroll_delta, timestamp, Fling(location, /*velocity_y*/ 0, /*velocity_x=*/-small_velocity);
/*velocity_y*/ 0,
/*velocity_x=*/-small_velocity);
EXPECT_TRUE(wm::GetWindowState(window())->IsSnapped()); EXPECT_TRUE(wm::GetWindowState(window())->IsSnapped());
} }
...@@ -3947,26 +3923,20 @@ TEST_F(SplitViewAppDraggingTest, FlingWhenSplitViewIsActive) { ...@@ -3947,26 +3923,20 @@ TEST_F(SplitViewAppDraggingTest, FlingWhenSplitViewIsActive) {
float large_velocity = float large_velocity =
TabletModeWindowDragDelegate::kFlingToOverviewFromSnappingAreaThreshold + TabletModeWindowDragDelegate::kFlingToOverviewFromSnappingAreaThreshold +
10.f; 10.f;
const gfx::Point start;
// Fling the window in left snapping area to left should still snap the // Fling the window in left snapping area to left should still snap the
// window. // window.
base::TimeTicks timestamp = base::TimeTicks::Now(); gfx::Point location(0, long_scroll_y);
SendScrollStartAndUpdate(start, long_scroll_y, timestamp); SendScrollStartAndUpdate(location);
Fling(start, long_scroll_y, timestamp, Fling(location, /*velocity_y=*/0, /*velocity_x=*/-large_velocity);
/*velocity_y=*/0,
/*velocity_x=*/-large_velocity);
EXPECT_TRUE(wm::GetWindowState(window())->IsSnapped()); EXPECT_TRUE(wm::GetWindowState(window())->IsSnapped());
EXPECT_EQ(SplitViewController::BOTH_SNAPPED, EXPECT_EQ(SplitViewController::BOTH_SNAPPED,
split_view_controller()->state()); split_view_controller()->state());
// Fling the window in left snapping area to right should drop the window // Fling the window in left snapping area to right should drop the window
// into overview. // into overview.
timestamp += base::TimeDelta::FromMilliseconds(1000); SendScrollStartAndUpdate(location);
SendScrollStartAndUpdate(start, long_scroll_y, timestamp); Fling(location, /*velocity_y=*/0, /*velocity_x=*/large_velocity);
Fling(start, long_scroll_y, timestamp,
/*velocity_y=*/0,
/*velocity_x=*/large_velocity);
OverviewController* selector_controller = Shell::Get()->overview_controller(); OverviewController* selector_controller = Shell::Get()->overview_controller();
EXPECT_TRUE( EXPECT_TRUE(
selector_controller->overview_session()->IsWindowInOverview(window())); selector_controller->overview_session()->IsWindowInOverview(window()));
...@@ -3980,12 +3950,9 @@ TEST_F(SplitViewAppDraggingTest, FlingWhenSplitViewIsActive) { ...@@ -3980,12 +3950,9 @@ TEST_F(SplitViewAppDraggingTest, FlingWhenSplitViewIsActive) {
// overview. // overview.
EXPECT_EQ(SplitViewController::BOTH_SNAPPED, EXPECT_EQ(SplitViewController::BOTH_SNAPPED,
split_view_controller()->state()); split_view_controller()->state());
const int scroll_x = display_bounds.CenterPoint().x() + 10; location.set_x(display_bounds.CenterPoint().x() + 10);
SendScrollStartAndUpdate(start, long_scroll_y, timestamp, scroll_x); SendScrollStartAndUpdate(location);
gfx::Point end(scroll_x, 0); Fling(location, /*velocity_y=*/0, /*velocity_x=*/-large_velocity);
Fling(end, long_scroll_y, timestamp,
/*velocity_y=*/0,
/*velocity_x=*/-large_velocity);
EXPECT_TRUE( EXPECT_TRUE(
selector_controller->overview_session()->IsWindowInOverview(window())); selector_controller->overview_session()->IsWindowInOverview(window()));
EXPECT_EQ(SplitViewController::RIGHT_SNAPPED, EXPECT_EQ(SplitViewController::RIGHT_SNAPPED,
...@@ -3994,12 +3961,10 @@ TEST_F(SplitViewAppDraggingTest, FlingWhenSplitViewIsActive) { ...@@ -3994,12 +3961,10 @@ TEST_F(SplitViewAppDraggingTest, FlingWhenSplitViewIsActive) {
// Fling the window in right snapping area to right should snap the window to // Fling the window in right snapping area to right should snap the window to
// right side. // right side.
// EXPECT_EQ(SplitViewController::BOTH_SNAPPED, EXPECT_EQ(SplitViewController::BOTH_SNAPPED,
// split_view_controller()->state()); split_view_controller()->state());
SendScrollStartAndUpdate(start, long_scroll_y, timestamp, scroll_x); SendScrollStartAndUpdate(location);
Fling(end, long_scroll_y, timestamp, Fling(location, /*velocity_y=*/0, /*velocity_x=*/large_velocity);
/*velocity_y=*/0,
/*velocity_x=*/large_velocity);
EXPECT_EQ(split_view_controller()->right_window(), window()); EXPECT_EQ(split_view_controller()->right_window(), window());
EXPECT_TRUE(selector_controller->overview_session()->IsWindowInOverview( EXPECT_TRUE(selector_controller->overview_session()->IsWindowInOverview(
window2.get())); window2.get()));
......
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