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

Side by Side Diff: chrome/browser/chromeos/extensions/input_method_apitest_chromeos.cc

Issue 1839923002: Add tests for IME menu private APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/input_method/ime_menu2/background.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 #include "chrome/browser/extensions/extension_apitest.h" 5 #include "chrome/browser/extensions/extension_apitest.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" 12 #include "chrome/browser/chromeos/extensions/input_method_event_router.h"
13 #include "chrome/browser/chromeos/input_method/input_method_util.h" 13 #include "chrome/browser/chromeos/input_method/input_method_util.h"
14 #include "chrome/common/chrome_features.h" 14 #include "chrome/common/chrome_features.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "chromeos/chromeos_switches.h" 16 #include "chromeos/chromeos_switches.h"
17 #include "components/prefs/pref_service.h" 17 #include "components/prefs/pref_service.h"
18 #include "content/public/browser/notification_observer.h" 18 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 19 #include "content/public/browser/notification_registrar.h"
20 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
21 #include "content/public/common/content_switches.h" 21 #include "content/public/common/content_switches.h"
22 #include "extensions/common/switches.h" 22 #include "extensions/common/switches.h"
23 #include "extensions/browser/api/test/test_api.h" 23 #include "extensions/browser/api/test/test_api.h"
24 #include "extensions/browser/notification_types.h" 24 #include "extensions/browser/notification_types.h"
25 #include "extensions/test/extension_test_message_listener.h" 25 #include "extensions/test/extension_test_message_listener.h"
26 #include "testing/gtest/include/gtest/gtest.h" 26 #include "testing/gtest/include/gtest/gtest.h"
27 #include "ui/base/ime/chromeos/extension_ime_util.h" 27 #include "ui/base/ime/chromeos/extension_ime_util.h"
28 #include "ui/base/ime/chromeos/input_method_manager.h" 28 #include "ui/base/ime/chromeos/input_method_manager.h"
29 #include "ui/base/ime/chromeos/input_method_whitelist.h" 29 #include "ui/base/ime/chromeos/input_method_whitelist.h"
30 #include "ui/base/ime/ime_bridge.h"
30 31
31 using namespace chromeos::input_method; 32 using namespace chromeos::input_method;
32 33
33 namespace { 34 namespace {
34 35
35 const char kLoginScreenUILanguage[] = "fr"; 36 const char kLoginScreenUILanguage[] = "fr";
36 const char kInitialInputMethodOnLoginScreen[] = "xkb:us::eng"; 37 const char kInitialInputMethodOnLoginScreen[] = "xkb:us::eng";
37 const char kBackgroundReady[] = "ready"; 38 const char kBackgroundReady[] = "ready";
39 const char kTestIMEID[] = "_ext_ime_ilanclmaeigfpnmdlgelmhkpkegdioiptest";
40 const char kTestIMEID2[] = "_ext_ime_ilanclmaeigfpnmdlgelmhkpkegdioiptest2";
38 41
39 // Class that listens for the JS message. 42 // Class that listens for the JS message.
40 class TestListener : public content::NotificationObserver { 43 class TestListener : public content::NotificationObserver {
41 public: 44 public:
42 TestListener() { 45 TestListener() {
43 registrar_.Add(this, 46 registrar_.Add(this,
44 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE, 47 extensions::NOTIFICATION_EXTENSION_TEST_MESSAGE,
45 content::NotificationService::AllSources()); 48 content::NotificationService::AllSources());
46 } 49 }
47 50
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ASSERT_TRUE( 108 ASSERT_TRUE(
106 LoadExtension(test_data_dir_.AppendASCII("input_method/ime_menu"))); 109 LoadExtension(test_data_dir_.AppendASCII("input_method/ime_menu")));
107 ASSERT_TRUE(config_listener.WaitUntilSatisfied()) << message_; 110 ASSERT_TRUE(config_listener.WaitUntilSatisfied()) << message_;
108 111
109 // Trigger chrome.inputMethodPrivate.onImeMenuActivationChanged() event. 112 // Trigger chrome.inputMethodPrivate.onImeMenuActivationChanged() event.
110 browser()->profile()->GetPrefs()->SetBoolean(prefs::kLanguageImeMenuActivated, 113 browser()->profile()->GetPrefs()->SetBoolean(prefs::kLanguageImeMenuActivated,
111 false); 114 false);
112 // Test that the extension gets the IME activation change event properly. 115 // Test that the extension gets the IME activation change event properly.
113 ASSERT_TRUE(event_listener.WaitUntilSatisfied()) << message_; 116 ASSERT_TRUE(event_listener.WaitUntilSatisfied()) << message_;
114 } 117 }
118
119 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, ImeMenuAPITest) {
120 ExtensionTestMessageListener activated_listener("activated", false);
121 ExtensionTestMessageListener menu_listener("get_menu_update", false);
122 ExtensionTestMessageListener item_activated_listenter("get_menu_activated",
123 false);
124 ExtensionTestMessageListener list_listenter("list_change", false);
125 browser()->profile()->GetPrefs()->SetBoolean(prefs::kLanguageImeMenuActivated,
126 true);
127 ASSERT_TRUE(
128 LoadExtension(test_data_dir_.AppendASCII("input_method/ime_menu2")));
129
130 std::vector<std::string> extension_ime_ids;
131 extension_ime_ids.push_back(kTestIMEID);
132 extension_ime_ids.push_back(kTestIMEID2);
133 InputMethodManager::Get()->GetActiveIMEState()->SetEnabledExtensionImes(
134 &extension_ime_ids);
135 InputMethodDescriptors extension_imes;
136 InputMethodManager::Get()->GetActiveIMEState()->GetInputMethodExtensions(
137 &extension_imes);
138 InputMethodManager::Get()->GetActiveIMEState()->ChangeInputMethod(
139 kTestIMEID, false /* show_message */);
140 ui::IMEEngineHandlerInterface* engine_handler =
141 ui::IMEBridge::Get()->GetCurrentEngineHandler();
142 ASSERT_TRUE(engine_handler);
143 engine_handler->Enable("test");
144
145 ASSERT_TRUE(activated_listener.WaitUntilSatisfied()) << message_;
146 ASSERT_TRUE(menu_listener.WaitUntilSatisfied()) << message_;
147 ASSERT_TRUE(item_activated_listenter.WaitUntilSatisfied()) << message_;
148
149 InputMethodManager::Get()->GetActiveIMEState()->ChangeInputMethod(
150 kTestIMEID2, false /* show_message */);
151 engine_handler->Enable("test2");
152 ASSERT_TRUE(list_listenter.WaitUntilSatisfied()) << message_;
153 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/input_method/ime_menu2/background.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698