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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/input_method/background.js
diff --git a/chrome/test/data/extensions/api_test/input_method/background.js b/chrome/test/data/extensions/api_test/input_method/background.js
index 2102fb3516c0d9d70b5ca9d838f1b504e8bfdadc..3ae7561494764cf64c47890def6210c730ec1306 100644
--- a/chrome/test/data/extensions/api_test/input_method/background.js
+++ b/chrome/test/data/extensions/api_test/input_method/background.js
@@ -2,37 +2,68 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-var kNewInputMethod = "fr::fra";
-
-function setAndGetTest() {
- console.log('Changing input method to: ' + kNewInputMethod);
- chrome.test.sendMessage('setInputMethod:' + kNewInputMethod,
- function (response) {
- chrome.test.assertEq('done', response);
- console.log('Getting current input method.');
- chrome.inputMethodPrivate.get(function (inputMethod) {
- chrome.test.assertEq(kNewInputMethod, inputMethod);
- chrome.test.succeed();
- }
- );
+var kOldInputMethod = "_comp_ime_fgoepimhcoialccpbmpnnblemnepkkaoxkb:us::eng";
+var kNewInputMethod = "_comp_ime_fgoepimhcoialccpbmpnnblemnepkkaoxkb:fr::fra";
+var kInvalidInputMethod = "xx::xxx";
+
+// The tests needs to be executed in order.
+
+function setTest() {
+ console.log('setTest: Changing input method to: ' + kNewInputMethod);
+ chrome.inputMethodPrivate.setCurrentInputMethod(kNewInputMethod,
+ function() {
+ chrome.test.assertTrue(!chrome.runtime.lastError);
+ chrome.test.succeed();
+ });
+}
+
+function getTest() {
+ console.log('getTest: Getting current input method.');
+ chrome.inputMethodPrivate.getCurrentInputMethod(function(inputMethod) {
+ chrome.test.assertEq(kNewInputMethod, inputMethod);
+ chrome.test.succeed();
});
}
-function setAndObserveTest() {
- console.log('Adding input method event listener.');
- chrome.inputMethodPrivate.onChanged.addListener(
- function(newInputMethod) {
- chrome.test.assertEq(kNewInputMethod, newInputMethod);
+function observeTest() {
+ console.log('observeTest: Adding input method event listener.');
+ chrome.inputMethodPrivate.onChanged.addListener(function(subfix) {
+ chrome.test.assertEq('us::eng', subfix);
+ chrome.test.succeed();
+ });
+ console.log('observeTest: Changing input method to: ' + kOldInputMethod);
+ chrome.inputMethodPrivate.setCurrentInputMethod(kOldInputMethod);
+}
+
+
+function setInvalidTest() {
+ console.log(
+ 'setInvalidTest: Changing input method to: ' + kInvalidInputMethod);
+ chrome.inputMethodPrivate.setCurrentInputMethod(kInvalidInputMethod,
+ function() {
+ chrome.test.assertTrue(!!chrome.runtime.lastError);
chrome.test.succeed();
+ });
+}
+
+function getListTest() {
+ console.log('getListTest: Getting input method list.');
+ chrome.inputMethodPrivate.getInputMethods(function(inputMethods) {
+ chrome.test.assertEq(6, inputMethods.length);
+ var foundOldInputMethod = false;
+ var foundNewInputMethod = false;
+ for (var i = 0; i < inputMethods.length; ++i) {
+ if (inputMethods[i].id == kOldInputMethod)
+ foundOldInputMethod = true;
+ if (inputMethods[i].id == kNewInputMethod)
+ foundNewInputMethod = true;
}
- );
- console.log('Changing input method to: ' + kNewInputMethod);
- chrome.test.sendMessage('setInputMethod:' + kNewInputMethod,
- function (response) {
- chrome.test.assertEq('done', response);
- }
- );
+ chrome.test.assertTrue(foundOldInputMethod);
+ chrome.test.assertTrue(foundNewInputMethod);
+ chrome.test.succeed();
+ });
}
chrome.test.sendMessage('ready');
-chrome.test.runTests([setAndGetTest, setAndObserveTest]);
+chrome.test.runTests(
+ [setTest, getTest, observeTest, setInvalidTest, getListTest]);
« 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