Prevent real IME from interfering with UrlBarTest
Android framework does not provide an easy way to remove keyboard app from the testing (unless you use Robolectric). So far we have been allowing the current keyboard app to interfere with test and thus flaked test results. Especially, when you make selection change, Google Latin Keyboard tries to look at the new status by running beginBatchEdit() -> getTextBeforeCursor() -> endBatchEdit(). And this disrupted batch edit logic such as mInBatchEditMode. With this change, onCreateInputConnection() will now return null, so keyboard app cannot interact with the text. Also, dispatchKeyEvent will ignore key events when it has to. Note that the test can still interact with BaseInputConnection's method and thus affects EditText's Editable through UrlBar#getInputConnection(). In doing so, I've guarded KeyUtils#dispatchKeyEventToView() to work with UI thread. BUG=723901 Review-Url: https://codereview.chromium.org/2894073002 Cr-Commit-Position: refs/heads/master@{#473782}
Showing
Please register or sign in to comment