OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
4 <script src="editor-test.js"></script> | 4 <script src="editor-test.js"></script> |
5 <script> | 5 <script> |
6 function test() | 6 function test() |
7 { | 7 { |
8 var out = InspectorTest.addResult; | 8 var out = InspectorTest.addResult; |
9 var textEditor = InspectorTest.createTestEditor(500); | 9 var textEditor = InspectorTest.createTestEditor(500); |
10 textEditor.setMimeType("text/javascript"); | 10 textEditor.setMimeType("text/javascript"); |
11 textEditor.setReadOnly(false); | 11 textEditor.setReadOnly(false); |
12 textEditor.element.focus(); | 12 textEditor.element.focus(); |
13 | 13 |
14 textEditor.setText(new Array(10000).join("\n")); | 14 textEditor.setText(new Array(10000).join("\n")); |
15 | 15 |
16 testLineReveal(0); | 16 testLineReveal(0); |
17 testLineReveal(500); | 17 testLineReveal(500); |
18 testLineReveal(510); | 18 testLineReveal(510); |
19 testLineReveal(490); | 19 testLineReveal(490); |
20 testLineReveal(1000); | 20 testLineReveal(1000); |
21 testLineReveal(100); | 21 testLineReveal(100); |
22 testLineReveal(9998); | 22 testLineReveal(9998); |
23 testLineReveal(-100); | 23 testLineReveal(-100); |
24 testLineReveal(textEditor.linesCount); | 24 testLineReveal(textEditor.linesCount); |
25 testLineReveal(-1); | 25 testLineReveal(-1); |
26 testLineReveal(10100); | 26 testLineReveal(10100); |
27 | 27 |
28 function testLineReveal(lineNumber) | 28 function testLineReveal(lineNumber) |
29 { | 29 { |
30 textEditor.revealLine(lineNumber); | 30 textEditor.revealPosition(lineNumber); |
31 var firstLine = textEditor.firstVisibleLine(); | 31 var firstLine = textEditor.firstVisibleLine(); |
32 var lastLine = textEditor.lastVisibleLine(); | 32 var lastLine = textEditor.lastVisibleLine(); |
33 var lineCentered = Math.abs(2 * lineNumber - firstLine - lastLine) <= 1; | 33 var lineCentered = Math.abs(2 * lineNumber - firstLine - lastLine) <= 1; |
34 out("======= Revealing line: " + lineNumber); | 34 out("======= Revealing line: " + lineNumber); |
35 out(" is line centered: " + lineCentered); | 35 out(" is line centered: " + lineCentered); |
36 out("\n"); | 36 out("\n"); |
37 } | 37 } |
38 InspectorTest.completeTest(); | 38 InspectorTest.completeTest(); |
39 } | 39 } |
40 | 40 |
41 </script> | 41 </script> |
42 </head> | 42 </head> |
43 | 43 |
44 <body onload="runTest()"> | 44 <body onload="runTest()"> |
45 <p> | 45 <p> |
46 This test checks that text editor's revealLine centers line where needed. | 46 This test checks that text editor's revealLine centers line where needed. |
47 </p> | 47 </p> |
48 | 48 |
49 </body> | 49 </body> |
50 </html> | 50 </html> |
OLD | NEW |