| 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" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 const std::string& content = *content::Details<std::string>(details).ptr(); | 51 const std::string& content = *content::Details<std::string>(details).ptr(); |
| 52 if (content == kBackgroundReady) { | 52 if (content == kBackgroundReady) { |
| 53 // Initializes IMF for testing when receives ready message from | 53 // Initializes IMF for testing when receives ready message from |
| 54 // background. | 54 // background. |
| 55 chromeos::input_method::InputMethodManager* manager = | 55 chromeos::input_method::InputMethodManager* manager = |
| 56 chromeos::input_method::InputMethodManager::Get(); | 56 chromeos::input_method::InputMethodManager::Get(); |
| 57 manager->GetInputMethodUtil()->InitXkbInputMethodsForTesting(); | 57 manager->GetInputMethodUtil()->InitXkbInputMethodsForTesting(); |
| 58 | 58 |
| 59 std::vector<std::string> keyboard_layouts; | 59 std::vector<std::string> keyboard_layouts; |
| 60 keyboard_layouts.push_back( | 60 keyboard_layouts.push_back( |
| 61 chromeos::extension_ime_util::GetInputMethodIDByKeyboardLayout( | 61 chromeos::extension_ime_util::GetInputMethodIDByEngineID( |
| 62 kInitialInputMethodOnLoginScreen)); | 62 kInitialInputMethodOnLoginScreen)); |
| 63 manager->EnableLoginLayouts(kLoginScreenUILanguage, keyboard_layouts); | 63 manager->EnableLoginLayouts(kLoginScreenUILanguage, keyboard_layouts); |
| 64 return; | 64 return; |
| 65 } | 65 } |
| 66 | 66 |
| 67 const std::string expected_message = | 67 const std::string expected_message = |
| 68 base::StringPrintf("%s:%s", kSetInputMethodMessage, kNewInputMethod); | 68 base::StringPrintf("%s:%s", kSetInputMethodMessage, kNewInputMethod); |
| 69 if (content == expected_message) { | 69 if (content == expected_message) { |
| 70 chromeos::input_method::InputMethodManager::Get()->ChangeInputMethod( | 70 chromeos::input_method::InputMethodManager::Get()->ChangeInputMethod( |
| 71 chromeos::extension_ime_util::GetInputMethodIDByKeyboardLayout( | 71 chromeos::extension_ime_util::GetInputMethodIDByEngineID( |
| 72 base::StringPrintf("xkb:%s", kNewInputMethod))); | 72 base::StringPrintf("xkb:%s", kNewInputMethod))); |
| 73 | 73 |
| 74 scoped_refptr<extensions::TestSendMessageFunction> function = | 74 scoped_refptr<extensions::TestSendMessageFunction> function = |
| 75 content::Source<extensions::TestSendMessageFunction>( | 75 content::Source<extensions::TestSendMessageFunction>( |
| 76 source).ptr(); | 76 source).ptr(); |
| 77 EXPECT_GT(count_--, 0); | 77 EXPECT_GT(count_--, 0); |
| 78 function->Reply(kSetInputMethodDone); | 78 function->Reply(kSetInputMethodDone); |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 | 81 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 95 }; | 95 }; |
| 96 | 96 |
| 97 } // namespace | 97 } // namespace |
| 98 | 98 |
| 99 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) { | 99 IN_PROC_BROWSER_TEST_F(ExtensionInputMethodApiTest, Basic) { |
| 100 // Two test, two calls. See JS code for more info. | 100 // Two test, two calls. See JS code for more info. |
| 101 SetInputMethodListener listener(2); | 101 SetInputMethodListener listener(2); |
| 102 | 102 |
| 103 ASSERT_TRUE(RunExtensionTest("input_method")) << message_; | 103 ASSERT_TRUE(RunExtensionTest("input_method")) << message_; |
| 104 } | 104 } |
| OLD | NEW |