Skip to content

Commit

Permalink
Remove ID from ui::TouchEvent's constructors
Browse files Browse the repository at this point in the history
We should put all the PointerEvent's properties in PointerDetails class, so remove ID from ui::TouchEvent's constructors
and replace with a PointerDetails object.

BUG=699372

Review-Url: https://codereview.chromium.org/2739713002
Cr-Commit-Position: refs/heads/master@{#457545}
  • Loading branch information
LanWei22 authored and Commit bot committed Mar 16, 2017
1 parent a6307fb commit 6472567
Show file tree
Hide file tree
Showing 52 changed files with 1,566 additions and 1,007 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,9 @@ TEST_F(ShelfButtonPressedMetricTrackerTest,
if (WmShell::Get()->IsRunningInMash())
return;

const ui::TouchEvent touch_event(ui::ET_GESTURE_TAP, gfx::Point(), 0,
base::TimeTicks());
const ui::TouchEvent touch_event(
ui::ET_GESTURE_TAP, gfx::Point(), base::TimeTicks(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));

base::UserActionTester user_action_tester;
ButtonPressed(touch_event);
Expand Down
16 changes: 12 additions & 4 deletions ash/drag_drop/drag_drop_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1068,20 +1068,28 @@ TEST_F(DragDropControllerTest, TouchDragDropCompletesOnFling) {
gfx::Point end = start + gfx::Vector2d(drag_view->bounds().width() / 3, 0);

base::TimeTicks timestamp = ui::EventTimeForNow();
ui::TouchEvent press(ui::ET_TOUCH_PRESSED, start, 0, timestamp);
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, start, timestamp,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
generator.Dispatch(&press);

DispatchGesture(ui::ET_GESTURE_LONG_PRESS, start);
UpdateDragData(&data);
timestamp += base::TimeDelta::FromMilliseconds(10);
ui::TouchEvent move1(ui::ET_TOUCH_MOVED, mid, 0, timestamp);
ui::TouchEvent move1(
ui::ET_TOUCH_MOVED, mid, timestamp,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
generator.Dispatch(&move1);
// Doing two moves instead of one will guarantee to generate a fling at the
// end.
timestamp += base::TimeDelta::FromMilliseconds(10);
ui::TouchEvent move2(ui::ET_TOUCH_MOVED, end, 0, timestamp);
ui::TouchEvent move2(
ui::ET_TOUCH_MOVED, end, timestamp,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
generator.Dispatch(&move2);
ui::TouchEvent release(ui::ET_TOUCH_RELEASED, end, 0, timestamp);
ui::TouchEvent release(
ui::ET_TOUCH_RELEASED, end, timestamp,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
generator.Dispatch(&release);

EXPECT_TRUE(drag_drop_controller_->drag_start_received_);
Expand Down
10 changes: 6 additions & 4 deletions ash/shelf/shelf_widget_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,9 @@ TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) {
// should not find the shelf as the target.
{
gfx::Point event_location(20, shelf_bounds.y() - 1);
ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0,
ui::EventTimeForNow());
ui::TouchEvent touch(
ui::ET_TOUCH_PRESSED, event_location, ui::EventTimeForNow(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
EXPECT_NE(shelf_widget->GetNativeWindow(),
targeter->FindTargetForEvent(root, &touch));
}
Expand All @@ -316,8 +317,9 @@ TEST_F(ShelfWidgetTest, HiddenShelfHitTestTouch) {
// shelf as the target.
{
gfx::Point event_location(20, shelf_bounds.y() - 1);
ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, event_location, 0,
ui::EventTimeForNow());
ui::TouchEvent touch(
ui::ET_TOUCH_PRESSED, event_location, ui::EventTimeForNow(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
EXPECT_EQ(shelf_widget->GetNativeWindow(),
targeter->FindTargetForEvent(root, &touch));
}
Expand Down
4 changes: 3 additions & 1 deletion ash/touch/touch_observer_hud_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,9 @@ class TouchHudProjectionTest : public TouchHudTestBase {
void SendTouchEventToInternalHud(ui::EventType type,
const gfx::Point& location,
int touch_id) {
ui::TouchEvent event(type, location, touch_id, event_time);
ui::TouchEvent event(
type, location, event_time,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, touch_id));
GetInternalTouchHudProjection()->OnTouchEvent(&event);

// Advance time for next event.
Expand Down
10 changes: 6 additions & 4 deletions ash/wm/immersive_fullscreen_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -768,8 +768,9 @@ TEST_F(ImmersiveFullscreenControllerTest, EventsDoNotLeakToWindowUnderneath) {
EXPECT_EQ(behind->GetBoundsInScreen().y(), window()->GetBoundsInScreen().y());
int top = behind->GetBoundsInScreen().y();

ui::TouchEvent touch(ui::ET_TOUCH_MOVED, gfx::Point(10, top), 0,
ui::EventTimeForNow());
ui::TouchEvent touch(
ui::ET_TOUCH_MOVED, gfx::Point(10, top), ui::EventTimeForNow(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
aura::Window* root = window()->GetRootWindow();
ui::EventTargeter* targeter =
root->GetHost()->dispatcher()->GetDefaultEventTargeter();
Expand All @@ -780,8 +781,9 @@ TEST_F(ImmersiveFullscreenControllerTest, EventsDoNotLeakToWindowUnderneath) {
// Make sure the windows are still aligned on top.
EXPECT_EQ(behind->GetBoundsInScreen().y(), window()->GetBoundsInScreen().y());
top = behind->GetBoundsInScreen().y();
ui::TouchEvent touch2(ui::ET_TOUCH_MOVED, gfx::Point(10, top), 0,
ui::EventTimeForNow());
ui::TouchEvent touch2(
ui::ET_TOUCH_MOVED, gfx::Point(10, top), ui::EventTimeForNow(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
// The event should still be targeted to window().
EXPECT_EQ(window(), targeter->FindTargetForEvent(root, &touch2));
}
Expand Down
7 changes: 4 additions & 3 deletions ash/wm/panels/panel_layout_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -885,9 +885,10 @@ TEST_F(PanelLayoutManagerTest, TouchHitTestPanel) {
// Hit test outside the right edge with a bottom-aligned shelf.
SetAlignment(Shell::GetPrimaryRootWindow(), SHELF_ALIGNMENT_BOTTOM);
gfx::Rect bounds(w->bounds());
ui::TouchEvent touch(ui::ET_TOUCH_PRESSED,
gfx::Point(bounds.right() + 3, bounds.y() + 2), 0,
ui::EventTimeForNow());
ui::TouchEvent touch(
ui::ET_TOUCH_PRESSED, gfx::Point(bounds.right() + 3, bounds.y() + 2),
ui::EventTimeForNow(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
ui::EventTarget* target = targeter->FindTargetForEvent(root, &touch);
EXPECT_EQ(w.get(), target);

Expand Down
12 changes: 9 additions & 3 deletions ash/wm/window_manager_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ TEST_F(WindowManagerTest, Focus) {
// Touch on a sub-window (w122) to focus it.
gfx::Point click_point = w122->bounds().CenterPoint();
aura::Window::ConvertPointToTarget(w122->parent(), root_window, &click_point);
ui::TouchEvent touchev(ui::ET_TOUCH_PRESSED, click_point, 0, getTime());
ui::TouchEvent touchev(
ui::ET_TOUCH_PRESSED, click_point, getTime(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
details = dispatcher->OnEventFromSource(&touchev);
ASSERT_FALSE(details.dispatcher_destroyed);
focus_client = aura::client::GetFocusClient(w122.get());
Expand Down Expand Up @@ -416,7 +418,9 @@ TEST_F(WindowManagerTest, ActivateOnTouch) {
// Touch window2.
gfx::Point press_point = w2->bounds().CenterPoint();
aura::Window::ConvertPointToTarget(w2->parent(), root_window, &press_point);
ui::TouchEvent touchev1(ui::ET_TOUCH_PRESSED, press_point, 0, getTime());
ui::TouchEvent touchev1(
ui::ET_TOUCH_PRESSED, press_point, getTime(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));

ui::EventProcessor* dispatcher = root_window->GetHost()->event_processor();
ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&touchev1);
Expand All @@ -436,7 +440,9 @@ TEST_F(WindowManagerTest, ActivateOnTouch) {
press_point = w1->bounds().CenterPoint();
aura::Window::ConvertPointToTarget(w1->parent(), root_window, &press_point);
d1.set_activate(false);
ui::TouchEvent touchev2(ui::ET_TOUCH_PRESSED, press_point, 1, getTime());
ui::TouchEvent touchev2(
ui::ET_TOUCH_PRESSED, press_point, getTime(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
details = dispatcher->OnEventFromSource(&touchev2);
ASSERT_FALSE(details.dispatcher_destroyed);

Expand Down
15 changes: 9 additions & 6 deletions ash/wm/workspace_controller_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1513,8 +1513,9 @@ TEST_F(WorkspaceControllerTest, WindowEdgeHitTest) {
ui::EventTarget* target = targeter->FindTargetForEvent(root, &mouse);
EXPECT_EQ(expected_target, target);

ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, location, 0,
ui::EventTimeForNow());
ui::TouchEvent touch(
ui::ET_TOUCH_PRESSED, location, ui::EventTimeForNow(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
target = targeter->FindTargetForEvent(root, &touch);
EXPECT_EQ(expected_target, target);
}
Expand Down Expand Up @@ -1587,8 +1588,9 @@ TEST_F(WorkspaceControllerTest, WindowEdgeTouchHitTestPanel) {
for (int i = 0; i < kNumPoints; ++i) {
SCOPED_TRACE(points[i].direction);
const gfx::Point& location = points[i].location;
ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, location, 0,
ui::EventTimeForNow());
ui::TouchEvent touch(
ui::ET_TOUCH_PRESSED, location, ui::EventTimeForNow(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
ui::EventTarget* target = targeter->FindTargetForEvent(root, &touch);
if (points[i].is_target_hit)
EXPECT_EQ(window.get(), target);
Expand Down Expand Up @@ -1637,8 +1639,9 @@ TEST_F(WorkspaceControllerTest, WindowEdgeHitTestDocked) {
else
EXPECT_NE(window.get(), target);

ui::TouchEvent touch(ui::ET_TOUCH_PRESSED, location, 0,
ui::EventTimeForNow());
ui::TouchEvent touch(
ui::ET_TOUCH_PRESSED, location, ui::EventTimeForNow(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
target = targeter->FindTargetForEvent(root, &touch);
if (points[i].is_target_hit)
EXPECT_EQ(window.get(), target);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,20 @@ IN_PROC_BROWSER_TEST_F(TouchExplorationTest, MAYBE_NoRewritingEventsWhenOff) {

base::TimeTicks initial_time = Now();
ui::TouchEvent initial_press(
ui::ET_TOUCH_PRESSED, gfx::Point(99, 200), 1, initial_time);
ui::ET_TOUCH_PRESSED, gfx::Point(99, 200), initial_time,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
generator.Dispatch(&initial_press);

// Since the touch exploration controller doesn't know if the user is
// double-tapping or not, touch exploration is only initiated if the
// 300 ms has elapsed and the finger does not move fast enough to begin
// gestures. Here, the touch move event is not important as a move, but
// a way to create time advancement.
ui::TouchEvent touch_time_advance(ui::ET_TOUCH_MOVED,
gfx::Point(100, 200),
1,
initial_time +
gesture_detector_config_.double_tap_timeout +
base::TimeDelta::FromMilliseconds(1));
ui::TouchEvent touch_time_advance(
ui::ET_TOUCH_MOVED, gfx::Point(100, 200),
initial_time + gesture_detector_config_.double_tap_timeout +
base::TimeDelta::FromMilliseconds(1),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
generator.Dispatch(&touch_time_advance);

EXPECT_EQ(0, event_handler_->num_mouse_events());
Expand All @@ -116,14 +116,14 @@ IN_PROC_BROWSER_TEST_F(TouchExplorationTest, MAYBE_NoRewritingEventsWhenOff) {

initial_time = Now();
ui::TouchEvent second_initial_press(
ui::ET_TOUCH_PRESSED, gfx::Point(499, 600), 2, initial_time);
ui::ET_TOUCH_PRESSED, gfx::Point(499, 600), initial_time,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
generator.Dispatch(&second_initial_press);
ui::TouchEvent second_touch_time_advance(
ui::ET_TOUCH_MOVED,
gfx::Point(500, 600),
2,
ui::ET_TOUCH_MOVED, gfx::Point(500, 600),
initial_time + gesture_detector_config_.double_tap_timeout +
base::TimeDelta::FromMilliseconds(1));
base::TimeDelta::FromMilliseconds(1),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
generator.Dispatch(&second_touch_time_advance);
EXPECT_EQ(0, event_handler_->num_mouse_events());
EXPECT_EQ(2, event_handler_->num_touch_events());
Expand All @@ -138,20 +138,20 @@ IN_PROC_BROWSER_TEST_F(TouchExplorationTest, DISABLED_RewritesEventsWhenOn) {

base::TimeTicks initial_time = Now();
ui::TouchEvent initial_press(
ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time);
ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), initial_time,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
generator.Dispatch(&initial_press);

// Since the touch exploration controller doesn't know if the user is
// double-tapping or not, touch exploration is only initiated if the
// 300 ms has elapsed and the finger does not move fast enough to begin
// gestures. Here, the touch move event is not important as a move, but
// a way to create time advancement.
ui::TouchEvent touch_time_advance(ui::ET_TOUCH_MOVED,
gfx::Point(100, 200),
1,
initial_time +
gesture_detector_config_.double_tap_timeout +
base::TimeDelta::FromMilliseconds(1));
ui::TouchEvent touch_time_advance(
ui::ET_TOUCH_MOVED, gfx::Point(100, 200),
initial_time + gesture_detector_config_.double_tap_timeout +
base::TimeDelta::FromMilliseconds(1),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
generator.Dispatch(&touch_time_advance);

// Number of mouse events may be greater than 1 because of ET_MOUSE_ENTERED.
Expand All @@ -161,14 +161,14 @@ IN_PROC_BROWSER_TEST_F(TouchExplorationTest, DISABLED_RewritesEventsWhenOn) {

initial_time = Now();
ui::TouchEvent second_initial_press(
ui::ET_TOUCH_PRESSED, gfx::Point(500, 600), 2, initial_time);
ui::ET_TOUCH_PRESSED, gfx::Point(500, 600), initial_time,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
generator.Dispatch(&second_initial_press);
ui::TouchEvent second_touch_time_advance(
ui::ET_TOUCH_MOVED,
gfx::Point(500, 600),
2,
ui::ET_TOUCH_MOVED, gfx::Point(500, 600),
initial_time + gesture_detector_config_.double_tap_timeout +
base::TimeDelta::FromMilliseconds(1));
base::TimeDelta::FromMilliseconds(1),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
generator.Dispatch(&second_touch_time_advance);
EXPECT_GT(event_handler_->num_mouse_events(), 0);
EXPECT_EQ(1, event_handler_->num_touch_events());
Expand All @@ -179,11 +179,10 @@ IN_PROC_BROWSER_TEST_F(TouchExplorationTest, DISABLED_RewritesEventsWhenOn) {
// event can come after the browser is already partly shut down, which causes
// the test to crash.
ui::TouchEvent release_second_touch(
ui::ET_TOUCH_RELEASED,
gfx::Point(500, 600),
2,
ui::ET_TOUCH_RELEASED, gfx::Point(500, 600),
initial_time + gesture_detector_config_.double_tap_timeout +
base::TimeDelta::FromMilliseconds(1));
base::TimeDelta::FromMilliseconds(1),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 2));
generator.Dispatch(&release_second_touch);
EXPECT_GT(event_handler_->num_mouse_events(), 0);
EXPECT_EQ(1, event_handler_->num_touch_events());
Expand All @@ -208,19 +207,19 @@ IN_PROC_BROWSER_TEST_F(TouchExplorationTest, DISABLED_SplitTapExplore) {
// after the move.
base::TimeTicks initial_time = Now();
ui::TouchEvent initial_press(
ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), 1, initial_time);
ui::ET_TOUCH_PRESSED, gfx::Point(100, 200), initial_time,
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
generator.Dispatch(&initial_press);
EXPECT_TRUE(cursor_client->IsMouseEventsEnabled());
EXPECT_TRUE(cursor_client->IsCursorVisible());

// Initiate touch explore by waiting for the tap timer timeout. Time is
// advanced by sending a move event after the timeout period.
ui::TouchEvent touch_time_advance(
ui::ET_TOUCH_MOVED,
gfx::Point(100, 200),
1,
ui::ET_TOUCH_MOVED, gfx::Point(100, 200),
initial_time + gesture_detector_config_.double_tap_timeout +
base::TimeDelta::FromMilliseconds(1));
base::TimeDelta::FromMilliseconds(1),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
generator.Dispatch(&touch_time_advance);
EXPECT_TRUE(cursor_client->IsMouseEventsEnabled());
EXPECT_FALSE(cursor_client->IsCursorVisible());
Expand Down
5 changes: 3 additions & 2 deletions chrome/browser/chromeos/events/event_rewriter_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1930,8 +1930,9 @@ TEST_F(EventRewriterTest, TestRewriteNonNativeEvent) {

const int kTouchId = 2;
gfx::Point location(0, 0);
ui::TouchEvent press(ui::ET_TOUCH_PRESSED, location, kTouchId,
base::TimeTicks());
ui::TouchEvent press(
ui::ET_TOUCH_PRESSED, location, base::TimeTicks(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, kTouchId));
press.set_flags(ui::EF_CONTROL_DOWN);
#if defined(USE_X11)
ui::UpdateX11EventForFlags(&press);
Expand Down
3 changes: 2 additions & 1 deletion chrome/browser/ui/views/first_run_bubble_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ TEST_F(FirstRunBubbleTest, CloseBubbleOnMouseDownEvent) {

TEST_F(FirstRunBubbleTest, CloseBubbleOnTouchDownEvent) {
ui::TouchEvent touch_down(
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), 0, ui::EventTimeForNow());
ui::ET_TOUCH_PRESSED, gfx::Point(10, 10), ui::EventTimeForNow(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 0));
CreateAndCloseBubbleOnEventTest(&touch_down);
}

5 changes: 3 additions & 2 deletions components/exo/touch_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ TEST_F(TouchTest, OnTouchCancel) {
// One touch point being canceled is enough for OnTouchCancel to be called.
EXPECT_CALL(delegate, OnTouchCancel());
EXPECT_CALL(delegate, OnTouchFrame());
ui::TouchEvent cancel_event(ui::ET_TOUCH_CANCELLED, gfx::Point(), 1,
ui::EventTimeForNow());
ui::TouchEvent cancel_event(
ui::ET_TOUCH_CANCELLED, gfx::Point(), ui::EventTimeForNow(),
ui::PointerDetails(ui::EventPointerType::POINTER_TYPE_TOUCH, 1));
generator.Dispatch(&cancel_event);

EXPECT_CALL(delegate, OnTouchDestroying(touch.get()));
Expand Down
Loading

0 comments on commit 6472567

Please sign in to comment.