Add orientation to regression tests
Change-Id: Iaf2cb7841c4622eedeb4bf880d55988bfa61e823main
parent
db2c0919cf
commit
3c70185b1b
|
@ -18,6 +18,7 @@ package com.android.inputmethod.latin;
|
||||||
import com.android.inputmethod.latin.tests.R;
|
import com.android.inputmethod.latin.tests.R;
|
||||||
|
|
||||||
import android.content.res.AssetFileDescriptor;
|
import android.content.res.AssetFileDescriptor;
|
||||||
|
import android.content.res.Configuration;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Slog;
|
import android.util.Slog;
|
||||||
|
|
||||||
|
@ -38,7 +39,7 @@ public class SuggestPerformanceTests extends SuggestTestsBase {
|
||||||
final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test);
|
final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test);
|
||||||
mHelper = new SuggestHelper(
|
mHelper = new SuggestHelper(
|
||||||
getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(),
|
getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(),
|
||||||
createKeyboardId(Locale.US));
|
createKeyboardId(Locale.US, Configuration.ORIENTATION_PORTRAIT));
|
||||||
loadString(R.raw.testtext);
|
loadString(R.raw.testtext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ package com.android.inputmethod.latin;
|
||||||
import com.android.inputmethod.latin.tests.R;
|
import com.android.inputmethod.latin.tests.R;
|
||||||
|
|
||||||
import android.content.res.AssetFileDescriptor;
|
import android.content.res.AssetFileDescriptor;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -31,7 +32,7 @@ public class SuggestTests extends SuggestTestsBase {
|
||||||
final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test);
|
final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test);
|
||||||
mHelper = new SuggestHelper(
|
mHelper = new SuggestHelper(
|
||||||
getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(),
|
getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(),
|
||||||
createKeyboardId(Locale.US));
|
createKeyboardId(Locale.US, Configuration.ORIENTATION_PORTRAIT));
|
||||||
mHelper.setCorrectionMode(Suggest.CORRECTION_FULL_BIGRAM);
|
mHelper.setCorrectionMode(Suggest.CORRECTION_FULL_BIGRAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.content.res.AssetFileDescriptor;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.util.DisplayMetrics;
|
||||||
import android.view.inputmethod.EditorInfo;
|
import android.view.inputmethod.EditorInfo;
|
||||||
|
|
||||||
import com.android.inputmethod.keyboard.KeyboardId;
|
import com.android.inputmethod.keyboard.KeyboardId;
|
||||||
|
@ -37,12 +38,22 @@ public class SuggestTestsBase extends AndroidTestCase {
|
||||||
mTestPackageFile = new File(getTestContext().getApplicationInfo().sourceDir);
|
mTestPackageFile = new File(getTestContext().getApplicationInfo().sourceDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KeyboardId createKeyboardId(Locale locale) {
|
protected KeyboardId createKeyboardId(Locale locale, int orientation) {
|
||||||
final int displayWidth = getContext().getResources().getDisplayMetrics().widthPixels;
|
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",
|
return new KeyboardId(locale.toString() + " keyboard",
|
||||||
com.android.inputmethod.latin.R.xml.kbd_qwerty, locale,
|
com.android.inputmethod.latin.R.xml.kbd_qwerty, locale, orientation, width,
|
||||||
Configuration.ORIENTATION_LANDSCAPE, displayWidth, KeyboardId.MODE_TEXT,
|
KeyboardId.MODE_TEXT, new EditorInfo(), false, KeyboardId.F2KEY_MODE_NONE,
|
||||||
new EditorInfo(), false, KeyboardId.F2KEY_MODE_NONE, false, false, false);
|
false, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected InputStream openTestRawResource(int resIdInTest) {
|
protected InputStream openTestRawResource(int resIdInTest) {
|
||||||
|
|
|
@ -15,9 +15,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.android.inputmethod.latin;
|
package com.android.inputmethod.latin;
|
||||||
import com.android.inputmethod.latin.tests.R;
|
|
||||||
|
|
||||||
import android.content.res.AssetFileDescriptor;
|
import android.content.res.AssetFileDescriptor;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.tests.R;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -34,7 +35,8 @@ public class UserBigramSuggestTests extends SuggestTestsBase {
|
||||||
final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test);
|
final AssetFileDescriptor dict = openTestRawResourceFd(R.raw.test);
|
||||||
mHelper = new UserBigramSuggestHelper(
|
mHelper = new UserBigramSuggestHelper(
|
||||||
getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(),
|
getContext(), mTestPackageFile, dict.getStartOffset(), dict.getLength(),
|
||||||
MAX_DATA, DELETE_DATA, createKeyboardId(Locale.US));
|
MAX_DATA, DELETE_DATA,
|
||||||
|
createKeyboardId(Locale.US, Configuration.ORIENTATION_PORTRAIT));
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************** Tests ************************/
|
/************************** Tests ************************/
|
||||||
|
|
Loading…
Reference in New Issue