| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="editor-test.js"></script> |
| <script> |
| |
| function test() |
| { |
| var text = [ |
| "foo();", |
| "foo_1; foor; foo_;", |
| "foo_", |
| "global_foo", |
| "global_foo2", |
| "some_other_foo_X" |
| ]; |
| var textEditor = InspectorTest.createTestEditor(); |
| textEditor.setText(text.join("\n")); |
| var paintLineCalls = 0; |
| function paintLineCounter() |
| { |
| ++paintLineCalls; |
| } |
| InspectorTest.addSniffer(textEditor._mainPanel, "_paintLine", paintLineCounter, true); |
| InspectorTest.addResult("\nBefore highlight"); |
| InspectorTest.dumpEditorHTML(textEditor, true); |
| |
| var rangeHighlightDescriptor; |
| var regexHighlightDescriptor; |
| |
| InspectorTest.runTestSuite([ |
| function testHighlightRegex(next) |
| { |
| regexHighlightDescriptor = textEditor.highlightRegex("foo_.", "some-css-class"); |
| InspectorTest.addResult("\nAdd highlight for regexp /foo_./"); |
| InspectorTest.addResult("Lines repainted: " + paintLineCalls); |
| InspectorTest.dumpEditorHTML(textEditor, true); |
| next(); |
| }, |
| |
| function testHighlightRange(next) |
| { |
| InspectorTest.addResult("\nHighlighting range from (1, 13) to (3, 16)"); |
| paintLineCalls = 0; |
| rangeHighlightDescriptor = textEditor.highlightRange(new WebInspector.TextRange(1, 13, 3, 16), "some-other-class"); |
| InspectorTest.addResult("Lines repainted: " + paintLineCalls); |
| InspectorTest.dumpEditorHTML(textEditor, true); |
| next(); |
| }, |
| |
| function testRemoveRegexHighlight(next) |
| { |
| InspectorTest.addResult("\nRemove highlight for regexp /foo_./"); |
| paintLineCalls = 0; |
| textEditor.removeHighlight(regexHighlightDescriptor); |
| InspectorTest.addResult("Lines repainted: " + paintLineCalls); |
| InspectorTest.dumpEditorHTML(textEditor, true); |
| next(); |
| }, |
| |
| function testRemoveRangeHighlight(next) |
| { |
| InspectorTest.addResult("\nRemove highlight for range (1, 13) to (3, 16)"); |
| paintLineCalls = 0; |
| textEditor.removeHighlight(rangeHighlightDescriptor); |
| InspectorTest.addResult("Lines repainted: " + paintLineCalls); |
| InspectorTest.dumpEditorHTML(textEditor, true); |
| next(); |
| }, |
| |
| function testHighlightSmallRange(next) |
| { |
| InspectorTest.addResult("\nHighlighting range from (1, 1) to (1, 1)"); |
| paintLineCalls = 0; |
| var smallRangeHighlightDescriptor = textEditor.highlightRange(new WebInspector.TextRange(1, 1, 1, 1), "some-other-class"); |
| InspectorTest.addResult("Lines repainted: " + paintLineCalls); |
| InspectorTest.dumpEditorHTML(textEditor, true); |
| next(); |
| }, |
| |
| ]); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <p> |
| Test editor highlight regexp API. |
| </p> |
| </body> |
| </html> |