| 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 } |
| 85 |
| 79 void SetUpCommandLine(base::CommandLine* command_line) override { | 86 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 80 ExtensionApiTest::SetUpCommandLine(command_line); | 87 ExtensionApiTest::SetUpCommandLine(command_line); |
| 81 command_line->AppendSwitchASCII( | 88 command_line->AppendSwitchASCII( |
| 82 extensions::switches::kWhitelistedExtensionID, | 89 extensions::switches::kWhitelistedExtensionID, |
| 83 "ilanclmaeigfpnmdlgelmhkpkegdioip"); | 90 "ilanclmaeigfpnmdlgelmhkpkegdioip"); |
| 84 command_line->AppendSwitchASCII(switches::kEnableFeatures, | |
| 85 features::kOptInImeMenu.name); | |
| 86 } | 91 } |
| 92 |
| 93 private: |
| 94 base::test::ScopedFeatureList scoped_feature_list_; |
| 87 }; | 95 }; |
| 88 | 96 |
| 89 } // namespace | 97 } // namespace |
| 90 | 98 |
| 91 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) { | 99 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) { |
| 92 // Listener for extension's background ready. | 100 // Listener for extension's background ready. |
| 93 TestListener listener; | 101 TestListener listener; |
| 94 | 102 |
| 95 ASSERT_TRUE(RunExtensionTest("input_method/basic")) << message_; | 103 ASSERT_TRUE(RunExtensionTest("input_method/basic")) << message_; |
| 96 } | 104 } |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 | 152 |
| 145 ASSERT_TRUE(activated_listener.WaitUntilSatisfied()) << message_; | 153 ASSERT_TRUE(activated_listener.WaitUntilSatisfied()) << message_; |
| 146 ASSERT_TRUE(menu_listener.WaitUntilSatisfied()) << message_; | 154 ASSERT_TRUE(menu_listener.WaitUntilSatisfied()) << message_; |
| 147 ASSERT_TRUE(item_activated_listenter.WaitUntilSatisfied()) << message_; | 155 ASSERT_TRUE(item_activated_listenter.WaitUntilSatisfied()) << message_; |
| 148 | 156 |
| 149 InputMethodManager::Get()->GetActiveIMEState()->ChangeInputMethod( | 157 InputMethodManager::Get()->GetActiveIMEState()->ChangeInputMethod( |
| 150 kTestIMEID2, false /* show_message */); | 158 kTestIMEID2, false /* show_message */); |
| 151 engine_handler->Enable("test2"); | 159 engine_handler->Enable("test2"); |
| 152 ASSERT_TRUE(list_listenter.WaitUntilSatisfied()) << message_; | 160 ASSERT_TRUE(list_listenter.WaitUntilSatisfied()) << message_; |
| 153 } | 161 } |
| OLD | NEW |