Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / input_ime / background.js
blob973c4532702169d72b6f3d6981608ba78460b68e
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 function setCompositionTest() {
6   chrome.input.ime.setComposition({
7     "contextID": 1,
8     "text": "Pie",
9     "selectionStart": 1,
10     "selectionEnd": 2,
11     "cursor": 3,
12     "segments": [{
13       "start": 0,
14       "end": 1,
15       "style": "underline"
16     }]
17   }, chrome.test.callbackPass());
21 function clearCompositionTest() {
22   chrome.input.ime.clearComposition({
23     "contextID": 1
24   }, chrome.test.callbackPass());
28 function commitTextTest() {
29   chrome.input.ime.commitText({
30     "contextID": 2,
31     "text": "Seaguls"
32   }, chrome.test.callbackPass());
36 function setCandidateWindowPropertiesTest() {
37   chrome.input.ime.setCandidateWindowProperties({
38     "engineID": "test",
39     "properties": {
40       "visible": true,
41       "cursorVisible": false,
42       "vertical": true,
43       "pageSize": 6,
44       "auxiliaryText": "notes",
45       "auxiliaryTextVisible": true
46     }
47   }, chrome.test.callbackPass());
51 function setCandidatesTest() {
52   chrome.input.ime.setCandidates({
53     "contextID": 8,
54     "candidates": [{
55       "candidate": "one",
56       "id": 1,
57       "label": "first",
58       "annotation": "The first one"
59     }, {
60       "candidate": "two",
61       "id": 2,
62       "label": "second",
63       "annotation": "The second one"
64     }, {
65       "candidate": "three",
66       "id": 3,
67       "label": "third",
68       "annotation": "The third one"
69     }]
70   }, chrome.test.callbackPass());
74 function setCursorPositionTest() {
75   chrome.input.ime.setCursorPosition({
76     "contextID": 9,
77     "candidateID": 1
78   }, chrome.test.callbackPass());
83 function setMenuItemsTest() {
84   chrome.input.ime.setMenuItems({
85     "engineID": "test",
86     "items": [{
87       "id": "Menu 1",
88       "label": "Menu 1",
89       "style": "check",
90       "visible": true,
91       "enabled": true
92     }, {
93       "id": "Menu 2",
94       "label": "Menu 2",
95       "style": "radio",
96       "visible": true,
97       "enabled": true
98     }]
99   }, chrome.test.callbackPass());
102 function updateMenuItemsTest() {
103   chrome.input.ime.updateMenuItems({
104     "engineID": "test",
105     "items": [{
106       "id": "Menu 1",
107       "enabled": false
108     }, {
109       "id": "Menu 2",
110       "visible": false,
111     }]
112   }, chrome.test.callbackPass());
115 function deleteSurroundingText() {
116   chrome.input.ime.deleteSurroundingText({
117     "engineID": "test",
118     "contextID": 1,
119     "offset": -1,
120     "length": 1
121   }, chrome.test.callbackPass());
124 chrome.test.runTests([setCompositionTest, clearCompositionTest,
125                       commitTextTest, setCandidateWindowPropertiesTest,
126                       setCandidatesTest, setCursorPositionTest,
127                       setMenuItemsTest, updateMenuItemsTest,
128                       deleteSurroundingText]);