| OLD | NEW |
| 1 function initialize_EditorTests() | 1 function initialize_EditorTests() |
| 2 { | 2 { |
| 3 | 3 |
| 4 InspectorTest.createTestEditor = function(clientHeight, textEditorDelegate) | 4 InspectorTest.createTestEditor = function(clientHeight, textEditorDelegate) |
| 5 { | 5 { |
| 6 var textEditor = new SourceFrame.SourcesTextEditor(textEditorDelegate || new
SourceFrame.SourcesTextEditorDelegate()); | 6 var textEditor = new SourceFrame.SourcesTextEditor(textEditorDelegate || new
SourceFrame.SourcesTextEditorDelegate()); |
| 7 clientHeight = clientHeight || 100; | 7 clientHeight = clientHeight || 100; |
| 8 textEditor.element.style.height = clientHeight + "px"; | 8 textEditor.element.style.height = clientHeight + "px"; |
| 9 textEditor.element.style.flex = "none"; | 9 textEditor.element.style.flex = "none"; |
| 10 textEditor.show(UI.inspectorView.element); | 10 textEditor.show(UI.inspectorView.element); |
| 11 return textEditor; | 11 return textEditor; |
| 12 }; | 12 }; |
| 13 | 13 |
| 14 function textWithSelection(text, selections) | 14 function textWithSelection(text, selections) |
| 15 { | 15 { |
| 16 if (!selections.length) | 16 if (!selections.length) |
| 17 return text; | 17 return text; |
| 18 | 18 |
| 19 function lineWithCursor(line, column, cursorChar) | 19 function lineWithCursor(line, column, cursorChar) |
| 20 { | 20 { |
| 21 return line.substring(0, column) + cursorChar + line.substring(column); | 21 return line.substring(0, column) + cursorChar + line.substring(column); |
| 22 } | 22 } |
| 23 | 23 |
| 24 var lines = text.split("\n"); | 24 var lines = text.split("\n"); |
| 25 selections.sort(Common.TextRange.comparator); | 25 selections.sort(TextUtils.TextRange.comparator); |
| 26 for (var i = selections.length - 1; i >= 0; --i) { | 26 for (var i = selections.length - 1; i >= 0; --i) { |
| 27 var selection = selections[i]; | 27 var selection = selections[i]; |
| 28 selection = selection.normalize(); | 28 selection = selection.normalize(); |
| 29 var endCursorChar = selection.isEmpty() ? "|" : "<"; | 29 var endCursorChar = selection.isEmpty() ? "|" : "<"; |
| 30 lines[selection.endLine] = lineWithCursor(lines[selection.endLine], sele
ction.endColumn, endCursorChar); | 30 lines[selection.endLine] = lineWithCursor(lines[selection.endLine], sele
ction.endColumn, endCursorChar); |
| 31 if (!selection.isEmpty()) { | 31 if (!selection.isEmpty()) { |
| 32 lines[selection.startLine] = lineWithCursor(lines[selection.startLin
e], selection.startColumn, ">"); | 32 lines[selection.startLine] = lineWithCursor(lines[selection.startLin
e], selection.startColumn, ">"); |
| 33 } | 33 } |
| 34 } | 34 } |
| 35 return lines.join("\n"); | 35 return lines.join("\n"); |
| 36 } | 36 } |
| 37 | 37 |
| 38 InspectorTest.dumpTextWithSelection = function(textEditor, dumpWhiteSpaces) | 38 InspectorTest.dumpTextWithSelection = function(textEditor, dumpWhiteSpaces) |
| 39 { | 39 { |
| 40 var text = textWithSelection(textEditor.text(), textEditor.selections()); | 40 var text = textWithSelection(textEditor.text(), textEditor.selections()); |
| 41 if (dumpWhiteSpaces) | 41 if (dumpWhiteSpaces) |
| 42 text = text.replace(/ /g, "."); | 42 text = text.replace(/ /g, "."); |
| 43 InspectorTest.addResult(text); | 43 InspectorTest.addResult(text); |
| 44 } | 44 } |
| 45 | 45 |
| 46 InspectorTest.setLineSelections = function(editor, selections) | 46 InspectorTest.setLineSelections = function(editor, selections) |
| 47 { | 47 { |
| 48 var coords = []; | 48 var coords = []; |
| 49 for (var i = 0; i < selections.length; ++i) { | 49 for (var i = 0; i < selections.length; ++i) { |
| 50 var selection = selections[i]; | 50 var selection = selections[i]; |
| 51 if (typeof selection.column === "number") { | 51 if (typeof selection.column === "number") { |
| 52 selection.from = selection.column; | 52 selection.from = selection.column; |
| 53 selection.to = selection.column; | 53 selection.to = selection.column; |
| 54 } | 54 } |
| 55 coords.push(new Common.TextRange(selection.line, selection.from, selecti
on.line, selection.to)); | 55 coords.push(new TextUtils.TextRange(selection.line, selection.from, sele
ction.line, selection.to)); |
| 56 } | 56 } |
| 57 editor.setSelections(coords); | 57 editor.setSelections(coords); |
| 58 } | 58 } |
| 59 | 59 |
| 60 InspectorTest.typeIn = function(editor, typeText, callback) | 60 InspectorTest.typeIn = function(editor, typeText, callback) |
| 61 { | 61 { |
| 62 callback = callback || new Function(); | 62 callback = callback || new Function(); |
| 63 var noop = new Function(); | 63 var noop = new Function(); |
| 64 for(var charIndex = 0; charIndex < typeText.length; ++charIndex) { | 64 for(var charIndex = 0; charIndex < typeText.length; ++charIndex) { |
| 65 // As soon as the last key event was processed, the whole text was proce
ssed. | 65 // As soon as the last key event was processed, the whole text was proce
ssed. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 var keyName = sortedKeys[i]; | 200 var keyName = sortedKeys[i]; |
| 201 if (!keyName.length) | 201 if (!keyName.length) |
| 202 keyName = "<Empty string>"; | 202 keyName = "<Empty string>"; |
| 203 else | 203 else |
| 204 keyName = "'" + keyName + "'"; | 204 keyName = "'" + keyName + "'"; |
| 205 InspectorTest.addResult(keyName + ": " + listHashMap[sortedKeys[i]]); | 205 InspectorTest.addResult(keyName + ": " + listHashMap[sortedKeys[i]]); |
| 206 } | 206 } |
| 207 } | 207 } |
| 208 | 208 |
| 209 } | 209 } |
| OLD | NEW |