am a7c44270: Merge "Add an initial test command to dicttool."

* commit 'a7c44270e5ccddc0044bcdc3d27bd4d6661fcda4':
  Add an initial test command to dicttool.
main
Jean Chalard 2013-06-19 04:34:57 -07:00 committed by Android Git Automerger
commit 788540ad2e
6 changed files with 66 additions and 8 deletions

View File

@ -28,12 +28,10 @@ LOCAL_ANNOTATIONS_SRC_FILES := \
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
$(LATINIME_CORE_SOURCE_DIRECTORY)/Constants.java \
$(call all-java-files-under, tests)
ifeq ($(DICTTOOL_UNITTEST), true)
LOCAL_SRC_FILES += $(call all-java-files-under, tests)
LOCAL_JAVA_LIBRARIES := junit
endif
LOCAL_JAVA_LIBRARIES := junit
LOCAL_JAR_MANIFEST := etc/manifest.txt
LOCAL_MODULE := dicttool_aosp

View File

@ -33,6 +33,7 @@ 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" ]
@ -51,12 +52,21 @@ then
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 -jar "$jarpath" "$@"
exec java -ea -classpath "$libpath":"$jarpath" "$classname" "$@"

View File

@ -27,5 +27,6 @@ public class CommandList {
Dicttool.addCommand("package", Package.Packager.class);
Dicttool.addCommand("unpackage", Package.Unpackager.class);
Dicttool.addCommand("makedict", Makedict.class);
Dicttool.addCommand("test", Test.class);
}
}

View File

@ -40,10 +40,12 @@ public class Crypt {
public Encrypter() {
}
@Override
public String getHelp() {
return COMMAND + " <src_filename> <dst_filename>: Encrypts a file";
}
@Override
public void run() {
throw new UnsupportedOperationException();
}
@ -55,10 +57,12 @@ public class Crypt {
public Decrypter() {
}
@Override
public String getHelp() {
return COMMAND + " <src_filename> <dst_filename>: Decrypts a file";
}
@Override
public void run() {
throw new UnsupportedOperationException();
}

View File

@ -22,9 +22,7 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
public class Package {
private Package() {
@ -39,10 +37,12 @@ public class Package {
public Packager() {
}
@Override
public String getHelp() {
return COMMAND + " <src_filename> <dst_filename>: Package a file for distribution";
}
@Override
public void run() throws IOException {
if (mArgs.length != 2) {
throw new RuntimeException("Too many/too few arguments for command " + COMMAND);
@ -67,11 +67,13 @@ public class Package {
public Unpackager() {
}
@Override
public String getHelp() {
return COMMAND + " <src_filename> <dst_filename>: Detects how a file is packaged and\n"
+ "decrypts/uncompresses as necessary to produce a raw binary file.";
}
@Override
public void run() throws FileNotFoundException, IOException {
if (mArgs.length != 2) {
throw new RuntimeException("Too many/too few arguments for command " + COMMAND);

View File

@ -0,0 +1,43 @@
/**
* 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.dicttool;
import com.android.inputmethod.latin.makedict.UnsupportedFormatException;
import java.io.IOException;
public class Test extends Dicttool.Command {
public static final String COMMAND = "test";
public Test() {
}
@Override
public String getHelp() {
return "test";
}
@Override
public void run() throws IOException, UnsupportedFormatException {
test();
}
private void test() throws IOException, UnsupportedFormatException {
final BinaryDictOffdeviceUtilsTests tests = new BinaryDictOffdeviceUtilsTests();
tests.testGetRawDictWorks();
}
}