Commit 26446308 authored by zork@chromium.org's avatar zork@chromium.org

Add API tests for all input.ime functions.

R=mpcomplete@chromium.org
BUG=chromium-os:23194
TEST=Run browser_tests --gtest_filter="ExtensionApiTest.InputImeApiBasic"

Review URL: http://codereview.chromium.org/8558013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110884 0039d316-1c4b-4281-b951-d872f2087c98
parent 602f618c
...@@ -64,35 +64,35 @@ class ExtensionInputImeEventRouter { ...@@ -64,35 +64,35 @@ class ExtensionInputImeEventRouter {
DISALLOW_COPY_AND_ASSIGN(ExtensionInputImeEventRouter); DISALLOW_COPY_AND_ASSIGN(ExtensionInputImeEventRouter);
}; };
class SetCompositionFunction : public AsyncExtensionFunction { class SetCompositionFunction : public SyncExtensionFunction {
public: public:
virtual bool RunImpl(); virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME( DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.input.ime.setComposition"); "experimental.input.ime.setComposition");
}; };
class ClearCompositionFunction : public AsyncExtensionFunction { class ClearCompositionFunction : public SyncExtensionFunction {
public: public:
virtual bool RunImpl(); virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME( DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.input.ime.clearComposition"); "experimental.input.ime.clearComposition");
}; };
class CommitTextFunction : public AsyncExtensionFunction { class CommitTextFunction : public SyncExtensionFunction {
public: public:
virtual bool RunImpl(); virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME( DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.input.ime.commitText"); "experimental.input.ime.commitText");
}; };
class SetCandidateWindowPropertiesFunction : public AsyncExtensionFunction { class SetCandidateWindowPropertiesFunction : public SyncExtensionFunction {
public: public:
virtual bool RunImpl(); virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME( DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.input.ime.setCandidateWindowProperties"); "experimental.input.ime.setCandidateWindowProperties");
}; };
class SetCandidatesFunction : public AsyncExtensionFunction { class SetCandidatesFunction : public SyncExtensionFunction {
public: public:
virtual bool RunImpl(); virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME( DECLARE_EXTENSION_FUNCTION_NAME(
...@@ -103,7 +103,7 @@ class SetCandidatesFunction : public AsyncExtensionFunction { ...@@ -103,7 +103,7 @@ class SetCandidatesFunction : public AsyncExtensionFunction {
std::vector<chromeos::InputMethodEngine::Candidate>* output); std::vector<chromeos::InputMethodEngine::Candidate>* output);
}; };
class SetCursorPositionFunction : public AsyncExtensionFunction { class SetCursorPositionFunction : public SyncExtensionFunction {
public: public:
virtual bool RunImpl(); virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME( DECLARE_EXTENSION_FUNCTION_NAME(
......
...@@ -3371,8 +3371,10 @@ ...@@ -3371,8 +3371,10 @@
}, },
"segments": { "segments": {
"description": "List of segments and their associated types.", "description": "List of segments and their associated types.",
"type": "object", "type": "array",
"optional": true, "optional": true,
"items": {
"type": "object",
"properties": { "properties": {
"start": { "start": {
"description": "Index of the character to start this segment at", "description": "Index of the character to start this segment at",
...@@ -3390,6 +3392,7 @@ ...@@ -3390,6 +3392,7 @@
} }
} }
} }
}
}, },
{ {
"type": "function", "type": "function",
...@@ -3598,7 +3601,12 @@ ...@@ -3598,7 +3601,12 @@
"name": "callback", "name": "callback",
"optional": true, "optional": true,
"description": "Called when the operation completes", "description": "Called when the operation completes",
"parameters": [] "parameters": [
{
"name": "success",
"type": "boolean"
}
]
} }
] ]
}, },
......
<script> <script>
function setCompositionTest() {
chrome.experimental.input.ime.setComposition({
"contextID": 1,
"text": "Pie",
"selectionStart": 1,
"selectionEnd": 2,
"segments": [{
"start": 0,
"end": 1,
"style": "underline"
}]
}, chrome.test.callbackPass());
}
function clearCompositionTest() {
chrome.experimental.input.ime.clearComposition({
"contextID": 1
}, chrome.test.callbackPass());
}
function commitTextTest() {
chrome.experimental.input.ime.commitText({
"contextID": 2,
"text": "Seaguls"
}, chrome.test.callbackPass());
}
function setCandidateWindowPropertiesTest() {
chrome.experimental.input.ime.setCandidateWindowProperties({
"engineID": "test",
"properties": {
"visible": true,
"cursorVisible": false,
"vertical": true,
"pageSize": 6,
"auxiliaryText": "notes",
"auxiliaryTextVisible": true
}
}, chrome.test.callbackPass());
}
function setCandidatesTest() {
chrome.experimental.input.ime.setCandidates({
"contextID": 8,
"candidates": [{
"candidate": "one",
"id": 1,
"label": "first",
"annotation": "The first one"
}, {
"candidate": "two",
"id": 2,
"label": "second",
"annotation": "The second one"
}, {
"candidate": "three",
"id": 3,
"label": "third",
"annotation": "The third one"
}]
}, chrome.test.callbackPass());
}
function setCursorPositionTest() {
chrome.experimental.input.ime.setCursorPosition({
"contextID": 9,
"candidateID": 1
}, chrome.test.callbackPass());
}
function setMenuItemsTest() { function setMenuItemsTest() {
chrome.experimental.input.ime.setMenuItems({ chrome.experimental.input.ime.setMenuItems({
"engineID": "test", "engineID": "test",
...@@ -15,10 +92,7 @@ ...@@ -15,10 +92,7 @@
"visible": true, "visible": true,
"enabled": true "enabled": true
}] }]
}, function () { }, chrome.test.callbackPass());
chrome.test.assertNoLastError();
chrome.test.succeed();
});
} }
function updateMenuItemsTest() { function updateMenuItemsTest() {
...@@ -31,11 +105,11 @@ ...@@ -31,11 +105,11 @@
"id": "Menu 2", "id": "Menu 2",
"visible": false, "visible": false,
}] }]
}, function () { }, chrome.test.callbackPass());
chrome.test.assertNoLastError();
chrome.test.succeed();
});
} }
chrome.test.runTests([setMenuItemsTest, updateMenuItemsTest]); chrome.test.runTests([setCompositionTest, clearCompositionTest,
commitTextTest, setCandidateWindowPropertiesTest,
setCandidatesTest, setCursorPositionTest,
setMenuItemsTest, updateMenuItemsTest]);
</script> </script>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment