Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
7086d88d
Commit
7086d88d
authored
10 years ago
by
Jean Chalard
Browse files
Options
Downloads
Patches
Plain Diff
Have dicttool test tidy up after itself.
Bug: 13776363 Change-Id: Icb1d3fc0efe71e0339b434928e8aed507f2fb590
parent
75cb258e
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/dicttool/compat/android/test/AndroidTestCase.java
+7
-1
7 additions, 1 deletion
tools/dicttool/compat/android/test/AndroidTestCase.java
tools/dicttool/src/com/android/inputmethod/latin/dicttool/Test.java
+29
-3
29 additions, 3 deletions
...tool/src/com/android/inputmethod/latin/dicttool/Test.java
with
36 additions
and
4 deletions
tools/dicttool/compat/android/test/AndroidTestCase.java
+
7
−
1
View file @
7086d88d
...
...
@@ -16,6 +16,8 @@
package
android.test
;
import
com.android.inputmethod.latin.dicttool.Test
;
import
junit.framework.TestCase
;
import
java.io.File
;
...
...
@@ -27,7 +29,11 @@ import java.io.File;
*/
public
class
AndroidTestCase
extends
TestCase
{
public
File
getCacheDir
()
{
return
new
File
(
"."
);
final
File
dir
=
Test
.
TEST_TMP_DIR
;
if
(!
dir
.
isDirectory
())
{
dir
.
mkdirs
();
}
return
dir
;
}
public
AndroidTestCase
getContext
()
{
return
this
;
...
...
This diff is collapsed.
Click to expand it.
tools/dicttool/src/com/android/inputmethod/latin/dicttool/Test.java
+
29
−
3
View file @
7086d88d
...
...
@@ -19,16 +19,29 @@ package com.android.inputmethod.latin.dicttool;
import
com.android.inputmethod.latin.makedict.BinaryDictDecoderEncoderTests
;
import
com.android.inputmethod.latin.makedict.BinaryDictEncoderFlattenTreeTests
;
import
com.android.inputmethod.latin.makedict.FusionDictionaryTest
;
import
com.android.inputmethod.latin.utils.FileUtils
;
import
java.io.File
;
import
java.io.IOException
;
import
java.lang.reflect.Constructor
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.Method
;
import
java.nio.file.Files
;
import
java.util.ArrayList
;
/**
* Dicttool command implementing self-tests.
*/
public
class
Test
extends
Dicttool
.
Command
{
private
static
final
String
getTmpDir
()
{
try
{
return
Files
.
createTempDirectory
(
"dicttool"
).
toString
();
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
"Can't get temporary directory"
,
e
);
}
}
private
static
final
String
TEST_TMP_DIR_BASE
=
getTmpDir
();
public
static
final
File
TEST_TMP_DIR
=
new
File
(
TEST_TMP_DIR_BASE
);
public
static
final
String
COMMAND
=
"test"
;
private
static
final
int
DEFAULT_MAX_UNIGRAMS
=
1500
;
private
long
mSeed
=
System
.
currentTimeMillis
();
...
...
@@ -56,8 +69,12 @@ public class Test extends Dicttool.Command {
@Override
public
String
getHelp
()
{
final
StringBuilder
s
=
new
StringBuilder
(
"test [-s seed] [-m maxUnigrams] [testName...]\n"
+
"If seed is not specified, the current time is used.\nTest list is:\n"
);
final
StringBuilder
s
=
new
StringBuilder
(
"test [-s seed] [-m maxUnigrams] [-n] [testName...]\n"
+
"If seed is not specified, the current time is used.\n"
+
"If -n option is provided, do not delete temporary files in "
+
TEST_TMP_DIR_BASE
+
"/*.\n"
+
"Test list is:\n"
);
for
(
final
Method
m
:
mAllTestMethods
)
{
s
.
append
(
" "
);
s
.
append
(
m
.
getName
());
...
...
@@ -70,17 +87,26 @@ public class Test extends Dicttool.Command {
public
void
run
()
throws
IllegalAccessException
,
InstantiationException
,
InvocationTargetException
{
int
i
=
0
;
boolean
deleteTmpDir
=
true
;
while
(
i
<
mArgs
.
length
)
{
final
String
arg
=
mArgs
[
i
++];
if
(
"-s"
.
equals
(
arg
))
{
mSeed
=
Long
.
parseLong
(
mArgs
[
i
++]);
}
else
if
(
"-m"
.
equals
(
arg
))
{
mMaxUnigrams
=
Integer
.
parseInt
(
mArgs
[
i
++]);
}
else
if
(
"-n"
.
equals
(
arg
))
{
deleteTmpDir
=
false
;
}
else
{
mUsedTestMethods
.
add
(
arg
);
}
}
runChosenTests
();
try
{
runChosenTests
();
}
finally
{
if
(
deleteTmpDir
)
{
FileUtils
.
deleteRecursively
(
TEST_TMP_DIR
);
}
}
}
private
void
runChosenTests
()
throws
IllegalAccessException
,
InstantiationException
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment