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

Commit cfec7e72 authored by Jean Chalard's avatar Jean Chalard Committed by Android (Google) Code Review
Browse files

Merge "Fix a race condition that makes tests unstable"

parents 4a3c0918 816a8a0f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -186,7 +186,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
    private View mKeyPreviewBackingView;
    private View mSuggestionsContainer;
    private SuggestionsView mSuggestionsView;
    private Suggest mSuggest;
    /* package for tests */ Suggest mSuggest;
    private CompletionInfo[] mApplicationSpecifiedCompletions;

    private InputMethodManagerCompatWrapper mImm;
+14 −0
Original line number Diff line number Diff line
@@ -111,6 +111,20 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
        mLatinIME.onStartInputView(ei, false);
        mLatinIME.onCreateInputMethodInterface().startInput(ic, ei);
        mInputConnection = ic;
        // Wait for the main dictionary to be loaded (we need it for auto-correction tests)
        int remainingAttempts = 10;
        while (remainingAttempts > 0 && !mLatinIME.mSuggest.hasMainDictionary()) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                // Don't do much
            } finally {
                --remainingAttempts;
            }
        }
        if (!mLatinIME.mSuggest.hasMainDictionary()) {
            throw new RuntimeException("Can't initialize the main dictionary");
        }
    }

    // type(int) and type(String): helper methods to send a code point resp. a string to LatinIME.