| 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" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 public ash::ime::InputMethodMenuManager::Observer { | 64 public ash::ime::InputMethodMenuManager::Observer { |
| 65 public: | 65 public: |
| 66 TestObserver() | 66 TestObserver() |
| 67 : input_method_changed_count_(0), | 67 : input_method_changed_count_(0), |
| 68 input_method_menu_item_changed_count_(0), | 68 input_method_menu_item_changed_count_(0), |
| 69 last_show_message_(false) { | 69 last_show_message_(false) { |
| 70 } | 70 } |
| 71 virtual ~TestObserver() {} | 71 virtual ~TestObserver() {} |
| 72 | 72 |
| 73 virtual void InputMethodChanged(InputMethodManager* manager, | 73 virtual void InputMethodChanged(InputMethodManager* manager, |
| 74 bool show_message) OVERRIDE { | 74 bool show_message) override { |
| 75 ++input_method_changed_count_; | 75 ++input_method_changed_count_; |
| 76 last_show_message_ = show_message; | 76 last_show_message_ = show_message; |
| 77 } | 77 } |
| 78 virtual void InputMethodMenuItemChanged( | 78 virtual void InputMethodMenuItemChanged( |
| 79 ash::ime::InputMethodMenuManager* manager) OVERRIDE { | 79 ash::ime::InputMethodMenuManager* manager) override { |
| 80 ++input_method_menu_item_changed_count_; | 80 ++input_method_menu_item_changed_count_; |
| 81 } | 81 } |
| 82 | 82 |
| 83 int input_method_changed_count_; | 83 int input_method_changed_count_; |
| 84 int input_method_menu_item_changed_count_; | 84 int input_method_menu_item_changed_count_; |
| 85 bool last_show_message_; | 85 bool last_show_message_; |
| 86 | 86 |
| 87 private: | 87 private: |
| 88 DISALLOW_COPY_AND_ASSIGN(TestObserver); | 88 DISALLOW_COPY_AND_ASSIGN(TestObserver); |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 class TestCandidateWindowObserver | 91 class TestCandidateWindowObserver |
| 92 : public InputMethodManager::CandidateWindowObserver { | 92 : public InputMethodManager::CandidateWindowObserver { |
| 93 public: | 93 public: |
| 94 TestCandidateWindowObserver() | 94 TestCandidateWindowObserver() |
| 95 : candidate_window_opened_count_(0), | 95 : candidate_window_opened_count_(0), |
| 96 candidate_window_closed_count_(0) { | 96 candidate_window_closed_count_(0) { |
| 97 } | 97 } |
| 98 | 98 |
| 99 virtual ~TestCandidateWindowObserver() {} | 99 virtual ~TestCandidateWindowObserver() {} |
| 100 | 100 |
| 101 virtual void CandidateWindowOpened(InputMethodManager* manager) OVERRIDE { | 101 virtual void CandidateWindowOpened(InputMethodManager* manager) override { |
| 102 ++candidate_window_opened_count_; | 102 ++candidate_window_opened_count_; |
| 103 } | 103 } |
| 104 virtual void CandidateWindowClosed(InputMethodManager* manager) OVERRIDE { | 104 virtual void CandidateWindowClosed(InputMethodManager* manager) override { |
| 105 ++candidate_window_closed_count_; | 105 ++candidate_window_closed_count_; |
| 106 } | 106 } |
| 107 | 107 |
| 108 int candidate_window_opened_count_; | 108 int candidate_window_opened_count_; |
| 109 int candidate_window_closed_count_; | 109 int candidate_window_closed_count_; |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 DISALLOW_COPY_AND_ASSIGN(TestCandidateWindowObserver); | 112 DISALLOW_COPY_AND_ASSIGN(TestCandidateWindowObserver); |
| 113 }; | 113 }; |
| 114 } // namespace | 114 } // namespace |
| 115 | 115 |
| 116 class InputMethodManagerImplTest : public BrowserWithTestWindowTest { | 116 class InputMethodManagerImplTest : public BrowserWithTestWindowTest { |
| 117 public: | 117 public: |
| 118 InputMethodManagerImplTest() | 118 InputMethodManagerImplTest() |
| 119 : delegate_(NULL), | 119 : delegate_(NULL), |
| 120 candidate_window_controller_(NULL), | 120 candidate_window_controller_(NULL), |
| 121 keyboard_(NULL) { | 121 keyboard_(NULL) { |
| 122 } | 122 } |
| 123 virtual ~InputMethodManagerImplTest() {} | 123 virtual ~InputMethodManagerImplTest() {} |
| 124 | 124 |
| 125 virtual void SetUp() OVERRIDE { | 125 virtual void SetUp() override { |
| 126 profile_manager_.reset(new TestingProfileManager(GetBrowserProcess())); | 126 profile_manager_.reset(new TestingProfileManager(GetBrowserProcess())); |
| 127 ASSERT_TRUE(profile_manager_->SetUp()); | 127 ASSERT_TRUE(profile_manager_->SetUp()); |
| 128 | 128 |
| 129 ui::InitializeInputMethodForTesting(); | 129 ui::InitializeInputMethodForTesting(); |
| 130 | 130 |
| 131 delegate_ = new FakeInputMethodDelegate(); | 131 delegate_ = new FakeInputMethodDelegate(); |
| 132 manager_.reset(new InputMethodManagerImpl( | 132 manager_.reset(new InputMethodManagerImpl( |
| 133 scoped_ptr<InputMethodDelegate>(delegate_), false)); | 133 scoped_ptr<InputMethodDelegate>(delegate_), false)); |
| 134 manager_->GetInputMethodUtil()->UpdateHardwareLayoutCache(); | 134 manager_->GetInputMethodUtil()->UpdateHardwareLayoutCache(); |
| 135 candidate_window_controller_ = new MockCandidateWindowController; | 135 candidate_window_controller_ = new MockCandidateWindowController; |
| 136 manager_->SetCandidateWindowControllerForTesting( | 136 manager_->SetCandidateWindowControllerForTesting( |
| 137 candidate_window_controller_); | 137 candidate_window_controller_); |
| 138 keyboard_ = new FakeImeKeyboard; | 138 keyboard_ = new FakeImeKeyboard; |
| 139 manager_->SetImeKeyboardForTesting(keyboard_); | 139 manager_->SetImeKeyboardForTesting(keyboard_); |
| 140 mock_engine_handler_.reset(new MockInputMethodEngine()); | 140 mock_engine_handler_.reset(new MockInputMethodEngine()); |
| 141 IMEBridge::Initialize(); | 141 IMEBridge::Initialize(); |
| 142 IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); | 142 IMEBridge::Get()->SetCurrentEngineHandler(mock_engine_handler_.get()); |
| 143 | 143 |
| 144 menu_manager_ = ash::ime::InputMethodMenuManager::GetInstance(); | 144 menu_manager_ = ash::ime::InputMethodMenuManager::GetInstance(); |
| 145 | 145 |
| 146 InitImeList(); | 146 InitImeList(); |
| 147 | 147 |
| 148 BrowserWithTestWindowTest::SetUp(); | 148 BrowserWithTestWindowTest::SetUp(); |
| 149 } | 149 } |
| 150 | 150 |
| 151 virtual void TearDown() OVERRIDE { | 151 virtual void TearDown() override { |
| 152 BrowserWithTestWindowTest::TearDown(); | 152 BrowserWithTestWindowTest::TearDown(); |
| 153 | 153 |
| 154 ui::ShutdownInputMethodForTesting(); | 154 ui::ShutdownInputMethodForTesting(); |
| 155 | 155 |
| 156 delegate_ = NULL; | 156 delegate_ = NULL; |
| 157 candidate_window_controller_ = NULL; | 157 candidate_window_controller_ = NULL; |
| 158 keyboard_ = NULL; | 158 keyboard_ = NULL; |
| 159 manager_.reset(); | 159 manager_.reset(); |
| 160 | 160 |
| 161 profile_manager_.reset(); | 161 profile_manager_.reset(); |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1391 ASSERT_EQ(4U, input_method_ids.size()); | 1391 ASSERT_EQ(4U, input_method_ids.size()); |
| 1392 | 1392 |
| 1393 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); | 1393 EXPECT_EQ(ImeIdFromEngineId("xkb:us::eng"), input_method_ids[0]); |
| 1394 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); | 1394 EXPECT_EQ(ImeIdFromEngineId("xkb:fr::fra"), input_method_ids[1]); |
| 1395 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); | 1395 EXPECT_EQ("_comp_ime_asdf_pinyin", input_method_ids[2]); |
| 1396 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); | 1396 EXPECT_EQ(ImeIdFromEngineId("zh-t-i0-pinyin"), input_method_ids[3]); |
| 1397 } | 1397 } |
| 1398 | 1398 |
| 1399 } // namespace input_method | 1399 } // namespace input_method |
| 1400 } // namespace chromeos | 1400 } // namespace chromeos |
| OLD | NEW |