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
0de2fbd7
Commit
0de2fbd7
authored
13 years ago
by
Tadashi G. Takaoka
Browse files
Options
Downloads
Patches
Plain Diff
Fix KeySpecParserTests to read correct icon id
Change-Id: Ic002e7fbe84a7001874ebd59e6af8ba695d173de
parent
909b2940
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/keyboard/internal/KeySpecParserTests.java
+17
-13
17 additions, 13 deletions
...oid/inputmethod/keyboard/internal/KeySpecParserTests.java
with
17 additions
and
13 deletions
tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTests.java
+
17
−
13
View file @
0de2fbd7
...
@@ -27,15 +27,18 @@ import java.util.Arrays;
...
@@ -27,15 +27,18 @@ import java.util.Arrays;
public
class
KeySpecParserTests
extends
AndroidTestCase
{
public
class
KeySpecParserTests
extends
AndroidTestCase
{
private
Resources
mRes
;
private
Resources
mRes
;
private
static
final
int
ICON_SETTINGS_KEY
=
R
.
styleable
.
Keyboard_iconSettingsKey
;
private
static
final
int
ICON_UNDEFINED
=
KeyboardIconsSet
.
ICON_UNDEFINED
;
private
static
final
int
ICON_UNDEFINED
=
KeyboardIconsSet
.
ICON_UNDEFINED
;
private
static
final
String
CODE_SETTINGS
=
"@integer/key_settings"
;
private
static
final
String
CODE_SETTINGS_RES
=
"integer/key_settings"
;
private
static
final
String
ICON_SETTINGS
=
"@icon/settingsKey"
;
private
static
final
String
ICON_SETTINGS_NAME
=
"settingsKey"
;
private
static
final
String
CODE_SETTINGS
=
"@"
+
CODE_SETTINGS_RES
;
private
static
final
String
ICON_SETTINGS
=
"@icon/"
+
ICON_SETTINGS_NAME
;
private
static
final
String
CODE_NON_EXISTING
=
"@integer/non_existing"
;
private
static
final
String
CODE_NON_EXISTING
=
"@integer/non_existing"
;
private
static
final
String
ICON_NON_EXISTING
=
"@icon/non_existing"
;
private
static
final
String
ICON_NON_EXISTING
=
"@icon/non_existing"
;
private
int
mCodeSettings
;
private
int
mCodeSettings
;
private
int
mSettingsIconId
;
@Override
@Override
protected
void
setUp
()
{
protected
void
setUp
()
{
...
@@ -43,8 +46,9 @@ public class KeySpecParserTests extends AndroidTestCase {
...
@@ -43,8 +46,9 @@ public class KeySpecParserTests extends AndroidTestCase {
mRes
=
res
;
mRes
=
res
;
final
String
packageName
=
res
.
getResourcePackageName
(
R
.
string
.
english_ime_name
);
final
String
packageName
=
res
.
getResourcePackageName
(
R
.
string
.
english_ime_name
);
final
int
codeId
=
res
.
getIdentifier
(
CODE_SETTINGS
.
substring
(
1
)
,
null
,
packageName
);
final
int
codeId
=
res
.
getIdentifier
(
CODE_SETTINGS
_RES
,
null
,
packageName
);
mCodeSettings
=
res
.
getInteger
(
codeId
);
mCodeSettings
=
res
.
getInteger
(
codeId
);
mSettingsIconId
=
KeyboardIconsSet
.
getIconId
(
ICON_SETTINGS_NAME
);
}
}
private
void
assertParser
(
String
message
,
String
moreKeySpec
,
String
expectedLabel
,
private
void
assertParser
(
String
message
,
String
moreKeySpec
,
String
expectedLabel
,
...
@@ -202,13 +206,13 @@ public class KeySpecParserTests extends AndroidTestCase {
...
@@ -202,13 +206,13 @@ public class KeySpecParserTests extends AndroidTestCase {
public
void
testIconAndCode
()
{
public
void
testIconAndCode
()
{
assertParser
(
"Icon with outputText"
,
ICON_SETTINGS
+
"|abc"
,
assertParser
(
"Icon with outputText"
,
ICON_SETTINGS
+
"|abc"
,
null
,
"abc"
,
ICON_SETTINGS_KEY
,
Keyboard
.
CODE_OUTPUT_TEXT
);
null
,
"abc"
,
mSettingsIconId
,
Keyboard
.
CODE_OUTPUT_TEXT
);
assertParser
(
"Icon with outputText starts with at"
,
ICON_SETTINGS
+
"|@bc"
,
assertParser
(
"Icon with outputText starts with at"
,
ICON_SETTINGS
+
"|@bc"
,
null
,
"@bc"
,
ICON_SETTINGS_KEY
,
Keyboard
.
CODE_OUTPUT_TEXT
);
null
,
"@bc"
,
mSettingsIconId
,
Keyboard
.
CODE_OUTPUT_TEXT
);
assertParser
(
"Icon with outputText contains at"
,
ICON_SETTINGS
+
"|a@c"
,
assertParser
(
"Icon with outputText contains at"
,
ICON_SETTINGS
+
"|a@c"
,
null
,
"a@c"
,
ICON_SETTINGS_KEY
,
Keyboard
.
CODE_OUTPUT_TEXT
);
null
,
"a@c"
,
mSettingsIconId
,
Keyboard
.
CODE_OUTPUT_TEXT
);
assertParser
(
"Icon with escaped at outputText"
,
ICON_SETTINGS
+
"|\\@bc"
,
assertParser
(
"Icon with escaped at outputText"
,
ICON_SETTINGS
+
"|\\@bc"
,
null
,
"@bc"
,
ICON_SETTINGS_KEY
,
Keyboard
.
CODE_OUTPUT_TEXT
);
null
,
"@bc"
,
mSettingsIconId
,
Keyboard
.
CODE_OUTPUT_TEXT
);
assertParser
(
"Label starts with at and code"
,
"@bc|"
+
CODE_SETTINGS
,
assertParser
(
"Label starts with at and code"
,
"@bc|"
+
CODE_SETTINGS
,
"@bc"
,
null
,
ICON_UNDEFINED
,
mCodeSettings
);
"@bc"
,
null
,
ICON_UNDEFINED
,
mCodeSettings
);
assertParser
(
"Label contains at and code"
,
"a@c|"
+
CODE_SETTINGS
,
assertParser
(
"Label contains at and code"
,
"a@c|"
+
CODE_SETTINGS
,
...
@@ -216,7 +220,7 @@ public class KeySpecParserTests extends AndroidTestCase {
...
@@ -216,7 +220,7 @@ public class KeySpecParserTests extends AndroidTestCase {
assertParser
(
"Escaped at label with code"
,
"\\@bc|"
+
CODE_SETTINGS
,
assertParser
(
"Escaped at label with code"
,
"\\@bc|"
+
CODE_SETTINGS
,
"@bc"
,
null
,
ICON_UNDEFINED
,
mCodeSettings
);
"@bc"
,
null
,
ICON_UNDEFINED
,
mCodeSettings
);
assertParser
(
"Icon with code"
,
ICON_SETTINGS
+
"|"
+
CODE_SETTINGS
,
assertParser
(
"Icon with code"
,
ICON_SETTINGS
+
"|"
+
CODE_SETTINGS
,
null
,
null
,
ICON_SETTINGS_KEY
,
mCodeSettings
);
null
,
null
,
mSettingsIconId
,
mCodeSettings
);
}
}
public
void
testFormatError
()
{
public
void
testFormatError
()
{
...
@@ -229,11 +233,11 @@ public class KeySpecParserTests extends AndroidTestCase {
...
@@ -229,11 +233,11 @@ public class KeySpecParserTests extends AndroidTestCase {
assertParserError
(
"Empty outputText with label"
,
"a|"
,
assertParserError
(
"Empty outputText with label"
,
"a|"
,
"a"
,
null
,
ICON_UNDEFINED
,
Keyboard
.
CODE_UNSPECIFIED
);
"a"
,
null
,
ICON_UNDEFINED
,
Keyboard
.
CODE_UNSPECIFIED
);
assertParserError
(
"Empty outputText with icon"
,
ICON_SETTINGS
+
"|"
,
assertParserError
(
"Empty outputText with icon"
,
ICON_SETTINGS
+
"|"
,
null
,
null
,
ICON_SETTINGS_KEY
,
Keyboard
.
CODE_UNSPECIFIED
);
null
,
null
,
mSettingsIconId
,
Keyboard
.
CODE_UNSPECIFIED
);
assertParserError
(
"Empty icon and code"
,
"|"
,
assertParserError
(
"Empty icon and code"
,
"|"
,
null
,
null
,
ICON_UNDEFINED
,
Keyboard
.
CODE_UNSPECIFIED
);
null
,
null
,
ICON_UNDEFINED
,
Keyboard
.
CODE_UNSPECIFIED
);
assertParserError
(
"Icon without code"
,
ICON_SETTINGS
,
assertParserError
(
"Icon without code"
,
ICON_SETTINGS
,
null
,
null
,
ICON_SETTINGS_KEY
,
Keyboard
.
CODE_UNSPECIFIED
);
null
,
null
,
mSettingsIconId
,
Keyboard
.
CODE_UNSPECIFIED
);
assertParserError
(
"Non existing icon"
,
ICON_NON_EXISTING
+
"|abc"
,
assertParserError
(
"Non existing icon"
,
ICON_NON_EXISTING
+
"|abc"
,
null
,
"abc"
,
ICON_UNDEFINED
,
Keyboard
.
CODE_OUTPUT_TEXT
);
null
,
"abc"
,
ICON_UNDEFINED
,
Keyboard
.
CODE_OUTPUT_TEXT
);
assertParserError
(
"Non existing code"
,
"abc|"
+
CODE_NON_EXISTING
,
assertParserError
(
"Non existing code"
,
"abc|"
+
CODE_NON_EXISTING
,
...
@@ -245,10 +249,10 @@ public class KeySpecParserTests extends AndroidTestCase {
...
@@ -245,10 +249,10 @@ public class KeySpecParserTests extends AndroidTestCase {
assertParserError
(
"Multiple bar with label and code"
,
"a|"
+
CODE_SETTINGS
+
"|c"
,
assertParserError
(
"Multiple bar with label and code"
,
"a|"
+
CODE_SETTINGS
+
"|c"
,
"a"
,
null
,
ICON_UNDEFINED
,
mCodeSettings
);
"a"
,
null
,
ICON_UNDEFINED
,
mCodeSettings
);
assertParserError
(
"Multiple bar with icon and outputText"
,
ICON_SETTINGS
+
"|b|c"
,
assertParserError
(
"Multiple bar with icon and outputText"
,
ICON_SETTINGS
+
"|b|c"
,
null
,
null
,
ICON_SETTINGS_KEY
,
Keyboard
.
CODE_UNSPECIFIED
);
null
,
null
,
mSettingsIconId
,
Keyboard
.
CODE_UNSPECIFIED
);
assertParserError
(
"Multiple bar with icon and code"
,
assertParserError
(
"Multiple bar with icon and code"
,
ICON_SETTINGS
+
"|"
+
CODE_SETTINGS
+
"|c"
,
ICON_SETTINGS
+
"|"
+
CODE_SETTINGS
+
"|c"
,
null
,
null
,
ICON_SETTINGS_KEY
,
mCodeSettings
);
null
,
null
,
mSettingsIconId
,
mCodeSettings
);
}
}
private
static
void
assertMoreKeys
(
String
message
,
String
[]
moreKeys
,
private
static
void
assertMoreKeys
(
String
message
,
String
[]
moreKeys
,
...
...
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