OLD | NEW |
---|---|
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 Loading... | |
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; |
85 // Listerner for IME menu event ready. | |
stevenjb
2016/01/21 19:16:16
Listener
Azure Wei
2016/01/23 02:40:39
Done.
| |
86 ExtensionTestMessageListener ime_menu_listener("ime_menu_ready", false); | |
80 | 87 |
88 browser()->profile()->GetPrefs()->SetBoolean(prefs::kLangugaeImeMenuActivated, | |
Devlin
2016/01/21 19:30:25
kLangugae? Is that typo everywhere?
Azure Wei
2016/01/23 02:40:39
Oh, I've so embarrassed. Corrected them in this cl
| |
89 true); | |
81 ASSERT_TRUE(RunExtensionTest("input_method")) << message_; | 90 ASSERT_TRUE(RunExtensionTest("input_method")) << message_; |
91 | |
92 // Trigger chrome.inputMethodPrivate.onImeMenuActivationChanged() event. | |
93 browser()->profile()->GetPrefs()->SetBoolean(prefs::kLangugaeImeMenuActivated, | |
94 false); | |
95 ASSERT_TRUE(ime_menu_listener.WaitUntilSatisfied()) << message_; | |
82 } | 96 } |
OLD | NEW |