3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"editor-test.js"></script>
10 "function foo(a, b) {",
11 " var f = /*.[a]/.test(a);",
14 var textEditor
= InspectorTest
.createTestEditor();
15 textEditor
.setText(text
.join("\n"));
17 InspectorTest
.runTestSuite([
18 function testCoordinatesToCursorPositionOuter(next
)
20 InspectorTest
.addResult("Request char at (-1000, -1000)");
21 InspectorTest
.addResult("Result:" + JSON
.stringify(textEditor
.coordinatesToCursorPosition(-1000, -1000)));
25 function testTextToCoordinatesCornerCases(next
)
27 InspectorTest
.addResult("Request (-1, 0):" + JSON
.stringify(textEditor
.cursorPositionToCoordinates(-1, 0)));
28 InspectorTest
.addResult("Request (100, 0):" + JSON
.stringify(textEditor
.cursorPositionToCoordinates(100, 0)));
29 InspectorTest
.addResult("Request (0, -1):" + JSON
.stringify(textEditor
.cursorPositionToCoordinates(0, -1)));
30 InspectorTest
.addResult("Request (0, 100):" + JSON
.stringify(textEditor
.cursorPositionToCoordinates(0, 100)));
31 InspectorTest
.addResult("Request (-100, -1100):" + JSON
.stringify(textEditor
.cursorPositionToCoordinates(0, 100)));
35 function testInverseRelationTextToCoordinates(next
)
37 for(var i
= 0; i
< textEditor
.linesCount
; ++i
) {
38 var line
= textEditor
.line(i
);
39 InspectorTest
.addResult("Testing line '" + line
+ "'");
40 for(var j
= 0; j
< textEditor
.length
; ++j
) {
41 var xy
= textEditor
.cursorPositionToCoordinates(i
, j
);
43 InspectorTest
.addResult("Failed inversion for line=" + i
+ " column=" + j
);
47 var range
= textEditor
.coordinatesToCursorPosition(xy
.x
, xy
.y
);
48 if (range
.startLine
!== i
|| range
.startColumn
!== j
)
49 InspectorTest
.addResult("Failed inversion for line=" + i
+ " column=" + j
);
60 <body onload=
"runTest()">
62 Test editor cursorPositionToCoordinates and coordinatesToCursorPosition API