fix virtual renderer test
This commit is contained in:
parent
5c60ebb753
commit
766af2388e
1 changed files with 16 additions and 14 deletions
|
|
@ -56,28 +56,30 @@ module.exports = {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
el.style.left = "0px";
|
el.style.left = "20px";
|
||||||
el.style.top = "0px";
|
el.style.top = "30px";
|
||||||
el.style.width = "100px";
|
el.style.width = "300px";
|
||||||
el.style.height = "100px";
|
el.style.height = "100px";
|
||||||
document.body.style.margin = "0px";
|
|
||||||
document.body.style.padding = "0px";
|
|
||||||
document.body.appendChild(el);
|
document.body.appendChild(el);
|
||||||
|
|
||||||
var renderer = new VirtualRenderer(el);
|
var renderer = new VirtualRenderer(el);
|
||||||
renderer.setPadding(0);
|
renderer.setPadding(0);
|
||||||
renderer.setSession(new EditSession("1234"));
|
renderer.setSession(new EditSession("1234"));
|
||||||
|
|
||||||
|
var r = renderer.scroller.getBoundingClientRect();
|
||||||
|
function testPixelToText(x, y, row, column) {
|
||||||
|
assert.position(renderer.screenToTextCoordinates(x+r.left, y+r.top), row, column);
|
||||||
|
}
|
||||||
|
|
||||||
renderer.characterWidth = 10;
|
renderer.characterWidth = 10;
|
||||||
renderer.lineHeight = 15;
|
renderer.lineHeight = 15;
|
||||||
|
|
||||||
assert.position(renderer.screenToTextCoordinates(0, 0), 0, 0);
|
testPixelToText(4, 0, 0, 0);
|
||||||
assert.position(renderer.screenToTextCoordinates(4, 0), 0, 0);
|
testPixelToText(5, 0, 0, 1);
|
||||||
assert.position(renderer.screenToTextCoordinates(5, 0), 0, 1);
|
testPixelToText(9, 0, 0, 1);
|
||||||
assert.position(renderer.screenToTextCoordinates(9, 0), 0, 1);
|
testPixelToText(10, 0, 0, 1);
|
||||||
assert.position(renderer.screenToTextCoordinates(10, 0), 0, 1);
|
testPixelToText(14, 0, 0, 1);
|
||||||
assert.position(renderer.screenToTextCoordinates(14, 0), 0, 1);
|
testPixelToText(15, 0, 0, 2);
|
||||||
assert.position(renderer.screenToTextCoordinates(15, 0), 0, 2);
|
|
||||||
document.body.removeChild(el);
|
document.body.removeChild(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue