| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="editor-test.js"></script> |
| <script> |
| function test() |
| { |
| var out = InspectorTest.addResult; |
| var textEditor = InspectorTest.createTestEditor(500); |
| textEditor.setMimeType("text/javascript"); |
| textEditor.setReadOnly(false); |
| textEditor.element.focus(); |
| |
| textEditor.setText(new Array(10000).join("\n")); |
| |
| testLineReveal(0); |
| testLineReveal(500); |
| testLineReveal(510); |
| testLineReveal(490); |
| testLineReveal(1000); |
| testLineReveal(100); |
| testLineReveal(9998); |
| testLineReveal(-100); |
| testLineReveal(textEditor.linesCount); |
| testLineReveal(-1); |
| testLineReveal(10100); |
| |
| function testLineReveal(lineNumber) |
| { |
| textEditor.revealPosition(lineNumber); |
| var firstLine = textEditor.firstVisibleLine(); |
| var lastLine = textEditor.lastVisibleLine(); |
| var lineCentered = Math.abs(2 * lineNumber - firstLine - lastLine) <= 1; |
| out("======= Revealing line: " + lineNumber); |
| out(" is line centered: " + lineCentered); |
| out("\n"); |
| } |
| InspectorTest.completeTest(); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <p> |
| This test checks that text editor's revealLine centers line where needed. |
| </p> |
| |
| </body> |
| </html> |