1 function initialize_EditorTests()
4 InspectorTest.createTestEditor = function(clientHeight, textEditorDelegate)
6 loadScript("CodeMirrorTextEditor.js");
7 var textEditor = new WebInspector.CodeMirrorTextEditor("", textEditorDelegate || new WebInspector.TextEditorDelegate());
9 textEditor.element.style.height = clientHeight + "px";
10 textEditor.show(WebInspector.inspectorView.element);
14 InspectorTest.fillEditorWithText = function(textEditor, lineCount)
16 var textModel = textEditor._textModel;
18 for (var i = 0; i < lineCount; ++i)
20 textModel.setText(lines.join("\n"));
23 InspectorTest.textWithSelection = function(text, selection)
28 function lineWithCursor(line, column, cursorChar)
30 return line.substring(0, column) + cursorChar + line.substring(column);
33 var lines = text.split("\n");
34 selection = selection.normalize();
35 var endCursorChar = selection.isEmpty() ? "|" : "<";
36 lines[selection.endLine] = lineWithCursor(lines[selection.endLine], selection.endColumn, endCursorChar);
37 if (!selection.isEmpty()) {
38 lines[selection.startLine] = lineWithCursor(lines[selection.startLine], selection.startColumn, ">");
40 return lines.join("\n");
43 InspectorTest.dumpTextWithSelection = function(textEditor, dumpWhiteSpaces)
45 var text = InspectorTest.textWithSelection(textEditor.text(), textEditor.selection());
47 text = text.replace(/ /g, ".");
48 InspectorTest.addResult(text);
51 InspectorTest.typeIn = function(typeText)
53 for(var charIndex = 0; charIndex < typeText.length; ++charIndex) {
54 switch (typeText[charIndex]) {
56 eventSender.keyDown("leftArrow");
59 eventSender.keyDown("rightArrow");
62 eventSender.keyDown("upArrow");
65 eventSender.keyDown("downArrow");
68 eventSender.keyDown(typeText[charIndex]);