Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(791)

Side by Side Diff: chrome/test/data/extensions/api_test/input_ime_nonchromeos/background.js

Issue 1805423002: Revert of Add tests for input.ime.* APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 chrome.test.runTests([ 5 chrome.test.runTests([
6 function testActivate() { 6 function testActivate() {
7 var focused = false; 7 var focused = false;
8 var activated = false; 8 var activated = false;
9 chrome.input.ime.onFocus.addListener(function(context) { 9 chrome.input.ime.onFocus.addListener(function(context) {
10 if (context.type == 'none') { 10 if (context.type == 'none') {
11 chrome.test.fail(); 11 chrome.test.fail();
12 return; 12 return;
13 } 13 }
14 focused = true; 14 focused = true;
15 chrome.test.sendMessage('get_focus_event');
16 if (activated) 15 if (activated)
17 chrome.test.succeed(); 16 chrome.test.succeed();
18 }); 17 });
19 chrome.input.ime.activate(function() { 18 chrome.input.ime.activate(function() {
20 if (chrome.runtime.lastError) { 19 if (chrome.runtime.lastError) {
21 chrome.test.fail(); 20 chrome.test.fail();
22 return; 21 return;
23 } 22 }
24 activated = true; 23 activated = true;
25 if (focused) 24 if (focused)
(...skipping 21 matching lines...) Expand all
47 chrome.test.assertTrue(!!win); 46 chrome.test.assertTrue(!!win);
48 chrome.test.assertTrue(win instanceof Window); 47 chrome.test.assertTrue(win instanceof Window);
49 chrome.test.assertFalse(win.document.webkitHidden); 48 chrome.test.assertFalse(win.document.webkitHidden);
50 // test for security origin. 49 // test for security origin.
51 // If security origin is not correctly set, there will be securtiy 50 // If security origin is not correctly set, there will be securtiy
52 // exceptions when accessing DOM or add event listeners. 51 // exceptions when accessing DOM or add event listeners.
53 win.addEventListener('unload', function() {}); 52 win.addEventListener('unload', function() {});
54 chrome.test.succeed(); 53 chrome.test.succeed();
55 }); 54 });
56 }, 55 },
57 function testBlur() { 56
58 chrome.input.ime.onBlur.addListener(function(context) {
59 if (context.type == 'none') {
60 chrome.test.fail();
61 return;
62 }
63 chrome.test.sendMessage('get_blur_event');
64 chrome.test.succeed();
65 });
66 chrome.test.succeed();
67 },
68 function testSendKeyEvents() { 57 function testSendKeyEvents() {
69 chrome.input.ime.sendKeyEvents({ 58 chrome.input.ime.sendKeyEvents({
70 'contextID': 1, 59 'contextID': 1,
71 'keyData': [{ 60 'keyData': [{
72 'type': 'keydown', 61 'type': 'keydown',
73 'requestId': '0', 62 'requestId': '0',
74 'key': 'a', 63 'key': 'a',
75 'code': 'KeyA' 64 'code': 'KeyA'
76 }, { 65 }, {
77 'type': 'keyup', 66 'type': 'keyup',
78 'requestId': '1', 67 'requestId': '1',
79 'key': 'a', 68 'key': 'a',
80 'code': 'KeyA' 69 'code': 'KeyA'
81 }] 70 }]
82 }); 71 });
83 chrome.test.succeed(); 72 chrome.test.succeed();
84 }, 73 }
85 function testCommitText() {
86 chrome.input.ime.commitText({
87 contextID: 1,
88 text: 'test_commit_text'
89 }, function () {
90 if (chrome.runtime.lastError) {
91 chrome.test.fail();
92 return;
93 }
94 chrome.test.succeed();
95 });
96 },
97 function testComposition() {
98 chrome.input.ime.onCompositionBoundsChanged.addListener(
99 function(boundsList) {
100 if (boundsList.length > 0 && boundsList[0].width > 1 ){
101 for (var i = 0; i < boundsList.length; i++ ) {
102 if (i==0) {
103 composition_left = boundsList[i].left;
104 composition_top = boundsList[i].top;
105 composition_width = boundsList[i].width;
106 composition_height = boundsList[i].height;
107 }
108 else {
109 chrome.test.assertEq(boundsList[i].top, composition_top);
110 chrome.test.assertEq(boundsList[i].height, composition_height);
111 chrome.test.assertEq(boundsList[i].left,
112 composition_left + composition_width);
113 composition_left = boundsList[i].left;
114 composition_width = boundsList[i].width;
115 }
116 }
117 }
118 if (boundsList.length > 20) {
119 chrome.test.sendMessage('finish_composition_test');
120 }
121 chrome.test.succeed();
122 });
123 chrome.input.ime.setComposition({
124 contextID: 1,
125 text: 'test_composition_text',
126 cursor: 2
127 }, function() {
128 if(chrome.runtime.lastError) {
129 chrome.test.fail();
130 return;
131 }
132 chrome.test.succeed();
133 });
134 }
135 ]); 74 ]);
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/ime/input_ime_apitest_nonchromeos.cc ('k') | ui/base/ime/dummy_text_input_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698