| 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 "ash/ime/input_method_menu_item.h" | 9 #include "ash/ime/input_method_menu_item.h" |
| 10 #include "ash/ime/input_method_menu_manager.h" | 10 #include "ash/ime/input_method_menu_manager.h" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "chrome/browser/chromeos/input_method/input_method_engine_interface.h" | 18 #include "chrome/browser/chromeos/input_method/input_method_engine_interface.h" |
| 19 #include "chrome/browser/chromeos/input_method/mock_candidate_window_controller.
h" | 19 #include "chrome/browser/chromeos/input_method/mock_candidate_window_controller.
h" |
| 20 #include "chrome/browser/chromeos/input_method/mock_input_method_engine.h" | 20 #include "chrome/browser/chromeos/input_method/mock_input_method_engine.h" |
| 21 #include "chromeos/ime/extension_ime_util.h" | 21 #include "chromeos/ime/extension_ime_util.h" |
| 22 #include "chromeos/ime/fake_input_method_delegate.h" | 22 #include "chromeos/ime/fake_input_method_delegate.h" |
| 23 #include "chromeos/ime/fake_xkeyboard.h" | 23 #include "chromeos/ime/fake_keyboard_controller.h" |
| 24 #include "chromeos/ime/mock_component_extension_ime_manager_delegate.h" | 24 #include "chromeos/ime/mock_component_extension_ime_manager_delegate.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 26 #include "ui/base/accelerators/accelerator.h" | 26 #include "ui/base/accelerators/accelerator.h" |
| 27 #include "ui/base/ime/chromeos/mock_ime_engine_handler.h" | 27 #include "ui/base/ime/chromeos/mock_ime_engine_handler.h" |
| 28 #include "ui/events/keycodes/keyboard_codes.h" | 28 #include "ui/events/keycodes/keyboard_codes.h" |
| 29 | 29 |
| 30 namespace chromeos { | 30 namespace chromeos { |
| 31 | 31 |
| 32 namespace input_method { | 32 namespace input_method { |
| 33 namespace { | 33 namespace { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 virtual ~InputMethodManagerImplTest() {} | 73 virtual ~InputMethodManagerImplTest() {} |
| 74 | 74 |
| 75 virtual void SetUp() OVERRIDE { | 75 virtual void SetUp() OVERRIDE { |
| 76 delegate_ = new FakeInputMethodDelegate(); | 76 delegate_ = new FakeInputMethodDelegate(); |
| 77 manager_.reset(new InputMethodManagerImpl( | 77 manager_.reset(new InputMethodManagerImpl( |
| 78 scoped_ptr<InputMethodDelegate>(delegate_))); | 78 scoped_ptr<InputMethodDelegate>(delegate_))); |
| 79 manager_->GetInputMethodUtil()->UpdateHardwareLayoutCache(); | 79 manager_->GetInputMethodUtil()->UpdateHardwareLayoutCache(); |
| 80 candidate_window_controller_ = new MockCandidateWindowController; | 80 candidate_window_controller_ = new MockCandidateWindowController; |
| 81 manager_->SetCandidateWindowControllerForTesting( | 81 manager_->SetCandidateWindowControllerForTesting( |
| 82 candidate_window_controller_); | 82 candidate_window_controller_); |
| 83 xkeyboard_ = new FakeXKeyboard; | 83 xkeyboard_ = new FakeKeyboardController; |
| 84 manager_->SetXKeyboardForTesting(xkeyboard_); | 84 manager_->SetKeyboardControllerForTesting(xkeyboard_); |
| 85 mock_engine_handler_.reset(new MockIMEEngineHandler()); | 85 mock_engine_handler_.reset(new MockIMEEngineHandler()); |
| 86 IMEBridge::Initialize(); | 86 IMEBridge::Initialize(); |
| 87 IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); | 87 IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); |
| 88 | 88 |
| 89 menu_manager_ = ash::ime::InputMethodMenuManager::GetInstance(); | 89 menu_manager_ = ash::ime::InputMethodMenuManager::GetInstance(); |
| 90 | 90 |
| 91 ime_list_.clear(); | 91 ime_list_.clear(); |
| 92 | 92 |
| 93 ComponentExtensionIME ext_xkb; | 93 ComponentExtensionIME ext_xkb; |
| 94 ext_xkb.id = kXkbExtId; | 94 ext_xkb.id = kXkbExtId; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 mock_engine_handler_.get()); | 237 mock_engine_handler_.get()); |
| 238 IMEBridge::Get()->SetEngineHandler(kExt2Engine2Id, | 238 IMEBridge::Get()->SetEngineHandler(kExt2Engine2Id, |
| 239 mock_engine_handler_.get()); | 239 mock_engine_handler_.get()); |
| 240 manager_->InitializeComponentExtensionForTesting(delegate.Pass()); | 240 manager_->InitializeComponentExtensionForTesting(delegate.Pass()); |
| 241 } | 241 } |
| 242 | 242 |
| 243 scoped_ptr<InputMethodManagerImpl> manager_; | 243 scoped_ptr<InputMethodManagerImpl> manager_; |
| 244 FakeInputMethodDelegate* delegate_; | 244 FakeInputMethodDelegate* delegate_; |
| 245 MockCandidateWindowController* candidate_window_controller_; | 245 MockCandidateWindowController* candidate_window_controller_; |
| 246 scoped_ptr<MockIMEEngineHandler> mock_engine_handler_; | 246 scoped_ptr<MockIMEEngineHandler> mock_engine_handler_; |
| 247 FakeXKeyboard* xkeyboard_; | 247 FakeKeyboardController* xkeyboard_; |
| 248 base::MessageLoop message_loop_; | 248 base::MessageLoop message_loop_; |
| 249 MockComponentExtIMEManagerDelegate* mock_delegate_; | 249 MockComponentExtIMEManagerDelegate* mock_delegate_; |
| 250 std::vector<ComponentExtensionIME> ime_list_; | 250 std::vector<ComponentExtensionIME> ime_list_; |
| 251 ash::ime::InputMethodMenuManager* menu_manager_; | 251 ash::ime::InputMethodMenuManager* menu_manager_; |
| 252 | 252 |
| 253 private: | 253 private: |
| 254 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImplTest); | 254 DISALLOW_COPY_AND_ASSIGN(InputMethodManagerImplTest); |
| 255 }; | 255 }; |
| 256 | 256 |
| 257 class TestObserver : public InputMethodManager::Observer, | 257 class TestObserver : public InputMethodManager::Observer, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 299 } | 299 } |
| 300 | 300 |
| 301 int candidate_window_opened_count_; | 301 int candidate_window_opened_count_; |
| 302 int candidate_window_closed_count_; | 302 int candidate_window_closed_count_; |
| 303 | 303 |
| 304 private: | 304 private: |
| 305 DISALLOW_COPY_AND_ASSIGN(TestCandidateWindowObserver); | 305 DISALLOW_COPY_AND_ASSIGN(TestCandidateWindowObserver); |
| 306 }; | 306 }; |
| 307 } // namespace | 307 } // namespace |
| 308 | 308 |
| 309 TEST_F(InputMethodManagerImplTest, TestGetXKeyboard) { | 309 TEST_F(InputMethodManagerImplTest, TestGetKeyboardController) { |
| 310 EXPECT_TRUE(manager_->GetXKeyboard()); | 310 EXPECT_TRUE(manager_->GetKeyboardController()); |
| 311 EXPECT_EQ(xkeyboard_, manager_->GetXKeyboard()); | 311 EXPECT_EQ(xkeyboard_, manager_->GetKeyboardController()); |
| 312 } | 312 } |
| 313 | 313 |
| 314 TEST_F(InputMethodManagerImplTest, TestCandidateWindowObserver) { | 314 TEST_F(InputMethodManagerImplTest, TestCandidateWindowObserver) { |
| 315 TestCandidateWindowObserver observer; | 315 TestCandidateWindowObserver observer; |
| 316 candidate_window_controller_->NotifyCandidateWindowOpened(); // nop | 316 candidate_window_controller_->NotifyCandidateWindowOpened(); // nop |
| 317 candidate_window_controller_->NotifyCandidateWindowClosed(); // nop | 317 candidate_window_controller_->NotifyCandidateWindowClosed(); // nop |
| 318 manager_->AddCandidateWindowObserver(&observer); | 318 manager_->AddCandidateWindowObserver(&observer); |
| 319 candidate_window_controller_->NotifyCandidateWindowOpened(); | 319 candidate_window_controller_->NotifyCandidateWindowOpened(); |
| 320 EXPECT_EQ(1, observer.candidate_window_opened_count_); | 320 EXPECT_EQ(1, observer.candidate_window_opened_count_); |
| 321 candidate_window_controller_->NotifyCandidateWindowClosed(); | 321 candidate_window_controller_->NotifyCandidateWindowClosed(); |
| (...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 | 1360 |
| 1361 ASSERT_EQ(3U, input_method_ids.size()); | 1361 ASSERT_EQ(3U, input_method_ids.size()); |
| 1362 | 1362 |
| 1363 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); | 1363 EXPECT_EQ("xkb:us::eng", input_method_ids[0]); |
| 1364 EXPECT_EQ("xkb:fr::fra", input_method_ids[1]); | 1364 EXPECT_EQ("xkb:fr::fra", input_method_ids[1]); |
| 1365 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); | 1365 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); |
| 1366 } | 1366 } |
| 1367 | 1367 |
| 1368 } // namespace input_method | 1368 } // namespace input_method |
| 1369 } // namespace chromeos | 1369 } // namespace chromeos |
| OLD | NEW |