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

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

Issue 305533002: Adds IME switching private APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 var kNewInputMethod = "fr::fra"; 5 var kOldInputMethod = "_comp_ime_fgoepimhcoialccpbmpnnblemnepkkaoxkb:us::eng";
6 var kNewInputMethod = "_comp_ime_fgoepimhcoialccpbmpnnblemnepkkaoxkb:fr::fra";
7 var kInvalidInputMethod = "xx::xxx";
6 8
7 function setAndGetTest() { 9 // The tests needs to be executed in order.
8 console.log('Changing input method to: ' + kNewInputMethod); 10
9 chrome.test.sendMessage('setInputMethod:' + kNewInputMethod, 11 function setTest() {
10 function (response) { 12 console.log('setTest: Changing input method to: ' + kNewInputMethod);
11 chrome.test.assertEq('done', response); 13 chrome.inputMethodPrivate.setCurrentInputMethod(kNewInputMethod,
12 console.log('Getting current input method.'); 14 function() {
13 chrome.inputMethodPrivate.get(function (inputMethod) { 15 chrome.test.assertTrue(!chrome.runtime.lastError);
14 chrome.test.assertEq(kNewInputMethod, inputMethod); 16 chrome.test.succeed();
15 chrome.test.succeed(); 17 });
16 } 18 }
17 ); 19
20 function getTest() {
21 console.log('getTest: Getting current input method.');
22 chrome.inputMethodPrivate.getCurrentInputMethod(function(inputMethod) {
23 chrome.test.assertEq(kNewInputMethod, inputMethod);
24 chrome.test.succeed();
18 }); 25 });
19 } 26 }
20 27
21 function setAndObserveTest() { 28 function observeTest() {
22 console.log('Adding input method event listener.'); 29 console.log('observeTest: Adding input method event listener.');
23 chrome.inputMethodPrivate.onChanged.addListener( 30 chrome.inputMethodPrivate.onChanged.addListener(function(subfix) {
24 function(newInputMethod) { 31 chrome.test.assertEq('us::eng', subfix);
25 chrome.test.assertEq(kNewInputMethod, newInputMethod); 32 chrome.test.succeed();
33 });
34 console.log('observeTest: Changing input method to: ' + kOldInputMethod);
35 chrome.inputMethodPrivate.setCurrentInputMethod(kOldInputMethod);
36 }
37
38
39 function setInvalidTest() {
40 console.log(
41 'setInvalidTest: Changing input method to: ' + kInvalidInputMethod);
42 chrome.inputMethodPrivate.setCurrentInputMethod(kInvalidInputMethod,
43 function() {
44 chrome.test.assertTrue(!!chrome.runtime.lastError);
26 chrome.test.succeed(); 45 chrome.test.succeed();
46 });
47 }
48
49 function getListTest() {
50 console.log('getListTest: Getting input method list.');
51 chrome.inputMethodPrivate.getInputMethods(function(inputMethods) {
52 chrome.test.assertEq(6, inputMethods.length);
53 var foundOldInputMethod = false;
54 var foundNewInputMethod = false;
55 for (var i = 0; i < inputMethods.length; ++i) {
56 if (inputMethods[i].id == kOldInputMethod)
57 foundOldInputMethod = true;
58 if (inputMethods[i].id == kNewInputMethod)
59 foundNewInputMethod = true;
27 } 60 }
28 ); 61 chrome.test.assertTrue(foundOldInputMethod);
29 console.log('Changing input method to: ' + kNewInputMethod); 62 chrome.test.assertTrue(foundNewInputMethod);
30 chrome.test.sendMessage('setInputMethod:' + kNewInputMethod, 63 chrome.test.succeed();
31 function (response) { 64 });
32 chrome.test.assertEq('done', response);
33 }
34 );
35 } 65 }
36 66
37 chrome.test.sendMessage('ready'); 67 chrome.test.sendMessage('ready');
38 chrome.test.runTests([setAndGetTest, setAndObserveTest]); 68 chrome.test.runTests(
69 [setTest, getTest, observeTest, setInvalidTest, getListTest]);
OLDNEW
« no previous file with comments | « chrome/common/extensions/api/input_method_private.json ('k') | extensions/browser/extension_function_histogram_value.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698