| 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/chromeos/input_method/input_method_manager_impl.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_manager_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
| 17 #include "chrome/browser/chromeos/input_method/input_method_engine_interface.h" | 17 #include "chrome/browser/chromeos/input_method/input_method_engine_interface.h" |
| 18 #include "chrome/browser/chromeos/input_method/mock_candidate_window_controller.
h" | 18 #include "chrome/browser/chromeos/input_method/mock_candidate_window_controller.
h" |
| 19 #include "chrome/browser/chromeos/input_method/mock_input_method_engine.h" | 19 #include "chrome/browser/chromeos/input_method/mock_input_method_engine.h" |
| 20 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/test/base/browser_with_test_window_test.h" | 21 #include "chrome/test/base/browser_with_test_window_test.h" |
| 21 #include "chrome/test/base/testing_browser_process.h" | 22 #include "chrome/test/base/testing_browser_process.h" |
| 22 #include "chrome/test/base/testing_profile.h" | 23 #include "chrome/test/base/testing_profile.h" |
| 23 #include "chrome/test/base/testing_profile_manager.h" | 24 #include "chrome/test/base/testing_profile_manager.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "ui/base/accelerators/accelerator.h" | 26 #include "ui/base/accelerators/accelerator.h" |
| 26 #include "ui/base/ime/chromeos/extension_ime_util.h" | 27 #include "ui/base/ime/chromeos/extension_ime_util.h" |
| 27 #include "ui/base/ime/chromeos/fake_ime_keyboard.h" | 28 #include "ui/base/ime/chromeos/fake_ime_keyboard.h" |
| 28 #include "ui/base/ime/chromeos/fake_input_method_delegate.h" | 29 #include "ui/base/ime/chromeos/fake_input_method_delegate.h" |
| 29 #include "ui/base/ime/chromeos/mock_component_extension_ime_manager_delegate.h" | 30 #include "ui/base/ime/chromeos/mock_component_extension_ime_manager_delegate.h" |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 | 165 |
| 165 protected: | 166 protected: |
| 166 // Helper function to initialize component extension stuff for testing. | 167 // Helper function to initialize component extension stuff for testing. |
| 167 void InitComponentExtension() { | 168 void InitComponentExtension() { |
| 168 mock_delegate_ = new MockComponentExtIMEManagerDelegate(); | 169 mock_delegate_ = new MockComponentExtIMEManagerDelegate(); |
| 169 mock_delegate_->set_ime_list(ime_list_); | 170 mock_delegate_->set_ime_list(ime_list_); |
| 170 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate(mock_delegate_); | 171 scoped_ptr<ComponentExtensionIMEManagerDelegate> delegate(mock_delegate_); |
| 171 | 172 |
| 172 // CreateNewState(NULL) returns state with non-empty current_input_method. | 173 // CreateNewState(NULL) returns state with non-empty current_input_method. |
| 173 // So SetState() triggers ChangeInputMethod(). | 174 // So SetState() triggers ChangeInputMethod(). |
| 174 manager_->SetState(manager_->CreateNewState(NULL)); | 175 manager_->SetState( |
| 176 manager_->CreateNewState(ProfileManager::GetActiveUserProfile())); |
| 175 | 177 |
| 176 std::vector<std::string> layouts; | 178 std::vector<std::string> layouts; |
| 177 layouts.push_back("us"); | 179 layouts.push_back("us"); |
| 178 std::vector<std::string> languages; | 180 std::vector<std::string> languages; |
| 179 languages.push_back("en-US"); | 181 languages.push_back("en-US"); |
| 180 | 182 |
| 181 // Note, for production, these SetEngineHandler are called when | 183 // Note, for production, these SetEngineHandler are called when |
| 182 // IMEEngineHandlerInterface is initialized via | 184 // IMEEngineHandlerInterface is initialized via |
| 183 // InitializeComponentextension. | 185 // InitializeComponentextension. |
| 184 InputMethodDescriptors descriptors; | 186 InputMethodDescriptors descriptors; |
| (...skipping 1189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1374 ASSERT_EQ(4U, input_method_ids.size()); | 1376 ASSERT_EQ(4U, input_method_ids.size()); |
| 1375 | 1377 |
| 1376 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); | 1378 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); |
| 1377 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); | 1379 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); |
| 1378 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); | 1380 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); |
| 1379 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); | 1381 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); |
| 1380 } | 1382 } |
| 1381 | 1383 |
| 1382 } // namespace input_method | 1384 } // namespace input_method |
| 1383 } // namespace chromeos | 1385 } // namespace chromeos |
| OLD | NEW |