Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 2130133004: Tracking text selection on the browser side in OOPIF. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initialize/Clear TextSelection for each view + make GetTextSelection() const. Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/browser/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <tuple> 10 #include <tuple>
(...skipping 4459 matching lines...) Expand 10 before | Expand all | Expand 10 after
4470 4470
4471 // No bounds at index 1. 4471 // No bounds at index 1.
4472 EXPECT_FALSE(text_input_client()->GetCompositionCharacterBounds(1, &bound)); 4472 EXPECT_FALSE(text_input_client()->GetCompositionCharacterBounds(1, &bound));
4473 4473
4474 // Valid bound at index 0. 4474 // Valid bound at index 0.
4475 EXPECT_TRUE(text_input_client()->GetCompositionCharacterBounds(0, &bound)); 4475 EXPECT_TRUE(text_input_client()->GetCompositionCharacterBounds(0, &bound));
4476 EXPECT_EQ(4 + (int)index, bound.height()); 4476 EXPECT_EQ(4 + (int)index, bound.height());
4477 } 4477 }
4478 } 4478 }
4479 4479
4480 // This test is for selected text.
4481 TEST_F(InputMethodStateAuraTest, GetSelectedText) {
4482 base::string16 text = base::ASCIIToUTF16("some text of length 22");
4483 size_t offset = 0U;
4484 gfx::Range selection_range(20, 21);
4485
4486 for (auto index : active_view_sequence_) {
4487 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT);
4488 views_[index]->SelectionChanged(text, offset, selection_range);
4489 base::string16 expected_text = text.substr(
4490 selection_range.GetMin() - offset, selection_range.length());
4491
4492 EXPECT_EQ(expected_text, views_[index]->GetSelectedText());
4493
4494 // Changing offset to make sure that the next view has a different text
4495 // selection.
4496 offset++;
4497 }
4498 }
4499
4500 // This test is for text range.
4501 TEST_F(InputMethodStateAuraTest, GetTextRange) {
4502 base::string16 text = base::ASCIIToUTF16("some text of length 22");
4503 size_t offset = 0U;
4504 gfx::Range selection_range;
4505
4506 for (auto index : active_view_sequence_) {
4507 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT);
4508 gfx::Range expected_range(offset, offset + text.length());
4509 views_[index]->SelectionChanged(text, offset, selection_range);
4510 gfx::Range range_from_client;
4511
4512 // For aura this always returns true.
4513 EXPECT_TRUE(text_input_client()->GetTextRange(&range_from_client));
4514 EXPECT_EQ(expected_range, range_from_client);
4515
4516 // Changing offset to make sure that the next view has a different text
4517 // selection.
4518 offset++;
4519 }
4520 }
4521
4522 // This test is for selection range.
4523 TEST_F(InputMethodStateAuraTest, GetSelectionRange) {
4524 base::string16 text;
4525 gfx::Range expected_range(0U, 1U);
4526
4527 for (auto index : active_view_sequence_) {
4528 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT);
4529 views_[index]->SelectionChanged(text, 0U, expected_range);
4530 gfx::Range range_from_client;
4531
4532 // This method always returns true.
4533 EXPECT_TRUE(text_input_client()->GetSelectionRange(&range_from_client));
4534 EXPECT_EQ(expected_range, range_from_client);
4535
4536 // Changing range to make sure that the next view has a different text
4537 // selection.
4538 expected_range.set_end(expected_range.end() + 1U);
4539 }
4540 }
4541
4480 } // namespace content 4542 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698