New issue
Advanced search Search tips

Issue 878734 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Oct 21
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Chrome
Pri: 2
Type: Feature



Sign in to add a comment

Tast should support injecting input events

Project Member Reported by derat@chromium.org, Aug 29

Issue description

Tast should support injecting fake input events into the kernel using evemu (https://www.freedesktop.org/wiki/Evemu/). This should be similar to the Autotest input_playback module at http://cs/chromeos_public/src/third_party/autotest/files/client/cros/input_playback/ .
 

Comment 1 Deleted

Cc: jkardatzke@chromium.org
Summary: Tast should support injecting input events (was: Tast should support generating input events)
The interface exposed by the existing input_playback module in Autotest doesn't seem ideal. There are a bunch of hardcoded evemu recording files checked in with names like "keyboard_ctrl+t" and "keyboard_search+L" (note inconsistent naming), and the module expects callers to pass in one of those names to determine which events to inject.

Injecting input events doesn't seem too complicated (see e.g. https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/tools/inject_powerd_input_event.cc), and I see Go bindings for the Linux input subsystem at https://github.com/gvalkov/golang-evdev.

I'd prefer that we avoid using evemu here, unless it provides some benefit that I'm missing.
Status: Started (was: Assigned)
I think I can hack something together here.
evemu for mouseclicks isn't ideal in general - the mouse movements are relative to the current position, and there's no way to use it to set the cursor somewhere
I'm just about done with a bare-bones implementation of this.

The initial version will likely just support injecting individual events (e.g. you'll need to send your own EV_SYN after each logical event) and only support discovery of a keyboard device. It'll be straightforward to build on top of that to make it more pleasant to send things like sequences of keystrokes or accelerators.

Re not being able to use absolute screen positions for mouse/touchpad/etc. events, I think that's just inherent in those types of events -- the kernel doesn't know anything about the onscreen pointer, just that the user dragged their finger from one spot on the touchpad to another. It should be possible to provide a better user (i.e. test author) experience there, but it'll likely require Chrome's involvement.
Project Member

Comment 6 by bugdroid1@chromium.org, Sep 26

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/tast-tests/+/8bd3f44081810aabfdede99f3f3239a6ffd6782b

commit 8bd3f44081810aabfdede99f3f3239a6ffd6782b
Author: Daniel Erat <derat@chromium.org>
Date: Wed Sep 26 03:40:59 2018

tast-tests: Add input constants and generator script.

Add a short script for generating constants from the
kernel's include/uapi/linux/input-event-codes.h header,
along with the generated constants themselves. This is the
first part of a forthcoming input package.

The constants were generated using the following commands:

  go run gen/gen_constants.go \
    ../../../../../../../third_party/kernel/v4.14/include/uapi/linux/input-event-codes.h \
    generated_constants.go

  go fmt generated_constants.go

After a later change, running "go generate" will execute
these commands. This only needs to be done if/when the
kernel header changes.

BUG= chromium:878734 
TEST=manual inspection (and verified in conjunction with
     later changes)

Change-Id: Id72e236ce9b6dafada3177e3a7836f04805060d0
Reviewed-on: https://chromium-review.googlesource.com/1239479
Commit-Ready: Dan Erat <derat@chromium.org>
Tested-by: Dan Erat <derat@chromium.org>
Reviewed-by: Dan Erat <derat@chromium.org>
Reviewed-by: Shuhei Takahashi <nya@chromium.org>

[add] https://crrev.com/8bd3f44081810aabfdede99f3f3239a6ffd6782b/src/chromiumos/tast/local/input/generated_constants.go
[add] https://crrev.com/8bd3f44081810aabfdede99f3f3239a6ffd6782b/src/chromiumos/tast/local/input/gen/gen_constants.go

Project Member

Comment 7 by bugdroid1@chromium.org, Sep 28

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/tast-tests/+/50bbfb2b7bb7c50d7f3b22f771f686f5b0027b36

commit 50bbfb2b7bb7c50d7f3b22f771f686f5b0027b36
Author: Daniel Erat <derat@chromium.org>
Date: Fri Sep 28 02:44:18 2018

tast-tests: Add device-related code to input package.

Add code to the input package for reading information about
input devices from /proc/bus/input/devices. A followup
change will use this to find keyboard devices.

BUG= chromium:878734 
TEST=added unit tests

Change-Id: Id522d8f5832ce4101eca0c5f1b349674ad08e53b
Reviewed-on: https://chromium-review.googlesource.com/1244411
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Dan Erat <derat@chromium.org>
Reviewed-by: Shuhei Takahashi <nya@chromium.org>

[add] https://crrev.com/50bbfb2b7bb7c50d7f3b22f771f686f5b0027b36/src/chromiumos/tast/local/input/device.go
[add] https://crrev.com/50bbfb2b7bb7c50d7f3b22f771f686f5b0027b36/src/chromiumos/tast/local/input/device_test.go

Project Member

Comment 8 by bugdroid1@chromium.org, Oct 11

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/tast-tests/+/3a42ab62a76331465c40b9f4f1935476e8650b58

commit 3a42ab62a76331465c40b9f4f1935476e8650b58
Author: Daniel Erat <derat@chromium.org>
Date: Thu Oct 11 00:08:00 2018

tast-tests: Add EventWriter to input package.

Add a new EventWriter type that can be used by local tests
to inject input events. The interface is currently low-level
(e.g. callers need to send synchronization events), with a
focus on keyboard devices.

Also add a short example.Input test demonstrating how to use
the package to inject keyboard events.

BUG= chromium:878734 
TEST=added unit tests; also verified that example.Input
     passes on a DUT with an internal keyboard

Change-Id: Ia3e7dc86f6c5006ae0e2ef6f611cc8eb404bc2f1
Reviewed-on: https://chromium-review.googlesource.com/1239480
Commit-Ready: Dan Erat <derat@chromium.org>
Tested-by: Dan Erat <derat@chromium.org>
Reviewed-by: Dan Erat <derat@chromium.org>

[add] https://crrev.com/3a42ab62a76331465c40b9f4f1935476e8650b58/src/chromiumos/tast/local/input/event.go
[add] https://crrev.com/3a42ab62a76331465c40b9f4f1935476e8650b58/src/chromiumos/tast/local/bundles/cros/example/input.go
[add] https://crrev.com/3a42ab62a76331465c40b9f4f1935476e8650b58/src/chromiumos/tast/local/input/event_test.go

Project Member

Comment 9 by bugdroid1@chromium.org, Oct 15

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/tast-tests/+/74e5447967fa455b401f081fcbf5f41b09dfe61c

commit 74e5447967fa455b401f081fcbf5f41b09dfe61c
Author: Daniel Erat <derat@chromium.org>
Date: Mon Oct 15 23:02:00 2018

tast-tests: Add EventWriter.Type method.

Add a Type method to the EventWriter class that can be used
to inject key events corresponding to a passed-in string.

Also remove Dvorak and Caps Lock support from the (disabled)
example.Input test, since trying to support all non-standard
configurations seems like a hopeless endeavor.

BUG= chromium:878734 
TEST=added unit test; also updated example.Input test to
     call new method

Change-Id: Ib473422050693993b98fc4f3fbd455d11a7566bb
Reviewed-on: https://chromium-review.googlesource.com/1279310
Commit-Ready: Dan Erat <derat@chromium.org>
Tested-by: Dan Erat <derat@chromium.org>
Reviewed-by: Dan Erat <derat@chromium.org>

[modify] https://crrev.com/74e5447967fa455b401f081fcbf5f41b09dfe61c/src/chromiumos/tast/local/input/event.go
[modify] https://crrev.com/74e5447967fa455b401f081fcbf5f41b09dfe61c/src/chromiumos/tast/local/bundles/cros/example/input.go
[add] https://crrev.com/74e5447967fa455b401f081fcbf5f41b09dfe61c/src/chromiumos/tast/local/input/key_mappings.go
[modify] https://crrev.com/74e5447967fa455b401f081fcbf5f41b09dfe61c/src/chromiumos/tast/local/input/event_test.go
[modify] https://crrev.com/74e5447967fa455b401f081fcbf5f41b09dfe61c/src/chromiumos/tast/local/input/gen/gen_constants.go

Project Member

Comment 10 by bugdroid1@chromium.org, Oct 21

The following revision refers to this bug:
  https://chromium.googlesource.com/chromiumos/platform/tast-tests/+/af9ae351636f4e2e991032ed671309f90b108c2c

commit af9ae351636f4e2e991032ed671309f90b108c2c
Author: Daniel Erat <derat@chromium.org>
Date: Sun Oct 21 12:25:01 2018

tast-tests: Add EventWriter.Accel.

Add a new Accel method to the input package's EventWriter
type. This method supports injecting accelerators via
descriptions like "Ctrl+Alt+T".

Also update the vm.CrostiniStartEverything and example.Input
tests to use this new method. I'm unfortunately also seeing
some flakiness in example.Input, although I think it
probably reflects issues in Chrome's handling of
unrealistically-fast keyboard input rather than bugs in
Tast's input package.

BUG= chromium:878734 
TEST=added unit tests; also verified that updated tests
     still pass

Change-Id: I1dc2655b2d6cfb0ddec73613fb8158a00efcddeb
Reviewed-on: https://chromium-review.googlesource.com/1290110
Commit-Ready: Dan Erat <derat@chromium.org>
Tested-by: Dan Erat <derat@chromium.org>
Reviewed-by: Dan Erat <derat@chromium.org>

[modify] https://crrev.com/af9ae351636f4e2e991032ed671309f90b108c2c/src/chromiumos/tast/local/input/event.go
[add] https://crrev.com/af9ae351636f4e2e991032ed671309f90b108c2c/src/chromiumos/tast/local/input/key_mappings_test.go
[modify] https://crrev.com/af9ae351636f4e2e991032ed671309f90b108c2c/src/chromiumos/tast/local/bundles/cros/example/input.go
[modify] https://crrev.com/af9ae351636f4e2e991032ed671309f90b108c2c/src/chromiumos/tast/local/bundles/cros/vm/subtest/verify_launcher_app.go
[modify] https://crrev.com/af9ae351636f4e2e991032ed671309f90b108c2c/src/chromiumos/tast/local/input/key_mappings.go
[modify] https://crrev.com/af9ae351636f4e2e991032ed671309f90b108c2c/src/chromiumos/tast/local/input/event_test.go

Status: Fixed (was: Started)

Sign in to add a comment