OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_engine.h" | 5 #include "chrome/browser/chromeos/input_method/input_method_engine.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 ComponentExtensionEngine ext1_engine1; | 57 ComponentExtensionEngine ext1_engine1; |
58 ext1_engine1.engine_id = kTestImeComponentId; | 58 ext1_engine1.engine_id = kTestImeComponentId; |
59 ext1_engine1.language_codes.push_back("en-US"); | 59 ext1_engine1.language_codes.push_back("en-US"); |
60 ext1_engine1.layouts.push_back("us"); | 60 ext1_engine1.layouts.push_back("us"); |
61 ext1.engines.push_back(ext1_engine1); | 61 ext1.engines.push_back(ext1_engine1); |
62 | 62 |
63 std::vector<ComponentExtensionIME> ime_list; | 63 std::vector<ComponentExtensionIME> ime_list; |
64 ime_list.push_back(ext1); | 64 ime_list.push_back(ext1); |
65 delegate->set_ime_list(ime_list); | 65 delegate->set_ime_list(ime_list); |
66 comp_ime_manager->Initialize( | 66 comp_ime_manager->Initialize( |
67 scoped_ptr<ComponentExtensionIMEManagerDelegate>(delegate)); | 67 std::unique_ptr<ComponentExtensionIMEManagerDelegate>(delegate)); |
68 | 68 |
69 MockInputMethodManager* manager = new MockInputMethodManager; | 69 MockInputMethodManager* manager = new MockInputMethodManager; |
70 manager->SetComponentExtensionIMEManager( | 70 manager->SetComponentExtensionIMEManager( |
71 scoped_ptr<ComponentExtensionIMEManager>(comp_ime_manager)); | 71 std::unique_ptr<ComponentExtensionIMEManager>(comp_ime_manager)); |
72 InitializeForTesting(manager); | 72 InitializeForTesting(manager); |
73 } | 73 } |
74 | 74 |
75 class TestObserver : public InputMethodEngineBase::Observer { | 75 class TestObserver : public InputMethodEngineBase::Observer { |
76 public: | 76 public: |
77 TestObserver() : calls_bitmap_(NONE) {} | 77 TestObserver() : calls_bitmap_(NONE) {} |
78 ~TestObserver() override {} | 78 ~TestObserver() override {} |
79 | 79 |
80 void OnActivate(const std::string& engine_id) override { | 80 void OnActivate(const std::string& engine_id) override { |
81 calls_bitmap_ |= ACTIVATE; | 81 calls_bitmap_ |= ACTIVATE; |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 ~InputMethodEngineTest() override { | 138 ~InputMethodEngineTest() override { |
139 ui::IMEBridge::Get()->SetInputContextHandler(NULL); | 139 ui::IMEBridge::Get()->SetInputContextHandler(NULL); |
140 engine_.reset(); | 140 engine_.reset(); |
141 Shutdown(); | 141 Shutdown(); |
142 } | 142 } |
143 | 143 |
144 protected: | 144 protected: |
145 void CreateEngine(bool whitelisted) { | 145 void CreateEngine(bool whitelisted) { |
146 engine_.reset(new InputMethodEngine()); | 146 engine_.reset(new InputMethodEngine()); |
147 observer_ = new TestObserver(); | 147 observer_ = new TestObserver(); |
148 scoped_ptr<InputMethodEngineBase::Observer> observer_ptr(observer_); | 148 std::unique_ptr<InputMethodEngineBase::Observer> observer_ptr(observer_); |
149 engine_->Initialize(std::move(observer_ptr), | 149 engine_->Initialize(std::move(observer_ptr), |
150 whitelisted ? kTestExtensionId : kTestExtensionId2, | 150 whitelisted ? kTestExtensionId : kTestExtensionId2, |
151 ProfileManager::GetActiveUserProfile()); | 151 ProfileManager::GetActiveUserProfile()); |
152 } | 152 } |
153 | 153 |
154 void FocusIn(ui::TextInputType input_type) { | 154 void FocusIn(ui::TextInputType input_type) { |
155 ui::IMEEngineHandlerInterface::InputContext input_context( | 155 ui::IMEEngineHandlerInterface::InputContext input_context( |
156 input_type, ui::TEXT_INPUT_MODE_DEFAULT, ui::TEXT_INPUT_FLAG_NONE); | 156 input_type, ui::TEXT_INPUT_MODE_DEFAULT, ui::TEXT_INPUT_FLAG_NONE); |
157 engine_->FocusIn(input_context); | 157 engine_->FocusIn(input_context); |
158 ui::IMEBridge::Get()->SetCurrentInputContext(input_context); | 158 ui::IMEBridge::Get()->SetCurrentInputContext(input_context); |
159 } | 159 } |
160 | 160 |
161 scoped_ptr<InputMethodEngine> engine_; | 161 std::unique_ptr<InputMethodEngine> engine_; |
162 | 162 |
163 TestObserver* observer_; | 163 TestObserver* observer_; |
164 std::vector<std::string> languages_; | 164 std::vector<std::string> languages_; |
165 std::vector<std::string> layouts_; | 165 std::vector<std::string> layouts_; |
166 GURL options_page_; | 166 GURL options_page_; |
167 GURL input_view_; | 167 GURL input_view_; |
168 | 168 |
169 scoped_ptr<MockIMEInputContextHandler> mock_ime_input_context_handler_; | 169 std::unique_ptr<MockIMEInputContextHandler> mock_ime_input_context_handler_; |
170 | 170 |
171 private: | 171 private: |
172 DISALLOW_COPY_AND_ASSIGN(InputMethodEngineTest); | 172 DISALLOW_COPY_AND_ASSIGN(InputMethodEngineTest); |
173 }; | 173 }; |
174 | 174 |
175 } // namespace | 175 } // namespace |
176 | 176 |
177 TEST_F(InputMethodEngineTest, TestSwitching) { | 177 TEST_F(InputMethodEngineTest, TestSwitching) { |
178 CreateEngine(false); | 178 CreateEngine(false); |
179 // Enable/disable with focus. | 179 // Enable/disable with focus. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 CreateEngine(true); | 270 CreateEngine(true); |
271 // Enable/disable with focus. | 271 // Enable/disable with focus. |
272 std::vector<gfx::Rect> rects; | 272 std::vector<gfx::Rect> rects; |
273 rects.push_back(gfx::Rect()); | 273 rects.push_back(gfx::Rect()); |
274 engine_->SetCompositionBounds(rects); | 274 engine_->SetCompositionBounds(rects); |
275 EXPECT_EQ(ONCOMPOSITIONBOUNDSCHANGED, observer_->GetCallsBitmapAndReset()); | 275 EXPECT_EQ(ONCOMPOSITIONBOUNDSCHANGED, observer_->GetCallsBitmapAndReset()); |
276 } | 276 } |
277 | 277 |
278 } // namespace input_method | 278 } // namespace input_method |
279 } // namespace chromeos | 279 } // namespace chromeos |
OLD | NEW |