OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/arc/ime/arc_ime_service.h" | 5 #include "components/arc/ime/arc_ime_service.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 instance_->OnWindowFocused(arc_win_.get(), nonarc_win.get()); | 258 instance_->OnWindowFocused(arc_win_.get(), nonarc_win.get()); |
259 EXPECT_EQ(instance_.get(), fake_input_method_->GetTextInputClient()); | 259 EXPECT_EQ(instance_.get(), fake_input_method_->GetTextInputClient()); |
260 EXPECT_EQ(2, fake_input_method_->count_set_focused_text_input_client()); | 260 EXPECT_EQ(2, fake_input_method_->count_set_focused_text_input_client()); |
261 | 261 |
262 // Focus is moving out. | 262 // Focus is moving out. |
263 instance_->OnWindowFocused(nullptr, arc_win_.get()); | 263 instance_->OnWindowFocused(nullptr, arc_win_.get()); |
264 EXPECT_EQ(nullptr, fake_input_method_->GetTextInputClient()); | 264 EXPECT_EQ(nullptr, fake_input_method_->GetTextInputClient()); |
265 EXPECT_EQ(2, fake_input_method_->count_set_focused_text_input_client()); | 265 EXPECT_EQ(2, fake_input_method_->count_set_focused_text_input_client()); |
266 } | 266 } |
267 | 267 |
| 268 TEST_F(ArcImeServiceTest, GetTextFromRange) { |
| 269 instance_->OnWindowFocused(arc_win_.get(), nullptr); |
| 270 |
| 271 const base::string16 text = base::ASCIIToUTF16("abcdefghijklmn"); |
| 272 // Assume the cursor is between 'c' and 'd'. |
| 273 const uint32_t cursor_pos = 3; |
| 274 const gfx::Range text_range(cursor_pos - 1, cursor_pos + 1); |
| 275 const base::string16 text_in_range = text.substr(cursor_pos - 1, 2); |
| 276 const gfx::Range selection_range(cursor_pos, cursor_pos); |
| 277 |
| 278 instance_->OnCursorRectChangedWithSurroundingText( |
| 279 gfx::Rect(0, 0, 1, 1), text_range, text_in_range, selection_range); |
| 280 |
| 281 gfx::Range temp; |
| 282 instance_->GetTextRange(&temp); |
| 283 EXPECT_EQ(text_range, temp); |
| 284 |
| 285 base::string16 temp_str; |
| 286 instance_->GetTextFromRange(text_range, &temp_str); |
| 287 EXPECT_EQ(text_in_range, temp_str); |
| 288 |
| 289 instance_->GetSelectionRange(&temp); |
| 290 EXPECT_EQ(selection_range, temp); |
| 291 } |
| 292 |
268 } // namespace arc | 293 } // namespace arc |
OLD | NEW |