Permalink
Browse files

fix virtual renderer test

  • Loading branch information...
1 parent 5c60ebb commit 766af2388efcf6e52484f1819229728a43bfcc29 @nightwing nightwing committed May 8, 2012
Showing with 16 additions and 14 deletions.
  1. +16 −14 lib/ace/virtual_renderer_test.js
@@ -50,34 +50,36 @@ var assert = require("./test/assertions");
module.exports = {
"test: screen2text the column should be rounded to the next character edge" : function() {
var el = document.createElement("div");
-
+
if (!el.getBoundingClientRect) {
console.log("Skipping test: This test only runs in the browser");
return;
}
-
- el.style.left = "0px";
- el.style.top = "0px";
- el.style.width = "100px";
+
+ el.style.left = "20px";
+ el.style.top = "30px";
+ el.style.width = "300px";
el.style.height = "100px";
- document.body.style.margin = "0px";
- document.body.style.padding = "0px";
document.body.appendChild(el);
var renderer = new VirtualRenderer(el);
renderer.setPadding(0);
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.lineHeight = 15;
- assert.position(renderer.screenToTextCoordinates(0, 0), 0, 0);
- assert.position(renderer.screenToTextCoordinates(4, 0), 0, 0);
- assert.position(renderer.screenToTextCoordinates(5, 0), 0, 1);
- assert.position(renderer.screenToTextCoordinates(9, 0), 0, 1);
- assert.position(renderer.screenToTextCoordinates(10, 0), 0, 1);
- assert.position(renderer.screenToTextCoordinates(14, 0), 0, 1);
- assert.position(renderer.screenToTextCoordinates(15, 0), 0, 2);
+ testPixelToText(4, 0, 0, 0);
+ testPixelToText(5, 0, 0, 1);
+ testPixelToText(9, 0, 0, 1);
+ testPixelToText(10, 0, 0, 1);
+ testPixelToText(14, 0, 0, 1);
+ testPixelToText(15, 0, 0, 2);
document.body.removeChild(el);
}

0 comments on commit 766af23

Please sign in to comment.