Commit 67b7a674 authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Make editing/selection/hit-test-on-text-with-line-height.html to test all platforms

This patch changes "hit-test-on-text-with-line-height.html" to test all
platforms by using |internals.settings.setEditingBehavior()|.

This patch also adjusts hit points for platform 'mac'.

Bug: 707656
Change-Id: I840cdc7db8de3f5ca695e045fa1fbd862b752056
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2269605
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Reviewed-by: default avatarKent Tamura <tkent@chromium.org>
Commit-Queue: Kent Tamura <tkent@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#782904}
parent ca6ab7ac
...@@ -43,7 +43,13 @@ function testIt(platform, title, id, x, y, expected) { ...@@ -43,7 +43,13 @@ function testIt(platform, title, id, x, y, expected) {
const offsetX = x === 'after' const offsetX = x === 'after'
? sample.offsetWidth ? sample.offsetWidth
: Math.min(x, sample.offsetWidth); : Math.min(x, sample.offsetWidth);
const offsetY = y === 'below' ? target.offsetHeight - 3 : y; const offsetY = {
'above': 15,
'below': sample.offsetHeight - 15,
'top': 10,
'middle': target.offsetHeight / 2,
'bottom': target.offsetHeight - 5,
}[y];
eventSender.leapForward(9999); // reset mouse click state eventSender.leapForward(9999); // reset mouse click state
eventSender.mouseMoveTo(selection.computeLeft(target) + offsetX, eventSender.mouseMoveTo(selection.computeLeft(target) + offsetX,
selection.computeTop(target) + offsetY); selection.computeTop(target) + offsetY);
...@@ -59,19 +65,21 @@ function testIt(platform, title, id, x, y, expected) { ...@@ -59,19 +65,21 @@ function testIt(platform, title, id, x, y, expected) {
`${platform}: ${title}`); `${platform}: ${title}`);
} }
for (const platform of ['android', 'max', 'unix', 'win']) { for (const platform of ['android', 'mac', 'unix', 'win']) {
if (window.internals)
internals.settings.setEditingBehavior(platform);
testIt(platform, 'Click after sample (top)', 'editable', testIt(platform, 'Click after sample (top)', 'editable',
'after', 15, 'abcd|'); 'after', 'top', 'abcd|');
testIt(platform, 'Click after sample (middle)', 'editable', testIt(platform, 'Click after sample (middle)', 'editable',
'after', kLineHeight / 2, 'abcd|'); 'after', 'middle', 'abcd|');
testIt(platform, 'Click after sample (bottom)', 'editable', testIt(platform, 'Click after sample (bottom)', 'editable',
'after', kLineHeight - 1, 'abcd|'); 'after', 'bottom', 'abcd|');
for (let i = 0; i <= kSample.length; ++i) { for (let i = 0; i <= kSample.length; ++i) {
const x = i * kFontSize; const x = i * kFontSize;
const expected = `${kSample.substr(0, i)}|${kSample.substr(i)}`; const expected = `${kSample.substr(0, i)}|${kSample.substr(i)}`;
testIt(platform, `Click above editable at ${expected}`, 'sample', testIt(platform, `Click above editable at ${expected}`, 'sample',
x + 1, 1, expected); x + 1, 'above', expected);
testIt(platform, `Click below editable at ${expected}`, 'sample', testIt(platform, `Click below editable at ${expected}`, 'sample',
x + 1, 'below', expected); x + 1, 'below', expected);
} }
......
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