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

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: Update ExtensionInputMethodApiTest.ImeMenuActivation 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 #include "ui/base/ime/chromeos/input_method_whitelist.h" 27 #include "ui/base/ime/chromeos/input_method_whitelist.h"
24 28
25 using namespace chromeos::input_method; 29 using namespace chromeos::input_method;
26 30
27 namespace { 31 namespace {
28 32
29 const char kLoginScreenUILanguage[] = "fr"; 33 const char kLoginScreenUILanguage[] = "fr";
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 private: 69 private:
66 content::NotificationRegistrar registrar_; 70 content::NotificationRegistrar registrar_;
67 }; 71 };
68 72
69 class ExtensionInputMethodApiTest : public ExtensionApiTest { 73 class ExtensionInputMethodApiTest : public ExtensionApiTest {
70 void SetUpCommandLine(base::CommandLine* command_line) override { 74 void SetUpCommandLine(base::CommandLine* command_line) override {
71 ExtensionApiTest::SetUpCommandLine(command_line); 75 ExtensionApiTest::SetUpCommandLine(command_line);
72 command_line->AppendSwitchASCII( 76 command_line->AppendSwitchASCII(
73 extensions::switches::kWhitelistedExtensionID, 77 extensions::switches::kWhitelistedExtensionID,
74 "ilanclmaeigfpnmdlgelmhkpkegdioip"); 78 "ilanclmaeigfpnmdlgelmhkpkegdioip");
79 command_line->AppendSwitch(chromeos::switches::kEnableImeMenu);
75 } 80 }
76 }; 81 };
77 82
78 } // namespace 83 } // namespace
79 84
80 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) { 85 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) {
81 // Listener for extension's background ready. 86 // Listener for extension's background ready.
82 TestListener listener; 87 TestListener listener;
83 88
84 ASSERT_TRUE(RunExtensionTest("input_method")) << message_; 89 ASSERT_TRUE(RunExtensionTest("input_method/basic")) << message_;
85 } 90 }
91
92 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, ImeMenuActivation) {
93 // Listener for IME menu initial state ready.
94 ExtensionTestMessageListener config_listener("config_ready", false);
95 // Listener for IME menu event ready.
96 ExtensionTestMessageListener event_listener("event_ready", false);
97
98 browser()->profile()->GetPrefs()->SetBoolean(prefs::kLanguageImeMenuActivated,
99 true);
100
101 // Test the initial state and add listener for IME menu activation change.
102 ASSERT_TRUE(RunExtensionTest("input_method/ime_menu")) << message_;
Devlin 2016/01/27 20:33:27 Instead of using RunExtensionTest here, just load
Azure Wei 2016/01/28 12:24:58 Done.
103 ASSERT_TRUE(config_listener.WaitUntilSatisfied()) << message_;
104
105 // Trigger chrome.inputMethodPrivate.onImeMenuActivationChanged() event.
106 browser()->profile()->GetPrefs()->SetBoolean(prefs::kLanguageImeMenuActivated,
107 false);
108 // Test that the extension gets the IME activation change event properly.
109 ASSERT_TRUE(event_listener.WaitUntilSatisfied()) << message_;
110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698