aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore7
-rw-r--r--Android.bp39
-rw-r--r--Android.mk16
-rw-r--r--CleanSpec.mk3
-rw-r--r--MODULE_LICENSE_APACHE2 (renamed from java/MODULE_LICENSE_APACHE2)0
-rw-r--r--NOTICE192
-rw-r--r--OWNERS6
-rw-r--r--build.gradle110
-rw-r--r--common/Android.bp21
-rw-r--r--common/Android.mk28
-rw-r--r--gradle/wrapper/gradle-wrapper.jarbin0 -> 53636 bytes
-rw-r--r--gradle/wrapper/gradle-wrapper.properties6
-rwxr-xr-xgradlew160
-rw-r--r--gradlew.bat90
-rw-r--r--java/Android.bp46
-rw-r--r--java/Android.mk46
-rw-r--r--java/AndroidManifest.xml5
-rw-r--r--java/res/layout/emoji_palettes_view.xml2
-rw-r--r--java/res/layout/user_dictionary_add_word.xml90
-rw-r--r--java/res/values-de/strings-emoji-descriptions.xml6
-rw-r--r--java/res/values-pt/strings-emoji-descriptions.xml2
-rw-r--r--java/shared.keystorebin0 -> 2926 bytes
-rw-r--r--java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java2
-rw-r--r--java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java6
-rw-r--r--java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java10
-rw-r--r--java/src/com/android/inputmethod/compat/AppWorkaroundsHelper.java (renamed from java-overridable/src/com/android/inputmethod/compat/AppWorkaroundsHelper.java)0
-rw-r--r--java/src/com/android/inputmethod/compat/UserManagerCompatUtils.java2
-rw-r--r--java/src/com/android/inputmethod/compat/ViewCompatUtils.java2
-rw-r--r--java/src/com/android/inputmethod/dictionarypack/DictionaryPackConstants.java (renamed from java-overridable/src/com/android/inputmethod/dictionarypack/DictionaryPackConstants.java)0
-rw-r--r--java/src/com/android/inputmethod/dictionarypack/MetadataUriGetter.java (renamed from java-overridable/src/com/android/inputmethod/dictionarypack/MetadataUriGetter.java)0
-rw-r--r--java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesAdapter.java2
-rw-r--r--java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java2
-rw-r--r--java/src/com/android/inputmethod/latin/DictionaryFacilitatorProvider.java (renamed from java-overridable/src/com/android/inputmethod/latin/DictionaryFacilitatorProvider.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/PersonalDictionaryLookup.java651
-rw-r--r--java/src/com/android/inputmethod/latin/about/AboutPreferences.java (renamed from java-overridable/src/com/android/inputmethod/latin/about/AboutPreferences.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/accounts/AccountStateChangedListener.java (renamed from java-overridable/src/com/android/inputmethod/latin/accounts/AccountStateChangedListener.java)2
-rw-r--r--java/src/com/android/inputmethod/latin/accounts/LoginAccountUtils.java (renamed from java-overridable/src/com/android/inputmethod/latin/accounts/LoginAccountUtils.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/define/DebugFlags.java (renamed from java-overridable/src/com/android/inputmethod/latin/define/DebugFlags.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/define/DecoderSpecificConstants.java (renamed from java-overridable/src/com/android/inputmethod/latin/define/DecoderSpecificConstants.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/define/JniLibName.java (renamed from java-overridable/src/com/android/inputmethod/latin/define/JniLibName.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/define/ProductionFlags.java (renamed from java-overridable/src/com/android/inputmethod/latin/define/ProductionFlags.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/makedict/FormatSpec.java3
-rw-r--r--java/src/com/android/inputmethod/latin/permissions/PermissionsActivity.java4
-rw-r--r--java/src/com/android/inputmethod/latin/permissions/PermissionsUtil.java6
-rw-r--r--java/src/com/android/inputmethod/latin/settings/AdditionalFeaturesSettingUtils.java (renamed from java-overridable/src/com/android/inputmethod/latin/settings/AdditionalFeaturesSettingUtils.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/settings/CustomInputStyleSettingsFragment.java2
-rw-r--r--java/src/com/android/inputmethod/latin/settings/SettingsActivity.java2
-rw-r--r--java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java2
-rw-r--r--java/src/com/android/inputmethod/latin/setup/SetupStepIndicatorView.java2
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java2
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java2
-rw-r--r--java/src/com/android/inputmethod/latin/touchinputconsumer/GestureConsumer.java (renamed from java-overridable/src/com/android/inputmethod/latin/touchinputconsumer/GestureConsumer.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/utils/DictionaryHeaderUtils.java (renamed from java-overridable/src/com/android/inputmethod/latin/utils/DictionaryHeaderUtils.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/utils/FeedbackUtils.java (renamed from java-overridable/src/com/android/inputmethod/latin/utils/FeedbackUtils.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/utils/FileTransforms.java (renamed from java-overridable/src/com/android/inputmethod/latin/utils/FileTransforms.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/utils/ManagedProfileUtils.java (renamed from java-overridable/src/com/android/inputmethod/latin/utils/ManagedProfileUtils.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/utils/MetadataFileUriGetter.java (renamed from java-overridable/src/com/android/inputmethod/latin/utils/MetadataFileUriGetter.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/utils/StatsUtils.java (renamed from java-overridable/src/com/android/inputmethod/latin/utils/StatsUtils.java)0
-rw-r--r--java/src/com/android/inputmethod/latin/utils/StatsUtilsManager.java (renamed from java-overridable/src/com/android/inputmethod/latin/utils/StatsUtilsManager.java)0
-rw-r--r--java/src/com/android/inputmethodcommon/InputMethodSettingsActivity.java94
-rw-r--r--java/src/com/android/inputmethodcommon/InputMethodSettingsFragment.java95
-rw-r--r--java/src/com/android/inputmethodcommon/InputMethodSettingsImpl.java179
-rw-r--r--java/src/com/android/inputmethodcommon/InputMethodSettingsInterface.java63
-rw-r--r--native/Android.mk1
-rw-r--r--native/dicttoolkit/Android.bp94
-rw-r--r--native/dicttoolkit/Android.mk66
-rw-r--r--native/dicttoolkit/CleanupNativeFileList.mk17
-rw-r--r--native/dicttoolkit/NativeFileList.mk44
-rw-r--r--native/dicttoolkit/UnitTests.mk65
-rw-r--r--native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.cpp2
-rw-r--r--native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.h2
-rw-r--r--native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict_pt_node.h2
-rw-r--r--native/dicttoolkit/tests/offdevice_intermediate_dict/offdevice_intermediate_dict_test.cpp2
-rw-r--r--native/jni/Android.bp215
-rw-r--r--native/jni/Android.mk103
-rw-r--r--native/jni/Application.mk1
-rw-r--r--native/jni/CleanupNativeFileList.mk19
-rw-r--r--native/jni/HostUnitTests.mk63
-rw-r--r--native/jni/NativeFileList.mk146
-rw-r--r--native/jni/TargetUnitTests.mk50
-rw-r--r--native/jni/src/defines.h4
-rw-r--r--native/jni/src/dictionary/structure/v4/ver4_patricia_trie_policy.cpp4
-rw-r--r--native/jni/src/dictionary/utils/binary_dictionary_bigrams_iterator.h2
-rw-r--r--native/jni/src/dictionary/utils/binary_dictionary_shortcut_iterator.h2
-rw-r--r--native/jni/tests/dictionary/structure/v4/content/language_model_dict_content_test.cpp2
-rw-r--r--tests/Android.bp46
-rw-r--r--tests/Android.mk46
-rw-r--r--tests/AndroidManifest.xml7
-rw-r--r--tests/AndroidTest.xml40
-rw-r--r--tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java17
-rw-r--r--tests/src/com/android/inputmethod/compat/SuggestionSpanUtilsTest.java24
-rw-r--r--tests/src/com/android/inputmethod/compat/TextInfoCompatUtilsTests.java14
-rw-r--r--tests/src/com/android/inputmethod/keyboard/KeyboardLayoutTest.java10
-rw-r--r--tests/src/com/android/inputmethod/keyboard/KeyboardThemeTests.java42
-rw-r--r--tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderAutoOrderTests.java156
-rw-r--r--tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderFixedOrderTests.java167
-rw-r--r--tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderMaxOrderTests.java153
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/HermiteInterpolatorTests.java141
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSetTests.java27
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/MatrixUtilsTests.java33
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecSplitTests.java33
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecStringReferenceTests.java39
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueueTests.java26
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/SmoothingUtilsTests.java16
-rw-r--r--tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java49
-rw-r--r--tests/src/com/android/inputmethod/latin/ContactsContentObserverTest.java6
-rw-r--r--tests/src/com/android/inputmethod/latin/ContactsDictionaryUtilsTest.java5
-rw-r--r--tests/src/com/android/inputmethod/latin/ContactsManagerTest.java25
-rw-r--r--tests/src/com/android/inputmethod/latin/DictionaryFacilitatorLruCacheTests.java20
-rw-r--r--tests/src/com/android/inputmethod/latin/NgramContextTests.java24
-rw-r--r--tests/src/com/android/inputmethod/latin/PersonalDictionaryLookupTest.java492
-rw-r--r--tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java41
-rw-r--r--tests/src/com/android/inputmethod/latin/RichInputMethodSubtypeTests.java40
-rw-r--r--tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java20
-rw-r--r--tests/src/com/android/inputmethod/latin/WordComposerTests.java16
-rw-r--r--tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java34
-rw-r--r--tests/src/com/android/inputmethod/latin/common/InputPointersTests.java26
-rw-r--r--tests/src/com/android/inputmethod/latin/common/ResizableIntArrayTests.java28
-rw-r--r--tests/src/com/android/inputmethod/latin/common/StringUtilsTests.java32
-rw-r--r--tests/src/com/android/inputmethod/latin/common/UnicodeSurrogateTests.java15
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java677
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/BinaryDictUtils.java80
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/Ver2DictEncoder.java279
-rw-r--r--tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java133
-rw-r--r--tests/src/com/android/inputmethod/latin/network/BlockingHttpClientTests.java23
-rw-r--r--tests/src/com/android/inputmethod/latin/network/HttpUrlConnectionBuilderTests.java35
-rw-r--r--tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java47
-rw-r--r--tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java49
-rw-r--r--tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java41
-rw-r--r--tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java26
-rw-r--r--tests/src/com/android/inputmethod/latin/touchinputconsumer/NullGestureConsumerTests.java15
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtilsTests.java27
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/AsyncResultHolderTests.java17
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java18
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/CollectionUtilsTests.java18
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/DictionaryInfoUtilsTests.java20
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/ExecutorUtilsTests.java14
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java34
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/JsonUtilsTests.java13
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/LanguageOnSpacebarUtilsTests.java29
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/RecapitalizeStatusTests.java14
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/ResourceUtilsTests.java16
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/SpannableStringUtilsTests.java28
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java40
-rw-r--r--tools/Android.mk15
-rw-r--r--tools/EditTextVariations/Android.bp22
-rw-r--r--tools/EditTextVariations/AndroidManifest.xml47
-rw-r--r--tools/EditTextVariations/assets/Theme.css56
-rw-r--r--tools/EditTextVariations/assets/Theme_Black.css56
-rw-r--r--tools/EditTextVariations/assets/Theme_Holo.css56
-rw-r--r--tools/EditTextVariations/assets/Theme_Holo_Light.css56
-rw-r--r--tools/EditTextVariations/assets/Theme_Light.css56
-rw-r--r--tools/EditTextVariations/assets/Theme_Material.css56
-rw-r--r--tools/EditTextVariations/assets/Theme_Material_Light.css56
-rw-r--r--tools/EditTextVariations/assets/webview.html96
-rw-r--r--tools/EditTextVariations/res/drawable-hdpi/ic_launcher.pngbin0 -> 4111 bytes
-rw-r--r--tools/EditTextVariations/res/drawable-mdpi/ic_launcher.pngbin0 -> 2258 bytes
-rw-r--r--tools/EditTextVariations/res/drawable-xhdpi/ic_launcher.pngbin0 -> 5963 bytes
-rw-r--r--tools/EditTextVariations/res/drawable-xxhdpi/ic_launcher.pngbin0 -> 10916 bytes
-rw-r--r--tools/EditTextVariations/res/layout/main.xml298
-rw-r--r--tools/EditTextVariations/res/values-v11/donottranslate.xml23
-rw-r--r--tools/EditTextVariations/res/values-v14/themes.xml23
-rw-r--r--tools/EditTextVariations/res/values-v27/themes.xml27
-rw-r--r--tools/EditTextVariations/res/values/countries.xml263
-rw-r--r--tools/EditTextVariations/res/values/strings.xml40
-rw-r--r--tools/EditTextVariations/res/values/themes.xml23
-rw-r--r--tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/EchoingTextWatcher.java86
-rw-r--r--tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/EditTextVariations.java479
-rw-r--r--tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/FinalClassField.java64
-rw-r--r--tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/InstanceMethod.java83
-rw-r--r--tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/MultiLineShortMessageEditText.java46
-rw-r--r--tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/NotificationBroadcastReceiver.java31
-rw-r--r--tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/NotificationUtils.java122
-rw-r--r--tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/ThemeItem.java68
-rw-r--r--tools/dicttool/Android.bp32
-rw-r--r--tools/dicttool/Android.mk87
-rw-r--r--tools/dicttool/NativeLib.mk46
-rw-r--r--tools/dicttool/compat/com/android/inputmethod/latin/define/JniLibName.java2
-rw-r--r--tools/dicttool/etc/Android.mk19
-rwxr-xr-xtools/dicttool/etc/dicttool_aosp67
-rwxr-xr-xtools/dicttool/etc/makedict_aosp18
-rw-r--r--tools/dicttool/etc/manifest.txt1
-rw-r--r--tools/dicttool/src/com/android/inputmethod/latin/dicttool/CombinedInputOutput.java25
-rw-r--r--tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java3
-rw-r--r--tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java20
-rw-r--r--tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java14
-rw-r--r--tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictEncoderFlattenTreeTests.java10
-rw-r--r--tools/dicttool/tests/com/android/inputmethod/latin/makedict/FusionDictionaryTest.java2
-rw-r--r--tools/make-keyboard-text/Android.bp22
-rw-r--r--tools/make-keyboard-text/Android.mk25
-rw-r--r--tools/make-keyboard-text/etc/Android.mk20
-rwxr-xr-xtools/make-keyboard-text/etc/make-keyboard-text63
-rw-r--r--tools/make-keyboard-text/etc/manifest.txt1
194 files changed, 6463 insertions, 2783 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 000000000..037fe9275
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,7 @@
+# Gradle
+.externalNativeBuild/
+.gradle/
+.idea/
+LatinIME.iml
+build/
+local.properties
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 000000000..3abd6c19f
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,39 @@
+// Copyright (C) 2018 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+filegroup {
+ name: "dicttool_deps",
+ srcs: [
+ "java/src/com/android/inputmethod/latin/makedict/**/*.java",
+
+ // Dependencies for Dicttool. Most of these files are needed by BinaryDictionary.java. Note that
+ // a significant part of the dependencies are mocked in the compat/ directory, with empty or
+ // nearly-empty implementations, for parts that we don't use in Dicttool.
+ "java/src/com/android/inputmethod/latin/BinaryDictionary.java",
+ "java/src/com/android/inputmethod/latin/DicTraverseSession.java",
+ "java/src/com/android/inputmethod/latin/Dictionary.java",
+ "java/src/com/android/inputmethod/latin/NgramContext.java",
+ "java/src/com/android/inputmethod/latin/SuggestedWords.java",
+ "java/src/com/android/inputmethod/latin/settings/SettingsValuesForSuggestion.java",
+ "java/src/com/android/inputmethod/latin/utils/BinaryDictionaryUtils.java",
+ "java/src/com/android/inputmethod/latin/utils/CombinedFormatUtils.java",
+ "java/src/com/android/inputmethod/latin/utils/JniUtils.java",
+
+ "java/src/com/android/inputmethod/latin/define/DebugFlags.java",
+ "java/src/com/android/inputmethod/latin/define/DecoderSpecificConstants.java",
+
+ "tests/src/com/android/inputmethod/latin/utils/ByteArrayDictBuffer.java",
+ "tests/src/com/android/inputmethod/latin/makedict/**/*.java",
+ ],
+}
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 17eeba8f0..000000000
--- a/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-subdirs := common native java tests tools
-include $(call all-named-subdir-makefiles, $(subdirs))
diff --git a/CleanSpec.mk b/CleanSpec.mk
index be13c30aa..98df622fa 100644
--- a/CleanSpec.mk
+++ b/CleanSpec.mk
@@ -52,6 +52,9 @@ $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libjni_latinim
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libjni_latinime_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libjni_latinime_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libjni_latinime_intermediates)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/LatinIME)
+$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libjni_latinime.so)
+
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
diff --git a/java/MODULE_LICENSE_APACHE2 b/MODULE_LICENSE_APACHE2
index e69de29bb..e69de29bb 100644
--- a/java/MODULE_LICENSE_APACHE2
+++ b/MODULE_LICENSE_APACHE2
diff --git a/NOTICE b/NOTICE
new file mode 100644
index 000000000..aa325547e
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,192 @@
+
+ Copyright (c) 2008, The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+
+Includes Dictionaries © Lexiteria LLC. Used by permission.
diff --git a/OWNERS b/OWNERS
new file mode 100644
index 000000000..3d485186b
--- /dev/null
+++ b/OWNERS
@@ -0,0 +1,6 @@
+# Recommended reviewers for general changes.
+# takaoka@google.com
+# yukawa@google.com
+#
+# Recommended reviewers for non-trivial build rule changes.
+# dwillemsen@google.com
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 000000000..ab631c0ef
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,110 @@
+buildscript {
+ repositories {
+ google()
+ jcenter()
+ }
+ dependencies {
+ classpath 'com.android.tools.build:gradle:3.2.0-beta03'
+ }
+}
+
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 28
+ buildToolsVersion '28.0.0'
+
+ // Required if using classes in android.test.runner
+ useLibrary 'android.test.runner'
+
+ // Required if using classes in android.test.base
+ useLibrary 'android.test.base'
+
+ // Required if using classes in android.test.mock
+ useLibrary 'android.test.mock'
+
+ defaultConfig {
+ minSdkVersion 21
+ targetSdkVersion 28
+ versionName "1.0"
+
+ applicationId 'com.android.inputmethod.latin'
+ testApplicationId 'com.android.inputmethod.latin.tests'
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ vectorDrawables.useSupportLibrary = false
+
+ signingConfig signingConfigs.debug
+ }
+
+ signingConfigs {
+ debug {
+ storeFile file("java/shared.keystore")
+ }
+ }
+
+ buildTypes {
+ debug {
+ minifyEnabled false
+ }
+ release {
+ proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard.flags'
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+ flavorDimensions "default"
+
+ sourceSets {
+ main {
+ res.srcDirs = ['java/res']
+ java.srcDirs = ['common/src', 'java/src']
+ manifest.srcFile 'java/AndroidManifest.xml'
+ }
+
+ androidTest {
+ res.srcDirs = ['tests/res']
+ java.srcDirs = ['tests/src']
+ manifest.srcFile "tests/AndroidManifest.xml"
+ }
+ }
+
+ lintOptions {
+ checkReleaseBuilds false
+ }
+
+ aaptOptions {
+ noCompress 'dict'
+ }
+
+ externalNativeBuild {
+ ndkBuild {
+ path 'native/jni/Android.mk'
+ }
+ }
+}
+
+repositories {
+ maven { url "../../../prebuilts/fullsdk-darwin/extras/android/m2repository" }
+ maven { url "../../../prebuilts/fullsdk-linux/extras/android/m2repository" }
+ mavenCentral()
+ google()
+ jcenter()
+}
+
+dependencies {
+ implementation 'androidx.legacy:legacy-support-v4:+'
+ implementation 'com.google.code.findbugs:jsr305:3.0.2'
+
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation "org.mockito:mockito-core:1.9.5"
+ androidTestImplementation 'com.google.dexmaker:dexmaker:1.2'
+ androidTestImplementation 'com.google.dexmaker:dexmaker-mockito:1.2'
+ androidTestImplementation 'com.android.support.test:runner:1.0.2'
+ androidTestImplementation 'com.android.support.test:rules:1.0.2'
+ androidTestImplementation 'com.android.support.test.uiautomator:uiautomator-v18:2.1.3'
+ androidTestImplementation "com.android.support:support-annotations:27.1.1"
+}
diff --git a/common/Android.bp b/common/Android.bp
new file mode 100644
index 000000000..925eef7fd
--- /dev/null
+++ b/common/Android.bp
@@ -0,0 +1,21 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+java_library {
+ name: "latinime-common",
+ host_supported: true,
+ srcs: ["src/**/*.java"],
+ static_libs: ["jsr305"],
+ sdk_version: "21",
+}
diff --git a/common/Android.mk b/common/Android.mk
deleted file mode 100644
index 132a22358..000000000
--- a/common/Android.mk
+++ /dev/null
@@ -1,28 +0,0 @@
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-LOCAL_MODULE := latinime-common
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_STATIC_JAVA_LIBRARIES := jsr305
-LOCAL_SDK_VERSION := 21
-include $(BUILD_STATIC_JAVA_LIBRARY)
-
-# Also build a host side library
-include $(CLEAR_VARS)
-LOCAL_MODULE := latinime-common-host
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_STATIC_JAVA_LIBRARIES := jsr305lib
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 000000000..13372aef5
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.jar
Binary files differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 000000000..33c5632be
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Sat Jun 23 15:45:27 PDT 2018
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
diff --git a/gradlew b/gradlew
new file mode 100755
index 000000000..9d82f7891
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,160 @@
+#!/usr/bin/env bash
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn ( ) {
+ echo "$*"
+}
+
+die ( ) {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+esac
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
+function splitJvmOpts() {
+ JVM_OPTS=("$@")
+}
+eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
+JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+
+exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 000000000..aec99730b
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,90 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/java/Android.bp b/java/Android.bp
new file mode 100644
index 000000000..f41e94af0
--- /dev/null
+++ b/java/Android.bp
@@ -0,0 +1,46 @@
+// Copyright (C) 2011 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_app {
+ name: "LatinIME",
+
+ srcs: ["src/**/*.java"],
+
+ certificate: "shared",
+
+ jni_libs: ["libjni_latinime"],
+
+ static_libs: [
+ "android-common",
+ "jsr305",
+ "latinime-common",
+ "androidx.legacy_legacy-support-v4",
+ ],
+
+ // Do not compress dictionary files to mmap dict data runtime
+ aaptflags: ["-0 .dict"],
+
+ // Include all the resources regardless of system supported locales
+ aapt_include_all_resources: true,
+
+ min_sdk_version: "14",
+ target_sdk_version: "23",
+ sdk_version: "current",
+
+ product_specific: true,
+
+ optimize: {
+ proguard_flags_files: ["proguard.flags"],
+ },
+}
diff --git a/java/Android.mk b/java/Android.mk
deleted file mode 100644
index 154f3a20c..000000000
--- a/java/Android.mk
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src ../java-overridable/src)
-
-LOCAL_PACKAGE_NAME := LatinIME
-
-LOCAL_CERTIFICATE := shared
-
-LOCAL_JNI_SHARED_LIBRARIES := libjni_latinime
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- android-common inputmethod-common jsr305 latinime-common
-
-LOCAL_STATIC_ANDROID_LIBRARIES := \
- android-support-v4
-
-LOCAL_USE_AAPT2 := true
-
-# Do not compress dictionary files to mmap dict data runtime
-LOCAL_AAPT_FLAGS := -0 .dict
-
-# Include all the resources regardless of system supported locales
-LOCAL_AAPT_INCLUDE_ALL_RESOURCES := true
-
-LOCAL_SDK_VERSION := current
-
-LOCAL_PROGUARD_FLAG_FILES := proguard.flags
-
-include $(BUILD_PACKAGE)
diff --git a/java/AndroidManifest.xml b/java/AndroidManifest.xml
index dedece55c..79d337310 100644
--- a/java/AndroidManifest.xml
+++ b/java/AndroidManifest.xml
@@ -16,9 +16,10 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
coreApp="true"
- package="com.android.inputmethod.latin">
+ package="com.android.inputmethod.latin"
+ android:versionCode="28">
- <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="23" />
+ <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.DOWNLOAD_WITHOUT_NOTIFICATION" />
diff --git a/java/res/layout/emoji_palettes_view.xml b/java/res/layout/emoji_palettes_view.xml
index 26cc042ab..7c5f6c0a6 100644
--- a/java/res/layout/emoji_palettes_view.xml
+++ b/java/res/layout/emoji_palettes_view.xml
@@ -71,7 +71,7 @@
android:soundEffectsEnabled="false"
android:contentDescription="@string/spoken_description_delete" />
</LinearLayout>
- <android.support.v4.view.ViewPager
+ <androidx.viewpager.widget.ViewPager
android:id="@+id/emoji_keyboard_pager"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
diff --git a/java/res/layout/user_dictionary_add_word.xml b/java/res/layout/user_dictionary_add_word.xml
deleted file mode 100644
index 615fde589..000000000
--- a/java/res/layout/user_dictionary_add_word.xml
+++ /dev/null
@@ -1,90 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2013 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- -->
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/user_dict_settings_add_dialog_top"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <com.android.internal.widget.DialogTitle
- style="?android:attr/windowTitleStyle"
- android:layout_width="match_parent"
- android:layout_height="64dip"
- android:layout_marginEnd="16dip"
- android:layout_marginStart="16dip"
- android:ellipsize="end"
- android:gravity="center_vertical|start"
- android:singleLine="true"
- android:text="@string/user_dict_settings_add_dialog_title" />
-
- <View
- android:layout_width="match_parent"
- android:layout_height="2dip"
- android:background="@android:color/holo_blue_light" />
- </LinearLayout>
-
- <EditText
- android:id="@+id/user_dictionary_add_word_text"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_gravity="fill_horizontal|center_vertical"
- android:layout_marginBottom="8dip"
- android:layout_marginStart="8dip"
- android:layout_marginTop="8dip"
- android:hint="@string/user_dict_settings_add_word_hint"
- android:imeOptions="flagNoFullscreen"
- android:inputType="textNoSuggestions"
- android:maxLength="@integer/config_user_dictionary_max_word_length" >
-
- <requestFocus />
- </EditText>
-
- <LinearLayout
- style="?android:attr/buttonBarStyle"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:measureWithLargestChild="true"
- android:orientation="horizontal" >
-
- <Button
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_gravity="start"
- android:layout_weight="1"
- android:maxLines="2"
- android:onClick="onClickCancel"
- android:text="@string/cancel"
- android:textSize="14sp" />
-
- <Button
- style="?android:attr/buttonBarButtonStyle"
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_gravity="end"
- android:layout_weight="1"
- android:maxLines="2"
- android:onClick="onClickConfirm"
- android:text="@string/user_dict_settings_add_dialog_confirm"
- android:textSize="14sp" />
- </LinearLayout>
-
-</LinearLayout> \ No newline at end of file
diff --git a/java/res/values-de/strings-emoji-descriptions.xml b/java/res/values-de/strings-emoji-descriptions.xml
index 0e4699b7c..75c8efae7 100644
--- a/java/res/values-de/strings-emoji-descriptions.xml
+++ b/java/res/values-de/strings-emoji-descriptions.xml
@@ -249,7 +249,7 @@
<string name="spoken_emoji_1F194" msgid="4903128609556175887">"Quadrat mit \"ID\""</string>
<string name="spoken_emoji_1F195" msgid="1433142500411060924">"Quadrat mit \"New\""</string>
<string name="spoken_emoji_1F196" msgid="8825160701159634202">"Quadrat mit \"NG\" (No Good)"</string>
- <string name="spoken_emoji_1F197" msgid="7841079241554176535">"Quadrat mit \"OK\""</string>
+ <string name="spoken_emoji_1F197" msgid="7841079241554176535">"Quadrat mit \"Ok\""</string>
<string name="spoken_emoji_1F198" msgid="7020298909426960622">"Quadrat mit \"SOS\""</string>
<string name="spoken_emoji_1F199" msgid="5971252667136235630">"Quadrat mit \"UP\" und Ausrufezeichen"</string>
<string name="spoken_emoji_1F19A" msgid="4557270135899843959">"Quadrat mit \"VS\" (Versus)"</string>
@@ -651,7 +651,7 @@
<string name="spoken_emoji_1F449" msgid="4764447975177805991">"Handrückseite mit nach rechts deutendem Zeigefinger"</string>
<string name="spoken_emoji_1F44A" msgid="7197417095486424841">"Faust"</string>
<string name="spoken_emoji_1F44B" msgid="1975968945250833117">"Winkende Hand"</string>
- <string name="spoken_emoji_1F44C" msgid="3185919567897876562">"Handzeichen für \"OK\""</string>
+ <string name="spoken_emoji_1F44C" msgid="3185919567897876562">"Handzeichen für \"Ok\""</string>
<string name="spoken_emoji_1F44D" msgid="6182553970602667815">"Daumen hoch"</string>
<string name="spoken_emoji_1F44E" msgid="8030851867365111809">"Daumen runter"</string>
<string name="spoken_emoji_1F44F" msgid="5148753662268213389">"Klatschende Hände"</string>
@@ -1082,7 +1082,7 @@
<!-- no translation found for spoken_emoji_1F644 (446284817942609022) -->
<skip />
<string name="spoken_emoji_1F645" msgid="5202090629227587076">"Gesicht mit Nicht in Ordnung-Geste"</string>
- <string name="spoken_emoji_1F646" msgid="6734425134415138134">"Gesicht mit OK-Geste"</string>
+ <string name="spoken_emoji_1F646" msgid="6734425134415138134">"Gesicht mit Ok-Geste"</string>
<string name="spoken_emoji_1F647" msgid="1090285518444205483">"Sich tief verneigende Person"</string>
<string name="spoken_emoji_1F648" msgid="8978535230610522356">"Nichts-Sehen-Affe"</string>
<string name="spoken_emoji_1F649" msgid="8486145279809495102">"Nichts-Hören-Affe"</string>
diff --git a/java/res/values-pt/strings-emoji-descriptions.xml b/java/res/values-pt/strings-emoji-descriptions.xml
index e6f51a92a..05d373974 100644
--- a/java/res/values-pt/strings-emoji-descriptions.xml
+++ b/java/res/values-pt/strings-emoji-descriptions.xml
@@ -813,7 +813,7 @@
<string name="spoken_emoji_1F4EB" msgid="6491414165464146137">"Caixa de correio fechada com bandeira levantada"</string>
<string name="spoken_emoji_1F4EC" msgid="7369517138779988438">"Caixa de correio aberta com bandeira levantada"</string>
<string name="spoken_emoji_1F4ED" msgid="5657520436285454241">"Caixa de correio aberta com bandeira abaixada"</string>
- <string name="spoken_emoji_1F4EE" msgid="8464138906243608614">"Caixa de correio"</string>
+ <string name="spoken_emoji_1F4EE" msgid="8464138906243608614">"Caixa de e-mails"</string>
<string name="spoken_emoji_1F4EF" msgid="8801427577198798226">"Corneta de correio"</string>
<string name="spoken_emoji_1F4F0" msgid="6330208624731662525">"Jornal"</string>
<string name="spoken_emoji_1F4F1" msgid="3966503935581675695">"Celular"</string>
diff --git a/java/shared.keystore b/java/shared.keystore
new file mode 100644
index 000000000..9c2f1bdc2
--- /dev/null
+++ b/java/shared.keystore
Binary files differ
diff --git a/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java b/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java
index 442ab3e3a..31e142e72 100644
--- a/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java
+++ b/java/src/com/android/inputmethod/accessibility/AccessibilityUtils.java
@@ -21,7 +21,7 @@ import android.media.AudioManager;
import android.os.Build;
import android.os.SystemClock;
import android.provider.Settings;
-import android.support.v4.view.accessibility.AccessibilityEventCompat;
+import androidx.core.view.accessibility.AccessibilityEventCompat;
import android.text.TextUtils;
import android.util.Log;
import android.view.MotionEvent;
diff --git a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java
index 237117d10..f7a11639d 100644
--- a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java
+++ b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityDelegate.java
@@ -18,9 +18,9 @@ package com.android.inputmethod.accessibility;
import android.content.Context;
import android.os.SystemClock;
-import android.support.v4.view.AccessibilityDelegateCompat;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
+import androidx.core.view.AccessibilityDelegateCompat;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
diff --git a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java
index 2de71cec9..a3511c63f 100644
--- a/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java
+++ b/java/src/com/android/inputmethod/accessibility/KeyboardAccessibilityNodeProvider.java
@@ -18,11 +18,11 @@ package com.android.inputmethod.accessibility;
import android.graphics.Rect;
import android.os.Bundle;
-import android.support.v4.view.ViewCompat;
-import android.support.v4.view.accessibility.AccessibilityEventCompat;
-import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
-import android.support.v4.view.accessibility.AccessibilityNodeProviderCompat;
-import android.support.v4.view.accessibility.AccessibilityRecordCompat;
+import androidx.core.view.ViewCompat;
+import androidx.core.view.accessibility.AccessibilityEventCompat;
+import androidx.core.view.accessibility.AccessibilityNodeInfoCompat;
+import androidx.core.view.accessibility.AccessibilityNodeProviderCompat;
+import androidx.core.view.accessibility.AccessibilityRecordCompat;
import android.util.Log;
import android.view.View;
import android.view.accessibility.AccessibilityEvent;
diff --git a/java-overridable/src/com/android/inputmethod/compat/AppWorkaroundsHelper.java b/java/src/com/android/inputmethod/compat/AppWorkaroundsHelper.java
index f5e56eb4b..f5e56eb4b 100644
--- a/java-overridable/src/com/android/inputmethod/compat/AppWorkaroundsHelper.java
+++ b/java/src/com/android/inputmethod/compat/AppWorkaroundsHelper.java
diff --git a/java/src/com/android/inputmethod/compat/UserManagerCompatUtils.java b/java/src/com/android/inputmethod/compat/UserManagerCompatUtils.java
index 5dee31629..a0ca2c9f2 100644
--- a/java/src/com/android/inputmethod/compat/UserManagerCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/UserManagerCompatUtils.java
@@ -19,7 +19,7 @@ package com.android.inputmethod.compat;
import android.content.Context;
import android.os.Build;
import android.os.UserManager;
-import android.support.annotation.IntDef;
+import androidx.annotation.IntDef;
import java.lang.annotation.Retention;
import java.lang.reflect.Method;
diff --git a/java/src/com/android/inputmethod/compat/ViewCompatUtils.java b/java/src/com/android/inputmethod/compat/ViewCompatUtils.java
index 16260ab6a..a584625e2 100644
--- a/java/src/com/android/inputmethod/compat/ViewCompatUtils.java
+++ b/java/src/com/android/inputmethod/compat/ViewCompatUtils.java
@@ -20,7 +20,7 @@ import android.view.View;
import java.lang.reflect.Method;
-// TODO: Use {@link android.support.v4.view.ViewCompat} instead of this utility class.
+// TODO: Use {@link androidx.core.view.ViewCompat} instead of this utility class.
// Currently {@link #getPaddingEnd(View)} and {@link #setPaddingRelative(View,int,int,int,int)}
// are missing from android-support-v4 static library in KitKat SDK.
public final class ViewCompatUtils {
diff --git a/java-overridable/src/com/android/inputmethod/dictionarypack/DictionaryPackConstants.java b/java/src/com/android/inputmethod/dictionarypack/DictionaryPackConstants.java
index 13caea403..13caea403 100644
--- a/java-overridable/src/com/android/inputmethod/dictionarypack/DictionaryPackConstants.java
+++ b/java/src/com/android/inputmethod/dictionarypack/DictionaryPackConstants.java
diff --git a/java-overridable/src/com/android/inputmethod/dictionarypack/MetadataUriGetter.java b/java/src/com/android/inputmethod/dictionarypack/MetadataUriGetter.java
index 512d426aa..512d426aa 100644
--- a/java-overridable/src/com/android/inputmethod/dictionarypack/MetadataUriGetter.java
+++ b/java/src/com/android/inputmethod/dictionarypack/MetadataUriGetter.java
diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java
index 582e09124..797541a15 100644
--- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java
+++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiLayoutParams.java
@@ -17,7 +17,7 @@
package com.android.inputmethod.keyboard.emoji;
import android.content.res.Resources;
-import android.support.v4.view.ViewPager;
+import androidx.viewpager.widget.ViewPager;
import android.view.View;
import android.widget.LinearLayout;
diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesAdapter.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesAdapter.java
index 68056e0eb..18b9c7e36 100644
--- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesAdapter.java
+++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesAdapter.java
@@ -16,7 +16,7 @@
package com.android.inputmethod.keyboard.emoji;
-import android.support.v4.view.PagerAdapter;
+import androidx.viewpager.widget.PagerAdapter;
import android.util.Log;
import android.util.SparseArray;
import android.view.LayoutInflater;
diff --git a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java
index a3b869d73..9ba8d2ba2 100644
--- a/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java
+++ b/java/src/com/android/inputmethod/keyboard/emoji/EmojiPalettesView.java
@@ -23,7 +23,7 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.preference.PreferenceManager;
-import android.support.v4.view.ViewPager;
+import androidx.viewpager.widget.ViewPager;
import android.util.AttributeSet;
import android.util.Pair;
import android.util.TypedValue;
diff --git a/java-overridable/src/com/android/inputmethod/latin/DictionaryFacilitatorProvider.java b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorProvider.java
index a48b41fa7..a48b41fa7 100644
--- a/java-overridable/src/com/android/inputmethod/latin/DictionaryFacilitatorProvider.java
+++ b/java/src/com/android/inputmethod/latin/DictionaryFacilitatorProvider.java
diff --git a/java/src/com/android/inputmethod/latin/PersonalDictionaryLookup.java b/java/src/com/android/inputmethod/latin/PersonalDictionaryLookup.java
deleted file mode 100644
index eed4ec1a0..000000000
--- a/java/src/com/android/inputmethod/latin/PersonalDictionaryLookup.java
+++ /dev/null
@@ -1,651 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.latin;
-
-import android.content.ContentResolver;
-import android.content.Context;
-import android.database.ContentObserver;
-import android.database.Cursor;
-import android.net.Uri;
-import android.provider.UserDictionary;
-import android.text.TextUtils;
-import android.util.Log;
-
-import com.android.inputmethod.annotations.UsedForTesting;
-import com.android.inputmethod.latin.common.CollectionUtils;
-import com.android.inputmethod.latin.common.LocaleUtils;
-import com.android.inputmethod.latin.define.DebugFlags;
-import com.android.inputmethod.latin.utils.ExecutorUtils;
-
-import java.io.Closeable;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
-
-/**
- * This class provides the ability to look into the system-wide "Personal dictionary". It loads the
- * data once when created and reloads it when notified of changes to {@link UserDictionary}
- *
- * It can be used directly to validate words or expand shortcuts, and it can be used by instances
- * of {@link PersonalLanguageModelHelper} that create language model files for a specific input
- * locale.
- *
- * Note, that the initial dictionary loading happens asynchronously so it is possible (hopefully
- * rarely) that {@link #isValidWord} or {@link #expandShortcut} is called before the initial load
- * has started.
- *
- * The caller should explicitly call {@link #close} when the object is no longer needed, in order
- * to release any resources and references to this object. A service should create this object in
- * {@link android.app.Service#onCreate} and close it in {@link android.app.Service#onDestroy}.
- */
-public class PersonalDictionaryLookup implements Closeable {
-
- /**
- * To avoid loading too many dictionary entries in memory, we cap them at this number. If
- * that number is exceeded, the lowest-frequency items will be dropped. Note, there is no
- * explicit cap on the number of locales in every entry.
- */
- private static final int MAX_NUM_ENTRIES = 1000;
-
- /**
- * The delay (in milliseconds) to impose on reloads. Previously scheduled reloads will be
- * cancelled if a new reload is scheduled before the delay expires. Thus, only the last
- * reload in the series of frequent reloads will execute.
- *
- * Note, this value should be low enough to allow the "Add to dictionary" feature in the
- * TextView correction (red underline) drop-down menu to work properly in the following case:
- *
- * 1. User types OOV (out-of-vocabulary) word.
- * 2. The OOV is red-underlined.
- * 3. User selects "Add to dictionary". The red underline disappears while the OOV is
- * in a composing span.
- * 4. The user taps space. The red underline should NOT reappear. If this value is very
- * high and the user performs the space tap fast enough, the red underline may reappear.
- */
- @UsedForTesting
- static final int RELOAD_DELAY_MS = 200;
-
- @UsedForTesting
- static final Locale ANY_LOCALE = new Locale("");
-
- private final String mTag;
- private final ContentResolver mResolver;
- private final String mServiceName;
-
- /**
- * Interface to implement for classes interested in getting notified of updates.
- */
- public static interface PersonalDictionaryListener {
- public void onUpdate();
- }
-
- private final Set<PersonalDictionaryListener> mListeners = new HashSet<>();
-
- public void addListener(@Nonnull final PersonalDictionaryListener listener) {
- mListeners.add(listener);
- }
-
- public void removeListener(@Nonnull final PersonalDictionaryListener listener) {
- mListeners.remove(listener);
- }
-
- /**
- * Broadcast the update to all the Locale-specific language models.
- */
- @UsedForTesting
- void notifyListeners() {
- for (PersonalDictionaryListener listener : mListeners) {
- listener.onUpdate();
- }
- }
-
- /**
- * Content observer for changes to the personal dictionary. It has the following properties:
- * 1. It spawns off a reload in another thread, after some delay.
- * 2. It cancels previously scheduled reloads, and only executes the latest.
- * 3. It may be called multiple times quickly in succession (and is in fact called so
- * when the dictionary is edited through its settings UI, when sometimes multiple
- * notifications are sent for the edited entry, but also for the entire dictionary).
- */
- private class PersonalDictionaryContentObserver extends ContentObserver implements Runnable {
- public PersonalDictionaryContentObserver() {
- super(null);
- }
-
- @Override
- public boolean deliverSelfNotifications() {
- return true;
- }
-
- // Support pre-API16 platforms.
- @Override
- public void onChange(boolean selfChange) {
- onChange(selfChange, null);
- }
-
- @Override
- public void onChange(boolean selfChange, Uri uri) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "onChange() : URI = " + uri);
- }
- // Cancel (but don't interrupt) any pending reloads (except the initial load).
- if (mReloadFuture != null && !mReloadFuture.isCancelled() &&
- !mReloadFuture.isDone()) {
- // Note, that if already cancelled or done, this will do nothing.
- boolean isCancelled = mReloadFuture.cancel(false);
- if (DebugFlags.DEBUG_ENABLED) {
- if (isCancelled) {
- Log.d(mTag, "onChange() : Canceled previous reload request");
- } else {
- Log.d(mTag, "onChange() : Failed to cancel previous reload request");
- }
- }
- }
-
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "onChange() : Scheduling reload in " + RELOAD_DELAY_MS + " ms");
- }
-
- // Schedule a new reload after RELOAD_DELAY_MS.
- mReloadFuture = ExecutorUtils.getBackgroundExecutor(mServiceName)
- .schedule(this, RELOAD_DELAY_MS, TimeUnit.MILLISECONDS);
- }
-
- @Override
- public void run() {
- loadPersonalDictionary();
- }
- }
-
- private final PersonalDictionaryContentObserver mPersonalDictionaryContentObserver =
- new PersonalDictionaryContentObserver();
-
- /**
- * Indicates that a load is in progress, so no need for another.
- */
- private AtomicBoolean mIsLoading = new AtomicBoolean(false);
-
- /**
- * Indicates that this lookup object has been close()d.
- */
- private AtomicBoolean mIsClosed = new AtomicBoolean(false);
-
- /**
- * We store a map from a dictionary word to the set of locales & raw string(as it appears)
- * We then iterate over the set of locales to find a match using LocaleUtils.
- */
- private volatile HashMap<String, HashMap<Locale, String>> mDictWords;
-
- /**
- * We store a map from a shortcut to a word for each locale.
- * Shortcuts that apply to any locale are keyed by {@link #ANY_LOCALE}.
- */
- private volatile HashMap<Locale, HashMap<String, String>> mShortcutsPerLocale;
-
- /**
- * The last-scheduled reload future. Saved in order to cancel a pending reload if a new one
- * is coming.
- */
- private volatile ScheduledFuture<?> mReloadFuture;
-
- private volatile List<DictionaryStats> mDictionaryStats;
-
- /**
- * @param context the context from which to obtain content resolver
- */
- public PersonalDictionaryLookup(
- @Nonnull final Context context,
- @Nonnull final String serviceName) {
- mTag = serviceName + ".Personal";
-
- Log.i(mTag, "create()");
-
- mServiceName = serviceName;
- mDictionaryStats = new ArrayList<DictionaryStats>();
- mDictionaryStats.add(new DictionaryStats(ANY_LOCALE, Dictionary.TYPE_USER, 0));
- mDictionaryStats.add(new DictionaryStats(ANY_LOCALE, Dictionary.TYPE_USER_SHORTCUT, 0));
-
- // Obtain a content resolver.
- mResolver = context.getContentResolver();
- }
-
- public List<DictionaryStats> getDictionaryStats() {
- return mDictionaryStats;
- }
-
- public void open() {
- Log.i(mTag, "open()");
-
- // Schedule the initial load to run immediately. It's possible that the first call to
- // isValidWord occurs before the dictionary has actually loaded, so it should not
- // assume that the dictionary has been loaded.
- loadPersonalDictionary();
-
- // Register the observer to be notified on changes to the personal dictionary and all
- // individual items.
- //
- // If the user is interacting with the Personal Dictionary settings UI, or with the
- // "Add to dictionary" drop-down option, duplicate notifications will be sent for the same
- // edit: if a new entry is added, there is a notification for the entry itself, and
- // separately for the entire dictionary. However, when used programmatically,
- // only notifications for the specific edits are sent. Thus, the observer is registered to
- // receive every possible notification, and instead has throttling logic to avoid doing too
- // many reloads.
- mResolver.registerContentObserver(
- UserDictionary.Words.CONTENT_URI,
- true /* notifyForDescendents */,
- mPersonalDictionaryContentObserver);
- }
-
- /**
- * To be called by the garbage collector in the off chance that the service did not clean up
- * properly. Do not rely on this getting called, and make sure close() is called explicitly.
- */
- @Override
- public void finalize() throws Throwable {
- try {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "finalize()");
- }
- close();
- } finally {
- super.finalize();
- }
- }
-
- /**
- * Cleans up PersonalDictionaryLookup: shuts down any extra threads and unregisters the observer.
- *
- * It is safe, but not advised to call this multiple times, and isValidWord would continue to
- * work, but no data will be reloaded any longer.
- */
- @Override
- public void close() {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "close() : Unregistering content observer");
- }
- if (mIsClosed.compareAndSet(false, true)) {
- // Unregister the content observer.
- mResolver.unregisterContentObserver(mPersonalDictionaryContentObserver);
- }
- }
-
- /**
- * Returns true if the initial load has been performed.
- *
- * @return true if the initial load is successful
- */
- public boolean isLoaded() {
- return mDictWords != null && mShortcutsPerLocale != null;
- }
-
- /**
- * Returns the set of words defined for the given locale and more general locales.
- *
- * For example, input locale en_US uses data for en_US, en, and the global dictionary.
- *
- * Note that this method returns expanded words, not shortcuts. Shortcuts are handled
- * by {@link #getShortcutsForLocale}.
- *
- * @param inputLocale the locale to restrict for
- * @return set of words that apply to the given locale.
- */
- public Set<String> getWordsForLocale(@Nonnull final Locale inputLocale) {
- final HashMap<String, HashMap<Locale, String>> dictWords = mDictWords;
- if (CollectionUtils.isNullOrEmpty(dictWords)) {
- return Collections.emptySet();
- }
-
- final Set<String> words = new HashSet<>();
- final String inputLocaleString = inputLocale.toString();
- for (String word : dictWords.keySet()) {
- HashMap<Locale, String> localeStringMap = dictWords.get(word);
- if (!CollectionUtils.isNullOrEmpty(localeStringMap)) {
- for (Locale wordLocale : localeStringMap.keySet()) {
- final String wordLocaleString = wordLocale.toString();
- final int match = LocaleUtils.getMatchLevel(wordLocaleString, inputLocaleString);
- if (LocaleUtils.isMatch(match)) {
- words.add(localeStringMap.get(wordLocale));
- }
- }
- }
- }
- return words;
- }
-
- /**
- * Returns the set of shortcuts defined for the given locale and more general locales.
- *
- * For example, input locale en_US uses data for en_US, en, and the global dictionary.
- *
- * Note that this method returns shortcut keys, not expanded words. Words are handled
- * by {@link #getWordsForLocale}.
- *
- * @param inputLocale the locale to restrict for
- * @return set of shortcuts that apply to the given locale.
- */
- public Set<String> getShortcutsForLocale(@Nonnull final Locale inputLocale) {
- final Map<Locale, HashMap<String, String>> shortcutsPerLocale = mShortcutsPerLocale;
- if (CollectionUtils.isNullOrEmpty(shortcutsPerLocale)) {
- return Collections.emptySet();
- }
-
- final Set<String> shortcuts = new HashSet<>();
- if (!TextUtils.isEmpty(inputLocale.getCountry())) {
- // First look for the country-specific shortcut: en_US, en_UK, fr_FR, etc.
- final Map<String, String> countryShortcuts = shortcutsPerLocale.get(inputLocale);
- if (!CollectionUtils.isNullOrEmpty(countryShortcuts)) {
- shortcuts.addAll(countryShortcuts.keySet());
- }
- }
-
- // Next look for the language-specific shortcut: en, fr, etc.
- final Locale languageOnlyLocale =
- LocaleUtils.constructLocaleFromString(inputLocale.getLanguage());
- final Map<String, String> languageShortcuts = shortcutsPerLocale.get(languageOnlyLocale);
- if (!CollectionUtils.isNullOrEmpty(languageShortcuts)) {
- shortcuts.addAll(languageShortcuts.keySet());
- }
-
- // If all else fails, look for a global shortcut.
- final Map<String, String> globalShortcuts = shortcutsPerLocale.get(ANY_LOCALE);
- if (!CollectionUtils.isNullOrEmpty(globalShortcuts)) {
- shortcuts.addAll(globalShortcuts.keySet());
- }
-
- return shortcuts;
- }
-
- /**
- * Determines if the given word is a valid word in the given locale based on the dictionary.
- * It tries hard to find a match: for example, casing is ignored and if the word is present in a
- * more general locale (e.g. en or all locales), and isValidWord is asking for a more specific
- * locale (e.g. en_US), it will be considered a match.
- *
- * @param word the word to match
- * @param inputLocale the locale in which to match the word
- * @return true iff the word has been matched for this locale in the dictionary.
- */
- public boolean isValidWord(@Nonnull final String word, @Nonnull final Locale inputLocale) {
- if (!isLoaded()) {
- // This is a corner case in the event the initial load of the dictionary has not
- // completed. In that case, we assume the word is not a valid word in the dictionary.
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "isValidWord() : Initial load not complete");
- }
- return false;
- }
-
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "isValidWord() : Word [" + word + "] in Locale [" + inputLocale + "]");
- }
- // Atomically obtain the current copy of mDictWords;
- final HashMap<String, HashMap<Locale, String>> dictWords = mDictWords;
- // Lowercase the word using the given locale. Note, that dictionary
- // words are lowercased using their locale, and theoretically the
- // lowercasing between two matching locales may differ. For simplicity
- // we ignore that possibility.
- final String lowercased = word.toLowerCase(inputLocale);
- final HashMap<Locale, String> dictLocales = dictWords.get(lowercased);
-
- if (CollectionUtils.isNullOrEmpty(dictLocales)) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "isValidWord() : No entry for word [" + word + "]");
- }
- return false;
- } else {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "isValidWord() : Found entry for word [" + word + "]");
- }
- // Iterate over the locales this word is in.
- for (final Locale dictLocale : dictLocales.keySet()) {
- final int matchLevel = LocaleUtils.getMatchLevel(dictLocale.toString(),
- inputLocale.toString());
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "isValidWord() : MatchLevel for DictLocale [" + dictLocale
- + "] and InputLocale [" + inputLocale + "] is " + matchLevel);
- }
- if (LocaleUtils.isMatch(matchLevel)) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "isValidWord() : MatchLevel " + matchLevel + " IS a match");
- }
- return true;
- }
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "isValidWord() : MatchLevel " + matchLevel + " is NOT a match");
- }
- }
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "isValidWord() : False, since none of the locales matched");
- }
- return false;
- }
- }
-
- /**
- * Expands the given shortcut for the given locale.
- *
- * @param shortcut the shortcut to expand
- * @param inputLocale the locale in which to expand the shortcut
- * @return expanded shortcut iff the word is a shortcut in the dictionary.
- */
- @Nullable public String expandShortcut(
- @Nonnull final String shortcut, @Nonnull final Locale inputLocale) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "expandShortcut() : Shortcut [" + shortcut + "] for [" + inputLocale + "]");
- }
-
- // Atomically obtain the current copy of mShortcuts;
- final HashMap<Locale, HashMap<String, String>> shortcutsPerLocale = mShortcutsPerLocale;
-
- // Exit as early as possible. Most users don't use shortcuts.
- if (CollectionUtils.isNullOrEmpty(shortcutsPerLocale)) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "expandShortcut() : User has no shortcuts");
- }
- return null;
- }
-
- if (!TextUtils.isEmpty(inputLocale.getCountry())) {
- // First look for the country-specific shortcut: en_US, en_UK, fr_FR, etc.
- final String expansionForCountry = expandShortcut(
- shortcutsPerLocale, shortcut, inputLocale);
- if (!TextUtils.isEmpty(expansionForCountry)) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "expandShortcut() : Country expansion is ["
- + expansionForCountry + "]");
- }
- return expansionForCountry;
- }
- }
-
- // Next look for the language-specific shortcut: en, fr, etc.
- final Locale languageOnlyLocale =
- LocaleUtils.constructLocaleFromString(inputLocale.getLanguage());
- final String expansionForLanguage = expandShortcut(
- shortcutsPerLocale, shortcut, languageOnlyLocale);
- if (!TextUtils.isEmpty(expansionForLanguage)) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "expandShortcut() : Language expansion is ["
- + expansionForLanguage + "]");
- }
- return expansionForLanguage;
- }
-
- // If all else fails, look for a global shortcut.
- final String expansionForGlobal = expandShortcut(shortcutsPerLocale, shortcut, ANY_LOCALE);
- if (!TextUtils.isEmpty(expansionForGlobal) && DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "expandShortcut() : Global expansion is [" + expansionForGlobal + "]");
- }
- return expansionForGlobal;
- }
-
- @Nullable private String expandShortcut(
- @Nullable final HashMap<Locale, HashMap<String, String>> shortcutsPerLocale,
- @Nonnull final String shortcut,
- @Nonnull final Locale locale) {
- if (CollectionUtils.isNullOrEmpty(shortcutsPerLocale)) {
- return null;
- }
- final HashMap<String, String> localeShortcuts = shortcutsPerLocale.get(locale);
- if (CollectionUtils.isNullOrEmpty(localeShortcuts)) {
- return null;
- }
- return localeShortcuts.get(shortcut);
- }
-
- /**
- * Loads the personal dictionary in the current thread.
- *
- * Only one reload can happen at a time. If already running, will exit quickly.
- */
- private void loadPersonalDictionary() {
- // Bail out if already in the process of loading.
- if (!mIsLoading.compareAndSet(false, true)) {
- Log.i(mTag, "loadPersonalDictionary() : Already Loading (exit)");
- return;
- }
- Log.i(mTag, "loadPersonalDictionary() : Start Loading");
- HashMap<String, HashMap<Locale, String>> dictWords = new HashMap<>();
- HashMap<Locale, HashMap<String, String>> shortcutsPerLocale = new HashMap<>();
- // Load the dictionary. Items are returned in the default sort order (by frequency).
- Cursor cursor = mResolver.query(UserDictionary.Words.CONTENT_URI,
- null, null, null, UserDictionary.Words.DEFAULT_SORT_ORDER);
- if (null == cursor || cursor.getCount() < 1) {
- Log.i(mTag, "loadPersonalDictionary() : Empty");
- } else {
- // Iterate over the entries in the personal dictionary. Note, that iteration is in
- // descending frequency by default.
- while (dictWords.size() < MAX_NUM_ENTRIES && cursor.moveToNext()) {
- // If there is no column for locale, skip this entry. An empty
- // locale on the other hand will not be skipped.
- final int dictLocaleIndex = cursor.getColumnIndex(UserDictionary.Words.LOCALE);
- if (dictLocaleIndex < 0) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "loadPersonalDictionary() : Entry without LOCALE, skipping");
- }
- continue;
- }
- // If there is no column for word, skip this entry.
- final int dictWordIndex = cursor.getColumnIndex(UserDictionary.Words.WORD);
- if (dictWordIndex < 0) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "loadPersonalDictionary() : Entry without WORD, skipping");
- }
- continue;
- }
- // If the word is null, skip this entry.
- final String rawDictWord = cursor.getString(dictWordIndex);
- if (null == rawDictWord) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "loadPersonalDictionary() : Null word");
- }
- continue;
- }
- // If the locale is null, that's interpreted to mean all locales. Note, the special
- // zz locale for an Alphabet (QWERTY) layout will not match any actual language.
- String localeString = cursor.getString(dictLocaleIndex);
- if (null == localeString) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "loadPersonalDictionary() : Null locale for word [" +
- rawDictWord + "], assuming all locales");
- }
- // For purposes of LocaleUtils, an empty locale matches everything.
- localeString = "";
- }
- final Locale dictLocale = LocaleUtils.constructLocaleFromString(localeString);
- // Lowercase the word before storing it.
- final String dictWord = rawDictWord.toLowerCase(dictLocale);
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "loadPersonalDictionary() : Adding word [" + dictWord
- + "] for locale " + dictLocale + "with value" + rawDictWord);
- }
- // Check if there is an existing entry for this word.
- HashMap<Locale, String> dictLocales = dictWords.get(dictWord);
- if (CollectionUtils.isNullOrEmpty(dictLocales)) {
- // If there is no entry for this word, create one.
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "loadPersonalDictionary() : Word [" + dictWord +
- "] not seen for other locales, creating new entry");
- }
- dictLocales = new HashMap<>();
- dictWords.put(dictWord, dictLocales);
- }
- // Append the locale to the list of locales this word is in.
- dictLocales.put(dictLocale, rawDictWord);
-
- // If there is no column for a shortcut, we're done.
- final int shortcutIndex = cursor.getColumnIndex(UserDictionary.Words.SHORTCUT);
- if (shortcutIndex < 0) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "loadPersonalDictionary() : Entry without SHORTCUT, done");
- }
- continue;
- }
- // If the shortcut is null, we're done.
- final String shortcut = cursor.getString(shortcutIndex);
- if (shortcut == null) {
- if (DebugFlags.DEBUG_ENABLED) {
- Log.d(mTag, "loadPersonalDictionary() : Null shortcut");
- }
- continue;
- }
- // Else, save the shortcut.
- HashMap<String, String> localeShortcuts = shortcutsPerLocale.get(dictLocale);
- if (localeShortcuts == null) {
- localeShortcuts = new HashMap<>();
- shortcutsPerLocale.put(dictLocale, localeShortcuts);
- }
- // Map to the raw input, which might be capitalized.
- // This lets the user create a shortcut from "gm" to "General Motors".
- localeShortcuts.put(shortcut, rawDictWord);
- }
- }
-
- List<DictionaryStats> stats = new ArrayList<>();
- stats.add(new DictionaryStats(ANY_LOCALE, Dictionary.TYPE_USER, dictWords.size()));
- int numShortcuts = 0;
- for (HashMap<String, String> shortcuts : shortcutsPerLocale.values()) {
- numShortcuts += shortcuts.size();
- }
- stats.add(new DictionaryStats(ANY_LOCALE, Dictionary.TYPE_USER_SHORTCUT, numShortcuts));
- mDictionaryStats = stats;
-
- // Atomically replace the copy of mDictWords and mShortcuts.
- mDictWords = dictWords;
- mShortcutsPerLocale = shortcutsPerLocale;
-
- // Allow other calls to loadPersonalDictionary to execute now.
- mIsLoading.set(false);
-
- Log.i(mTag, "loadPersonalDictionary() : Loaded " + mDictWords.size()
- + " words and " + numShortcuts + " shortcuts");
-
- notifyListeners();
- }
-}
diff --git a/java-overridable/src/com/android/inputmethod/latin/about/AboutPreferences.java b/java/src/com/android/inputmethod/latin/about/AboutPreferences.java
index f60b189f1..f60b189f1 100644
--- a/java-overridable/src/com/android/inputmethod/latin/about/AboutPreferences.java
+++ b/java/src/com/android/inputmethod/latin/about/AboutPreferences.java
diff --git a/java-overridable/src/com/android/inputmethod/latin/accounts/AccountStateChangedListener.java b/java/src/com/android/inputmethod/latin/accounts/AccountStateChangedListener.java
index 60d420fc3..3c39c9a16 100644
--- a/java-overridable/src/com/android/inputmethod/latin/accounts/AccountStateChangedListener.java
+++ b/java/src/com/android/inputmethod/latin/accounts/AccountStateChangedListener.java
@@ -16,7 +16,7 @@
package com.android.inputmethod.latin.accounts;
-import android.support.annotation.NonNull;
+import androidx.annotation.NonNull;
import javax.annotation.Nullable;
diff --git a/java-overridable/src/com/android/inputmethod/latin/accounts/LoginAccountUtils.java b/java/src/com/android/inputmethod/latin/accounts/LoginAccountUtils.java
index dcc64a223..dcc64a223 100644
--- a/java-overridable/src/com/android/inputmethod/latin/accounts/LoginAccountUtils.java
+++ b/java/src/com/android/inputmethod/latin/accounts/LoginAccountUtils.java
diff --git a/java-overridable/src/com/android/inputmethod/latin/define/DebugFlags.java b/java/src/com/android/inputmethod/latin/define/DebugFlags.java
index c509e8322..c509e8322 100644
--- a/java-overridable/src/com/android/inputmethod/latin/define/DebugFlags.java
+++ b/java/src/com/android/inputmethod/latin/define/DebugFlags.java
diff --git a/java-overridable/src/com/android/inputmethod/latin/define/DecoderSpecificConstants.java b/java/src/com/android/inputmethod/latin/define/DecoderSpecificConstants.java
index 7f57ce858..7f57ce858 100644
--- a/java-overridable/src/com/android/inputmethod/latin/define/DecoderSpecificConstants.java
+++ b/java/src/com/android/inputmethod/latin/define/DecoderSpecificConstants.java
diff --git a/java-overridable/src/com/android/inputmethod/latin/define/JniLibName.java b/java/src/com/android/inputmethod/latin/define/JniLibName.java
index abfc36d39..abfc36d39 100644
--- a/java-overridable/src/com/android/inputmethod/latin/define/JniLibName.java
+++ b/java/src/com/android/inputmethod/latin/define/JniLibName.java
diff --git a/java-overridable/src/com/android/inputmethod/latin/define/ProductionFlags.java b/java/src/com/android/inputmethod/latin/define/ProductionFlags.java
index f31c20822..f31c20822 100644
--- a/java-overridable/src/com/android/inputmethod/latin/define/ProductionFlags.java
+++ b/java/src/com/android/inputmethod/latin/define/ProductionFlags.java
diff --git a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
index e422c4cd2..288261bf0 100644
--- a/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
+++ b/java/src/com/android/inputmethod/latin/makedict/FormatSpec.java
@@ -174,6 +174,9 @@ public final class FormatSpec {
public static final int VERSION202 = 202;
// format version for Fava Dictionaries.
public static final int VERSION_DELIGHT3 = 86736212;
+ public static final int MINIMUM_SUPPORTED_VERSION_OF_CODE_POINT_TABLE = VERSION201;
+ // Dictionary version used for testing.
+ public static final int VERSION4_ONLY_FOR_TESTING = 399;
public static final int VERSION402 = 402;
public static final int VERSION403 = 403;
public static final int VERSION4 = VERSION403;
diff --git a/java/src/com/android/inputmethod/latin/permissions/PermissionsActivity.java b/java/src/com/android/inputmethod/latin/permissions/PermissionsActivity.java
index bdd63fa00..36d8ed943 100644
--- a/java/src/com/android/inputmethod/latin/permissions/PermissionsActivity.java
+++ b/java/src/com/android/inputmethod/latin/permissions/PermissionsActivity.java
@@ -21,8 +21,8 @@ import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
-import android.support.annotation.NonNull;
-import android.support.v4.app.ActivityCompat;
+import androidx.annotation.NonNull;
+import androidx.core.app.ActivityCompat;
/**
* An activity to help request permissions. It's used when no other activity is available, e.g. in
diff --git a/java/src/com/android/inputmethod/latin/permissions/PermissionsUtil.java b/java/src/com/android/inputmethod/latin/permissions/PermissionsUtil.java
index 747f64f24..9a618a755 100644
--- a/java/src/com/android/inputmethod/latin/permissions/PermissionsUtil.java
+++ b/java/src/com/android/inputmethod/latin/permissions/PermissionsUtil.java
@@ -20,9 +20,9 @@ import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
-import android.support.annotation.NonNull;
-import android.support.v4.app.ActivityCompat;
-import android.support.v4.content.ContextCompat;
+import androidx.annotation.NonNull;
+import androidx.core.app.ActivityCompat;
+import androidx.core.content.ContextCompat;
import java.util.ArrayList;
import java.util.List;
diff --git a/java-overridable/src/com/android/inputmethod/latin/settings/AdditionalFeaturesSettingUtils.java b/java/src/com/android/inputmethod/latin/settings/AdditionalFeaturesSettingUtils.java
index 4e8a10b1f..4e8a10b1f 100644
--- a/java-overridable/src/com/android/inputmethod/latin/settings/AdditionalFeaturesSettingUtils.java
+++ b/java/src/com/android/inputmethod/latin/settings/AdditionalFeaturesSettingUtils.java
diff --git a/java/src/com/android/inputmethod/latin/settings/CustomInputStyleSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/CustomInputStyleSettingsFragment.java
index 46fcc7106..56e8f1623 100644
--- a/java/src/com/android/inputmethod/latin/settings/CustomInputStyleSettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/settings/CustomInputStyleSettingsFragment.java
@@ -26,7 +26,7 @@ import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceGroup;
-import android.support.v4.view.ViewCompat;
+import androidx.core.view.ViewCompat;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsActivity.java b/java/src/com/android/inputmethod/latin/settings/SettingsActivity.java
index a7d157a6b..ac1657762 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsActivity.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsActivity.java
@@ -25,7 +25,7 @@ import android.app.ActionBar;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
-import android.support.v4.app.ActivityCompat;
+import androidx.core.app.ActivityCompat;
import android.view.MenuItem;
public final class SettingsActivity extends PreferenceActivity
diff --git a/java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java b/java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java
index 73d25f6aa..789694f08 100644
--- a/java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java
+++ b/java/src/com/android/inputmethod/latin/setup/SetupStartIndicatorView.java
@@ -21,7 +21,7 @@ import android.content.res.ColorStateList;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
-import android.support.v4.view.ViewCompat;
+import androidx.core.view.ViewCompat;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
diff --git a/java/src/com/android/inputmethod/latin/setup/SetupStepIndicatorView.java b/java/src/com/android/inputmethod/latin/setup/SetupStepIndicatorView.java
index 6734e61b8..9a39ceace 100644
--- a/java/src/com/android/inputmethod/latin/setup/SetupStepIndicatorView.java
+++ b/java/src/com/android/inputmethod/latin/setup/SetupStepIndicatorView.java
@@ -20,7 +20,7 @@ import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Path;
-import android.support.v4.view.ViewCompat;
+import androidx.core.view.ViewCompat;
import android.util.AttributeSet;
import android.view.View;
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java
index 356d9d021..5f99f9004 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerSettingsActivity.java
@@ -24,7 +24,7 @@ import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.preference.PreferenceActivity;
-import android.support.v4.app.ActivityCompat;
+import androidx.core.app.ActivityCompat;
/**
* Spell checker preference screen.
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
index c1d1fad68..840a4aa3d 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
@@ -21,7 +21,7 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
-import android.support.v4.view.ViewCompat;
+import androidx.core.view.ViewCompat;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
diff --git a/java-overridable/src/com/android/inputmethod/latin/touchinputconsumer/GestureConsumer.java b/java/src/com/android/inputmethod/latin/touchinputconsumer/GestureConsumer.java
index 8291b4f72..8291b4f72 100644
--- a/java-overridable/src/com/android/inputmethod/latin/touchinputconsumer/GestureConsumer.java
+++ b/java/src/com/android/inputmethod/latin/touchinputconsumer/GestureConsumer.java
diff --git a/java-overridable/src/com/android/inputmethod/latin/utils/DictionaryHeaderUtils.java b/java/src/com/android/inputmethod/latin/utils/DictionaryHeaderUtils.java
index 5eb613c9b..5eb613c9b 100644
--- a/java-overridable/src/com/android/inputmethod/latin/utils/DictionaryHeaderUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/DictionaryHeaderUtils.java
diff --git a/java-overridable/src/com/android/inputmethod/latin/utils/FeedbackUtils.java b/java/src/com/android/inputmethod/latin/utils/FeedbackUtils.java
index 67de8ba32..67de8ba32 100644
--- a/java-overridable/src/com/android/inputmethod/latin/utils/FeedbackUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/FeedbackUtils.java
diff --git a/java-overridable/src/com/android/inputmethod/latin/utils/FileTransforms.java b/java/src/com/android/inputmethod/latin/utils/FileTransforms.java
index 9f4584ec9..9f4584ec9 100644
--- a/java-overridable/src/com/android/inputmethod/latin/utils/FileTransforms.java
+++ b/java/src/com/android/inputmethod/latin/utils/FileTransforms.java
diff --git a/java-overridable/src/com/android/inputmethod/latin/utils/ManagedProfileUtils.java b/java/src/com/android/inputmethod/latin/utils/ManagedProfileUtils.java
index ef1872bf4..ef1872bf4 100644
--- a/java-overridable/src/com/android/inputmethod/latin/utils/ManagedProfileUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/ManagedProfileUtils.java
diff --git a/java-overridable/src/com/android/inputmethod/latin/utils/MetadataFileUriGetter.java b/java/src/com/android/inputmethod/latin/utils/MetadataFileUriGetter.java
index 97fb17de3..97fb17de3 100644
--- a/java-overridable/src/com/android/inputmethod/latin/utils/MetadataFileUriGetter.java
+++ b/java/src/com/android/inputmethod/latin/utils/MetadataFileUriGetter.java
diff --git a/java-overridable/src/com/android/inputmethod/latin/utils/StatsUtils.java b/java/src/com/android/inputmethod/latin/utils/StatsUtils.java
index 03e58478b..03e58478b 100644
--- a/java-overridable/src/com/android/inputmethod/latin/utils/StatsUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/StatsUtils.java
diff --git a/java-overridable/src/com/android/inputmethod/latin/utils/StatsUtilsManager.java b/java/src/com/android/inputmethod/latin/utils/StatsUtilsManager.java
index cd42f50c7..cd42f50c7 100644
--- a/java-overridable/src/com/android/inputmethod/latin/utils/StatsUtilsManager.java
+++ b/java/src/com/android/inputmethod/latin/utils/StatsUtilsManager.java
diff --git a/java/src/com/android/inputmethodcommon/InputMethodSettingsActivity.java b/java/src/com/android/inputmethodcommon/InputMethodSettingsActivity.java
new file mode 100644
index 000000000..6e868c9ff
--- /dev/null
+++ b/java/src/com/android/inputmethodcommon/InputMethodSettingsActivity.java
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.inputmethodcommon;
+
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+
+/**
+ * This is a helper class for an IME's settings preference activity. It's recommended for every
+ * IME to have its own settings preference activity which inherits this class.
+ */
+public abstract class InputMethodSettingsActivity extends PreferenceActivity
+ implements InputMethodSettingsInterface {
+ private final InputMethodSettingsImpl mSettings = new InputMethodSettingsImpl();
+ @SuppressWarnings("deprecation")
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setPreferenceScreen(getPreferenceManager().createPreferenceScreen(this));
+ mSettings.init(this, getPreferenceScreen());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setInputMethodSettingsCategoryTitle(int resId) {
+ mSettings.setInputMethodSettingsCategoryTitle(resId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setInputMethodSettingsCategoryTitle(CharSequence title) {
+ mSettings.setInputMethodSettingsCategoryTitle(title);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSubtypeEnablerTitle(int resId) {
+ mSettings.setSubtypeEnablerTitle(resId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSubtypeEnablerTitle(CharSequence title) {
+ mSettings.setSubtypeEnablerTitle(title);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSubtypeEnablerIcon(int resId) {
+ mSettings.setSubtypeEnablerIcon(resId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSubtypeEnablerIcon(Drawable drawable) {
+ mSettings.setSubtypeEnablerIcon(drawable);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onResume() {
+ super.onResume();
+ mSettings.updateSubtypeEnabler();
+ }
+}
diff --git a/java/src/com/android/inputmethodcommon/InputMethodSettingsFragment.java b/java/src/com/android/inputmethodcommon/InputMethodSettingsFragment.java
new file mode 100644
index 000000000..49f0b87f1
--- /dev/null
+++ b/java/src/com/android/inputmethodcommon/InputMethodSettingsFragment.java
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethodcommon;
+
+import android.content.Context;
+import android.graphics.drawable.Drawable;
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+
+/**
+ * This is a helper class for an IME's settings preference fragment. It's recommended for every
+ * IME to have its own settings preference fragment which inherits this class.
+ */
+public abstract class InputMethodSettingsFragment extends PreferenceFragment
+ implements InputMethodSettingsInterface {
+ private final InputMethodSettingsImpl mSettings = new InputMethodSettingsImpl();
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ final Context context = getActivity();
+ setPreferenceScreen(getPreferenceManager().createPreferenceScreen(context));
+ mSettings.init(context, getPreferenceScreen());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setInputMethodSettingsCategoryTitle(int resId) {
+ mSettings.setInputMethodSettingsCategoryTitle(resId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setInputMethodSettingsCategoryTitle(CharSequence title) {
+ mSettings.setInputMethodSettingsCategoryTitle(title);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSubtypeEnablerTitle(int resId) {
+ mSettings.setSubtypeEnablerTitle(resId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSubtypeEnablerTitle(CharSequence title) {
+ mSettings.setSubtypeEnablerTitle(title);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSubtypeEnablerIcon(int resId) {
+ mSettings.setSubtypeEnablerIcon(resId);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSubtypeEnablerIcon(Drawable drawable) {
+ mSettings.setSubtypeEnablerIcon(drawable);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void onResume() {
+ super.onResume();
+ mSettings.updateSubtypeEnabler();
+ }
+}
diff --git a/java/src/com/android/inputmethodcommon/InputMethodSettingsImpl.java b/java/src/com/android/inputmethodcommon/InputMethodSettingsImpl.java
new file mode 100644
index 000000000..cfa1a6596
--- /dev/null
+++ b/java/src/com/android/inputmethodcommon/InputMethodSettingsImpl.java
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethodcommon;
+
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.drawable.Drawable;
+import android.preference.Preference;
+import android.preference.Preference.OnPreferenceClickListener;
+import android.preference.PreferenceScreen;
+import android.provider.Settings;
+import android.text.TextUtils;
+import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.view.inputmethod.InputMethodSubtype;
+
+import java.util.List;
+
+/* package private */ class InputMethodSettingsImpl implements InputMethodSettingsInterface {
+ private Preference mSubtypeEnablerPreference;
+ private int mInputMethodSettingsCategoryTitleRes;
+ private CharSequence mInputMethodSettingsCategoryTitle;
+ private int mSubtypeEnablerTitleRes;
+ private CharSequence mSubtypeEnablerTitle;
+ private int mSubtypeEnablerIconRes;
+ private Drawable mSubtypeEnablerIcon;
+ private InputMethodManager mImm;
+ private InputMethodInfo mImi;
+
+ /**
+ * Initialize internal states of this object.
+ * @param context the context for this application.
+ * @param prefScreen a PreferenceScreen of PreferenceActivity or PreferenceFragment.
+ * @return true if this application is an IME and has two or more subtypes, false otherwise.
+ */
+ public boolean init(final Context context, final PreferenceScreen prefScreen) {
+ mImm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
+ mImi = getMyImi(context, mImm);
+ if (mImi == null || mImi.getSubtypeCount() <= 1) {
+ return false;
+ }
+ final Intent intent = new Intent(Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
+ intent.putExtra(Settings.EXTRA_INPUT_METHOD_ID, mImi.getId());
+ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
+ | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ mSubtypeEnablerPreference = new Preference(context);
+ mSubtypeEnablerPreference.setIntent(intent);
+ prefScreen.addPreference(mSubtypeEnablerPreference);
+ updateSubtypeEnabler();
+ return true;
+ }
+
+ private static InputMethodInfo getMyImi(Context context, InputMethodManager imm) {
+ final List<InputMethodInfo> imis = imm.getInputMethodList();
+ for (int i = 0; i < imis.size(); ++i) {
+ final InputMethodInfo imi = imis.get(i);
+ if (imis.get(i).getPackageName().equals(context.getPackageName())) {
+ return imi;
+ }
+ }
+ return null;
+ }
+
+ private static String getEnabledSubtypesLabel(
+ Context context, InputMethodManager imm, InputMethodInfo imi) {
+ if (context == null || imm == null || imi == null) return null;
+ final List<InputMethodSubtype> subtypes = imm.getEnabledInputMethodSubtypeList(imi, true);
+ final StringBuilder sb = new StringBuilder();
+ final int N = subtypes.size();
+ for (int i = 0; i < N; ++i) {
+ final InputMethodSubtype subtype = subtypes.get(i);
+ if (sb.length() > 0) {
+ sb.append(", ");
+ }
+ sb.append(subtype.getDisplayName(context, imi.getPackageName(),
+ imi.getServiceInfo().applicationInfo));
+ }
+ return sb.toString();
+ }
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setInputMethodSettingsCategoryTitle(int resId) {
+ mInputMethodSettingsCategoryTitleRes = resId;
+ updateSubtypeEnabler();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setInputMethodSettingsCategoryTitle(CharSequence title) {
+ mInputMethodSettingsCategoryTitleRes = 0;
+ mInputMethodSettingsCategoryTitle = title;
+ updateSubtypeEnabler();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSubtypeEnablerTitle(int resId) {
+ mSubtypeEnablerTitleRes = resId;
+ updateSubtypeEnabler();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSubtypeEnablerTitle(CharSequence title) {
+ mSubtypeEnablerTitleRes = 0;
+ mSubtypeEnablerTitle = title;
+ updateSubtypeEnabler();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSubtypeEnablerIcon(int resId) {
+ mSubtypeEnablerIconRes = resId;
+ updateSubtypeEnabler();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setSubtypeEnablerIcon(Drawable drawable) {
+ mSubtypeEnablerIconRes = 0;
+ mSubtypeEnablerIcon = drawable;
+ updateSubtypeEnabler();
+ }
+
+ public void updateSubtypeEnabler() {
+ final Preference pref = mSubtypeEnablerPreference;
+ if (pref == null) {
+ return;
+ }
+ final Context context = pref.getContext();
+ final CharSequence title;
+ if (mSubtypeEnablerTitleRes != 0) {
+ title = context.getString(mSubtypeEnablerTitleRes);
+ } else {
+ title = mSubtypeEnablerTitle;
+ }
+ pref.setTitle(title);
+ final Intent intent = pref.getIntent();
+ if (intent != null) {
+ intent.putExtra(Intent.EXTRA_TITLE, title);
+ }
+ final String summary = getEnabledSubtypesLabel(context, mImm, mImi);
+ if (!TextUtils.isEmpty(summary)) {
+ pref.setSummary(summary);
+ }
+ if (mSubtypeEnablerIconRes != 0) {
+ pref.setIcon(mSubtypeEnablerIconRes);
+ } else {
+ pref.setIcon(mSubtypeEnablerIcon);
+ }
+ }
+}
diff --git a/java/src/com/android/inputmethodcommon/InputMethodSettingsInterface.java b/java/src/com/android/inputmethodcommon/InputMethodSettingsInterface.java
new file mode 100644
index 000000000..6e97faeb7
--- /dev/null
+++ b/java/src/com/android/inputmethodcommon/InputMethodSettingsInterface.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+package com.android.inputmethodcommon;
+
+import android.graphics.drawable.Drawable;
+
+/**
+ * InputMethodSettingsInterface is the interface for adding IME related preferences to
+ * PreferenceActivity or PreferenceFragment.
+ */
+public interface InputMethodSettingsInterface {
+ /**
+ * Sets the title for the input method settings category with a resource ID.
+ * @param resId The resource ID of the title.
+ */
+ public void setInputMethodSettingsCategoryTitle(int resId);
+
+ /**
+ * Sets the title for the input method settings category with a CharSequence.
+ * @param title The title for this preference.
+ */
+ public void setInputMethodSettingsCategoryTitle(CharSequence title);
+
+ /**
+ * Sets the title for the input method enabler preference for launching subtype enabler with a
+ * resource ID.
+ * @param resId The resource ID of the title.
+ */
+ public void setSubtypeEnablerTitle(int resId);
+
+ /**
+ * Sets the title for the input method enabler preference for launching subtype enabler with a
+ * CharSequence.
+ * @param title The title for this preference.
+ */
+ public void setSubtypeEnablerTitle(CharSequence title);
+
+ /**
+ * Sets the icon for the preference for launching subtype enabler with a resource ID.
+ * @param resId The resource id of an optional icon for the preference.
+ */
+ public void setSubtypeEnablerIcon(int resId);
+
+ /**
+ * Sets the icon for the Preference for launching subtype enabler with a Drawable.
+ * @param drawable The drawable of an optional icon for the preference.
+ */
+ public void setSubtypeEnablerIcon(Drawable drawable);
+}
diff --git a/native/Android.mk b/native/Android.mk
deleted file mode 100644
index 5053e7d64..000000000
--- a/native/Android.mk
+++ /dev/null
@@ -1 +0,0 @@
-include $(call all-subdir-makefiles)
diff --git a/native/dicttoolkit/Android.bp b/native/dicttoolkit/Android.bp
new file mode 100644
index 000000000..b214ff984
--- /dev/null
+++ b/native/dicttoolkit/Android.bp
@@ -0,0 +1,94 @@
+// Copyright (C) 2014 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+cc_defaults {
+ name: "dicttoolkit_defaults",
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ "-Wextra",
+ "-Weffc++",
+ "-Wformat=2",
+ "-Wcast-qual",
+ "-Wcast-align",
+ "-Wwrite-strings",
+ "-Wfloat-equal",
+ "-Wpointer-arith",
+ "-Winit-self",
+ "-Wredundant-decls",
+ "-Woverloaded-virtual",
+ "-Wsign-promo",
+ "-Wno-system-headers",
+
+ // To suppress compiler warnings for unused variables/functions used for debug features etc.
+ "-Wno-unused-parameter",
+ "-Wno-unused-function",
+ ],
+
+ local_include_dirs: ["src"],
+ // TODO
+ include_dirs: ["packages/inputmethods/LatinIME/native/jni/src"],
+
+ product_variables: {
+ unbundled_build: {
+ enabled: false,
+ },
+ },
+}
+
+cc_library_host_static {
+ name: "liblatinime_dicttoolkit",
+ defaults: ["dicttoolkit_defaults"],
+
+ srcs: [
+ "src/command_executors/diff_executor.cpp",
+ "src/command_executors/header_executor.cpp",
+ "src/command_executors/help_executor.cpp",
+ "src/command_executors/info_executor.cpp",
+ "src/command_executors/makedict_executor.cpp",
+ "src/offdevice_intermediate_dict/offdevice_intermediate_dict.cpp",
+ "src/utils/arguments_parser.cpp",
+ "src/utils/command_utils.cpp",
+ "src/utils/utf8_utils.cpp",
+
+ ":LATIN_IME_CORE_SRC_FILES",
+ ],
+}
+
+cc_binary_host {
+ name: "dicttoolkit",
+ defaults: ["dicttoolkit_defaults"],
+
+ srcs: ["dict_toolkit_main.cpp"],
+ static_libs: ["liblatinime_dicttoolkit"],
+}
+
+cc_test_host {
+ name: "dicttoolkit_unittests",
+ defaults: ["dicttoolkit_defaults"],
+
+ srcs: [
+ "tests/command_executors/diff_executor_test.cpp",
+ "tests/command_executors/header_executor_test.cpp",
+ "tests/command_executors/info_executor_test.cpp",
+ "tests/command_executors/makedict_executor_test.cpp",
+ "tests/dict_toolkit_defines_test.cpp",
+ "tests/offdevice_intermediate_dict/offdevice_intermediate_dict_test.cpp",
+ "tests/utils/arguments_parser_test.cpp",
+ "tests/utils/command_utils_test.cpp",
+ "tests/utils/utf8_utils_test.cpp",
+ ],
+ static_libs: ["liblatinime_dicttoolkit"],
+}
diff --git a/native/dicttoolkit/Android.mk b/native/dicttoolkit/Android.mk
deleted file mode 100644
index 7a446860c..000000000
--- a/native/dicttoolkit/Android.mk
+++ /dev/null
@@ -1,66 +0,0 @@
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-ifeq (,$(TARGET_BUILD_APPS))
-
-# Only build if it's explicitly requested, or running mm/mmm.
-ifneq ($(ONE_SHOT_MAKEFILE)$(filter $(MAKECMDGOALS),dicttoolkit),)
-
-# HACK: Temporarily disable host tool build on Mac until the build system is ready for C++11.
-LATINIME_HOST_OSNAME := $(shell uname -s)
-ifneq ($(LATINIME_HOST_OSNAME), Darwin) # TODO: Remove this
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-LATIN_IME_CORE_PATH := $(LOCAL_PATH)/../jni
-
-LATIN_IME_DICT_TOOLKIT_SRC_DIR := src
-LATIN_IME_CORE_SRC_DIR := ../jni/src
-
-LOCAL_CFLAGS += -Werror -Wall -Wextra -Weffc++ -Wformat=2 -Wcast-qual -Wcast-align \
- -Wwrite-strings -Wfloat-equal -Wpointer-arith -Winit-self -Wredundant-decls \
- -Woverloaded-virtual -Wsign-promo -Wno-system-headers
-
-# To suppress compiler warnings for unused variables/functions used for debug features etc.
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function
-
-include $(LOCAL_PATH)/NativeFileList.mk
-include $(LATIN_IME_CORE_PATH)/NativeFileList.mk
-
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_DICT_TOOLKIT_SRC_DIR) \
- $(LATIN_IME_CORE_PATH)/$(LATIN_IME_CORE_SRC_DIR)
-
-LOCAL_SRC_FILES := $(LATIN_IME_DICT_TOOLKIT_MAIN_SRC_FILES) \
- $(addprefix $(LATIN_IME_DICT_TOOLKIT_SRC_DIR)/, $(LATIN_IME_DICT_TOOLKIT_SRC_FILES)) \
- $(addprefix $(LATIN_IME_CORE_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES))
-
-LOCAL_MODULE := dicttoolkit
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_CXX_STL := libc++
-
-include $(BUILD_HOST_EXECUTABLE)
-#################### Clean up the tmp vars
-include $(LOCAL_PATH)/CleanupNativeFileList.mk
-#################### Unit test
-include $(LOCAL_PATH)/UnitTests.mk
-
-endif # Darwin - TODO: Remove this
-
-endif
-
-endif # TARGET_BUILD_APPS
diff --git a/native/dicttoolkit/CleanupNativeFileList.mk b/native/dicttoolkit/CleanupNativeFileList.mk
deleted file mode 100644
index b804b41ed..000000000
--- a/native/dicttoolkit/CleanupNativeFileList.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LATIN_IME_DICT_TOOLKIT_MAIN_SRC_FILES :=
-LATIN_IME_DICT_TOOLKIT_SRC_FILES :=
-LATIN_IME_DICT_TOOLKIT_TEST_FILES :=
diff --git a/native/dicttoolkit/NativeFileList.mk b/native/dicttoolkit/NativeFileList.mk
deleted file mode 100644
index 9a547b054..000000000
--- a/native/dicttoolkit/NativeFileList.mk
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LATIN_IME_DICT_TOOLKIT_MAIN_SRC_FILES := \
- dict_toolkit_main.cpp
-
-LATIN_IME_DICT_TOOLKIT_SRC_FILES := \
- $(addprefix command_executors/, \
- diff_executor.cpp \
- header_executor.cpp \
- help_executor.cpp \
- info_executor.cpp \
- makedict_executor.cpp) \
- $(addprefix offdevice_intermediate_dict/, \
- offdevice_intermediate_dict.cpp) \
- $(addprefix utils/, \
- arguments_parser.cpp \
- command_utils.cpp \
- utf8_utils.cpp)
-
-LATIN_IME_DICT_TOOLKIT_TEST_FILES := \
- $(addprefix command_executors/, \
- diff_executor_test.cpp \
- header_executor_test.cpp \
- info_executor_test.cpp \
- makedict_executor_test.cpp) \
- dict_toolkit_defines_test.cpp \
- $(addprefix offdevice_intermediate_dict/, \
- offdevice_intermediate_dict_test.cpp) \
- $(addprefix utils/, \
- arguments_parser_test.cpp \
- command_utils_test.cpp \
- utf8_utils_test.cpp)
diff --git a/native/dicttoolkit/UnitTests.mk b/native/dicttoolkit/UnitTests.mk
deleted file mode 100644
index 55177c084..000000000
--- a/native/dicttoolkit/UnitTests.mk
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-ifeq (,$(TARGET_BUILD_APPS))
-
-LOCAL_PATH := $(call my-dir)
-
-######################################
-include $(CLEAR_VARS)
-
-LATIN_IME_CORE_PATH := $(LOCAL_PATH)/../jni
-
-LATIN_IME_DICT_TOOLKIT_SRC_DIR := src
-LATIN_IME_CORE_SRC_DIR := ../jni/src
-LATIN_DICT_TOOLKIT_TEST_SRC_DIR := tests
-
-include $(LOCAL_PATH)/NativeFileList.mk
-include $(LATIN_IME_CORE_PATH)/NativeFileList.mk
-
-LATIN_IME_SRC_DIR := src
-LOCAL_ADDRESS_SANITIZER := true
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function
-LOCAL_CXX_STL := libc++
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_DICT_TOOLKIT_SRC_DIR) \
- $(LATIN_IME_CORE_PATH)/$(LATIN_IME_CORE_SRC_DIR)
-LOCAL_MODULE := liblatinime_dicttoolkit_host_static_for_unittests
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := \
- $(addprefix $(LATIN_IME_DICT_TOOLKIT_SRC_DIR)/, $(LATIN_IME_DICT_TOOLKIT_SRC_FILES)) \
- $(addprefix $(LATIN_IME_CORE_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES))
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_ADDRESS_SANITIZER := true
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function
-LOCAL_CXX_STL := libc++
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_DICT_TOOLKIT_SRC_DIR) \
- $(LATIN_IME_CORE_PATH)/$(LATIN_IME_CORE_SRC_DIR)
-LOCAL_MODULE := dicttoolkit_unittests
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := \
- $(addprefix $(LATIN_DICT_TOOLKIT_TEST_SRC_DIR)/, $(LATIN_IME_DICT_TOOLKIT_TEST_FILES))
-LOCAL_STATIC_LIBRARIES += liblatinime_dicttoolkit_host_static_for_unittests
-include $(BUILD_HOST_NATIVE_TEST)
-
-include $(LOCAL_PATH)/CleanupNativeFileList.mk
-
-#################### Clean up the tmp vars
-LATINIME_HOST_OSNAME :=
-LATIN_IME_SRC_DIR :=
-LATIN_IME_TEST_SRC_DIR :=
-
-endif # TARGET_BUILD_APPS
diff --git a/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.cpp b/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.cpp
index af28131cf..e94a9c2ff 100644
--- a/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.cpp
+++ b/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.cpp
@@ -93,7 +93,7 @@ const WordProperty *OffdeviceIntermediateDict::getWordProperty(
const OffdeviceIntermediateDictPtNodeArray *ptNodeArray = &mRootPtNodeArray;
for (size_t i = 0; i < codePoints.size();) {
bool foundNext = false;
- for (const auto ptNode : ptNodeArray->getPtNodeList()) {
+ for (const auto& ptNode : ptNodeArray->getPtNodeList()) {
const CodePointArrayView ptNodeCodePoints = ptNode->getPtNodeCodePoints();
if (codePoints[i] < ptNodeCodePoints[0]) {
continue;
diff --git a/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.h b/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.h
index 13d26ba91..ea17a31d3 100644
--- a/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.h
+++ b/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict.h
@@ -20,7 +20,7 @@
#include "dict_toolkit_defines.h"
#include "offdevice_intermediate_dict/offdevice_intermediate_dict_header.h"
#include "offdevice_intermediate_dict/offdevice_intermediate_dict_pt_node_array.h"
-#include "suggest/core/dictionary/property/word_property.h"
+#include "dictionary/property/word_property.h"
#include "utils/int_array_view.h"
namespace latinime {
diff --git a/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict_pt_node.h b/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict_pt_node.h
index 721ccd778..e7d7e13eb 100644
--- a/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict_pt_node.h
+++ b/native/dicttoolkit/src/offdevice_intermediate_dict/offdevice_intermediate_dict_pt_node.h
@@ -21,7 +21,7 @@
#include "dict_toolkit_defines.h"
#include "offdevice_intermediate_dict/offdevice_intermediate_dict_pt_node_array.h"
-#include "suggest/core/dictionary/property/word_property.h"
+#include "dictionary/property/word_property.h"
#include "utils/int_array_view.h"
namespace latinime {
diff --git a/native/dicttoolkit/tests/offdevice_intermediate_dict/offdevice_intermediate_dict_test.cpp b/native/dicttoolkit/tests/offdevice_intermediate_dict/offdevice_intermediate_dict_test.cpp
index f2e24ab5f..89598de60 100644
--- a/native/dicttoolkit/tests/offdevice_intermediate_dict/offdevice_intermediate_dict_test.cpp
+++ b/native/dicttoolkit/tests/offdevice_intermediate_dict/offdevice_intermediate_dict_test.cpp
@@ -20,7 +20,7 @@
#include <vector>
-#include "suggest/core/dictionary/property/word_property.h"
+#include "dictionary/property/word_property.h"
#include "utils/int_array_view.h"
namespace latinime {
diff --git a/native/jni/Android.bp b/native/jni/Android.bp
new file mode 100644
index 000000000..5649fc1ea
--- /dev/null
+++ b/native/jni/Android.bp
@@ -0,0 +1,215 @@
+// Copyright (C) 2013 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+filegroup {
+ name: "LATIN_IME_CORE_SRC_FILES",
+ srcs: [
+ "src/dictionary/header/header_policy.cpp",
+ "src/dictionary/header/header_read_write_utils.cpp",
+ "src/dictionary/property/ngram_context.cpp",
+ "src/dictionary/structure/dictionary_structure_with_buffer_policy_factory.cpp",
+ "src/dictionary/structure/pt_common/bigram/bigram_list_read_write_utils.cpp",
+ "src/dictionary/structure/pt_common/dynamic_pt_gc_event_listeners.cpp",
+ "src/dictionary/structure/pt_common/dynamic_pt_reading_helper.cpp",
+ "src/dictionary/structure/pt_common/dynamic_pt_reading_utils.cpp",
+ "src/dictionary/structure/pt_common/dynamic_pt_updating_helper.cpp",
+ "src/dictionary/structure/pt_common/dynamic_pt_writing_utils.cpp",
+ "src/dictionary/structure/pt_common/patricia_trie_reading_utils.cpp",
+ "src/dictionary/structure/pt_common/shortcut/shortcut_list_reading_utils.cpp",
+ "src/dictionary/structure/v2/patricia_trie_policy.cpp",
+ "src/dictionary/structure/v2/ver2_patricia_trie_node_reader.cpp",
+ "src/dictionary/structure/v2/ver2_pt_node_array_reader.cpp",
+ "src/dictionary/structure/v4/ver4_dict_buffers.cpp",
+ "src/dictionary/structure/v4/ver4_dict_constants.cpp",
+ "src/dictionary/structure/v4/ver4_patricia_trie_node_reader.cpp",
+ "src/dictionary/structure/v4/ver4_patricia_trie_node_writer.cpp",
+ "src/dictionary/structure/v4/ver4_patricia_trie_policy.cpp",
+ "src/dictionary/structure/v4/ver4_patricia_trie_reading_utils.cpp",
+ "src/dictionary/structure/v4/ver4_patricia_trie_writing_helper.cpp",
+ "src/dictionary/structure/v4/ver4_pt_node_array_reader.cpp",
+ "src/dictionary/structure/v4/content/dynamic_language_model_probability_utils.cpp",
+ "src/dictionary/structure/v4/content/language_model_dict_content.cpp",
+ "src/dictionary/structure/v4/content/language_model_dict_content_global_counters.cpp",
+ "src/dictionary/structure/v4/content/shortcut_dict_content.cpp",
+ "src/dictionary/structure/v4/content/sparse_table_dict_content.cpp",
+ "src/dictionary/structure/v4/content/terminal_position_lookup_table.cpp",
+ "src/dictionary/utils/buffer_with_extendable_buffer.cpp",
+ "src/dictionary/utils/byte_array_utils.cpp",
+ "src/dictionary/utils/dict_file_writing_utils.cpp",
+ "src/dictionary/utils/file_utils.cpp",
+ "src/dictionary/utils/forgetting_curve_utils.cpp",
+ "src/dictionary/utils/format_utils.cpp",
+ "src/dictionary/utils/mmapped_buffer.cpp",
+ "src/dictionary/utils/multi_bigram_map.cpp",
+ "src/dictionary/utils/probability_utils.cpp",
+ "src/dictionary/utils/sparse_table.cpp",
+ "src/dictionary/utils/trie_map.cpp",
+ "src/suggest/core/suggest.cpp",
+ "src/suggest/core/dicnode/dic_node.cpp",
+ "src/suggest/core/dicnode/dic_node_utils.cpp",
+ "src/suggest/core/dicnode/dic_nodes_cache.cpp",
+ "src/suggest/core/dictionary/dictionary.cpp",
+ "src/suggest/core/dictionary/dictionary_utils.cpp",
+ "src/suggest/core/dictionary/digraph_utils.cpp",
+ "src/suggest/core/dictionary/error_type_utils.cpp",
+ "src/suggest/core/layout/additional_proximity_chars.cpp",
+ "src/suggest/core/layout/proximity_info.cpp",
+ "src/suggest/core/layout/proximity_info_params.cpp",
+ "src/suggest/core/layout/proximity_info_state.cpp",
+ "src/suggest/core/layout/proximity_info_state_utils.cpp",
+ "src/suggest/core/policy/weighting.cpp",
+ "src/suggest/core/session/dic_traverse_session.cpp",
+ "src/suggest/core/result/suggestion_results.cpp",
+ "src/suggest/core/result/suggestions_output_utils.cpp",
+ "src/suggest/policyimpl/gesture/gesture_suggest_policy_factory.cpp",
+ "src/suggest/policyimpl/typing/scoring_params.cpp",
+ "src/suggest/policyimpl/typing/typing_scoring.cpp",
+ "src/suggest/policyimpl/typing/typing_suggest_policy.cpp",
+ "src/suggest/policyimpl/typing/typing_traversal.cpp",
+ "src/suggest/policyimpl/typing/typing_weighting.cpp",
+ "src/utils/autocorrection_threshold_utils.cpp",
+ "src/utils/char_utils.cpp",
+ "src/utils/jni_data_utils.cpp",
+ "src/utils/log_utils.cpp",
+ "src/utils/time_keeper.cpp",
+
+ // BACKWARD_V402
+ "src/dictionary/structure/backward/v402/ver4_dict_buffers.cpp",
+ "src/dictionary/structure/backward/v402/ver4_dict_constants.cpp",
+ "src/dictionary/structure/backward/v402/ver4_patricia_trie_node_reader.cpp",
+ "src/dictionary/structure/backward/v402/ver4_patricia_trie_node_writer.cpp",
+ "src/dictionary/structure/backward/v402/ver4_patricia_trie_policy.cpp",
+ "src/dictionary/structure/backward/v402/ver4_patricia_trie_reading_utils.cpp",
+ "src/dictionary/structure/backward/v402/ver4_patricia_trie_writing_helper.cpp",
+ "src/dictionary/structure/backward/v402/ver4_pt_node_array_reader.cpp",
+ "src/dictionary/structure/backward/v402/content/bigram_dict_content.cpp",
+ "src/dictionary/structure/backward/v402/content/probability_dict_content.cpp",
+ "src/dictionary/structure/backward/v402/content/shortcut_dict_content.cpp",
+ "src/dictionary/structure/backward/v402/content/sparse_table_dict_content.cpp",
+ "src/dictionary/structure/backward/v402/content/terminal_position_lookup_table.cpp",
+ "src/dictionary/structure/backward/v402/bigram/ver4_bigram_list_policy.cpp",
+ ],
+}
+
+cc_library {
+ name: "libjni_latinime",
+ host_supported: true,
+ product_specific: true,
+
+ sdk_version: "14",
+ cflags: [
+ "-Werror",
+ "-Wall",
+ "-Wextra",
+ "-Weffc++",
+ "-Wformat=2",
+ "-Wcast-qual",
+ "-Wcast-align",
+ "-Wwrite-strings",
+ "-Wfloat-equal",
+ "-Wpointer-arith",
+ "-Winit-self",
+ "-Wredundant-decls",
+ "-Woverloaded-virtual",
+ "-Wsign-promo",
+ "-Wno-system-headers",
+ "-Wno-format-nonliteral",
+
+ // To suppress compiler warnings for unused variables/functions used for debug features etc.
+ "-Wno-unused-parameter",
+ "-Wno-unused-function",
+ ],
+ local_include_dirs: ["src"],
+
+ srcs: [
+ "com_android_inputmethod_keyboard_ProximityInfo.cpp",
+ "com_android_inputmethod_latin_BinaryDictionary.cpp",
+ "com_android_inputmethod_latin_BinaryDictionaryUtils.cpp",
+ "com_android_inputmethod_latin_DicTraverseSession.cpp",
+ "jni_common.cpp",
+
+ ":LATIN_IME_CORE_SRC_FILES",
+ ],
+
+ target: {
+ android_x86: {
+ // HACK: -mstackrealign is required for x86 builds running on pre-KitKat devices to avoid crashes
+ // with SSE instructions.
+ cflags: ["-mstackrealign"],
+ },
+ android: {
+ stl: "libc++_static",
+ },
+ host: {
+ cflags: ["-DHOST_TOOL"],
+ },
+ },
+}
+
+cc_library_static {
+ name: "liblatinime_static_for_unittests",
+ host_supported: true,
+
+ cflags: [
+ "-Wno-unused-parameter",
+ "-Wno-unused-function",
+ "-Wall",
+ "-Werror",
+ ],
+ local_include_dirs: ["src"],
+ sdk_version: "14",
+ stl: "libc++_static",
+
+ srcs: [":LATIN_IME_CORE_SRC_FILES"],
+}
+
+cc_test {
+ name: "liblatinime_unittests",
+ host_supported: true,
+
+ cflags: [
+ "-Wno-unused-parameter",
+ "-Wno-unused-function",
+ "-Wall",
+ "-Werror",
+ ],
+ local_include_dirs: ["src"],
+ sdk_version: "14",
+ stl: "libc++_static",
+
+ srcs: [
+ "tests/defines_test.cpp",
+ "tests/dictionary/header/header_read_write_utils_test.cpp",
+ "tests/dictionary/structure/v4/content/language_model_dict_content_test.cpp",
+ "tests/dictionary/structure/v4/content/language_model_dict_content_global_counters_test.cpp",
+ "tests/dictionary/structure/v4/content/probability_entry_test.cpp",
+ "tests/dictionary/structure/v4/content/terminal_position_lookup_table_test.cpp",
+ "tests/dictionary/utils/bloom_filter_test.cpp",
+ "tests/dictionary/utils/buffer_with_extendable_buffer_test.cpp",
+ "tests/dictionary/utils/byte_array_utils_test.cpp",
+ "tests/dictionary/utils/format_utils_test.cpp",
+ "tests/dictionary/utils/probability_utils_test.cpp",
+ "tests/dictionary/utils/sparse_table_test.cpp",
+ "tests/dictionary/utils/trie_map_test.cpp",
+ "tests/suggest/core/dicnode/dic_node_pool_test.cpp",
+ "tests/suggest/core/layout/geometry_utils_test.cpp",
+ "tests/suggest/core/layout/normal_distribution_2d_test.cpp",
+ "tests/suggest/policyimpl/utils/damerau_levenshtein_edit_distance_policy_test.cpp",
+ "tests/utils/autocorrection_threshold_utils_test.cpp",
+ "tests/utils/char_utils_test.cpp",
+ "tests/utils/int_array_view_test.cpp",
+ "tests/utils/time_keeper_test.cpp",
+ ],
+ static_libs: ["liblatinime_static_for_unittests"],
+}
diff --git a/native/jni/Android.mk b/native/jni/Android.mk
deleted file mode 100644
index 53846485f..000000000
--- a/native/jni/Android.mk
+++ /dev/null
@@ -1,103 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-############ some local flags
-# If you change any of those flags, you need to rebuild both libjni_latinime_common_static
-# and the shared library that uses libjni_latinime_common_static.
-FLAG_DBG ?= false
-FLAG_DO_PROFILE ?= false
-
-######################################
-include $(CLEAR_VARS)
-
-LATIN_IME_SRC_DIR := src
-
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
-
-LOCAL_CFLAGS += -Werror -Wall -Wextra -Weffc++ -Wformat=2 -Wcast-qual -Wcast-align \
- -Wwrite-strings -Wfloat-equal -Wpointer-arith -Winit-self -Wredundant-decls \
- -Woverloaded-virtual -Wsign-promo -Wno-system-headers
-
-# To suppress compiler warnings for unused variables/functions used for debug features etc.
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function
-
-# HACK: -mstackrealign is required for x86 builds running on pre-KitKat devices to avoid crashes
-# with SSE instructions.
-ifeq ($(TARGET_ARCH), x86)
- LOCAL_CFLAGS += -mstackrealign
-endif # x86
-
-include $(LOCAL_PATH)/NativeFileList.mk
-
-LOCAL_SRC_FILES := \
- $(LATIN_IME_JNI_SRC_FILES) \
- $(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES))
-
-ifeq ($(FLAG_DO_PROFILE), true)
- $(warning Making profiling version of native library)
- LOCAL_CFLAGS += -DFLAG_DO_PROFILE -funwind-tables
-else # FLAG_DO_PROFILE
-ifeq ($(FLAG_DBG), true)
- $(warning Making debug version of native library)
- LOCAL_CFLAGS += -DFLAG_DBG -funwind-tables -fno-inline
-ifeq ($(FLAG_FULL_DBG), true)
- $(warning Making full debug version of native library)
- LOCAL_CFLAGS += -DFLAG_FULL_DBG
-endif # FLAG_FULL_DBG
-endif # FLAG_DBG
-endif # FLAG_DO_PROFILE
-
-LOCAL_MODULE := libjni_latinime_common_static
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SDK_VERSION := 14
-LOCAL_NDK_STL_VARIANT := c++_static
-
-include $(BUILD_STATIC_LIBRARY)
-######################################
-include $(CLEAR_VARS)
-
-# All code in LOCAL_WHOLE_STATIC_LIBRARIES will be built into this shared library.
-LOCAL_WHOLE_STATIC_LIBRARIES := libjni_latinime_common_static
-
-ifeq ($(FLAG_DO_PROFILE), true)
- $(warning Making profiling version of native library)
- LOCAL_LDFLAGS += -llog
-else # FLAG_DO_PROFILE
-ifeq ($(FLAG_DBG), true)
- $(warning Making debug version of native library)
- LOCAL_LDFLAGS += -llog
-endif # FLAG_DBG
-endif # FLAG_DO_PROFILE
-
-LOCAL_MODULE := libjni_latinime
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SDK_VERSION := 14
-LOCAL_NDK_STL_VARIANT := c++_static
-LOCAL_CFLAGS := -Wall -Werror
-LOCAL_LDFLAGS += -ldl
-
-include $(BUILD_SHARED_LIBRARY)
-#################### Clean up the tmp vars
-include $(LOCAL_PATH)/CleanupNativeFileList.mk
-
-#################### Unit test on host environment
-include $(LOCAL_PATH)/HostUnitTests.mk
-
-#################### Unit test on target environment
-include $(LOCAL_PATH)/TargetUnitTests.mk
-//LOCAL_CFLAGS += -Wall -Werror
diff --git a/native/jni/Application.mk b/native/jni/Application.mk
deleted file mode 100644
index ce095350e..000000000
--- a/native/jni/Application.mk
+++ /dev/null
@@ -1 +0,0 @@
-APP_STL := c++_static
diff --git a/native/jni/CleanupNativeFileList.mk b/native/jni/CleanupNativeFileList.mk
deleted file mode 100644
index eed6f1e63..000000000
--- a/native/jni/CleanupNativeFileList.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LATIN_IME_CORE_SRC_FILES :=
-LATIN_IME_CORE_SRC_FILES_BACKWARD_V401 :=
-LATIN_IME_CORE_TEST_FILES :=
-LATIN_IME_JNI_SRC_FILES :=
-LATIN_IME_SRC_DIR :=
diff --git a/native/jni/HostUnitTests.mk b/native/jni/HostUnitTests.mk
deleted file mode 100644
index 94cd764b4..000000000
--- a/native/jni/HostUnitTests.mk
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Host build is never supported in unbundled (NDK/tapas) build
-ifeq (,$(TARGET_BUILD_APPS))
-
-# HACK: Temporarily disable host tool build on Mac until the build system is ready for C++11.
-LATINIME_HOST_OSNAME := $(shell uname -s)
-ifneq ($(LATINIME_HOST_OSNAME), Darwin) # TODO: Remove this
-
-LOCAL_PATH := $(call my-dir)
-
-######################################
-include $(CLEAR_VARS)
-
-include $(LOCAL_PATH)/NativeFileList.mk
-
-#################### Host library for unit test
-LATIN_IME_SRC_DIR := src
-LOCAL_ADDRESS_SANITIZER := true
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function -Wall -Werror
-LOCAL_CXX_STL := libc++
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
-LOCAL_MODULE := liblatinime_host_static_for_unittests
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES))
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-#################### Host native tests
-include $(CLEAR_VARS)
-LATIN_IME_TEST_SRC_DIR := tests
-LOCAL_ADDRESS_SANITIZER := true
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function
-LOCAL_CFLAGS += -Wall -Werror
-LOCAL_CXX_STL := libc++
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
-LOCAL_MODULE := liblatinime_host_unittests
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_TEST_SRC_DIR)/, $(LATIN_IME_CORE_TEST_FILES))
-LOCAL_STATIC_LIBRARIES += liblatinime_host_static_for_unittests
-include $(BUILD_HOST_NATIVE_TEST)
-
-include $(LOCAL_PATH)/CleanupNativeFileList.mk
-
-endif # Darwin - TODO: Remove this
-
-endif # TARGET_BUILD_APPS
-
-#################### Clean up the tmp vars
-LATINIME_HOST_OSNAME :=
-LATIN_IME_SRC_DIR :=
-LATIN_IME_TEST_SRC_DIR :=
diff --git a/native/jni/NativeFileList.mk b/native/jni/NativeFileList.mk
deleted file mode 100644
index d8b69bfd7..000000000
--- a/native/jni/NativeFileList.mk
+++ /dev/null
@@ -1,146 +0,0 @@
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LATIN_IME_JNI_SRC_FILES := \
- com_android_inputmethod_keyboard_ProximityInfo.cpp \
- com_android_inputmethod_latin_BinaryDictionary.cpp \
- com_android_inputmethod_latin_BinaryDictionaryUtils.cpp \
- com_android_inputmethod_latin_DicTraverseSession.cpp \
- jni_common.cpp
-
-LATIN_IME_CORE_SRC_FILES := \
- $(addprefix dictionary/header/, \
- header_policy.cpp \
- header_read_write_utils.cpp) \
- dictionary/property/ngram_context.cpp \
- dictionary/structure/dictionary_structure_with_buffer_policy_factory.cpp \
- $(addprefix dictionary/structure/pt_common/, \
- bigram/bigram_list_read_write_utils.cpp \
- dynamic_pt_gc_event_listeners.cpp \
- dynamic_pt_reading_helper.cpp \
- dynamic_pt_reading_utils.cpp \
- dynamic_pt_updating_helper.cpp \
- dynamic_pt_writing_utils.cpp \
- patricia_trie_reading_utils.cpp \
- shortcut/shortcut_list_reading_utils.cpp) \
- $(addprefix dictionary/structure/v2/, \
- patricia_trie_policy.cpp \
- ver2_patricia_trie_node_reader.cpp \
- ver2_pt_node_array_reader.cpp) \
- $(addprefix dictionary/structure/v4/, \
- ver4_dict_buffers.cpp \
- ver4_dict_constants.cpp \
- ver4_patricia_trie_node_reader.cpp \
- ver4_patricia_trie_node_writer.cpp \
- ver4_patricia_trie_policy.cpp \
- ver4_patricia_trie_reading_utils.cpp \
- ver4_patricia_trie_writing_helper.cpp \
- ver4_pt_node_array_reader.cpp) \
- $(addprefix dictionary/structure/v4/content/, \
- dynamic_language_model_probability_utils.cpp \
- language_model_dict_content.cpp \
- language_model_dict_content_global_counters.cpp \
- shortcut_dict_content.cpp \
- sparse_table_dict_content.cpp \
- terminal_position_lookup_table.cpp) \
- $(addprefix dictionary/utils/, \
- buffer_with_extendable_buffer.cpp \
- byte_array_utils.cpp \
- dict_file_writing_utils.cpp \
- file_utils.cpp \
- forgetting_curve_utils.cpp \
- format_utils.cpp \
- mmapped_buffer.cpp \
- multi_bigram_map.cpp \
- probability_utils.cpp \
- sparse_table.cpp \
- trie_map.cpp ) \
- suggest/core/suggest.cpp \
- $(addprefix suggest/core/dicnode/, \
- dic_node.cpp \
- dic_node_utils.cpp \
- dic_nodes_cache.cpp) \
- $(addprefix suggest/core/dictionary/, \
- dictionary.cpp \
- dictionary_utils.cpp \
- digraph_utils.cpp \
- error_type_utils.cpp ) \
- $(addprefix suggest/core/layout/, \
- additional_proximity_chars.cpp \
- proximity_info.cpp \
- proximity_info_params.cpp \
- proximity_info_state.cpp \
- proximity_info_state_utils.cpp) \
- suggest/core/policy/weighting.cpp \
- suggest/core/session/dic_traverse_session.cpp \
- $(addprefix suggest/core/result/, \
- suggestion_results.cpp \
- suggestions_output_utils.cpp) \
- suggest/policyimpl/gesture/gesture_suggest_policy_factory.cpp \
- $(addprefix suggest/policyimpl/typing/, \
- scoring_params.cpp \
- typing_scoring.cpp \
- typing_suggest_policy.cpp \
- typing_traversal.cpp \
- typing_weighting.cpp) \
- $(addprefix utils/, \
- autocorrection_threshold_utils.cpp \
- char_utils.cpp \
- jni_data_utils.cpp \
- log_utils.cpp \
- time_keeper.cpp)
-
-LATIN_IME_CORE_SRC_FILES_BACKWARD_V402 := \
- $(addprefix dictionary/structure/backward/v402/, \
- ver4_dict_buffers.cpp \
- ver4_dict_constants.cpp \
- ver4_patricia_trie_node_reader.cpp \
- ver4_patricia_trie_node_writer.cpp \
- ver4_patricia_trie_policy.cpp \
- ver4_patricia_trie_reading_utils.cpp \
- ver4_patricia_trie_writing_helper.cpp \
- ver4_pt_node_array_reader.cpp) \
- $(addprefix dictionary/structure/backward/v402/content/, \
- bigram_dict_content.cpp \
- probability_dict_content.cpp \
- shortcut_dict_content.cpp \
- sparse_table_dict_content.cpp \
- terminal_position_lookup_table.cpp) \
- $(addprefix dictionary/structure/backward/v402/bigram/, \
- ver4_bigram_list_policy.cpp)
-
-LATIN_IME_CORE_SRC_FILES += $(LATIN_IME_CORE_SRC_FILES_BACKWARD_V402)
-
-LATIN_IME_CORE_TEST_FILES := \
- defines_test.cpp \
- dictionary/header/header_read_write_utils_test.cpp \
- dictionary/structure/v4/content/language_model_dict_content_test.cpp \
- dictionary/structure/v4/content/language_model_dict_content_global_counters_test.cpp \
- dictionary/structure/v4/content/probability_entry_test.cpp \
- dictionary/structure/v4/content/terminal_position_lookup_table_test.cpp \
- dictionary/utils/bloom_filter_test.cpp \
- dictionary/utils/buffer_with_extendable_buffer_test.cpp \
- dictionary/utils/byte_array_utils_test.cpp \
- dictionary/utils/format_utils_test.cpp \
- dictionary/utils/probability_utils_test.cpp \
- dictionary/utils/sparse_table_test.cpp \
- dictionary/utils/trie_map_test.cpp \
- suggest/core/dicnode/dic_node_pool_test.cpp \
- suggest/core/layout/geometry_utils_test.cpp \
- suggest/core/layout/normal_distribution_2d_test.cpp \
- suggest/policyimpl/utils/damerau_levenshtein_edit_distance_policy_test.cpp \
- utils/autocorrection_threshold_utils_test.cpp \
- utils/char_utils_test.cpp \
- utils/int_array_view_test.cpp \
- utils/time_keeper_test.cpp
diff --git a/native/jni/TargetUnitTests.mk b/native/jni/TargetUnitTests.mk
deleted file mode 100644
index 32aada057..000000000
--- a/native/jni/TargetUnitTests.mk
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright (C) 2014 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-######################################
-include $(CLEAR_VARS)
-
-include $(LOCAL_PATH)/NativeFileList.mk
-
-#################### Target library for unit test
-LATIN_IME_SRC_DIR := src
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function -Wall -Werror
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
-LOCAL_MODULE := liblatinime_target_static_for_unittests
-LOCAL_MODULE_TAGS := optional
-LOCAL_SRC_FILES := $(addprefix $(LATIN_IME_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES))
-LOCAL_SDK_VERSION := 14
-LOCAL_NDK_STL_VARIANT := c++_static
-include $(BUILD_STATIC_LIBRARY)
-
-#################### Target native tests
-include $(CLEAR_VARS)
-LATIN_IME_TEST_SRC_DIR := tests
-LOCAL_CFLAGS += -Wno-unused-parameter -Wno-unused-function -Wall -Werror
-LOCAL_C_INCLUDES += $(LOCAL_PATH)/$(LATIN_IME_SRC_DIR)
-LOCAL_MODULE := liblatinime_target_unittests
-LOCAL_MODULE_TAGS := tests
-LOCAL_SRC_FILES := \
- $(addprefix $(LATIN_IME_TEST_SRC_DIR)/, $(LATIN_IME_CORE_TEST_FILES))
-LOCAL_STATIC_LIBRARIES += liblatinime_target_static_for_unittests
-LOCAL_SDK_VERSION := 14
-LOCAL_NDK_STL_VARIANT := c++_static
-include $(BUILD_NATIVE_TEST)
-
-#################### Clean up the tmp vars
-LATIN_IME_SRC_DIR :=
-LATIN_IME_TEST_SRC_DIR :=
-include $(LOCAL_PATH)/CleanupNativeFileList.mk
diff --git a/native/jni/src/defines.h b/native/jni/src/defines.h
index 10b930e4f..1531b6cbe 100644
--- a/native/jni/src/defines.h
+++ b/native/jni/src/defines.h
@@ -17,6 +17,8 @@
#ifndef LATINIME_DEFINES_H
#define LATINIME_DEFINES_H
+#include <cstdint>
+
#ifdef __GNUC__
#define AK_FORCE_INLINE __attribute__((always_inline)) __inline__
#else // __GNUC__
@@ -51,7 +53,7 @@ AK_FORCE_INLINE static int intArrayToCharArray(const int *const source, const in
int si = 0;
int di = 0;
while (si < sourceSize && di < destLimit && 0 != source[si]) {
- const int codePoint = source[si++];
+ const uint32_t codePoint = static_cast<uint32_t>(source[si++]);
if (codePoint < 0x7F) { // One byte
dest[di++] = codePoint;
} else if (codePoint < 0x7FF) { // Two bytes
diff --git a/native/jni/src/dictionary/structure/v4/ver4_patricia_trie_policy.cpp b/native/jni/src/dictionary/structure/v4/ver4_patricia_trie_policy.cpp
index 1dbec5545..6f96a5a0b 100644
--- a/native/jni/src/dictionary/structure/v4/ver4_patricia_trie_policy.cpp
+++ b/native/jni/src/dictionary/structure/v4/ver4_patricia_trie_policy.cpp
@@ -141,7 +141,7 @@ void Ver4PatriciaTriePolicy::iterateNgramEntries(const WordIdArrayView prevWordI
}
const auto languageModelDictContent = mBuffers->getLanguageModelDictContent();
for (size_t i = 1; i <= prevWordIds.size(); ++i) {
- for (const auto entry : languageModelDictContent->getProbabilityEntries(
+ for (const auto& entry : languageModelDictContent->getProbabilityEntries(
prevWordIds.limit(i))) {
const ProbabilityEntry &probabilityEntry = entry.getProbabilityEntry();
if (!probabilityEntry.isValid()) {
@@ -516,7 +516,7 @@ const WordProperty Ver4PatriciaTriePolicy::getWordProperty(
int ngramPrevWordsCodePoints[MAX_PREV_WORD_COUNT_FOR_N_GRAM][MAX_WORD_LENGTH];
int ngramPrevWordsCodePointCount[MAX_PREV_WORD_COUNT_FOR_N_GRAM];
bool ngramPrevWordIsBeginningOfSentense[MAX_PREV_WORD_COUNT_FOR_N_GRAM];
- for (const auto entry : languageModelDictContent->exportAllNgramEntriesRelatedToWord(
+ for (const auto& entry : languageModelDictContent->exportAllNgramEntriesRelatedToWord(
mHeaderPolicy, wordId)) {
const int codePointCount = getCodePointsAndReturnCodePointCount(entry.getTargetWordId(),
MAX_WORD_LENGTH, ngramTargetCodePoints);
diff --git a/native/jni/src/dictionary/utils/binary_dictionary_bigrams_iterator.h b/native/jni/src/dictionary/utils/binary_dictionary_bigrams_iterator.h
index 8a614730b..a30336475 100644
--- a/native/jni/src/dictionary/utils/binary_dictionary_bigrams_iterator.h
+++ b/native/jni/src/dictionary/utils/binary_dictionary_bigrams_iterator.h
@@ -35,7 +35,7 @@ class BinaryDictionaryBigramsIterator {
mBigramPos(NOT_A_DICT_POS), mProbability(NOT_A_PROBABILITY),
mHasNext(pos != NOT_A_DICT_POS) {}
- BinaryDictionaryBigramsIterator(BinaryDictionaryBigramsIterator &&bigramsIterator)
+ BinaryDictionaryBigramsIterator(BinaryDictionaryBigramsIterator &&bigramsIterator) noexcept
: mBigramsStructurePolicy(bigramsIterator.mBigramsStructurePolicy),
mPos(bigramsIterator.mPos), mBigramPos(bigramsIterator.mBigramPos),
mProbability(bigramsIterator.mProbability), mHasNext(bigramsIterator.mHasNext) {}
diff --git a/native/jni/src/dictionary/utils/binary_dictionary_shortcut_iterator.h b/native/jni/src/dictionary/utils/binary_dictionary_shortcut_iterator.h
index a4ddd58c2..e14805e37 100644
--- a/native/jni/src/dictionary/utils/binary_dictionary_shortcut_iterator.h
+++ b/native/jni/src/dictionary/utils/binary_dictionary_shortcut_iterator.h
@@ -31,7 +31,7 @@ class BinaryDictionaryShortcutIterator {
mPos(shortcutStructurePolicy->getStartPos(shortcutPos)),
mHasNextShortcutTarget(shortcutPos != NOT_A_DICT_POS) {}
- BinaryDictionaryShortcutIterator(const BinaryDictionaryShortcutIterator &&shortcutIterator)
+ BinaryDictionaryShortcutIterator(const BinaryDictionaryShortcutIterator &&shortcutIterator) noexcept
: mShortcutStructurePolicy(shortcutIterator.mShortcutStructurePolicy),
mPos(shortcutIterator.mPos),
mHasNextShortcutTarget(shortcutIterator.mHasNextShortcutTarget) {}
diff --git a/native/jni/tests/dictionary/structure/v4/content/language_model_dict_content_test.cpp b/native/jni/tests/dictionary/structure/v4/content/language_model_dict_content_test.cpp
index ca8626e2f..ab11975c2 100644
--- a/native/jni/tests/dictionary/structure/v4/content/language_model_dict_content_test.cpp
+++ b/native/jni/tests/dictionary/structure/v4/content/language_model_dict_content_test.cpp
@@ -80,7 +80,7 @@ TEST(LanguageModelDictContentTest, TestIterateProbabilityEntry) {
languageModelDictContent.setProbabilityEntry(wordId, &originalEntry);
}
std::unordered_set<int> wordIdSet(std::begin(wordIds), std::end(wordIds));
- for (const auto entry : languageModelDictContent.getProbabilityEntries(WordIdArrayView())) {
+ for (const auto& entry : languageModelDictContent.getProbabilityEntries(WordIdArrayView())) {
EXPECT_EQ(originalEntry.getFlags(), entry.getProbabilityEntry().getFlags());
EXPECT_EQ(originalEntry.getProbability(), entry.getProbabilityEntry().getProbability());
wordIdSet.erase(entry.getWordId());
diff --git a/tests/Android.bp b/tests/Android.bp
new file mode 100644
index 000000000..76681f669
--- /dev/null
+++ b/tests/Android.bp
@@ -0,0 +1,46 @@
+// Copyright (C) 2011 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test {
+ name: "LatinIMETests",
+
+ certificate: "shared",
+
+ aaptflags: [
+ // Do not compress dictionary files to mmap dict data runtime
+ "-0 .dict",
+
+ // Do not compress test data file
+ "-0 .txt",
+ ],
+
+ static_libs: [
+ "androidx.test.rules",
+ "mockito-target-minus-junit4",
+ ],
+ libs: [
+ "android.test.mock.stubs",
+ "android.test.runner.stubs",
+ "android.test.base.stubs",
+ ],
+
+ // Include all test java files.
+ srcs: ["src/**/*.java"],
+
+ instrumentation_for: "LatinIME",
+
+ min_sdk_version: "14",
+ target_sdk_version: "21",
+ sdk_version: "current",
+}
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index 7c0bb4f71..000000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,46 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# We only want this apk build for tests.
-LOCAL_MODULE_TAGS := tests
-LOCAL_CERTIFICATE := shared
-
-# Do not compress dictionary files to mmap dict data runtime
-LOCAL_AAPT_FLAGS += -0 .dict
-# Do not compress test data file
-LOCAL_AAPT_FLAGS += -0 .txt
-
-LOCAL_STATIC_JAVA_LIBRARIES := \
- android-support-test \
- mockito-target-minus-junit4
-
-LOCAL_JAVA_LIBRARIES := \
- android.test.mock.stubs \
- android.test.runner.stubs \
- android.test.base.stubs \
-
-
-# Include all test java files.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_PACKAGE_NAME := LatinIMETests
-
-LOCAL_INSTRUMENTATION_FOR := LatinIME
-
-LOCAL_SDK_VERSION := current
-
-include $(BUILD_PACKAGE)
diff --git a/tests/AndroidManifest.xml b/tests/AndroidManifest.xml
index c7a9e13a2..e788e0b7c 100644
--- a/tests/AndroidManifest.xml
+++ b/tests/AndroidManifest.xml
@@ -15,9 +15,10 @@
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.android.inputmethod.latin.tests">
+ package="com.android.inputmethod.latin.tests"
+ android:versionCode="28">
- <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
+ <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
@@ -27,7 +28,7 @@
<!-- meta-data android:name="com.android.contacts.iconset" android:resource="@xml/iconset" /-->
</application>
- <instrumentation android:name="android.support.test.runner.AndroidJUnitRunner"
+ <instrumentation android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="com.android.inputmethod.latin"
android:label="LatinIME tests">
</instrumentation>
diff --git a/tests/AndroidTest.xml b/tests/AndroidTest.xml
new file mode 100644
index 000000000..41334d5a8
--- /dev/null
+++ b/tests/AndroidTest.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2018 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration description="Runs Tests for LatinIME.">
+ <!--
+ To run this test with atest, run the following commands:
+
+ tapas adb LatinIME LatinIMETests arm64 userdebug && \
+ DISABLE_PROGUARD=true make -j LatinIME && \
+ adb install -r $OUT/system/app/LatinIME/LatinIME.apk && \
+ atest LatinIMETests
+
+ currently tradefed does not look up files under $OUT/system/
+ hence we cannot rely on "test-file-name" to install LatinIME.apk
+ -->
+
+ <target_preparer class="com.android.tradefed.targetprep.TestAppInstallSetup">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="LatinIMETests.apk" />
+ </target_preparer>
+
+ <option name="test-tag" value="LatinIMETests" />
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="package" value="com.android.inputmethod.latin.tests" />
+ <option name="runner" value="androidx.test.runner.AndroidJUnitRunner" />
+ <option name="hidden-api-checks" value="false"/>
+ </test>
+</configuration>
diff --git a/tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java b/tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java
index 67e76464b..6203238b8 100644
--- a/tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java
+++ b/tests/src/com/android/inputmethod/compat/LocaleSpanCompatUtilsTests.java
@@ -16,18 +16,28 @@
package com.android.inputmethod.compat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import android.graphics.Typeface;
import android.os.Build;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.style.StyleSpan;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.Locale;
@SmallTest
-public class LocaleSpanCompatUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class LocaleSpanCompatUtilsTests {
+ @Test
public void testInstantiatable() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
// LocaleSpan isn't yet available.
@@ -61,6 +71,7 @@ public class LocaleSpanCompatUtilsTests extends AndroidTestCase {
assertEquals(expectedCount, spans.length);
}
+ @Test
public void testUpdateLocaleSpan() {
if (!LocaleSpanCompatUtils.isLocaleSpanAvailable()) {
return;
diff --git a/tests/src/com/android/inputmethod/compat/SuggestionSpanUtilsTest.java b/tests/src/com/android/inputmethod/compat/SuggestionSpanUtilsTest.java
index 2d6d28f2b..a0544d62a 100644
--- a/tests/src/com/android/inputmethod/compat/SuggestionSpanUtilsTest.java
+++ b/tests/src/com/android/inputmethod/compat/SuggestionSpanUtilsTest.java
@@ -16,17 +16,26 @@
package com.android.inputmethod.compat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import android.annotation.TargetApi;
+import android.content.Context;
import android.os.Build;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.style.SuggestionSpan;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Locale;
@@ -34,7 +43,12 @@ import java.util.Locale;
import javax.annotation.Nullable;
@SmallTest
-public class SuggestionSpanUtilsTest extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class SuggestionSpanUtilsTest {
+
+ private Context getContext() {
+ return InstrumentationRegistry.getTargetContext();
+ }
/**
* Helper method to create a dummy {@link SuggestedWordInfo}.
@@ -91,6 +105,7 @@ public class SuggestionSpanUtilsTest extends AndroidTestCase {
}
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
+ @Test
public void testGetTextWithAutoCorrectionIndicatorUnderline() {
final String ORIGINAL_TEXT = "Hey!";
final Locale NONNULL_LOCALE = new Locale("en", "GB");
@@ -107,6 +122,7 @@ public class SuggestionSpanUtilsTest extends AndroidTestCase {
}
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1)
+ @Test
public void testGetTextWithAutoCorrectionIndicatorUnderlineRootLocale() {
final String ORIGINAL_TEXT = "Hey!";
final CharSequence text = SuggestionSpanUtils.getTextWithAutoCorrectionIndicatorUnderline(
@@ -121,6 +137,7 @@ public class SuggestionSpanUtilsTest extends AndroidTestCase {
new String[]{}, Locale.ROOT, text);
}
+ @Test
public void testGetTextWithSuggestionSpan() {
final SuggestedWordInfo prediction1 =
createWordInfo("Quality", SuggestedWordInfo.KIND_PREDICTION);
@@ -218,6 +235,7 @@ public class SuggestionSpanUtilsTest extends AndroidTestCase {
}
}
+ @Test
public void testFindFirstLocaleFromSuggestionSpans() {
final String[] suggestions = new String[] {"Quality", "Speed", "Price"};
final SuggestionSpan nullLocaleSpan = new SuggestionSpan((Locale)null, suggestions, 0);
diff --git a/tests/src/com/android/inputmethod/compat/TextInfoCompatUtilsTests.java b/tests/src/com/android/inputmethod/compat/TextInfoCompatUtilsTests.java
index c399cced6..d4dbfd4c6 100644
--- a/tests/src/com/android/inputmethod/compat/TextInfoCompatUtilsTests.java
+++ b/tests/src/com/android/inputmethod/compat/TextInfoCompatUtilsTests.java
@@ -16,10 +16,10 @@
package com.android.inputmethod.compat;
+import static org.junit.Assert.assertTrue;
+
import android.graphics.Typeface;
import android.os.Parcel;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
@@ -27,10 +27,17 @@ import android.text.style.StyleSpan;
import android.text.style.URLSpan;
import android.view.textservice.TextInfo;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.Arrays;
@SmallTest
-public class TextInfoCompatUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class TextInfoCompatUtilsTests {
final private static String TEST_TEXT = "0123456789";
final private static int TEST_COOKIE = 0x1234;
final private static int TEST_SEQUENCE_NUMBER = 0x4321;
@@ -45,6 +52,7 @@ public class TextInfoCompatUtilsTests extends AndroidTestCase {
final private static int TEST_URL_SPAN_END = 7;
final private static int TEST_URL_SPAN_FLAGS = Spanned.SPAN_EXCLUSIVE_EXCLUSIVE;
+ @Test
public void testGetCharSequence() {
final SpannableString text = new SpannableString(TEST_TEXT);
text.setSpan(TEST_STYLE_SPAN, TEST_STYLE_SPAN_START, TEST_STYLE_SPAN_END,
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutTest.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutTest.java
index 1e1f82fc0..ddace1a38 100644
--- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutTest.java
+++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutTest.java
@@ -18,15 +18,17 @@ package com.android.inputmethod.keyboard;
import static org.junit.Assert.assertEquals;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import java.util.ArrayList;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.ArrayList;
@SmallTest
+@RunWith(AndroidJUnit4.class)
public class KeyboardLayoutTest {
-
@Test
public void testNewKeyboardLayout() {
KeyboardLayout keyboardLayout = KeyboardLayout
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardThemeTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardThemeTests.java
index 33e88c13b..2f8140e23 100644
--- a/tests/src/com/android/inputmethod/keyboard/KeyboardThemeTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/KeyboardThemeTests.java
@@ -21,17 +21,30 @@ import static com.android.inputmethod.keyboard.KeyboardTheme.THEME_ID_KLP;
import static com.android.inputmethod.keyboard.KeyboardTheme.THEME_ID_LXX_DARK;
import static com.android.inputmethod.keyboard.KeyboardTheme.THEME_ID_LXX_LIGHT;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import android.content.Context;
import android.content.SharedPreferences;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.preference.PreferenceManager;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import java.util.Arrays;
@SmallTest
-public class KeyboardThemeTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class KeyboardThemeTests {
private SharedPreferences mPrefs;
private static final int THEME_ID_NULL = -1;
@@ -39,9 +52,12 @@ public class KeyboardThemeTests extends AndroidTestCase {
private static final int THEME_ID_ILLEGAL = -3;
private static final String ILLEGAL_THEME_ID_STRING = "ThisCausesNumberFormatExecption";
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ private Context getContext() {
+ return InstrumentationRegistry.getTargetContext();
+ }
+
+ @Before
+ public void setUp() throws Exception {
mPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
}
@@ -110,6 +126,7 @@ public class KeyboardThemeTests extends AndroidTestCase {
assertKeyboardThemePreference(sdkVersion, THEME_ID_ILLEGAL, defaultThemeId);
}
+ @Test
public void testKeyboardThemePreferenceOnKlp() {
assertKeyboardThemePreferenceOnKlp(VERSION_CODES.ICE_CREAM_SANDWICH);
assertKeyboardThemePreferenceOnKlp(VERSION_CODES.ICE_CREAM_SANDWICH_MR1);
@@ -130,6 +147,7 @@ public class KeyboardThemeTests extends AndroidTestCase {
assertKeyboardThemePreference(sdkVersion, THEME_ID_ILLEGAL, defaultThemeId);
}
+ @Test
public void testKeyboardThemePreferenceOnLxx() {
assertKeyboardThemePreferenceOnLxx(Build.VERSION_CODES.LOLLIPOP);
}
@@ -165,6 +183,7 @@ public class KeyboardThemeTests extends AndroidTestCase {
assertDefaultKeyboardTheme(sdkVersion, THEME_ID_ILLEGAL, THEME_ID_KLP);
}
+ @Test
public void testDefaultKeyboardThemeOnKlp() {
assertDefaultKeyboardThemeOnKlp(VERSION_CODES.ICE_CREAM_SANDWICH);
assertDefaultKeyboardThemeOnKlp(VERSION_CODES.ICE_CREAM_SANDWICH_MR1);
@@ -183,6 +202,7 @@ public class KeyboardThemeTests extends AndroidTestCase {
assertDefaultKeyboardTheme(sdkVersion, THEME_ID_ILLEGAL, THEME_ID_LXX_LIGHT);
}
+ @Test
public void testDefaultKeyboardThemeOnLxx() {
assertDefaultKeyboardThemeOnLxx(Build.VERSION_CODES.LOLLIPOP);
}
@@ -231,6 +251,7 @@ public class KeyboardThemeTests extends AndroidTestCase {
}
// Upgrading keyboard on I,J and K.
+ @Test
public void testUpgradeKeyboardToLxxOnKlp() {
assertUpgradeKeyboardToLxxOnKlp(VERSION_CODES.ICE_CREAM_SANDWICH);
assertUpgradeKeyboardToLxxOnKlp(VERSION_CODES.ICE_CREAM_SANDWICH_MR1);
@@ -250,6 +271,7 @@ public class KeyboardThemeTests extends AndroidTestCase {
}
// Upgrading keyboard on L.
+ @Test
public void testUpgradeKeyboardToLxxOnLxx() {
assertUpgradeKeyboardToLxxOnLxx(Build.VERSION_CODES.LOLLIPOP);
}
@@ -293,6 +315,7 @@ public class KeyboardThemeTests extends AndroidTestCase {
}
// Update platform from I,J, and K to I,J, and K
+ @Test
public void testUpgradePlatformToKlpFromKlp() {
assertUpgradePlatformToKlpFrom(VERSION_CODES.ICE_CREAM_SANDWICH);
assertUpgradePlatformToKlpFrom(VERSION_CODES.ICE_CREAM_SANDWICH_MR1);
@@ -318,6 +341,7 @@ public class KeyboardThemeTests extends AndroidTestCase {
}
// Update platform from I,J, and K to L
+ @Test
public void testUpgradePlatformToLxx() {
assertUpgradePlatformToLxxFrom(VERSION_CODES.ICE_CREAM_SANDWICH);
assertUpgradePlatformToLxxFrom(VERSION_CODES.ICE_CREAM_SANDWICH_MR1);
@@ -328,6 +352,7 @@ public class KeyboardThemeTests extends AndroidTestCase {
}
// Update platform from L to L.
+ @Test
public void testUpgradePlatformToLxxFromLxx() {
final int oldSdkVersion = Build.VERSION_CODES.LOLLIPOP;
final int newSdkVersion = Build.VERSION_CODES.LOLLIPOP;
@@ -364,10 +389,12 @@ public class KeyboardThemeTests extends AndroidTestCase {
}
}
+ @Test
public void testSortedKeyboardTheme() {
assertSortedKeyboardThemeArray(KeyboardTheme.KEYBOARD_THEMES);
}
+ @Test
public void testSortedAvailableKeyboardTheme() {
assertSortedKeyboardThemeArray(KeyboardTheme.getAvailableThemeArray(getContext()));
}
@@ -384,6 +411,7 @@ public class KeyboardThemeTests extends AndroidTestCase {
assertSortedKeyboardThemeArray(LIMITED_THEMES);
}
+ @Test
public void testMissingSelectedThemeIcs() {
// Clean up preferences.
setKeyboardThemePreference(KeyboardTheme.KLP_KEYBOARD_THEME_KEY, THEME_ID_NULL);
@@ -399,6 +427,7 @@ public class KeyboardThemeTests extends AndroidTestCase {
assertEquals(THEME_ID_KLP, actualTheme.mThemeId);
}
+ @Test
public void testMissingSelectedThemeKlp() {
// Clean up preferences.
setKeyboardThemePreference(KeyboardTheme.KLP_KEYBOARD_THEME_KEY, THEME_ID_NULL);
@@ -414,6 +443,7 @@ public class KeyboardThemeTests extends AndroidTestCase {
assertEquals(THEME_ID_KLP, actualTheme.mThemeId);
}
+ @Test
public void testMissingSelectedThemeLxx() {
// Clean up preferences.
setKeyboardThemePreference(KeyboardTheme.KLP_KEYBOARD_THEME_KEY, THEME_ID_NULL);
diff --git a/tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderAutoOrderTests.java b/tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderAutoOrderTests.java
index ebefe2d0e..90963d4ca 100644
--- a/tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderAutoOrderTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderAutoOrderTests.java
@@ -16,13 +16,21 @@
package com.android.inputmethod.keyboard;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import androidx.test.filters.MediumTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.keyboard.MoreKeysKeyboard.MoreKeysKeyboardParams;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
@MediumTest
-public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class MoreKeysKeyboardBuilderAutoOrderTests {
private static final int WIDTH = 10;
private static final int HEIGHT = 10;
@@ -38,11 +46,6 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
private static final int XPOS_R1 = WIDTH * 8 + WIDTH / 2;
private static final int XPOS_R0 = WIDTH * 9 + WIDTH / 2;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
private static MoreKeysKeyboardParams createParams(final int numKeys, final int columnNum,
final int coordXInParent) {
final MoreKeysKeyboardParams params = new MoreKeysKeyboardParams();
@@ -52,6 +55,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
return params;
}
+ @Test
public void testLayoutError() {
MoreKeysKeyboardParams params = null;
try {
@@ -69,6 +73,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// "<1>" is the default key.
// <1>
+ @Test
public void testLayout1KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_M0);
assertEquals("1 key auto 5 M0 columns", 1, params.mNumColumns);
@@ -81,6 +86,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |<1>
+ @Test
public void testLayout1KeyAuto5L0() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L0);
assertEquals("1 key auto 5 L0 columns", 1, params.mNumColumns);
@@ -93,6 +99,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ <1>
+ @Test
public void testLayout1KeyAuto5L1() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L1);
assertEquals("1 key auto 5 L1 columns", 1, params.mNumColumns);
@@ -105,6 +112,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ ___ <1>
+ @Test
public void testLayout1KeyAuto5L2() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L2);
assertEquals("1 key auto 5 L2 columns", 1, params.mNumColumns);
@@ -117,6 +125,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// <1>|
+ @Test
public void testLayout1KeyAuto5R0() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R0);
assertEquals("1 key auto 5 R0 columns", 1, params.mNumColumns);
@@ -129,6 +138,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// <1> ___|
+ @Test
public void testLayout1KeyAuto5R1() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R1);
assertEquals("1 key auto 5 R1 columns", 1, params.mNumColumns);
@@ -141,6 +151,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// <1> ___ ___|
+ @Test
public void testLayout1KeyAuto5R2() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R2);
assertEquals("1 key auto 5 R2 columns", 1, params.mNumColumns);
@@ -153,6 +164,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// <1> [2]
+ @Test
public void testLayout2KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_M0);
assertEquals("2 key auto 5 M0 columns", 2, params.mNumColumns);
@@ -166,6 +178,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |<1> [2]
+ @Test
public void testLayout2KeyAuto5L0() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L0);
assertEquals("2 key auto 5 L0 columns", 2, params.mNumColumns);
@@ -179,6 +192,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ <1> [2]
+ @Test
public void testLayout2KeyAuto5L1() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L1);
assertEquals("2 key auto 5 L1 columns", 2, params.mNumColumns);
@@ -192,6 +206,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ ___ <1> [2]
+ @Test
public void testLayout2KeyAuto5L2() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L2);
assertEquals("2 key auto 5 L2 columns", 2, params.mNumColumns);
@@ -205,6 +220,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [2] <1>|
+ @Test
public void testLayout2KeyAuto5R0() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R0);
assertEquals("2 key auto 5 R0 columns", 2, params.mNumColumns);
@@ -218,6 +234,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [2] <1> ___|
+ @Test
public void testLayout2KeyAuto5R1() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R1);
assertEquals("2 key auto 5 R1 columns", 2, params.mNumColumns);
@@ -231,6 +248,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// <1> [2] ___|
+ @Test
public void testLayout2KeyAuto5R2() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R2);
assertEquals("2 key auto 5 R2 columns", 2, params.mNumColumns);
@@ -244,6 +262,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [3] <1> [2]
+ @Test
public void testLayout3KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_M0);
assertEquals("3 key auto 5 M0 columns", 3, params.mNumColumns);
@@ -258,6 +277,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |<1> [2] [3]
+ @Test
public void testLayout3KeyAuto5L0() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L0);
assertEquals("3 key auto 5 L0 columns", 3, params.mNumColumns);
@@ -272,6 +292,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3]
+ @Test
public void testLayout3KeyAuto5L1() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L1);
assertEquals("3 key auto 5 L1 columns", 3, params.mNumColumns);
@@ -286,6 +307,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ [3] <1> [2]
+ @Test
public void testLayout3KeyAuto5L2() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L2);
assertEquals("3 key auto 5 L2 columns", 3, params.mNumColumns);
@@ -300,6 +322,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [3] [2] <1>|
+ @Test
public void testLayout3KeyAuto5R0() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R0);
assertEquals("3 key auto 5 R0 columns", 3, params.mNumColumns);
@@ -314,6 +337,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [3] [2] <1> ___|
+ @Test
public void testLayout3KeyAuto5R1() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R1);
assertEquals("3 key auto 5 R1 columns", 3, params.mNumColumns);
@@ -328,6 +352,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [3] <1> [2] ___|
+ @Test
public void testLayout3KeyAuto5R2() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R2);
assertEquals("3 key auto 5 R2 columns", 3, params.mNumColumns);
@@ -343,6 +368,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [3]
// <1> [2]
+ @Test
public void testLayout3KeyAuto2M0() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_M0);
assertEquals("3 key auto 2 M0 columns", 2, params.mNumColumns);
@@ -358,6 +384,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |[3]
// |<1> [2]
+ @Test
public void testLayout3KeyAuto2L0() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L0);
assertEquals("3 key auto 2 L0 columns", 2, params.mNumColumns);
@@ -373,6 +400,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [3]
// |___ <1> [2]
+ @Test
public void testLayout3KeyAuto2L1() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L1);
assertEquals("3 key auto 2 L1 columns", 2, params.mNumColumns);
@@ -388,6 +416,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// | [3]
// |___ ___ <1> [2]
+ @Test
public void testLayout3KeyAuto2L2() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L2);
assertEquals("3 key auto 2 L2 columns", 2, params.mNumColumns);
@@ -403,6 +432,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [3]|
// [2] <1>|
+ @Test
public void testLayout3KeyAuto2R0() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R0);
assertEquals("3 key auto 2 R0 columns", 2, params.mNumColumns);
@@ -418,6 +448,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [3] |
// [2] <1> ___|
+ @Test
public void testLayout3KeyAuto2R1() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R1);
assertEquals("3 key auto 2 R1 columns", 2, params.mNumColumns);
@@ -433,6 +464,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [3] |
// <1> [2] ___|
+ @Test
public void testLayout3KeyAuto2R2() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R2);
assertEquals("3 key auto 2 R2 columns", 2, params.mNumColumns);
@@ -448,6 +480,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [4]
// [3] <1> [2]
+ @Test
public void testLayout4KeyAuto3M0() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_M0);
assertEquals("4 key auto 3 M0 columns", 3, params.mNumColumns);
@@ -464,6 +497,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |[4]
// |<1> [2] [3]
+ @Test
public void testLayout4KeyAuto3L0() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L0);
assertEquals("4 key auto 3 L0 columns", 3, params.mNumColumns);
@@ -480,6 +514,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [4]
// |___ <1> [2] [3]
+ @Test
public void testLayout4KeyAuto3L1() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L1);
assertEquals("4 key auto 3 L1 columns", 3, params.mNumColumns);
@@ -496,6 +531,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ ___ [4]
// |___ [3] <1> [2]
+ @Test
public void testLayout4KeyAuto3L2() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L2);
assertEquals("4 key auto 3 L2 columns", 3, params.mNumColumns);
@@ -512,6 +548,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [4]|
// [3] [2] <1>|
+ @Test
public void testLayout4KeyAuto3R0() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R0);
assertEquals("4 key auto 3 R0 columns", 3, params.mNumColumns);
@@ -528,6 +565,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [4] ___|
// [3] [2] <1> ___|
+ @Test
public void testLayout4KeyAuto3R1() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R1);
assertEquals("4 key auto 3 R1 columns", 3, params.mNumColumns);
@@ -544,6 +582,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [4] ___|
// [3] <1> [2] ___|
+ @Test
public void testLayout4KeyAuto3R2() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R2);
assertEquals("4 key auto 3 R2 columns", 3, params.mNumColumns);
@@ -559,6 +598,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [3] <1> [2] [4]
+ @Test
public void testLayout4KeyAuto4M0() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_M0);
assertEquals("4 key auto 4 M0 columns", 4, params.mNumColumns);
@@ -574,6 +614,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |<1> [2] [3] [4]
+ @Test
public void testLayout4KeyAuto4L0() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_L0);
assertEquals("4 key auto 4 L0 columns", 4, params.mNumColumns);
@@ -589,6 +630,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout4KeyAuto4L1() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_L1);
assertEquals("4 key auto 4 L1 columns", 4, params.mNumColumns);
@@ -604,6 +646,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ [3] <1> [2] [4]
+ @Test
public void testLayout4KeyAuto4L2() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_L2);
assertEquals("4 key auto 4 L2 columns", 4, params.mNumColumns);
@@ -619,6 +662,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [4] [3] [2] <1>|
+ @Test
public void testLayout4KeyAuto4R0() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_R0);
assertEquals("4 key auto 4 R0 columns", 4, params.mNumColumns);
@@ -634,6 +678,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [4] [3] [2] <1> ___|
+ @Test
public void testLayout4KeyAuto4R1() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_R1);
assertEquals("4 key auto 4 R1 columns", 4, params.mNumColumns);
@@ -649,6 +694,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [4] [3] <1> [2] ___|
+ @Test
public void testLayout4KeyAuto4R2() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_R2);
assertEquals("4 key auto 4 R2 columns", 4, params.mNumColumns);
@@ -664,6 +710,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [3] <1> [2] [4]
+ @Test
public void testLayout4KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_M0);
assertEquals("4 key auto 5 M0 columns", 4, params.mNumColumns);
@@ -679,6 +726,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |<1> [2] [3] [4]
+ @Test
public void testLayout4KeyAuto5L0() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L0);
assertEquals("4 key auto 5 L0 columns", 4, params.mNumColumns);
@@ -694,6 +742,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout4KeyAuto5L1() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L1);
assertEquals("4 key auto 5 L1 columns", 4, params.mNumColumns);
@@ -709,6 +758,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ [3] <1> [2] [4]
+ @Test
public void testLayout4KeyAuto5L2() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L2);
assertEquals("4 key auto 5 L2 columns", 4, params.mNumColumns);
@@ -724,6 +774,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [4] [3] [2] <1>|
+ @Test
public void testLayout4KeyAuto5R0() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R0);
assertEquals("4 key auto 5 R0 columns", 4, params.mNumColumns);
@@ -739,6 +790,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [4] [3] [2] <1> ___|
+ @Test
public void testLayout4KeyAuto5R1() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R1);
assertEquals("4 key auto 5 R1 columns", 4, params.mNumColumns);
@@ -754,6 +806,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [4] [3] <1> [2] ___|
+ @Test
public void testLayout4KeyAuto5R2() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R2);
assertEquals("4 key auto 5 R2 columns", 4, params.mNumColumns);
@@ -770,6 +823,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [4] [5]
// [3] <1> [2]
+ @Test
public void testLayout5KeyAuto3M0() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_M0);
assertEquals("5 key auto 3 M0 columns", 3, params.mNumColumns);
@@ -787,6 +841,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |[4] [5]
// |<1> [2] [3]
+ @Test
public void testLayout5KeyAuto3L0() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L0);
assertEquals("5 key auto 3 L0 columns", 3, params.mNumColumns);
@@ -804,6 +859,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [4] [5]
// |___ <1> [2] [3]
+ @Test
public void testLayout5KeyAuto3L1() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L1);
assertEquals("5 key auto 3 L1 columns", 3, params.mNumColumns);
@@ -821,6 +877,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [4] [5]
// |___ [3] <1> [2]
+ @Test
public void testLayout5KeyAuto3L2() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L2);
assertEquals("5 key auto 3 L2 columns", 3, params.mNumColumns);
@@ -838,6 +895,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [5] [4]|
// [3] [2] <1>|
+ @Test
public void testLayout5KeyAuto3R0() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R0);
assertEquals("5 key auto 3 R0 columns", 3, params.mNumColumns);
@@ -855,6 +913,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [5] [4] ___|
// [3] [2] <1> ___|
+ @Test
public void testLayout5KeyAuto3R1() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R1);
assertEquals("5 key auto 3 R1 columns", 3, params.mNumColumns);
@@ -872,6 +931,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [4] [5] ___|
// [3] <1> [2] ___|
+ @Test
public void testLayout5KeyAuto3R2() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R2);
assertEquals("5 key auto 3 R2 columns", 3, params.mNumColumns);
@@ -889,6 +949,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [5]
// [3] <1> [2] [4]
+ @Test
public void testLayout5KeyAuto4M0() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_M0);
assertEquals("5 key auto 4 M0 columns", 4, params.mNumColumns);
@@ -906,6 +967,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |[5]
// |<1> [2] [3] [4]
+ @Test
public void testLayout5KeyAuto4L0() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L0);
assertEquals("5 key auto 4 L0 columns", 4, params.mNumColumns);
@@ -923,6 +985,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [5]
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout5KeyAuto4L1() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L1);
assertEquals("5 key auto 4 L1 columns", 4, params.mNumColumns);
@@ -940,6 +1003,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [5]
// |___ [3] <1> [2] [4]
+ @Test
public void testLayout5KeyAuto4L2() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L2);
assertEquals("5 key auto 4 L2 columns", 4, params.mNumColumns);
@@ -957,6 +1021,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [5]|
// [4] [3] [2] <1>|
+ @Test
public void testLayout5KeyAuto4R0() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R0);
assertEquals("5 key auto 4 R0 columns", 4, params.mNumColumns);
@@ -974,6 +1039,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [5] ___|
// [4] [3] [2] <1> ___|
+ @Test
public void testLayout5KeyAuto4R1() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R1);
assertEquals("5 key auto 4 R1 columns", 4, params.mNumColumns);
@@ -991,6 +1057,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [5] ___|
// [4] [3] <1> [2] ___|
+ @Test
public void testLayout5KeyAuto4R2() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R2);
assertEquals("5 key auto 4 R2 columns", 4, params.mNumColumns);
@@ -1007,6 +1074,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout5KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_M0);
assertEquals("5 key auto 5 M0 columns", 5, params.mNumColumns);
@@ -1023,6 +1091,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout5KeyAuto5L0() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L0);
assertEquals("5 key auto 5 L0 columns", 5, params.mNumColumns);
@@ -1039,6 +1108,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout5KeyAuto5L1() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L1);
assertEquals("5 key auto 5 L1 columns", 5, params.mNumColumns);
@@ -1055,6 +1125,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ [3] <1> [2] [4] [5]
+ @Test
public void testLayout5KeyAuto5L2() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L2);
assertEquals("5 key auto 5 L2 columns", 5, params.mNumColumns);
@@ -1071,6 +1142,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [5] [4] [3] [2] <1>|
+ @Test
public void testLayout5KeyAuto5R0() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R0);
assertEquals("5 key auto 5 R0 columns", 5, params.mNumColumns);
@@ -1087,6 +1159,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [5] [4] [3] [2] <1> ___|
+ @Test
public void testLayout5KeyAuto5R1() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R1);
assertEquals("5 key auto 5 R1 columns", 5, params.mNumColumns);
@@ -1103,6 +1176,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// [5] [4] [3] <1> [2] ___|
+ @Test
public void testLayout5KeyAuto5R2() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R2);
assertEquals("5 key auto 5 R2 columns", 5, params.mNumColumns);
@@ -1120,6 +1194,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [5] [6]
// [3] <1> [2] [4]
+ @Test
public void testLayout6KeyAuto4M0() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_M0);
assertEquals("6 key auto 4 M0 columns", 4, params.mNumColumns);
@@ -1138,6 +1213,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |[5] [6]
// |<1> [2] [3] [4]
+ @Test
public void testLayout6KeyAuto4L0() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L0);
assertEquals("6 key auto 4 L0 columns", 4, params.mNumColumns);
@@ -1156,6 +1232,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [5] [6]
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout6KeyAuto4L1() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L1);
assertEquals("6 key auto 4 L1 columns", 4, params.mNumColumns);
@@ -1174,6 +1251,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [5] [6]
// |___ [3] <1> [2] [4]
+ @Test
public void testLayout6KeyAuto4L2() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L2);
assertEquals("6 key auto 4 L2 columns", 4, params.mNumColumns);
@@ -1192,6 +1270,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [6] [5]|
// [4] [3] [2] <1>|
+ @Test
public void testLayout6KeyAuto4R0() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R0);
assertEquals("6 key auto 4 R0 columns", 4, params.mNumColumns);
@@ -1210,6 +1289,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [6] [5] ___|
// [4] [3] [2] <1> ___|
+ @Test
public void testLayout6KeyAuto4R1() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R1);
assertEquals("6 key auto 4 R1 columns", 4, params.mNumColumns);
@@ -1228,6 +1308,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [5] [6] ___|
// [4] [3] <1> [2] ___|
+ @Test
public void testLayout6KeyAuto4R2() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R2);
assertEquals("6 key auto 4 R2 columns", 4, params.mNumColumns);
@@ -1246,6 +1327,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [6]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout6KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_M0);
assertEquals("6 key auto 5 M0 columns", 5, params.mNumColumns);
@@ -1264,6 +1346,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |[6]
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout6KeyAuto5L0() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L0);
assertEquals("6 key auto 5 L0 columns", 5, params.mNumColumns);
@@ -1282,6 +1365,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [6]
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout6KeyAuto5L1() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L1);
assertEquals("6 key auto 5 L1 columns", 5, params.mNumColumns);
@@ -1300,6 +1384,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [6]
// |___ [3] <1> [2] [4] [5]
+ @Test
public void testLayout6KeyAuto5L2() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L2);
assertEquals("6 key auto 5 L2 columns", 5, params.mNumColumns);
@@ -1318,6 +1403,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [6]|
// [5] [4] [3] [2] <1>|
+ @Test
public void testLayout6KeyAuto5R0() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R0);
assertEquals("6 key auto 5 R0 columns", 5, params.mNumColumns);
@@ -1336,6 +1422,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [6] ___|
// [5] [4] [3] [2] <1> ___|
+ @Test
public void testLayout6KeyAuto5R1() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R1);
assertEquals("6 key auto 5 R1 columns", 5, params.mNumColumns);
@@ -1354,6 +1441,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [6] ___|
// [5] [4] [3] <1> [2] ___|
+ @Test
public void testLayout6KeyAuto5R2() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R2);
assertEquals("6 key auto 5 R2 columns", 5, params.mNumColumns);
@@ -1371,6 +1459,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |<1> [2] [3] [4] [5] [6] [7] ___ ___ ___|
+ @Test
public void testLayout7KeyAuto7L0() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L0);
assertEquals("7 key auto 7 L0 columns", 7, params.mNumColumns);
@@ -1389,6 +1478,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3] [4] [5] [6] [7] ___ ___|
+ @Test
public void testLayout7KeyAuto7L1() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L1);
assertEquals("7 key auto 7 L1 columns", 7, params.mNumColumns);
@@ -1407,6 +1497,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ [3] <1> [2] [4] [5] [6] [7] ___ ___|
+ @Test
public void testLayout7KeyAuto7L2() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L2);
assertEquals("7 key auto 7 L2 columns", 7, params.mNumColumns);
@@ -1425,6 +1516,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ [5] [3] <1> [2] [4] [6] [7] ___ ___|
+ @Test
public void testLayout7KeyAuto7L3() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L3);
assertEquals("7 key auto 7 L3 columns", 7, params.mNumColumns);
@@ -1443,6 +1535,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ [7] [5] [3] <1> [2] [4] [6] ___ ___|
+ @Test
public void testLayout7KeyAuto7M0() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_M0);
assertEquals("7 key auto 7 M0 columns", 7, params.mNumColumns);
@@ -1461,6 +1554,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ ___ [7] [5] [3] <1> [2] [4] [6] ___|
+ @Test
public void testLayout7KeyAuto7M1() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_M1);
assertEquals("7 key auto 7 M1 columns", 7, params.mNumColumns);
@@ -1479,6 +1573,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ ___ [7] [6] [5] [3] <1> [2] [4] ___|
+ @Test
public void testLayout7KeyAuto7R3() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R3);
assertEquals("7 key auto 7 R3 columns", 7, params.mNumColumns);
@@ -1497,6 +1592,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ ___ [7] [6] [5] [4] [3] <1> [2] ___|
+ @Test
public void testLayout7KeyAuto7R2() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R2);
assertEquals("7 key auto 7 R2 columns", 7, params.mNumColumns);
@@ -1515,6 +1611,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ ___ [7] [6] [5] [4] [3] [2] <1> ___|
+ @Test
public void testLayout7KeyAuto7R1() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R1);
assertEquals("7 key auto 7 R1 columns", 7, params.mNumColumns);
@@ -1533,6 +1630,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
}
// |___ ___ [7] [6] [5] [4] [3] [2] <1>|
+ @Test
public void testLayout7KeyAuto7R0() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R0);
assertEquals("7 key auto 7 R0 columns", 7, params.mNumColumns);
@@ -1552,6 +1650,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [6] [7]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout7KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_M0);
assertEquals("7 key auto 5 M0 columns", 5, params.mNumColumns);
@@ -1571,6 +1670,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |[6] [7]
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout7KeyAuto5L0() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L0);
assertEquals("7 key auto 5 L0 columns", 5, params.mNumColumns);
@@ -1590,6 +1690,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [6] [7]
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout7KeyAuto5L1() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L1);
assertEquals("7 key auto 5 L1 columns", 5, params.mNumColumns);
@@ -1609,6 +1710,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [6] [7]
// |___ [3] <1> [2] [4] [5]
+ @Test
public void testLayout7KeyAuto5L2() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L2);
assertEquals("7 key auto 5 L2 columns", 5, params.mNumColumns);
@@ -1628,6 +1730,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [7] [6]|
// [5] [4] [3] [2] <1>|
+ @Test
public void testLayout7KeyAuto5R0() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R0);
assertEquals("7 key auto 5 R0 columns", 5, params.mNumColumns);
@@ -1647,6 +1750,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [7] [6] ___|
// [5] [4] [3] [2] <1> ___|
+ @Test
public void testLayout7KeyAuto5R1() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R1);
assertEquals("7 key auto 5 R1 columns", 5, params.mNumColumns);
@@ -1666,6 +1770,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [6] [7] ___|
// [5] [4] [3] <1> [2] ___|
+ @Test
public void testLayout7KeyAuto5R2() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R2);
assertEquals("7 key auto 5 R2 columns", 5, params.mNumColumns);
@@ -1686,6 +1791,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [7]
// [6] [4] [5]
// [3] <1> [2]
+ @Test
public void testLayout7KeyAuto3M0() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_M0);
assertEquals("7 key auto 3 M0 columns", 3, params.mNumColumns);
@@ -1706,6 +1812,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |[7]
// |[4] [5] [6]
// |<1> [2] [3]
+ @Test
public void testLayout7KeyAuto3L0() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_L0);
assertEquals("7 key auto 3 L0 columns", 3, params.mNumColumns);
@@ -1726,6 +1833,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [7]
// |___ [4] [5] [6]
// |___ <1> [2] [3]
+ @Test
public void testLayout7KeyAuto3L1() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_L1);
assertEquals("7 key auto 3 L1 columns", 3, params.mNumColumns);
@@ -1746,6 +1854,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [7]
// |___ [6] [4] [5]
// |___ [3] <1> [2]
+ @Test
public void testLayout7KeyAuto3L2() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_L2);
assertEquals("7 key auto 3 L2 columns", 3, params.mNumColumns);
@@ -1766,6 +1875,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [7]|
// [6] [5] [4]|
// [3] [2] <1>|
+ @Test
public void testLayout7KeyAuto3R0() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_R0);
assertEquals("7 key auto 3 R0 columns", 3, params.mNumColumns);
@@ -1786,6 +1896,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [7] ___|
// [6] [5] [4] ___|
// [3] [2] <1> ___|
+ @Test
public void testLayout7KeyAuto3R1() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_R1);
assertEquals("7 key auto 3 R1 columns", 3, params.mNumColumns);
@@ -1806,6 +1917,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [7] ___|
// [6] [4] [5] ___|
// [3] <1> [2] ___|
+ @Test
public void testLayout7KeyAuto3R2() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_R2);
assertEquals("7 key auto 3 R2 columns", 3, params.mNumColumns);
@@ -1825,6 +1937,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [8] [6] [7]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout8KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_M0);
assertEquals("8 key auto 5 M0 columns", 5, params.mNumColumns);
@@ -1845,6 +1958,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |[6] [7] [8]
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout8KeyAuto5L0() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L0);
assertEquals("8 key auto 5 L0 columns", 5, params.mNumColumns);
@@ -1865,6 +1979,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [6] [7] [8]
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout8KeyAuto5L1() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L1);
assertEquals("8 key auto 5 L1 columns", 5, params.mNumColumns);
@@ -1885,6 +2000,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [8] [6] [7]
// |___ [3] <1> [2] [4] [5]
+ @Test
public void testLayout8KeyAuto5L2() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L2);
assertEquals("8 key auto 5 L2 columns", 5, params.mNumColumns);
@@ -1905,6 +2021,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [8] [7] [6]|
// [5] [4] [3] [2] <1>|
+ @Test
public void testLayout8KeyAuto5R0() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R0);
assertEquals("8 key auto 5 R0 columns", 5, params.mNumColumns);
@@ -1925,6 +2042,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [8] [7] [6] ___|
// [5] [4] [3] [2] <1> ___|
+ @Test
public void testLayout8KeyAuto5R1() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R1);
assertEquals("8 key auto 5 R1 columns", 5, params.mNumColumns);
@@ -1945,6 +2063,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [8] [6] [7] ___|
// [5] [4] [3] <1> [2] ___|
+ @Test
public void testLayout8KeyAuto5R2() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R2);
assertEquals("8 key auto 5 R2 columns", 5, params.mNumColumns);
@@ -1965,6 +2084,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [8] [6] [7] [9]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout9KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_M0);
assertEquals("9 key auto 5 M0 columns", 5, params.mNumColumns);
@@ -1986,6 +2106,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |[6] [7] [8] [9]
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout9KeyAuto5L0() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L0);
assertEquals("9 key auto 5 L0 columns", 5, params.mNumColumns);
@@ -2007,6 +2128,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [6] [7] [8] [9]
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout9KeyAuto5L1() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L1);
assertEquals("9 key auto 5 L1 columns", 5, params.mNumColumns);
@@ -2028,6 +2150,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [6] [7] [8] [9]
// |___ [3] <1> [2] [4] [5]
+ @Test
public void testLayout9KeyAuto5L2() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L2);
assertEquals("9 key auto 5 L2 columns", 5, params.mNumColumns);
@@ -2049,6 +2172,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [9] [8] [7] [6]|
// [5] [4] [3] [2] <1>|
+ @Test
public void testLayout9KeyAuto5R0() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R0);
assertEquals("9 key auto 5 R0 columns", 5, params.mNumColumns);
@@ -2070,6 +2194,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [9] [8] [7] [6] ___|
// [5] [4] [3] [2] <1> ___|
+ @Test
public void testLayout9KeyAuto5R1() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R1);
assertEquals("9 key auto 5 R1 columns", 5, params.mNumColumns);
@@ -2091,6 +2216,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [9] [8] [6] [7] ___|
// [5] [4] [3] <1> [2] ___|
+ @Test
public void testLayout9KeyAuto5R2() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R2);
assertEquals("9 key auto 5 R2 columns", 5, params.mNumColumns);
@@ -2112,6 +2238,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [A] [8] [6] [7] [9]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout10KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_M0);
assertEquals("10 key auto 5 M0 columns", 5, params.mNumColumns);
@@ -2134,6 +2261,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |[6] [7] [8] [9] [A]
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout10KeyAuto5L0() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L0);
assertEquals("10 key auto 5 L0 columns", 5, params.mNumColumns);
@@ -2156,6 +2284,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [6] [7] [8] [9] [A]
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout10KeyAuto5L1() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L1);
assertEquals("10 key auto 5 L1 columns", 5, params.mNumColumns);
@@ -2178,6 +2307,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// |___ [8] [6] [7] [9] [A]
// |___ [3] <1> [2] [4] [5]
+ @Test
public void testLayout10KeyAuto5L2() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L2);
assertEquals("10 key auto 5 L2 columns", 5, params.mNumColumns);
@@ -2200,6 +2330,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [A] [9] [8] [7] [6]|
// [5] [4] [3] [2] <1>|
+ @Test
public void testLayout10KeyAuto5R0() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R0);
assertEquals("10 key auto 5 R0 columns", 5, params.mNumColumns);
@@ -2222,6 +2353,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [A] [9] [8] [7] [6] ___|
// [5] [4] [3] [2] <1> ___|
+ @Test
public void testLayout10KeyAuto5R1() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R1);
assertEquals("10 key auto 5 R1 columns", 5, params.mNumColumns);
@@ -2244,6 +2376,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [A] [9] [8] [6] [7] ___|
// [5] [4] [3] <1> [2] ___|
+ @Test
public void testLayout10KeyAuto5R2() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R2);
assertEquals("10 key auto 5 R2 columns", 5, params.mNumColumns);
@@ -2267,6 +2400,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [B]
// [A] [8] [6] [7] [9]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout11KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(11, 5, XPOS_M0);
assertEquals("11 key auto 5 M0 columns", 5, params.mNumColumns);
@@ -2291,6 +2425,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [B] [C]
// [A] [8] [6] [7] [9]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout12KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(12, 5, XPOS_M0);
assertEquals("12 key auto 5 M0 columns", 5, params.mNumColumns);
@@ -2316,6 +2451,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [D] [B] [C]
// [A] [8] [6] [7] [9]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout13KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(13, 5, XPOS_M0);
assertEquals("13 key auto 5 M0 columns", 5, params.mNumColumns);
@@ -2342,6 +2478,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [D] [B] [C] [E]
// [A] [8] [6] [7] [9]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout14KeyAuto5M0() {
MoreKeysKeyboardParams params = createParams(14, 5, XPOS_M0);
assertEquals("13 key auto 5 M0 columns", 5, params.mNumColumns);
@@ -2369,6 +2506,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [J] [I] [H] ___|
// [G] [F] [E] [D] [C] [B] [A] [9] ___|
// [8] [7] [6] [5] [4] [3] [2] <1> ___|
+ @Test
public void testLayout19KeyAuto8R1() {
MoreKeysKeyboardParams params = createParams(19, 8, XPOS_R1);
assertEquals("19 key auto 8 R1 columns", 8, params.mNumColumns);
@@ -2401,6 +2539,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [J] [H] [I] ___|
// [G] [F] [E] [D] [C] [B] [9] [A] ___|
// [8] [7] [6] [5] [4] [3] <1> [2] ___|
+ @Test
public void testLayout19KeyAuto8R2() {
MoreKeysKeyboardParams params = createParams(19, 8, XPOS_R2);
assertEquals("19 key auto 8 R2 columns", 8, params.mNumColumns);
@@ -2433,6 +2572,7 @@ public class MoreKeysKeyboardBuilderAutoOrderTests extends AndroidTestCase {
// [J] [H] [I] ___|
// [G] [F] [E] [D] [B] [9] [A] [C] ___|
// [8] [7] [6] [5] [3] <1> [2] [4] ___|
+ @Test
public void testLayout19KeyAuto8R3() {
MoreKeysKeyboardParams params = createParams(19, 8, XPOS_R3);
assertEquals("19 key auto 8 R3 columns", 8, params.mNumColumns);
diff --git a/tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderFixedOrderTests.java b/tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderFixedOrderTests.java
index 7e51d955d..3c5c298f6 100644
--- a/tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderFixedOrderTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderFixedOrderTests.java
@@ -16,13 +16,21 @@
package com.android.inputmethod.keyboard;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import androidx.test.filters.MediumTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.keyboard.MoreKeysKeyboard.MoreKeysKeyboardParams;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
@MediumTest
-public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class MoreKeysKeyboardBuilderFixedOrderTests {
private static final int WIDTH = 10;
private static final int HEIGHT = 10;
@@ -38,11 +46,6 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
private static final int XPOS_R1 = WIDTH * 8 + WIDTH / 2;
private static final int XPOS_R0 = WIDTH * 9 + WIDTH / 2;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
private static MoreKeysKeyboardParams createParams(final int numKeys, final int columnNum,
final int coordXInParent) {
final MoreKeysKeyboardParams params = new MoreKeysKeyboardParams();
@@ -52,6 +55,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
return params;
}
+ @Test
public void testLayoutError() {
MoreKeysKeyboardParams params = null;
try {
@@ -69,6 +73,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// "<m>" is the default key.
// <1>
+ @Test
public void testLayout1KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_M0);
assertEquals("1 key fix 5 M0 columns", 1, params.mNumColumns);
@@ -81,6 +86,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |<1>
+ @Test
public void testLayout1KeyFix5L0() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L0);
assertEquals("1 key fix 5 L0 columns", 1, params.mNumColumns);
@@ -93,6 +99,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ <1>
+ @Test
public void testLayout1KeyFix5L1() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L1);
assertEquals("1 key fix 5 L1 columns", 1, params.mNumColumns);
@@ -105,6 +112,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ ___ <1>
+ @Test
public void testLayout1KeyFix5L2() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L2);
assertEquals("1 key fix 5 L2 columns", 1, params.mNumColumns);
@@ -117,6 +125,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// <1>|
+ @Test
public void testLayout1KeyFix5R0() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R0);
assertEquals("1 key fix 5 R0 columns", 1, params.mNumColumns);
@@ -129,6 +138,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// <1> ___|
+ @Test
public void testLayout1KeyFix5R1() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R1);
assertEquals("1 key fix 5 R1 columns", 1, params.mNumColumns);
@@ -141,6 +151,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// <1> ___ ___|
+ @Test
public void testLayout1KeyFix5R2() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R2);
assertEquals("1 key fix 5 R2 columns", 1, params.mNumColumns);
@@ -153,6 +164,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// <1> [2]
+ @Test
public void testLayout2KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_M0);
assertEquals("2 key fix 5 M0 columns", 2, params.mNumColumns);
@@ -166,6 +178,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |<1> [2]
+ @Test
public void testLayout2KeyFix5L0() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L0);
assertEquals("2 key fix 5 L0 columns", 2, params.mNumColumns);
@@ -179,6 +192,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ <1> [2]
+ @Test
public void testLayout2KeyFix5L1() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L1);
assertEquals("2 key fix 5 L1 columns", 2, params.mNumColumns);
@@ -192,6 +206,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ ___ <1> [2]
+ @Test
public void testLayout2KeyFix5L2() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L2);
assertEquals("2 key fix 5 L2 columns", 2, params.mNumColumns);
@@ -205,6 +220,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] <2>|
+ @Test
public void testLayout2KeyFix5R0() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R0);
assertEquals("2 key fix 5 R0 columns", 2, params.mNumColumns);
@@ -218,6 +234,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] <2> ___|
+ @Test
public void testLayout2KeyFix5R1() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R1);
assertEquals("2 key fix 5 R1 columns", 2, params.mNumColumns);
@@ -231,6 +248,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// <1> [2] ___|
+ @Test
public void testLayout2KeyFix5R2() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R2);
assertEquals("2 key fix 5 R2 columns", 2, params.mNumColumns);
@@ -245,6 +263,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [3]
// <1> [2]
+ @Test
public void testLayout3KeyFix2M0() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_M0);
assertEquals("3 key fix 2 M0 columns", 2, params.mNumColumns);
@@ -260,6 +279,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[3]
// |<1> [2]
+ @Test
public void testLayout3KeyFix2L0() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L0);
assertEquals("3 key fix 2 L0 columns", 2, params.mNumColumns);
@@ -275,6 +295,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [3]
// |___ <1> [2]
+ @Test
public void testLayout3KeyFix2L1() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L1);
assertEquals("3 key fix 2 L1 columns", 2, params.mNumColumns);
@@ -290,6 +311,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// | [3]
// |___ ___ <1> [2]
+ @Test
public void testLayout3KeyFix2L2() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L2);
assertEquals("3 key fix 2 L2 columns", 2, params.mNumColumns);
@@ -305,6 +327,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [3]|
// [1] <2>|
+ @Test
public void testLayout3KeyFix2R0() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R0);
assertEquals("3 key fix 2 R0 columns", 2, params.mNumColumns);
@@ -320,6 +343,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [3] ___|
// [1] <2> ___|
+ @Test
public void testLayout3KeyFix2R1() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R1);
assertEquals("3 key fix 2 R1 columns", 2, params.mNumColumns);
@@ -335,6 +359,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [3] ___|
// <1> [2] ___|
+ @Test
public void testLayout3KeyFix2R2() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R2);
assertEquals("3 key fix 2 R2 columns", 2, params.mNumColumns);
@@ -350,6 +375,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [3] [4]
// <1> [2]
+ @Test
public void testLayout4KeyFix2M0() {
MoreKeysKeyboardParams params = createParams(4, 2, XPOS_M0);
assertEquals("3 key fix 2 M0 columns", 2, params.mNumColumns);
@@ -366,6 +392,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[3] [4]
// |<1> [2]
+ @Test
public void testLayout4KeyFix2L0() {
MoreKeysKeyboardParams params = createParams(4, 2, XPOS_L0);
assertEquals("3 key fix 2 L0 columns", 2, params.mNumColumns);
@@ -382,6 +409,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [3] [4]
// |___ <1> [2]
+ @Test
public void testLayout4KeyFix2L1() {
MoreKeysKeyboardParams params = createParams(4, 2, XPOS_L1);
assertEquals("3 key fix 2 L1 columns", 2, params.mNumColumns);
@@ -398,6 +426,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// | [3] [4]
// |___ ___ <1> [2]
+ @Test
public void testLayout4KeyFix2L2() {
MoreKeysKeyboardParams params = createParams(4, 2, XPOS_L2);
assertEquals("3 key fix 2 L2 columns", 2, params.mNumColumns);
@@ -414,6 +443,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [3] [4]|
// [1] <2>|
+ @Test
public void testLayout4KeyFix2R0() {
MoreKeysKeyboardParams params = createParams(4, 2, XPOS_R0);
assertEquals("3 key fix 2 R0 columns", 2, params.mNumColumns);
@@ -430,6 +460,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [3] [4] ___|
// [1] <2> ___|
+ @Test
public void testLayout4KeyFix2R1() {
MoreKeysKeyboardParams params = createParams(4, 2, XPOS_R1);
assertEquals("3 key fix 2 R1 columns", 2, params.mNumColumns);
@@ -446,6 +477,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [3] [4] ___|
// <1> [2] ___|
+ @Test
public void testLayout4KeyFix2R2() {
MoreKeysKeyboardParams params = createParams(4, 2, XPOS_R2);
assertEquals("3 key fix 2 R2 columns", 2, params.mNumColumns);
@@ -461,6 +493,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] <2> [3]
+ @Test
public void testLayout3KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_M0);
assertEquals("3 key fix 5 columns", 3, params.mNumColumns);
@@ -475,6 +508,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |<1> [2] [3]
+ @Test
public void testLayout3KeyFix5L0() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L0);
assertEquals("3 key fix 5 L0 columns", 3, params.mNumColumns);
@@ -489,6 +523,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3]
+ @Test
public void testLayout3KeyFix5L1() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L1);
assertEquals("3 key fix 5 L1 columns", 3, params.mNumColumns);
@@ -503,6 +538,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ [1] <2> [3]
+ @Test
public void testLayout3KeyFix5L2() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L2);
assertEquals("3 key fix 5 L2 columns", 3, params.mNumColumns);
@@ -517,6 +553,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] <3>|
+ @Test
public void testLayout3KeyFix5R0() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R0);
assertEquals("3 key fix 5 R0 columns", 3, params.mNumColumns);
@@ -531,6 +568,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] <3> ___|
+ @Test
public void testLayout3KeyFix5R1() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R1);
assertEquals("3 key fix 5 R1 columns", 3, params.mNumColumns);
@@ -545,6 +583,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] <2> [3] ___|
+ @Test
public void testLayout3KeyFix5R2() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R2);
assertEquals("3 key fix 5 R2 columns", 3, params.mNumColumns);
@@ -560,6 +599,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [4]
// [1] <2> [3]
+ @Test
public void testLayout4KeyFix3M0() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_M0);
assertEquals("4 key fix 3 M0 columns", 3, params.mNumColumns);
@@ -576,6 +616,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[4]
// |<1> [2] [3]
+ @Test
public void testLayout4KeyFix3L0() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L0);
assertEquals("4 key fix 3 L0 columns", 3, params.mNumColumns);
@@ -592,6 +633,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [4]
// |___ <1> [2] [3]
+ @Test
public void testLayout4KeyFix3L1() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L1);
assertEquals("4 key fix 3 L1 columns", 3, params.mNumColumns);
@@ -608,6 +650,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ ___ [4]
// |___ ___ [1] <2> [3]
+ @Test
public void testLayout4KeyFix3L2() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L2);
assertEquals("4 key fix 3 L2 columns", 3, params.mNumColumns);
@@ -624,6 +667,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [4]|
// [1] [2] <3>|
+ @Test
public void testLayout4KeyFix3R0() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R0);
assertEquals("4 key fix 3 R0 columns", 3, params.mNumColumns);
@@ -640,6 +684,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [4] ___|
// [1] [2] <3> ___|
+ @Test
public void testLayout4KeyFix3R1() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R1);
assertEquals("4 key fix 3 R1 columns", 3, params.mNumColumns);
@@ -656,6 +701,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [4] ___|
// [1] <2> [3] ___|
+ @Test
public void testLayout4KeyFix3R2() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R2);
assertEquals("4 key fix 3 R2 columns", 3, params.mNumColumns);
@@ -672,6 +718,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [4] [5]
// [1] <2> [3]
+ @Test
public void testLayout5KeyFix3M0() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_M0);
assertEquals("5 key fix 3 M0 columns", 3, params.mNumColumns);
@@ -689,6 +736,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[4] [5]
// |<1> [2] [3]
+ @Test
public void testLayout5KeyFix3L0() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L0);
assertEquals("5 key fix 3 L0 columns", 3, params.mNumColumns);
@@ -706,6 +754,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [4] [5]
// |___ <1> [2] [3]
+ @Test
public void testLayout5KeyFix3L1() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L1);
assertEquals("5 key fix 3 L1 columns", 3, params.mNumColumns);
@@ -723,6 +772,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [4] [5]
// |___ [1] <2> [3]
+ @Test
public void testLayout5KeyFix3L2() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L2);
assertEquals("5 key fix 3 L2 columns", 3, params.mNumColumns);
@@ -740,6 +790,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [4] [5]|
// [1] [2] <3>|
+ @Test
public void testLayout5KeyFix3R0() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R0);
assertEquals("5 key fix 3 R0 columns", 3, params.mNumColumns);
@@ -757,6 +808,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [4] [5] ___|
// [1] [2] <3> ___|
+ @Test
public void testLayout5KeyFix3R1() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R1);
assertEquals("5 key fix 3 R1 columns", 3, params.mNumColumns);
@@ -774,6 +826,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [4] [5] ___|
// [1] <2> [3] ___|
+ @Test
public void testLayout5KeyFix3R2() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R2);
assertEquals("5 key fix 3 R2 columns", 3, params.mNumColumns);
@@ -791,6 +844,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [4] [5] [6]
// [1] <2> [3]
+ @Test
public void testLayout6KeyFix3M0() {
MoreKeysKeyboardParams params = createParams(6, 3, XPOS_M0);
assertEquals("6 key fix 3 M0 columns", 3, params.mNumColumns);
@@ -809,6 +863,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[4] [5] [6]
// |<1> [2] [3]
+ @Test
public void testLayout6KeyFix3L0() {
MoreKeysKeyboardParams params = createParams(6, 3, XPOS_L0);
assertEquals("6 key fix 3 L0 columns", 3, params.mNumColumns);
@@ -827,6 +882,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [4] [5] [6]
// |___ <1> [2] [3]
+ @Test
public void testLayout6KeyFix3L1() {
MoreKeysKeyboardParams params = createParams(6, 3, XPOS_L1);
assertEquals("6 key fix 3 L1 columns", 3, params.mNumColumns);
@@ -845,6 +901,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [4] [5] [6]
// |___ [1] <2> [3]
+ @Test
public void testLayout6KeyFix3L2() {
MoreKeysKeyboardParams params = createParams(6, 3, XPOS_L2);
assertEquals("6 key fix 3 L2 columns", 3, params.mNumColumns);
@@ -863,6 +920,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [4] [5] [6]|
// [1] [2] <3>|
+ @Test
public void testLayout6KeyFix3R0() {
MoreKeysKeyboardParams params = createParams(6, 3, XPOS_R0);
assertEquals("6 key fix 3 R0 columns", 3, params.mNumColumns);
@@ -881,6 +939,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [4] [5] [6] ___|
// [1] [2] <3> ___|
+ @Test
public void testLayout6KeyFix3R1() {
MoreKeysKeyboardParams params = createParams(6, 3, XPOS_R1);
assertEquals("6 key fix 3 R1 columns", 3, params.mNumColumns);
@@ -899,6 +958,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [4] [5] [6] ___|
// [1] <2> [3] ___|
+ @Test
public void testLayout6KeyFix3R2() {
MoreKeysKeyboardParams params = createParams(6, 3, XPOS_R2);
assertEquals("6 key fix 3 R2 columns", 3, params.mNumColumns);
@@ -916,6 +976,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// <1> [2] [3] [4]
+ @Test
public void testLayout4KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_M0);
assertEquals("4 key fix 5 columns", 4, params.mNumColumns);
@@ -931,6 +992,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |<1> [2] [3] [4]
+ @Test
public void testLayout4KeyFix5L0() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L0);
assertEquals("4 key fix 5 L0 columns", 4, params.mNumColumns);
@@ -946,6 +1008,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout4KeyFix5L1() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L1);
assertEquals("4 key fix 5 L1 columns", 4, params.mNumColumns);
@@ -961,6 +1024,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ [1] <2> [3] [4]
+ @Test
public void testLayout4KeyFix5L2() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L2);
assertEquals("4 key fix 5 L2 columns", 4, params.mNumColumns);
@@ -976,6 +1040,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] [3] <4>|
+ @Test
public void testLayout4KeyFix5R0() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R0);
assertEquals("4 key fix 5 R0 columns", 4, params.mNumColumns);
@@ -991,6 +1056,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] [3] <4> ___|
+ @Test
public void testLayout4KeyFix5R1() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R1);
assertEquals("4 key fix 5 R1 columns", 4, params.mNumColumns);
@@ -1006,6 +1072,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] <3> [4] ___|
+ @Test
public void testLayout4KeyFix5R2() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R2);
assertEquals("4 key fix 5 R2 columns", 4, params.mNumColumns);
@@ -1022,6 +1089,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5]
// [1] <2> [3] [4]
+ @Test
public void testLayout5KeyFix4M0() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_M0);
assertEquals("5 key fix 4 M0 columns", 4, params.mNumColumns);
@@ -1039,6 +1107,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[5]
// |<1> [2] [3] [4]
+ @Test
public void testLayout5KeyFix4L0() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L0);
assertEquals("5 key fix 4 L0 columns", 4, params.mNumColumns);
@@ -1056,6 +1125,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [5]
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout5KeyFix4L1() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L1);
assertEquals("5 key fix 4 L1 columns", 4, params.mNumColumns);
@@ -1073,6 +1143,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [5]
// |___ [1] <2> [3] [4]
+ @Test
public void testLayout5KeyFix4L2() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L2);
assertEquals("5 key fix 4 L2 columns", 4, params.mNumColumns);
@@ -1090,6 +1161,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5]|
// [1] [2] [3] <4>|
+ @Test
public void testLayout5KeyFix4R0() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R0);
assertEquals("5 key fix 4 R0 columns", 4, params.mNumColumns);
@@ -1107,6 +1179,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] ___|
// [1] [2] [3] <4> ___|
+ @Test
public void testLayout5KeyFix4R1() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R1);
assertEquals("5 key fix 4 R1 columns", 4, params.mNumColumns);
@@ -1124,6 +1197,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] ___|
// [1] [2] <3> [4] ___|
+ @Test
public void testLayout5KeyFix4R2() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R2);
assertEquals("5 key fix 4 R2 columns", 4, params.mNumColumns);
@@ -1141,6 +1215,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] [6]
// [1] <2> [3] [4]
+ @Test
public void testLayout6KeyFix4M0() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_M0);
assertEquals("6 key fix 4 M0 columns", 4, params.mNumColumns);
@@ -1159,6 +1234,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[5] [6]
// |<1> [2] [3] [4]
+ @Test
public void testLayout6KeyFix4L0() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L0);
assertEquals("6 key fix 4 L0 columns", 4, params.mNumColumns);
@@ -1177,6 +1253,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [5] [6]
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout6KeyFix4L1() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L1);
assertEquals("6 key fix 4 L1 columns", 4, params.mNumColumns);
@@ -1195,6 +1272,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [5] [6]
// |___ [1] <2> [3] [4]
+ @Test
public void testLayout6KeyFix4L2() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L2);
assertEquals("6 key fix 4 L2 columns", 4, params.mNumColumns);
@@ -1213,6 +1291,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] [6]|
// [1] [2] [3] <4>|
+ @Test
public void testLayout6KeyFix4R0() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R0);
assertEquals("6 key fix 4 R0 columns", 4, params.mNumColumns);
@@ -1231,6 +1310,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] [6] ___|
// [1] [2] [3] <4> ___|
+ @Test
public void testLayout6KeyFix4R1() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R1);
assertEquals("6 key fix 4 R1 columns", 4, params.mNumColumns);
@@ -1249,6 +1329,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] [6] ___|
// [1] [2] <3> [4] ___|
+ @Test
public void testLayout6KeyFix4R2() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R2);
assertEquals("6 key fix 4 R2 columns", 4, params.mNumColumns);
@@ -1267,6 +1348,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] [6] [7]
// [1] <2> [3] [4]
+ @Test
public void testLayout7KeyFix4M0() {
MoreKeysKeyboardParams params = createParams(7, 4, XPOS_M0);
assertEquals("7 key fix 4 M0 columns", 4, params.mNumColumns);
@@ -1286,6 +1368,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[5] [6] [7]
// |<1> [2] [3] [4]
+ @Test
public void testLayout7KeyFix4L0() {
MoreKeysKeyboardParams params = createParams(7, 4, XPOS_L0);
assertEquals("7 key fix 4 L0 columns", 4, params.mNumColumns);
@@ -1305,6 +1388,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [5] [6] [7]
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout7KeyFix4L1() {
MoreKeysKeyboardParams params = createParams(7, 4, XPOS_L1);
assertEquals("7 key fix 4 L1 columns", 4, params.mNumColumns);
@@ -1324,6 +1408,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [5] [6] [7]
// |___ [1] <2> [3] [4]
+ @Test
public void testLayout7KeyFix4L2() {
MoreKeysKeyboardParams params = createParams(7, 4, XPOS_L2);
assertEquals("7 key fix 4 L2 columns", 4, params.mNumColumns);
@@ -1343,6 +1428,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] [6] [7]|
// [1] [2] [3] <4>|
+ @Test
public void testLayout7KeyFix4R0() {
MoreKeysKeyboardParams params = createParams(7, 4, XPOS_R0);
assertEquals("7 key fix 4 R0 columns", 4, params.mNumColumns);
@@ -1362,6 +1448,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] [6] [7] ___|
// [1] [2] [3] <4> ___|
+ @Test
public void testLayout7KeyFix4R1() {
MoreKeysKeyboardParams params = createParams(7, 4, XPOS_R1);
assertEquals("7 key fix 4 R1 columns", 4, params.mNumColumns);
@@ -1381,6 +1468,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] [6] [7] ___|
// [1] [2] <3> [4] ___|
+ @Test
public void testLayout7KeyFix4R2() {
MoreKeysKeyboardParams params = createParams(7, 4, XPOS_R2);
assertEquals("7 key fix 4 R2 columns", 4, params.mNumColumns);
@@ -1400,6 +1488,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] [6] [7] [8]
// [1] <2> [3] [4]
+ @Test
public void testLayout8KeyFix4M0() {
MoreKeysKeyboardParams params = createParams(8, 4, XPOS_M0);
assertEquals("8 key fix 4 M0 columns", 4, params.mNumColumns);
@@ -1420,6 +1509,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[5] [6] [7] [8]
// |<1> [2] [3] [4]
+ @Test
public void testLayout8KeyFix4L0() {
MoreKeysKeyboardParams params = createParams(8, 4, XPOS_L0);
assertEquals("8 key fix 4 L0 columns", 4, params.mNumColumns);
@@ -1440,6 +1530,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [5] [6] [7] [8]
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout8KeyFix4L1() {
MoreKeysKeyboardParams params = createParams(8, 4, XPOS_L1);
assertEquals("8 key fix 4 L1 columns", 4, params.mNumColumns);
@@ -1460,6 +1551,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [5] [6] [7] [8]
// |___ [1] <2> [3] [4]
+ @Test
public void testLayout8KeyFix4L2() {
MoreKeysKeyboardParams params = createParams(8, 4, XPOS_L2);
assertEquals("8 key fix 4 L2 columns", 4, params.mNumColumns);
@@ -1480,6 +1572,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] [6] [7] [8]|
// [1] [2] [3] <4>|
+ @Test
public void testLayout8KeyFix4R0() {
MoreKeysKeyboardParams params = createParams(8, 4, XPOS_R0);
assertEquals("8 key fix 4 R0 columns", 4, params.mNumColumns);
@@ -1500,6 +1593,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] [6] [7] [8] ___|
// [1] [2] [3] <4> ___|
+ @Test
public void testLayout8KeyFix4R1() {
MoreKeysKeyboardParams params = createParams(8, 4, XPOS_R1);
assertEquals("8 key fix 4 R1 columns", 4, params.mNumColumns);
@@ -1520,6 +1614,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [5] [6] [7] [8] ___|
// [1] [2] <3> [4] ___|
+ @Test
public void testLayout8KeyFix4R2() {
MoreKeysKeyboardParams params = createParams(8, 4, XPOS_R2);
assertEquals("8 key fix 4 R2 columns", 4, params.mNumColumns);
@@ -1539,6 +1634,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] <3> [4] [5]
+ @Test
public void testLayout5KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_M0);
assertEquals("5 key fix 5 columns", 5, params.mNumColumns);
@@ -1555,6 +1651,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout5KeyFix5L0() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L0);
assertEquals("5 key fix 5 L0 columns", 5, params.mNumColumns);
@@ -1571,6 +1668,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout5KeyFix5L1() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L1);
assertEquals("5 key fix 5 L1 columns", 5, params.mNumColumns);
@@ -1587,6 +1685,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ [1] <2> [3] [4] [5]
+ @Test
public void testLayout5KeyFix5L2() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L2);
assertEquals("5 key fix 5 L2 columns", 5, params.mNumColumns);
@@ -1603,6 +1702,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] [3] [4] <5>|
+ @Test
public void testLayout5KeyFix5R0() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R0);
assertEquals("5 key fix 5 R0 columns", 5, params.mNumColumns);
@@ -1619,6 +1719,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] [3] [4] <5> ___|
+ @Test
public void testLayout5KeyFix5R1() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R1);
assertEquals("5 key fix 5 R1 columns", 5, params.mNumColumns);
@@ -1635,6 +1736,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] [3] <4> [5] ___|
+ @Test
public void testLayout5KeyFix5R2() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R2);
assertEquals("5 key fix 5 R2 columns", 5, params.mNumColumns);
@@ -1652,6 +1754,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6]
// [1] [2] <3> [4] [5]
+ @Test
public void testLayout6KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_M0);
assertEquals("6 key fix 5 columns", 5, params.mNumColumns);
@@ -1670,6 +1773,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[6]
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout6KeyFix5L0() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L0);
assertEquals("6 key fix 5 L0 columns", 5, params.mNumColumns);
@@ -1688,6 +1792,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [6]
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout6KeyFix5L1() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L1);
assertEquals("6 key fix 5 L1 columns", 5, params.mNumColumns);
@@ -1706,6 +1811,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [6]
// |___ [1] <2> [3] [4] [5]
+ @Test
public void testLayout6KeyFix5L2() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L2);
assertEquals("6 key fix 5 L2 columns", 5, params.mNumColumns);
@@ -1724,6 +1830,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6]|
// [1] [2] [3] [4] <5>|
+ @Test
public void testLayout6KeyFix5R0() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R0);
assertEquals("6 key fix 5 R0 columns", 5, params.mNumColumns);
@@ -1742,6 +1849,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] ___|
// [1] [2] [3] [4] <5> ___|
+ @Test
public void testLayout6KeyFix5R1() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R1);
assertEquals("6 key fix 5 R1 columns", 5, params.mNumColumns);
@@ -1760,6 +1868,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] ___|
// [1] [2] [3] <4> [5] ___|
+ @Test
public void testLayout6KeyFix5R2() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R2);
assertEquals("6 key fix 5 R2 columns", 5, params.mNumColumns);
@@ -1778,6 +1887,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7]
// [1] [2] <3> [4] [5]
+ @Test
public void testLayout7KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_M0);
assertEquals("7 key fix 5 columns", 5, params.mNumColumns);
@@ -1797,6 +1907,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[6] [7]
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout7KeyFix5L0() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L0);
assertEquals("7 key fix 5 L0 columns", 5, params.mNumColumns);
@@ -1816,6 +1927,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [6] [7]
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout7KeyFix5L1() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L1);
assertEquals("7 key fix 5 L1 columns", 5, params.mNumColumns);
@@ -1835,6 +1947,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [6] [7]
// |___ [1] <2> [3] [4] [5]
+ @Test
public void testLayout7KeyFix5L2() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L2);
assertEquals("7 key fix 5 L2 columns", 5, params.mNumColumns);
@@ -1854,6 +1967,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7]|
// [1] [2] [3] [4] <5>|
+ @Test
public void testLayout7KeyFix5R0() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R0);
assertEquals("7 key fix 5 R0 columns", 5, params.mNumColumns);
@@ -1873,6 +1987,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] ___|
// [1] [2] [3] [4] <5> ___|
+ @Test
public void testLayout7KeyFix5R1() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R1);
assertEquals("7 key fix 5 R1 columns", 5, params.mNumColumns);
@@ -1892,6 +2007,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] ___|
// [1] [2] [3] <4> [5] ___|
+ @Test
public void testLayout7KeyFix5R2() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R2);
assertEquals("7 key fix 5 R2 columns",5, params.mNumColumns);
@@ -1911,6 +2027,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] [8]
// [1] [2] <3> [4] [5]
+ @Test
public void testLayout8KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_M0);
assertEquals("8 key fix 5 M0 columns", 5, params.mNumColumns);
@@ -1931,6 +2048,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[6] [7] [8]
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout8KeyFix5L0() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L0);
assertEquals("8 key fix 5 L0 columns", 5, params.mNumColumns);
@@ -1951,6 +2069,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [6] [7] [8]
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout8KeyFix5L1() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L1);
assertEquals("8 key fix 5 L1 columns", 5, params.mNumColumns);
@@ -1971,6 +2090,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [6] [7] [8]
// |___ [1] <2> [3] [4] [5]
+ @Test
public void testLayout8KeyFix5L2() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L2);
assertEquals("8 key fix 5 L2 columns", 5, params.mNumColumns);
@@ -1991,6 +2111,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] [8]|
// [1] [2] [3] [4] <5>|
+ @Test
public void testLayout8KeyFix5R0() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R0);
assertEquals("8 key fix 5 R0 columns", 5, params.mNumColumns);
@@ -2011,6 +2132,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] [8] ___|
// [1] [2] [3] [4] <5> ___|
+ @Test
public void testLayout8KeyFix5R1() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R1);
assertEquals("8 key fix 5 R1 columns", 5, params.mNumColumns);
@@ -2031,6 +2153,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] [8] ___|
// [1] [2] [3] <4> [5] ___|
+ @Test
public void testLayout8KeyFix5R2() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R2);
assertEquals("8 key fix 5 R2 columns", 5, params.mNumColumns);
@@ -2051,6 +2174,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] [8] [9]
// [1] [2] <3> [4] [5]
+ @Test
public void testLayout9KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_M0);
assertEquals("9 key fix 5 M0 columns", 5, params.mNumColumns);
@@ -2072,6 +2196,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[6] [7] [8] [9]
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout9KeyFix5L0() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L0);
assertEquals("9 key fix 5 L0 columns", 5, params.mNumColumns);
@@ -2093,6 +2218,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [6] [7] [8] [9]
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout9KeyFix5L1() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L1);
assertEquals("9 key fix 5 L1 columns", 5, params.mNumColumns);
@@ -2114,6 +2240,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [6] [7] [8] [9]
// |___ [1] <2> [3] [4] [5]
+ @Test
public void testLayout9KeyFix5L2() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L2);
assertEquals("9 key fix 5 L2 columns", 5, params.mNumColumns);
@@ -2135,6 +2262,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] [8] [9]|
// [1] [2] [3] [4] <5>|
+ @Test
public void testLayout9KeyFix5R0() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R0);
assertEquals("9 key fix 5 R0 columns", 5, params.mNumColumns);
@@ -2156,6 +2284,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] [8] [9] ___|
// [1] [2] [3] [4] <5> ___|
+ @Test
public void testLayout9KeyFix5R1() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R1);
assertEquals("9 key fix 5 R1 columns", 5, params.mNumColumns);
@@ -2177,6 +2306,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] [8] [9] ___|
// [1] [2] [3] <4> [5] ___|
+ @Test
public void testLayout9KeyFix5R2() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R2);
assertEquals("9 key fix 5 R2 columns", 5, params.mNumColumns);
@@ -2198,6 +2328,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] [8] [9] [A]
// [1] [2] <3> [4] [5]
+ @Test
public void testLayout10KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_M0);
assertEquals("10 key fix 5 M0 columns", 5, params.mNumColumns);
@@ -2220,6 +2351,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |[6] [7] [8] [9] [A]
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout10KeyFix5L0() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L0);
assertEquals("10 key fix 5 L0 columns", 5, params.mNumColumns);
@@ -2242,6 +2374,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [6] [7] [8] [9] [A]
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout10KeyFix5L1() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L1);
assertEquals("10 key fix 5 L1 columns", 5, params.mNumColumns);
@@ -2264,6 +2397,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// |___ [6] [7] [8] [9] [A]
// |___ [1] <2> [3] [4] [5]
+ @Test
public void testLayout10KeyFix5L2() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L2);
assertEquals("10 key fix 5 L2 columns", 5, params.mNumColumns);
@@ -2286,6 +2420,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] [8] [9] [A]|
// [1] [2] [3] [4] <5>|
+ @Test
public void testLayout10KeyFix5R0() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R0);
assertEquals("10 key fix 5 R0 columns", 5, params.mNumColumns);
@@ -2308,6 +2443,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] [8] [9] [A] ___|
// [1] [2] [3] [4] <5> ___|
+ @Test
public void testLayout10KeyFix5R1() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R1);
assertEquals("10 key fix 5 R1 columns", 5, params.mNumColumns);
@@ -2330,6 +2466,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [6] [7] [8] [9] [A] ___|
// [1] [2] [3] <4> [5] ___|
+ @Test
public void testLayout10KeyFix5R2() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R2);
assertEquals("10 key fix 5 R2 columns", 5, params.mNumColumns);
@@ -2353,6 +2490,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [B]
// [6] [7] [8] [9] [A]
// [1] [2] <3> [4] [5]
+ @Test
public void testLayout11KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(11, 5, XPOS_M0);
assertEquals("11 key fix 5 M0 columns", 5, params.mNumColumns);
@@ -2377,6 +2515,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [B] [C]
// [6] [7] [8] [9] [A]
// [1] [2] <3> [4] [5]
+ @Test
public void testLayout12KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(12, 5, XPOS_M0);
assertEquals("12 key fix 5 M0 columns", 5, params.mNumColumns);
@@ -2402,6 +2541,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [B] [C] [D]
// [6] [7] [8] [9] [A]
// [1] [2] <3> [4] [5]
+ @Test
public void testLayout13KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(13, 5, XPOS_M0);
assertEquals("13 key fix 5 M0 columns", 5, params.mNumColumns);
@@ -2428,6 +2568,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
// [B] [C] [D] [E]
// [6] [7] [8] [9] [A]
// [1] [2] <3> [4] [5]
+ @Test
public void testLayout14KeyFix5M0() {
MoreKeysKeyboardParams params = createParams(14, 5, XPOS_M0);
assertEquals("14 key fix 5 M0 columns", 5, params.mNumColumns);
@@ -2453,6 +2594,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |<1> [2] [3] [4] [5] [6] [7]
+ @Test
public void testLayout7KeyFix7L0() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L0);
assertEquals("7 key fix 7 L0 columns", 7, params.mNumColumns);
@@ -2471,6 +2613,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3] [4] [5] [6] [7]
+ @Test
public void testLayout7KeyFix7L1() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L1);
assertEquals("7 key fix 7 L1 columns", 7, params.mNumColumns);
@@ -2489,6 +2632,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ [1] <2> [3] [4] [5] [6] [7]
+ @Test
public void testLayout7KeyFix7L2() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L2);
assertEquals("7 key fix 7 L2 columns", 7, params.mNumColumns);
@@ -2507,6 +2651,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ [1] [2] <3> [4] [5] [6] [7]
+ @Test
public void testLayout7KeyFix7L3() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L3);
assertEquals("7 key fix 7 L3 columns", 7, params.mNumColumns);
@@ -2525,6 +2670,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ [1] [2] [3] <4> [5] [6] [7] ___ ___|
+ @Test
public void testLayout7KeyFix7M0() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_M0);
assertEquals("7 key fix 7 M0 columns", 7, params.mNumColumns);
@@ -2543,6 +2689,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// |___ ___ [1] [2] [3] <4> [5] [6] [7] ___|
+ @Test
public void testLayout7KeyFix7M1() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_M1);
assertEquals("7 key fix 7 M1 columns", 7, params.mNumColumns);
@@ -2561,6 +2708,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] [3] [4] <5> [6] [7] ___|
+ @Test
public void testLayout7KeyFix7R3() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R3);
assertEquals("7 key fix 7 R3 columns", 7, params.mNumColumns);
@@ -2579,6 +2727,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] [3] [4] [5] <6> [7] ___|
+ @Test
public void testLayout7KeyFix7R2() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R2);
assertEquals("7 key fix 7 R2 columns", 7, params.mNumColumns);
@@ -2597,6 +2746,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] [3] [4] [5] [6] <7> ___|
+ @Test
public void testLayout7KeyFix7R1() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R1);
assertEquals("7 key fix 7 R1 columns", 7, params.mNumColumns);
@@ -2615,6 +2765,7 @@ public class MoreKeysKeyboardBuilderFixedOrderTests extends AndroidTestCase {
}
// [1] [2] [3] [4] [5] [6] <7>|
+ @Test
public void testLayout7KeyFix7R0() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R0);
assertEquals("7 key fix 7 R0 columns", 7, params.mNumColumns);
diff --git a/tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderMaxOrderTests.java b/tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderMaxOrderTests.java
index 806790eff..1d28c2295 100644
--- a/tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderMaxOrderTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/MoreKeysKeyboardBuilderMaxOrderTests.java
@@ -16,13 +16,21 @@
package com.android.inputmethod.keyboard;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
+
+import androidx.test.filters.MediumTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.keyboard.MoreKeysKeyboard.MoreKeysKeyboardParams;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
@MediumTest
-public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class MoreKeysKeyboardBuilderMaxOrderTests {
private static final int WIDTH = 10;
private static final int HEIGHT = 10;
@@ -38,11 +46,6 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
private static final int XPOS_R1 = WIDTH * 8 + WIDTH / 2;
private static final int XPOS_R0 = WIDTH * 9 + WIDTH / 2;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
private static MoreKeysKeyboardParams createParams(final int numKeys, final int maxColumns,
final int coordXInParent) {
final MoreKeysKeyboardParams params = new MoreKeysKeyboardParams();
@@ -52,6 +55,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
return params;
}
+ @Test
public void testLayoutError() {
MoreKeysKeyboardParams params = null;
try {
@@ -69,6 +73,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// "<1>" is the default key.
// <1>
+ @Test
public void testLayout1KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_M0);
assertEquals("1 key max 5 M0 columns", 1, params.mNumColumns);
@@ -81,6 +86,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |<1>
+ @Test
public void testLayout1KeyMax5L0() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L0);
assertEquals("1 key max 5 L0 columns", 1, params.mNumColumns);
@@ -93,6 +99,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ <1>
+ @Test
public void testLayout1KeyMax5L1() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L1);
assertEquals("1 key max 5 L1 columns", 1, params.mNumColumns);
@@ -105,6 +112,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ ___ <1>
+ @Test
public void testLayout1KeyMax5L2() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L2);
assertEquals("1 key max 5 L2 columns", 1, params.mNumColumns);
@@ -117,6 +125,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// <1>|
+ @Test
public void testLayout1KeyMax5R0() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R0);
assertEquals("1 key max 5 R0 columns", 1, params.mNumColumns);
@@ -129,6 +138,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// <1> ___|
+ @Test
public void testLayout1KeyMax5R1() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R1);
assertEquals("1 key max 5 R1 columns", 1, params.mNumColumns);
@@ -141,6 +151,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// <1> ___ ___|
+ @Test
public void testLayout1KeyMax5R2() {
MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R2);
assertEquals("1 key max 5 R2 columns", 1, params.mNumColumns);
@@ -153,6 +164,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// <1> [2]
+ @Test
public void testLayout2KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_M0);
assertEquals("2 key max 5 M0 columns", 2, params.mNumColumns);
@@ -166,6 +178,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |<1> [2]
+ @Test
public void testLayout2KeyMax5L0() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L0);
assertEquals("2 key max 5 L0 columns", 2, params.mNumColumns);
@@ -179,6 +192,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ <1> [2]
+ @Test
public void testLayout2KeyMax5L1() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L1);
assertEquals("2 key max 5 L1 columns", 2, params.mNumColumns);
@@ -192,6 +206,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ ___ <1> [2]
+ @Test
public void testLayout2KeyMax5L2() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L2);
assertEquals("2 key max 5 L2 columns", 2, params.mNumColumns);
@@ -205,6 +220,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [2] <1>|
+ @Test
public void testLayout2KeyMax5R0() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R0);
assertEquals("2 key max 5 R0 columns", 2, params.mNumColumns);
@@ -218,6 +234,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [2] <1> ___|
+ @Test
public void testLayout2KeyMax5R1() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R1);
assertEquals("2 key max 5 R1 columns", 2, params.mNumColumns);
@@ -231,6 +248,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// <1> [2] ___|
+ @Test
public void testLayout2KeyMax5R2() {
MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R2);
assertEquals("2 key max 5 R2 columns", 2, params.mNumColumns);
@@ -244,6 +262,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [3] <1> [2]
+ @Test
public void testLayout3KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_M0);
assertEquals("3 key max 5 M0 columns", 3, params.mNumColumns);
@@ -258,6 +277,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |<1> [2] [3]
+ @Test
public void testLayout3KeyMax5L0() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L0);
assertEquals("3 key max 5 L0 columns", 3, params.mNumColumns);
@@ -272,6 +292,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3]
+ @Test
public void testLayout3KeyMax5L1() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L1);
assertEquals("3 key max 5 L1 columns", 3, params.mNumColumns);
@@ -286,6 +307,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ [3] <1> [2]
+ @Test
public void testLayout3KeyMax5L2() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L2);
assertEquals("3 key max 5 L2 columns", 3, params.mNumColumns);
@@ -300,6 +322,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [3] [2] <1>|
+ @Test
public void testLayout3KeyMax5R0() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R0);
assertEquals("3 key max 5 R0 columns", 3, params.mNumColumns);
@@ -314,6 +337,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [3] [2] <1> ___|
+ @Test
public void testLayout3KeyMax5R1() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R1);
assertEquals("3 key max 5 R1 columns", 3, params.mNumColumns);
@@ -328,6 +352,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [3] <1> [2] ___|
+ @Test
public void testLayout3KeyMax5R2() {
MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R2);
assertEquals("3 key max 5 R2 columns", 3, params.mNumColumns);
@@ -343,6 +368,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [3]
// <1> [2]
+ @Test
public void testLayout3KeyMax2M0() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_M0);
assertEquals("3 key max 2 M0 columns", 2, params.mNumColumns);
@@ -358,6 +384,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |[3]
// |<1> [2]
+ @Test
public void testLayout3KeyMax2L0() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L0);
assertEquals("3 key max 2 L0 columns", 2, params.mNumColumns);
@@ -373,6 +400,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [3]
// |___ <1> [2]
+ @Test
public void testLayout3KeyMax2L1() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L1);
assertEquals("3 key max 2 L1 columns", 2, params.mNumColumns);
@@ -388,6 +416,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// | [3]
// |___ ___ <1> [2]
+ @Test
public void testLayout3KeyMax2L2() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L2);
assertEquals("3 key max 2 L2 columns", 2, params.mNumColumns);
@@ -403,6 +432,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [3]|
// [2] <1>|
+ @Test
public void testLayout3KeyMax2R0() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R0);
assertEquals("3 key max 2 R0 columns", 2, params.mNumColumns);
@@ -418,6 +448,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [3] |
// [2] <1> ___|
+ @Test
public void testLayout3KeyMax2R1() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R1);
assertEquals("3 key max 2 R1 columns", 2, params.mNumColumns);
@@ -433,6 +464,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [3] |
// <1> [2] ___|
+ @Test
public void testLayout3KeyMax2R2() {
MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R2);
assertEquals("3 key max 2 R2 columns", 2, params.mNumColumns);
@@ -448,6 +480,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [3] [4]
// <1> [2]
+ @Test
public void testLayout4KeyMax3M0() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_M0);
assertEquals("4 key max 3 M0 columns", 2, params.mNumColumns);
@@ -464,6 +497,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |[3] [4]
// |<1> [2]
+ @Test
public void testLayout4KeyMax3L0() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L0);
assertEquals("4 key max 3 L0 columns", 2, params.mNumColumns);
@@ -480,6 +514,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [3] [4]
// |___ <1> [2]
+ @Test
public void testLayout4KeyMax3L1() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L1);
assertEquals("4 key max 3 L1 columns", 2, params.mNumColumns);
@@ -496,6 +531,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ ___ [3] [4]
// |___ ___ <1> [2]
+ @Test
public void testLayout4KeyMax3L2() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L2);
assertEquals("4 key max 3 L2 columns", 2, params.mNumColumns);
@@ -512,6 +548,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [4] [3]|
// [2] <1>|
+ @Test
public void testLayout4KeyMax3R0() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R0);
assertEquals("4 key max 3 R0 columns", 2, params.mNumColumns);
@@ -528,6 +565,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [4] [3] ___|
// [2] <1> ___|
+ @Test
public void testLayout4KeyMax3R1() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R1);
assertEquals("4 key max 3 R1 columns", 2, params.mNumColumns);
@@ -544,6 +582,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [3] [4] ___|
// <1> [2] ___|
+ @Test
public void testLayout4KeyMax3R2() {
MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R2);
assertEquals("4 key max 3 R2 columns", 2, params.mNumColumns);
@@ -559,6 +598,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [3] <1> [2] [4]
+ @Test
public void testLayout4KeyMax4M0() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_M0);
assertEquals("4 key max 4 M0 columns", 4, params.mNumColumns);
@@ -574,6 +614,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |<1> [2] [3] [4]
+ @Test
public void testLayout4KeyMax4L0() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_L0);
assertEquals("4 key max 4 L0 columns", 4, params.mNumColumns);
@@ -589,6 +630,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout4KeyMax4L1() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_L1);
assertEquals("4 key max 4 L1 columns", 4, params.mNumColumns);
@@ -604,6 +646,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ [3] <1> [2] [4]
+ @Test
public void testLayout4KeyMax4L2() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_L2);
assertEquals("4 key max 4 L2 columns", 4, params.mNumColumns);
@@ -619,6 +662,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [4] [3] [2] <1>|
+ @Test
public void testLayout4KeyMax4R0() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_R0);
assertEquals("4 key max 4 R0 columns", 4, params.mNumColumns);
@@ -634,6 +678,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [4] [3] [2] <1> ___|
+ @Test
public void testLayout4KeyMax4R1() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_R1);
assertEquals("4 key max 4 R1 columns", 4, params.mNumColumns);
@@ -649,6 +694,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [4] [3] <1> [2] ___|
+ @Test
public void testLayout4KeyMax4R2() {
MoreKeysKeyboardParams params = createParams(4, 4, XPOS_R2);
assertEquals("4 key max 4 R2 columns", 4, params.mNumColumns);
@@ -664,6 +710,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [3] <1> [2] [4]
+ @Test
public void testLayout4KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_M0);
assertEquals("4 key max 5 M0 columns", 4, params.mNumColumns);
@@ -679,6 +726,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |<1> [2] [3] [4]
+ @Test
public void testLayout4KeyMax5L0() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L0);
assertEquals("4 key max 5 L0 columns", 4, params.mNumColumns);
@@ -694,6 +742,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout4KeyMax5L1() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L1);
assertEquals("4 key max 5 L1 columns", 4, params.mNumColumns);
@@ -709,6 +758,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ [3] <1> [2] [4]
+ @Test
public void testLayout4KeyMax5L2() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L2);
assertEquals("4 key max 5 L2 columns", 4, params.mNumColumns);
@@ -724,6 +774,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [4] [3] [2] <1>|
+ @Test
public void testLayout4KeyMax5R0() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R0);
assertEquals("4 key max 5 R0 columns", 4, params.mNumColumns);
@@ -739,6 +790,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [4] [3] [2] <1> ___|
+ @Test
public void testLayout4KeyMax5R1() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R1);
assertEquals("4 key max 5 R1 columns", 4, params.mNumColumns);
@@ -754,6 +806,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [4] [3] <1> [2] ___|
+ @Test
public void testLayout4KeyMax5R2() {
MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R2);
assertEquals("4 key max 5 R2 columns", 4, params.mNumColumns);
@@ -770,6 +823,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [4] [5]
// [3] <1> [2]
+ @Test
public void testLayout5KeyMax3M0() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_M0);
assertEquals("5 key max 3 M0 columns", 3, params.mNumColumns);
@@ -787,6 +841,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |[4] [5]
// |<1> [2] [3]
+ @Test
public void testLayout5KeyMax3L0() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L0);
assertEquals("5 key max 3 L0 columns", 3, params.mNumColumns);
@@ -804,6 +859,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [4] [5]
// |___ <1> [2] [3]
+ @Test
public void testLayout5KeyMax3L1() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L1);
assertEquals("5 key max 3 L1 columns", 3, params.mNumColumns);
@@ -821,6 +877,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [4] [5]
// |___ [3] <1> [2]
+ @Test
public void testLayout5KeyMax3L2() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L2);
assertEquals("5 key max 3 L2 columns", 3, params.mNumColumns);
@@ -838,6 +895,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [5] [4]|
// [3] [2] <1>|
+ @Test
public void testLayout5KeyMax3R0() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R0);
assertEquals("5 key max 3 R0 columns", 3, params.mNumColumns);
@@ -855,6 +913,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [5] [4] ___|
// [3] [2] <1> ___|
+ @Test
public void testLayout5KeyMax3R1() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R1);
assertEquals("5 key max 3 R1 columns", 3, params.mNumColumns);
@@ -872,6 +931,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [4] [5] ___|
// [3] <1> [2] ___|
+ @Test
public void testLayout5KeyMax3R2() {
MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R2);
assertEquals("5 key max 3 R2 columns", 3, params.mNumColumns);
@@ -889,6 +949,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [4] [5]
// [3] <1> [2]
+ @Test
public void testLayout5KeyMax4M0() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_M0);
assertEquals("5 key max 4 M0 columns", 3, params.mNumColumns);
@@ -906,6 +967,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |[4] [5]
// |<1> [2] [3]
+ @Test
public void testLayout5KeyMax4L0() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L0);
assertEquals("5 key max 4 L0 columns", 3, params.mNumColumns);
@@ -923,6 +985,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [4] [5]
// |___ <1> [2] [3]
+ @Test
public void testLayout5KeyMax4L1() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L1);
assertEquals("5 key max 4 L1 columns", 3, params.mNumColumns);
@@ -940,6 +1003,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [4] [5]
// |___ [3] <1> [2]
+ @Test
public void testLayout5KeyMax4L2() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L2);
assertEquals("5 key max 4 L2 columns", 3, params.mNumColumns);
@@ -957,6 +1021,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [5] [4]|
// [3] [2] <1>|
+ @Test
public void testLayout5KeyMax4R0() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R0);
assertEquals("5 key max 4 R0 columns", 3, params.mNumColumns);
@@ -974,6 +1039,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [5] [4] ___|
// [3] [2] <1> ___|
+ @Test
public void testLayout5KeyMax4R1() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R1);
assertEquals("5 key max 4 R1 columns", 3, params.mNumColumns);
@@ -991,6 +1057,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [4] [5] ___|
// [3] <1> [2] ___|
+ @Test
public void testLayout5KeyMax4R2() {
MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R2);
assertEquals("5 key max 4 R2 columns", 3, params.mNumColumns);
@@ -1007,6 +1074,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout5KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_M0);
assertEquals("5 key max 5 M0 columns", 5, params.mNumColumns);
@@ -1023,6 +1091,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout5KeyMax5L0() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L0);
assertEquals("5 key max 5 L0 columns", 5, params.mNumColumns);
@@ -1039,6 +1108,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout5KeyMax5L1() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L1);
assertEquals("5 key max 5 L1 columns", 5, params.mNumColumns);
@@ -1055,6 +1125,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ [3] <1> [2] [4] [5]
+ @Test
public void testLayout5KeyMax5L2() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L2);
assertEquals("5 key max 5 L2 columns", 5, params.mNumColumns);
@@ -1071,6 +1142,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [5] [4] [3] [2] <1>|
+ @Test
public void testLayout5KeyMax5R0() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R0);
assertEquals("5 key max 5 R0 columns", 5, params.mNumColumns);
@@ -1087,6 +1159,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [5] [4] [3] [2] <1> ___|
+ @Test
public void testLayout5KeyMax5R1() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R1);
assertEquals("5 key max 5 R1 columns", 5, params.mNumColumns);
@@ -1103,6 +1176,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// [5] [4] [3] <1> [2] ___|
+ @Test
public void testLayout5KeyMax5R2() {
MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R2);
assertEquals("5 key max 5 R2 columns", 5, params.mNumColumns);
@@ -1120,6 +1194,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [6] [4] [5]
// [3] <1> [2]
+ @Test
public void testLayout6KeyMax4M0() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_M0);
assertEquals("6 key max 4 M0 columns", 3, params.mNumColumns);
@@ -1138,6 +1213,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |[4] [5] [6]
// |<1> [2] [3]
+ @Test
public void testLayout6KeyMax4L0() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L0);
assertEquals("6 key max 4 L0 columns", 3, params.mNumColumns);
@@ -1156,6 +1232,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [4] [5] [6]
// |___ <1> [2] [3]
+ @Test
public void testLayout6KeyMax4L1() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L1);
assertEquals("6 key max 4 L1 columns", 3, params.mNumColumns);
@@ -1174,6 +1251,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [6] [4] [5]
// |___ [3] <1> [2]
+ @Test
public void testLayout6KeyMax4L2() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L2);
assertEquals("6 key max 4 L2 columns", 3, params.mNumColumns);
@@ -1192,6 +1270,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [6] [5] [4]|
// [3] [2] <1>|
+ @Test
public void testLayout6KeyMax4R0() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R0);
assertEquals("6 key max 4 R0 columns", 3, params.mNumColumns);
@@ -1210,6 +1289,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [6] [5] [4] ___|
// [3] [2] <1> ___|
+ @Test
public void testLayout6KeyMax4R1() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R1);
assertEquals("6 key max 4 R1 columns", 3, params.mNumColumns);
@@ -1228,6 +1308,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [6] [4] [5] ___|
// [3] <1> [2] ___|
+ @Test
public void testLayout6KeyMax4R2() {
MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R2);
assertEquals("6 key max 4 R2 columns", 3, params.mNumColumns);
@@ -1246,6 +1327,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [6] [4] [5]
// [3] <1> [2]
+ @Test
public void testLayout6KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_M0);
assertEquals("6 key max 5 M0 columns", 3, params.mNumColumns);
@@ -1264,6 +1346,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |[4] [5] [6]
// |<1> [2] [3]
+ @Test
public void testLayout6KeyMax5L0() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L0);
assertEquals("6 key max 5 L0 columns", 3, params.mNumColumns);
@@ -1282,6 +1365,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [4] [5] [6]
// |___ <1> [2] [3]
+ @Test
public void testLayout6KeyMax5L1() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L1);
assertEquals("6 key max 5 L1 columns", 3, params.mNumColumns);
@@ -1300,6 +1384,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [6] [4] [5]
// |___ [3] <1> [2]
+ @Test
public void testLayout6KeyMax5L2() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L2);
assertEquals("6 key max 5 L2 columns", 3, params.mNumColumns);
@@ -1318,6 +1403,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [6] [5] [4]|
// [3] [2] <1>|
+ @Test
public void testLayout6KeyMax5R0() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R0);
assertEquals("6 key max 5 R0 columns", 3, params.mNumColumns);
@@ -1336,6 +1422,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [6] [5] [4] ___|
// [3] [2] <1> ___|
+ @Test
public void testLayout6KeyMax5R1() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R1);
assertEquals("6 key max 5 R1 columns", 3, params.mNumColumns);
@@ -1354,6 +1441,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [6] [4] [5] ___|
// [3] <1> [2] ___|
+ @Test
public void testLayout6KeyMax5R2() {
MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R2);
assertEquals("6 key max 5 R2 columns", 3, params.mNumColumns);
@@ -1371,6 +1459,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |<1> [2] [3] [4] [5] [6] [7] ___ ___ ___|
+ @Test
public void testLayout7KeyMax7L0() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L0);
assertEquals("7 key max 7 L0 columns", 7, params.mNumColumns);
@@ -1389,6 +1478,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ <1> [2] [3] [4] [5] [6] [7] ___ ___|
+ @Test
public void testLayout7KeyMax7L1() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L1);
assertEquals("7 key max 7 L1 columns", 7, params.mNumColumns);
@@ -1407,6 +1497,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ [3] <1> [2] [4] [5] [6] [7] ___ ___|
+ @Test
public void testLayout7KeyMax7L2() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L2);
assertEquals("7 key max 7 L2 columns", 7, params.mNumColumns);
@@ -1425,6 +1516,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ [5] [3] <1> [2] [4] [6] [7] ___ ___|
+ @Test
public void testLayout7KeyMax7L3() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L3);
assertEquals("7 key max 7 L3 columns", 7, params.mNumColumns);
@@ -1443,6 +1535,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ [7] [5] [3] <1> [2] [4] [6] ___ ___|
+ @Test
public void testLayout7KeyMax7M0() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_M0);
assertEquals("7 key max 7 M0 columns", 7, params.mNumColumns);
@@ -1461,6 +1554,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ ___ [7] [5] [3] <1> [2] [4] [6] ___|
+ @Test
public void testLayout7KeyMax7M1() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_M1);
assertEquals("7 key max 7 M1 columns", 7, params.mNumColumns);
@@ -1479,6 +1573,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ ___ [7] [6] [5] [3] <1> [2] [4] ___|
+ @Test
public void testLayout7KeyMax7R3() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R3);
assertEquals("7 key max 7 R3 columns", 7, params.mNumColumns);
@@ -1497,6 +1592,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ ___ [7] [6] [5] [4] [3] <1> [2] ___|
+ @Test
public void testLayout7KeyMax7R2() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R2);
assertEquals("7 key max 7 R2 columns", 7, params.mNumColumns);
@@ -1515,6 +1611,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ ___ [7] [6] [5] [4] [3] [2] <1> ___|
+ @Test
public void testLayout7KeyMax7R1() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R1);
assertEquals("7 key max 7 R1 columns", 7, params.mNumColumns);
@@ -1533,6 +1630,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
}
// |___ ___ [7] [6] [5] [4] [3] [2] <1>|
+ @Test
public void testLayout7KeyMax7R0() {
MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R0);
assertEquals("7 key max 7 R0 columns", 7, params.mNumColumns);
@@ -1552,6 +1650,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [5] [6] [7]
// [3] <1> [2] [4]
+ @Test
public void testLayout7KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_M0);
assertEquals("7 key max 5 M0 columns", 4, params.mNumColumns);
@@ -1571,6 +1670,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |[5] [6] [7]
// |<1> [2] [3] [4]
+ @Test
public void testLayout7KeyMax5L0() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L0);
assertEquals("7 key max 5 L0 columns", 4, params.mNumColumns);
@@ -1590,6 +1690,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [5] [6] [7]
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout7KeyMax5L1() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L1);
assertEquals("7 key max 5 L1 columns", 4, params.mNumColumns);
@@ -1609,6 +1710,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [5] [6] [7]
// |___ [3] <1> [2] [4]
+ @Test
public void testLayout7KeyMax5L2() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L2);
assertEquals("7 key max 5 L2 columns", 4, params.mNumColumns);
@@ -1628,6 +1730,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [7] [6] [5]|
// [4] [3] [2] <1>|
+ @Test
public void testLayout7KeyMax5R0() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R0);
assertEquals("7 key max 5 R0 columns", 4, params.mNumColumns);
@@ -1647,6 +1750,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [7] [6] [5] ___|
// [4] [3] [2] <1> ___|
+ @Test
public void testLayout7KeyMax5R1() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R1);
assertEquals("7 key max 5 R1 columns", 4, params.mNumColumns);
@@ -1666,6 +1770,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [7] [5] [6] ___|
// [4] [3] <1> [2] ___|
+ @Test
public void testLayout7KeyMax5R2() {
MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R2);
assertEquals("7 key max 5 R2 columns", 4, params.mNumColumns);
@@ -1686,6 +1791,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [7]
// [6] [4] [5]
// [3] <1> [2]
+ @Test
public void testLayout7KeyMax3M0() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_M0);
assertEquals("7 key max 3 M0 columns", 3, params.mNumColumns);
@@ -1706,6 +1812,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |[7]
// |[4] [5] [6]
// |<1> [2] [3]
+ @Test
public void testLayout7KeyMax3L0() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_L0);
assertEquals("7 key max 3 L0 columns", 3, params.mNumColumns);
@@ -1726,6 +1833,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [7]
// |___ [4] [5] [6]
// |___ <1> [2] [3]
+ @Test
public void testLayout7KeyMax3L1() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_L1);
assertEquals("7 key max 3 L1 columns", 3, params.mNumColumns);
@@ -1746,6 +1854,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [7]
// |___ [6] [4] [5]
// |___ [3] <1> [2]
+ @Test
public void testLayout7KeyMax3L2() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_L2);
assertEquals("7 key max 3 L2 columns", 3, params.mNumColumns);
@@ -1766,6 +1875,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [7]|
// [6] [5] [4]|
// [3] [2] <1>|
+ @Test
public void testLayout7KeyMax3R0() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_R0);
assertEquals("7 key max 3 R0 columns", 3, params.mNumColumns);
@@ -1786,6 +1896,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [7] ___|
// [6] [5] [4] ___|
// [3] [2] <1> ___|
+ @Test
public void testLayout7KeyMax3R1() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_R1);
assertEquals("7 key max 3 R1 columns", 3, params.mNumColumns);
@@ -1806,6 +1917,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [7] ___|
// [6] [4] [5] ___|
// [3] <1> [2] ___|
+ @Test
public void testLayout7KeyMax3R2() {
MoreKeysKeyboardParams params = createParams(7, 3, XPOS_R2);
assertEquals("7 key max 3 R2 columns", 3, params.mNumColumns);
@@ -1825,6 +1937,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [7] [5] [6] [8]
// [3] <1> [2] [4]
+ @Test
public void testLayout8KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_M0);
assertEquals("8 key max 5 M0 columns", 4, params.mNumColumns);
@@ -1845,6 +1958,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |[5] [6] [7] [8]
// |<1> [2] [3] [4]
+ @Test
public void testLayout8KeyMax5L0() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L0);
assertEquals("8 key max 5 L0 columns", 4, params.mNumColumns);
@@ -1865,6 +1979,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [5] [6] [7] [8]
// |___ <1> [2] [3] [4]
+ @Test
public void testLayout8KeyMax5L1() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L1);
assertEquals("8 key max 5 L1 columns", 4, params.mNumColumns);
@@ -1885,6 +2000,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [7] [5] [6] [8]
// |___ [3] <1> [2] [4]
+ @Test
public void testLayout8KeyMax5L2() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L2);
assertEquals("8 key max 5 L2 columns", 4, params.mNumColumns);
@@ -1905,6 +2021,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [8] [7] [6] [5]|
// [4] [3] [2] <1>|
+ @Test
public void testLayout8KeyMax5R0() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R0);
assertEquals("8 key max 5 R0 columns", 4, params.mNumColumns);
@@ -1925,6 +2042,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [8] [7] [6] [5] ___|
// [4] [3] [2] <1> ___|
+ @Test
public void testLayout8KeyMax5R1() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R1);
assertEquals("8 key max 5 R1 columns", 4, params.mNumColumns);
@@ -1945,6 +2063,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [8] [7] [5] [6] ___|
// [4] [3] <1> [2] ___|
+ @Test
public void testLayout8KeyMax5R2() {
MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R2);
assertEquals("8 key max 5 R2 columns", 4, params.mNumColumns);
@@ -1965,6 +2084,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [8] [6] [7] [9]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout9KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_M0);
assertEquals("9 key max 5 M0 columns", 5, params.mNumColumns);
@@ -1986,6 +2106,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |[6] [7] [8] [9]
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout9KeyMax5L0() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L0);
assertEquals("9 key max 5 L0 columns", 5, params.mNumColumns);
@@ -2007,6 +2128,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [6] [7] [8] [9]
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout9KeyMax5L1() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L1);
assertEquals("9 key max 5 L1 columns", 5, params.mNumColumns);
@@ -2028,6 +2150,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [6] [7] [8] [9]
// |___ [3] <1> [2] [4] [5]
+ @Test
public void testLayout9KeyMax5L2() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L2);
assertEquals("9 key max 5 L2 columns", 5, params.mNumColumns);
@@ -2049,6 +2172,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [9] [8] [7] [6]|
// [5] [4] [3] [2] <1>|
+ @Test
public void testLayout9KeyMax5R0() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R0);
assertEquals("9 key max 5 R0 columns", 5, params.mNumColumns);
@@ -2070,6 +2194,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [9] [8] [7] [6] ___|
// [5] [4] [3] [2] <1> ___|
+ @Test
public void testLayout9KeyMax5R1() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R1);
assertEquals("9 key max 5 R1 columns", 5, params.mNumColumns);
@@ -2091,6 +2216,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [9] [8] [6] [7] ___|
// [5] [4] [3] <1> [2] ___|
+ @Test
public void testLayout9KeyMax5R2() {
MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R2);
assertEquals("9 key max 5 R2 columns", 5, params.mNumColumns);
@@ -2112,6 +2238,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [A] [8] [6] [7] [9]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout10KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_M0);
assertEquals("10 key max 5 M0 columns", 5, params.mNumColumns);
@@ -2134,6 +2261,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |[6] [7] [8] [9] [A]
// |<1> [2] [3] [4] [5]
+ @Test
public void testLayout10KeyMax5L0() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L0);
assertEquals("10 key max 5 L0 columns", 5, params.mNumColumns);
@@ -2156,6 +2284,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [6] [7] [8] [9] [A]
// |___ <1> [2] [3] [4] [5]
+ @Test
public void testLayout10KeyMax5L1() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L1);
assertEquals("10 key max 5 L1 columns", 5, params.mNumColumns);
@@ -2178,6 +2307,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// |___ [8] [6] [7] [9] [A]
// |___ [3] <1> [2] [4] [5]
+ @Test
public void testLayout10KeyMax5L2() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L2);
assertEquals("10 key max 5 L2 columns", 5, params.mNumColumns);
@@ -2200,6 +2330,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [A] [9] [8] [7] [6]|
// [5] [4] [3] [2] <1>|
+ @Test
public void testLayout10KeyMax5R0() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R0);
assertEquals("10 key max 5 R0 columns", 5, params.mNumColumns);
@@ -2222,6 +2353,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [A] [9] [8] [7] [6] ___|
// [5] [4] [3] [2] <1> ___|
+ @Test
public void testLayout10KeyMax5R1() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R1);
assertEquals("10 key max 5 R1 columns", 5, params.mNumColumns);
@@ -2244,6 +2376,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [A] [9] [8] [6] [7] ___|
// [5] [4] [3] <1> [2] ___|
+ @Test
public void testLayout10KeyMax5R2() {
MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R2);
assertEquals("10 key max 5 R2 columns", 5, params.mNumColumns);
@@ -2267,6 +2400,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [9] [A] [B]
// [7] [5] [6] [8]
// [3] <1> [2] [4]
+ @Test
public void testLayout11KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(11, 5, XPOS_M0);
assertEquals("11 key max 5 M0 columns", 4, params.mNumColumns);
@@ -2291,6 +2425,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [B] [9] [A] [C]
// [7] [5] [6] [8]
// [3] <1> [2] [4]
+ @Test
public void testLayout12KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(12, 5, XPOS_M0);
assertEquals("12 key max 5 M0 columns", 4, params.mNumColumns);
@@ -2316,6 +2451,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [D] [B] [C]
// [A] [8] [6] [7] [9]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout13KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(13, 5, XPOS_M0);
assertEquals("13 key max 5 M0 columns", 5, params.mNumColumns);
@@ -2342,6 +2478,7 @@ public class MoreKeysKeyboardBuilderMaxOrderTests extends AndroidTestCase {
// [D] [B] [C] [E]
// [A] [8] [6] [7] [9]
// [5] [3] <1> [2] [4]
+ @Test
public void testLayout14KeyMax5M0() {
MoreKeysKeyboardParams params = createParams(14, 5, XPOS_M0);
assertEquals("13 key max 5 M0 columns", 5, params.mNumColumns);
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/HermiteInterpolatorTests.java b/tests/src/com/android/inputmethod/keyboard/internal/HermiteInterpolatorTests.java
index 3ff5aa485..a1ee199c0 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/HermiteInterpolatorTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/HermiteInterpolatorTests.java
@@ -16,25 +16,20 @@
package com.android.inputmethod.keyboard.internal;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertEquals;
-@SmallTest
-public class HermiteInterpolatorTests extends AndroidTestCase {
- private final HermiteInterpolator mInterpolator = new HermiteInterpolator();
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
+import org.junit.Test;
+import org.junit.runner.RunWith;
- private static final float EPSLION = 0.0000005f;
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class HermiteInterpolatorTests {
+ private final HermiteInterpolator mInterpolator = new HermiteInterpolator();
- private static void assertFloatEquals(final String message, float expected, float actual) {
- if (Math.abs(expected - actual) >= EPSLION) {
- fail(String.format("%s expected:<%s> but was:<%s>", message, expected, actual));
- }
- }
+ private static final float EPSILON = 0.0000005f;
// t=0 p0=(0,1)
// t=1 p1=(1,0)
@@ -57,6 +52,7 @@ public class HermiteInterpolatorTests extends AndroidTestCase {
private static final int p2 = 2;
private static final int p3 = 3;
+ @Test
public void testP0P1() {
// [(p0 p1) p2 p3]
mInterpolator.reset(mXCoords, mYCoords, p0, p3 + 1);
@@ -66,33 +62,34 @@ public class HermiteInterpolatorTests extends AndroidTestCase {
assertEquals("p1x", mXCoords[p1], mInterpolator.mP2X);
assertEquals("p1y", mYCoords[p1], mInterpolator.mP2Y);
// XY-slope at p0=3.0 (-0.75/-0.25)
- assertFloatEquals("slope x p0", -0.25f, mInterpolator.mSlope1X);
- assertFloatEquals("slope y p0", -0.75f, mInterpolator.mSlope1Y);
+ assertEquals("slope x p0", -0.25f, mInterpolator.mSlope1X, EPSILON);
+ assertEquals("slope y p0", -0.75f, mInterpolator.mSlope1Y, EPSILON);
// XY-slope at p1=1/3.0 (0.50/1.50)
- assertFloatEquals("slope x p1", 1.50f, mInterpolator.mSlope2X);
- assertFloatEquals("slope y p1", 0.50f, mInterpolator.mSlope2Y);
+ assertEquals("slope x p1", 1.50f, mInterpolator.mSlope2X, EPSILON);
+ assertEquals("slope y p1", 0.50f, mInterpolator.mSlope2Y, EPSILON);
// t=0.0 (p0)
mInterpolator.interpolate(0.0f);
- assertFloatEquals("t=0.0 x", 0.0f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.0 y", 1.0f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.0 x", 0.0f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.0 y", 1.0f, mInterpolator.mInterpolatedY, EPSILON);
// t=0.2
mInterpolator.interpolate(0.2f);
- assertFloatEquals("t=0.2 x", 0.02400f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.2 y", 0.78400f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.2 x", 0.02400f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.2 y", 0.78400f, mInterpolator.mInterpolatedY, EPSILON);
// t=0.5
mInterpolator.interpolate(0.5f);
- assertFloatEquals("t=0.5 x", 0.28125f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.5 y", 0.34375f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.5 x", 0.28125f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.5 y", 0.34375f, mInterpolator.mInterpolatedY, EPSILON);
// t=0.8
mInterpolator.interpolate(0.8f);
- assertFloatEquals("t=0.8 x", 0.69600f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.8 y", 0.01600f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.8 x", 0.69600f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.8 y", 0.01600f, mInterpolator.mInterpolatedY, EPSILON);
// t=1.0 (p1)
mInterpolator.interpolate(1.0f);
- assertFloatEquals("t=1.0 x", 1.0f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=1.0 y", 0.0f, mInterpolator.mInterpolatedY);
+ assertEquals("t=1.0 x", 1.0f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=1.0 y", 0.0f, mInterpolator.mInterpolatedY, EPSILON);
}
+ @Test
public void testP1P2() {
// [p0 (p1 p2) p3]
mInterpolator.reset(mXCoords, mYCoords, p0, p3 + 1);
@@ -102,33 +99,34 @@ public class HermiteInterpolatorTests extends AndroidTestCase {
assertEquals("p2x", mXCoords[p2], mInterpolator.mP2X);
assertEquals("p2y", mYCoords[p2], mInterpolator.mP2Y);
// XY-slope at p1=1/3.0 (0.50/1.50)
- assertFloatEquals("slope x p1", 1.50f, mInterpolator.mSlope1X);
- assertFloatEquals("slope y p1", 0.50f, mInterpolator.mSlope1Y);
+ assertEquals("slope x p1", 1.50f, mInterpolator.mSlope1X, EPSILON);
+ assertEquals("slope y p1", 0.50f, mInterpolator.mSlope1Y, EPSILON);
// XY-slope at p2=3.0 (1.50/0.50)
- assertFloatEquals("slope x p2", 0.50f, mInterpolator.mSlope2X);
- assertFloatEquals("slope y p2", 1.50f, mInterpolator.mSlope2Y);
+ assertEquals("slope x p2", 0.50f, mInterpolator.mSlope2X, EPSILON);
+ assertEquals("slope y p2", 1.50f, mInterpolator.mSlope2Y, EPSILON);
// t=0.0 (p1)
mInterpolator.interpolate(0.0f);
- assertFloatEquals("t=0.0 x", 1.0f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.0 y", 0.0f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.0 x", 1.0f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.0 y", 0.0f, mInterpolator.mInterpolatedY, EPSILON);
// t=0.2
mInterpolator.interpolate(0.2f);
- assertFloatEquals("t=0.2 x", 1.384f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.2 y", 0.224f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.2 x", 1.384f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.2 y", 0.224f, mInterpolator.mInterpolatedY, EPSILON);
// t=0.5
mInterpolator.interpolate(0.5f);
- assertFloatEquals("t=0.5 x", 2.125f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.5 y", 0.875f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.5 x", 2.125f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.5 y", 0.875f, mInterpolator.mInterpolatedY, EPSILON);
// t=0.8
mInterpolator.interpolate(0.8f);
- assertFloatEquals("t=0.8 x", 2.776f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.8 y", 1.616f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.8 x", 2.776f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.8 y", 1.616f, mInterpolator.mInterpolatedY, EPSILON);
// t=1.0 (p2)
mInterpolator.interpolate(1.0f);
- assertFloatEquals("t=1.0 x", 3.0f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=1.0 y", 2.0f, mInterpolator.mInterpolatedY);
+ assertEquals("t=1.0 x", 3.0f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=1.0 y", 2.0f, mInterpolator.mInterpolatedY, EPSILON);
}
+ @Test
public void testP2P3() {
// [p0 p1 (p2 p3)]
mInterpolator.reset(mXCoords, mYCoords, p0, p3 + 1);
@@ -138,33 +136,34 @@ public class HermiteInterpolatorTests extends AndroidTestCase {
assertEquals("p3x", mXCoords[p3], mInterpolator.mP2X);
assertEquals("p3y", mYCoords[p3], mInterpolator.mP2Y);
// XY-slope at p2=3.0 (1.50/0.50)
- assertFloatEquals("slope x p2", 0.50f, mInterpolator.mSlope1X);
- assertFloatEquals("slope y p2", 1.50f, mInterpolator.mSlope1Y);
+ assertEquals("slope x p2", 0.50f, mInterpolator.mSlope1X, EPSILON);
+ assertEquals("slope y p2", 1.50f, mInterpolator.mSlope1Y, EPSILON);
// XY-slope at p3=1/3.0 (-0.25/-0.75)
- assertFloatEquals("slope x p3", -0.75f, mInterpolator.mSlope2X);
- assertFloatEquals("slope y p3", -0.25f, mInterpolator.mSlope2Y);
+ assertEquals("slope x p3", -0.75f, mInterpolator.mSlope2X, EPSILON);
+ assertEquals("slope y p3", -0.25f, mInterpolator.mSlope2Y, EPSILON);
// t=0.0 (p2)
mInterpolator.interpolate(0.0f);
- assertFloatEquals("t=0.0 x", 3.0f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.0 y", 2.0f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.0 x", 3.0f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.0 y", 2.0f, mInterpolator.mInterpolatedY, EPSILON);
// t=0.2
mInterpolator.interpolate(0.2f);
- assertFloatEquals("t=0.2 x", 2.98400f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.2 y", 2.30400f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.2 x", 2.98400f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.2 y", 2.30400f, mInterpolator.mInterpolatedY, EPSILON);
// t=0.5
mInterpolator.interpolate(0.5f);
- assertFloatEquals("t=0.5 x", 2.65625f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.5 y", 2.71875f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.5 x", 2.65625f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.5 y", 2.71875f, mInterpolator.mInterpolatedY, EPSILON);
// t=0.8
mInterpolator.interpolate(0.8f);
- assertFloatEquals("t=0.8 x", 2.21600f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.8 y", 2.97600f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.8 x", 2.21600f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.8 y", 2.97600f, mInterpolator.mInterpolatedY, EPSILON);
// t=1.0 (p3)
mInterpolator.interpolate(1.0f);
- assertFloatEquals("t=1.0 x", 2.0f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=1.0 y", 3.0f, mInterpolator.mInterpolatedY);
+ assertEquals("t=1.0 x", 2.0f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=1.0 y", 3.0f, mInterpolator.mInterpolatedY, EPSILON);
}
+ @Test
public void testJustP1P2() {
// [(p1 p2)]
mInterpolator.reset(mXCoords, mYCoords, p1, p2 + 1);
@@ -174,30 +173,30 @@ public class HermiteInterpolatorTests extends AndroidTestCase {
assertEquals("p2x", mXCoords[p2], mInterpolator.mP2X);
assertEquals("p2y", mYCoords[p2], mInterpolator.mP2Y);
// XY-slope at p1=1.0 (2.0/2.0)
- assertFloatEquals("slope x p1", 2.00f, mInterpolator.mSlope1X);
- assertFloatEquals("slope y p1", 2.00f, mInterpolator.mSlope1Y);
+ assertEquals("slope x p1", 2.00f, mInterpolator.mSlope1X, EPSILON);
+ assertEquals("slope y p1", 2.00f, mInterpolator.mSlope1Y, EPSILON);
// XY-slope at p2=1.0 (2.0/2.0)
- assertFloatEquals("slope x p2", 2.00f, mInterpolator.mSlope2X);
- assertFloatEquals("slope y p2", 2.00f, mInterpolator.mSlope2Y);
+ assertEquals("slope x p2", 2.00f, mInterpolator.mSlope2X, EPSILON);
+ assertEquals("slope y p2", 2.00f, mInterpolator.mSlope2Y, EPSILON);
// t=0.0 (p1)
mInterpolator.interpolate(0.0f);
- assertFloatEquals("t=0.0 x", 1.0f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.0 y", 0.0f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.0 x", 1.0f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.0 y", 0.0f, mInterpolator.mInterpolatedY, EPSILON);
// t=0.2
mInterpolator.interpolate(0.2f);
- assertFloatEquals("t=0.2 x", 1.4f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.2 y", 0.4f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.2 x", 1.4f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.2 y", 0.4f, mInterpolator.mInterpolatedY, EPSILON);
// t=0.5
mInterpolator.interpolate(0.5f);
- assertFloatEquals("t=0.5 x", 2.0f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.5 y", 1.0f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.5 x", 2.0f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.5 y", 1.0f, mInterpolator.mInterpolatedY, EPSILON);
// t=0.8
mInterpolator.interpolate(0.8f);
- assertFloatEquals("t=0.8 x", 2.6f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=0.8 y", 1.6f, mInterpolator.mInterpolatedY);
+ assertEquals("t=0.8 x", 2.6f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=0.8 y", 1.6f, mInterpolator.mInterpolatedY, EPSILON);
// t=1.0 (p2)
mInterpolator.interpolate(1.0f);
- assertFloatEquals("t=1.0 x", 3.0f, mInterpolator.mInterpolatedX);
- assertFloatEquals("t=1.0 y", 2.0f, mInterpolator.mInterpolatedY);
+ assertEquals("t=1.0 x", 3.0f, mInterpolator.mInterpolatedX, EPSILON);
+ assertEquals("t=1.0 y", 2.0f, mInterpolator.mInterpolatedY, EPSILON);
}
}
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSetTests.java b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSetTests.java
index 72211015f..f312cadae 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSetTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSetTests.java
@@ -16,28 +16,41 @@
package com.android.inputmethod.keyboard.internal;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
import android.content.Context;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
@SmallTest
-public final class KeyboardTextsSetTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public final class KeyboardTextsSetTests {
// All input method subtypes of LatinIME.
private List<InputMethodSubtype> mAllSubtypesList;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ private Context getContext() {
+ return InstrumentationRegistry.getTargetContext();
+ }
+
+ @Before
+ public void setUp() throws Exception {
RichInputMethodManager.init(getContext());
final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
@@ -54,6 +67,7 @@ public final class KeyboardTextsSetTests extends AndroidTestCase {
// Test that the text {@link KeyboardTextsSet#SWITCH_TO_ALPHA_KEY_LABEL} exists for all
// subtypes. The text is needed to implement Emoji Keyboard, see
// {@link KeyboardSwitcher#setEmojiKeyboard()}.
+ @Test
public void testSwitchToAlphaKeyLabel() {
final Context context = getContext();
final KeyboardTextsSet textsSet = new KeyboardTextsSet();
@@ -80,6 +94,7 @@ public final class KeyboardTextsSetTests extends AndroidTestCase {
};
// Test that the text from resources are correctly loaded for all subtypes.
+ @Test
public void testTextFromResources() {
final Context context = getContext();
final KeyboardTextsSet textsSet = new KeyboardTextsSet();
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MatrixUtilsTests.java b/tests/src/com/android/inputmethod/keyboard/internal/MatrixUtilsTests.java
index e2a11ab99..10c552f29 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/MatrixUtilsTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/MatrixUtilsTests.java
@@ -16,25 +16,25 @@
package com.android.inputmethod.keyboard.internal;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.keyboard.internal.MatrixUtils.MatrixOperationFailedException;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
@SmallTest
-public class MatrixUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class MatrixUtilsTests {
// "run tests" -c com.android.inputmethod.keyboard.internal.MatrixUtilsTests
private static final boolean DEBUG = false;
private static final float EPSILON = 0.00001f;
- private static void assertEqualsFloat(float f0, float f1) {
- assertEqualsFloat(f0, f1, EPSILON);
- }
-
- /* package */ static void assertEqualsFloat(float f0, float f1, float error) {
- assertTrue(Math.abs(f0 - f1) < error);
- }
-
+ @Test
public void testMulti() {
final float[][] matrixA = {{1, 2}, {3, 4}};
final float[][] matrixB = {{5, 6}, {7, 8}};
@@ -47,12 +47,13 @@ public class MatrixUtilsTests extends AndroidTestCase {
if (DEBUG) {
MatrixUtils.dump("multi", retval);
}
- assertEqualsFloat(retval[0][0], 19);
- assertEqualsFloat(retval[0][1], 22);
- assertEqualsFloat(retval[1][0], 43);
- assertEqualsFloat(retval[1][1], 50);
+ assertEquals(retval[0][0], 19, EPSILON);
+ assertEquals(retval[0][1], 22, EPSILON);
+ assertEquals(retval[1][0], 43, EPSILON);
+ assertEquals(retval[1][1], 50, EPSILON);
}
+ @Test
public void testInverse() {
final int N = 4;
final float[][] matrix =
@@ -77,7 +78,7 @@ public class MatrixUtilsTests extends AndroidTestCase {
}
for (int i = 0; i < N; ++i) {
for (int j = 0; j < N; ++j) {
- assertEqualsFloat(((i == j) ? 1.0f : 0.0f), retval[i][j]);
+ assertEquals(((i == j) ? 1.0f : 0.0f), retval[i][j], EPSILON);
}
}
}
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecSplitTests.java b/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecSplitTests.java
index 8f4648c52..cbedd0426 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecSplitTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecSplitTests.java
@@ -16,26 +16,34 @@
package com.android.inputmethod.keyboard.internal;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import android.content.Context;
import android.content.res.Resources;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.R;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.Arrays;
import java.util.Locale;
@SmallTest
-public class MoreKeySpecSplitTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class MoreKeySpecSplitTests {
private static final Locale TEST_LOCALE = Locale.ENGLISH;
private final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- final Context targetContext = getContext();
+ @Before
+ public void setUp() throws Exception {
+ final Context targetContext = InstrumentationRegistry.getTargetContext();
final Resources targetRes = targetContext.getResources();
final String targetPackageName = targetRes.getResourcePackageName(
R.string.english_ime_name);
@@ -90,6 +98,7 @@ public class MoreKeySpecSplitTests extends AndroidTestCase {
private static final String SURROGATE1 = PAIR1 + PAIR2;
private static final String SURROGATE2 = PAIR1 + PAIR2 + PAIR3;
+ @Test
public void testSplitZero() {
assertTextArray("Empty string", "");
assertTextArray("Empty entry", ",");
@@ -99,6 +108,7 @@ public class MoreKeySpecSplitTests extends AndroidTestCase {
assertTextArray("Empty entries with escape", ",a,b\\,c,,d,", "a", "b\\,c", "d");
}
+ @Test
public void testSplitSingle() {
assertTextArray("Single char", "a", "a");
assertTextArray("Surrogate pair", PAIR1, PAIR1);
@@ -128,6 +138,7 @@ public class MoreKeySpecSplitTests extends AndroidTestCase {
assertTextArray("Incomplete resource reference 4", "!" + SURROGATE2, "!" + SURROGATE2);
}
+ @Test
public void testSplitSingleEscaped() {
assertTextArray("Escaped char", "\\a", "\\a");
assertTextArray("Escaped surrogate pair", "\\" + PAIR1, "\\" + PAIR1);
@@ -163,6 +174,7 @@ public class MoreKeySpecSplitTests extends AndroidTestCase {
assertTextArray("Escaped !TEXT/NAME", "\\!TEXT/EMPTY_STRING", "\\!TEXT/EMPTY_STRING");
}
+ @Test
public void testSplitMulti() {
assertTextArray("Multiple chars", "a,b,c", "a", "b", "c");
assertTextArray("Multiple chars", "a,b,\\c", "a", "b", "\\c");
@@ -178,6 +190,7 @@ public class MoreKeySpecSplitTests extends AndroidTestCase {
" abc ", " def ", " ghi ");
}
+ @Test
public void testSplitMultiEscaped() {
assertTextArray("Multiple chars with comma", "a,\\,,c", "a", "\\,", "c");
assertTextArray("Multiple chars with comma surrounded by spaces", " a , \\, , c ",
@@ -197,16 +210,19 @@ public class MoreKeySpecSplitTests extends AndroidTestCase {
"\\!", "\\!TEXT/EMPTY_STRING");
}
+ @Test
public void testSplitTextReferenceError() {
assertError("Incomplete text name", "!text/", "!text/");
assertError("Non existing text", "!text/non_existing");
}
+ @Test
public void testSplitEmptyTextReference() {
// Note that morekeys_q of English locale is empty.
assertTextArray("Empty string", "!text/morekeys_q");
}
+ @Test
public void testLabelReferece() {
assertTextArray("Label time am", "!text/keylabel_time_am", "AM");
@@ -217,6 +233,7 @@ public class MoreKeySpecSplitTests extends AndroidTestCase {
"!icon/settings_key|!code/key_settings");
}
+ @Test
public void testUselessUpperCaseSpecifier() {
assertTextArray("EMPTY STRING",
"!TEXT/EMPTY_STRING", "!TEXT/EMPTY_STRING");
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecStringReferenceTests.java b/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecStringReferenceTests.java
index e06ecaedf..3655abbd5 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecStringReferenceTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecStringReferenceTests.java
@@ -16,26 +16,34 @@
package com.android.inputmethod.keyboard.internal;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
import android.app.Instrumentation;
import android.content.Context;
import android.content.res.Resources;
-import android.test.InstrumentationTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.tests.R;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.Locale;
@SmallTest
-public class MoreKeySpecStringReferenceTests extends InstrumentationTestCase {
+@RunWith(AndroidJUnit4.class)
+public class MoreKeySpecStringReferenceTests {
private static final Locale TEST_LOCALE = Locale.ENGLISH;
private final KeyboardTextsSet mTextsSet = new KeyboardTextsSet();
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- final Instrumentation instrumentation = getInstrumentation();
+ @Before
+ public void setUp() throws Exception {
+ final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
final Context testContext = instrumentation.getContext();
final Resources testRes = testContext.getResources();
final String testPackageName = testRes.getResourcePackageName(R.string.empty_string);
@@ -59,16 +67,19 @@ public class MoreKeySpecStringReferenceTests extends InstrumentationTestCase {
}
}
+ @Test
public void testResolveNullText() {
assertEquals("resolve null",
mTextsSet.resolveTextReference(null), null);
}
+ @Test
public void testResolveEmptyText() {
assertEquals("resolve empty text",
mTextsSet.resolveTextReference("!string/empty_string"), null);
}
+ @Test
public void testSplitSingleEscaped() {
assertTextArray("Escaped !string", "\\!string",
"\\!string");
@@ -82,6 +93,7 @@ public class MoreKeySpecStringReferenceTests extends InstrumentationTestCase {
"\\!STRING/EMPTY_STRING");
}
+ @Test
public void testSplitMultiEscaped() {
assertTextArray("Multiple escaped !string", "\\!,\\!string/empty_string",
"\\!", "\\!string/empty_string");
@@ -89,15 +101,18 @@ public class MoreKeySpecStringReferenceTests extends InstrumentationTestCase {
"\\!", "\\!STRING/EMPTY_STRING");
}
+ @Test
public void testSplitStringReferenceError() {
assertError("Incomplete resource name", "!string/", "!string/");
assertError("Non existing resource", "!string/non_existing");
}
+ @Test
public void testSplitEmptyStringReference() {
assertTextArray("Empty string", "!string/empty_string");
}
+ @Test
public void testSplitResourceSingle() {
assertTextArray("Single char", "!string/single_char",
"a");
@@ -119,6 +134,7 @@ public class MoreKeySpecStringReferenceTests extends InstrumentationTestCase {
"\\\\a");
}
+ @Test
public void testSplitResourceSingleEscaped() {
assertTextArray("Escaped char",
"!string/escaped_char", "\\a");
@@ -146,6 +162,7 @@ public class MoreKeySpecStringReferenceTests extends InstrumentationTestCase {
"!string/escaped_label_with_escape", "a\\\\c");
}
+ @Test
public void testSplitResourceMulti() {
assertTextArray("Multiple chars",
"!string/multiple_chars", "a", "b", "c");
@@ -158,6 +175,7 @@ public class MoreKeySpecStringReferenceTests extends InstrumentationTestCase {
"!string/multiple_labels_surrounded_by_spaces", " abc ", " def ", " ghi ");
}
+ @Test
public void testSplitResourcetMultiEscaped() {
assertTextArray("Multiple chars with comma",
"!string/multiple_chars_with_comma",
@@ -179,6 +197,7 @@ public class MoreKeySpecStringReferenceTests extends InstrumentationTestCase {
" ab\\\\ ", " d\\\\\\, ", " g\\,i ");
}
+ @Test
public void testSplitMultipleResources() {
assertTextArray("Literals and resources",
"1,!string/multiple_chars,z",
@@ -203,6 +222,7 @@ public class MoreKeySpecStringReferenceTests extends InstrumentationTestCase {
"abcabc", "def", "ghi");
}
+ @Test
public void testSplitIndirectReference() {
assertTextArray("Indirect",
"!string/indirect_string", "a", "b", "c");
@@ -212,11 +232,13 @@ public class MoreKeySpecStringReferenceTests extends InstrumentationTestCase {
"!string/indirect2_string", "a", "b", "c");
}
+ @Test
public void testSplitInfiniteIndirectReference() {
assertError("Infinite indirection",
"1,!string/infinite_indirection,2", "1", "infinite", "<infinite>", "loop", "2");
}
+ @Test
public void testLabelReferece() {
assertTextArray("Indirect naviagte actions as more key",
"!string/keyspec_indirect_navigate_actions",
@@ -225,6 +247,7 @@ public class MoreKeySpecStringReferenceTests extends InstrumentationTestCase {
"!hasLabels!", "ActionNext|!code/key_action_next");
}
+ @Test
public void testUselessUpperCaseSpecifier() {
assertTextArray("EMPTY STRING",
"!STRING/EMPTY_STRING", "!STRING/EMPTY_STRING");
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueueTests.java b/tests/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueueTests.java
index 7908b260e..6ab1549c0 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueueTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/PointerTrackerQueueTests.java
@@ -16,11 +16,19 @@
package com.android.inputmethod.keyboard.internal;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
@SmallTest
-public class PointerTrackerQueueTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class PointerTrackerQueueTests {
public static class Element implements PointerTrackerQueue.Element {
public static int sPhantomUpCount;
public static final long NOT_HAPPENED = -1;
@@ -65,11 +73,13 @@ public class PointerTrackerQueueTests extends AndroidTestCase {
private final Element mElement4 = new Element(4);
private final PointerTrackerQueue mQueue = new PointerTrackerQueue();
+ @Test
public void testEmpty() {
assertEquals(0, mQueue.size());
assertEquals("[]", mQueue.toString());
}
+ @Test
public void testAdd() {
mQueue.add(mElement1);
assertEquals(1, mQueue.size());
@@ -85,6 +95,7 @@ public class PointerTrackerQueueTests extends AndroidTestCase {
assertEquals("[1 2 3 4]", mQueue.toString());
}
+ @Test
public void testRemove() {
Element.sPhantomUpCount = 0;
@@ -119,6 +130,7 @@ public class PointerTrackerQueueTests extends AndroidTestCase {
assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime);
}
+ @Test
public void testAddAndRemove() {
Element.sPhantomUpCount = 0;
@@ -158,6 +170,7 @@ public class PointerTrackerQueueTests extends AndroidTestCase {
assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime);
}
+ @Test
public void testReleaseAllPointers() {
mElement2.mIsModifier = true;
mQueue.add(mElement1);
@@ -177,6 +190,7 @@ public class PointerTrackerQueueTests extends AndroidTestCase {
assertEquals(eventTime + 4, mElement4.mPhantomUpEventTime);
}
+ @Test
public void testReleaseAllPointersOlderThanFirst() {
mElement2.mIsModifier = true;
mQueue.add(mElement1);
@@ -194,6 +208,7 @@ public class PointerTrackerQueueTests extends AndroidTestCase {
assertEquals(Element.NOT_HAPPENED, mElement3.mPhantomUpEventTime);
}
+ @Test
public void testReleaseAllPointersOlderThanLast() {
mElement2.mIsModifier = true;
mQueue.add(mElement1);
@@ -213,6 +228,7 @@ public class PointerTrackerQueueTests extends AndroidTestCase {
assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime);
}
+ @Test
public void testReleaseAllPointersOlderThanWithoutModifierMiddle() {
mQueue.add(mElement1);
mQueue.add(mElement2);
@@ -231,6 +247,7 @@ public class PointerTrackerQueueTests extends AndroidTestCase {
assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime);
}
+ @Test
public void testReleaseAllPointersOlderThanWithoutModifierLast() {
mQueue.add(mElement1);
mQueue.add(mElement2);
@@ -249,6 +266,7 @@ public class PointerTrackerQueueTests extends AndroidTestCase {
assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime);
}
+ @Test
public void testReleaseAllPointersExcept() {
mElement2.mIsModifier = true;
mQueue.add(mElement1);
@@ -268,6 +286,7 @@ public class PointerTrackerQueueTests extends AndroidTestCase {
assertEquals(eventTime + 3, mElement4.mPhantomUpEventTime);
}
+ @Test
public void testHasModifierKeyOlderThan() {
Element.sPhantomUpCount = 0;
assertFalse("hasModifierKeyOlderThan empty", mQueue.hasModifierKeyOlderThan(mElement1));
@@ -297,6 +316,7 @@ public class PointerTrackerQueueTests extends AndroidTestCase {
assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime);
}
+ @Test
public void testIsAnyInDraggingFinger() {
Element.sPhantomUpCount = 0;
assertFalse(mQueue.isAnyInDraggingFinger());
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/SmoothingUtilsTests.java b/tests/src/com/android/inputmethod/keyboard/internal/SmoothingUtilsTests.java
index 293741af2..39da3ec71 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/SmoothingUtilsTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/SmoothingUtilsTests.java
@@ -16,16 +16,24 @@
package com.android.inputmethod.keyboard.internal;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.keyboard.internal.MatrixUtils.MatrixOperationFailedException;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
@SmallTest
-public class SmoothingUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class SmoothingUtilsTests {
// "run tests" -c com.android.inputmethod.keyboard.internal.SmoothingUtilsTests
private static final boolean DEBUG = false;
+ @Test
public void testGet3DParamaters() {
final float[] xs = new float[] {0, 1, 2, 3, 4};
final float[] ys = new float[] {1, 4, 15, 40, 85}; // y = x^3 + x^2 + x + 1
@@ -36,7 +44,7 @@ public class SmoothingUtilsTests extends AndroidTestCase {
MatrixUtils.dump("3d", retval);
}
for (int i = 0; i < 4; ++i) {
- MatrixUtilsTests.assertEqualsFloat(retval[i][0], 1.0f, 0.001f);
+ assertEquals(retval[i][0], 1.0f, 0.001f);
}
} catch (MatrixOperationFailedException e) {
assertTrue(false);
diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
index e96c934cb..db8b80949 100644
--- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
@@ -16,11 +16,18 @@
package com.android.inputmethod.latin;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import android.text.TextUtils;
import android.util.Pair;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.LargeTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.latin.NgramContext.WordInfo;
import com.android.inputmethod.latin.common.CodePointUtils;
import com.android.inputmethod.latin.common.FileUtils;
@@ -30,6 +37,11 @@ import com.android.inputmethod.latin.makedict.WeightedString;
import com.android.inputmethod.latin.makedict.WordProperty;
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -39,26 +51,25 @@ import java.util.Locale;
import java.util.Random;
@LargeTest
-public class BinaryDictionaryTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class BinaryDictionaryTests {
private static final String TEST_DICT_FILE_EXTENSION = ".testDict";
private static final String TEST_LOCALE = "test";
private static final String DICTIONARY_ID = "TestBinaryDictionary";
private HashSet<File> mDictFilesToBeDeleted = new HashSet<>();
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
mDictFilesToBeDeleted.clear();
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
for (final File dictFile : mDictFilesToBeDeleted) {
dictFile.delete();
}
mDictFilesToBeDeleted.clear();
- super.tearDown();
}
private File createEmptyDictionaryAndGetFile(final int formatVersion) {
@@ -82,7 +93,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
private File createEmptyVer4DictionaryAndGetFile(final int formatVersion,
final HashMap<String, String> attributeMap) throws IOException {
final File file = File.createTempFile(DICTIONARY_ID, TEST_DICT_FILE_EXTENSION,
- getContext().getCacheDir());
+ InstrumentationRegistry.getTargetContext().getCacheDir());
file.delete();
file.mkdir();
if (BinaryDictionaryUtils.createEmptyDictFile(file.getAbsolutePath(), formatVersion,
@@ -106,6 +117,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
Locale.getDefault(), TEST_LOCALE, true /* isUpdatable */);
}
+ @Test
public void testIsValidDictionary() {
final File dictFile = createEmptyDictionaryAndGetFile(FormatSpec.VERSION403);
BinaryDictionary binaryDictionary = getBinaryDictionary(dictFile);
@@ -121,6 +133,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
binaryDictionary.close();
}
+ @Test
public void testConstructingDictionaryOnMemory() {
final File dictFile = createEmptyDictionaryAndGetFile(FormatSpec.VERSION403);
FileUtils.deleteRecursively(dictFile);
@@ -142,6 +155,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
binaryDictionary.close();
}
+ @Test
public void testAddTooLongWord() {
final BinaryDictionary binaryDictionary = getEmptyBinaryDictionary(FormatSpec.VERSION403);
final StringBuffer stringBuilder = new StringBuffer();
@@ -209,6 +223,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
new NgramContext(new WordInfo(word1), new WordInfo(word0)), word2);
}
+ @Test
public void testAddUnigramWord() {
final BinaryDictionary binaryDictionary = getEmptyBinaryDictionary(FormatSpec.VERSION403);
final int probability = 100;
@@ -236,6 +251,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
assertEquals(updatedProbability, binaryDictionary.getFrequency("aaa"));
}
+ @Test
public void testRandomlyAddUnigramWord() {
final int wordCount = 1000;
final int codePointSetSize = 50;
@@ -258,6 +274,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
}
}
+ @Test
public void testAddBigramWords() {
final BinaryDictionary binaryDictionary = getEmptyBinaryDictionary(FormatSpec.VERSION403);
@@ -311,6 +328,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
getBigramProbability(binaryDictionary, "abcde", "fghij"));
}
+ @Test
public void testRandomlyAddBigramWords() {
final int wordCount = 100;
final int bigramCount = 1000;
@@ -357,6 +375,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
}
}
+ @Test
public void testAddTrigramWords() {
final BinaryDictionary binaryDictionary = getEmptyBinaryDictionary(FormatSpec.VERSION403);
final int unigramProbability = 100;
@@ -383,6 +402,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
getTrigramProbability(binaryDictionary, "bcc", "abb", "aaa"));
}
+ @Test
public void testFlushDictionary() {
final File dictFile = createEmptyDictionaryAndGetFile(FormatSpec.VERSION403);
BinaryDictionary binaryDictionary = getBinaryDictionary(dictFile);
@@ -417,6 +437,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
binaryDictionary.close();
}
+ @Test
public void testFlushWithGCDictionary() {
final File dictFile = createEmptyDictionaryAndGetFile(FormatSpec.VERSION403);
BinaryDictionary binaryDictionary = getBinaryDictionary(dictFile);
@@ -447,6 +468,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
binaryDictionary.close();
}
+ @Test
public void testAddBigramWordsAndFlashWithGC() {
final int wordCount = 100;
final int bigramCount = 1000;
@@ -499,6 +521,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
}
}
+ @Test
public void testRandomOperationsAndFlashWithGC() {
final int maxUnigramCount = 5000;
final int maxBigramCount = 10000;
@@ -593,6 +616,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
}
}
+ @Test
public void testAddManyUnigramsAndFlushWithGC() {
final int flashWithGCIterationCount = 3;
final int codePointSetSize = 50;
@@ -628,6 +652,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
}
}
+ @Test
public void testUnigramAndBigramCount() {
final int maxUnigramCount = 5000;
final int maxBigramCount = 10000;
@@ -684,6 +709,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
}
}
+ @Test
public void testGetWordProperties() {
final long seed = System.currentTimeMillis();
final Random random = new Random(seed);
@@ -769,6 +795,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
}
}
+ @Test
public void testIterateAllWords() {
final long seed = System.currentTimeMillis();
final Random random = new Random(seed);
@@ -852,6 +879,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
assertTrue(bigramSet.isEmpty());
}
+ @Test
public void testPossiblyOffensiveAttributeMaintained() {
final BinaryDictionary binaryDictionary =
getEmptyBinaryDictionary(FormatSpec.VERSION403);
@@ -860,6 +888,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
assertEquals(true, wordProperty.mIsPossiblyOffensive);
}
+ @Test
public void testBeginningOfSentence() {
final BinaryDictionary binaryDictionary = getEmptyBinaryDictionary(FormatSpec.VERSION403);
final int dummyProbability = 0;
diff --git a/tests/src/com/android/inputmethod/latin/ContactsContentObserverTest.java b/tests/src/com/android/inputmethod/latin/ContactsContentObserverTest.java
index f90a18bf1..029e1b506 100644
--- a/tests/src/com/android/inputmethod/latin/ContactsContentObserverTest.java
+++ b/tests/src/com/android/inputmethod/latin/ContactsContentObserverTest.java
@@ -24,11 +24,14 @@ import static org.mockito.Mockito.when;
import android.content.Context;
import android.provider.ContactsContract.Contacts;
-import android.test.suitebuilder.annotation.SmallTest;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -38,6 +41,7 @@ import java.util.ArrayList;
* Tests for {@link ContactsContentObserver}.
*/
@SmallTest
+@RunWith(AndroidJUnit4.class)
public class ContactsContentObserverTest {
private static final int UPDATED_CONTACT_COUNT = 10;
private static final int STALE_CONTACT_COUNT = 8;
diff --git a/tests/src/com/android/inputmethod/latin/ContactsDictionaryUtilsTest.java b/tests/src/com/android/inputmethod/latin/ContactsDictionaryUtilsTest.java
index 9b49f1abb..a00c9dfdd 100644
--- a/tests/src/com/android/inputmethod/latin/ContactsDictionaryUtilsTest.java
+++ b/tests/src/com/android/inputmethod/latin/ContactsDictionaryUtilsTest.java
@@ -20,9 +20,11 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import android.test.suitebuilder.annotation.SmallTest;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import org.junit.Test;
+import org.junit.runner.RunWith;
import java.util.Locale;
@@ -30,6 +32,7 @@ import java.util.Locale;
* Tests for {@link ContactsDictionaryUtils}
*/
@SmallTest
+@RunWith(AndroidJUnit4.class)
public class ContactsDictionaryUtilsTest {
@Test
diff --git a/tests/src/com/android/inputmethod/latin/ContactsManagerTest.java b/tests/src/com/android/inputmethod/latin/ContactsManagerTest.java
index f987e0c05..d3d746df5 100644
--- a/tests/src/com/android/inputmethod/latin/ContactsManagerTest.java
+++ b/tests/src/com/android/inputmethod/latin/ContactsManagerTest.java
@@ -16,6 +16,10 @@
package com.android.inputmethod.latin;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;
@@ -23,17 +27,20 @@ import android.database.MatrixCursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
-import android.test.AndroidTestCase;
import android.test.RenamingDelegatingContext;
import android.test.mock.MockContentProvider;
import android.test.mock.MockContentResolver;
-import android.test.suitebuilder.annotation.SmallTest;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.ContactsDictionaryConstants;
import com.android.inputmethod.latin.ContactsManager;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.HashMap;
@@ -43,14 +50,16 @@ import java.util.concurrent.TimeUnit;
* Tests for {@link ContactsManager}
*/
@SmallTest
-public class ContactsManagerTest extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class ContactsManagerTest {
private ContactsManager mManager;
private FakeContactsContentProvider mFakeContactsContentProvider;
private MatrixCursor mMatrixCursor;
+ private final static float EPSILON = 0.00001f;
+
@Before
- @Override
public void setUp() throws Exception {
// Fake content provider
mFakeContactsContentProvider = new FakeContactsContentProvider();
@@ -59,7 +68,8 @@ public class ContactsManagerTest extends AndroidTestCase {
final MockContentResolver contentResolver = new MockContentResolver();
contentResolver.addProvider(ContactsContract.AUTHORITY, mFakeContactsContentProvider);
// Add the fake content resolver to a fake context.
- final ContextWithMockContentResolver context = new ContextWithMockContentResolver(mContext);
+ final ContextWithMockContentResolver context =
+ new ContextWithMockContentResolver(InstrumentationRegistry.getTargetContext());
context.setContentResolver(contentResolver);
mManager = new ContactsManager(context);
@@ -113,9 +123,10 @@ public class ContactsManagerTest extends AndroidTestCase {
cursor.moveToFirst();
ContactsManager.RankedContact contact = new ContactsManager.RankedContact(cursor);
contact.computeAffinity(1, month_ago);
- assertEquals(contact.getAffinity(), 1.0f);
+ assertEquals(contact.getAffinity(), 1.0f, EPSILON);
contact.computeAffinity(2, now);
- assertEquals(contact.getAffinity(), (2.0f/3.0f + (float)Math.pow(0.5, 3) + 1.0f) / 3);
+ assertEquals(contact.getAffinity(), (2.0f/3.0f + (float)Math.pow(0.5, 3) + 1.0f) / 3,
+ EPSILON);
}
@Test
diff --git a/tests/src/com/android/inputmethod/latin/DictionaryFacilitatorLruCacheTests.java b/tests/src/com/android/inputmethod/latin/DictionaryFacilitatorLruCacheTests.java
index 6b0bbc279..f8130f33c 100644
--- a/tests/src/com/android/inputmethod/latin/DictionaryFacilitatorLruCacheTests.java
+++ b/tests/src/com/android/inputmethod/latin/DictionaryFacilitatorLruCacheTests.java
@@ -16,16 +16,26 @@
package com.android.inputmethod.latin;
-import java.util.Locale;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.LargeTest;
+import androidx.test.runner.AndroidJUnit4;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.Locale;
@LargeTest
-public class DictionaryFacilitatorLruCacheTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class DictionaryFacilitatorLruCacheTests {
+
+ @Test
public void testGetFacilitator() {
final DictionaryFacilitatorLruCache cache =
- new DictionaryFacilitatorLruCache(getContext(), "");
+ new DictionaryFacilitatorLruCache(InstrumentationRegistry.getTargetContext(), "");
final DictionaryFacilitator dictionaryFacilitatorEnUs = cache.get(Locale.US);
assertNotNull(dictionaryFacilitatorEnUs);
diff --git a/tests/src/com/android/inputmethod/latin/NgramContextTests.java b/tests/src/com/android/inputmethod/latin/NgramContextTests.java
index 0a662db82..505818439 100644
--- a/tests/src/com/android/inputmethod/latin/NgramContextTests.java
+++ b/tests/src/com/android/inputmethod/latin/NgramContextTests.java
@@ -16,15 +16,26 @@
package com.android.inputmethod.latin;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.latin.NgramContext.WordInfo;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
import com.android.inputmethod.latin.utils.NgramContextUtils;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import org.junit.Test;
+import org.junit.runner.RunWith;
@SmallTest
-public class NgramContextTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class NgramContextTests {
+
+ @Test
public void testConstruct() {
assertEquals(new NgramContext(new WordInfo("a")), new NgramContext(new WordInfo("a")));
assertEquals(new NgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO),
@@ -35,6 +46,7 @@ public class NgramContextTests extends AndroidTestCase {
new NgramContext(WordInfo.EMPTY_WORD_INFO));
}
+ @Test
public void testIsBeginningOfSentenceContext() {
assertFalse(new NgramContext().isBeginningOfSentenceContext());
assertTrue(new NgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO)
@@ -52,6 +64,7 @@ public class NgramContextTests extends AndroidTestCase {
.isBeginningOfSentenceContext());
}
+ @Test
public void testGetNextNgramContext() {
final NgramContext ngramContext_a = new NgramContext(new WordInfo("a"));
final NgramContext ngramContext_b_a =
@@ -67,6 +80,7 @@ public class NgramContextTests extends AndroidTestCase {
assertEquals("c", ngramContext_c_bos.getNthPrevWord(1));
}
+ @Test
public void testExtractPrevWordsContextTest() {
final NgramContext ngramContext_bos =
new NgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO);
@@ -92,6 +106,7 @@ public class NgramContextTests extends AndroidTestCase {
assertEquals("a", ngramContext_a_empty.extractPrevWordsContext());
}
+ @Test
public void testExtractPrevWordsContextArray() {
final NgramContext ngramContext_bos =
new NgramContext(WordInfo.BEGINNING_OF_SENTENCE_WORD_INFO);
@@ -123,9 +138,10 @@ public class NgramContextTests extends AndroidTestCase {
assertEquals("a", ngramContext_a_empty.extractPrevWordsContextArray()[0]);
}
+ @Test
public void testGetNgramContextFromNthPreviousWord() {
SpacingAndPunctuations spacingAndPunctuations = new SpacingAndPunctuations(
- mContext.getResources());
+ InstrumentationRegistry.getTargetContext().getResources());
assertEquals("<S>", NgramContextUtils.getNgramContextFromNthPreviousWord("",
spacingAndPunctuations, 1).extractPrevWordsContext());
assertEquals("<S> b", NgramContextUtils.getNgramContextFromNthPreviousWord("a. b ",
diff --git a/tests/src/com/android/inputmethod/latin/PersonalDictionaryLookupTest.java b/tests/src/com/android/inputmethod/latin/PersonalDictionaryLookupTest.java
deleted file mode 100644
index c06adedfd..000000000
--- a/tests/src/com/android/inputmethod/latin/PersonalDictionaryLookupTest.java
+++ /dev/null
@@ -1,492 +0,0 @@
-/*
- * Copyright (C) 2015 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.inputmethod.latin;
-
-import static com.android.inputmethod.latin.PersonalDictionaryLookup.ANY_LOCALE;
-
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyNoMoreInteractions;
-
-import android.annotation.SuppressLint;
-import android.content.ContentResolver;
-import android.database.Cursor;
-import android.net.Uri;
-import android.provider.UserDictionary;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.util.Log;
-
-import com.android.inputmethod.latin.PersonalDictionaryLookup.PersonalDictionaryListener;
-import com.android.inputmethod.latin.utils.ExecutorUtils;
-
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
-
-/**
- * Unit tests for {@link PersonalDictionaryLookup}.
- *
- * Note, this test doesn't mock out the ContentResolver, in order to make sure
- * {@link PersonalDictionaryLookup} works in a real setting.
- */
-@SmallTest
-public class PersonalDictionaryLookupTest extends AndroidTestCase {
- private static final String TAG = PersonalDictionaryLookupTest.class.getSimpleName();
-
- private ContentResolver mContentResolver;
- private HashSet<Uri> mAddedBackup;
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mContentResolver = mContext.getContentResolver();
- mAddedBackup = new HashSet<Uri>();
- }
-
- @Override
- protected void tearDown() throws Exception {
- // Remove all entries added during this test.
- for (Uri row : mAddedBackup) {
- mContentResolver.delete(row, null, null);
- }
- mAddedBackup.clear();
-
- super.tearDown();
- }
-
- /**
- * Adds the given word to the personal dictionary.
- *
- * @param word the word to add
- * @param locale the locale of the word to add
- * @param frequency the frequency of the word to add
- * @return the Uri for the given word
- */
- @SuppressLint("NewApi")
- private Uri addWord(final String word, final Locale locale, int frequency, String shortcut) {
- // Add the given word for the given locale.
- UserDictionary.Words.addWord(mContext, word, frequency, shortcut, locale);
- // Obtain an Uri for the given word.
- Cursor cursor = mContentResolver.query(UserDictionary.Words.CONTENT_URI, null,
- UserDictionary.Words.WORD + "='" + word + "'", null, null);
- assertTrue(cursor.moveToFirst());
- Uri uri = Uri.withAppendedPath(UserDictionary.Words.CONTENT_URI,
- cursor.getString(cursor.getColumnIndex(UserDictionary.Words._ID)));
- // Add the row to the backup for later clearing.
- mAddedBackup.add(uri);
- return uri;
- }
-
- /**
- * Deletes the entry for the given word from UserDictionary.
- *
- * @param uri the Uri for the word as returned by addWord
- */
- private void deleteWord(Uri uri) {
- // Remove the word from the backup so that it's not cleared again later.
- mAddedBackup.remove(uri);
- // Remove the word from the personal dictionary.
- mContentResolver.delete(uri, null, null);
- }
-
- private PersonalDictionaryLookup setUpWord(final Locale locale) {
- // Insert "foo" in the personal dictionary for the given locale.
- addWord("foo", locale, 17, null);
-
- // Create the PersonalDictionaryLookup and wait until it's loaded.
- PersonalDictionaryLookup lookup =
- new PersonalDictionaryLookup(mContext, ExecutorUtils.SPELLING);
- lookup.open();
- return lookup;
- }
-
- private PersonalDictionaryLookup setUpShortcut(final Locale locale) {
- // Insert "shortcut" => "Expansion" in the personal dictionary for the given locale.
- addWord("Expansion", locale, 17, "shortcut");
-
- // Create the PersonalDictionaryLookup and wait until it's loaded.
- PersonalDictionaryLookup lookup =
- new PersonalDictionaryLookup(mContext, ExecutorUtils.SPELLING);
- lookup.open();
- return lookup;
- }
-
- private void verifyWordExists(final Set<String> set, final String word) {
- assertTrue(set.contains(word));
- }
-
- private void verifyWordDoesNotExist(final Set<String> set, final String word) {
- assertFalse(set.contains(word));
- }
-
- public void testShortcutKeyMatching() {
- Log.d(TAG, "testShortcutKeyMatching");
- PersonalDictionaryLookup lookup = setUpShortcut(Locale.US);
-
- assertEquals("Expansion", lookup.expandShortcut("shortcut", Locale.US));
- assertNull(lookup.expandShortcut("Shortcut", Locale.US));
- assertNull(lookup.expandShortcut("SHORTCUT", Locale.US));
- assertNull(lookup.expandShortcut("shortcu", Locale.US));
- assertNull(lookup.expandShortcut("shortcutt", Locale.US));
-
- lookup.close();
- }
-
- public void testShortcutMatchesInputCountry() {
- Log.d(TAG, "testShortcutMatchesInputCountry");
- PersonalDictionaryLookup lookup = setUpShortcut(Locale.US);
-
- verifyWordExists(lookup.getShortcutsForLocale(Locale.US), "shortcut");
- assertTrue(lookup.getShortcutsForLocale(Locale.UK).isEmpty());
- assertTrue(lookup.getShortcutsForLocale(Locale.ENGLISH).isEmpty());
- assertTrue(lookup.getShortcutsForLocale(Locale.FRENCH).isEmpty());
- assertTrue(lookup.getShortcutsForLocale(ANY_LOCALE).isEmpty());
-
- assertEquals("Expansion", lookup.expandShortcut("shortcut", Locale.US));
- assertNull(lookup.expandShortcut("shortcut", Locale.UK));
- assertNull(lookup.expandShortcut("shortcut", Locale.ENGLISH));
- assertNull(lookup.expandShortcut("shortcut", Locale.FRENCH));
- assertNull(lookup.expandShortcut("shortcut", ANY_LOCALE));
-
- lookup.close();
- }
-
- public void testShortcutMatchesInputLanguage() {
- Log.d(TAG, "testShortcutMatchesInputLanguage");
- PersonalDictionaryLookup lookup = setUpShortcut(Locale.ENGLISH);
-
- verifyWordExists(lookup.getShortcutsForLocale(Locale.US), "shortcut");
- verifyWordExists(lookup.getShortcutsForLocale(Locale.UK), "shortcut");
- verifyWordExists(lookup.getShortcutsForLocale(Locale.ENGLISH), "shortcut");
- assertTrue(lookup.getShortcutsForLocale(Locale.FRENCH).isEmpty());
- assertTrue(lookup.getShortcutsForLocale(ANY_LOCALE).isEmpty());
-
- assertEquals("Expansion", lookup.expandShortcut("shortcut", Locale.US));
- assertEquals("Expansion", lookup.expandShortcut("shortcut", Locale.UK));
- assertEquals("Expansion", lookup.expandShortcut("shortcut", Locale.ENGLISH));
- assertNull(lookup.expandShortcut("shortcut", Locale.FRENCH));
- assertNull(lookup.expandShortcut("shortcut", ANY_LOCALE));
-
- lookup.close();
- }
-
- public void testShortcutMatchesAnyLocale() {
- PersonalDictionaryLookup lookup = setUpShortcut(PersonalDictionaryLookup.ANY_LOCALE);
-
- verifyWordExists(lookup.getShortcutsForLocale(Locale.US), "shortcut");
- verifyWordExists(lookup.getShortcutsForLocale(Locale.UK), "shortcut");
- verifyWordExists(lookup.getShortcutsForLocale(Locale.ENGLISH), "shortcut");
- verifyWordExists(lookup.getShortcutsForLocale(Locale.FRENCH), "shortcut");
- verifyWordExists(lookup.getShortcutsForLocale(ANY_LOCALE), "shortcut");
-
- assertEquals("Expansion", lookup.expandShortcut("shortcut", Locale.US));
- assertEquals("Expansion", lookup.expandShortcut("shortcut", Locale.UK));
- assertEquals("Expansion", lookup.expandShortcut("shortcut", Locale.ENGLISH));
- assertEquals("Expansion", lookup.expandShortcut("shortcut", Locale.FRENCH));
- assertEquals("Expansion", lookup.expandShortcut("shortcut", ANY_LOCALE));
-
- lookup.close();
- }
-
- public void testExactLocaleMatch() {
- Log.d(TAG, "testExactLocaleMatch");
- PersonalDictionaryLookup lookup = setUpWord(Locale.US);
-
- verifyWordExists(lookup.getWordsForLocale(Locale.US), "foo");
- verifyWordDoesNotExist(lookup.getWordsForLocale(Locale.UK), "foo");
- verifyWordDoesNotExist(lookup.getWordsForLocale(Locale.ENGLISH), "foo");
- verifyWordDoesNotExist(lookup.getWordsForLocale(Locale.FRENCH), "foo");
- verifyWordDoesNotExist(lookup.getWordsForLocale(ANY_LOCALE), "foo");
-
- // Any capitalization variation should match.
- assertTrue(lookup.isValidWord("foo", Locale.US));
- assertTrue(lookup.isValidWord("Foo", Locale.US));
- assertTrue(lookup.isValidWord("FOO", Locale.US));
- // But similar looking words don't match.
- assertFalse(lookup.isValidWord("fo", Locale.US));
- assertFalse(lookup.isValidWord("fop", Locale.US));
- assertFalse(lookup.isValidWord("fooo", Locale.US));
- // Other locales, including more general locales won't match.
- assertFalse(lookup.isValidWord("foo", Locale.ENGLISH));
- assertFalse(lookup.isValidWord("foo", Locale.UK));
- assertFalse(lookup.isValidWord("foo", Locale.FRENCH));
- assertFalse(lookup.isValidWord("foo", ANY_LOCALE));
-
- lookup.close();
- }
-
- public void testSubLocaleMatch() {
- Log.d(TAG, "testSubLocaleMatch");
- PersonalDictionaryLookup lookup = setUpWord(Locale.ENGLISH);
-
- verifyWordExists(lookup.getWordsForLocale(Locale.US), "foo");
- verifyWordExists(lookup.getWordsForLocale(Locale.UK), "foo");
- verifyWordExists(lookup.getWordsForLocale(Locale.ENGLISH), "foo");
- verifyWordDoesNotExist(lookup.getWordsForLocale(Locale.FRENCH), "foo");
- verifyWordDoesNotExist(lookup.getWordsForLocale(ANY_LOCALE), "foo");
-
- // Any capitalization variation should match for both en and en_US.
- assertTrue(lookup.isValidWord("foo", Locale.ENGLISH));
- assertTrue(lookup.isValidWord("foo", Locale.US));
- assertTrue(lookup.isValidWord("Foo", Locale.US));
- assertTrue(lookup.isValidWord("FOO", Locale.US));
- // But similar looking words don't match.
- assertFalse(lookup.isValidWord("fo", Locale.US));
- assertFalse(lookup.isValidWord("fop", Locale.US));
- assertFalse(lookup.isValidWord("fooo", Locale.US));
-
- lookup.close();
- }
-
- public void testAllLocalesMatch() {
- Log.d(TAG, "testAllLocalesMatch");
- PersonalDictionaryLookup lookup = setUpWord(null);
-
- verifyWordExists(lookup.getWordsForLocale(Locale.US), "foo");
- verifyWordExists(lookup.getWordsForLocale(Locale.UK), "foo");
- verifyWordExists(lookup.getWordsForLocale(Locale.ENGLISH), "foo");
- verifyWordExists(lookup.getWordsForLocale(Locale.FRENCH), "foo");
- verifyWordExists(lookup.getWordsForLocale(ANY_LOCALE), "foo");
-
- // Any capitalization variation should match for fr, en and en_US.
- assertTrue(lookup.isValidWord("foo", ANY_LOCALE));
- assertTrue(lookup.isValidWord("foo", Locale.FRENCH));
- assertTrue(lookup.isValidWord("foo", Locale.ENGLISH));
- assertTrue(lookup.isValidWord("foo", Locale.US));
- assertTrue(lookup.isValidWord("Foo", Locale.US));
- assertTrue(lookup.isValidWord("FOO", Locale.US));
- // But similar looking words don't match.
- assertFalse(lookup.isValidWord("fo", Locale.US));
- assertFalse(lookup.isValidWord("fop", Locale.US));
- assertFalse(lookup.isValidWord("fooo", Locale.US));
-
- lookup.close();
- }
-
- public void testMultipleLocalesMatch() {
- Log.d(TAG, "testMultipleLocalesMatch");
-
- // Insert "Foo" as capitalized in the personal dictionary under the en_US and en_CA and fr
- // locales.
- addWord("Foo", Locale.US, 17, null);
- addWord("foO", Locale.CANADA, 17, null);
- addWord("fOo", Locale.FRENCH, 17, null);
-
- // Create the PersonalDictionaryLookup and wait until it's loaded.
- PersonalDictionaryLookup lookup = new PersonalDictionaryLookup(mContext,
- ExecutorUtils.SPELLING);
- lookup.open();
-
- // Both en_CA and en_US match.
- assertTrue(lookup.isValidWord("foo", Locale.CANADA));
- assertTrue(lookup.isValidWord("foo", Locale.US));
- assertTrue(lookup.isValidWord("foo", Locale.FRENCH));
- // Other locales, including more general locales won't match.
- assertFalse(lookup.isValidWord("foo", Locale.ENGLISH));
- assertFalse(lookup.isValidWord("foo", Locale.UK));
- assertFalse(lookup.isValidWord("foo", ANY_LOCALE));
-
- lookup.close();
- }
-
-
- public void testCaseMatchingForWordsAndShortcuts() {
- Log.d(TAG, "testCaseMatchingForWordsAndShortcuts");
- addWord("Foo", Locale.US, 17, "f");
- addWord("bokabu", Locale.US, 17, "Bu");
-
- // Create the PersonalDictionaryLookup and wait until it's loaded.
- PersonalDictionaryLookup lookup = new PersonalDictionaryLookup(mContext,
- ExecutorUtils.SPELLING);
- lookup.open();
-
- // Valid, inspite of capitalization in US but not in other
- // locales.
- assertTrue(lookup.isValidWord("Foo", Locale.US));
- assertTrue(lookup.isValidWord("foo", Locale.US));
- assertFalse(lookup.isValidWord("Foo", Locale.UK));
- assertFalse(lookup.isValidWord("foo", Locale.UK));
-
- // Valid in all forms in US.
- assertTrue(lookup.isValidWord("bokabu", Locale.US));
- assertTrue(lookup.isValidWord("BOKABU", Locale.US));
- assertTrue(lookup.isValidWord("BokaBU", Locale.US));
-
- // Correct capitalization; sensitive to shortcut casing & locale.
- assertEquals("Foo", lookup.expandShortcut("f", Locale.US));
- assertNull(lookup.expandShortcut("f", Locale.UK));
-
- // Correct capitalization; sensitive to shortcut casing & locale.
- assertEquals("bokabu", lookup.expandShortcut("Bu", Locale.US));
- assertNull(lookup.expandShortcut("Bu", Locale.UK));
- assertNull(lookup.expandShortcut("bu", Locale.US));
-
- // Verify that raw strings are retained for #getWordsForLocale.
- verifyWordExists(lookup.getWordsForLocale(Locale.US), "Foo");
- verifyWordDoesNotExist(lookup.getWordsForLocale(Locale.US), "foo");
- }
-
- public void testManageListeners() {
- Log.d(TAG, "testManageListeners");
-
- PersonalDictionaryLookup lookup =
- new PersonalDictionaryLookup(mContext, ExecutorUtils.SPELLING);
-
- PersonalDictionaryListener listener = mock(PersonalDictionaryListener.class);
- // Add the same listener a bunch of times. It doesn't make a difference.
- lookup.addListener(listener);
- lookup.addListener(listener);
- lookup.addListener(listener);
- lookup.notifyListeners();
-
- verify(listener, times(1)).onUpdate();
-
- // Remove the same listener a bunch of times. It doesn't make a difference.
- lookup.removeListener(listener);
- lookup.removeListener(listener);
- lookup.removeListener(listener);
- lookup.notifyListeners();
-
- verifyNoMoreInteractions(listener);
- }
-
- public void testReload() {
- Log.d(TAG, "testReload");
-
- // Insert "foo".
- Uri uri = addWord("foo", Locale.US, 17, null);
-
- // Create the PersonalDictionaryLookup and wait until it's loaded.
- PersonalDictionaryLookup lookup =
- new PersonalDictionaryLookup(mContext, ExecutorUtils.SPELLING);
- lookup.open();
-
- // "foo" should match.
- assertTrue(lookup.isValidWord("foo", Locale.US));
-
- // "bar" shouldn't match.
- assertFalse(lookup.isValidWord("bar", Locale.US));
-
- // Now delete "foo" and add "bar".
- deleteWord(uri);
- addWord("bar", Locale.US, 18, null);
-
- // Wait a little bit before expecting a change. The time we wait should be greater than
- // PersonalDictionaryLookup.RELOAD_DELAY_MS.
- try {
- Thread.sleep(PersonalDictionaryLookup.RELOAD_DELAY_MS + 1000);
- } catch (InterruptedException e) {
- }
-
- // Perform lookups again. Reload should have occured.
- //
- // "foo" should not match.
- assertFalse(lookup.isValidWord("foo", Locale.US));
-
- // "bar" should match.
- assertTrue(lookup.isValidWord("bar", Locale.US));
-
- lookup.close();
- }
-
- public void testDictionaryStats() {
- Log.d(TAG, "testDictionaryStats");
-
- // Insert "foo" and "bar". Only "foo" has a shortcut.
- Uri uri = addWord("foo", Locale.GERMANY, 17, "f");
- addWord("bar", Locale.GERMANY, 17, null);
-
- // Create the PersonalDictionaryLookup and wait until it's loaded.
- PersonalDictionaryLookup lookup =
- new PersonalDictionaryLookup(mContext, ExecutorUtils.SPELLING);
- lookup.open();
-
- // "foo" should match.
- assertTrue(lookup.isValidWord("foo", Locale.GERMANY));
-
- // "bar" should match.
- assertTrue(lookup.isValidWord("bar", Locale.GERMANY));
-
- // "foo" should have a shortcut.
- assertEquals("foo", lookup.expandShortcut("f", Locale.GERMANY));
-
- // Now delete "foo".
- deleteWord(uri);
-
- // Wait a little bit before expecting a change. The time we wait should be greater than
- // PersonalDictionaryLookup.RELOAD_DELAY_MS.
- try {
- Thread.sleep(PersonalDictionaryLookup.RELOAD_DELAY_MS + 1000);
- } catch (InterruptedException e) {
- }
-
- // Perform lookups again. Reload should have occured.
- //
- // "foo" should not match.
- assertFalse(lookup.isValidWord("foo", Locale.GERMANY));
-
- // "foo" should not have a shortcut.
- assertNull(lookup.expandShortcut("f", Locale.GERMANY));
-
- // "bar" should still match.
- assertTrue(lookup.isValidWord("bar", Locale.GERMANY));
-
- lookup.close();
- }
-
- public void testClose() {
- Log.d(TAG, "testClose");
-
- // Insert "foo".
- Uri uri = addWord("foo", Locale.US, 17, null);
-
- // Create the PersonalDictionaryLookup and wait until it's loaded.
- PersonalDictionaryLookup lookup =
- new PersonalDictionaryLookup(mContext, ExecutorUtils.SPELLING);
- lookup.open();
-
- // "foo" should match.
- assertTrue(lookup.isValidWord("foo", Locale.US));
-
- // "bar" shouldn't match.
- assertFalse(lookup.isValidWord("bar", Locale.US));
-
- // Now close (prevents further reloads).
- lookup.close();
-
- // Now delete "foo" and add "bar".
- deleteWord(uri);
- addWord("bar", Locale.US, 18, null);
-
- // Wait a little bit before expecting a change. The time we wait should be greater than
- // PersonalDictionaryLookup.RELOAD_DELAY_MS.
- try {
- Thread.sleep(PersonalDictionaryLookup.RELOAD_DELAY_MS + 1000);
- } catch (InterruptedException e) {
- }
-
- // Perform lookups again. Reload should not have occurred.
- //
- // "foo" should stil match.
- assertTrue(lookup.isValidWord("foo", Locale.US));
-
- // "bar" should still not match.
- assertFalse(lookup.isValidWord("bar", Locale.US));
- }
-}
diff --git a/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java b/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java
index 128f9f7db..ac38468f9 100644
--- a/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java
+++ b/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java
@@ -16,12 +16,13 @@
package com.android.inputmethod.latin;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import android.content.res.Resources;
import android.inputmethodservice.InputMethodService;
import android.os.Parcel;
-import android.test.AndroidTestCase;
-import android.test.MoreAsserts;
-import android.test.suitebuilder.annotation.SmallTest;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.SuggestionSpan;
@@ -30,6 +31,10 @@ import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputConnection;
import android.view.inputmethod.InputConnectionWrapper;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.latin.common.Constants;
import com.android.inputmethod.latin.common.StringUtils;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
@@ -38,25 +43,29 @@ import com.android.inputmethod.latin.utils.RunInLocale;
import com.android.inputmethod.latin.utils.ScriptUtils;
import com.android.inputmethod.latin.utils.TextRange;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.Locale;
@SmallTest
-public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class RichInputConnectionAndTextRangeTests {
// The following is meant to be a reasonable default for
// the "word_separators" resource.
private SpacingAndPunctuations mSpacingAndPunctuations;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
final RunInLocale<SpacingAndPunctuations> job = new RunInLocale<SpacingAndPunctuations>() {
@Override
protected SpacingAndPunctuations job(final Resources res) {
return new SpacingAndPunctuations(res);
}
};
- final Resources res = getContext().getResources();
+ final Resources res = InstrumentationRegistry.getTargetContext().getResources();
mSpacingAndPunctuations = job.runInLocale(res, Locale.ENGLISH);
}
@@ -156,6 +165,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
/**
* Test for getting previous word (for bigram suggestions)
*/
+ @Test
public void testGetPreviousWord() {
// If one of the following cases breaks, the bigram suggestions won't work.
assertEquals(NgramContextUtils.getNgramContextFromNthPreviousWord(
@@ -218,6 +228,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
"abc 'def", mSpacingAndPunctuations, 2), NgramContext.EMPTY_PREV_WORDS_INFO);
}
+ @Test
public void testGetWordRangeAtCursor() {
/**
* Test logic in getting the word range at the cursor.
@@ -282,6 +293,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
/**
* Test logic in getting the word range at the cursor.
*/
+ @Test
public void testGetSuggestionSpansAtWord() {
helpTestGetSuggestionSpansAtWord(10);
helpTestGetSuggestionSpansAtWord(12);
@@ -309,7 +321,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
r = ic.getWordRangeAtCursor(SPACE, ScriptUtils.SCRIPT_LATIN);
suggestions = r.getSuggestionSpansAtWord();
assertEquals(suggestions.length, 1);
- MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
+ assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
// Test the case with 2 suggestion spans in the same place.
text = new SpannableString("This is a string for test");
@@ -321,8 +333,8 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
r = ic.getWordRangeAtCursor(SPACE, ScriptUtils.SCRIPT_LATIN);
suggestions = r.getSuggestionSpansAtWord();
assertEquals(suggestions.length, 2);
- MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
- MoreAsserts.assertEquals(suggestions[1].getSuggestions(), SUGGESTIONS2);
+ assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
+ assertEquals(suggestions[1].getSuggestions(), SUGGESTIONS2);
// Test a case with overlapping spans, 2nd extending past the start of the word
text = new SpannableString("This is a string for test");
@@ -334,7 +346,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
r = ic.getWordRangeAtCursor(SPACE, ScriptUtils.SCRIPT_LATIN);
suggestions = r.getSuggestionSpansAtWord();
assertEquals(suggestions.length, 1);
- MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
+ assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
// Test a case with overlapping spans, 2nd extending past the end of the word
text = new SpannableString("This is a string for test");
@@ -346,7 +358,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
r = ic.getWordRangeAtCursor(SPACE, ScriptUtils.SCRIPT_LATIN);
suggestions = r.getSuggestionSpansAtWord();
assertEquals(suggestions.length, 1);
- MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
+ assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
// Test a case with overlapping spans, 2nd extending past both ends of the word
text = new SpannableString("This is a string for test");
@@ -358,7 +370,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
r = ic.getWordRangeAtCursor(SPACE, ScriptUtils.SCRIPT_LATIN);
suggestions = r.getSuggestionSpansAtWord();
assertEquals(suggestions.length, 1);
- MoreAsserts.assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
+ assertEquals(suggestions[0].getSuggestions(), SUGGESTIONS1);
// Test a case with overlapping spans, none right on the word
text = new SpannableString("This is a string for test");
@@ -372,6 +384,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase {
assertEquals(suggestions.length, 0);
}
+ @Test
public void testCursorTouchingWord() {
final MockInputMethodService ims = new MockInputMethodService();
final RichInputConnection ic = new RichInputConnection(ims);
diff --git a/tests/src/com/android/inputmethod/latin/RichInputMethodSubtypeTests.java b/tests/src/com/android/inputmethod/latin/RichInputMethodSubtypeTests.java
index af94be664..578e6bea0 100644
--- a/tests/src/com/android/inputmethod/latin/RichInputMethodSubtypeTests.java
+++ b/tests/src/com/android/inputmethod/latin/RichInputMethodSubtypeTests.java
@@ -16,13 +16,20 @@
package com.android.inputmethod.latin;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import android.content.Context;
import android.content.res.Resources;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.RichInputMethodSubtype;
@@ -30,11 +37,17 @@ import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.RunInLocale;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.ArrayList;
import java.util.Locale;
@SmallTest
-public class RichInputMethodSubtypeTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class RichInputMethodSubtypeTests {
// All input method subtypes of LatinIME.
private final ArrayList<RichInputMethodSubtype> mSubtypesList = new ArrayList<>();
@@ -67,10 +80,9 @@ public class RichInputMethodSubtypeTests extends AndroidTestCase {
RichInputMethodSubtype HI_LATN_DVORAK;
RichInputMethodSubtype SR_LATN_QWERTY;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- final Context context = getContext();
+ @Before
+ public void setUp() throws Exception {
+ final Context context = InstrumentationRegistry.getTargetContext();
mRes = context.getResources();
RichInputMethodManager.init(context);
mRichImm = RichInputMethodManager.getInstance();
@@ -152,13 +164,13 @@ public class RichInputMethodSubtypeTests extends AndroidTestCase {
}
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
// Restore additional subtypes.
mRichImm.setAdditionalInputMethodSubtypes(mSavedAddtionalSubtypes);
- super.tearDown();
}
+ @Test
public void testAllFullDisplayNameForSpacebar() {
for (final RichInputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils
@@ -174,7 +186,8 @@ public class RichInputMethodSubtypeTests extends AndroidTestCase {
}
}
- public void testAllMiddleDisplayNameForSpacebar() {
+ @Test
+ public void testAllMiddleDisplayNameForSpacebar() {
for (final RichInputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils
.getSubtypeDisplayNameInSystemLocale(subtype.getRawSubtype());
@@ -293,22 +306,27 @@ public class RichInputMethodSubtypeTests extends AndroidTestCase {
}
};
+ @Test
public void testPredefinedSubtypesForSpacebarInEnglish() {
testsPredefinedSubtypesForSpacebar.runInLocale(mRes, Locale.ENGLISH);
}
+ @Test
public void testAdditionalSubtypeForSpacebarInEnglish() {
testsAdditionalSubtypesForSpacebar.runInLocale(mRes, Locale.ENGLISH);
}
+ @Test
public void testPredefinedSubtypesForSpacebarInFrench() {
testsPredefinedSubtypesForSpacebar.runInLocale(mRes, Locale.FRENCH);
}
+ @Test
public void testAdditionalSubtypeForSpacebarInFrench() {
testsAdditionalSubtypesForSpacebar.runInLocale(mRes, Locale.FRENCH);
}
+ @Test
public void testRichInputMethodSubtypeForNullInputMethodSubtype() {
RichInputMethodSubtype subtype = RichInputMethodSubtype.getRichInputMethodSubtype(null);
assertNotNull(subtype);
diff --git a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
index d465ce674..92bff0e2e 100644
--- a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
+++ b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
@@ -16,16 +16,24 @@
package com.android.inputmethod.latin;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.ArrayList;
import java.util.Locale;
@SmallTest
-public class SuggestedWordsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class SuggestedWordsTests {
/**
* Helper method to create a dummy {@link SuggestedWordInfo} with specifying
@@ -80,30 +88,35 @@ public class SuggestedWordsTests extends AndroidTestCase {
return returnedWordInfo;
}
+ @Test
public void testRemoveDupesNoDupes() {
final ArrayList<SuggestedWordInfo> infos = createCorrectionWordInfos("a", "c");
assertEquals(-1, SuggestedWordInfo.removeDups("b", infos));
assertEquals(2, infos.size());
}
+ @Test
public void testRemoveDupesTypedWordNotDupe() {
final ArrayList<SuggestedWordInfo> infos = createCorrectionWordInfos("a", "a", "c");
assertEquals(-1, SuggestedWordInfo.removeDups("b", infos));
assertEquals(2, infos.size());
}
+ @Test
public void testRemoveDupesTypedWordOnlyDupe() {
final ArrayList<SuggestedWordInfo> infos = createCorrectionWordInfos("a", "b", "c");
assertEquals(1, SuggestedWordInfo.removeDups("b", infos));
assertEquals(2, infos.size());
}
+ @Test
public void testRemoveDupesTypedWordNotOnlyDupe() {
final ArrayList<SuggestedWordInfo> infos = createCorrectionWordInfos("a", "b", "b", "c");
assertEquals(1, SuggestedWordInfo.removeDups("b", infos));
assertEquals(2, infos.size());
}
+ @Test
public void testGetTransformedSuggestedWordInfo() {
SuggestedWordInfo result = transformWordInfo("word", 0);
assertEquals(result.mWord, "word");
@@ -119,6 +132,7 @@ public class SuggestedWordsTests extends AndroidTestCase {
assertEquals(result.mWord, "didn't''");
}
+ @Test
public void testGetTypedWordInfoOrNull() {
final String TYPED_WORD = "typed";
final SuggestedWordInfo TYPED_WORD_INFO = createTypedWordInfo(TYPED_WORD);
diff --git a/tests/src/com/android/inputmethod/latin/WordComposerTests.java b/tests/src/com/android/inputmethod/latin/WordComposerTests.java
index 8ae475f7e..4ac094b25 100644
--- a/tests/src/com/android/inputmethod/latin/WordComposerTests.java
+++ b/tests/src/com/android/inputmethod/latin/WordComposerTests.java
@@ -16,18 +16,28 @@
package com.android.inputmethod.latin;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.common.Constants;
import com.android.inputmethod.latin.common.CoordinateUtils;
import com.android.inputmethod.latin.common.StringUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
/**
* Unit tests for WordComposer.
*/
@SmallTest
-public class WordComposerTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class WordComposerTests {
+
+ @Test
public void testMoveCursor() {
final WordComposer wc = new WordComposer();
// BMP is the Basic Multilingual Plane, as defined by Unicode. This includes
diff --git a/tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java b/tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java
index 832817967..86f453b08 100644
--- a/tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java
+++ b/tests/src/com/android/inputmethod/latin/accounts/AccountsChangedReceiverTests.java
@@ -16,40 +16,55 @@
package com.android.inputmethod.latin.accounts;
+import static org.junit.Assert.assertEquals;
+
import android.accounts.AccountManager;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
-import android.test.AndroidTestCase;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.settings.LocalSettingsConstants;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
/**
* Tests for {@link AccountsChangedReceiver}.
*/
-public class AccountsChangedReceiverTests extends AndroidTestCase {
+@SmallTest
+@RunWith(AndroidJUnit4.class)
+public class AccountsChangedReceiverTests {
private static final String ACCOUNT_1 = "account1@example.com";
private static final String ACCOUNT_2 = "account2@example.com";
private SharedPreferences mPrefs;
private String mLastKnownAccount = null;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ private Context getContext() {
+ return InstrumentationRegistry.getTargetContext();
+ }
+
+ @Before
+ public void setUp() throws Exception {
mPrefs = PreferenceManager.getDefaultSharedPreferences(getContext());
// Keep track of the current account so that we restore it when the test finishes.
mLastKnownAccount = mPrefs.getString(LocalSettingsConstants.PREF_ACCOUNT_NAME, null);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
// Restore the account that was present before running the test.
updateAccountName(mLastKnownAccount);
}
+ @Test
public void testUnknownIntent() {
updateAccountName(ACCOUNT_1);
AccountsChangedReceiver reciever = new AccountsChangedReceiver();
@@ -58,6 +73,7 @@ public class AccountsChangedReceiverTests extends AndroidTestCase {
assertAccountName(ACCOUNT_1);
}
+ @Test
public void testAccountRemoved() {
updateAccountName(ACCOUNT_1);
AccountsChangedReceiver reciever = new AccountsChangedReceiver() {
@@ -71,6 +87,7 @@ public class AccountsChangedReceiverTests extends AndroidTestCase {
assertAccountName(null);
}
+ @Test
public void testAccountRemoved_noAccounts() {
updateAccountName(ACCOUNT_2);
AccountsChangedReceiver reciever = new AccountsChangedReceiver() {
@@ -84,6 +101,7 @@ public class AccountsChangedReceiverTests extends AndroidTestCase {
assertAccountName(null);
}
+ @Test
public void testAccountNotRemoved() {
updateAccountName(ACCOUNT_2);
AccountsChangedReceiver reciever = new AccountsChangedReceiver() {
diff --git a/tests/src/com/android/inputmethod/latin/common/InputPointersTests.java b/tests/src/com/android/inputmethod/latin/common/InputPointersTests.java
index 6b3490de8..29abec365 100644
--- a/tests/src/com/android/inputmethod/latin/common/InputPointersTests.java
+++ b/tests/src/com/android/inputmethod/latin/common/InputPointersTests.java
@@ -16,15 +16,27 @@
package com.android.inputmethod.latin.common;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
import java.util.Arrays;
@SmallTest
-public class InputPointersTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class InputPointersTests {
private static final int DEFAULT_CAPACITY = 48;
+ @Test
public void testNewInstance() {
final InputPointers src = new InputPointers(DEFAULT_CAPACITY);
assertEquals("new instance size", 0, src.getPointerSize());
@@ -34,6 +46,7 @@ public class InputPointersTests extends AndroidTestCase {
assertNotNull("new instance times", src.getTimes());
}
+ @Test
public void testReset() {
final InputPointers src = new InputPointers(DEFAULT_CAPACITY);
final int[] xCoordinates = src.getXCoordinates();
@@ -49,6 +62,7 @@ public class InputPointersTests extends AndroidTestCase {
assertNotSame("times after reset", times, src.getTimes());
}
+ @Test
public void testAdd() {
final InputPointers src = new InputPointers(DEFAULT_CAPACITY);
final int limit = src.getXCoordinates().length * 2 + 10;
@@ -72,6 +86,7 @@ public class InputPointersTests extends AndroidTestCase {
}
}
+ @Test
public void testAddAt() {
final InputPointers src = new InputPointers(DEFAULT_CAPACITY);
final int limit = 1000, step = 100;
@@ -95,6 +110,7 @@ public class InputPointersTests extends AndroidTestCase {
}
}
+ @Test
public void testSet() {
final InputPointers src = new InputPointers(DEFAULT_CAPACITY);
final int limit = src.getXCoordinates().length * 2 + 10;
@@ -114,6 +130,7 @@ public class InputPointersTests extends AndroidTestCase {
assertSame("times after set", dst.getTimes(), src.getTimes());
}
+ @Test
public void testCopy() {
final InputPointers src = new InputPointers(DEFAULT_CAPACITY);
final int limit = 100;
@@ -142,6 +159,7 @@ public class InputPointersTests extends AndroidTestCase {
dst.getTimes(), 0, src.getTimes(), 0, size);
}
+ @Test
public void testAppend() {
final int dstLength = 50;
final InputPointers dst = new InputPointers(DEFAULT_CAPACITY);
@@ -211,6 +229,7 @@ public class InputPointersTests extends AndroidTestCase {
srcTimes.getPrimitiveArray(), startPos, dst.getTimes(), dstLength, srcLength);
}
+ @Test
public void testAppendResizableIntArray() {
final int dstLength = 50;
final InputPointers dst = new InputPointers(DEFAULT_CAPACITY);
@@ -296,6 +315,7 @@ public class InputPointersTests extends AndroidTestCase {
}
}
+ @Test
public void testShift() {
final InputPointers src = new InputPointers(DEFAULT_CAPACITY);
final int limit = 100;
diff --git a/tests/src/com/android/inputmethod/latin/common/ResizableIntArrayTests.java b/tests/src/com/android/inputmethod/latin/common/ResizableIntArrayTests.java
index bd1629faf..5151b6b2b 100644
--- a/tests/src/com/android/inputmethod/latin/common/ResizableIntArrayTests.java
+++ b/tests/src/com/android/inputmethod/latin/common/ResizableIntArrayTests.java
@@ -16,15 +16,27 @@
package com.android.inputmethod.latin.common;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
import java.util.Arrays;
@SmallTest
-public class ResizableIntArrayTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class ResizableIntArrayTests {
private static final int DEFAULT_CAPACITY = 48;
+ @Test
public void testNewInstance() {
final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
final int[] array = src.getPrimitiveArray();
@@ -33,6 +45,7 @@ public class ResizableIntArrayTests extends AndroidTestCase {
assertEquals("new instance array length", DEFAULT_CAPACITY, array.length);
}
+ @Test
public void testAdd() {
final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
final int[] array = src.getPrimitiveArray();
@@ -62,6 +75,7 @@ public class ResizableIntArrayTests extends AndroidTestCase {
}
}
+ @Test
public void testAddAt() {
final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
final int limit = DEFAULT_CAPACITY * 10, step = DEFAULT_CAPACITY * 2;
@@ -76,6 +90,7 @@ public class ResizableIntArrayTests extends AndroidTestCase {
}
}
+ @Test
public void testGet() {
final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
try {
@@ -105,6 +120,7 @@ public class ResizableIntArrayTests extends AndroidTestCase {
}
}
+ @Test
public void testReset() {
final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
final int[] array = src.getPrimitiveArray();
@@ -136,6 +152,7 @@ public class ResizableIntArrayTests extends AndroidTestCase {
}
}
+ @Test
public void testSetLength() {
final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
final int[] array = src.getPrimitiveArray();
@@ -172,6 +189,7 @@ public class ResizableIntArrayTests extends AndroidTestCase {
}
}
+ @Test
public void testSet() {
final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
final int limit = DEFAULT_CAPACITY * 2 + 10;
@@ -186,6 +204,7 @@ public class ResizableIntArrayTests extends AndroidTestCase {
assertSame("array after set", dst.getPrimitiveArray(), src.getPrimitiveArray());
}
+ @Test
public void testCopy() {
final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
for (int i = 0; i < DEFAULT_CAPACITY; i++) {
@@ -214,6 +233,7 @@ public class ResizableIntArrayTests extends AndroidTestCase {
dst.getPrimitiveArray(), 0, src.getPrimitiveArray(), 0, dst.getLength());
}
+ @Test
public void testAppend() {
final int srcLength = DEFAULT_CAPACITY;
final ResizableIntArray src = new ResizableIntArray(srcLength);
@@ -264,6 +284,7 @@ public class ResizableIntArrayTests extends AndroidTestCase {
srcLength);
}
+ @Test
public void testFill() {
final int srcLength = DEFAULT_CAPACITY;
final ResizableIntArray src = new ResizableIntArray(srcLength);
@@ -359,6 +380,7 @@ public class ResizableIntArrayTests extends AndroidTestCase {
}
}
+ @Test
public void testShift() {
final ResizableIntArray src = new ResizableIntArray(DEFAULT_CAPACITY);
final int limit = DEFAULT_CAPACITY * 10;
diff --git a/tests/src/com/android/inputmethod/latin/common/StringUtilsTests.java b/tests/src/com/android/inputmethod/latin/common/StringUtilsTests.java
index ec9d4be92..36a4b912d 100644
--- a/tests/src/com/android/inputmethod/latin/common/StringUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/common/StringUtilsTests.java
@@ -16,13 +16,21 @@
package com.android.inputmethod.latin.common;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
import java.util.Locale;
@SmallTest
-public class StringUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class StringUtilsTests {
private static final Locale US = Locale.US;
private static final Locale GERMAN = Locale.GERMAN;
private static final Locale TURKEY = new Locale("tr", "TR");
@@ -34,6 +42,7 @@ public class StringUtilsTests extends AndroidTestCase {
StringUtils.toTitleCaseOfKeyLabel(lowerCase, locale));
}
+ @Test
public void test_toTitleCaseOfKeyLabel() {
assert_toTitleCaseOfKeyLabel(US, null, null);
assert_toTitleCaseOfKeyLabel(US, "", "");
@@ -116,6 +125,7 @@ public class StringUtilsTests extends AndroidTestCase {
StringUtils.toTitleCaseOfKeyCode(lowerCase, locale));
}
+ @Test
public void test_toTitleCaseOfKeyCode() {
assert_toTitleCaseOfKeyCode(US, Constants.CODE_ENTER, Constants.CODE_ENTER);
assert_toTitleCaseOfKeyCode(US, Constants.CODE_SPACE, Constants.CODE_SPACE);
@@ -148,6 +158,7 @@ public class StringUtilsTests extends AndroidTestCase {
StringUtils.capitalizeFirstCodePoint(text, locale));
}
+ @Test
public void test_capitalizeFirstCodePoint() {
assert_capitalizeFirstCodePoint(US, "", "");
assert_capitalizeFirstCodePoint(US, "a", "A");
@@ -167,6 +178,7 @@ public class StringUtilsTests extends AndroidTestCase {
StringUtils.capitalizeFirstAndDowncaseRest(text, locale));
}
+ @Test
public void test_capitalizeFirstAndDowncaseRest() {
assert_capitalizeFirstAndDowncaseRest(US, "", "");
assert_capitalizeFirstAndDowncaseRest(US, "a", "A");
@@ -185,6 +197,7 @@ public class StringUtilsTests extends AndroidTestCase {
assert_capitalizeFirstAndDowncaseRest(GREECE, "ΆΝΕΣΗ", "Άνεση");
}
+ @Test
public void testContainsInArray() {
assertFalse("empty array", StringUtils.containsInArray("key", new String[0]));
assertFalse("not in 1 element", StringUtils.containsInArray("key", new String[] {
@@ -202,6 +215,7 @@ public class StringUtilsTests extends AndroidTestCase {
}));
}
+ @Test
public void testContainsInCommaSplittableText() {
assertFalse("null", StringUtils.containsInCommaSplittableText("key", null));
assertFalse("empty", StringUtils.containsInCommaSplittableText("key", ""));
@@ -214,6 +228,7 @@ public class StringUtilsTests extends AndroidTestCase {
assertTrue("in 2 elements", StringUtils.containsInCommaSplittableText("key", "key1,key"));
}
+ @Test
public void testRemoveFromCommaSplittableTextIfExists() {
assertEquals("null", "", StringUtils.removeFromCommaSplittableTextIfExists("key", null));
assertEquals("empty", "", StringUtils.removeFromCommaSplittableTextIfExists("key", ""));
@@ -239,7 +254,7 @@ public class StringUtilsTests extends AndroidTestCase {
"key", "key1,key,key3,key,key5"));
}
-
+ @Test
public void testCapitalizeFirstCodePoint() {
assertEquals("SSaa",
StringUtils.capitalizeFirstCodePoint("ßaa", Locale.GERMAN));
@@ -259,6 +274,7 @@ public class StringUtilsTests extends AndroidTestCase {
StringUtils.capitalizeFirstCodePoint("A", Locale.ENGLISH));
}
+ @Test
public void testCapitalizeFirstAndDowncaseRest() {
assertEquals("SSaa",
StringUtils.capitalizeFirstAndDowncaseRest("ßaa", Locale.GERMAN));
@@ -278,6 +294,7 @@ public class StringUtilsTests extends AndroidTestCase {
StringUtils.capitalizeFirstAndDowncaseRest("A", Locale.ENGLISH));
}
+ @Test
public void testGetCapitalizationType() {
assertEquals(StringUtils.CAPITALIZE_NONE,
StringUtils.getCapitalizationType("capitalize"));
@@ -301,6 +318,7 @@ public class StringUtilsTests extends AndroidTestCase {
StringUtils.getCapitalizationType(""));
}
+ @Test
public void testIsIdenticalAfterUpcaseIsIdenticalAfterDowncase() {
assertFalse(StringUtils.isIdenticalAfterUpcase("capitalize"));
assertTrue(StringUtils.isIdenticalAfterDowncase("capitalize"));
@@ -337,6 +355,7 @@ public class StringUtilsTests extends AndroidTestCase {
StringUtils.toSortedCodePointArray(" \n.!?*()&");
private static final int[] WORD_SEPARATORS = StringUtils.toSortedCodePointArray(" \n.!?*,();&");
+ @Test
public void testCapitalizeEachWord() {
checkCapitalize("", "", SPACE, Locale.ENGLISH);
checkCapitalize("test", "Test", SPACE, Locale.ENGLISH);
@@ -367,6 +386,7 @@ public class StringUtilsTests extends AndroidTestCase {
WORD_SEPARATORS, Locale.ENGLISH);
}
+ @Test
public void testLooksLikeURL() {
assertTrue(StringUtils.lastPartLooksLikeURL("http://www.google."));
assertFalse(StringUtils.lastPartLooksLikeURL("word wo"));
@@ -389,6 +409,7 @@ public class StringUtilsTests extends AndroidTestCase {
assertTrue(StringUtils.lastPartLooksLikeURL(".abc/def"));
}
+ @Test
public void testHexStringUtils() {
final byte[] bytes = new byte[] { (byte)0x01, (byte)0x11, (byte)0x22, (byte)0x33,
(byte)0x55, (byte)0x88, (byte)0xEE };
@@ -401,6 +422,7 @@ public class StringUtilsTests extends AndroidTestCase {
assertTrue(bytesStr.equals(bytesStr2));
}
+ @Test
public void testToCodePointArray() {
final String STR_WITH_SUPPLEMENTARY_CHAR = "abcde\uD861\uDED7fgh\u0000\u2002\u2003\u3000xx";
final int[] EXPECTED_RESULT = new int[] { 'a', 'b', 'c', 'd', 'e', 0x286D7, 'f', 'g', 'h',
@@ -414,6 +436,7 @@ public class StringUtilsTests extends AndroidTestCase {
}
}
+ @Test
public void testCopyCodePointsAndReturnCodePointCount() {
final String STR_WITH_SUPPLEMENTARY_CHAR = "AbcDE\uD861\uDED7fGh\u0000\u2002\u3000あx";
final int[] EXPECTED_RESULT = new int[] { 'A', 'b', 'c', 'D', 'E', 0x286D7,
@@ -465,6 +488,7 @@ public class StringUtilsTests extends AndroidTestCase {
exceptionHappened);
}
+ @Test
public void testGetTrailingSingleQuotesCount() {
assertEquals(0, StringUtils.getTrailingSingleQuotesCount(""));
assertEquals(1, StringUtils.getTrailingSingleQuotesCount("'"));
diff --git a/tests/src/com/android/inputmethod/latin/common/UnicodeSurrogateTests.java b/tests/src/com/android/inputmethod/latin/common/UnicodeSurrogateTests.java
index 59bb08292..adfbbf418 100644
--- a/tests/src/com/android/inputmethod/latin/common/UnicodeSurrogateTests.java
+++ b/tests/src/com/android/inputmethod/latin/common/UnicodeSurrogateTests.java
@@ -16,18 +16,27 @@
package com.android.inputmethod.latin.common;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
@SmallTest
-public class UnicodeSurrogateTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class UnicodeSurrogateTests {
+ @Test
public void testIsLowSurrogate() {
assertFalse(UnicodeSurrogate.isLowSurrogate('\uD7FF'));
assertTrue(UnicodeSurrogate.isLowSurrogate('\uD83D'));
assertFalse(UnicodeSurrogate.isLowSurrogate('\uDC00'));
}
+ @Test
public void testIsHighSurrogate() {
assertFalse(UnicodeSurrogate.isHighSurrogate('\uDBFF'));
assertTrue(UnicodeSurrogate.isHighSurrogate('\uDE25'));
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java
new file mode 100644
index 000000000..39da9fcd6
--- /dev/null
+++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictDecoderEncoderTests.java
@@ -0,0 +1,677 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.latin.makedict;
+
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.LargeTest;
+import android.util.Log;
+import android.util.Pair;
+import android.util.SparseArray;
+
+import com.android.inputmethod.latin.BinaryDictionary;
+import com.android.inputmethod.latin.common.CodePointUtils;
+import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.CharEncoding;
+import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.DictBuffer;
+import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions;
+import com.android.inputmethod.latin.makedict.FusionDictionary.PtNode;
+import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray;
+import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
+import com.android.inputmethod.latin.utils.ByteArrayDictBuffer;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map.Entry;
+import java.util.Random;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * Unit tests for BinaryDictDecoderUtils and BinaryDictEncoderUtils.
+ */
+@LargeTest
+public class BinaryDictDecoderEncoderTests extends AndroidTestCase {
+ private static final String TAG = BinaryDictDecoderEncoderTests.class.getSimpleName();
+ private static final int DEFAULT_MAX_UNIGRAMS = 300;
+ private static final int DEFAULT_CODE_POINT_SET_SIZE = 50;
+ private static final int LARGE_CODE_POINT_SET_SIZE = 300;
+ private static final int UNIGRAM_FREQ = 10;
+ private static final int BIGRAM_FREQ = 50;
+ private static final int TOLERANCE_OF_BIGRAM_FREQ = 5;
+
+ private static final ArrayList<String> sWords = new ArrayList<>();
+ private static final ArrayList<String> sWordsWithVariousCodePoints = new ArrayList<>();
+ private static final SparseArray<List<Integer>> sEmptyBigrams = new SparseArray<>();
+ private static final SparseArray<List<Integer>> sStarBigrams = new SparseArray<>();
+ private static final SparseArray<List<Integer>> sChainBigrams = new SparseArray<>();
+
+ final Random mRandom;
+
+ public BinaryDictDecoderEncoderTests() {
+ this(System.currentTimeMillis(), DEFAULT_MAX_UNIGRAMS);
+ }
+
+ public BinaryDictDecoderEncoderTests(final long seed, final int maxUnigrams) {
+ super();
+ BinaryDictionaryUtils.setCurrentTimeForTest(0);
+ Log.e(TAG, "Testing dictionary: seed is " + seed);
+ mRandom = new Random(seed);
+ sWords.clear();
+ sWordsWithVariousCodePoints.clear();
+ generateWords(maxUnigrams, mRandom);
+
+ for (int i = 0; i < sWords.size(); ++i) {
+ sChainBigrams.put(i, new ArrayList<Integer>());
+ if (i > 0) {
+ sChainBigrams.get(i - 1).add(i);
+ }
+ }
+
+ sStarBigrams.put(0, new ArrayList<Integer>());
+ // MAX - 1 because we added one above already
+ final int maxBigrams = Math.min(sWords.size(), FormatSpec.MAX_BIGRAMS_IN_A_PTNODE - 1);
+ for (int i = 1; i < maxBigrams; ++i) {
+ sStarBigrams.get(0).add(i);
+ }
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ BinaryDictionaryUtils.setCurrentTimeForTest(0);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ // Quit test mode.
+ BinaryDictionaryUtils.setCurrentTimeForTest(-1);
+ super.tearDown();
+ }
+
+ private static void generateWords(final int number, final Random random) {
+ final int[] codePointSet = CodePointUtils.generateCodePointSet(DEFAULT_CODE_POINT_SET_SIZE,
+ random);
+ final Set<String> wordSet = new HashSet<>();
+ while (wordSet.size() < number) {
+ wordSet.add(CodePointUtils.generateWord(random, codePointSet));
+ }
+ sWords.addAll(wordSet);
+
+ final int[] largeCodePointSet = CodePointUtils.generateCodePointSet(
+ LARGE_CODE_POINT_SET_SIZE, random);
+ wordSet.clear();
+ while (wordSet.size() < number) {
+ wordSet.add(CodePointUtils.generateWord(random, largeCodePointSet));
+ }
+ sWordsWithVariousCodePoints.addAll(wordSet);
+ }
+
+ /**
+ * Adds unigrams to the dictionary.
+ */
+ private static void addUnigrams(final int number, final FusionDictionary dict,
+ final List<String> words) {
+ for (int i = 0; i < number; ++i) {
+ final String word = words.get(i);
+ final ArrayList<WeightedString> shortcuts = new ArrayList<>();
+ dict.add(word, new ProbabilityInfo(UNIGRAM_FREQ), false /* isNotAWord */,
+ false /* isPossiblyOffensive */);
+ }
+ }
+
+ private static void addBigrams(final FusionDictionary dict,
+ final List<String> words,
+ final SparseArray<List<Integer>> bigrams) {
+ for (int i = 0; i < bigrams.size(); ++i) {
+ final int w1 = bigrams.keyAt(i);
+ for (int w2 : bigrams.valueAt(i)) {
+ dict.setBigram(words.get(w1), words.get(w2), new ProbabilityInfo(BIGRAM_FREQ));
+ }
+ }
+ }
+
+// The following is useful to dump the dictionary into a textual file, but it can't compile
+// on-device, so it's commented out.
+// private void dumpToCombinedFileForDebug(final FusionDictionary dict, final String filename)
+// throws IOException {
+// com.android.inputmethod.latin.dicttool.CombinedInputOutput.writeDictionaryCombined(
+// new java.io.FileWriter(new File(filename)), dict);
+// }
+
+ private static long timeWritingDictToFile(final File file, final FusionDictionary dict,
+ final FormatSpec.FormatOptions formatOptions) {
+
+ long now = -1, diff = -1;
+
+ try {
+ final DictEncoder dictEncoder = BinaryDictUtils.getDictEncoder(file, formatOptions);
+
+ now = System.currentTimeMillis();
+ // If you need to dump the dict to a textual file, uncomment the line below and the
+ // function above
+ // dumpToCombinedFileForDebug(file, "/tmp/foo");
+ dictEncoder.writeDictionary(dict, formatOptions);
+ diff = System.currentTimeMillis() - now;
+ } catch (IOException e) {
+ Log.e(TAG, "IO exception while writing file", e);
+ } catch (UnsupportedFormatException e) {
+ Log.e(TAG, "UnsupportedFormatException", e);
+ }
+
+ return diff;
+ }
+
+ private static void checkDictionary(final FusionDictionary dict, final List<String> words,
+ final SparseArray<List<Integer>> bigrams) {
+ assertNotNull(dict);
+
+ // check unigram
+ for (final String word : words) {
+ final PtNode ptNode = FusionDictionary.findWordInTree(dict.mRootNodeArray, word);
+ assertNotNull(ptNode);
+ }
+
+ // check bigram
+ for (int i = 0; i < bigrams.size(); ++i) {
+ final int w1 = bigrams.keyAt(i);
+ for (final int w2 : bigrams.valueAt(i)) {
+ final PtNode ptNode = FusionDictionary.findWordInTree(dict.mRootNodeArray,
+ words.get(w1));
+ assertNotNull(words.get(w1) + "," + words.get(w2), ptNode.getBigram(words.get(w2)));
+ }
+ }
+ }
+
+ private static String outputOptions(final int bufferType,
+ final FormatSpec.FormatOptions formatOptions) {
+ final String result = " : buffer type = "
+ + ((bufferType == BinaryDictUtils.USE_BYTE_BUFFER) ? "byte buffer" : "byte array");
+ return result + " : version = " + formatOptions.mVersion;
+ }
+
+ // Tests for readDictionaryBinary and writeDictionaryBinary
+
+ private static long timeReadingAndCheckDict(final File file, final List<String> words,
+ final SparseArray<List<Integer>> bigrams, final int bufferType) {
+ long now, diff = -1;
+
+ FusionDictionary dict = null;
+ try {
+ final DictDecoder dictDecoder = BinaryDictIOUtils.getDictDecoder(file, 0, file.length(),
+ bufferType);
+ now = System.currentTimeMillis();
+ dict = dictDecoder.readDictionaryBinary(false /* deleteDictIfBroken */);
+ diff = System.currentTimeMillis() - now;
+ } catch (IOException e) {
+ Log.e(TAG, "IOException while reading dictionary", e);
+ } catch (UnsupportedFormatException e) {
+ Log.e(TAG, "Unsupported format", e);
+ }
+
+ checkDictionary(dict, words, bigrams);
+ return diff;
+ }
+
+ // Tests for readDictionaryBinary and writeDictionaryBinary
+ private String runReadAndWrite(final List<String> words,
+ final SparseArray<List<Integer>> bigrams,
+ final int bufferType, final FormatSpec.FormatOptions formatOptions,
+ final String message) {
+
+ final String dictName = "runReadAndWrite";
+ final String dictVersion = Long.toString(System.currentTimeMillis());
+ final File file = BinaryDictUtils.getDictFile(dictName, dictVersion, formatOptions,
+ getContext().getCacheDir());
+
+ final FusionDictionary dict = new FusionDictionary(new PtNodeArray(),
+ BinaryDictUtils.makeDictionaryOptions(dictName, dictVersion, formatOptions));
+ addUnigrams(words.size(), dict, words);
+ addBigrams(dict, words, bigrams);
+ checkDictionary(dict, words, bigrams);
+
+ final long write = timeWritingDictToFile(file, dict, formatOptions);
+ final long read = timeReadingAndCheckDict(file, words, bigrams, bufferType);
+
+ return "PROF: read=" + read + "ms, write=" + write + "ms :" + message
+ + " : " + outputOptions(bufferType, formatOptions);
+ }
+
+ private void runReadAndWriteTests(final List<String> results, final int bufferType,
+ final FormatSpec.FormatOptions formatOptions) {
+ results.add(runReadAndWrite(sWords, sEmptyBigrams, bufferType,
+ formatOptions, "unigram"));
+ results.add(runReadAndWrite(sWords, sChainBigrams, bufferType,
+ formatOptions, "chain"));
+ results.add(runReadAndWrite(sWords, sStarBigrams, bufferType,
+ formatOptions, "star"));
+ results.add(runReadAndWrite(sWords, sEmptyBigrams, bufferType, formatOptions,
+ "unigram with shortcuts"));
+ results.add(runReadAndWrite(sWords, sChainBigrams, bufferType, formatOptions,
+ "chain with shortcuts"));
+ results.add(runReadAndWrite(sWords, sStarBigrams, bufferType, formatOptions,
+ "star with shortcuts"));
+ results.add(runReadAndWrite(sWordsWithVariousCodePoints, sEmptyBigrams,
+ bufferType, formatOptions,
+ "unigram with various code points"));
+ }
+
+ public void testCharacterTableIsPresent() throws IOException, UnsupportedFormatException {
+ final String[] wordSource = {"words", "used", "for", "testing", "a", "code point", "table"};
+ final List<String> words = Arrays.asList(wordSource);
+ final String correctCodePointTable = "toesdrniawuplgfcb ";
+ final String dictName = "codePointTableTest";
+ final String dictVersion = Long.toString(System.currentTimeMillis());
+ final String codePointTableAttribute = DictionaryHeader.CODE_POINT_TABLE_KEY;
+ final File file = BinaryDictUtils.getDictFile(dictName, dictVersion,
+ BinaryDictUtils.STATIC_OPTIONS, getContext().getCacheDir());
+
+ // Write a test dictionary
+ final DictEncoder dictEncoder = new Ver2DictEncoder(file,
+ Ver2DictEncoder.CODE_POINT_TABLE_ON);
+ final FormatSpec.FormatOptions formatOptions =
+ new FormatSpec.FormatOptions(
+ FormatSpec.MINIMUM_SUPPORTED_STATIC_VERSION);
+ final FusionDictionary sourcedict = new FusionDictionary(new PtNodeArray(),
+ BinaryDictUtils.makeDictionaryOptions(dictName, dictVersion, formatOptions));
+ addUnigrams(words.size(), sourcedict, words);
+ dictEncoder.writeDictionary(sourcedict, formatOptions);
+
+ // Read the dictionary
+ final DictDecoder dictDecoder = BinaryDictIOUtils.getDictDecoder(file, 0, file.length(),
+ DictDecoder.USE_BYTEARRAY);
+ final DictionaryHeader fileHeader = dictDecoder.readHeader();
+ // Check if codePointTable is present
+ assertTrue("codePointTable is not present",
+ fileHeader.mDictionaryOptions.mAttributes.containsKey(codePointTableAttribute));
+ final String codePointTable =
+ fileHeader.mDictionaryOptions.mAttributes.get(codePointTableAttribute);
+ // Check if codePointTable is correct
+ assertEquals("codePointTable is incorrect", codePointTable, correctCodePointTable);
+ }
+
+ // Unit test for CharEncoding.readString and CharEncoding.writeString.
+ public void testCharEncoding() {
+ // the max length of a word in sWords is less than 50.
+ // See generateWords.
+ final byte[] buffer = new byte[50 * 3];
+ final DictBuffer dictBuffer = new ByteArrayDictBuffer(buffer);
+ for (final String word : sWords) {
+ Arrays.fill(buffer, (byte) 0);
+ CharEncoding.writeString(buffer, 0, word, null);
+ dictBuffer.position(0);
+ final String str = CharEncoding.readString(dictBuffer);
+ assertEquals(word, str);
+ }
+ }
+
+ public void testReadAndWriteWithByteBuffer() {
+ final List<String> results = new ArrayList<>();
+
+ runReadAndWriteTests(results, BinaryDictUtils.USE_BYTE_BUFFER,
+ BinaryDictUtils.STATIC_OPTIONS);
+ runReadAndWriteTests(results, BinaryDictUtils.USE_BYTE_BUFFER,
+ BinaryDictUtils.DYNAMIC_OPTIONS_WITHOUT_TIMESTAMP);
+ runReadAndWriteTests(results, BinaryDictUtils.USE_BYTE_BUFFER,
+ BinaryDictUtils.DYNAMIC_OPTIONS_WITH_TIMESTAMP);
+ for (final String result : results) {
+ Log.d(TAG, result);
+ }
+ }
+
+ public void testReadAndWriteWithByteArray() {
+ final List<String> results = new ArrayList<>();
+
+ runReadAndWriteTests(results, BinaryDictUtils.USE_BYTE_ARRAY,
+ BinaryDictUtils.STATIC_OPTIONS);
+ runReadAndWriteTests(results, BinaryDictUtils.USE_BYTE_ARRAY,
+ BinaryDictUtils.DYNAMIC_OPTIONS_WITHOUT_TIMESTAMP);
+ runReadAndWriteTests(results, BinaryDictUtils.USE_BYTE_ARRAY,
+ BinaryDictUtils.DYNAMIC_OPTIONS_WITH_TIMESTAMP);
+
+ for (final String result : results) {
+ Log.d(TAG, result);
+ }
+ }
+
+ // Tests for readUnigramsAndBigramsBinary
+
+ private static void checkWordMap(final List<String> expectedWords,
+ final SparseArray<List<Integer>> expectedBigrams,
+ final TreeMap<Integer, String> resultWords,
+ final TreeMap<Integer, Integer> resultFrequencies,
+ final TreeMap<Integer, ArrayList<PendingAttribute>> resultBigrams,
+ final boolean checkProbability) {
+ // check unigrams
+ final Set<String> actualWordsSet = new HashSet<>(resultWords.values());
+ final Set<String> expectedWordsSet = new HashSet<>(expectedWords);
+ assertEquals(actualWordsSet, expectedWordsSet);
+ if (checkProbability) {
+ for (int freq : resultFrequencies.values()) {
+ assertEquals(freq, UNIGRAM_FREQ);
+ }
+ }
+
+ // check bigrams
+ final HashMap<String, Set<String>> expBigrams = new HashMap<>();
+ for (int i = 0; i < expectedBigrams.size(); ++i) {
+ final String word1 = expectedWords.get(expectedBigrams.keyAt(i));
+ for (int w2 : expectedBigrams.valueAt(i)) {
+ if (expBigrams.get(word1) == null) {
+ expBigrams.put(word1, new HashSet<String>());
+ }
+ expBigrams.get(word1).add(expectedWords.get(w2));
+ }
+ }
+
+ final HashMap<String, Set<String>> actBigrams = new HashMap<>();
+ for (Entry<Integer, ArrayList<PendingAttribute>> entry : resultBigrams.entrySet()) {
+ final String word1 = resultWords.get(entry.getKey());
+ final int unigramFreq = resultFrequencies.get(entry.getKey());
+ for (PendingAttribute attr : entry.getValue()) {
+ final String word2 = resultWords.get(attr.mAddress);
+ if (actBigrams.get(word1) == null) {
+ actBigrams.put(word1, new HashSet<String>());
+ }
+ actBigrams.get(word1).add(word2);
+
+ if (checkProbability) {
+ final int bigramFreq = BinaryDictIOUtils.reconstructBigramFrequency(
+ unigramFreq, attr.mFrequency);
+ assertTrue(Math.abs(bigramFreq - BIGRAM_FREQ) < TOLERANCE_OF_BIGRAM_FREQ);
+ }
+ }
+ }
+ assertEquals(actBigrams, expBigrams);
+ }
+
+ private static long timeAndCheckReadUnigramsAndBigramsBinary(final File file,
+ final List<String> words, final SparseArray<List<Integer>> bigrams,
+ final int bufferType, final boolean checkProbability) {
+ final TreeMap<Integer, String> resultWords = new TreeMap<>();
+ final TreeMap<Integer, ArrayList<PendingAttribute>> resultBigrams = new TreeMap<>();
+ final TreeMap<Integer, Integer> resultFreqs = new TreeMap<>();
+
+ long now = -1, diff = -1;
+ try {
+ final DictDecoder dictDecoder = BinaryDictIOUtils.getDictDecoder(file, 0, file.length(),
+ bufferType);
+ now = System.currentTimeMillis();
+ dictDecoder.readUnigramsAndBigramsBinary(resultWords, resultFreqs, resultBigrams);
+ diff = System.currentTimeMillis() - now;
+ } catch (IOException e) {
+ Log.e(TAG, "IOException", e);
+ } catch (UnsupportedFormatException e) {
+ Log.e(TAG, "UnsupportedFormatException", e);
+ }
+
+ checkWordMap(words, bigrams, resultWords, resultFreqs, resultBigrams, checkProbability);
+ return diff;
+ }
+
+ private String runReadUnigramsAndBigramsBinary(final ArrayList<String> words,
+ final SparseArray<List<Integer>> bigrams, final int bufferType,
+ final FormatSpec.FormatOptions formatOptions, final String message) {
+ final String dictName = "runReadUnigrams";
+ final String dictVersion = Long.toString(System.currentTimeMillis());
+ final File file = BinaryDictUtils.getDictFile(dictName, dictVersion, formatOptions,
+ getContext().getCacheDir());
+
+ // making the dictionary from lists of words.
+ final FusionDictionary dict = new FusionDictionary(new PtNodeArray(),
+ BinaryDictUtils.makeDictionaryOptions(dictName, dictVersion, formatOptions));
+ addUnigrams(words.size(), dict, words);
+ addBigrams(dict, words, bigrams);
+
+ timeWritingDictToFile(file, dict, formatOptions);
+
+ // Caveat: Currently, the Java code to read a v4 dictionary doesn't calculate the
+ // probability when there's a timestamp for the entry.
+ // TODO: Abandon the Java code, and implement the v4 dictionary reading code in native.
+ long wordMap = timeAndCheckReadUnigramsAndBigramsBinary(file, words, bigrams, bufferType,
+ !formatOptions.mHasTimestamp /* checkProbability */);
+ long fullReading = timeReadingAndCheckDict(file, words, bigrams,
+ bufferType);
+
+ return "readDictionaryBinary=" + fullReading + ", readUnigramsAndBigramsBinary=" + wordMap
+ + " : " + message + " : " + outputOptions(bufferType, formatOptions);
+ }
+
+ private void runReadUnigramsAndBigramsTests(final ArrayList<String> results,
+ final int bufferType, final FormatSpec.FormatOptions formatOptions) {
+ results.add(runReadUnigramsAndBigramsBinary(sWords, sEmptyBigrams, bufferType,
+ formatOptions, "unigram"));
+ results.add(runReadUnigramsAndBigramsBinary(sWords, sChainBigrams, bufferType,
+ formatOptions, "chain"));
+ results.add(runReadUnigramsAndBigramsBinary(sWords, sStarBigrams, bufferType,
+ formatOptions, "star"));
+ }
+
+ public void testReadUnigramsAndBigramsBinaryWithByteBuffer() {
+ final ArrayList<String> results = new ArrayList<>();
+
+ runReadUnigramsAndBigramsTests(results, BinaryDictUtils.USE_BYTE_BUFFER,
+ BinaryDictUtils.STATIC_OPTIONS);
+
+ for (final String result : results) {
+ Log.d(TAG, result);
+ }
+ }
+
+ public void testReadUnigramsAndBigramsBinaryWithByteArray() {
+ final ArrayList<String> results = new ArrayList<>();
+
+ runReadUnigramsAndBigramsTests(results, BinaryDictUtils.USE_BYTE_ARRAY,
+ BinaryDictUtils.STATIC_OPTIONS);
+
+ for (final String result : results) {
+ Log.d(TAG, result);
+ }
+ }
+
+ // Tests for getTerminalPosition
+ private static String getWordFromBinary(final DictDecoder dictDecoder, final int address) {
+ if (dictDecoder.getPosition() != 0) dictDecoder.setPosition(0);
+
+ DictionaryHeader fileHeader = null;
+ try {
+ fileHeader = dictDecoder.readHeader();
+ } catch (IOException e) {
+ return null;
+ } catch (UnsupportedFormatException e) {
+ return null;
+ }
+ if (fileHeader == null) return null;
+ return BinaryDictDecoderUtils.getWordAtPosition(dictDecoder, fileHeader.mBodyOffset,
+ address).mWord;
+ }
+
+ private static long checkGetTerminalPosition(final DictDecoder dictDecoder, final String word,
+ final boolean contained) {
+ long diff = -1;
+ int position = -1;
+ try {
+ final long now = System.nanoTime();
+ position = dictDecoder.getTerminalPosition(word);
+ diff = System.nanoTime() - now;
+ } catch (IOException e) {
+ Log.e(TAG, "IOException while getTerminalPosition", e);
+ } catch (UnsupportedFormatException e) {
+ Log.e(TAG, "UnsupportedFormatException while getTerminalPosition", e);
+ }
+
+ assertEquals(FormatSpec.NOT_VALID_WORD != position, contained);
+ if (contained) assertEquals(getWordFromBinary(dictDecoder, position), word);
+ return diff;
+ }
+
+ private void runGetTerminalPosition(final ArrayList<String> words,
+ final SparseArray<List<Integer>> bigrams, final int bufferType,
+ final FormatOptions formatOptions, final String message) {
+ final String dictName = "testGetTerminalPosition";
+ final String dictVersion = Long.toString(System.currentTimeMillis());
+ final File file = BinaryDictUtils.getDictFile(dictName, dictVersion, formatOptions,
+ getContext().getCacheDir());
+
+ final FusionDictionary dict = new FusionDictionary(new PtNodeArray(),
+ BinaryDictUtils.makeDictionaryOptions(dictName, dictVersion, formatOptions));
+ addUnigrams(sWords.size(), dict, sWords);
+ addBigrams(dict, words, bigrams);
+ timeWritingDictToFile(file, dict, formatOptions);
+
+ final DictDecoder dictDecoder = BinaryDictIOUtils.getDictDecoder(file, 0, file.length(),
+ DictDecoder.USE_BYTEARRAY);
+ try {
+ dictDecoder.openDictBuffer();
+ } catch (IOException e) {
+ Log.e(TAG, "IOException while opening the buffer", e);
+ } catch (UnsupportedFormatException e) {
+ Log.e(TAG, "IOException while opening the buffer", e);
+ }
+ assertTrue("Can't get the buffer", dictDecoder.isDictBufferOpen());
+
+ try {
+ // too long word
+ final String longWord = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz";
+ assertEquals(FormatSpec.NOT_VALID_WORD, dictDecoder.getTerminalPosition(longWord));
+
+ // null
+ assertEquals(FormatSpec.NOT_VALID_WORD, dictDecoder.getTerminalPosition(null));
+
+ // empty string
+ assertEquals(FormatSpec.NOT_VALID_WORD, dictDecoder.getTerminalPosition(""));
+ } catch (IOException e) {
+ } catch (UnsupportedFormatException e) {
+ }
+
+ // Test a word that is contained within the dictionary.
+ long sum = 0;
+ for (int i = 0; i < sWords.size(); ++i) {
+ final long time = checkGetTerminalPosition(dictDecoder, sWords.get(i), true);
+ sum += time == -1 ? 0 : time;
+ }
+ Log.d(TAG, "per search : " + (((double)sum) / sWords.size() / 1000000) + " : " + message
+ + " : " + outputOptions(bufferType, formatOptions));
+
+ // Test a word that isn't contained within the dictionary.
+ final int[] codePointSet = CodePointUtils.generateCodePointSet(DEFAULT_CODE_POINT_SET_SIZE,
+ mRandom);
+ for (int i = 0; i < 1000; ++i) {
+ final String word = CodePointUtils.generateWord(mRandom, codePointSet);
+ if (sWords.indexOf(word) != -1) continue;
+ checkGetTerminalPosition(dictDecoder, word, false);
+ }
+ }
+
+ private void runGetTerminalPositionTests(final int bufferType,
+ final FormatOptions formatOptions) {
+ runGetTerminalPosition(sWords, sEmptyBigrams, bufferType, formatOptions, "unigram");
+ }
+
+ public void testGetTerminalPosition() {
+ final ArrayList<String> results = new ArrayList<>();
+
+ runGetTerminalPositionTests(BinaryDictUtils.USE_BYTE_ARRAY,
+ BinaryDictUtils.STATIC_OPTIONS);
+ runGetTerminalPositionTests(BinaryDictUtils.USE_BYTE_BUFFER,
+ BinaryDictUtils.STATIC_OPTIONS);
+
+ for (final String result : results) {
+ Log.d(TAG, result);
+ }
+ }
+
+ public void testVer2DictGetWordProperty() {
+ final FormatOptions formatOptions = BinaryDictUtils.STATIC_OPTIONS;
+ final ArrayList<String> words = sWords;
+ final String dictName = "testGetWordProperty";
+ final String dictVersion = Long.toString(System.currentTimeMillis());
+ final FusionDictionary dict = new FusionDictionary(new PtNodeArray(),
+ BinaryDictUtils.makeDictionaryOptions(dictName, dictVersion, formatOptions));
+ addUnigrams(words.size(), dict, words);
+ addBigrams(dict, words, sEmptyBigrams);
+ final File file = BinaryDictUtils.getDictFile(dictName, dictVersion, formatOptions,
+ getContext().getCacheDir());
+ file.delete();
+ timeWritingDictToFile(file, dict, formatOptions);
+ final BinaryDictionary binaryDictionary = new BinaryDictionary(file.getAbsolutePath(),
+ 0 /* offset */, file.length(), true /* useFullEditDistance */,
+ Locale.ENGLISH, dictName, false /* isUpdatable */);
+ for (final String word : words) {
+ final WordProperty wordProperty = binaryDictionary.getWordProperty(word,
+ false /* isBeginningOfSentence */);
+ assertEquals(word, wordProperty.mWord);
+ assertEquals(UNIGRAM_FREQ, wordProperty.getProbability());
+ }
+ }
+
+ public void testVer2DictIteration() {
+ final FormatOptions formatOptions = BinaryDictUtils.STATIC_OPTIONS;
+ final ArrayList<String> words = sWords;
+ final SparseArray<List<Integer>> bigrams = sEmptyBigrams;
+ final String dictName = "testGetWordProperty";
+ final String dictVersion = Long.toString(System.currentTimeMillis());
+ final FusionDictionary dict = new FusionDictionary(new PtNodeArray(),
+ BinaryDictUtils.makeDictionaryOptions(dictName, dictVersion, formatOptions));
+ addUnigrams(words.size(), dict, words);
+ addBigrams(dict, words, bigrams);
+ final File file = BinaryDictUtils.getDictFile(dictName, dictVersion, formatOptions,
+ getContext().getCacheDir());
+ timeWritingDictToFile(file, dict, formatOptions);
+ Log.d(TAG, file.getAbsolutePath());
+ final BinaryDictionary binaryDictionary = new BinaryDictionary(file.getAbsolutePath(),
+ 0 /* offset */, file.length(), true /* useFullEditDistance */,
+ Locale.ENGLISH, dictName, false /* isUpdatable */);
+
+ final HashSet<String> wordSet = new HashSet<>(words);
+ final HashSet<Pair<String, String>> bigramSet = new HashSet<>();
+
+ for (int i = 0; i < words.size(); i++) {
+ final List<Integer> bigramList = bigrams.get(i);
+ if (bigramList != null) {
+ for (final Integer word1Index : bigramList) {
+ final String word1 = words.get(word1Index);
+ bigramSet.add(new Pair<>(words.get(i), word1));
+ }
+ }
+ }
+ int token = 0;
+ do {
+ final BinaryDictionary.GetNextWordPropertyResult result =
+ binaryDictionary.getNextWordProperty(token);
+ final WordProperty wordProperty = result.mWordProperty;
+ final String word0 = wordProperty.mWord;
+ assertEquals(UNIGRAM_FREQ, wordProperty.mProbabilityInfo.mProbability);
+ wordSet.remove(word0);
+ if (wordProperty.mHasNgrams) {
+ for (final WeightedString bigramTarget : wordProperty.getBigrams()) {
+ final String word1 = bigramTarget.mWord;
+ final Pair<String, String> bigram = new Pair<>(word0, word1);
+ assertTrue(bigramSet.contains(bigram));
+ bigramSet.remove(bigram);
+ }
+ }
+ token = result.mNextToken;
+ } while (token != 0);
+ assertTrue(wordSet.isEmpty());
+ assertTrue(bigramSet.isEmpty());
+ }
+}
diff --git a/tests/src/com/android/inputmethod/latin/makedict/BinaryDictUtils.java b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictUtils.java
new file mode 100644
index 000000000..9c1e4cf84
--- /dev/null
+++ b/tests/src/com/android/inputmethod/latin/makedict/BinaryDictUtils.java
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.latin.makedict;
+
+import com.android.inputmethod.latin.makedict.FormatSpec.DictionaryOptions;
+import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions;
+
+import java.io.File;
+import java.util.HashMap;
+
+public class BinaryDictUtils {
+ public static final int USE_BYTE_ARRAY = 1;
+ public static final int USE_BYTE_BUFFER = 2;
+
+ public static final String TEST_DICT_FILE_EXTENSION = ".testDict";
+
+ public static final FormatSpec.FormatOptions STATIC_OPTIONS =
+ new FormatSpec.FormatOptions(FormatSpec.VERSION202);
+ public static final FormatSpec.FormatOptions DYNAMIC_OPTIONS_WITHOUT_TIMESTAMP =
+ new FormatSpec.FormatOptions(FormatSpec.VERSION4, false /* hasTimestamp */);
+ public static final FormatSpec.FormatOptions DYNAMIC_OPTIONS_WITH_TIMESTAMP =
+ new FormatSpec.FormatOptions(FormatSpec.VERSION4, true /* hasTimestamp */);
+
+ public static DictionaryOptions makeDictionaryOptions(final String id, final String version,
+ final FormatSpec.FormatOptions formatOptions) {
+ final DictionaryOptions options = new DictionaryOptions(new HashMap<String, String>());
+ options.mAttributes.put(DictionaryHeader.DICTIONARY_LOCALE_KEY, "en_US");
+ options.mAttributes.put(DictionaryHeader.DICTIONARY_ID_KEY, id);
+ options.mAttributes.put(DictionaryHeader.DICTIONARY_VERSION_KEY, version);
+ if (formatOptions.mHasTimestamp) {
+ options.mAttributes.put(DictionaryHeader.HAS_HISTORICAL_INFO_KEY,
+ DictionaryHeader.ATTRIBUTE_VALUE_TRUE);
+ options.mAttributes.put(DictionaryHeader.USES_FORGETTING_CURVE_KEY,
+ DictionaryHeader.ATTRIBUTE_VALUE_TRUE);
+ }
+ return options;
+ }
+
+ public static File getDictFile(final String name, final String version,
+ final FormatOptions formatOptions, final File directory) {
+ if (formatOptions.mVersion == FormatSpec.VERSION2
+ || formatOptions.mVersion == FormatSpec.VERSION201
+ || formatOptions.mVersion == FormatSpec.VERSION202) {
+ return new File(directory, name + "." + version + TEST_DICT_FILE_EXTENSION);
+ } else if (formatOptions.mVersion == FormatSpec.VERSION4) {
+ return new File(directory, name + "." + version);
+ } else {
+ throw new RuntimeException("the format option has a wrong version : "
+ + formatOptions.mVersion);
+ }
+ }
+
+ public static DictEncoder getDictEncoder(final File file, final FormatOptions formatOptions) {
+ if (formatOptions.mVersion == FormatSpec.VERSION4) {
+ if (!file.isDirectory()) {
+ file.mkdir();
+ }
+ return new Ver4DictEncoder(file);
+ } else if (formatOptions.mVersion == FormatSpec.VERSION202) {
+ return new Ver2DictEncoder(file, Ver2DictEncoder.CODE_POINT_TABLE_OFF);
+ } else {
+ throw new RuntimeException("The format option has a wrong version : "
+ + formatOptions.mVersion);
+ }
+ }
+}
diff --git a/tests/src/com/android/inputmethod/latin/makedict/Ver2DictEncoder.java b/tests/src/com/android/inputmethod/latin/makedict/Ver2DictEncoder.java
new file mode 100644
index 000000000..c63b972eb
--- /dev/null
+++ b/tests/src/com/android/inputmethod/latin/makedict/Ver2DictEncoder.java
@@ -0,0 +1,279 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.latin.makedict;
+
+import com.android.inputmethod.annotations.UsedForTesting;
+import com.android.inputmethod.latin.makedict.BinaryDictDecoderUtils.CharEncoding;
+import com.android.inputmethod.latin.makedict.BinaryDictEncoderUtils.CodePointTable;
+import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions;
+import com.android.inputmethod.latin.makedict.FusionDictionary.PtNode;
+import com.android.inputmethod.latin.makedict.FusionDictionary.PtNodeArray;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+/**
+ * An implementation of DictEncoder for version 2 binary dictionary.
+ */
+@UsedForTesting
+public class Ver2DictEncoder implements DictEncoder {
+
+ private final File mDictFile;
+ private OutputStream mOutStream;
+ private byte[] mBuffer;
+ private int mPosition;
+ private final int mCodePointTableMode;
+ public static final int CODE_POINT_TABLE_OFF = 0;
+ public static final int CODE_POINT_TABLE_ON = 1;
+
+ @UsedForTesting
+ public Ver2DictEncoder(final File dictFile, final int codePointTableMode) {
+ mDictFile = dictFile;
+ mOutStream = null;
+ mBuffer = null;
+ mCodePointTableMode = codePointTableMode;
+ }
+
+ // This constructor is used only by BinaryDictOffdeviceUtilsTests.
+ // If you want to use this in the production code, you should consider keeping consistency of
+ // the interface of Ver3DictDecoder by using factory.
+ @UsedForTesting
+ public Ver2DictEncoder(final OutputStream outStream) {
+ mDictFile = null;
+ mOutStream = outStream;
+ mCodePointTableMode = CODE_POINT_TABLE_OFF;
+ }
+
+ private void openStream() throws FileNotFoundException {
+ mOutStream = new FileOutputStream(mDictFile);
+ }
+
+ private void close() throws IOException {
+ if (mOutStream != null) {
+ mOutStream.close();
+ mOutStream = null;
+ }
+ }
+
+ // Package for testing
+ static CodePointTable makeCodePointTable(final FusionDictionary dict) {
+ final HashMap<Integer, Integer> codePointOccurrenceCounts = new HashMap<>();
+ for (final WordProperty word : dict) {
+ // Store per code point occurrence
+ final String wordString = word.mWord;
+ for (int i = 0; i < wordString.length(); ++i) {
+ final int codePoint = Character.codePointAt(wordString, i);
+ if (codePointOccurrenceCounts.containsKey(codePoint)) {
+ codePointOccurrenceCounts.put(codePoint,
+ codePointOccurrenceCounts.get(codePoint) + 1);
+ } else {
+ codePointOccurrenceCounts.put(codePoint, 1);
+ }
+ }
+ }
+ final ArrayList<Entry<Integer, Integer>> codePointOccurrenceArray =
+ new ArrayList<>(codePointOccurrenceCounts.entrySet());
+ // Descending order sort by occurrence (value side)
+ Collections.sort(codePointOccurrenceArray, new Comparator<Entry<Integer, Integer>>() {
+ @Override
+ public int compare(final Entry<Integer, Integer> a, final Entry<Integer, Integer> b) {
+ if (a.getValue() != b.getValue()) {
+ return b.getValue().compareTo(a.getValue());
+ }
+ return b.getKey().compareTo(a.getKey());
+ }
+ });
+ int currentCodePointTableIndex = FormatSpec.MINIMAL_ONE_BYTE_CHARACTER_VALUE;
+ // Temporary map for writing of nodes
+ final HashMap<Integer, Integer> codePointToOneByteCodeMap = new HashMap<>();
+ for (final Entry<Integer, Integer> entry : codePointOccurrenceArray) {
+ // Put a relation from the original code point to the one byte code.
+ codePointToOneByteCodeMap.put(entry.getKey(), currentCodePointTableIndex);
+ if (FormatSpec.MAXIMAL_ONE_BYTE_CHARACTER_VALUE < ++currentCodePointTableIndex) {
+ break;
+ }
+ }
+ // codePointToOneByteCodeMap for writing the trie
+ // codePointOccurrenceArray for writing the header
+ return new CodePointTable(codePointToOneByteCodeMap, codePointOccurrenceArray);
+ }
+
+ @Override
+ public void writeDictionary(final FusionDictionary dict, final FormatOptions formatOptions)
+ throws IOException, UnsupportedFormatException {
+ // We no longer support anything but the latest version of v2.
+ if (formatOptions.mVersion != FormatSpec.VERSION202) {
+ throw new UnsupportedFormatException(
+ "The given format options has wrong version number : "
+ + formatOptions.mVersion);
+ }
+
+ if (mOutStream == null) {
+ openStream();
+ }
+
+ // Make code point conversion table ordered by occurrence of code points
+ // Version 201 or later have codePointTable
+ final CodePointTable codePointTable;
+ if (mCodePointTableMode == CODE_POINT_TABLE_OFF || formatOptions.mVersion
+ < FormatSpec.MINIMUM_SUPPORTED_VERSION_OF_CODE_POINT_TABLE) {
+ codePointTable = new CodePointTable();
+ } else {
+ codePointTable = makeCodePointTable(dict);
+ }
+
+ BinaryDictEncoderUtils.writeDictionaryHeader(mOutStream, dict, formatOptions,
+ codePointTable.mCodePointOccurrenceArray);
+
+ // Addresses are limited to 3 bytes, but since addresses can be relative to each node
+ // array, the structure itself is not limited to 16MB. However, if it is over 16MB deciding
+ // the order of the PtNode arrays becomes a quite complicated problem, because though the
+ // dictionary itself does not have a size limit, each node array must still be within 16MB
+ // of all its children and parents. As long as this is ensured, the dictionary file may
+ // grow to any size.
+
+ // Leave the choice of the optimal node order to the flattenTree function.
+ MakedictLog.i("Flattening the tree...");
+ ArrayList<PtNodeArray> flatNodes = BinaryDictEncoderUtils.flattenTree(dict.mRootNodeArray);
+
+ MakedictLog.i("Computing addresses...");
+ BinaryDictEncoderUtils.computeAddresses(dict, flatNodes,
+ codePointTable.mCodePointToOneByteCodeMap);
+ MakedictLog.i("Checking PtNode array...");
+ if (MakedictLog.DBG) BinaryDictEncoderUtils.checkFlatPtNodeArrayList(flatNodes);
+
+ // Create a buffer that matches the final dictionary size.
+ final PtNodeArray lastNodeArray = flatNodes.get(flatNodes.size() - 1);
+ final int bufferSize = lastNodeArray.mCachedAddressAfterUpdate + lastNodeArray.mCachedSize;
+ mBuffer = new byte[bufferSize];
+
+ MakedictLog.i("Writing file...");
+
+ for (PtNodeArray nodeArray : flatNodes) {
+ BinaryDictEncoderUtils.writePlacedPtNodeArray(dict, this, nodeArray,
+ codePointTable.mCodePointToOneByteCodeMap);
+ }
+ if (MakedictLog.DBG) BinaryDictEncoderUtils.showStatistics(flatNodes);
+ mOutStream.write(mBuffer, 0, mPosition);
+
+ MakedictLog.i("Done");
+ close();
+ }
+
+ @Override
+ public void setPosition(final int position) {
+ if (mBuffer == null || position < 0 || position >= mBuffer.length) return;
+ mPosition = position;
+ }
+
+ @Override
+ public int getPosition() {
+ return mPosition;
+ }
+
+ @Override
+ public void writePtNodeCount(final int ptNodeCount) {
+ final int countSize = BinaryDictIOUtils.getPtNodeCountSize(ptNodeCount);
+ if (countSize != 1 && countSize != 2) {
+ throw new RuntimeException("Strange size from getGroupCountSize : " + countSize);
+ }
+ final int encodedPtNodeCount = (countSize == 2) ?
+ (ptNodeCount | FormatSpec.LARGE_PTNODE_ARRAY_SIZE_FIELD_SIZE_FLAG) : ptNodeCount;
+ mPosition = BinaryDictEncoderUtils.writeUIntToBuffer(mBuffer, mPosition, encodedPtNodeCount,
+ countSize);
+ }
+
+ private void writePtNodeFlags(final PtNode ptNode,
+ final HashMap<Integer, Integer> codePointToOneByteCodeMap) {
+ final int childrenPos = BinaryDictEncoderUtils.getChildrenPosition(ptNode,
+ codePointToOneByteCodeMap);
+ mPosition = BinaryDictEncoderUtils.writeUIntToBuffer(mBuffer, mPosition,
+ BinaryDictEncoderUtils.makePtNodeFlags(ptNode, childrenPos),
+ FormatSpec.PTNODE_FLAGS_SIZE);
+ }
+
+ private void writeCharacters(final int[] codePoints, final boolean hasSeveralChars,
+ final HashMap<Integer, Integer> codePointToOneByteCodeMap) {
+ mPosition = CharEncoding.writeCharArray(codePoints, mBuffer, mPosition,
+ codePointToOneByteCodeMap);
+ if (hasSeveralChars) {
+ mBuffer[mPosition++] = FormatSpec.PTNODE_CHARACTERS_TERMINATOR;
+ }
+ }
+
+ private void writeFrequency(final int frequency) {
+ if (frequency >= 0) {
+ mPosition = BinaryDictEncoderUtils.writeUIntToBuffer(mBuffer, mPosition, frequency,
+ FormatSpec.PTNODE_FREQUENCY_SIZE);
+ }
+ }
+
+ private void writeChildrenPosition(final PtNode ptNode,
+ final HashMap<Integer, Integer> codePointToOneByteCodeMap) {
+ final int childrenPos = BinaryDictEncoderUtils.getChildrenPosition(ptNode,
+ codePointToOneByteCodeMap);
+ mPosition += BinaryDictEncoderUtils.writeChildrenPosition(mBuffer, mPosition,
+ childrenPos);
+ }
+
+ /**
+ * Write a bigram attributes list to mBuffer.
+ *
+ * @param bigrams the bigram attributes list.
+ * @param dict the dictionary the node array is a part of (for relative offsets).
+ */
+ private void writeBigrams(final ArrayList<WeightedString> bigrams,
+ final FusionDictionary dict) {
+ if (bigrams == null) return;
+
+ final Iterator<WeightedString> bigramIterator = bigrams.iterator();
+ while (bigramIterator.hasNext()) {
+ final WeightedString bigram = bigramIterator.next();
+ final PtNode target =
+ FusionDictionary.findWordInTree(dict.mRootNodeArray, bigram.mWord);
+ final int addressOfBigram = target.mCachedAddressAfterUpdate;
+ final int unigramFrequencyForThisWord = target.getProbability();
+ final int offset = addressOfBigram
+ - (mPosition + FormatSpec.PTNODE_ATTRIBUTE_FLAGS_SIZE);
+ final int bigramFlags = BinaryDictEncoderUtils.makeBigramFlags(bigramIterator.hasNext(),
+ offset, bigram.getProbability(), unigramFrequencyForThisWord, bigram.mWord);
+ mPosition = BinaryDictEncoderUtils.writeUIntToBuffer(mBuffer, mPosition, bigramFlags,
+ FormatSpec.PTNODE_ATTRIBUTE_FLAGS_SIZE);
+ mPosition += BinaryDictEncoderUtils.writeChildrenPosition(mBuffer, mPosition,
+ Math.abs(offset));
+ }
+ }
+
+ @Override
+ public void writePtNode(final PtNode ptNode, final FusionDictionary dict,
+ final HashMap<Integer, Integer> codePointToOneByteCodeMap) {
+ writePtNodeFlags(ptNode, codePointToOneByteCodeMap);
+ writeCharacters(ptNode.mChars, ptNode.hasSeveralChars(), codePointToOneByteCodeMap);
+ writeFrequency(ptNode.getProbability());
+ writeChildrenPosition(ptNode, codePointToOneByteCodeMap);
+ writeBigrams(ptNode.mBigrams, dict);
+ }
+}
diff --git a/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java b/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java
new file mode 100644
index 000000000..6e7b37d54
--- /dev/null
+++ b/tests/src/com/android/inputmethod/latin/makedict/Ver4DictEncoder.java
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2013 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.latin.makedict;
+
+import com.android.inputmethod.annotations.UsedForTesting;
+import com.android.inputmethod.latin.BinaryDictionary;
+import com.android.inputmethod.latin.Dictionary;
+import com.android.inputmethod.latin.NgramContext;
+import com.android.inputmethod.latin.common.LocaleUtils;
+import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions;
+import com.android.inputmethod.latin.makedict.FusionDictionary.PtNode;
+import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+
+/**
+ * An implementation of DictEncoder for version 4 binary dictionary.
+ */
+@UsedForTesting
+public class Ver4DictEncoder implements DictEncoder {
+ private final File mDictPlacedDir;
+
+ @UsedForTesting
+ public Ver4DictEncoder(final File dictPlacedDir) {
+ mDictPlacedDir = dictPlacedDir;
+ }
+
+ // TODO: This builds a FusionDictionary first and iterates it to add words to the binary
+ // dictionary. However, it is possible to just add words directly to the binary dictionary
+ // instead.
+ // In the long run, when we stop supporting version 2, FusionDictionary will become deprecated
+ // and we can remove it. Then we'll be able to just call BinaryDictionary directly.
+ @Override
+ public void writeDictionary(FusionDictionary dict, FormatOptions formatOptions)
+ throws IOException, UnsupportedFormatException {
+ if (formatOptions.mVersion != FormatSpec.VERSION4) {
+ throw new UnsupportedFormatException("File header has a wrong version number : "
+ + formatOptions.mVersion);
+ }
+ if (!mDictPlacedDir.isDirectory()) {
+ throw new UnsupportedFormatException("Given path is not a directory.");
+ }
+ if (!BinaryDictionaryUtils.createEmptyDictFile(mDictPlacedDir.getAbsolutePath(),
+ FormatSpec.VERSION4, LocaleUtils.constructLocaleFromString(
+ dict.mOptions.mAttributes.get(DictionaryHeader.DICTIONARY_LOCALE_KEY)),
+ dict.mOptions.mAttributes)) {
+ throw new IOException("Cannot create dictionary file : "
+ + mDictPlacedDir.getAbsolutePath());
+ }
+ final BinaryDictionary binaryDict = new BinaryDictionary(mDictPlacedDir.getAbsolutePath(),
+ 0l, mDictPlacedDir.length(), true /* useFullEditDistance */,
+ LocaleUtils.constructLocaleFromString(dict.mOptions.mAttributes.get(
+ DictionaryHeader.DICTIONARY_LOCALE_KEY)),
+ Dictionary.TYPE_USER /* Dictionary type. Does not matter for us */,
+ true /* isUpdatable */);
+ if (!binaryDict.isValidDictionary()) {
+ // Somehow createEmptyDictFile returned true, but the file was not created correctly
+ throw new IOException("Cannot create dictionary file");
+ }
+ for (final WordProperty wordProperty : dict) {
+ if (!binaryDict.addUnigramEntry(wordProperty.mWord, wordProperty.getProbability(),
+ wordProperty.mIsBeginningOfSentence, wordProperty.mIsNotAWord,
+ wordProperty.mIsPossiblyOffensive, 0 /* timestamp */)) {
+ MakedictLog.e("Cannot add unigram entry for " + wordProperty.mWord);
+ }
+ if (binaryDict.needsToRunGC(true /* mindsBlockByGC */)) {
+ if (!binaryDict.flushWithGC()) {
+ MakedictLog.e("Cannot flush dict with GC.");
+ return;
+ }
+ }
+ }
+ for (final WordProperty word0Property : dict) {
+ if (!word0Property.mHasNgrams) continue;
+ // TODO: Support ngram.
+ for (final WeightedString word1 : word0Property.getBigrams()) {
+ final NgramContext ngramContext =
+ new NgramContext(new NgramContext.WordInfo(word0Property.mWord));
+ if (!binaryDict.addNgramEntry(ngramContext, word1.mWord,
+ word1.getProbability(), 0 /* timestamp */)) {
+ MakedictLog.e("Cannot add n-gram entry for "
+ + ngramContext + " -> " + word1.mWord);
+ return;
+ }
+ if (binaryDict.needsToRunGC(true /* mindsBlockByGC */)) {
+ if (!binaryDict.flushWithGC()) {
+ MakedictLog.e("Cannot flush dict with GC.");
+ return;
+ }
+ }
+ }
+ }
+ if (!binaryDict.flushWithGC()) {
+ MakedictLog.e("Cannot flush dict with GC.");
+ return;
+ }
+ binaryDict.close();
+ }
+
+ @Override
+ public void setPosition(int position) {
+ }
+
+ @Override
+ public int getPosition() {
+ return 0;
+ }
+
+ @Override
+ public void writePtNodeCount(int ptNodeCount) {
+ }
+
+ @Override
+ public void writePtNode(PtNode ptNode, FusionDictionary dict,
+ HashMap<Integer, Integer> codePointToOneByteCodeMap) {
+ }
+}
diff --git a/tests/src/com/android/inputmethod/latin/network/BlockingHttpClientTests.java b/tests/src/com/android/inputmethod/latin/network/BlockingHttpClientTests.java
index 8f24cdb44..f6f54eb77 100644
--- a/tests/src/com/android/inputmethod/latin/network/BlockingHttpClientTests.java
+++ b/tests/src/com/android/inputmethod/latin/network/BlockingHttpClientTests.java
@@ -16,16 +16,22 @@
package com.android.inputmethod.latin.network;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.network.BlockingHttpClient.ResponseProcessor;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;
@@ -44,15 +50,16 @@ import java.util.Random;
* Tests for {@link BlockingHttpClient}.
*/
@SmallTest
-public class BlockingHttpClientTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class BlockingHttpClientTests {
@Mock HttpURLConnection mMockHttpConnection;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
}
+ @Test
public void testError_badGateway() throws IOException, AuthException {
when(mMockHttpConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_BAD_GATEWAY);
final BlockingHttpClient client = new BlockingHttpClient(mMockHttpConnection);
@@ -67,6 +74,7 @@ public class BlockingHttpClientTests extends AndroidTestCase {
}
}
+ @Test
public void testError_clientTimeout() throws Exception {
when(mMockHttpConnection.getResponseCode()).thenReturn(
HttpURLConnection.HTTP_CLIENT_TIMEOUT);
@@ -82,6 +90,7 @@ public class BlockingHttpClientTests extends AndroidTestCase {
}
}
+ @Test
public void testError_forbiddenWithRequest() throws Exception {
final OutputStream mockOutputStream = Mockito.mock(OutputStream.class);
when(mMockHttpConnection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_FORBIDDEN);
@@ -98,6 +107,7 @@ public class BlockingHttpClientTests extends AndroidTestCase {
verify(mockOutputStream).write(any(byte[].class), eq(0), eq(100));
}
+ @Test
public void testSuccess_emptyRequest() throws Exception {
final Random rand = new Random();
byte[] response = new byte[100];
@@ -112,6 +122,7 @@ public class BlockingHttpClientTests extends AndroidTestCase {
assertTrue("ResponseProcessor was not invoked", processor.mInvoked);
}
+ @Test
public void testSuccess() throws Exception {
final OutputStream mockOutputStream = Mockito.mock(OutputStream.class);
final Random rand = new Random();
diff --git a/tests/src/com/android/inputmethod/latin/network/HttpUrlConnectionBuilderTests.java b/tests/src/com/android/inputmethod/latin/network/HttpUrlConnectionBuilderTests.java
index 5b3e78eaf..1aa4040b8 100644
--- a/tests/src/com/android/inputmethod/latin/network/HttpUrlConnectionBuilderTests.java
+++ b/tests/src/com/android/inputmethod/latin/network/HttpUrlConnectionBuilderTests.java
@@ -20,25 +20,28 @@ import static com.android.inputmethod.latin.network.HttpUrlConnectionBuilder.MOD
import static com.android.inputmethod.latin.network.HttpUrlConnectionBuilder.MODE_DOWNLOAD_ONLY;
import static com.android.inputmethod.latin.network.HttpUrlConnectionBuilder.MODE_UPLOAD_ONLY;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
-
/**
* Tests for {@link HttpUrlConnectionBuilder}.
*/
@SmallTest
-public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
+@RunWith(AndroidJUnit4.class)
+public class HttpUrlConnectionBuilderTests {
+ @Test
public void testSetUrl_malformed() {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
try {
@@ -49,6 +52,7 @@ public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
}
}
+ @Test
public void testSetConnectTimeout_invalid() {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
try {
@@ -59,6 +63,7 @@ public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
}
}
+ @Test
public void testSetConnectTimeout() throws IOException {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
builder.setUrl("https://www.example.com");
@@ -67,6 +72,7 @@ public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
assertEquals(8765, connection.getConnectTimeout());
}
+ @Test
public void testSetReadTimeout_invalid() {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
try {
@@ -77,6 +83,7 @@ public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
}
}
+ @Test
public void testSetReadTimeout() throws IOException {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
builder.setUrl("https://www.example.com");
@@ -85,6 +92,7 @@ public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
assertEquals(8765, connection.getReadTimeout());
}
+ @Test
public void testAddHeader() throws IOException {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
builder.setUrl("http://www.example.com");
@@ -93,6 +101,7 @@ public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
assertEquals("some-random-value", connection.getRequestProperty("some-random-key"));
}
+ @Test
public void testSetUseCache_notSet() throws IOException {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
builder.setUrl("http://www.example.com");
@@ -100,6 +109,7 @@ public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
assertFalse(connection.getUseCaches());
}
+ @Test
public void testSetUseCache_false() throws IOException {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
builder.setUrl("http://www.example.com");
@@ -108,6 +118,7 @@ public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
assertFalse(connection.getUseCaches());
}
+ @Test
public void testSetUseCache_true() throws IOException {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
builder.setUrl("http://www.example.com");
@@ -116,6 +127,7 @@ public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
assertTrue(connection.getUseCaches());
}
+ @Test
public void testSetMode_uploadOnly() throws IOException {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
builder.setUrl("http://www.example.com");
@@ -125,6 +137,7 @@ public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
assertFalse(connection.getDoOutput());
}
+ @Test
public void testSetMode_downloadOnly() throws IOException {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
builder.setUrl("https://www.example.com");
@@ -134,6 +147,7 @@ public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
assertTrue(connection.getDoOutput());
}
+ @Test
public void testSetMode_bidirectional() throws IOException {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
builder.setUrl("https://www.example.com");
@@ -143,6 +157,7 @@ public class HttpUrlConnectionBuilderTests extends AndroidTestCase {
assertTrue(connection.getDoOutput());
}
+ @Test
public void testSetAuthToken() throws IOException {
HttpUrlConnectionBuilder builder = new HttpUrlConnectionBuilder();
builder.setUrl("https://www.example.com");
diff --git a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
index 559f28642..68f041589 100644
--- a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
@@ -16,13 +16,23 @@
package com.android.inputmethod.latin.personalization;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.LargeTest;
+import static org.junit.Assert.assertTrue;
+
+import android.content.Context;
import android.util.Log;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.LargeTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.latin.ExpandableBinaryDictionary;
import com.android.inputmethod.latin.utils.BinaryDictionaryUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.io.File;
import java.util.Locale;
import java.util.Random;
@@ -31,13 +41,18 @@ import java.util.Random;
* Unit tests for UserHistoryDictionary
*/
@LargeTest
-public class UserHistoryDictionaryTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class UserHistoryDictionaryTests {
private static final String TAG = UserHistoryDictionaryTests.class.getSimpleName();
private static final int WAIT_FOR_WRITING_FILE_IN_MILLISECONDS = 3000;
private static final String TEST_ACCOUNT = "account@example.com";
private int mCurrentTime = 0;
+ private Context getContext() {
+ return InstrumentationRegistry.getTargetContext();
+ }
+
private static void printAllFiles(final File dir) {
Log.d(TAG, dir.getAbsolutePath());
for (final File file : dir.listFiles()) {
@@ -62,20 +77,18 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
assertTrue("Following dictionary file doesn't exist: " + dictFile, dictFile.exists());
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
resetCurrentTimeForTestMode();
UserHistoryDictionaryTestsHelper.removeAllTestDictFiles(
- UserHistoryDictionaryTestsHelper.TEST_LOCALE_PREFIX, mContext);
+ UserHistoryDictionaryTestsHelper.TEST_LOCALE_PREFIX, getContext());
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
UserHistoryDictionaryTestsHelper.removeAllTestDictFiles(
- UserHistoryDictionaryTestsHelper.TEST_LOCALE_PREFIX, mContext);
+ UserHistoryDictionaryTestsHelper.TEST_LOCALE_PREFIX, getContext());
stopTestModeInNativeCode();
- super.tearDown();
}
private void resetCurrentTimeForTestMode() {
@@ -111,7 +124,7 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
null /* dictFile */,
testAccount /* account */);
final File dictFile = ExpandableBinaryDictionary.getDictFile(
- mContext, dictName, null /* dictFile */);
+ getContext(), dictName, null /* dictFile */);
final UserHistoryDictionary dict = PersonalizationHelper.getUserHistoryDictionary(
getContext(), dummyLocale, testAccount);
clearHistory(dict);
@@ -123,18 +136,22 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
assertDictionaryExists(dict, dictFile);
}
+ @Test
public void testRandomWords_NullAccount() {
doTestRandomWords(null /* testAccount */);
}
+ @Test
public void testRandomWords() {
doTestRandomWords(TEST_ACCOUNT);
}
+ @Test
public void testStressTestForSwitchingLanguagesAndAddingWords() {
doTestStressTestForSwitchingLanguagesAndAddingWords(TEST_ACCOUNT);
}
+ @Test
public void testStressTestForSwitchingLanguagesAndAddingWords_NullAccount() {
doTestStressTestForSwitchingLanguagesAndAddingWords(null /* testAccount */);
}
@@ -158,7 +175,7 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
UserHistoryDictionary.NAME, dummyLocale, null /* dictFile */,
testAccount /* account */);
dictFiles[i] = ExpandableBinaryDictionary.getDictFile(
- mContext, dictName, null /* dictFile */);
+ getContext(), dictName, null /* dictFile */);
dicts[i] = PersonalizationHelper.getUserHistoryDictionary(getContext(),
dummyLocale, testAccount);
clearHistory(dicts[i]);
@@ -186,10 +203,12 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
}
}
+ @Test
public void testAddManyWords() {
doTestAddManyWords(TEST_ACCOUNT);
}
+ @Test
public void testAddManyWords_NullAccount() {
doTestAddManyWords(null /* testAccount */);
}
@@ -200,7 +219,7 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
final String dictName = UserHistoryDictionary.getUserHistoryDictName(
UserHistoryDictionary.NAME, dummyLocale, null /* dictFile */, testAccount);
final File dictFile = ExpandableBinaryDictionary.getDictFile(
- mContext, dictName, null /* dictFile */);
+ getContext(), dictName, null /* dictFile */);
final int numberOfWords = 10000;
final Random random = new Random(123456);
final UserHistoryDictionary dict = PersonalizationHelper.getUserHistoryDictionary(
diff --git a/tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java b/tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java
index f2d8973f7..667ffd1ae 100644
--- a/tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java
+++ b/tests/src/com/android/inputmethod/latin/settings/AccountsSettingsFragmentTests.java
@@ -16,6 +16,9 @@
package com.android.inputmethod.latin.settings;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
@@ -23,13 +26,19 @@ import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
-import android.test.ActivityInstrumentationTestCase2;
-import android.test.suitebuilder.annotation.MediumTest;
import android.view.View;
import android.widget.ListView;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.MediumTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.latin.utils.ManagedProfileUtils;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -37,36 +46,41 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@MediumTest
-public class AccountsSettingsFragmentTests
- extends ActivityInstrumentationTestCase2<TestFragmentActivity> {
+@RunWith(AndroidJUnit4.class)
+public class AccountsSettingsFragmentTests {
private static final String FRAG_NAME = AccountsSettingsFragment.class.getName();
private static final long TEST_TIMEOUT_MILLIS = 5000;
@Mock private ManagedProfileUtils mManagedProfileUtils;
- public AccountsSettingsFragmentTests() {
- super(TestFragmentActivity.class);
+ private TestFragmentActivity mActivity;
+ private TestFragmentActivity getActivity() {
+ return mActivity;
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
// Initialize the mocks.
MockitoAnnotations.initMocks(this);
ManagedProfileUtils.setTestInstance(mManagedProfileUtils);
- Intent intent = new Intent();
- intent.putExtra(TestFragmentActivity.EXTRA_SHOW_FRAGMENT, FRAG_NAME);
- setActivityIntent(intent);
+ final Intent intent = new Intent()
+ .setAction(Intent.ACTION_MAIN)
+ .setClass(InstrumentationRegistry.getTargetContext(), TestFragmentActivity.class)
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
+ .addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
+ .putExtra(TestFragmentActivity.EXTRA_SHOW_FRAGMENT, FRAG_NAME);
+ mActivity = (TestFragmentActivity) InstrumentationRegistry.getInstrumentation()
+ .startActivitySync(intent);
}
- @Override
+ @After
public void tearDown() throws Exception {
ManagedProfileUtils.setTestInstance(null);
- super.tearDown();
+ mActivity = null;
}
+ @Test
public void testEmptyAccounts() {
final AccountsSettingsFragment fragment =
(AccountsSettingsFragment) getActivity().mFragment;
@@ -83,6 +97,7 @@ public class AccountsSettingsFragmentTests
DialogHolder() {}
}
+ @Test
public void testMultipleAccounts_noSettingsForManagedProfile() {
when(mManagedProfileUtils.hasWorkProfile(any(Context.class))).thenReturn(true);
@@ -95,6 +110,7 @@ public class AccountsSettingsFragmentTests
assertNull(fragment.findPreference(AccountsSettingsFragment.PREF_ACCCOUNT_SWITCHER));
}
+ @Test
public void testMultipleAccounts_noCurrentAccount() {
when(mManagedProfileUtils.hasWorkProfile(any(Context.class))).thenReturn(false);
@@ -116,6 +132,7 @@ public class AccountsSettingsFragmentTests
dialog.getButton(DialogInterface.BUTTON_POSITIVE).getVisibility());
}
+ @Test
public void testMultipleAccounts_currentAccount() {
when(mManagedProfileUtils.hasWorkProfile(any(Context.class))).thenReturn(false);
@@ -164,7 +181,7 @@ public class AccountsSettingsFragmentTests
} catch (InterruptedException ex) {
fail();
}
- getInstrumentation().waitForIdleSync();
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync();
return dialogHolder;
}
}
diff --git a/tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java b/tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java
index ed632db68..df44fba67 100644
--- a/tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java
+++ b/tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java
@@ -16,9 +16,17 @@
package com.android.inputmethod.latin.settings;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import android.content.Context;
import android.content.res.Resources;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.SuggestedWords;
import com.android.inputmethod.latin.common.Constants;
@@ -26,15 +34,24 @@ import com.android.inputmethod.latin.utils.RunInLocale;
import junit.framework.AssertionFailedError;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.Locale;
@SmallTest
-public class SpacingAndPunctuationsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class SpacingAndPunctuationsTests {
private static final int ARMENIAN_FULL_STOP = '\u0589';
private static final int ARMENIAN_COMMA = '\u055D';
private int mScreenMetrics;
+ private Context getContext() {
+ return InstrumentationRegistry.getTargetContext();
+ }
+
private boolean isPhone() {
return Constants.isPhone(mScreenMetrics);
}
@@ -63,10 +80,8 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase {
private SpacingAndPunctuations CAMBODIA_KHMER;
private SpacingAndPunctuations LAOS_LAO;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public void setUp() throws Exception {
mScreenMetrics = Settings.readScreenMetrics(getContext().getResources());
// Language only
@@ -140,6 +155,7 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase {
assertFalse("Tilde", sp.isWordSeparator('~'));
}
+ @Test
public void testWordSeparator() {
testingStandardWordSeparator(ENGLISH);
testingStandardWordSeparator(FRENCH);
@@ -192,6 +208,7 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase {
}
+ @Test
public void testWordConnector() {
testingStandardWordConnector(ENGLISH);
testingStandardWordConnector(FRENCH);
@@ -245,6 +262,7 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase {
assertFalse("Question", sp.isUsuallyPrecededBySpace('?'));
}
+ @Test
public void testIsUsuallyPrecededBySpace() {
testingStandardPrecededBySpace(ENGLISH);
testingCommonPrecededBySpace(FRENCH);
@@ -298,6 +316,7 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase {
assertFalse("Tilde", sp.isUsuallyFollowedBySpace('~'));
}
+ @Test
public void testIsUsuallyFollowedBySpace() {
testingStandardFollowedBySpace(ENGLISH);
testingStandardFollowedBySpace(FRENCH);
@@ -345,7 +364,8 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase {
assertFalse("Tilde", sp.isUsuallyFollowedBySpace('~'));
}
- public void isSentenceSeparator() {
+ @Test
+ public void testIsSentenceSeparator() {
testingStandardSentenceSeparator(ENGLISH);
try {
testingStandardSentenceSeparator(ARMENIA_ARMENIAN);
@@ -357,6 +377,7 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase {
assertFalse(ARMENIA_ARMENIAN.isSentenceSeparator(ARMENIAN_COMMA));
}
+ @Test
public void testLanguageHasSpace() {
assertTrue(ENGLISH.mCurrentLanguageHasSpaces);
assertTrue(FRENCH.mCurrentLanguageHasSpaces);
@@ -369,6 +390,7 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase {
assertTrue(LAO.mCurrentLanguageHasSpaces);
}
+ @Test
public void testUsesAmericanTypography() {
assertTrue(ENGLISH.mUsesAmericanTypography);
assertTrue(UNITED_STATES.mUsesAmericanTypography);
@@ -379,6 +401,7 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase {
assertFalse(SWISS_GERMAN.mUsesAmericanTypography);
}
+ @Test
public void testUsesGermanRules() {
assertFalse(ENGLISH.mUsesGermanRules);
assertFalse(FRENCH.mUsesGermanRules);
@@ -436,6 +459,7 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase {
}
}
+ @Test
public void testPhonePunctuationSuggestions() {
if (!isPhone()) {
return;
@@ -454,6 +478,7 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase {
PUNCTUATION_LABELS_PHONE, PUNCTUATION_WORDS_PHONE_HEBREW);
}
+ @Test
public void testTabletPunctuationSuggestions() {
if (!isTablet()) {
return;
diff --git a/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java b/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java
index f3273a2d1..3706574ef 100644
--- a/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java
+++ b/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java
@@ -16,13 +16,22 @@
package com.android.inputmethod.latin.suggestions;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static junit.framework.TestCase.assertEquals;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.SuggestedWords;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
@SmallTest
-public class SuggestionStripLayoutHelperTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class SuggestionStripLayoutHelperTests {
private static void confirmShowTypedWord(final String message, final int inputType) {
assertFalse(message, SuggestionStripLayoutHelper.shouldOmitTypedWord(
inputType,
@@ -42,6 +51,7 @@ public class SuggestionStripLayoutHelperTests extends AndroidTestCase {
true /* shouldShowUiToAcceptTypedWord */));
}
+ @Test
public void testShouldShowTypedWord() {
confirmShowTypedWord("no input style",
SuggestedWords.INPUT_STYLE_NONE);
@@ -51,7 +61,8 @@ public class SuggestionStripLayoutHelperTests extends AndroidTestCase {
SuggestedWords.INPUT_STYLE_RECORRECTION);
}
- public void testshouldOmitTypedWordWhileTyping() {
+ @Test
+ public void testShouldOmitTypedWordWhileTyping() {
assertFalse("typing", SuggestionStripLayoutHelper.shouldOmitTypedWord(
SuggestedWords.INPUT_STYLE_TYPING,
false /* gestureFloatingPreviewTextEnabled */,
@@ -70,7 +81,8 @@ public class SuggestionStripLayoutHelperTests extends AndroidTestCase {
true /* shouldShowUiToAcceptTypedWord */));
}
- public void testshouldOmitTypedWordWhileGesturing() {
+ @Test
+ public void testShouldOmitTypedWordWhileGesturing() {
assertFalse("gesturing", SuggestionStripLayoutHelper.shouldOmitTypedWord(
SuggestedWords.INPUT_STYLE_UPDATE_BATCH,
false /* gestureFloatingPreviewTextEnabled */,
@@ -89,7 +101,8 @@ public class SuggestionStripLayoutHelperTests extends AndroidTestCase {
true /* shouldShowUiToAcceptTypedWord */));
}
- public void testshouldOmitTypedWordWhenGestured() {
+ @Test
+ public void testShouldOmitTypedWordWhenGestured() {
assertFalse("gestured", SuggestionStripLayoutHelper.shouldOmitTypedWord(
SuggestedWords.INPUT_STYLE_TAIL_BATCH,
false /* gestureFloatingPreviewTextEnabled */,
@@ -115,6 +128,7 @@ public class SuggestionStripLayoutHelperTests extends AndroidTestCase {
private static final int POSITION_CENTER = 1;
private static final int POSITION_RIGHT = 2;
+ @Test
public void testGetPositionInSuggestionStrip() {
assertEquals("1st word without auto correction", POSITION_CENTER,
SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
diff --git a/tests/src/com/android/inputmethod/latin/touchinputconsumer/NullGestureConsumerTests.java b/tests/src/com/android/inputmethod/latin/touchinputconsumer/NullGestureConsumerTests.java
index ad6bcc3c4..986c8e3dd 100644
--- a/tests/src/com/android/inputmethod/latin/touchinputconsumer/NullGestureConsumerTests.java
+++ b/tests/src/com/android/inputmethod/latin/touchinputconsumer/NullGestureConsumerTests.java
@@ -16,18 +16,26 @@
package com.android.inputmethod.latin.touchinputconsumer;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertSame;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
/**
* Tests for GestureConsumer.NULL_GESTURE_CONSUMER.
*/
@SmallTest
-public class NullGestureConsumerTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class NullGestureConsumerTests {
/**
* Tests that GestureConsumer.NULL_GESTURE_CONSUMER indicates that it won't consume gesture data
* and that its methods don't raise exceptions even for invalid data.
*/
+ @Test
public void testNullGestureConsumer() {
assertFalse(GestureConsumer.NULL_GESTURE_CONSUMER.willConsume());
GestureConsumer.NULL_GESTURE_CONSUMER.onInit(null, null);
@@ -40,6 +48,7 @@ public class NullGestureConsumerTests extends AndroidTestCase {
/**
* Tests that newInstance returns NULL_GESTURE_CONSUMER for invalid input.
*/
+ @Test
public void testNewInstanceGivesNullGestureConsumerForInvalidInputs() {
assertSame(GestureConsumer.NULL_GESTURE_CONSUMER,
GestureConsumer.newInstance(null, null, null, null));
diff --git a/tests/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtilsTests.java
index 1db839506..08c404e12 100644
--- a/tests/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtilsTests.java
@@ -16,25 +16,36 @@
package com.android.inputmethod.latin.utils;
-import static com.android.inputmethod.latin.common.Constants.Subtype.KEYBOARD_MODE;
import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.ASCII_CAPABLE;
import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.EMOJI_CAPABLE;
import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.IS_ADDITIONAL_SUBTYPE;
import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET;
import static com.android.inputmethod.latin.common.Constants.Subtype.ExtraValue.UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME;
+import static com.android.inputmethod.latin.common.Constants.Subtype.KEYBOARD_MODE;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import android.content.Context;
import android.os.Build;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
import android.view.inputmethod.InputMethodSubtype;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.Locale;
@SmallTest
-public class AdditionalSubtypeUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class AdditionalSubtypeUtilsTests {
/**
* Predictable subtype ID for en_US dvorak layout. This is actually a hash code calculated as
@@ -98,10 +109,9 @@ public class AdditionalSubtypeUtilsTests extends AndroidTestCase {
",EmojiCapable" +
",isAdditionalSubtype";
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- final Context context = getContext();
+ @Before
+ public void setUp() throws Exception {
+ final Context context = InstrumentationRegistry.getTargetContext();
SubtypeLocaleUtils.init(context);
}
@@ -149,6 +159,7 @@ public class AdditionalSubtypeUtilsTests extends AndroidTestCase {
assertEquals(SUBTYPE_ID_ZZ_AZERTY, subtype.hashCode());
}
+ @Test
public void testRestorable() {
final InputMethodSubtype EN_US_DVORAK =
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
diff --git a/tests/src/com/android/inputmethod/latin/utils/AsyncResultHolderTests.java b/tests/src/com/android/inputmethod/latin/utils/AsyncResultHolderTests.java
index c214b5fd0..f53780543 100644
--- a/tests/src/com/android/inputmethod/latin/utils/AsyncResultHolderTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/AsyncResultHolderTests.java
@@ -16,12 +16,19 @@
package com.android.inputmethod.latin.utils;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
+import static org.junit.Assert.assertEquals;
+
import android.util.Log;
+import androidx.test.filters.MediumTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
@MediumTest
-public class AsyncResultHolderTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class AsyncResultHolderTests {
static final String TAG = AsyncResultHolderTests.class.getSimpleName();
private static final int TIMEOUT_IN_MILLISECONDS = 500;
@@ -44,12 +51,14 @@ public class AsyncResultHolderTests extends AndroidTestCase {
}).start();
}
+ @Test
public void testGetWithoutSet() {
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
final int resultValue = holder.get(DEFAULT_VALUE, TIMEOUT_IN_MILLISECONDS);
assertEquals(DEFAULT_VALUE, resultValue);
}
+ @Test
public void testGetBeforeSet() {
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
setAfterGivenTime(holder, SET_VALUE, TIMEOUT_IN_MILLISECONDS + MARGIN_IN_MILLISECONDS);
@@ -57,6 +66,7 @@ public class AsyncResultHolderTests extends AndroidTestCase {
assertEquals(DEFAULT_VALUE, resultValue);
}
+ @Test
public void testGetAfterSet() {
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
holder.set(SET_VALUE);
@@ -64,6 +74,7 @@ public class AsyncResultHolderTests extends AndroidTestCase {
assertEquals(SET_VALUE, resultValue);
}
+ @Test
public void testGetBeforeTimeout() {
final AsyncResultHolder<Integer> holder = new AsyncResultHolder<>("Test");
setAfterGivenTime(holder, SET_VALUE, TIMEOUT_IN_MILLISECONDS - MARGIN_IN_MILLISECONDS);
diff --git a/tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java
index 9680d85b3..4aac7fc41 100644
--- a/tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java
@@ -16,18 +16,27 @@
package com.android.inputmethod.latin.utils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
import android.content.res.Resources;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
import android.text.TextUtils;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.latin.common.LocaleUtils;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.Locale;
@SmallTest
-public class CapsModeUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class CapsModeUtilsTests {
private static void onePathForCaps(final CharSequence cs, final int expectedResult,
final int mask, final SpacingAndPunctuations sp, final boolean hasSpaceBefore) {
final int oneTimeResult = expectedResult & mask;
@@ -49,6 +58,7 @@ public class CapsModeUtilsTests extends AndroidTestCase {
onePathForCaps(cs, expectedResult, s, sp, hasSpaceBefore);
}
+ @Test
public void testGetCapsMode() {
final int c = TextUtils.CAP_MODE_CHARACTERS;
final int w = TextUtils.CAP_MODE_WORDS;
@@ -59,7 +69,7 @@ public class CapsModeUtilsTests extends AndroidTestCase {
return new SpacingAndPunctuations(res);
}
};
- final Resources res = getContext().getResources();
+ final Resources res = InstrumentationRegistry.getTargetContext().getResources();
SpacingAndPunctuations sp = job.runInLocale(res, Locale.ENGLISH);
allPathsForCaps("", c | w | s, sp, false);
allPathsForCaps("Word", c, sp, false);
diff --git a/tests/src/com/android/inputmethod/latin/utils/CollectionUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/CollectionUtilsTests.java
index 0cbb02c4f..da23c9cb8 100644
--- a/tests/src/com/android/inputmethod/latin/utils/CollectionUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/CollectionUtilsTests.java
@@ -16,11 +16,19 @@
package com.android.inputmethod.latin.utils;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.common.CollectionUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -32,11 +40,13 @@ import java.util.Map;
* Tests for {@link CollectionUtils}.
*/
@SmallTest
-public class CollectionUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class CollectionUtilsTests {
/**
* Tests that {@link CollectionUtils#arrayAsList(Object[],int,int)} fails as expected
* with some invalid inputs.
*/
+ @Test
public void testArrayAsListFailure() {
final String[] array = { "0", "1" };
// Negative start
@@ -66,6 +76,7 @@ public class CollectionUtilsTests extends AndroidTestCase {
* Tests that {@link CollectionUtils#arrayAsList(Object[],int,int)} gives the expected
* results for a few valid inputs.
*/
+ @Test
public void testArrayAsList() {
final ArrayList<String> empty = new ArrayList<>();
assertEquals(empty, CollectionUtils.arrayAsList(new String[] {}, 0, 0));
@@ -81,6 +92,7 @@ public class CollectionUtilsTests extends AndroidTestCase {
* Tests that {@link CollectionUtils#isNullOrEmpty(java.util.Collection)} gives the expected
* results for a few cases.
*/
+ @Test
public void testIsNullOrEmpty() {
assertTrue(CollectionUtils.isNullOrEmpty((List<String>) null));
assertTrue(CollectionUtils.isNullOrEmpty((Map<String, String>) null));
diff --git a/tests/src/com/android/inputmethod/latin/utils/DictionaryInfoUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/DictionaryInfoUtilsTests.java
index 812353cc4..2112f985a 100644
--- a/tests/src/com/android/inputmethod/latin/utils/DictionaryInfoUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/DictionaryInfoUtilsTests.java
@@ -16,17 +16,28 @@
package com.android.inputmethod.latin.utils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import android.content.res.Resources;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.common.LocaleUtils;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.Locale;
@SmallTest
-public class DictionaryInfoUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class DictionaryInfoUtilsTests {
+ @Test
public void testLooksValidForDictionaryInsertion() {
final RunInLocale<SpacingAndPunctuations> job = new RunInLocale<SpacingAndPunctuations>() {
@Override
@@ -34,7 +45,7 @@ public class DictionaryInfoUtilsTests extends AndroidTestCase {
return new SpacingAndPunctuations(res);
}
};
- final Resources res = getContext().getResources();
+ final Resources res = InstrumentationRegistry.getTargetContext().getResources();
final SpacingAndPunctuations sp = job.runInLocale(res, Locale.ENGLISH);
assertTrue(DictionaryInfoUtils.looksValidForDictionaryInsertion("aochaueo", sp));
assertFalse(DictionaryInfoUtils.looksValidForDictionaryInsertion("", sp));
@@ -46,6 +57,7 @@ public class DictionaryInfoUtilsTests extends AndroidTestCase {
assertFalse(DictionaryInfoUtils.looksValidForDictionaryInsertion("!!!", sp));
}
+ @Test
public void testGetMainDictId() {
assertEquals("main:en",
DictionaryInfoUtils.getMainDictId(LocaleUtils.constructLocaleFromString("en")));
diff --git a/tests/src/com/android/inputmethod/latin/utils/ExecutorUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/ExecutorUtilsTests.java
index 86923059b..7c9b3e6ca 100644
--- a/tests/src/com/android/inputmethod/latin/utils/ExecutorUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/ExecutorUtilsTests.java
@@ -16,10 +16,16 @@
package com.android.inputmethod.latin.utils;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
+import static org.junit.Assert.assertEquals;
+
import android.util.Log;
+import androidx.test.filters.MediumTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@@ -28,12 +34,14 @@ import java.util.concurrent.atomic.AtomicInteger;
* Unit tests for {@link ExecutorUtils}.
*/
@MediumTest
-public class ExecutorUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class ExecutorUtilsTests {
private static final String TAG = ExecutorUtilsTests.class.getSimpleName();
private static final int NUM_OF_TASKS = 10;
private static final int DELAY_FOR_WAITING_TASKS_MILLISECONDS = 500;
+ @Test
public void testExecute() {
final ExecutorService executor =
ExecutorUtils.getBackgroundExecutor(ExecutorUtils.KEYBOARD);
diff --git a/tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java
index df0180729..9d9a541b7 100644
--- a/tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/ImportantNoticeUtilsTests.java
@@ -17,32 +17,41 @@
package com.android.inputmethod.latin.utils;
import static com.android.inputmethod.latin.utils.ImportantNoticeUtils.KEY_TIMESTAMP_OF_CONTACTS_NOTICE;
+
+import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.SharedPreferences;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.MediumTest;
-import android.text.TextUtils;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.MediumTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.settings.SettingsValues;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
-import java.util.concurrent.TimeUnit;
-
@MediumTest
-public class ImportantNoticeUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class ImportantNoticeUtilsTests {
private ImportantNoticePreferences mImportantNoticePreferences;
@Mock private SettingsValues mMockSettingsValues;
+ private Context getContext() {
+ return InstrumentationRegistry.getTargetContext();
+ }
+
private static class ImportantNoticePreferences {
private final SharedPreferences mPref;
- private Integer mVersion;
private Long mLastTime;
public ImportantNoticePreferences(final Context context) {
@@ -96,21 +105,20 @@ public class ImportantNoticeUtilsTests extends AndroidTestCase {
}
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
mImportantNoticePreferences = new ImportantNoticePreferences(getContext());
mImportantNoticePreferences.save();
when(mMockSettingsValues.isPersonalizationEnabled()).thenReturn(true);
}
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
+ @After
+ public void tearDown() throws Exception {
mImportantNoticePreferences.restore();
}
+ @Test
public void testPersonalizationSetting() {
mImportantNoticePreferences.clear();
diff --git a/tests/src/com/android/inputmethod/latin/utils/JsonUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/JsonUtilsTests.java
index 194112070..fd5e0a4d7 100644
--- a/tests/src/com/android/inputmethod/latin/utils/JsonUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/JsonUtilsTests.java
@@ -16,14 +16,21 @@
package com.android.inputmethod.latin.utils;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertEquals;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
import java.util.Arrays;
import java.util.List;
@SmallTest
-public class JsonUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class JsonUtilsTests {
+ @Test
public void testJsonUtils() {
final Object[] objs = new Object[] { 1, "aaa", "bbb", 3 };
final List<Object> objArray = Arrays.asList(objs);
diff --git a/tests/src/com/android/inputmethod/latin/utils/LanguageOnSpacebarUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/LanguageOnSpacebarUtilsTests.java
index e4b6a668c..58e26e8d6 100644
--- a/tests/src/com/android/inputmethod/latin/utils/LanguageOnSpacebarUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/LanguageOnSpacebarUtilsTests.java
@@ -20,24 +20,33 @@ import static com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils.FORMAT
import static com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils.FORMAT_TYPE_LANGUAGE_ONLY;
import static com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils.FORMAT_TYPE_NONE;
+import static org.junit.Assert.assertEquals;
+
import android.content.Context;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
import android.view.inputmethod.InputMethodSubtype;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.LanguageOnSpacebarUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.ArrayList;
import java.util.Locale;
import javax.annotation.Nonnull;
@SmallTest
-public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class LanguageOnSpacebarUtilsTests {
private RichInputMethodManager mRichImm;
RichInputMethodSubtype EN_US_QWERTY;
@@ -50,10 +59,9 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
RichInputMethodSubtype IW_HEBREW;
RichInputMethodSubtype ZZ_QWERTY;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- final Context context = getContext();
+ @Before
+ public void setUp() throws Exception {
+ final Context context = InstrumentationRegistry.getTargetContext();
RichInputMethodManager.init(context);
mRichImm = RichInputMethodManager.getInstance();
@@ -99,6 +107,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
LanguageOnSpacebarUtils.getLanguageOnSpacebarFormatType(subtype));
}
+ @Test
public void testOneSubtypeImplicitlyEnabled() {
enableSubtypes(EN_US_QWERTY);
assertFormatType(EN_US_QWERTY, true, Locale.US, FORMAT_TYPE_NONE);
@@ -113,6 +122,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
assertFormatType(FR_CA_QWERTY, true, Locale.CANADA_FRENCH, FORMAT_TYPE_NONE);
}
+ @Test
public void testOneSubtypeExplicitlyEnabled() {
enableSubtypes(EN_US_QWERTY);
assertFormatType(EN_US_QWERTY, false, Locale.UK, FORMAT_TYPE_LANGUAGE_ONLY);
@@ -131,6 +141,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
assertFormatType(FR_CA_QWERTY, false, Locale.FRANCE, FORMAT_TYPE_LANGUAGE_ONLY);
}
+ @Test
public void testOneSubtypeImplicitlyEnabledWithNoLanguageSubtype() {
final Locale Locale_IW = new Locale("iw");
enableSubtypes(IW_HEBREW, ZZ_QWERTY);
@@ -140,6 +151,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
assertFormatType(ZZ_QWERTY, true, Locale_IW, FORMAT_TYPE_FULL_LOCALE);
}
+ @Test
public void testTwoSubtypesExplicitlyEnabled() {
enableSubtypes(EN_US_QWERTY, FR_AZERTY);
assertFormatType(EN_US_QWERTY, false, Locale.US, FORMAT_TYPE_LANGUAGE_ONLY);
@@ -157,6 +169,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
}
+ @Test
public void testMultiSubtypeWithSameLanuageAndSameLayout() {
// Explicitly enable en_US, en_GB, fr_FR, and no language keyboards.
enableSubtypes(EN_US_QWERTY, EN_GB_QWERTY, FR_CA_QWERTY, ZZ_QWERTY);
@@ -172,6 +185,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
assertFormatType(ZZ_QWERTY, false, Locale.JAPAN, FORMAT_TYPE_FULL_LOCALE);
}
+ @Test
public void testMultiSubtypesWithSameLanguageButHaveDifferentLayout() {
enableSubtypes(FR_AZERTY, FR_CA_QWERTY, FR_CH_SWISS, FR_CH_QWERTZ);
@@ -191,6 +205,7 @@ public class LanguageOnSpacebarUtilsTests extends AndroidTestCase {
assertFormatType(FR_CH_QWERTZ, false, Locale.JAPAN, FORMAT_TYPE_LANGUAGE_ONLY);
}
+ @Test
public void testMultiSubtypesWithSameLanguageAndMayHaveSameLayout() {
enableSubtypes(FR_AZERTY, FR_CA_QWERTY, FR_CH_SWISS, FR_CH_QWERTY, FR_CH_QWERTZ);
diff --git a/tests/src/com/android/inputmethod/latin/utils/RecapitalizeStatusTests.java b/tests/src/com/android/inputmethod/latin/utils/RecapitalizeStatusTests.java
index 9b826839f..0908f2b54 100644
--- a/tests/src/com/android/inputmethod/latin/utils/RecapitalizeStatusTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/RecapitalizeStatusTests.java
@@ -16,17 +16,24 @@
package com.android.inputmethod.latin.utils;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertEquals;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
import com.android.inputmethod.latin.common.Constants;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.Locale;
@SmallTest
-public class RecapitalizeStatusTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class RecapitalizeStatusTests {
private static final int[] SPACE = { Constants.CODE_SPACE };
+ @Test
public void testTrim() {
final RecapitalizeStatus status = new RecapitalizeStatus();
status.start(30, 40, "abcdefghij", Locale.ENGLISH, SPACE);
@@ -54,6 +61,7 @@ public class RecapitalizeStatusTests extends AndroidTestCase {
assertEquals(43, status.getNewCursorEnd());
}
+ @Test
public void testRotate() {
final RecapitalizeStatus status = new RecapitalizeStatus();
status.start(29, 40, "abcd efghij", Locale.ENGLISH, SPACE);
diff --git a/tests/src/com/android/inputmethod/latin/utils/ResourceUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/ResourceUtilsTests.java
index 8e764e40f..4aab96a55 100644
--- a/tests/src/com/android/inputmethod/latin/utils/ResourceUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/ResourceUtilsTests.java
@@ -16,13 +16,21 @@
package com.android.inputmethod.latin.utils;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
import java.util.HashMap;
@SmallTest
-public class ResourceUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class ResourceUtilsTests {
+ @Test
public void testFindConstantForKeyValuePairsSimple() {
final HashMap<String,String> anyKeyValue = new HashMap<>();
anyKeyValue.put("anyKey", "anyValue");
@@ -69,6 +77,7 @@ public class ResourceUtilsTests extends AndroidTestCase {
assertNull(ResourceUtils.findConstantForKeyValuePairs(emptyKeyValue, array));
}
+ @Test
public void testFindConstantForKeyValuePairsCombined() {
final String HARDWARE_KEY = "HARDWARE";
final String MODEL_KEY = "MODEL";
@@ -113,6 +122,7 @@ public class ResourceUtilsTests extends AndroidTestCase {
assertEquals("0.2", ResourceUtils.findConstantForKeyValuePairs(keyValues, failArray));
}
+ @Test
public void testFindConstantForKeyValuePairsRegexp() {
final String HARDWARE_KEY = "HARDWARE";
final String MODEL_KEY = "MODEL";
diff --git a/tests/src/com/android/inputmethod/latin/utils/SpannableStringUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/SpannableStringUtilsTests.java
index 665d81ccd..a5987cf13 100644
--- a/tests/src/com/android/inputmethod/latin/utils/SpannableStringUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/SpannableStringUtilsTests.java
@@ -16,17 +16,33 @@
package com.android.inputmethod.latin.utils;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
-import android.text.style.SuggestionSpan;
-import android.text.style.URLSpan;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import android.content.Context;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.SpannedString;
+import android.text.style.SuggestionSpan;
+import android.text.style.URLSpan;
+
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
@SmallTest
-public class SpannableStringUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class SpannableStringUtilsTests {
+
+ private Context getContext() {
+ return InstrumentationRegistry.getTargetContext();
+ }
+
+ @Test
public void testConcatWithSuggestionSpansOnly() {
SpannableStringBuilder s = new SpannableStringBuilder("test string\ntest string\n"
+ "test string\ntest string\ntest string\ntest string\ntest string\ntest string\n"
@@ -87,6 +103,7 @@ public class SpannableStringUtilsTests extends AndroidTestCase {
assertTrue(false);
}
+ @Test
public void testSplitCharSequenceWithSpan() {
// text: " a bcd efg hij "
// span1: ^^^^^^^
@@ -182,6 +199,7 @@ public class SpannableStringUtilsTests extends AndroidTestCase {
assertSpanCount(0, charSequencesFromSpanned[6]);
}
+ @Test
public void testSplitCharSequencePreserveTrailingEmptySegmengs() {
assertEquals(1, SpannableStringUtils.split("", " ",
false /* preserveTrailingEmptySegmengs */).length);
diff --git a/tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java
index 2297cacf8..6764fd880 100644
--- a/tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java
@@ -16,22 +16,35 @@
package com.android.inputmethod.latin.utils;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import android.content.Context;
import android.content.res.Resources;
-import android.test.AndroidTestCase;
-import android.test.suitebuilder.annotation.SmallTest;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
+import androidx.test.InstrumentationRegistry;
+import androidx.test.filters.SmallTest;
+import androidx.test.runner.AndroidJUnit4;
+
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.RichInputMethodSubtype;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
import java.util.ArrayList;
import java.util.Locale;
@SmallTest
-public class SubtypeLocaleUtilsTests extends AndroidTestCase {
+@RunWith(AndroidJUnit4.class)
+public class SubtypeLocaleUtilsTests {
// All input method subtypes of LatinIME.
private final ArrayList<RichInputMethodSubtype> mSubtypesList = new ArrayList<>();
@@ -64,10 +77,9 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
InputMethodSubtype HI_LATN_DVORAK; // Hinglis Dvorak
InputMethodSubtype SR_LATN_QWERTY; // Serbian Latin Qwerty
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- final Context context = getContext();
+ @Before
+ public void setUp() throws Exception {
+ final Context context = InstrumentationRegistry.getTargetContext();
mRes = context.getResources();
RichInputMethodManager.init(context);
mRichImm = RichInputMethodManager.getInstance();
@@ -136,13 +148,13 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
}
}
- @Override
- protected void tearDown() throws Exception {
+ @After
+ public void tearDown() throws Exception {
// Restore additional subtypes.
mRichImm.setAdditionalInputMethodSubtypes(mSavedAddtionalSubtypes);
- super.tearDown();
}
+ @Test
public void testAllFullDisplayName() {
for (final RichInputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils
@@ -159,6 +171,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
}
}
+ @Test
public void testKeyboardLayoutSetName() {
assertEquals("en_US", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(EN_US));
assertEquals("en_GB", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(EN_GB));
@@ -223,6 +236,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
// sr_ZZ qwerty T Serbian (QWERTY) exception
// zz pc T Alphabet (PC)
+ @Test
public void testPredefinedSubtypesInEnglishSystemLocale() {
final RunInLocale<Void> tests = new RunInLocale<Void>() {
@Override
@@ -264,6 +278,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
tests.runInLocale(mRes, Locale.ENGLISH);
}
+ @Test
public void testAdditionalSubtypesInEnglishSystemLocale() {
final RunInLocale<Void> tests = new RunInLocale<Void>() {
@Override
@@ -323,6 +338,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
// sr_ZZ qwerty T Serbe (QWERTY) exception
// zz pc T Alphabet latin (PC)
+ @Test
public void testPredefinedSubtypesInFrenchSystemLocale() {
final RunInLocale<Void> tests = new RunInLocale<Void>() {
@Override
@@ -364,6 +380,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
tests.runInLocale(mRes, Locale.FRENCH);
}
+ @Test
public void testAdditionalSubtypesInFrenchSystemLocale() {
final RunInLocale<Void> tests = new RunInLocale<Void>() {
@Override
@@ -405,6 +422,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
// hi_ZZ qwerty F हिंग्लिश
// hi_ZZ dvorak T हिंग्लिश (Dvorak)
+ @Test
public void testHinglishSubtypesInHindiSystemLocale() {
final RunInLocale<Void> tests = new RunInLocale<Void>() {
@Override
@@ -432,6 +450,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
// sr_ZZ serbian_qwertz F Српски (латиница)
// sr_ZZ qwerty T Српски (QWERTY)
+ @Test
public void testSerbianLatinSubtypesInSerbianSystemLocale() {
final RunInLocale<Void> tests = new RunInLocale<Void>() {
@Override
@@ -451,6 +470,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
tests.runInLocale(mRes, new Locale("sr"));
}
+ @Test
public void testIsRtlLanguage() {
// Known Right-to-Left language subtypes.
final InputMethodSubtype ARABIC = mRichImm
diff --git a/tools/Android.mk b/tools/Android.mk
deleted file mode 100644
index 91b2fbbb0..000000000
--- a/tools/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-include $(call all-subdir-makefiles)
diff --git a/tools/EditTextVariations/Android.bp b/tools/EditTextVariations/Android.bp
new file mode 100644
index 000000000..94b4951a7
--- /dev/null
+++ b/tools/EditTextVariations/Android.bp
@@ -0,0 +1,22 @@
+// Copyright (C) 2013 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+android_test {
+ name: "EditTextVariations",
+
+ srcs: ["src/**/*.java"],
+
+ sdk_version: "current",
+ min_sdk_version: "11",
+}
diff --git a/tools/EditTextVariations/AndroidManifest.xml b/tools/EditTextVariations/AndroidManifest.xml
new file mode 100644
index 000000000..96c244b32
--- /dev/null
+++ b/tools/EditTextVariations/AndroidManifest.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2010 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<manifest
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ package="com.android.inputmethod.tools.edittextvariations"
+ android:versionName="0.67"
+ android:versionCode="67"
+>
+ <supports-screens android:resizeable="true" />
+ <uses-sdk
+ android:targetSdkVersion="27"
+ android:minSdkVersion="11" />
+ <application
+ android:icon="@drawable/ic_launcher"
+ android:label="@string/app_name"
+ android:allowBackup="false"
+ >
+ <activity
+ android:name=".EditTextVariations"
+ android:windowSoftInputMode="stateHidden|adjustPan"
+ android:theme="@style/defaultActivityTheme"
+ android:label="@string/app_name"
+ >
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
+ </intent-filter>
+ </activity>
+ <receiver
+ android:name=".NotificationBroadcastReceiver"
+ android:exported="false" />
+ </application>
+</manifest>
diff --git a/tools/EditTextVariations/assets/Theme.css b/tools/EditTextVariations/assets/Theme.css
new file mode 100644
index 000000000..b7aa514bf
--- /dev/null
+++ b/tools/EditTextVariations/assets/Theme.css
@@ -0,0 +1,56 @@
+<!--
+/*
+**
+** Copyright 2014, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+body {
+ background-color: black;
+}
+div.placeholder {
+ color: #a0a0a0;
+ font-size: 18px;
+ margin: 0px 0px -34px 0px;
+ padding: 4px 0px 4px 0px
+}
+div.input {
+ border: none;
+ margin: 4px 0px 4px -8px;
+}
+input {
+ color: black;
+ background-color: white;
+ font-size: 18px;
+ line-height: 200%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: none;
+ border-right: none;
+ border-bottom: none;
+ border-left: none;
+}
+textarea {
+ color: black;
+ background-color: white;
+ font-size: 18px;
+ line-height: 150%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: none;
+ border-right: none;
+ border-bottom: none;
+ border-left: none;
+}
diff --git a/tools/EditTextVariations/assets/Theme_Black.css b/tools/EditTextVariations/assets/Theme_Black.css
new file mode 100644
index 000000000..ce663a180
--- /dev/null
+++ b/tools/EditTextVariations/assets/Theme_Black.css
@@ -0,0 +1,56 @@
+<!--
+/*
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+body {
+ background-color: black;
+}
+div.placeholder {
+ color: #a0a0a0;
+ font-size: 18px;
+ margin: 0px 0px -34px 0px;
+ padding: 4px 0px 4px 0px
+}
+div.input {
+ border: none;
+ margin: 4px 0px 4px -8px;
+}
+input {
+ color: black;
+ background-color: white;
+ font-size: 18px;
+ line-height: 200%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: none;
+ border-right: none;
+ border-bottom: none;
+ border-left: none;
+}
+textarea {
+ color: black;
+ background-color: white;
+ font-size: 18px;
+ line-height: 150%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: none;
+ border-right: none;
+ border-bottom: none;
+ border-left: none;
+}
diff --git a/tools/EditTextVariations/assets/Theme_Holo.css b/tools/EditTextVariations/assets/Theme_Holo.css
new file mode 100644
index 000000000..a3afe2e00
--- /dev/null
+++ b/tools/EditTextVariations/assets/Theme_Holo.css
@@ -0,0 +1,56 @@
+<!--
+/*
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+body {
+ background-color: #16191C;
+}
+div.placeholder {
+ color: #808080;
+ font-size: 18px;
+ margin: 0px 0px -34px 0px;
+ padding: 4px 0px 4px 0px
+}
+div.input {
+ border: none;
+ margin: 4px 0px 4px -8px;
+}
+input {
+ color: white;
+ background-color: rgba(0, 0, 0, 0.0);
+ font-size: 18px;
+ line-height: 180%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: none;
+ border-right: none;
+ border-bottom: 1px solid #5E6063;
+ border-left: none;
+}
+textarea {
+ color: white;
+ background-color: rgba(0, 0, 0, 0.0);
+ font-size: 18px;
+ line-height: 150%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: none;
+ border-right: none;
+ border-bottom: 1px solid #5E6063;
+ border-left: none;
+}
diff --git a/tools/EditTextVariations/assets/Theme_Holo_Light.css b/tools/EditTextVariations/assets/Theme_Holo_Light.css
new file mode 100644
index 000000000..fb3a83c69
--- /dev/null
+++ b/tools/EditTextVariations/assets/Theme_Holo_Light.css
@@ -0,0 +1,56 @@
+<!--
+/*
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+body {
+ background-color: #F2F2F2;
+}
+div.placeholder {
+ color: #808080;
+ font-size: 18px;
+ margin: 0px 0px -34px 0px;
+ padding: 4px 0px 4px 0px
+}
+div.input {
+ border: none;
+ margin: 4px 0px 4px -8px;
+}
+input {
+ color: black;
+ background-color: rgba(0, 0, 0, 0.0);
+ font-size: 18px;
+ line-height: 150%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: none;
+ border-right: none;
+ border-bottom: 1px solid #808080;
+ border-left: none;
+}
+textarea {
+ color: black;
+ background-color: rgba(0, 0, 0, 0.0);
+ font-size: 18px;
+ line-height: 150%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: none;
+ border-right: none;
+ border-bottom: 1px solid #808080;
+ border-left: none;
+}
diff --git a/tools/EditTextVariations/assets/Theme_Light.css b/tools/EditTextVariations/assets/Theme_Light.css
new file mode 100644
index 000000000..4cce0a002
--- /dev/null
+++ b/tools/EditTextVariations/assets/Theme_Light.css
@@ -0,0 +1,56 @@
+<!--
+/*
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+body {
+ background-color: #f3f3f3;
+}
+div.placeholder {
+ color: #a0a0a0;
+ font-size: 18px;
+ margin: 0px 0px -34px 0px;
+ padding: 4px 0px 4px 0px
+}
+div.input {
+ border: none;
+ margin: 4px 0px 4px -8px;
+}
+input {
+ color: black;
+ background-color: rgba(0, 0, 0, 0.0);
+ font-size: 18px;
+ line-height: 200%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: 1px solid #808080;
+ border-right: 1px solid rgba(0, 0, 0, 0.5);
+ border-bottom: 1px solid #808080;
+ border-left: 1px solid rgba(0, 0, 0, 0.5);
+}
+textarea {
+ color: black;
+ background-color: rgba(0, 0, 0, 0.0);
+ font-size: 18px;
+ line-height: 150%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: 1px solid #808080;
+ border-right: 1px solid rgba(0, 0, 0, 0.5);
+ border-bottom: 1px solid #808080;
+ border-left: 1px solid rgba(0, 0, 0, 0.5);
+}
diff --git a/tools/EditTextVariations/assets/Theme_Material.css b/tools/EditTextVariations/assets/Theme_Material.css
new file mode 100644
index 000000000..3581a8824
--- /dev/null
+++ b/tools/EditTextVariations/assets/Theme_Material.css
@@ -0,0 +1,56 @@
+<!--
+/*
+**
+** Copyright 2014, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+body {
+ background-color: #212121;
+}
+div.placeholder {
+ color: #909090;
+ font-size: 18px;
+ margin: 0px 0px -34px 0px;
+ padding: 4px 0px 4px 0px
+}
+div.input {
+ border: none;
+ margin: 4px 0px 4px -8px;
+}
+input {
+ color: white;
+ background-color: rgba(0, 0, 0, 0.0);
+ font-size: 18px;
+ line-height: 180%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: none;
+ border-right: none;
+ border-bottom: 1px solid #757575;
+ border-left: none;
+}
+textarea {
+ color: white;
+ background-color: rgba(0, 0, 0, 0.0);
+ font-size: 18px;
+ line-height: 150%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: none;
+ border-right: none;
+ border-bottom: 1px solid #757575;
+ border-left: none;
+}
diff --git a/tools/EditTextVariations/assets/Theme_Material_Light.css b/tools/EditTextVariations/assets/Theme_Material_Light.css
new file mode 100644
index 000000000..1a78a2d4a
--- /dev/null
+++ b/tools/EditTextVariations/assets/Theme_Material_Light.css
@@ -0,0 +1,56 @@
+<!--
+/*
+**
+** Copyright 2014, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+body {
+ background-color: #FAFAFA;
+}
+div.placeholder {
+ color: #7D7D7D;
+ font-size: 18px;
+ margin: 0px 0px -34px 0px;
+ padding: 4px 0px 4px 0px
+}
+div.input {
+ border: none;
+ margin: 4px 0px 4px -8px;
+}
+input {
+ color: white;
+ background-color: rgba(0, 0, 0, 0.0);
+ font-size: 18px;
+ line-height: 180%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: none;
+ border-right: none;
+ border-bottom: 1px solid #737373;
+ border-left: none;
+}
+textarea {
+ color: white;
+ background-color: rgba(0, 0, 0, 0.0);
+ font-size: 18px;
+ line-height: 150%;
+ vertical-align: center;
+ padding-left: 8px;
+ border-top: none;
+ border-right: none;
+ border-bottom: 1px solid #737373;
+ border-left: none;
+}
diff --git a/tools/EditTextVariations/assets/webview.html b/tools/EditTextVariations/assets/webview.html
new file mode 100644
index 000000000..daf0fdb73
--- /dev/null
+++ b/tools/EditTextVariations/assets/webview.html
@@ -0,0 +1,96 @@
+<!--
+/*
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<html>
+ <head>
+ <script type="text/javascript">
+ (function(d, name) {
+ var css = document.createElement('link');
+ css.rel = 'stylesheet';
+ css.href = name + ".css";
+ d.head.appendChild(css);
+ })(document, theme.name());
+ </script>
+ </head>
+ <body>
+ <div
+ class="input"
+ style="margin-top:-8px"
+ >
+ <input
+ type="text"
+ size="80%"
+ name="webtext"
+ placeholder="&lt;input type=&quot;text&quot;/&gt;" />
+ </div>
+ <div class="input">
+ <input
+ type="email"
+ size="80%"
+ name="webemail"
+ placeholder="&lt;input type=&quot;email&quot;/&gt;" />
+ </div>
+ <div class="input">
+ <input
+ type="password"
+ size="80%"
+ name="webpassword"
+ placeholder="&lt;input type=&quot;password&quot;/&gt;" />
+ </div>
+ <div class="input">
+ <input
+ type="url"
+ size="80%"
+ name="weburl"
+ placeholder="&lt;input type=&quot;url&quot;/&gt;" />
+ </div>
+ <div class="input">
+ <input
+ type="number"
+ size="80%"
+ name="webnumber"
+ placeholder="&lt;input type=&quot;number&quot;/&gt;" />
+ </div>
+ <div class="input">
+ <input
+ type="tel"
+ size="80%"
+ name="webtel"
+ placeholder="&lt;input type=&quot;tel&quot;/&gt;" />
+ </div>
+ <div class="input">
+ <input
+ type="search"
+ size="80%"
+ name="websearch"
+ placeholder="&lt;input type=&quot;search&quot;/&gt;" />
+ </div>
+ <div
+ class="input"
+ style="margin-bottom:-4px"
+ >
+ <textarea
+ rows="2"
+ cols="80%"
+ name="webtextarea"
+ placeholder="&lt;textarea&gt;&lt/textarea&gt;"
+ ></textarea>
+ </div>
+ </body>
+</html>
diff --git a/tools/EditTextVariations/res/drawable-hdpi/ic_launcher.png b/tools/EditTextVariations/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 000000000..e0923a605
--- /dev/null
+++ b/tools/EditTextVariations/res/drawable-hdpi/ic_launcher.png
Binary files differ
diff --git a/tools/EditTextVariations/res/drawable-mdpi/ic_launcher.png b/tools/EditTextVariations/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 000000000..9bc091481
--- /dev/null
+++ b/tools/EditTextVariations/res/drawable-mdpi/ic_launcher.png
Binary files differ
diff --git a/tools/EditTextVariations/res/drawable-xhdpi/ic_launcher.png b/tools/EditTextVariations/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 000000000..d60ac3dc0
--- /dev/null
+++ b/tools/EditTextVariations/res/drawable-xhdpi/ic_launcher.png
Binary files differ
diff --git a/tools/EditTextVariations/res/drawable-xxhdpi/ic_launcher.png b/tools/EditTextVariations/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 000000000..f3069d74f
--- /dev/null
+++ b/tools/EditTextVariations/res/drawable-xxhdpi/ic_launcher.png
Binary files differ
diff --git a/tools/EditTextVariations/res/layout/main.xml b/tools/EditTextVariations/res/layout/main.xml
new file mode 100644
index 000000000..99abfb07e
--- /dev/null
+++ b/tools/EditTextVariations/res/layout/main.xml
@@ -0,0 +1,298 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2010, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<ScrollView
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent"
+>
+ <LinearLayout
+ android:id="@+id/edit_text_list"
+ android:orientation="vertical"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ >
+ <EditText
+ android:id="@+id/text_multi_lines_none"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textMultiLine|textAutoCorrect"
+ android:imeOptions="actionUnspecified" />
+ <EditText
+ android:id="@+id/text_multi_lines_send"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textMultiLine|textAutoCorrect"
+ android:imeOptions="actionSend" />
+ <view
+ class="com.android.inputmethod.tools.edittextvariations.MultiLineShortMessageEditText"
+ android:id="@+id/text_short_message_send_multi_lines"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textShortMessage|textMultiLine|textAutoCorrect|textCapSentences"
+ android:imeOptions="actionSend" />
+ <view
+ class="com.android.inputmethod.tools.edittextvariations.MultiLineShortMessageEditText"
+ android:id="@+id/text_multi_lines_search"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textMultiLine|textAutoCorrect|textCapSentences"
+ android:imeOptions="actionSearch" />
+ <EditText
+ android:id="@+id/text_short_message_send"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textShortMessage|textAutoCorrect|textCapSentences"
+ android:imeOptions="actionSend" />
+ <EditText
+ android:id="@+id/text_autocap_none"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textAutoCorrect|textCapSentences"
+ android:imeOptions="actionNone" />
+ <EditText
+ android:id="@+id/text_autocap_send"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textAutoCorrect|textCapSentences"
+ android:imeOptions="actionSend" />
+ <EditText
+ android:id="@+id/text_uri_go"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textUri"
+ android:imeOptions="actionGo" />
+ <EditText
+ android:id="@+id/text_email_address_done"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textEmailAddress"
+ android:imeOptions="actionDone" />
+ <EditText
+ android:id="@+id/text_auto_correct_search"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textAutoCorrect"
+ android:imeOptions="actionSearch" />
+ <EditText
+ android:id="@+id/text_auto_correct_next"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textAutoCorrect"
+ android:imeOptions="actionNext" />
+ <EditText
+ android:id="@+id/text_auto_correct_previous"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textAutoCorrect" />
+ <EditText
+ android:id="@+id/text_auto_correct_custom"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textAutoCorrect"
+ android:imeActionLabel="@string/custom_action_label"
+ android:imeActionId="100" />
+ <EditText
+ android:id="@+id/phone"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="phone" />
+ <EditText
+ android:id="@+id/phone_no_action"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="phone"
+ android:imeOptions="actionNone" />
+ <EditText
+ android:id="@+id/number_send"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="number"
+ android:imeOptions="actionSend" />
+ <EditText
+ android:id="@+id/number_no_action"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="number"
+ android:imeOptions="actionNone" />
+ <EditText
+ android:id="@+id/text_password_next"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textPassword"
+ android:imeOptions="actionNext" />
+ <EditText
+ android:id="@+id/text_visible_password_done"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textVisiblePassword"
+ android:imeOptions="actionDone" />
+ <EditText
+ android:id="@+id/number_password_send"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="numberPassword"
+ android:imeOptions="actionDone" />
+ <EditText
+ android:id="@+id/text_no_suggestions"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textNoSuggestions"
+ android:imeOptions="actionGo" />
+ <EditText
+ android:id="@+id/text_no_auto_correction"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textShortMessage"
+ android:imeOptions="actionDone" />
+ <WebView
+ android:id="@+id/web_view"
+ android:layout_width="fill_parent"
+ android:layout_height="380sp"
+ android:focusable="true" />
+ <EditText
+ android:id="@+id/text_cap_characters_with_auto_correction"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textCapCharacters|textAutoCorrect" />
+ <EditText
+ android:id="@+id/text_cap_words_with_auto_correction"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textCapWords|textAutoCorrect" />
+ <EditText
+ android:id="@+id/text_cap_sentences_with_auto_correction"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textCapSentences|textAutoCorrect" />
+ <EditText
+ android:id="@+id/text_cap_characters"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textCapCharacters" />
+ <EditText
+ android:id="@+id/text_cap_words"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textCapWords" />
+ <EditText
+ android:id="@+id/text_cap_sentences"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textCapSentences" />
+ <EditText
+ android:id="@+id/text_email_subject"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textEmailSubject" />
+ <EditText
+ android:id="@+id/text_personal_name"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textPersonName" />
+ <EditText
+ android:id="@+id/text_postal_address"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textPostalAddress" />
+ <EditText
+ android:id="@+id/text_phonetic"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textPhonetic" />
+ <EditText
+ android:id="@+id/number_signed"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="numberSigned" />
+ <EditText
+ android:id="@+id/number_decimal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="numberDecimal" />
+ <EditText
+ android:id="@+id/number_signed_decimal"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="numberSigned|numberDecimal" />
+ <EditText
+ android:id="@+id/date_time"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="datetime" />
+ <EditText
+ android:id="@+id/date"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="date" />
+ <EditText
+ android:id="@+id/time"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="time" />
+ <EditText
+ android:id="@+id/text_no_extract_ui"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="text"
+ android:imeOptions="flagNoExtractUi" />
+ <EditText
+ android:id="@+id/text_no_fullscreen"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="textCapSentences"
+ android:imeOptions="flagNoFullscreen" />
+ <EditText
+ android:id="@+id/text_nm"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="text"
+ android:privateImeOptions="nm" />
+ <EditText
+ android:id="@+id/text_force_ascii_flag"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="text" />
+ <AutoCompleteTextView
+ android:id="@+id/text_app_completion"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content" />
+ <AutoCompleteTextView
+ android:id="@+id/text_app_completion_no_fullscreen"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:imeOptions="flagNoFullscreen" />
+ <AutoCompleteTextView
+ android:id="@+id/text_app_compeletion_no_extract_ui"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:imeOptions="flagNoExtractUi" />
+ <EditText
+ android:id="@+id/text_restarting"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="text" />
+ <EditText
+ android:id="@+id/text_null"
+ android:layout_width="fill_parent"
+ android:layout_height="wrap_content"
+ android:inputType="none" />
+ </LinearLayout>
+</ScrollView>
diff --git a/tools/EditTextVariations/res/values-v11/donottranslate.xml b/tools/EditTextVariations/res/values-v11/donottranslate.xml
new file mode 100644
index 000000000..5b7eb23fc
--- /dev/null
+++ b/tools/EditTextVariations/res/values-v11/donottranslate.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2011, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources>
+ <string name="default_theme">Theme_Holo_Light</string>
+</resources>
diff --git a/tools/EditTextVariations/res/values-v14/themes.xml b/tools/EditTextVariations/res/values-v14/themes.xml
new file mode 100644
index 000000000..22c6016ff
--- /dev/null
+++ b/tools/EditTextVariations/res/values-v14/themes.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2017, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+ <style name="defaultActivityTheme" parent="@android:style/Theme.DeviceDefault.Light" />
+</resources>
diff --git a/tools/EditTextVariations/res/values-v27/themes.xml b/tools/EditTextVariations/res/values-v27/themes.xml
new file mode 100644
index 000000000..8fd3aae4f
--- /dev/null
+++ b/tools/EditTextVariations/res/values-v27/themes.xml
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2017, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+ <style name="defaultActivityTheme" parent="@android:style/Theme.DeviceDefault.Light">
+ <item name="android:navigationBarColor">@android:color/white</item>
+ <item name="android:navigationBarDividerColor">#1f000000</item>
+ <item name="android:windowLightNavigationBar">true</item>
+ </style>
+</resources>
diff --git a/tools/EditTextVariations/res/values/countries.xml b/tools/EditTextVariations/res/values/countries.xml
new file mode 100644
index 000000000..6d7e5c137
--- /dev/null
+++ b/tools/EditTextVariations/res/values/countries.xml
@@ -0,0 +1,263 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources>
+ <!-- The list of country names. [CHAR LIMIT=100] -->
+ <string-array name="countries_array">
+ <item>Afghanistan</item>
+ <item>Albania</item>
+ <item>Algeria</item>
+ <item>American Samoa</item>
+ <item>Andorra</item>
+ <item>Angola</item>
+ <item>Anguilla</item>
+ <item>Antarctica</item>
+ <item>Antigua and Barbuda</item>
+ <item>Argentina</item>
+ <item>Armenia</item>
+ <item>Aruba</item>
+ <item>Australia</item>
+ <item>Austria</item>
+ <item>Azerbaijan</item>
+ <item>Bahrain</item>
+ <item>Bangladesh</item>
+ <item>Barbados</item>
+ <item>Belarus</item>
+ <item>Belgium</item>
+ <item>Belize</item>
+ <item>Benin</item>
+ <item>Bermuda</item>
+ <item>Bhutan</item>
+ <item>Bolivia</item>
+ <item>Bosnia and Herzegovina</item>
+ <item>Botswana</item>
+ <item>Bouvet Island</item>
+ <item>Brazil</item>
+ <item>British Indian Ocean Territory</item>
+ <item>British Virgin Islands</item>
+ <item>Brunei</item>
+ <item>Bulgaria</item>
+ <item>Burkina Faso</item>
+ <item>Burundi</item>
+ <item>"Cote d'Ivoire"</item>
+ <item>Cambodia</item>
+ <item>Cameroon</item>
+ <item>Canada</item>
+ <item>Cape Verde</item>
+ <item>Cayman Islands</item>
+ <item>Central African Republic</item>
+ <item>Chad</item>
+ <item>Chile</item>
+ <item>China</item>
+ <item>Christmas Island</item>
+ <item>Cocos (Keeling) Islands</item>
+ <item>Colombia</item>
+ <item>Comoros</item>
+ <item>Congo</item>
+ <item>Cook Islands</item>
+ <item>Costa Rica</item>
+ <item>Croatia</item>
+ <item>Cuba</item>
+ <item>Cyprus</item>
+ <item>Czech Republic</item>
+ <item>Democratic Republic of the Congo</item>
+ <item>Denmark</item>
+ <item>Djibouti</item>
+ <item>Dominica</item>
+ <item>Dominican Republic</item>
+ <item>East Timor</item>
+ <item>Ecuador</item>
+ <item>Egypt</item>
+ <item>El Salvador</item>
+ <item>Equatorial Guinea</item>
+ <item>Eritrea</item>
+ <item>Estonia</item>
+ <item>Ethiopia</item>
+ <item>Faeroe Islands</item>
+ <item>Falkland Islands</item>
+ <item>Fiji</item>
+ <item>Finland</item>
+ <item>Republic of Macedonia</item>
+ <item>France</item>
+ <item>French Guiana</item>
+ <item>French Polynesia</item>
+ <item>French Southern Territories</item>
+ <item>Gabon</item>
+ <item>Georgia</item>
+ <item>Germany</item>
+ <item>Ghana</item>
+ <item>Gibraltar</item>
+ <item>Greece</item>
+ <item>Greenland</item>
+ <item>Grenada</item>
+ <item>Guadeloupe</item>
+ <item>Guam</item>
+ <item>Guatemala</item>
+ <item>Guinea</item>
+ <item>Guinea-Bissau</item>
+ <item>Guyana</item>
+ <item>Haiti</item>
+ <item>Heard Island and McDonald Islands</item>
+ <item>Honduras</item>
+ <item>Hong Kong</item>
+ <item>Hungary</item>
+ <item>Iceland</item>
+ <item>India</item>
+ <item>Indonesia</item>
+ <item>Iran</item>
+ <item>Iraq</item>
+ <item>Ireland</item>
+ <item>Israel</item>
+ <item>Italy</item>
+ <item>Jamaica</item>
+ <item>Japan</item>
+ <item>Jordan</item>
+ <item>Kazakhstan</item>
+ <item>Kenya</item>
+ <item>Kiribati</item>
+ <item>Kuwait</item>
+ <item>Kyrgyzstan</item>
+ <item>Laos</item>
+ <item>Latvia</item>
+ <item>Lebanon</item>
+ <item>Lesotho</item>
+ <item>Liberia</item>
+ <item>Libya</item>
+ <item>Liechtenstein</item>
+ <item>Lithuania</item>
+ <item>Luxembourg</item>
+ <item>Macau</item>
+ <item>Madagascar</item>
+ <item>Malawi</item>
+ <item>Malaysia</item>
+ <item>Maldives</item>
+ <item>Mali</item>
+ <item>Malta</item>
+ <item>Marshall Islands</item>
+ <item>Martinique</item>
+ <item>Mauritania</item>
+ <item>Mauritius</item>
+ <item>Mayotte</item>
+ <item>Mexico</item>
+ <item>Micronesia</item>
+ <item>Moldova</item>
+ <item>Monaco</item>
+ <item>Mongolia</item>
+ <item>Montserrat</item>
+ <item>Morocco</item>
+ <item>Mozambique</item>
+ <item>Myanmar</item>
+ <item>Namibia</item>
+ <item>Nauru</item>
+ <item>Nepal</item>
+ <item>Netherlands</item>
+ <item>Netherlands Antilles</item>
+ <item>New Caledonia</item>
+ <item>New Zealand</item>
+ <item>Nicaragua</item>
+ <item>Niger</item>
+ <item>Nigeria</item>
+ <item>Niue</item>
+ <item>Norfolk Island</item>
+ <item>North Korea</item>
+ <item>Northern Marianas</item>
+ <item>Norway</item>
+ <item>Oman</item>
+ <item>Pakistan</item>
+ <item>Palau</item>
+ <item>Panama</item>
+ <item>Papua New Guinea</item>
+ <item>Paraguay</item>
+ <item>Peru</item>
+ <item>Philippines</item>
+ <item>Pitcairn Islands</item>
+ <item>Poland</item>
+ <item>Portugal</item>
+ <item>Puerto Rico</item>
+ <item>Qatar</item>
+ <item>Reunion</item>
+ <item>Romania</item>
+ <item>Russia</item>
+ <item>Rwanda</item>
+ <item>Sao Tome and Principe</item>
+ <item>Saint Helena</item>
+ <item>Saint Kitts and Nevis</item>
+ <item>Saint Lucia</item>
+ <item>Saint Pierre and Miquelon</item>
+ <item>Saint Vincent and the Grenadines</item>
+ <item>Samoa</item>
+ <item>San Marino</item>
+ <item>Saudi Arabia</item>
+ <item>Senegal</item>
+ <item>Seychelles</item>
+ <item>Sierra Leone</item>
+ <item>Singapore</item>
+ <item>Slovakia</item>
+ <item>Slovenia</item>
+ <item>Solomon Islands</item>
+ <item>Somalia</item>
+ <item>South Africa</item>
+ <item>South Georgia and the South Sandwich Islands</item>
+ <item>South Korea</item>
+ <item>Spain</item>
+ <item>Sri Lanka</item>
+ <item>Sudan</item>
+ <item>Suriname</item>
+ <item>Svalbard and Jan Mayen</item>
+ <item>Swaziland</item>
+ <item>Sweden</item>
+ <item>Switzerland</item>
+ <item>Syria</item>
+ <item>Taiwan</item>
+ <item>Tajikistan</item>
+ <item>Tanzania</item>
+ <item>Thailand</item>
+ <item>The Bahamas</item>
+ <item>The Gambia</item>
+ <item>Togo</item>
+ <item>Tokelau</item>
+ <item>Tonga</item>
+ <item>Trinidad and Tobago</item>
+ <item>Tunisia</item>
+ <item>Turkey</item>
+ <item>Turkmenistan</item>
+ <item>Turks and Caicos Islands</item>
+ <item>Tuvalu</item>
+ <item>Virgin Islands</item>
+ <item>Uganda</item>
+ <item>Ukraine</item>
+ <item>United Arab Emirates</item>
+ <item>United Kingdom</item>
+ <item>United States</item>
+ <item>United States Minor Outlying Islands</item>
+ <item>Uruguay</item>
+ <item>Uzbekistan</item>
+ <item>Vanuatu</item>
+ <item>Vatican City</item>
+ <item>Venezuela</item>
+ <item>Vietnam</item>
+ <item>Wallis and Futuna</item>
+ <item>Western Sahara</item>
+ <item>Yemen</item>
+ <item>Zambia</item>
+ <item>Zimbabwe</item>
+ <item>Yemen</item>
+ </string-array>
+</resources>
diff --git a/tools/EditTextVariations/res/values/strings.xml b/tools/EditTextVariations/res/values/strings.xml
new file mode 100644
index 000000000..cb896e8b6
--- /dev/null
+++ b/tools/EditTextVariations/res/values/strings.xml
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2010, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- This test application name. -->
+ <string name="app_name" translatable="false">EditTextVariations</string>
+ <!-- The menu title to change color theme of this application. [CHAR LIMIT=20] -->
+ <string name="menu_change_theme">Change Theme</string>
+ <!-- The menu title to display the version name of this application. [CHAR LIMIT=20] -->
+ <string name="menu_version">Version <xliff:g id="VERSION_NAME" example="0.56">%s</xliff:g></string>
+ <!-- The menu title to turn on the text field focus navigation. [CHAR LIMIT=20] -->
+ <string name="menu_navigate_on" translatable="false">Navigate On</string>
+ <!-- The menu title to turn off the text field focus navigation. [CHAR LIMIT=20] -->
+ <string name="menu_navigate_off" translatable="false">Navigate Off</string>
+ <!-- The menu title to show software keyboard when the application is launched. [CHAR LIMIT=20] -->
+ <string name="menu_softinput_visible" translatable="false">Keyboard Visible</string>
+ <!-- The menu title to stay hidden software keyboard when the application is launched. [CHAR LIMIT=20] -->
+ <string name="menu_softinput_hidden" translatable="false">Keyboard Hidden</string>
+ <!-- The menu title to send a notification to test direct reply. [CHAR LIMIT=20] -->
+ <string name="menu_direct_reply">Direct Reply</string>
+ <!-- The example of custom action key label. Must be short to fit on key. 5 chars or less is preferable. [CHAR LIMIT=7] -->
+ <string name="custom_action_label">Custom</string>
+</resources>
diff --git a/tools/EditTextVariations/res/values/themes.xml b/tools/EditTextVariations/res/values/themes.xml
new file mode 100644
index 000000000..036a7111b
--- /dev/null
+++ b/tools/EditTextVariations/res/values/themes.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2017, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<resources xmlns:android="http://schemas.android.com/apk/res/android">
+ <style name="defaultActivityTheme" parent="@android:style/Theme.Holo" />
+</resources>
diff --git a/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/EchoingTextWatcher.java b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/EchoingTextWatcher.java
new file mode 100644
index 000000000..1c652c2a2
--- /dev/null
+++ b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/EchoingTextWatcher.java
@@ -0,0 +1,86 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.tools.edittextvariations;
+
+import android.annotation.SuppressLint;
+import android.os.Handler;
+import android.os.Message;
+import android.text.Editable;
+import android.text.TextUtils;
+import android.text.TextWatcher;
+import android.widget.EditText;
+
+import java.util.Locale;
+
+final class EchoingTextWatcher implements TextWatcher {
+ private static final int SET_TEXT_DELAY = 500;
+
+ final EditText mEditText;
+ CharSequence mExpected;
+
+ @SuppressLint("HandlerLeak")
+ private Handler mHandler = new Handler() {
+ @Override
+ public void handleMessage(final Message msg) {
+ final String toBeappended = (String) msg.obj;
+ final CharSequence current = mEditText.getText();
+ final CharSequence newText = TextUtils.concat(current, toBeappended);
+ mExpected = newText;
+ mEditText.setText(newText);
+ mEditText.setSelection(newText.length());
+ }
+ };
+
+ @SuppressWarnings("unused")
+ public static void attachTo(final EditText editText) {
+ final EchoingTextWatcher watcher = new EchoingTextWatcher(editText);
+ }
+
+ public EchoingTextWatcher(final EditText editText) {
+ mEditText = editText;
+ editText.addTextChangedListener(this);
+ }
+
+ @Override
+ public void afterTextChanged(final Editable ss) {
+ }
+
+ @Override
+ public void beforeTextChanged(final CharSequence s, final int start, final int count,
+ final int after) {
+ }
+
+ @Override
+ public void onTextChanged(final CharSequence s, final int start, final int before,
+ final int count) {
+ if (count == 0 || before > 0 || TextUtils.equals(s, mExpected)) {
+ return;
+ }
+ final int len = s.length();
+ if (len > 0) {
+ final String last = s.subSequence(len - 1, len).toString();
+ final char lastChar = last.charAt(0);
+ if (Character.isUpperCase(lastChar)) {
+ final String lowerCase = last.toLowerCase(Locale.getDefault());
+ mHandler.sendMessageDelayed(mHandler.obtainMessage(0, lowerCase), SET_TEXT_DELAY);
+ } else if (Character.isLowerCase(lastChar)) {
+ final String upperCase = last.toUpperCase(Locale.getDefault());
+ mHandler.sendMessageDelayed(mHandler.obtainMessage(0, upperCase), SET_TEXT_DELAY);
+ }
+ }
+ }
+}
diff --git a/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/EditTextVariations.java b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/EditTextVariations.java
new file mode 100644
index 000000000..6eb85a528
--- /dev/null
+++ b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/EditTextVariations.java
@@ -0,0 +1,479 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.tools.edittextvariations;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.app.AlertDialog;
+import android.content.DialogInterface;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager.NameNotFoundException;
+import android.os.Build;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.text.InputType;
+import android.text.TextUtils;
+import android.util.Log;
+import android.view.KeyEvent;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.Window;
+import android.view.WindowManager;
+import android.view.inputmethod.EditorInfo;
+import android.webkit.JavascriptInterface;
+import android.webkit.WebView;
+import android.widget.ArrayAdapter;
+import android.widget.AutoCompleteTextView;
+import android.widget.EditText;
+import android.widget.TextView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public final class EditTextVariations extends Activity implements TextView.OnEditorActionListener,
+ DialogInterface.OnClickListener {
+ private static final String TAG = EditTextVariations.class.getSimpleName();
+ private static final boolean DEBUG_INPUT_TEXT = false;
+
+ private static final int MENU_CHANGE_THEME = 0;
+ private static final int MENU_VERSION = 1;
+ private static final int MENU_NAVIGATE_ON = 2;
+ private static final int MENU_NAVIGATE_OFF = 3;
+ private static final int MENU_SOFTINPUT_VISIBLE = 4;
+ private static final int MENU_SOFTINPUT_HIDDEN = 5;
+ private static final int MENU_DIRECT_REPLY = 6;
+ private static final String PREF_THEME = "theme";
+ private static final String PREF_NAVIGATE = "navigate";
+ private static final String PREF_SOFTINPUT = "softinput";
+
+ private SharedPreferences prefs;
+ private View[] fields;
+
+ private static final FinalClassField<Integer> ApplicationInfo_FLAG_SUPPORTS_RTL =
+ FinalClassField.newInstance(ApplicationInfo.class, "FLAG_SUPPORTS_RTL", 1 << 22);
+
+ // This flag should be defined IceCreamSandwich and later.
+ // Note that Froyo and Gingerbread have hidden IME_FLAG_NO_FULLSCREEN as
+ // value 0x80000000.
+ private static final FinalClassField<Integer> EditorInfo_IME_FLAG_FORCE_ASCII =
+ FinalClassField.newInstance(EditorInfo.class, "IME_FLAG_FORCE_ASCII",
+ Build.VERSION.SDK_INT >= /* ICE_CREAM_SANDWICH */14 ? 0x80000000 : 0);
+
+ private ArrayAdapter<String> mAutoCompleteAdapter;
+
+ /** Called when the activity is first created. */
+ @SuppressLint("SetJavaScriptEnabled")
+ @Override
+ public void onCreate(final Bundle savedInstanceState) {
+ getApplicationInfo().flags |= ApplicationInfo_FLAG_SUPPORTS_RTL.value;
+ prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ loadTheme();
+ loadSoftInputMode();
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.main);
+
+ final String[] countries = getResources().getStringArray(R.array.countries_array);
+ mAutoCompleteAdapter = new ArrayAdapter<>(
+ this, android.R.layout.simple_dropdown_item_1line, countries);
+
+ final boolean navigateMode = getNavigateMode();
+ final ViewGroup vg = (ViewGroup) findViewById(R.id.edit_text_list);
+ final int n = vg.getChildCount();
+ fields = new View[n];
+ for (int i = 0; i < n; i++) {
+ final View v = vg.getChildAt(i);
+ if (v instanceof EditText) {
+ final int id = v.getId();
+ final EditText e = (EditText) v;
+ int inputType = e.getInputType();
+ int imeOptions = e.getImeOptions();
+ if (id == R.id.text_auto_correct_previous) {
+ imeOptions &= ~EditorInfo.IME_MASK_ACTION;
+ imeOptions |= EditorInfo.IME_ACTION_PREVIOUS;
+ }
+ if (id == R.id.text_force_ascii_flag) {
+ imeOptions |= EditorInfo_IME_FLAG_FORCE_ASCII.value;
+ }
+ if (id == R.id.text_null) {
+ inputType = InputType.TYPE_NULL;
+ }
+ if (id == R.id.text_restarting) {
+ EchoingTextWatcher.attachTo(e);
+ }
+ if (navigateMode && i > 0) {
+ imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS;
+ }
+ if (navigateMode && i < n - 1) {
+ imeOptions |= EditorInfo.IME_FLAG_NAVIGATE_NEXT;
+ }
+
+ e.setInputType(inputType);
+ e.setImeOptions(imeOptions);
+ setupHintText(e);
+ if (navigateMode) {
+ e.setOnEditorActionListener(this);
+ }
+ }
+ if (v instanceof AutoCompleteTextView) {
+ final AutoCompleteTextView e = (AutoCompleteTextView) v;
+ e.setAdapter(mAutoCompleteAdapter);
+ e.setThreshold(1);
+ }
+ if (v instanceof WebView) {
+ final WebView wv = (WebView) v;
+ wv.getSettings().setJavaScriptEnabled(true);
+ wv.addJavascriptInterface(new Object() {
+ @JavascriptInterface
+ public String name() {
+ return getThemeName();
+ }
+ }, "theme");
+ wv.loadUrl("file:///android_asset/webview.html");
+ }
+ fields[i] = v;
+ }
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(final Menu menu) {
+ super.onCreateOptionsMenu(menu);
+
+ menu.add(Menu.NONE, MENU_NAVIGATE_ON, 0, getString(R.string.menu_navigate_on));
+ menu.add(Menu.NONE, MENU_NAVIGATE_OFF, 1, getString(R.string.menu_navigate_off));
+ menu.add(Menu.NONE, MENU_SOFTINPUT_VISIBLE, 2, getString(R.string.menu_softinput_visible));
+ menu.add(Menu.NONE, MENU_SOFTINPUT_HIDDEN, 3, getString(R.string.menu_softinput_hidden));
+ menu.add(Menu.NONE, MENU_CHANGE_THEME, 4, R.string.menu_change_theme);
+ if (NotificationUtils.DIRECT_REPLY_SUPPORTED) {
+ menu.add(Menu.NONE, MENU_DIRECT_REPLY, 5, R.string.menu_direct_reply);
+ }
+ try {
+ final PackageInfo pinfo = getPackageManager().getPackageInfo(getPackageName(), 0);
+ menu.add(Menu.NONE, MENU_VERSION, 6,
+ getString(R.string.menu_version, pinfo.versionName))
+ .setEnabled(false);
+ } catch (NameNotFoundException e) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(final MenuItem item) {
+ final int itemId = item.getItemId();
+ if (itemId == MENU_CHANGE_THEME) {
+ final List<CharSequence> items = new ArrayList<>();
+ for (final ThemeItem theme : ThemeItem.THEME_LIST) {
+ items.add(theme.name);
+ }
+ final AlertDialog.Builder builder = new AlertDialog.Builder(this);
+ builder.setTitle(R.string.menu_change_theme);
+ builder.setCancelable(true);
+ builder.setNegativeButton(android.R.string.cancel, null);
+ builder.setItems(items.toArray(new CharSequence[items.size()]), this);
+ builder.show();
+ } else if (itemId == MENU_NAVIGATE_ON || itemId == MENU_NAVIGATE_OFF) {
+ saveNavigateMode(itemId == MENU_NAVIGATE_ON);
+ restartActivity();
+ } else if (itemId == MENU_SOFTINPUT_VISIBLE || itemId == MENU_SOFTINPUT_HIDDEN) {
+ saveSoftInputMode(itemId == MENU_SOFTINPUT_VISIBLE);
+ restartActivity();
+ } else if (itemId == MENU_DIRECT_REPLY) {
+ NotificationUtils.sendDirectReplyNotification(this);
+ }
+ return true;
+ }
+
+ @Override
+ public void onClick(final DialogInterface dialog, final int which) {
+ saveTheme(ThemeItem.THEME_LIST.get(which));
+ restartActivity();
+ }
+
+ private void restartActivity() {
+ final Intent intent = getIntent();
+ finish();
+ startActivity(intent);
+ }
+
+ private static void setupHintText(final EditText e) {
+ final int imeOptions = e.getImeOptions();
+ String hint = (e instanceof MultiLineShortMessageEditText) ? "*" : "";
+ hint += inputTypeToString(e.getInputType());
+ String text;
+ if (e.getImeActionLabel() != null) {
+ text = "actionLabel<" + e.getImeActionLabel() + ":" + e.getImeActionId() + ">";
+ } else {
+ text = actionName(imeOptions & EditorInfo.IME_MASK_ACTION);
+ }
+ text = appendFlagText(text,
+ (imeOptions & EditorInfo.IME_FLAG_NO_EXTRACT_UI) != 0, "flagNoExtractUi");
+ text = appendFlagText(text,
+ (imeOptions & EditorInfo.IME_FLAG_NO_FULLSCREEN) != 0, "flagNoFullscreen");
+ text = appendFlagText(text,
+ (imeOptions & EditorInfo_IME_FLAG_FORCE_ASCII.value) != 0, "flagForceAscii");
+ text = appendFlagText(text,
+ (imeOptions & EditorInfo.IME_FLAG_NAVIGATE_NEXT) != 0, ">");
+ text = appendFlagText(text,
+ (imeOptions & EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS) != 0, "<");
+ if (text.length() > 0)
+ hint += " " + text;
+ final String privateOptions = e.getPrivateImeOptions();
+ if (!TextUtils.isEmpty(privateOptions)) {
+ hint += " (";
+ String sep = "";
+ for (final String opt : privateOptions.trim().split(",")) {
+ final String[] elem = opt.trim().split("\\.");
+ hint += sep + elem[elem.length - 1];
+ sep = ",";
+ }
+ hint += ")";
+ }
+ if (DEBUG_INPUT_TEXT) {
+ Log.d(TAG, String.format("class=0x%08x variation=0x%08x flags=0x%08x hint=%s",
+ e.getInputType() & InputType.TYPE_MASK_CLASS,
+ e.getInputType() & InputType.TYPE_MASK_VARIATION,
+ e.getInputType() & InputType.TYPE_MASK_FLAGS, hint));
+ }
+ if (e.getId() == R.id.text_restarting) {
+ hint += " restarting";
+ }
+ e.setHint(hint);
+ }
+
+ private void saveBooleanPreference(final String key, final boolean value) {
+ final SharedPreferences.Editor editor = prefs.edit();
+ editor.putBoolean(key, value);
+ editor.apply();
+ }
+
+ private void saveStringPreference(final String key, final String value) {
+ final SharedPreferences.Editor editor = prefs.edit();
+ editor.putString(key, value);
+ editor.apply();
+ }
+
+ private void saveNavigateMode(final boolean enabled) {
+ saveBooleanPreference(PREF_NAVIGATE, enabled);
+ }
+
+ private boolean getNavigateMode() {
+ return prefs.getBoolean(PREF_NAVIGATE, false);
+ }
+
+ private void saveSoftInputMode(final boolean visible) {
+ saveBooleanPreference(PREF_SOFTINPUT, visible);
+ }
+
+ private void loadSoftInputMode() {
+ final boolean visible = prefs.getBoolean(PREF_SOFTINPUT, false);
+ final Window w = getWindow();
+ w.setSoftInputMode(visible
+ ? WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE
+ : WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
+ }
+
+ private void saveTheme(final ThemeItem theme) {
+ saveStringPreference(PREF_THEME, theme.name);
+ }
+
+ String getThemeName() {
+ return prefs.getString(PREF_THEME, ThemeItem.getDefaultThemeName());
+ }
+
+ private void loadTheme() {
+ final String themeName = getThemeName();
+ for (final ThemeItem theme : ThemeItem.THEME_LIST) {
+ if (themeName.equals(theme.name)) {
+ setTheme(theme.id);
+ return;
+ }
+ }
+ }
+
+ @Override
+ public boolean onEditorAction(final TextView v, final int action, final KeyEvent event) {
+ for (int i = 0; i < fields.length; i++) {
+ if (v == fields[i]) {
+ final int direction;
+ if (action == EditorInfo.IME_ACTION_PREVIOUS) {
+ direction = -1;
+ } else {
+ direction = +1;
+ }
+
+ final int target = i + direction;
+ if (target < 0 || target >= fields.length)
+ return false;
+
+ final View targetView = fields[target];
+ targetView.requestFocus();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static String actionName(final int action) {
+ switch (action & EditorInfo.IME_MASK_ACTION) {
+ case EditorInfo.IME_ACTION_UNSPECIFIED:
+ return "actionUnspecified";
+ case EditorInfo.IME_ACTION_NONE:
+ return "actionNone";
+ case EditorInfo.IME_ACTION_GO:
+ return "actionGo";
+ case EditorInfo.IME_ACTION_SEARCH:
+ return "actionSearch";
+ case EditorInfo.IME_ACTION_SEND:
+ return "actionSend";
+ case EditorInfo.IME_ACTION_NEXT:
+ return "actionNext";
+ case EditorInfo.IME_ACTION_DONE:
+ return "actionDone";
+ case EditorInfo.IME_ACTION_PREVIOUS:
+ return "actionPrevious";
+ default:
+ return "actionUnknown(" + action + ")";
+ }
+ }
+
+ private static String inputTypeToString(final int inputType) {
+ if (inputType == InputType.TYPE_NULL) {
+ return "TYPE_NULL";
+ }
+ final int clazz = inputType & InputType.TYPE_MASK_CLASS;
+ final int variation = inputType & InputType.TYPE_MASK_VARIATION;
+ final int flags = inputType & InputType.TYPE_MASK_FLAGS;
+ String base = "unknown(class=" + clazz + " variation=" + variation + " flag=0x"
+ + Integer.toHexString(flags);
+
+ switch (clazz) {
+ case InputType.TYPE_CLASS_TEXT:
+ switch (variation) {
+ case InputType.TYPE_TEXT_VARIATION_NORMAL:
+ base = "text";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_URI:
+ base = "textUri";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS:
+ base = "textEmailAddress";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_EMAIL_SUBJECT:
+ base = "textEmailSubject";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE:
+ base = "textShortMessage";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE:
+ base = "textLongMessage";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_PERSON_NAME:
+ base = "textPersonName";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS:
+ base = "textPostalAddress";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_PASSWORD:
+ base = "textPassword";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD:
+ base = "textVisiblePassword";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT:
+ base = "textWebEditText";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_FILTER:
+ base = "textFilter";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_PHONETIC:
+ base = "textPhonetic";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS:
+ base = "textWebEmailAddress";
+ break;
+ case InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD:
+ base = "textWebPassword";
+ break;
+ }
+ base = appendFlagText(base, (flags & InputType.TYPE_TEXT_FLAG_CAP_CHARACTERS) != 0,
+ "textCapCharacters");
+ base = appendFlagText(base, (flags & InputType.TYPE_TEXT_FLAG_CAP_WORDS) != 0,
+ "textCapWords");
+ base = appendFlagText(base, (flags & InputType.TYPE_TEXT_FLAG_CAP_SENTENCES) != 0,
+ "textCapSentences");
+ base = appendFlagText(base, (flags & InputType.TYPE_TEXT_FLAG_AUTO_CORRECT) != 0,
+ "textAutoCorrect");
+ base = appendFlagText(base, (flags & InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE) != 0,
+ "textAutoComplete");
+ base = appendFlagText(base, (flags & InputType.TYPE_TEXT_FLAG_MULTI_LINE) != 0,
+ "textMultiLine");
+ base = appendFlagText(base, (flags & InputType.TYPE_TEXT_FLAG_IME_MULTI_LINE) != 0,
+ "textImeMultiLine");
+ base = appendFlagText(base, (flags & InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS) != 0,
+ "textNoSuggestions");
+ break;
+
+ case InputType.TYPE_CLASS_NUMBER:
+ if (variation == InputType.TYPE_NUMBER_VARIATION_NORMAL) {
+ base = "number";
+ } else if (variation == InputType.TYPE_NUMBER_VARIATION_PASSWORD) {
+ base = "numberPassword";
+ }
+ base = appendFlagText(base, (flags & InputType.TYPE_NUMBER_FLAG_SIGNED) != 0,
+ "numberSigned");
+ base = appendFlagText(base, (flags & InputType.TYPE_NUMBER_FLAG_DECIMAL) != 0,
+ "numberDecimal");
+ break;
+
+ case InputType.TYPE_CLASS_PHONE:
+ base = "phone";
+ break;
+
+ case InputType.TYPE_CLASS_DATETIME:
+ switch (variation) {
+ case InputType.TYPE_DATETIME_VARIATION_NORMAL:
+ base = "datetime";
+ break;
+ case InputType.TYPE_DATETIME_VARIATION_DATE:
+ base = "date";
+ break;
+ case InputType.TYPE_DATETIME_VARIATION_TIME:
+ base = "time";
+ break;
+ }
+ break;
+ }
+
+ return base;
+ }
+
+ private static String appendFlagText(final String text, final boolean flag, final String name) {
+ if (flag) {
+ if (text.length() == 0 || name.startsWith(text))
+ return name;
+ return text + "|" + name;
+ }
+ return text;
+ }
+}
diff --git a/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/FinalClassField.java b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/FinalClassField.java
new file mode 100644
index 000000000..14c556a67
--- /dev/null
+++ b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/FinalClassField.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.tools.edittextvariations;
+
+import java.lang.reflect.Field;
+
+public final class FinalClassField<T> {
+ public final boolean defined;
+ public final String name;
+ public final String className;
+ public final T value;
+
+ @SuppressWarnings("unchecked")
+ private FinalClassField(final Field field, final String className, final String fieldName,
+ final T compatValue) {
+ this.defined = field != null;
+ this.name = fieldName;
+ this.className = className;
+ T v = null;
+ try {
+ final Object obj = field.get(null);
+ v = (T) obj;
+ } catch (final Exception e) {
+ v = compatValue;
+ }
+ this.value = v;
+ }
+
+ public static <T> FinalClassField<T> newInstance(final Class<?> definedClass, final String name,
+ final T compatValue) {
+ if (definedClass == null)
+ throw new NullPointerException("defined class");
+ String className = definedClass.getCanonicalName();
+ try {
+ return new FinalClassField<>(
+ definedClass.getField(name), className, name, compatValue);
+ } catch (Exception e) {
+ return new FinalClassField<>(null, className, name, compatValue);
+ }
+ }
+
+ public static <T> FinalClassField<T> newInstance(final String className, final String fieldName,
+ final T compatValue) {
+ try {
+ return newInstance(Class.forName(className), fieldName, compatValue);
+ } catch (ClassNotFoundException e) {
+ return new FinalClassField<>(null, className, fieldName, compatValue);
+ }
+ }
+}
diff --git a/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/InstanceMethod.java b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/InstanceMethod.java
new file mode 100644
index 000000000..05dc0d6dc
--- /dev/null
+++ b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/InstanceMethod.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.tools.edittextvariations;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+public final class InstanceMethod {
+ public final boolean defined;
+ public final String name;
+ public final String className;
+
+ private final Class<?> clazz;
+ private final Method method;
+
+ private InstanceMethod(final Class<?> receiverClass, final Method instanceMethod,
+ final String receiverName, final String methodName) {
+ this.defined = instanceMethod != null;
+ this.clazz = receiverClass;
+ this.method = instanceMethod;
+ this.name = methodName;
+ this.className = receiverName;
+ }
+
+ public Object invoke(final Object receiverObject, final Object... args) {
+ if (!defined)
+ throw new RuntimeException("method " + name + " not defined");
+ if (receiverObject == null)
+ throw new NullPointerException("receiver object");
+ if (clazz.isInstance(receiverObject)) {
+ try {
+ if (args.length == 0) {
+ return method.invoke(receiverObject);
+ }
+ return method.invoke(clazz, args);
+ } catch (IllegalArgumentException e) {
+ throw new RuntimeException("IllegalArgumentException");
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException("IllegalAccessException");
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException("InvocationTargetException");
+ }
+ }
+ throw new RuntimeException("receiver type not matched: method=" + name
+ + " actual receiver=" + receiverObject.getClass().getCanonicalName());
+ }
+
+ public static InstanceMethod newInstance(final Class<?> receiverClass, final String methodName,
+ final Class<?>... parameterTypes) {
+ if (receiverClass == null)
+ throw new NullPointerException("receiver class");
+ final String className = receiverClass.getCanonicalName();
+ try {
+ return new InstanceMethod(receiverClass,
+ receiverClass.getMethod(methodName, parameterTypes), className, methodName);
+ } catch (Exception e) {
+ return new InstanceMethod(receiverClass, null, className, methodName);
+ }
+ }
+
+ public static InstanceMethod newInstance(final String className, final String methodName,
+ final Class<?>... parameterTypes) {
+ try {
+ return newInstance(Class.forName(className), methodName, parameterTypes);
+ } catch (ClassNotFoundException e) {
+ return new InstanceMethod(null, null, className, methodName);
+ }
+ }
+}
diff --git a/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/MultiLineShortMessageEditText.java b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/MultiLineShortMessageEditText.java
new file mode 100644
index 000000000..7ab700776
--- /dev/null
+++ b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/MultiLineShortMessageEditText.java
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.tools.edittextvariations;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputConnection;
+import android.widget.EditText;
+
+public final class MultiLineShortMessageEditText extends EditText {
+
+ public MultiLineShortMessageEditText(final Context context) {
+ super(context);
+ }
+
+ public MultiLineShortMessageEditText(final Context context, final AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public MultiLineShortMessageEditText(final Context context, final AttributeSet attrs,
+ final int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ @Override
+ public InputConnection onCreateInputConnection(final EditorInfo outAttrs) {
+ final InputConnection ic = super.onCreateInputConnection(outAttrs);
+ outAttrs.imeOptions &= ~EditorInfo.IME_FLAG_NO_ENTER_ACTION;
+ return ic;
+ }
+}
diff --git a/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/NotificationBroadcastReceiver.java b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/NotificationBroadcastReceiver.java
new file mode 100644
index 000000000..97db49b15
--- /dev/null
+++ b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/NotificationBroadcastReceiver.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.tools.edittextvariations;
+
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+
+/**
+ * A non-exported {@link BroadcastReceiver} to receive {@link Intent} from notifications.
+ */
+public final class NotificationBroadcastReceiver extends BroadcastReceiver {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ NotificationUtils.onReceiveDirectReply(context, intent);
+ }
+}
diff --git a/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/NotificationUtils.java b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/NotificationUtils.java
new file mode 100644
index 000000000..a9b7132eb
--- /dev/null
+++ b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/NotificationUtils.java
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.tools.edittextvariations;
+
+import android.app.Notification;
+import android.app.NotificationChannel;
+import android.app.NotificationManager;
+import android.app.PendingIntent;
+import android.app.RemoteInput;
+import android.content.Context;
+import android.content.Intent;
+import android.os.Build;
+import android.os.Bundle;
+import android.os.Process;
+import android.os.UserHandle;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+
+final class NotificationUtils {
+ private static final String REPLY_ACTION = "REPLY_ACTION";
+ private static final String KEY_REPLY = "KEY_REPLY";
+ private static final String KEY_NOTIFICATION_ID = "KEY_NOTIFICATION_ID";
+ private static final String CHANNEL_NAME = "Channel Name";
+ private static final String CHANNEL_DESCRIPTION = "Channel Description";
+ private static final String CHANNEL_ID = "Channel ID";
+ private static final AtomicInteger sNextNotificationId = new AtomicInteger(1);
+
+ private static final Object sLock = new Object();
+ private static boolean sNotificationChannelInitialized = false;
+
+ static final boolean NOTIFICATION_CHANNEL_REQUIRED =
+ Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
+ static final boolean DIRECT_REPLY_SUPPORTED = Build.VERSION.SDK_INT >= Build.VERSION_CODES.N;
+
+ private static Notification.Builder createNotificationBuilder(Context context) {
+ if (!NOTIFICATION_CHANNEL_REQUIRED) {
+ // NotificationChannel is not implemented. No need to set up notification channel.
+ return new Notification.Builder(context);
+ }
+
+ // Make sure that a notification channel is created *before* we send a notification.
+ synchronized (sLock) {
+ if (!sNotificationChannelInitialized) {
+ final NotificationChannel channel = new NotificationChannel(CHANNEL_ID,
+ CHANNEL_NAME, NotificationManager.IMPORTANCE_DEFAULT);
+ channel.setDescription(CHANNEL_DESCRIPTION);
+ context.getSystemService(NotificationManager.class)
+ .createNotificationChannel(channel);
+ sNotificationChannelInitialized = true;
+ }
+ }
+ return new Notification.Builder(context, CHANNEL_ID);
+ }
+
+ static void sendDirectReplyNotification(Context context) {
+ if (!DIRECT_REPLY_SUPPORTED) {
+ // DirectReply is not supported.
+ return;
+ }
+
+ RemoteInput remoteInput = new RemoteInput.Builder(KEY_REPLY)
+ .setLabel("Reply Label")
+ .build();
+
+ final int notificationId = sNextNotificationId.getAndIncrement();
+ final PendingIntent pendingIntent = getReplyPendingIntent(context, notificationId);
+ final Notification.Action action =
+ new Notification.Action.Builder(null, "Direct Reply Test", pendingIntent)
+ .addRemoteInput(remoteInput)
+ .build();
+ final Notification notification = createNotificationBuilder(context)
+ .setContentText("Content Title")
+ .setSmallIcon(R.drawable.ic_launcher)
+ .setContentText("Message from " + UserHandle.getUserHandleForUid(Process.myUid()))
+ .setShowWhen(true)
+ .addAction(action)
+ .build();
+ context.getSystemService(NotificationManager.class).notify(notificationId, notification);
+ }
+
+ static void onReceiveDirectReply(Context context, Intent intent) {
+ final Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
+ if (remoteInput == null) {
+ return;
+ }
+ final CharSequence reply = remoteInput.getCharSequence(KEY_REPLY);
+ final int notificationId = intent.getIntExtra(KEY_NOTIFICATION_ID, 0);
+ final Notification.Builder notificationBuilder =
+ new Notification.Builder(context, CHANNEL_ID);
+ notificationBuilder.setContentText("Content Title")
+ .setSmallIcon(R.drawable.ic_launcher)
+ .setContentText(String.format("Sent \"%s\" to %s", reply,
+ UserHandle.getUserHandleForUid(Process.myUid())));
+ context.getSystemService(NotificationManager.class)
+ .notify(notificationId, notificationBuilder.build());
+ }
+
+ private static PendingIntent getReplyPendingIntent(Context context, int notificationId) {
+ final Intent intent = new Intent(context, NotificationBroadcastReceiver.class);
+ intent.setAction(REPLY_ACTION);
+ intent.putExtra(KEY_NOTIFICATION_ID, notificationId);
+ // Pass notificationId as the result code to get a new PendingIntent rather than an existing
+ // one.
+ return PendingIntent.getBroadcast(context.getApplicationContext(), notificationId, intent,
+ PendingIntent.FLAG_ONE_SHOT);
+ }
+}
diff --git a/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/ThemeItem.java b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/ThemeItem.java
new file mode 100644
index 000000000..f3c6d4f54
--- /dev/null
+++ b/tools/EditTextVariations/src/com/android/inputmethod/tools/edittextvariations/ThemeItem.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.tools.edittextvariations;
+
+import android.os.Build;
+
+import com.android.inputmethod.tools.edittextvariations.R;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public final class ThemeItem {
+ public final int id;
+ public final String name;
+
+ private ThemeItem(final String name, final int resId) {
+ this.id = resId;
+ this.name = name;
+ }
+
+ private static final String THEME_DEFAULT = "Default";
+ private static final String THEME_HOLO = "Theme_Holo";
+ private static final String THEME_HOLO_LIGHT = "Theme_Holo_Light";
+ private static final String THEME_DEVICE_DEFAULT = "Theme_DeviceDefault";
+ private static final String THEME_DEVICE_DEFAULT_LIGHT = "Theme_DeviceDefault_Light";
+ private static final String THEME_MATERIAL = "Theme_Material";
+ private static final String THEME_MATERIAL_LIGHT = "Theme_Material_Light";
+
+ public static String getDefaultThemeName() {
+ return THEME_DEFAULT;
+ }
+
+ public static final List<ThemeItem> THEME_LIST = createThemeList(
+ THEME_HOLO, THEME_HOLO_LIGHT, THEME_DEVICE_DEFAULT, THEME_DEVICE_DEFAULT_LIGHT,
+ THEME_MATERIAL, THEME_MATERIAL_LIGHT);
+
+ private static List<ThemeItem> createThemeList(final String... candidateList) {
+ final ArrayList<ThemeItem> list = new ArrayList<>();
+
+ // Default theme is always available as it's defined in our resource.
+ list.add(new ThemeItem(THEME_DEFAULT, R.style.defaultActivityTheme));
+
+ for (final String name : candidateList) {
+ final FinalClassField<Integer> constant =
+ FinalClassField.newInstance(android.R.style.class, name, 0);
+ if (constant.defined) {
+ list.add(new ThemeItem(name, constant.value));
+ }
+ }
+
+ return Collections.unmodifiableList(list);
+ }
+}
diff --git a/tools/dicttool/Android.bp b/tools/dicttool/Android.bp
new file mode 100644
index 000000000..83b4ed32c
--- /dev/null
+++ b/tools/dicttool/Android.bp
@@ -0,0 +1,32 @@
+// Copyright (C) 2012 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+java_binary_host {
+ name: "dicttool_aosp",
+
+ srcs: [
+ "src/**/*.java",
+ "tests/**/*.java",
+ "compat/**/*.java",
+ ":dicttool_deps",
+ ],
+
+ libs: ["junit"],
+ static_libs: [
+ "jsr305",
+ "latinime-common",
+ ],
+ required: ["libjni_latinime"],
+ main_class: "com.android.inputmethod.latin.dicttool.Dicttool",
+}
diff --git a/tools/dicttool/Android.mk b/tools/dicttool/Android.mk
deleted file mode 100644
index 49816294f..000000000
--- a/tools/dicttool/Android.mk
+++ /dev/null
@@ -1,87 +0,0 @@
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Only build if it's explicitly requested, or running mm/mmm.
-ifneq ($(ONE_SHOT_MAKEFILE)$(filter $(MAKECMDGOALS),dicttool_aosp),)
-
-LATINIME_DICTTOOL_AOSP_LOCAL_PATH := $(call my-dir)
-LOCAL_PATH := $(LATINIME_DICTTOOL_AOSP_LOCAL_PATH)
-LATINIME_HOST_NATIVE_LIBNAME := liblatinime-aosp-dicttool-host
-include $(LOCAL_PATH)/NativeLib.mk
-
-######################################
-LOCAL_PATH := $(LATINIME_DICTTOOL_AOSP_LOCAL_PATH)
-include $(CLEAR_VARS)
-
-LATINIME_LOCAL_DIR := ../..
-LATINIME_BASE_SRC_DIR := $(LATINIME_LOCAL_DIR)/java/src/com/android/inputmethod
-LATINIME_BASE_OVERRIDABLE_SRC_DIR := \
- $(LATINIME_LOCAL_DIR)/java-overridable/src/com/android/inputmethod
-MAKEDICT_CORE_SRC_DIR := $(LATINIME_BASE_SRC_DIR)/latin/makedict
-LATINIME_TESTS_SRC_DIR := $(LATINIME_LOCAL_DIR)/tests/src/com/android/inputmethod/latin
-
-# Dependencies for Dicttool. Most of these files are needed by BinaryDictionary.java. Note that
-# a significant part of the dependencies are mocked in the compat/ directory, with empty or
-# nearly-empty implementations, for parts that we don't use in Dicttool.
-LATINIME_SRC_FILES_FOR_DICTTOOL := \
- latin/BinaryDictionary.java \
- latin/DicTraverseSession.java \
- latin/Dictionary.java \
- latin/NgramContext.java \
- latin/SuggestedWords.java \
- latin/settings/SettingsValuesForSuggestion.java \
- latin/utils/BinaryDictionaryUtils.java \
- latin/utils/CombinedFormatUtils.java \
- latin/utils/JniUtils.java
-
-LATINIME_OVERRIDABLE_SRC_FILES_FOR_DICTTOOL := \
- latin/define/DebugFlags.java
-
-LATINIME_TEST_SRC_FILES_FOR_DICTTOOL := \
- utils/ByteArrayDictBuffer.java
-
-USED_TARGETED_SRC_FILES := \
- $(addprefix $(LATINIME_BASE_SRC_DIR)/, $(LATINIME_SRC_FILES_FOR_DICTTOOL)) \
- $(addprefix $(LATINIME_BASE_OVERRIDABLE_SRC_DIR)/, \
- $(LATINIME_OVERRIDABLE_SRC_FILES_FOR_DICTTOOL)) \
- $(addprefix $(LATINIME_TESTS_SRC_DIR)/, $(LATINIME_TEST_SRC_FILES_FOR_DICTTOOL))
-
-DICTTOOL_ONDEVICE_TESTS_DIR := \
- $(LATINIME_LOCAL_DIR)/tests/src/com/android/inputmethod/latin/makedict/
-DICTTOOL_COMPAT_TESTS_DIR := compat
-
-LOCAL_MAIN_SRC_FILES := $(call all-java-files-under, $(MAKEDICT_CORE_SRC_DIR))
-LOCAL_TOOL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_SRC_FILES := $(LOCAL_TOOL_SRC_FILES) \
- $(filter-out $(addprefix %/, $(notdir $(LOCAL_TOOL_SRC_FILES))), $(LOCAL_MAIN_SRC_FILES)) \
- $(USED_TARGETED_SRC_FILES) \
- $(call all-java-files-under, \
- tests $(DICTTOOL_COMPAT_TESTS_DIR) $(DICTTOOL_ONDEVICE_TESTS_DIR))
-
-LOCAL_JAVA_LIBRARIES := junit-host
-LOCAL_STATIC_JAVA_LIBRARIES := jsr305lib latinime-common-host
-LOCAL_REQUIRED_MODULES := $(LATINIME_HOST_NATIVE_LIBNAME)
-LOCAL_JAR_MANIFEST := etc/manifest.txt
-LOCAL_MODULE := dicttool_aosp
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-include $(LOCAL_PATH)/etc/Android.mk
-
-# Clear our private variables
-LATINIME_DICTTOOL_AOSP_LOCAL_PATH :=
-LATINIME_LOCAL_DIR :=
-
-endif
diff --git a/tools/dicttool/NativeLib.mk b/tools/dicttool/NativeLib.mk
deleted file mode 100644
index 510f18c4e..000000000
--- a/tools/dicttool/NativeLib.mk
+++ /dev/null
@@ -1,46 +0,0 @@
-#
-# Copyright (C) 2013 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# Need to define the name of the library in the caller in LATINIME_HOST_NATIVE_LIBNAME
-
-LATINIME_DIR_RELATIVE_TO_DICTTOOL := ../..
-
-ifeq ($(FLAG_DBG), true)
- $(warning Making debug version of native library)
- LOCAL_CFLAGS += -DFLAG_DBG -funwind-tables -fno-inline
-endif #FLAG_DBG
-
-LOCAL_CFLAGS += -DHOST_TOOL -fPIC -Wno-deprecated -Wno-unused-parameter -Wno-unused-function
-
-LATINIME_NATIVE_JNI_DIR := $(LATINIME_DIR_RELATIVE_TO_DICTTOOL)/native/jni
-LATINIME_NATIVE_SRC_DIR := $(LATINIME_DIR_RELATIVE_TO_DICTTOOL)/native/jni/src
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(LATINIME_NATIVE_SRC_DIR)
-
-include $(LOCAL_PATH)/$(LATINIME_NATIVE_JNI_DIR)/NativeFileList.mk
-
-LOCAL_SRC_FILES := \
- $(addprefix $(LATINIME_NATIVE_JNI_DIR)/, $(LATIN_IME_JNI_SRC_FILES)) \
- $(addprefix $(LATINIME_NATIVE_SRC_DIR)/, $(LATIN_IME_CORE_SRC_FILES))
-
-LOCAL_MODULE := $(LATINIME_HOST_NATIVE_LIBNAME)
-
-include $(BUILD_HOST_SHARED_LIBRARY)
-
-# Clear our private variables
-include $(LOCAL_PATH)/$(LATINIME_NATIVE_JNI_DIR)/CleanupNativeFileList.mk
-LATINIME_DIR_RELATIVE_TO_DICTTOOL := ../..
diff --git a/tools/dicttool/compat/com/android/inputmethod/latin/define/JniLibName.java b/tools/dicttool/compat/com/android/inputmethod/latin/define/JniLibName.java
index d6d5e2d61..93ac1980a 100644
--- a/tools/dicttool/compat/com/android/inputmethod/latin/define/JniLibName.java
+++ b/tools/dicttool/compat/com/android/inputmethod/latin/define/JniLibName.java
@@ -21,5 +21,5 @@ public final class JniLibName {
// This class is not publicly instantiable.
}
- public static final String JNI_LIB_NAME = "latinime-aosp-dicttool-host";
+ public static final String JNI_LIB_NAME = "jni_latinime";
}
diff --git a/tools/dicttool/etc/Android.mk b/tools/dicttool/etc/Android.mk
deleted file mode 100644
index 0c611b7e9..000000000
--- a/tools/dicttool/etc/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_EXECUTABLES := dicttool_aosp makedict_aosp
-include $(BUILD_HOST_PREBUILT)
diff --git a/tools/dicttool/etc/dicttool_aosp b/tools/dicttool/etc/dicttool_aosp
deleted file mode 100755
index fc918f0f8..000000000
--- a/tools/dicttool/etc/dicttool_aosp
+++ /dev/null
@@ -1,67 +0,0 @@
-#!/bin/sh
-# Copyright 2011, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-classname=com.android.inputmethod.latin.dicttool.Dicttool
-jarfile=dicttool_aosp.jar
-frameworkdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
- libdir=`dirname "$progdir"`/lib64
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo `basename "$prog"`": can't find $jarfile"
- exit 1
-fi
-
-lib=junit.jar
-if [ ! -r "$frameworkdir/$lib" ]
-then
- echo `basename "$prog"`": can't find lib $lib"
- exit 1
-fi
-
-if [ "$OSTYPE" = "cygwin" ] ; then
- jarpath=`cygpath -w "$frameworkdir/$jarfile"`
- libpath=`cygpath -w "$frameworkdir/$lib"`
- progdir=`cygpath -w "$progdir"`
-else
- jarpath="$frameworkdir/$jarfile"
- libpath="$frameworkdir/$lib"
-fi
-
-# might need more memory, e.g. -Xmx128M
-exec java -ea -classpath "$libpath":"$jarpath" -Djava.library.path="$libdir" "$classname" "$@"
diff --git a/tools/dicttool/etc/makedict_aosp b/tools/dicttool/etc/makedict_aosp
deleted file mode 100755
index 095c50538..000000000
--- a/tools/dicttool/etc/makedict_aosp
+++ /dev/null
@@ -1,18 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2012, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Dicttool supports making the dictionary using the 'makedict' command and
-# the same arguments that the old 'makedict' command used to accept.
-dicttool_aosp makedict $@
diff --git a/tools/dicttool/etc/manifest.txt b/tools/dicttool/etc/manifest.txt
deleted file mode 100644
index 67c85214c..000000000
--- a/tools/dicttool/etc/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Main-Class: com.android.inputmethod.latin.dicttool.Dicttool
diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/CombinedInputOutput.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/CombinedInputOutput.java
index 955c5728c..5e7aca5bb 100644
--- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/CombinedInputOutput.java
+++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/CombinedInputOutput.java
@@ -106,8 +106,7 @@ public class CombinedInputOutput {
final String args[] = line.trim().split(",");
if (args[0].matches(CombinedFormatUtils.WORD_TAG + "=.*")) {
if (null != word) {
- dict.add(word, probabilityInfo, shortcuts.isEmpty() ? null : shortcuts,
- isNotAWord, isPossiblyOffensive);
+ dict.add(word, probabilityInfo, isNotAWord, isPossiblyOffensive);
for (WeightedString s : bigrams) {
dict.setBigram(word, s.mWord, s.mProbabilityInfo);
}
@@ -148,25 +147,6 @@ public class CombinedInputOutput {
break;
}
}
- } else if (args[0].matches(CombinedFormatUtils.SHORTCUT_TAG + "=.*")) {
- String shortcut = null;
- int shortcutFreq = 0;
- for (String param : args) {
- final String params[] = param.split("=", 2);
- if (2 != params.length) throw new RuntimeException("Wrong format : " + line);
- if (CombinedFormatUtils.SHORTCUT_TAG.equals(params[0])) {
- shortcut = params[1];
- } else if (CombinedFormatUtils.PROBABILITY_TAG.equals(params[0])) {
- shortcutFreq = WHITELIST_TAG.equals(params[1])
- ? FormatSpec.SHORTCUT_WHITELIST_FREQUENCY
- : Integer.parseInt(params[1]);
- }
- }
- if (null != shortcut) {
- shortcuts.add(new WeightedString(shortcut, shortcutFreq));
- } else {
- throw new RuntimeException("Wrong format : " + line);
- }
} else if (args[0].matches(CombinedFormatUtils.BIGRAM_TAG + "=.*")) {
String secondWordOfBigram = null;
ProbabilityInfo bigramProbabilityInfo = new ProbabilityInfo(0);
@@ -200,8 +180,7 @@ public class CombinedInputOutput {
}
}
if (null != word) {
- dict.add(word, probabilityInfo, shortcuts.isEmpty() ? null : shortcuts, isNotAWord,
- isPossiblyOffensive);
+ dict.add(word, probabilityInfo, isNotAWord, isPossiblyOffensive);
for (WeightedString s : bigrams) {
dict.setBigram(word, s.mWord, s.mProbabilityInfo);
}
diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java
index f97fbef2c..4ba7e1309 100644
--- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java
+++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java
@@ -136,9 +136,6 @@ public class Diff extends Dicttool.Command {
}
hasDifferences |= hasAttributesDifferencesAndPrintThemIfAny(word0Property.mWord,
"Bigram", word0Property.getBigrams(), word1PtNode.getBigrams());
- hasDifferences |= hasAttributesDifferencesAndPrintThemIfAny(word0Property.mWord,
- "Shortcut", word0Property.mShortcutTargets,
- word1PtNode.getShortcutTargets());
}
}
for (final WordProperty word1Property : dict1) {
diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java
index b8a64e31a..d516d60c3 100644
--- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java
+++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java
@@ -48,15 +48,6 @@ public class Info extends Dicttool.Command {
if (wordProperty.mHasNgrams) {
bigramCount += wordProperty.mNgrams.size();
}
- if (null != wordProperty.mShortcutTargets) {
- shortcutCount += wordProperty.mShortcutTargets.size();
- for (WeightedString shortcutTarget : wordProperty.mShortcutTargets) {
- if (FormatSpec.SHORTCUT_WHITELIST_FREQUENCY
- == shortcutTarget.getProbability()) {
- ++whitelistCount;
- }
- }
- }
}
System.out.println("Words in the dictionary : " + wordCount);
System.out.println("Bigram count : " + bigramCount);
@@ -78,17 +69,6 @@ public class Info extends Dicttool.Command {
if (ptNode.getIsPossiblyOffensive()) {
System.out.println(" Is possibly offensive");
}
- final ArrayList<WeightedString> shortcutTargets = ptNode.getShortcutTargets();
- if (null == shortcutTargets || shortcutTargets.isEmpty()) {
- System.out.println(" No shortcuts");
- } else {
- for (final WeightedString shortcutTarget : shortcutTargets) {
- System.out.println(" Shortcut target: " + shortcutTarget.mWord + " ("
- + (FormatSpec.SHORTCUT_WHITELIST_FREQUENCY
- == shortcutTarget.getProbability() ?
- "whitelist" : shortcutTarget.getProbability()) + ")");
- }
- }
final ArrayList<WeightedString> bigrams = ptNode.getBigrams();
if (null == bigrams || bigrams.isEmpty()) {
System.out.println(" No bigrams");
diff --git a/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java b/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java
index e68aeb0eb..84d36a0c3 100644
--- a/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java
+++ b/tools/dicttool/tests/com/android/inputmethod/latin/dicttool/BinaryDictOffdeviceUtilsTests.java
@@ -85,15 +85,15 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase {
testOptions.mAttributes.put(DictionaryHeader.DICTIONARY_LOCALE_KEY, LOCALE);
testOptions.mAttributes.put(DictionaryHeader.DICTIONARY_ID_KEY, ID);
final FusionDictionary dict = new FusionDictionary(new PtNodeArray(), testOptions);
- dict.add("foo", new ProbabilityInfo(TEST_FREQ), null, false /* isNotAWord */,
+ dict.add("foo", new ProbabilityInfo(TEST_FREQ), false /* isNotAWord */,
false /* isPossiblyOffensive */);
- dict.add("fta", new ProbabilityInfo(1), null, false /* isNotAWord */,
+ dict.add("fta", new ProbabilityInfo(1), false /* isNotAWord */,
false /* isPossiblyOffensive */);
- dict.add("ftb", new ProbabilityInfo(1), null, false /* isNotAWord */,
+ dict.add("ftb", new ProbabilityInfo(1), false /* isNotAWord */,
false /* isPossiblyOffensive */);
- dict.add("bar", new ProbabilityInfo(1), null, false /* isNotAWord */,
+ dict.add("bar", new ProbabilityInfo(1), false /* isNotAWord */,
false /* isPossiblyOffensive */);
- dict.add("fool", new ProbabilityInfo(1), null, false /* isNotAWord */,
+ dict.add("fool", new ProbabilityInfo(1), false /* isNotAWord */,
false /* isPossiblyOffensive */);
final File dst = File.createTempFile("testGetRawDict", ".tmp");
@@ -171,8 +171,8 @@ public class BinaryDictOffdeviceUtilsTests extends TestCase {
for (int i = 0; i < sWords.size(); ++i) {
final String word = sWords.get(i);
- dict.add(word, new ProbabilityInfo(TEST_FREQ), null /* shortcuts */,
- false /* isNotAWord */, false /* isPossiblyOffensive */);
+ dict.add(word, new ProbabilityInfo(TEST_FREQ), false /* isNotAWord */,
+ false /* isPossiblyOffensive */);
}
File file = File.createTempFile(dictName, ".tmp");
diff --git a/tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictEncoderFlattenTreeTests.java b/tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictEncoderFlattenTreeTests.java
index dc9981d1a..178fc41e2 100644
--- a/tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictEncoderFlattenTreeTests.java
+++ b/tools/dicttool/tests/com/android/inputmethod/latin/makedict/BinaryDictEncoderFlattenTreeTests.java
@@ -33,15 +33,15 @@ public class BinaryDictEncoderFlattenTreeTests extends TestCase {
public void testFlattenNodes() {
final FusionDictionary dict = new FusionDictionary(new PtNodeArray(),
new DictionaryOptions(new HashMap<String, String>()));
- dict.add("foo", new ProbabilityInfo(1), null, false /* isNotAWord */,
+ dict.add("foo", new ProbabilityInfo(1), false /* isNotAWord */,
false /* isPossiblyOffensive */);
- dict.add("fta", new ProbabilityInfo(1), null, false /* isNotAWord */,
+ dict.add("fta", new ProbabilityInfo(1), false /* isNotAWord */,
false /* isPossiblyOffensive */);
- dict.add("ftb", new ProbabilityInfo(1), null, false /* isNotAWord */,
+ dict.add("ftb", new ProbabilityInfo(1), false /* isNotAWord */,
false /* isPossiblyOffensive */);
- dict.add("bar", new ProbabilityInfo(1), null, false /* isNotAWord */,
+ dict.add("bar", new ProbabilityInfo(1), false /* isNotAWord */,
false /* isPossiblyOffensive */);
- dict.add("fool", new ProbabilityInfo(1), null, false /* isNotAWord */,
+ dict.add("fool", new ProbabilityInfo(1), false /* isNotAWord */,
false /* isPossiblyOffensive */);
final ArrayList<PtNodeArray> result =
BinaryDictEncoderUtils.flattenTree(dict.mRootNodeArray);
diff --git a/tools/dicttool/tests/com/android/inputmethod/latin/makedict/FusionDictionaryTest.java b/tools/dicttool/tests/com/android/inputmethod/latin/makedict/FusionDictionaryTest.java
index 1a4f096e4..626023920 100644
--- a/tools/dicttool/tests/com/android/inputmethod/latin/makedict/FusionDictionaryTest.java
+++ b/tools/dicttool/tests/com/android/inputmethod/latin/makedict/FusionDictionaryTest.java
@@ -102,7 +102,7 @@ public class FusionDictionaryTest extends TestCase {
prepare(time);
for (int i = 0; i < sWords.size(); ++i) {
System.out.println("Adding in pos " + i + " : " + dumpWord(sWords.get(i)));
- dict.add(sWords.get(i), new ProbabilityInfo(180), null, false,
+ dict.add(sWords.get(i), new ProbabilityInfo(180), false,
false /* isPossiblyOffensive */);
dumpDict(dict);
checkDictionary(dict, sWords, i);
diff --git a/tools/make-keyboard-text/Android.bp b/tools/make-keyboard-text/Android.bp
new file mode 100644
index 000000000..4976051da
--- /dev/null
+++ b/tools/make-keyboard-text/Android.bp
@@ -0,0 +1,22 @@
+//
+// Copyright (C) 2012 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+java_binary_host {
+ name: "make-keyboard-text",
+
+ srcs: ["src/**/*.java"],
+ main_class: "com.android.inputmethod.keyboard.tools.MakeKeyboardText",
+ java_resource_dirs: ["res"],
+}
diff --git a/tools/make-keyboard-text/Android.mk b/tools/make-keyboard-text/Android.mk
deleted file mode 100644
index 87601489e..000000000
--- a/tools/make-keyboard-text/Android.mk
+++ /dev/null
@@ -1,25 +0,0 @@
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES += $(call all-java-files-under,src)
-LOCAL_JAR_MANIFEST := etc/manifest.txt
-LOCAL_JAVA_RESOURCE_DIRS := res
-LOCAL_MODULE := make-keyboard-text
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-include $(LOCAL_PATH)/etc/Android.mk
diff --git a/tools/make-keyboard-text/etc/Android.mk b/tools/make-keyboard-text/etc/Android.mk
deleted file mode 100644
index 0fbf4ffe9..000000000
--- a/tools/make-keyboard-text/etc/Android.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_EXECUTABLES := make-keyboard-text
-
-include $(BUILD_HOST_PREBUILT)
diff --git a/tools/make-keyboard-text/etc/make-keyboard-text b/tools/make-keyboard-text/etc/make-keyboard-text
deleted file mode 100755
index 156f9ec5f..000000000
--- a/tools/make-keyboard-text/etc/make-keyboard-text
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/sh
-# Copyright 2012, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-jarfile=make-keyboard-text.jar
-frameworkdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/tools/lib
- libdir=`dirname "$progdir"`/tools/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
- libdir=`dirname "$progdir"`/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo `basename "$prog"`": can't find $jarfile"
- exit 1
-fi
-
-if [ "$OSTYPE" = "cygwin" ] ; then
- jarpath=`cygpath -w "$frameworkdir/$jarfile"`
- progdir=`cygpath -w "$progdir"`
-else
- jarpath="$frameworkdir/$jarfile"
-fi
-
-# need to use "java.ext.dirs" because "-jar" causes classpath to be ignored
-# might need more memory, e.g. -Xmx128M
-exec java -ea -jar "$jarpath" "$@"
diff --git a/tools/make-keyboard-text/etc/manifest.txt b/tools/make-keyboard-text/etc/manifest.txt
deleted file mode 100644
index 8ad4db059..000000000
--- a/tools/make-keyboard-text/etc/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Main-Class: com.android.inputmethod.keyboard.tools.MakeKeyboardText