Merge "Add a way to know externally if we're installing a new dict"
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index cf78e7d..975664d 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -57,6 +57,8 @@
     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 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 @@
                 if (listener != null) {
                     listener.onUpdateMainDictionaryAvailability(hasMainDictionary());
                 }
+                mIsCurrentlyWaitingForMainDictionary = false;
             }
         }.start();
     }
@@ -122,6 +126,11 @@
         return null != mMainDictionary && mMainDictionary.isInitialized();
     }
 
+    @UsedForTesting
+    public boolean isCurrentlyWaitingForMainDictionary() {
+        return mIsCurrentlyWaitingForMainDictionary;
+    }
+
     public Dictionary getMainDictionary() {
         return mMainDictionary;
     }
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
index a01fef2..10d415b 100644
--- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
@@ -231,8 +231,8 @@
     }
 
     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) {