Chromium Code Reviews| 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/test/scoped_feature_list.h" | |
| 11 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" | 12 #include "chrome/browser/chromeos/extensions/input_method_event_router.h" |
| 12 #include "chrome/common/chrome_features.h" | 13 #include "chrome/common/chrome_features.h" |
| 13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 14 #include "chromeos/chromeos_switches.h" | 15 #include "chromeos/chromeos_switches.h" |
| 15 #include "components/prefs/pref_service.h" | 16 #include "components/prefs/pref_service.h" |
| 16 #include "content/public/browser/notification_observer.h" | 17 #include "content/public/browser/notification_observer.h" |
| 17 #include "content/public/browser/notification_registrar.h" | 18 #include "content/public/browser/notification_registrar.h" |
| 18 #include "content/public/browser/notification_service.h" | 19 #include "content/public/browser/notification_service.h" |
| 19 #include "content/public/common/content_switches.h" | 20 #include "content/public/common/content_switches.h" |
| 20 #include "extensions/browser/api/test/test_api.h" | 21 #include "extensions/browser/api/test/test_api.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 manager->GetActiveIMEState()->EnableLoginLayouts(kLoginScreenUILanguage, | 70 manager->GetActiveIMEState()->EnableLoginLayouts(kLoginScreenUILanguage, |
| 70 keyboard_layouts); | 71 keyboard_layouts); |
| 71 } | 72 } |
| 72 } | 73 } |
| 73 | 74 |
| 74 private: | 75 private: |
| 75 content::NotificationRegistrar registrar_; | 76 content::NotificationRegistrar registrar_; |
| 76 }; | 77 }; |
| 77 | 78 |
| 78 class ExtensionInputMethodApiTest : public ExtensionApiTest { | 79 class ExtensionInputMethodApiTest : public ExtensionApiTest { |
| 80 public: | |
| 81 void SetUp() override { | |
| 82 scoped_feature_list_.InitAndEnableFeature(features::kOptInImeMenu); | |
| 83 ExtensionApiTest::SetUp(); | |
| 84 } | |
|
Ilya Sherman
2017/06/28 19:56:04
nit: Please leave a blank line here.
chaopeng
2017/06/30 19:32:36
Done.
| |
| 79 void SetUpCommandLine(base::CommandLine* command_line) override { | 85 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 80 ExtensionApiTest::SetUpCommandLine(command_line); | 86 ExtensionApiTest::SetUpCommandLine(command_line); |
| 81 command_line->AppendSwitchASCII( | 87 command_line->AppendSwitchASCII( |
| 82 extensions::switches::kWhitelistedExtensionID, | 88 extensions::switches::kWhitelistedExtensionID, |
| 83 "ilanclmaeigfpnmdlgelmhkpkegdioip"); | 89 "ilanclmaeigfpnmdlgelmhkpkegdioip"); |
| 84 command_line->AppendSwitchASCII(switches::kEnableFeatures, | |
| 85 features::kOptInImeMenu.name); | |
| 86 } | 90 } |
| 91 | |
| 92 private: | |
| 93 base::test::ScopedFeatureList scoped_feature_list_; | |
| 87 }; | 94 }; |
| 88 | 95 |
| 89 } // namespace | 96 } // namespace |
| 90 | 97 |
| 91 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) { | 98 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) { |
| 92 // Listener for extension's background ready. | 99 // Listener for extension's background ready. |
| 93 TestListener listener; | 100 TestListener listener; |
| 94 | 101 |
| 95 ASSERT_TRUE(RunExtensionTest("input_method/basic")) << message_; | 102 ASSERT_TRUE(RunExtensionTest("input_method/basic")) << message_; |
| 96 } | 103 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 | 151 |
| 145 ASSERT_TRUE(activated_listener.WaitUntilSatisfied()) << message_; | 152 ASSERT_TRUE(activated_listener.WaitUntilSatisfied()) << message_; |
| 146 ASSERT_TRUE(menu_listener.WaitUntilSatisfied()) << message_; | 153 ASSERT_TRUE(menu_listener.WaitUntilSatisfied()) << message_; |
| 147 ASSERT_TRUE(item_activated_listenter.WaitUntilSatisfied()) << message_; | 154 ASSERT_TRUE(item_activated_listenter.WaitUntilSatisfied()) << message_; |
| 148 | 155 |
| 149 InputMethodManager::Get()->GetActiveIMEState()->ChangeInputMethod( | 156 InputMethodManager::Get()->GetActiveIMEState()->ChangeInputMethod( |
| 150 kTestIMEID2, false /* show_message */); | 157 kTestIMEID2, false /* show_message */); |
| 151 engine_handler->Enable("test2"); | 158 engine_handler->Enable("test2"); |
| 152 ASSERT_TRUE(list_listenter.WaitUntilSatisfied()) << message_; | 159 ASSERT_TRUE(list_listenter.WaitUntilSatisfied()) << message_; |
| 153 } | 160 } |
| OLD | NEW |