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
......@@ -779,9 +779,9 @@ bool SetCursorPositionFunction::RunImpl() {
int candidate_id;
EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kContextIdKey,
&context_id));
&context_id));
EXTENSION_FUNCTION_VALIDATE(args->GetInteger(keys::kCandidateIdKey,
&candidate_id));
&candidate_id));
if (engine->SetCursorPosition(context_id, candidate_id, &error_)) {
result_.reset(Value::CreateBooleanValue(true));
......
......@@ -64,35 +64,35 @@ class ExtensionInputImeEventRouter {
DISALLOW_COPY_AND_ASSIGN(ExtensionInputImeEventRouter);
};
class SetCompositionFunction : public AsyncExtensionFunction {
class SetCompositionFunction : public SyncExtensionFunction {
public:
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.input.ime.setComposition");
};
class ClearCompositionFunction : public AsyncExtensionFunction {
class ClearCompositionFunction : public SyncExtensionFunction {
public:
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.input.ime.clearComposition");
};
class CommitTextFunction : public AsyncExtensionFunction {
class CommitTextFunction : public SyncExtensionFunction {
public:
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.input.ime.commitText");
};
class SetCandidateWindowPropertiesFunction : public AsyncExtensionFunction {
class SetCandidateWindowPropertiesFunction : public SyncExtensionFunction {
public:
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME(
"experimental.input.ime.setCandidateWindowProperties");
};
class SetCandidatesFunction : public AsyncExtensionFunction {
class SetCandidatesFunction : public SyncExtensionFunction {
public:
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME(
......@@ -103,7 +103,7 @@ class SetCandidatesFunction : public AsyncExtensionFunction {
std::vector<chromeos::InputMethodEngine::Candidate>* output);
};
class SetCursorPositionFunction : public AsyncExtensionFunction {
class SetCursorPositionFunction : public SyncExtensionFunction {
public:
virtual bool RunImpl();
DECLARE_EXTENSION_FUNCTION_NAME(
......
......@@ -3371,21 +3371,24 @@
},
"segments": {
"description": "List of segments and their associated types.",
"type": "object",
"type": "array",
"optional": true,
"properties": {
"start": {
"description": "Index of the character to start this segment at",
"type": "integer"
},
"end": {
"description": "Index of the character to end this segment after.",
"type": "integer"
},
"style": {
"description": "How to render this segment",
"enum": ["underline", "doubleUnderline"],
"type": "string"
"items": {
"type": "object",
"properties": {
"start": {
"description": "Index of the character to start this segment at",
"type": "integer"
},
"end": {
"description": "Index of the character to end this segment after.",
"type": "integer"
},
"style": {
"description": "How to render this segment",
"enum": ["underline", "doubleUnderline"],
"type": "string"
}
}
}
}
......@@ -3598,7 +3601,12 @@
"name": "callback",
"optional": true,
"description": "Called when the operation completes",
"parameters": []
"parameters": [
{
"name": "success",
"type": "boolean"
}
]
}
]
},
......
<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() {
chrome.experimental.input.ime.setMenuItems({
"engineID": "test",
......@@ -15,10 +92,7 @@
"visible": true,
"enabled": true
}]
}, function () {
chrome.test.assertNoLastError();
chrome.test.succeed();
});
}, chrome.test.callbackPass());
}
function updateMenuItemsTest() {
......@@ -31,11 +105,11 @@
"id": "Menu 2",
"visible": false,
}]
}, function () {
chrome.test.assertNoLastError();
chrome.test.succeed();
});
}, chrome.test.callbackPass());
}
chrome.test.runTests([setMenuItemsTest, updateMenuItemsTest]);
chrome.test.runTests([setCompositionTest, clearCompositionTest,
commitTextTest, setCandidateWindowPropertiesTest,
setCandidatesTest, setCursorPositionTest,
setMenuItemsTest, updateMenuItemsTest]);
</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