Add orientation to regression tests
Change-Id: Iaf2cb7841c4622eedeb4bf880d55988bfa61e823
This commit is contained in:
parent
db2c0919cf
commit
3c70185b1b
4 changed files with 25 additions and 10 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 ************************/
|
||||
|
|
Loading…
Reference in a new issue