diff --git a/tests/src/com/android/inputmethod/latin/SuggestPerformanceTests.java b/tests/src/com/android/inputmethod/latin/SuggestPerformanceTests.java index 99bcc615e..7af566b03 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestPerformanceTests.java +++ b/tests/src/com/android/inputmethod/latin/SuggestPerformanceTests.java @@ -18,6 +18,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.latin.tests.R; import android.content.res.AssetFileDescriptor; +import android.content.res.Configuration; import android.text.TextUtils; import android.util.Slog; @@ -38,7 +39,7 @@ public class SuggestPerformanceTests extends SuggestTestsBase { final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test); mHelper = new SuggestHelper( getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(), - createKeyboardId(Locale.US)); + createKeyboardId(Locale.US, Configuration.ORIENTATION_PORTRAIT)); loadString(R.raw.testtext); } diff --git a/tests/src/com/android/inputmethod/latin/SuggestTests.java b/tests/src/com/android/inputmethod/latin/SuggestTests.java index 6e9a12797..cf4558090 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestTests.java +++ b/tests/src/com/android/inputmethod/latin/SuggestTests.java @@ -19,6 +19,7 @@ package com.android.inputmethod.latin; import com.android.inputmethod.latin.tests.R; import android.content.res.AssetFileDescriptor; +import android.content.res.Configuration; import java.util.Locale; @@ -31,7 +32,7 @@ public class SuggestTests extends SuggestTestsBase { final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test); mHelper = new SuggestHelper( getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(), - createKeyboardId(Locale.US)); + createKeyboardId(Locale.US, Configuration.ORIENTATION_PORTRAIT)); mHelper.setCorrectionMode(Suggest.CORRECTION_FULL_BIGRAM); } diff --git a/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java b/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java index 7d61d00f0..058a3e7c0 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java @@ -20,6 +20,7 @@ import android.content.res.AssetFileDescriptor; import android.content.res.Configuration; import android.test.AndroidTestCase; import android.text.TextUtils; +import android.util.DisplayMetrics; import android.view.inputmethod.EditorInfo; import com.android.inputmethod.keyboard.KeyboardId; @@ -37,12 +38,22 @@ public class SuggestTestsBase extends AndroidTestCase { mTestPackageFile = new File(getTestContext().getApplicationInfo().sourceDir); } - protected KeyboardId createKeyboardId(Locale locale) { - final int displayWidth = getContext().getResources().getDisplayMetrics().widthPixels; + protected KeyboardId createKeyboardId(Locale locale, int orientation) { + final DisplayMetrics dm = getContext().getResources().getDisplayMetrics(); + final int width; + if (orientation == Configuration.ORIENTATION_LANDSCAPE) { + width = Math.max(dm.widthPixels, dm.heightPixels); + } else if (orientation == Configuration.ORIENTATION_PORTRAIT) { + width = Math.min(dm.widthPixels, dm.heightPixels); + } else { + fail("Orientation should be ORIENTATION_LANDSCAPE or ORIENTATION_PORTRAIT: " + + "orientation=" + orientation); + return null; + } return new KeyboardId(locale.toString() + " keyboard", - com.android.inputmethod.latin.R.xml.kbd_qwerty, locale, - Configuration.ORIENTATION_LANDSCAPE, displayWidth, KeyboardId.MODE_TEXT, - new EditorInfo(), false, KeyboardId.F2KEY_MODE_NONE, false, false, false); + com.android.inputmethod.latin.R.xml.kbd_qwerty, locale, orientation, width, + KeyboardId.MODE_TEXT, new EditorInfo(), false, KeyboardId.F2KEY_MODE_NONE, + false, false, false); } protected InputStream openTestRawResource(int resIdInTest) { diff --git a/tests/src/com/android/inputmethod/latin/UserBigramSuggestTests.java b/tests/src/com/android/inputmethod/latin/UserBigramSuggestTests.java index 9bd85385e..0b97e41fd 100644 --- a/tests/src/com/android/inputmethod/latin/UserBigramSuggestTests.java +++ b/tests/src/com/android/inputmethod/latin/UserBigramSuggestTests.java @@ -15,9 +15,10 @@ */ package com.android.inputmethod.latin; -import com.android.inputmethod.latin.tests.R; - import android.content.res.AssetFileDescriptor; +import android.content.res.Configuration; + +import com.android.inputmethod.latin.tests.R; import java.util.Locale; @@ -34,7 +35,8 @@ public class UserBigramSuggestTests extends SuggestTestsBase { final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test); mHelper = new UserBigramSuggestHelper( getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(), - MAX_DATA, DELETE_DATA, createKeyboardId(Locale.US)); + MAX_DATA, DELETE_DATA, + createKeyboardId(Locale.US, Configuration.ORIENTATION_PORTRAIT)); } /************************** Tests ************************/