Commit e06f2cd1 authored by Mitsuru Oshima's avatar Mitsuru Oshima Committed by Commit Bot

Add more coverage for launcher on external screen scenario

* Fix EventGenerator so that GestureTapDownAndUp and Scroll methods works
on external display.
* Changed the test harness to use the EventGenerator which is
much closer to how home button works.
* Updated AppListTest to use MoveMouseTo and the global event generator.

Bug: 1042754
Change-Id: I33e9696960cd990512847a54a7e487098d73d9dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2008130Reviewed-by: default avatarSadrul Chowdhury <sadrul@chromium.org>
Reviewed-by: default avatarAlex Newcomer <newcomer@chromium.org>
Commit-Queue: Mitsuru Oshima <oshima@chromium.org>
Cr-Commit-Position: refs/heads/master@{#738601}
parent f66f28d2
......@@ -38,8 +38,10 @@
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/test/shell_test_api.h"
#include "ash/root_window_controller.h"
#include "ash/shelf/home_button.h"
#include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_layout_manager.h"
#include "ash/shelf/shelf_navigation_widget.h"
#include "ash/shelf/shelf_view.h"
#include "ash/shell.h"
#include "ash/system/unified/unified_system_tray.h"
......@@ -1436,6 +1438,46 @@ TEST_P(AppListPresenterDelegateTest,
GetAppListTestHelper()->CheckVisibility(false);
}
// Tests that a drag to the bezel from Fullscreen/Peeking will close the app
// list even on external display with non zero y origin.
TEST_P(AppListPresenterDelegateTest,
DragToBezelClosesAppListFromFullscreenAndPeekingOnExternal) {
UpdateDisplay("800x600,1000x768");
const bool test_fullscreen = GetParam();
GetAppListTestHelper()->ShowAndRunLoop(GetSecondaryDisplay().id());
AppListView* view = GetAppListView();
{
SCOPED_TRACE("Peeking");
GetAppListTestHelper()->CheckState(AppListViewState::kPeeking);
}
EXPECT_EQ(Shell::GetAllRootWindows()[1],
view->GetWidget()->GetNativeWindow()->GetRootWindow());
if (test_fullscreen) {
FlingUpOrDown(GetEventGenerator(), view, true /* up */);
GetAppListTestHelper()->WaitUntilIdle();
SCOPED_TRACE("FullscreenAllApps");
GetAppListTestHelper()->CheckState(AppListViewState::kFullscreenAllApps);
}
// Drag the app list to 50 DIPs from the bottom bezel.
display::Display display =
display::Screen::GetScreen()->GetDisplayNearestView(
view->GetWidget()->GetNativeWindow());
const int bezel_y = display.bounds().bottom();
const int drag_x = display.bounds().x() + 10;
GetEventGenerator()->GestureScrollSequence(
gfx::Point(drag_x, bezel_y - (kAppListBezelMargin + 100)),
gfx::Point(drag_x, bezel_y - (kAppListBezelMargin)),
base::TimeDelta::FromMilliseconds(1500), 100);
GetAppListTestHelper()->WaitUntilIdle();
SCOPED_TRACE("Closed");
GetAppListTestHelper()->CheckState(AppListViewState::kClosed);
GetAppListTestHelper()->CheckVisibility(false);
}
// Tests that a fling from Fullscreen/Peeking closes the app list.
TEST_P(AppListPresenterDelegateTest,
FlingDownClosesAppListFromFullscreenAndPeeking) {
......@@ -2528,9 +2570,23 @@ class AppListPresenterDelegateHomeLauncherTest
}
void PressHomeButton() {
Shell::Get()->app_list_controller()->ToggleAppList(
GetPrimaryDisplayId(), AppListShowSource::kShelfButton,
base::TimeTicks());
HomeButton* const home_button =
GetPrimaryShelf()->navigation_widget()->GetHomeButton();
auto* gen = GetEventGenerator();
gfx::Point click_point = home_button->GetBoundsInScreen().CenterPoint();
gen->MoveMouseTo(click_point);
gen->ClickLeftButton();
GetAppListTestHelper()->WaitUntilIdle();
}
void TapHomeButton(int64_t display_id) {
HomeButton* const home_button =
Shell::GetRootWindowControllerWithDisplayId(display_id)
->shelf()
->navigation_widget()
->GetHomeButton();
gfx::Point tap_point = home_button->GetBoundsInScreen().CenterPoint();
GetEventGenerator()->GestureTapDownAndUp(tap_point);
GetAppListTestHelper()->WaitUntilIdle();
}
......@@ -3417,4 +3473,23 @@ TEST_P(AppListPresenterDelegateVirtualKeyboardTest,
EXPECT_FALSE(GetAppListView()->search_box_view()->is_search_box_active());
}
TEST_P(AppListPresenterDelegateHomeLauncherTest,
TapHomeButtonOnExternalDisplay) {
UpdateDisplay("800x600,1000x768");
TapHomeButton(GetSecondaryDisplay().id());
{
SCOPED_TRACE("1st tap");
GetAppListTestHelper()->CheckVisibility(true);
GetAppListTestHelper()->CheckState(AppListViewState::kPeeking);
}
TapHomeButton(GetSecondaryDisplay().id());
{
SCOPED_TRACE("2nd tap");
GetAppListTestHelper()->CheckVisibility(false);
GetAppListTestHelper()->CheckState(AppListViewState::kClosed);
}
}
} // namespace ash
......@@ -35,7 +35,7 @@ TEST_F(AppListTest, PressHomeButtonToShowAndDismiss) {
aura::Window* app_list_container =
root_window->GetChildById(kShellWindowId_AppListContainer);
ui::test::EventGenerator generator(root_window);
ui::test::EventGenerator* generator = GetEventGenerator();
// Click the home button to show the app list.
auto* controller = Shell::Get()->app_list_controller();
......@@ -44,15 +44,15 @@ TEST_F(AppListTest, PressHomeButtonToShowAndDismiss) {
EXPECT_FALSE(presenter->GetTargetVisibility());
EXPECT_EQ(0u, app_list_container->children().size());
EXPECT_FALSE(home_button->IsShowingAppList());
generator.set_current_screen_location(
home_button->GetBoundsInScreen().CenterPoint());
generator.ClickLeftButton();
generator->MoveMouseTo(home_button->GetBoundsInScreen().CenterPoint());
generator->ClickLeftButton();
EXPECT_TRUE(presenter->GetTargetVisibility());
EXPECT_EQ(1u, app_list_container->children().size());
EXPECT_TRUE(home_button->IsShowingAppList());
// Click the button again to dismiss the app list; it will animate to close.
generator.ClickLeftButton();
generator->ClickLeftButton();
EXPECT_FALSE(controller->GetTargetVisibility());
EXPECT_EQ(1u, app_list_container->children().size());
EXPECT_FALSE(home_button->IsShowingAppList());
......@@ -74,7 +74,7 @@ TEST_F(AppListTest, PressHomeButtonToShowAndDismissOnSecondDisplay) {
aura::Window* app_list_container =
root_window->GetChildById(kShellWindowId_AppListContainer);
ui::test::EventGenerator generator(root_window);
ui::test::EventGenerator* generator = GetEventGenerator();
// Click the home button to show the app list.
auto* controller = Shell::Get()->app_list_controller();
......@@ -84,15 +84,14 @@ TEST_F(AppListTest, PressHomeButtonToShowAndDismissOnSecondDisplay) {
EXPECT_EQ(0u, app_list_container->children().size());
EXPECT_FALSE(home_button->IsShowingAppList());
generator.set_current_screen_location(
home_button->GetBoundsInScreen().CenterPoint());
generator.ClickLeftButton();
generator->MoveMouseTo(home_button->GetBoundsInScreen().CenterPoint());
generator->ClickLeftButton();
EXPECT_TRUE(presenter->GetTargetVisibility());
EXPECT_EQ(1u, app_list_container->children().size());
EXPECT_TRUE(home_button->IsShowingAppList());
// Click the button again to dismiss the app list; it will animate to close.
generator.ClickLeftButton();
generator->ClickLeftButton();
EXPECT_FALSE(controller->GetTargetVisibility());
EXPECT_EQ(1u, app_list_container->children().size());
EXPECT_FALSE(home_button->IsShowingAppList());
......
......@@ -323,14 +323,18 @@ void EventGenerator::GestureTapAt(const gfx::Point& location) {
}
void EventGenerator::GestureTapDownAndUp(const gfx::Point& location) {
UpdateCurrentDispatcher(location);
gfx::Point converted_location = location;
delegate()->ConvertPointToTarget(current_target_, &converted_location);
const int kTouchId = 3;
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, location, ui::EventTimeForNow(),
ui::ET_TOUCH_PRESSED, converted_location, ui::EventTimeForNow(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
Dispatch(&press);
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, location,
ui::ET_TOUCH_RELEASED, converted_location,
press.time_stamp() + base::TimeDelta::FromMilliseconds(1000),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
Dispatch(&release);
......@@ -360,6 +364,7 @@ void EventGenerator::GestureScrollSequenceWithCallback(
const base::TimeDelta& step_delay,
int steps,
const ScrollStepCallback& callback) {
UpdateCurrentDispatcher(start);
const int kTouchId = 5;
base::TimeTicks timestamp = ui::EventTimeForNow();
ui::TouchEvent press(ui::ET_TOUCH_PRESSED, start, timestamp,
......@@ -527,6 +532,8 @@ void EventGenerator::ScrollSequence(const gfx::Point& start,
float y_offset,
int steps,
int num_fingers) {
UpdateCurrentDispatcher(start);
base::TimeTicks timestamp = ui::EventTimeForNow();
ui::ScrollEvent fling_cancel(ui::ET_SCROLL_FLING_CANCEL,
start,
......
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