Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Migrate keyboard_key_handler_unittests to keyboard_win32_unittests #30615

Merged

Conversation

dkwingsmt
Copy link
Contributor

@dkwingsmt dkwingsmt commented Dec 31, 2021

Some of the tests in keyboard_key_handler_unittests.cc are related to KeyboardKeyHandler's internal behaviors (such as how to arrange multiple delegates), while the others are for generic keyboard processing logic (such as processing AltGr events). This PR re-implements the latter type of tests in the form of keyboard_win32_unittests.cc. In this way, we can gradually phase out KeyboardKeyHandler as announced in #30456.

This PR also includes the following minor changes:

  • Fixes a test that incorrectly assumed WM_SYSKEY* events could be redispatched. They can not due to limitation of SendInput.
  • Creates a new testing util class, MockKeyResponseController, which combines the previous parameters to set the channel result callback and the embedder result callback. A new method, LateResponding, can be used to asynchronously respond.
  • Fixes the mocking of SendInput. Now it correctly processes more than one LPINPUT (although this case is not used in existing tests.)

This is one of the many steps to refactor the windows keyboard system.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@dkwingsmt dkwingsmt changed the title Win key move tests to keyboard unittest Migrate keyboard_key_handler_unittests to keyboard_win32_unittests Jan 5, 2022
@dkwingsmt dkwingsmt requested a review from gspencergoog January 5, 2022 12:01
@dkwingsmt dkwingsmt marked this pull request as ready for review January 5, 2022 12:01
Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

Comment on lines 132 to 134
// Sys key events can't be synthesized. Their dispatching should be prevented
// in earlier code.
assert(event.action != WM_SYSKEYDOWN && event.action != WM_SYSKEYUP);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could make the message part of the assert message:

Suggested change
// Sys key events can't be synthesized. Their dispatching should be prevented
// in earlier code.
assert(event.action != WM_SYSKEYDOWN && event.action != WM_SYSKEYUP);
assert(event.action != WM_SYSKEYDOWN && event.action != WM_SYSKEYUP
&& "Sys key events can't be synthesized. Their dispatching should be prevented in earlier code.");

Then the message will also print when the assert fires.

@dkwingsmt dkwingsmt merged commit 2bf6b01 into flutter:main Jan 6, 2022
@dkwingsmt dkwingsmt deleted the win-key-move-tests-to-keyboard-unittest branch January 6, 2022 01:19
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 6, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 7, 2022
zanderso pushed a commit to flutter/flutter that referenced this pull request Jan 7, 2022
* 1f60bfc Fix missing shcore.dll error on Windows 7 (flutter/engine#30699)

* 4c30367 Roll Fuchsia Mac SDK from G04Sc3__F... to WjrtT4DAB... (flutter/engine#30700)

* 2bf6b01 Migrate keyboard_key_handler_unittests to keyboard_win32_unittests (flutter/engine#30615)

* ed6868f Update //third_party/glfw from Aug 2016 to Jan 2019 (revision 78e6a006) (flutter/engine#30609)

* 7fae72a Roll Skia from 88c5af7ecd72 to 8e6b60f27da3 (3 revisions) (flutter/engine#30703)

* b01a5a9 Roll Fuchsia Mac SDK from WjrtT4DAB... to fSRFvvC1c... (flutter/engine#30705)

* 63f9190 Roll Skia from 8e6b60f27da3 to f5853ff6525b (1 revision) (flutter/engine#30706)

* 7467eac Roll Skia from f5853ff6525b to db2b8eb98f14 (1 revision) (flutter/engine#30708)

* 936c3a0 Roll Skia from db2b8eb98f14 to 426f7b5ad606 (2 revisions) (flutter/engine#30710)

* 9524ec8 Roll Skia from 426f7b5ad606 to a5d4541ae556 (3 revisions) (flutter/engine#30712)

* e8bb686 Roll Skia from a5d4541ae556 to 96e4053be7a5 (3 revisions) (flutter/engine#30714)

* d301340 Roll Skia from 96e4053be7a5 to ce49ff6520fa (4 revisions) (flutter/engine#30715)

* 38a007d Roll Dart SDK from f59531cc2973 to 5f2c54513b7d (13 revisions) (flutter/engine#30716)

* 305dcd5 Roll Skia from ce49ff6520fa to 73657689b6cb (5 revisions) (flutter/engine#30718)

* d930dce [web] allow customizing Ahem URL using FontManifest.json (flutter/engine#30719)

* a0bbfeb Roll Skia from 73657689b6cb to 72412a86725a (3 revisions) (flutter/engine#30721)

* d53b3c2 Fix aot builds in the dart_runner for fuchsia (flutter/engine#30722)

* 56816a0 Roll Skia from 72412a86725a to 2f3891bf76f3 (1 revision) (flutter/engine#30723)

* 496e055 Roll Dart SDK from 5f2c54513b7d to 8a8fb0972646 (1 revision) (flutter/engine#30725)

* 685d220 Bump Robolectric to 4.7.3 (flutter/engine#30437)

* f8a8276 Roll Fuchsia Mac SDK from fSRFvvC1c... to cSwk_StnQ... (flutter/engine#30727)

* 594238c Revert Dart SDK to f59531cc2973 (flutter/engine#30729)
JsouLiang pushed a commit to JsouLiang/engine that referenced this pull request Jan 14, 2022
…lutter#30615)

* Refactor to MockKeyResponseController (ATP)

* Implement LateResponding and move GetEngine in (ATP)

* RespondValue

* DisorderlyRepliedEvents

* SlowFrameworkResponse

* NeverRedispatchShiftRightKeyDown

* Migrate AltGr event. (ATP)

* Correctly handle sys messages.

* Remove SendInputInfo

* Comment and format
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants