OLD | NEW |
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') { |
(...skipping 25 matching lines...) Expand all Loading... |
36 }); | 36 }); |
37 }, | 37 }, |
38 function testFollowCursorCreateWindow() { | 38 function testFollowCursorCreateWindow() { |
39 var options = { windowType: 'followCursor' }; | 39 var options = { windowType: 'followCursor' }; |
40 chrome.input.ime.createWindow(options, function(win) { | 40 chrome.input.ime.createWindow(options, function(win) { |
41 chrome.test.assertNoLastError() | 41 chrome.test.assertNoLastError() |
42 chrome.test.assertTrue(!!win); | 42 chrome.test.assertTrue(!!win); |
43 chrome.test.assertFalse(win.document.webkitHidden); | 43 chrome.test.assertFalse(win.document.webkitHidden); |
44 chrome.test.succeed(); | 44 chrome.test.succeed(); |
45 }); | 45 }); |
| 46 }, |
| 47 |
| 48 function testSendKeyEvent() { |
| 49 var key_vent_count = 0; |
| 50 |
| 51 chrome.input.ime.onKeyEvent.addListener(function(engineID, keyData) { |
| 52 if (key_vent_count == 0) { |
| 53 chrome.test.assertEq(keyData.type, 'keydown'); |
| 54 } |
| 55 else if (key_vent_count == 1) { |
| 56 chrome.test.assertEq(keyData.type, 'keyup'); |
| 57 chrome.test.succeed(); |
| 58 } |
| 59 chrome.test.assertEq(keyData.key, 'a'); |
| 60 chrome.test.assertEq(keyData.code, 'KeyA'); |
| 61 chrome.test.assertFalse(keyData.ctrlKey); |
| 62 chrome.test.assertFalse(keyData.altKey); |
| 63 chrome.test.assertFalse(keyData.shiftKey); |
| 64 chrome.test.assertFalse(keyData.capsLock); |
| 65 ++key_vent_count; |
| 66 return false; |
| 67 }); |
| 68 |
| 69 chrome.input.ime.sendKeyEvents({ |
| 70 'contextID': 1, |
| 71 'keyData': [{ |
| 72 'type': 'keydown', |
| 73 'requestId': '0', |
| 74 'key': 'a', |
| 75 'code': 'KeyA' |
| 76 }, { |
| 77 'type': 'keyup', |
| 78 'requestId': '1', |
| 79 'key': 'a', |
| 80 'code': 'KeyA' |
| 81 }] |
| 82 }); |
46 } | 83 } |
47 ]); | 84 ]); |
OLD | NEW |