diff options
Diffstat (limited to 'tests')
4 files changed, 7 insertions, 41 deletions
diff --git a/tests/src/com/android/inputmethod/latin/SuggestHelper.java b/tests/src/com/android/inputmethod/latin/SuggestHelper.java index 7254520d5..de898c3ea 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestHelper.java +++ b/tests/src/com/android/inputmethod/latin/SuggestHelper.java @@ -38,49 +38,15 @@ public class SuggestHelper { private final String TAG; /** Uses main dictionary only **/ - public SuggestHelper(String tag, Context context, int[] resId) { + public SuggestHelper(String tag, Context context, int resId) { TAG = tag; - InputStream[] is = null; - try { - // merging separated dictionary into one if dictionary is separated - int total = 0; - is = new InputStream[resId.length]; - for (int i = 0; i < resId.length; i++) { - is[i] = context.getResources().openRawResource(resId[i]); - total += is[i].available(); - } - - ByteBuffer byteBuffer = - ByteBuffer.allocateDirect(total).order(ByteOrder.nativeOrder()); - int got = 0; - for (int i = 0; i < resId.length; i++) { - got += Channels.newChannel(is[i]).read(byteBuffer); - } - if (got != total) { - Log.w(TAG, "Read " + got + " bytes, expected " + total); - } else { - mSuggest = new Suggest(context, byteBuffer); - Log.i(TAG, "Created mSuggest " + total + " bytes"); - } - } catch (IOException e) { - Log.w(TAG, "No available memory for binary dictionary"); - } finally { - try { - if (is != null) { - for (int i = 0; i < is.length; i++) { - is[i].close(); - } - } - } catch (IOException e) { - Log.w(TAG, "Failed to close input stream"); - } - } + mSuggest = new Suggest(context, resId); mSuggest.setAutoTextEnabled(false); mSuggest.setCorrectionMode(Suggest.CORRECTION_FULL_BIGRAM); } /** Uses both main dictionary and user-bigram dictionary **/ - public SuggestHelper(String tag, Context context, int[] resId, int userBigramMax, + public SuggestHelper(String tag, Context context, int resId, int userBigramMax, int userBigramDelete) { this(tag, context, resId); mUserBigram = new UserBigramDictionary(context, null, Locale.US.toString(), diff --git a/tests/src/com/android/inputmethod/latin/SuggestPerformanceTests.java b/tests/src/com/android/inputmethod/latin/SuggestPerformanceTests.java index 7eb66d502..c5913ab4f 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestPerformanceTests.java +++ b/tests/src/com/android/inputmethod/latin/SuggestPerformanceTests.java @@ -36,9 +36,9 @@ public class SuggestPerformanceTests extends AndroidTestCase { // For testing with real dictionary, TEMPORARILY COPY main dictionary into test directory. // DO NOT SUBMIT real dictionary under test directory. - //int[] resId = new int[] { R.raw.main0, R.raw.main1, R.raw.main2 }; + //int resId = R.raw.main; - int[] resId = new int[] { R.raw.test }; + int resId = R.raw.test; sh = new SuggestHelper(TAG, getTestContext(), resId); loadString(); diff --git a/tests/src/com/android/inputmethod/latin/SuggestTests.java b/tests/src/com/android/inputmethod/latin/SuggestTests.java index 33462dccf..c890394d0 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestTests.java +++ b/tests/src/com/android/inputmethod/latin/SuggestTests.java @@ -26,7 +26,7 @@ public class SuggestTests extends AndroidTestCase { @Override protected void setUp() { - int[] resId = new int[] { R.raw.test }; + int resId = R.raw.test; sh = new SuggestHelper(TAG, getTestContext(), resId); } diff --git a/tests/src/com/android/inputmethod/latin/UserBigramTests.java b/tests/src/com/android/inputmethod/latin/UserBigramTests.java index cbf7bd8e1..af527b02d 100644 --- a/tests/src/com/android/inputmethod/latin/UserBigramTests.java +++ b/tests/src/com/android/inputmethod/latin/UserBigramTests.java @@ -31,7 +31,7 @@ public class UserBigramTests extends AndroidTestCase { @Override protected void setUp() { - int[] resId = new int[] { R.raw.test }; + int resId = R.raw.test; sh = new SuggestHelper(TAG, getTestContext(), resId, MAX_DATA, DELETE_DATA); } |