Commit a8b6c18e authored by Yoichi Osato's avatar Yoichi Osato Committed by Commit Bot

Add ComputeLayerSelection tests

This patch adds test cases for selection crossing blocks.
The test checks regression behavior that
reverted crrev.com/c/1182710 caused.

Bug: 892584
Cq-Include-Trybots: luci.chromium.try:linux_layout_tests_layout_ng
Change-Id: I299ca3323c201a71267f50f8bba95269f759a0fe
Reviewed-on: https://chromium-review.googlesource.com/c/1272819Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Yoichi Osato <yoichio@chromium.org>
Cr-Commit-Position: refs/heads/master@{#607168}
parent 86b2a5cd
......@@ -341,4 +341,43 @@ TEST_F(ComputeLayerSelectionTest, SamplePointOnBoundary) {
EXPECT_FALSE(composited_selection.end.hidden);
}
// https://crbug.com/892584.
TEST_F(ComputeLayerSelectionTest, CrossingBlock1) {
// TODO(yoichio): To support this case with ComputeLayoutSelection,
// we may need to fix LocalCaretRectOfPosition(<after first br>).
Selection().SetSelection(
SetSelectionTextToBody("<div style='font: 10px/10px Ahem;'>"
"<div>^<br></div>"
"<div>|<br></div>"
"</div>"),
SetSelectionOptions::Builder().SetShouldShowHandle(true).Build());
Selection().CommitAppearanceIfNeeded();
const cc::LayerSelection& layer_selection =
ComputeLayerSelection(Selection());
EXPECT_EQ(layer_selection.start.edge_top, gfx::Point(8, 8));
EXPECT_EQ(layer_selection.start.edge_bottom, gfx::Point(8, 18));
EXPECT_EQ(layer_selection.end.edge_top, gfx::Point(8, 18));
EXPECT_EQ(layer_selection.end.edge_bottom, gfx::Point(8, 28));
}
// https://crbug.com/892584.
TEST_F(ComputeLayerSelectionTest, CrossingBlock2) {
// TODO(yoichio): To support this case with ComputeLayoutSelection,
// we may need to fix LocalCaretRectOfPosition(<after first br>).
Selection().SetSelection(
SetSelectionTextToBody(
"<div contenteditable style='font: 10px/10px Ahem;'>"
"<div>^<br></div>"
"<div>|<br></div>"
"</div>"),
SetSelectionOptions::Builder().SetShouldShowHandle(true).Build());
Selection().CommitAppearanceIfNeeded();
const cc::LayerSelection& layer_selection =
ComputeLayerSelection(Selection());
EXPECT_EQ(layer_selection.start.edge_top, gfx::Point(8, 8));
EXPECT_EQ(layer_selection.start.edge_bottom, gfx::Point(8, 18));
EXPECT_EQ(layer_selection.end.edge_top, gfx::Point(8, 18));
EXPECT_EQ(layer_selection.end.edge_bottom, gfx::Point(8, 28));
}
} // namespace blink
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment