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
7185f30a
Commit
7185f30a
authored
10 years ago
by
Keisuke Kuroyanagi
Browse files
Options
Downloads
Patches
Plain Diff
Remove all test dictionary files before and after unit test.
Change-Id: I92db6318daa98684639ab959f55d047a941fe265
parent
82be1873
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
+26
-4
26 additions, 4 deletions
...hod/latin/personalization/UserHistoryDictionaryTests.java
with
26 additions
and
4 deletions
tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java
+
26
−
4
View file @
7185f30a
...
...
@@ -28,6 +28,7 @@ import com.android.inputmethod.latin.utils.DistracterFilter;
import
com.android.inputmethod.latin.utils.FileUtils
;
import
java.io.File
;
import
java.io.FilenameFilter
;
import
java.util.ArrayList
;
import
java.util.HashSet
;
import
java.util.List
;
...
...
@@ -42,6 +43,7 @@ import java.util.concurrent.TimeUnit;
public
class
UserHistoryDictionaryTests
extends
AndroidTestCase
{
private
static
final
String
TAG
=
UserHistoryDictionaryTests
.
class
.
getSimpleName
();
private
static
final
int
WAIT_FOR_WRITING_FILE_IN_MILLISECONDS
=
3000
;
private
static
final
String
TEST_LOCALE_PREFIX
=
"test_"
;
private
static
final
String
[]
CHARACTERS
=
{
"a"
,
"b"
,
"c"
,
"d"
,
"e"
,
"f"
,
"g"
,
"h"
,
"i"
,
"j"
,
"k"
,
"l"
,
"m"
,
...
...
@@ -50,14 +52,31 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
private
int
mCurrentTime
=
0
;
private
void
removeAllTestDictFiles
()
{
final
Locale
dummyLocale
=
new
Locale
(
TEST_LOCALE_PREFIX
);
final
String
dictName
=
ExpandableBinaryDictionary
.
getDictName
(
UserHistoryDictionary
.
NAME
,
dummyLocale
,
null
/* dictFile */
);
final
File
dictFile
=
ExpandableBinaryDictionary
.
getDictFile
(
mContext
,
dictName
,
null
/* dictFile */
);
final
FilenameFilter
filenameFilter
=
new
FilenameFilter
()
{
@Override
public
boolean
accept
(
File
dir
,
String
filename
)
{
return
filename
.
startsWith
(
UserHistoryDictionary
.
NAME
+
"."
+
TEST_LOCALE_PREFIX
);
}
};
FileUtils
.
deleteFilteredFiles
(
dictFile
.
getParentFile
(),
filenameFilter
);
}
@Override
protected
void
setUp
()
throws
Exception
{
super
.
setUp
();
resetCurrentTimeForTestMode
();
removeAllTestDictFiles
();
}
@Override
protected
void
tearDown
()
throws
Exception
{
removeAllTestDictFiles
();
stopTestModeInNativeCode
();
super
.
tearDown
();
}
...
...
@@ -169,7 +188,8 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
public
void
testRandomWords
()
{
Log
.
d
(
TAG
,
"This test can be used for profiling."
);
Log
.
d
(
TAG
,
"Usage: please set UserHistoryDictionary.PROFILE_SAVE_RESTORE to true."
);
final
Locale
dummyLocale
=
new
Locale
(
"test_random_words"
+
System
.
currentTimeMillis
());
final
Locale
dummyLocale
=
new
Locale
(
TEST_LOCALE_PREFIX
+
"random_words"
+
System
.
currentTimeMillis
());
final
String
dictName
=
ExpandableBinaryDictionary
.
getDictName
(
UserHistoryDictionary
.
NAME
,
dummyLocale
,
null
/* dictFile */
);
final
File
dictFile
=
ExpandableBinaryDictionary
.
getDictFile
(
...
...
@@ -202,7 +222,7 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
// Create filename suffixes for this test.
for
(
int
i
=
0
;
i
<
numberOfLanguages
;
i
++)
{
dummyLocales
[
i
]
=
new
Locale
(
"test_
switching_languages"
+
i
);
dummyLocales
[
i
]
=
new
Locale
(
TEST_LOCALE_PREFIX
+
"
switching_languages"
+
i
);
final
String
dictName
=
ExpandableBinaryDictionary
.
getDictName
(
UserHistoryDictionary
.
NAME
,
dummyLocales
[
i
],
null
/* dictFile */
);
dictFiles
[
i
]
=
ExpandableBinaryDictionary
.
getDictFile
(
...
...
@@ -236,7 +256,8 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
}
public
void
testAddManyWords
()
{
final
Locale
dummyLocale
=
new
Locale
(
"test_random_words"
+
System
.
currentTimeMillis
());
final
Locale
dummyLocale
=
new
Locale
(
TEST_LOCALE_PREFIX
+
"random_words"
+
System
.
currentTimeMillis
());
final
String
dictName
=
ExpandableBinaryDictionary
.
getDictName
(
UserHistoryDictionary
.
NAME
,
dummyLocale
,
null
/* dictFile */
);
final
File
dictFile
=
ExpandableBinaryDictionary
.
getDictFile
(
...
...
@@ -264,7 +285,8 @@ public class UserHistoryDictionaryTests extends AndroidTestCase {
}
public
void
testDecaying
()
{
final
Locale
dummyLocale
=
new
Locale
(
"test_decaying"
+
System
.
currentTimeMillis
());
final
Locale
dummyLocale
=
new
Locale
(
TEST_LOCALE_PREFIX
+
"decaying"
+
System
.
currentTimeMillis
());
final
int
numberOfWords
=
5000
;
final
Random
random
=
new
Random
(
123456
);
resetCurrentTimeForTestMode
();
...
...
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