Skip to content
Snippets Groups Projects
Commit 01a4ebcd authored by Jean Chalard's avatar Jean Chalard
Browse files

Add a way to know externally if we're installing a new dict

That helps tests know when to wait and when to declare the
dictionary actually not usable.

Bug: 7925814
Change-Id: Ic963c1206c43e3cde39ac4214a0d601f4fc6c03b
parent 3d0477fb
No related branches found
No related tags found
No related merge requests found
......@@ -57,6 +57,8 @@ public final class Suggest {
private ContactsBinaryDictionary mContactsDict;
private final ConcurrentHashMap<String, Dictionary> mDictionaries =
CollectionUtils.newConcurrentHashMap();
@UsedForTesting
private boolean mIsCurrentlyWaitingForMainDictionary = false;
public static final int MAX_SUGGESTIONS = 18;
......@@ -98,6 +100,7 @@ public final class Suggest {
public void resetMainDict(final Context context, final Locale locale,
final SuggestInitializationListener listener) {
mIsCurrentlyWaitingForMainDictionary = true;
mMainDictionary = null;
if (listener != null) {
listener.onUpdateMainDictionaryAvailability(hasMainDictionary());
......@@ -112,6 +115,7 @@ public final class Suggest {
if (listener != null) {
listener.onUpdateMainDictionaryAvailability(hasMainDictionary());
}
mIsCurrentlyWaitingForMainDictionary = false;
}
}.start();
}
......@@ -122,6 +126,11 @@ public final class Suggest {
return null != mMainDictionary && mMainDictionary.isInitialized();
}
@UsedForTesting
public boolean isCurrentlyWaitingForMainDictionary() {
return mIsCurrentlyWaitingForMainDictionary;
}
public Dictionary getMainDictionary() {
return mMainDictionary;
}
......
......@@ -231,8 +231,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
}
protected void waitForDictionaryToBeLoaded() {
int remainingAttempts = 10;
while (remainingAttempts > 0 && !mLatinIME.mSuggest.hasMainDictionary()) {
int remainingAttempts = 300;
while (remainingAttempts > 0 && mLatinIME.mSuggest.isCurrentlyWaitingForMainDictionary()) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment