Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5760c018 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Deflake InputMethodServiceTest" into main

parents 1e49841f 98e390c7
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -99,6 +99,12 @@ public class InputMethodServiceTest {
                    InputMethodServiceWrapper.getInputMethodServiceWrapperForTesting();
            assertThat(mInputMethodService).isNotNull();

            // The activity gets focus.
            assertThat(mActivity.hasWindowFocus()).isTrue();
            assertThat(mInputMethodService.getCurrentInputEditorInfo()).isNotNull();
            assertThat(mInputMethodService.getCurrentInputEditorInfo().packageName)
                    .isEqualTo(mTargetPackageName);

            // The editor won't bring up keyboard by default.
            assertThat(mInputMethodService.getCurrentInputStarted()).isTrue();
            assertThat(mInputMethodService.getCurrentInputViewStarted()).isFalse();
+13 −2
Original line number Diff line number Diff line
@@ -53,13 +53,14 @@ public class InputMethodServiceWrapper extends InputMethodService {

    @Override
    public void onStartInput(EditorInfo info, boolean restarting) {
        Log.i(TAG, "onStartInput() editor=" + info + ", restarting=" + restarting);
        Log.i(TAG, "onStartInput() editor=" + dumpEditorInfo(info) + ", restarting=" + restarting);
        super.onStartInput(info, restarting);
    }

    @Override
    public void onStartInputView(EditorInfo info, boolean restarting) {
        Log.i(TAG, "onStartInputView() editor=" + info + ", restarting=" + restarting);
        Log.i(TAG, "onStartInputView() editor=" + dumpEditorInfo(info)
                + ", restarting=" + restarting);
        super.onStartInputView(info, restarting);
        mInputViewStarted = true;
        if (mCountDownLatchForTesting != null) {
@@ -99,4 +100,14 @@ public class InputMethodServiceWrapper extends InputMethodService {
            mCountDownLatchForTesting.countDown();
        }
    }

    private String dumpEditorInfo(EditorInfo info) {
        var sb = new StringBuilder();
        sb.append("EditorInfo{packageName=").append(info.packageName);
        sb.append(" fieldId=").append(info.fieldId);
        sb.append(" hintText=").append(info.hintText);
        sb.append(" privateImeOptions=").append(info.privateImeOptions);
        sb.append("}");
        return sb.toString();
    }
}