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

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

Issue 1552743003: Add chrome.inputMethodPrivate.onImeMenuActivationChanged API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make IME menu test as a separate browser test. Created 4 years, 11 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) 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/prefs/pref_service.h"
11 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
12 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" 13 #include "chrome/browser/chromeos/extensions/input_method_event_router.h"
13 #include "chrome/browser/chromeos/input_method/input_method_util.h" 14 #include "chrome/browser/chromeos/input_method/input_method_util.h"
15 #include "chrome/common/pref_names.h"
16 #include "chromeos/chromeos_switches.h"
14 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
17 #include "extensions/common/switches.h" 20 #include "extensions/common/switches.h"
18 #include "extensions/browser/api/test/test_api.h" 21 #include "extensions/browser/api/test/test_api.h"
19 #include "extensions/browser/notification_types.h" 22 #include "extensions/browser/notification_types.h"
23 #include "extensions/test/extension_test_message_listener.h"
20 #include "testing/gtest/include/gtest/gtest.h" 24 #include "testing/gtest/include/gtest/gtest.h"
21 #include "ui/base/ime/chromeos/extension_ime_util.h" 25 #include "ui/base/ime/chromeos/extension_ime_util.h"
22 #include "ui/base/ime/chromeos/input_method_manager.h" 26 #include "ui/base/ime/chromeos/input_method_manager.h"
23 27
24 namespace { 28 namespace {
25 29
26 const char kLoginScreenUILanguage[] = "fr"; 30 const char kLoginScreenUILanguage[] = "fr";
27 const char kInitialInputMethodOnLoginScreen[] = "xkb:us::eng"; 31 const char kInitialInputMethodOnLoginScreen[] = "xkb:us::eng";
28 const char kBackgroundReady[] = "ready"; 32 const char kBackgroundReady[] = "ready";
29 33
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 private: 66 private:
63 content::NotificationRegistrar registrar_; 67 content::NotificationRegistrar registrar_;
64 }; 68 };
65 69
66 class ExtensionInputMethodApiTest : public ExtensionApiTest { 70 class ExtensionInputMethodApiTest : public ExtensionApiTest {
67 void SetUpCommandLine(base::CommandLine* command_line) override { 71 void SetUpCommandLine(base::CommandLine* command_line) override {
68 ExtensionApiTest::SetUpCommandLine(command_line); 72 ExtensionApiTest::SetUpCommandLine(command_line);
69 command_line->AppendSwitchASCII( 73 command_line->AppendSwitchASCII(
70 extensions::switches::kWhitelistedExtensionID, 74 extensions::switches::kWhitelistedExtensionID,
71 "ilanclmaeigfpnmdlgelmhkpkegdioip"); 75 "ilanclmaeigfpnmdlgelmhkpkegdioip");
76 command_line->AppendSwitch(chromeos::switches::kEnableImeMenu);
72 } 77 }
73 }; 78 };
74 79
75 } // namespace 80 } // namespace
76 81
77 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) { 82 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) {
78 // Listener for extension's background ready. 83 // Listener for extension's background ready.
79 TestListener listener; 84 TestListener listener;
80 85
81 ASSERT_TRUE(RunExtensionTest("input_method")) << message_; 86 ASSERT_TRUE(RunExtensionTest("input_method/basic")) << message_;
82 } 87 }
88
89 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, ImeMenuActivation) {
90 // Listener for IME menu initial state ready.
91 ExtensionTestMessageListener config_listener("config_ready", false);
Devlin 2016/01/25 20:35:36 Right now, this is never used (but it should be).
Azure Wei 2016/01/27 05:06:26 Done.
92 // Listener for IME menu event ready.
93 ExtensionTestMessageListener event_listener("event_ready", false);
94
95 browser()->profile()->GetPrefs()->SetBoolean(prefs::kLanguageImeMenuActivated,
96 true);
97
98 // Test the initial state and add listener for IME menu activation change.
99 ASSERT_TRUE(RunExtensionTest("input_method/ime_menu")) << message_;
100
101 // Trigger chrome.inputMethodPrivate.onImeMenuActivationChanged() event.
102 browser()->profile()->GetPrefs()->SetBoolean(prefs::kLanguageImeMenuActivated,
103 false);
104 // Test that the extension gets the IME activation change event properly.
105 ASSERT_TRUE(event_listener.WaitUntilSatisfied()) << message_;
106 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698