Commit 699f0e72 authored by Fernando Serboncini's avatar Fernando Serboncini Committed by Commit Bot

Clean up modify-up-on-rtl-wrapping-text test

TBR=drott@chromium.org

Change-Id: I9c026944acad5c4783bbed7dcbea262479fbd707
Reviewed-on: https://chromium-review.googlesource.com/1136388
Commit-Queue: Fernando Serboncini <fserb@chromium.org>
Reviewed-by: default avatarDominik Röttsches <drott@chromium.org>
Reviewed-by: default avatarFernando Serboncini <fserb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#574933}
parent 3ab73342
...@@ -6,5 +6,8 @@ PASS: on כ ככ כככ, caret is at 8 initially ...@@ -6,5 +6,8 @@ PASS: on כ ככ כככ, caret is at 8 initially
PASS: on כ ככ כככ, caret is at 5 after moving upwards once PASS: on כ ככ כככ, caret is at 5 after moving upwards once
PASS: on כ ככ כככ, caret is at 2 after moving upwards twice PASS: on כ ככ כככ, caret is at 2 after moving upwards twice
PASS: on גכ יגכ יגכ יגכ יגכ, caret is at 18 initially PASS: on גכ יגכ יגכ יגכ יגכ, caret is at 18 initially
FAIL: on גכ יגכ יגכ יגכ יגכ, caret is at 15 after moving upwards once but expected at 6 PASS: on גכ יגכ יגכ יגכ יגכ, caret is at 14 after moving upwards once
גכ יגכ יגכ יגכ יגכ PASS: on גכ יגכ יגכ יגכ יגכ, caret is at 10 after moving upwards twice
PASS: on גכ יגכ יגכ יגכ יגכ, caret is at 6 after moving upwards 3 times
PASS: on גכ יגכ יגכ יגכ יגכ, caret is at 3 after moving upwards 4 times
...@@ -16,28 +16,30 @@ var tests = [ ...@@ -16,28 +16,30 @@ var tests = [
]; ];
function failed(message) { function failed(message) {
console.innerHTML += 'FAIL: ' + message + '\n'; document.getElementById('console').innerHTML += 'FAIL: ' + message + '\n';
} }
function passed(message) { function passed(message) {
console.innerHTML += 'PASS: ' + message + '\n'; document.getElementById('console').innerHTML += 'PASS: ' + message + '\n';
} }
function runTest(container, test) { function runTest(container, test) {
container.style.width = '100%'; container.style.width = '100%';
container.innerHTML = test.content; container.innerHTML = test.content;
// Starting from 5px, slowly increase the width until each word fits in one line. // Starting from 5px, slowly increase the width until each word fits in one
// line.
var heightOfLine = container.offsetHeight; var heightOfLine = container.offsetHeight;
var width = 5; var width = 5;
do { do {
container.style.width = width + 'px'; container.style.width = width + 'px';
width++; width++;
} while (container.offsetHeight > heightOfLine * test.expected.length); } while (
Math.floor(container.offsetHeight / heightOfLine) > test.expected.length);
container.style.width = (width + 1) + 'px'; container.style.width = (width + 1) + 'px';
var lines = ['st', 'nd', 'rd', 'th']; window.getSelection().collapse(container.lastChild,
window.getSelection().collapse(container.lastChild, container.lastChild.length); container.lastChild.length);
for (var i = 0; i < test.expected.length; i++) { for (var i = 0; i < test.expected.length; i++) {
if (!window.getSelection().isCollapsed) if (!window.getSelection().isCollapsed)
...@@ -52,23 +54,25 @@ function runTest(container, test) { ...@@ -52,23 +54,25 @@ function runTest(container, test) {
else if (i == 1) action += ' after moving upwards once'; else if (i == 1) action += ' after moving upwards once';
else if (i == 2) action += ' after moving upwards twice'; else if (i == 2) action += ' after moving upwards twice';
else action += ' after moving upwards ' + i + ' times'; else action += ' after moving upwards ' + i + ' times';
if (range.startOffset != test.expected[test.expected.length - i - 1]) if (range.startOffset != test.expected[test.expected.length - i - 1]) {
return failed(action + ' but expected at ' + test.expected[i]); return failed(action + ' but expected at ' +
test.expected[test.expected.length - i - 1]);
}
passed(action); passed(action);
window.getSelection().modify('move', 'backward', 'line') window.getSelection().modify('move', 'backward', 'line')
} }
} }
var console = document.getElementById('console');
var container = document.createElement('div'); var container = document.createElement('div');
container.contentEditable = true; container.contentEditable = true;
container.setAttribute('dir', 'rtl'); container.setAttribute('dir', 'rtl');
document.body.appendChild(container); document.body.appendChild(container);
for (var i = 0; i < tests.length; i++) for (var i = 0; i < tests.length; i++) {
runTest(container, tests[i]); runTest(container, tests[i]);
//container.innerHTML = ''; }
document.body.removeChild(container);
</script> </script>
</body> </body>
......
...@@ -6,8 +6,5 @@ PASS: on כ ככ כככ, caret is at 8 initially ...@@ -6,8 +6,5 @@ PASS: on כ ככ כככ, caret is at 8 initially
PASS: on כ ככ כככ, caret is at 5 after moving upwards once PASS: on כ ככ כככ, caret is at 5 after moving upwards once
PASS: on כ ככ כככ, caret is at 2 after moving upwards twice PASS: on כ ככ כככ, caret is at 2 after moving upwards twice
PASS: on גכ יגכ יגכ יגכ יגכ, caret is at 18 initially PASS: on גכ יגכ יגכ יגכ יגכ, caret is at 18 initially
PASS: on גכ יגכ יגכ יגכ יגכ, caret is at 14 after moving upwards once FAIL: on גכ יגכ יגכ יגכ יגכ, caret is at 15 after moving upwards once but expected at 14
PASS: on גכ יגכ יגכ יגכ יגכ, caret is at 10 after moving upwards twice
PASS: on גכ יגכ יגכ יגכ יגכ, caret is at 6 after moving upwards 3 times
PASS: on גכ יגכ יגכ יגכ יגכ, caret is at 3 after moving upwards 4 times
גכ יגכ יגכ יגכ יגכ
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