diff options
Diffstat (limited to 'tools')
7 files changed, 159 insertions, 8 deletions
diff --git a/tools/dicttool/Android.mk b/tools/dicttool/Android.mk index d3bff8688..c99ba2f99 100644 --- a/tools/dicttool/Android.mk +++ b/tools/dicttool/Android.mk @@ -16,10 +16,22 @@ LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) -LATINIME_BASE_SOURCE_DIRECTORY := ../../java/src/com/android/inputmethod +BUILD_TOP := ../../../../.. +FRAMEWORK_TOP := $(BUILD_TOP)/frameworks/base/core/java +LATINIME_DIR := $(BUILD_TOP)/packages/inputmethods/LatinIME +LATINIME_BASE_SOURCE_DIRECTORY := $(LATINIME_DIR)/java/src/com/android/inputmethod LATINIME_CORE_SOURCE_DIRECTORY := $(LATINIME_BASE_SOURCE_DIRECTORY)/latin LATINIME_ANNOTATIONS_SOURCE_DIRECTORY := $(LATINIME_BASE_SOURCE_DIRECTORY)/annotations MAKEDICT_CORE_SOURCE_DIRECTORY := $(LATINIME_CORE_SOURCE_DIRECTORY)/makedict +DICTTOOL_COMPAT_TESTS_DIRECTORY := compat +DICTTOOL_ONDEVICE_TESTS_DIRECTORY := \ + $(LATINIME_DIR)/tests/src/com/android/inputmethod/latin/makedict/ + +USED_TARGETTED_UTILS := \ + $(FRAMEWORK_TOP)/android/util/SparseArray.java \ + $(FRAMEWORK_TOP)/com/android/internal/util/ArrayUtils.java \ + $(LATINIME_CORE_SOURCE_DIRECTORY)/CollectionUtils.java \ + $(LATINIME_CORE_SOURCE_DIRECTORY)/ByteArrayWrapper.java LOCAL_MAIN_SRC_FILES := $(call all-java-files-under, $(MAKEDICT_CORE_SOURCE_DIRECTORY)) LOCAL_TOOL_SRC_FILES := $(call all-java-files-under, src) @@ -29,7 +41,10 @@ LOCAL_SRC_FILES := $(LOCAL_TOOL_SRC_FILES) \ $(filter-out $(addprefix %/, $(notdir $(LOCAL_TOOL_SRC_FILES))), $(LOCAL_MAIN_SRC_FILES)) \ $(LOCAL_ANNOTATIONS_SRC_FILES) \ $(LATINIME_CORE_SOURCE_DIRECTORY)/Constants.java \ - $(call all-java-files-under, tests) + $(call all-java-files-under, tests) \ + $(call all-java-files-under, $(DICTTOOL_ONDEVICE_TESTS_DIRECTORY)) \ + $(call all-java-files-under, $(DICTTOOL_COMPAT_TESTS_DIRECTORY)) \ + $(USED_TARGETTED_UTILS) LOCAL_JAVA_LIBRARIES := junit diff --git a/tools/dicttool/compat/android/test/AndroidTestCase.java b/tools/dicttool/compat/android/test/AndroidTestCase.java new file mode 100644 index 000000000..d01b7ad7c --- /dev/null +++ b/tools/dicttool/compat/android/test/AndroidTestCase.java @@ -0,0 +1,35 @@ +/* + * 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 android.test; + +import junit.framework.TestCase; + +import java.io.File; + +/** + * This is a compatibility class that aims at emulating android.test.AndroidTestcase from the + * Android library as simply as possible, and only to the extent that is used by the client classes. + * Its purpose is to provide compatibility without having to pull the whole Android library. + */ +public class AndroidTestCase extends TestCase { + public File getCacheDir() { + return new File("."); + } + public AndroidTestCase getContext() { + return this; + } +} diff --git a/tools/dicttool/compat/android/test/MoreAsserts.java b/tools/dicttool/compat/android/test/MoreAsserts.java new file mode 100644 index 000000000..f56420b9c --- /dev/null +++ b/tools/dicttool/compat/android/test/MoreAsserts.java @@ -0,0 +1,35 @@ +/* + * 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 android.test; + +import junit.framework.Assert; + +/** + * This is a compatibility class that aims at emulating android.test.MoreAsserts from the + * Android library as simply as possible, and only to the extent that is used by the client classes. + * Its purpose is to provide compatibility without having to pull the whole Android library. + */ +public class MoreAsserts { + public static void assertNotEqual(Object unexpected, Object actual) { + if (equal(unexpected, actual)) { + Assert.fail("expected not to be:<" + unexpected + ">"); + } + } + private static boolean equal(Object a, Object b) { + return a == b || (a != null && a.equals(b)); + } +} diff --git a/tools/dicttool/compat/android/test/suitebuilder/annotation/LargeTest.java b/tools/dicttool/compat/android/test/suitebuilder/annotation/LargeTest.java new file mode 100644 index 000000000..ed00f8d5f --- /dev/null +++ b/tools/dicttool/compat/android/test/suitebuilder/annotation/LargeTest.java @@ -0,0 +1,25 @@ +/* + * 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 android.test.suitebuilder.annotation; + +/** + * This is a compatibility class that aims at emulating the LargeTest annotation from the + * Android library as simply as possible, and only to the extent that is used by the client classes. + * Its purpose is to provide compatibility without having to pull the whole Android library. + */ +public @interface LargeTest { +} diff --git a/tools/dicttool/compat/android/util/Log.java b/tools/dicttool/compat/android/util/Log.java new file mode 100644 index 000000000..d9df3a4ae --- /dev/null +++ b/tools/dicttool/compat/android/util/Log.java @@ -0,0 +1,37 @@ +/* + * 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 android.util; + +/** + * This is a compatibility class that aims at emulating android.util.Log from the + * Android library as simply as possible, and only to the extent that is used by the client classes. + * Its purpose is to provide compatibility without having to pull the whole Android library. + */ +public class Log { + public static void d(final String tag, final String message) { + System.out.println(tag + " : " + message); + } + public static void d(final String tag, final String message, final Exception e) { + System.out.println(tag + " : " + message + " : " + e); + } + public static void e(final String tag, final String message) { + d(tag, message); + } + public static void e(final String tag, final String message, final Exception e) { + e(tag, message, e); + } +} diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Test.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Test.java index fdc53b30e..827c5e3a9 100644 --- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Test.java +++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Test.java @@ -16,10 +16,16 @@ package com.android.inputmethod.latin.dicttool; +import com.android.inputmethod.latin.makedict.BinaryDictIOUtilsTests; +import com.android.inputmethod.latin.makedict.BinaryDictInputOutputTest; +import com.android.inputmethod.latin.makedict.FusionDictionaryTest; import com.android.inputmethod.latin.makedict.UnsupportedFormatException; import java.io.IOException; +/** + * Dicttool command implementing self-tests. + */ public class Test extends Dicttool.Command { public static final String COMMAND = "test"; @@ -37,7 +43,9 @@ public class Test extends Dicttool.Command { } private void test() throws IOException, UnsupportedFormatException { - final BinaryDictOffdeviceUtilsTests tests = new BinaryDictOffdeviceUtilsTests(); - tests.testGetRawDictWorks(); + new BinaryDictOffdeviceUtilsTests().testGetRawDictWorks(); + new FusionDictionaryTest().testFusion(); + new BinaryDictInputOutputTest().testFlattenNodes(); + new BinaryDictIOUtilsTests().testRandomWords(); } } 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 fe3781d80..76071133d 100644 --- a/tools/dicttool/tests/com/android/inputmethod/latin/makedict/FusionDictionaryTest.java +++ b/tools/dicttool/tests/com/android/inputmethod/latin/makedict/FusionDictionaryTest.java @@ -73,10 +73,6 @@ public class FusionDictionaryTest extends TestCase { for (final String word : words) { if (--limit < 0) return; final CharGroup cg = FusionDictionary.findWordInTree(dict.mRoot, word); - if (null == cg) { - System.out.println("word " + dumpWord(word)); - dumpDict(dict); - } assertNotNull(cg); } } |