Chromium Code Reviews| Index: LayoutTests/inspector/jump-to-previous-editing-location.html |
| diff --git a/LayoutTests/inspector/jump-to-previous-editing-location.html b/LayoutTests/inspector/jump-to-previous-editing-location.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..262b5e4bb1e698d5aa7dfc5c23603a69d89b23f5 |
| --- /dev/null |
| +++ b/LayoutTests/inspector/jump-to-previous-editing-location.html |
| @@ -0,0 +1,276 @@ |
| +<html> |
| +<head> |
| +<script src="../http/tests/inspector/inspector-test.js"></script> |
| +<script src="../http/tests/inspector/workspace-test.js"></script> |
| +<script src="resources/blink-fs.js"></script> |
| +<script src="editor/editor-test.js"></script> |
| +<script> |
| +function test() |
| +{ |
| + WebInspector.experimentsSettings.jumpToPreviousLocation.enableForTest(); |
| + WebInspector.showPanel("sources"); |
| + var panel = WebInspector.panels.sources; |
| + var project = WebInspector.workspace.projectsForType(WebInspector.projectTypes.Network)[0]; |
| + var sourceCodes = project.uiSourceCodes(); |
| + |
| + function rollback() |
| + { |
| + panel._historyManager.rollback(); |
| + } |
| + |
| + function rollover() |
| + { |
| + panel._historyManager.rollover(); |
| + } |
| + |
| + function findSourceCode(substring) |
| + { |
| + for (var i = 0; i < sourceCodes.length; ++i) { |
| + if (sourceCodes[i].path().indexOf(substring) >= 0) |
| + return sourceCodes[i]; |
| + } |
| + return null; |
| + } |
| + |
| + function clickAtEditor(editor, lineNumber, columnNumber) |
| + { |
| + editor.scrollToLine(lineNumber); |
| + var coordinates = editor.cursorPositionToCoordinates(lineNumber, columnNumber); |
| + eventSender.mouseMoveTo(coordinates.x, coordinates.y); |
| + eventSender.mouseDown(); |
| + eventSender.mouseUp(); |
| + dumpSelection(editor, "Mouse click (" + lineNumber + ", " + columnNumber + ")"); |
| + } |
| + |
| + function clickAndDump(editor, callback, lines, columns) |
| + { |
| + var iterationsAmount = lines.length; |
| + function innerClickAndDump(iteration) |
| + { |
| + if (iteration === iterationsAmount) { |
| + callback(); |
| + return; |
| + } |
| + clickAtEditor(editor, lines[iteration], columns[iteration]); |
| + setTimeout(innerClickAndDump.bind(this, iteration + 1), 0); |
| + } |
| + innerClickAndDump(0); |
| + } |
| + |
| + function dumpLineColumn(line, column) |
| + { |
| + return "line: " + line + " column: " + column; |
| + } |
| + |
| + function dumpSelection(editor, label) |
| + { |
| + var selection = editor.selection(); |
| + var label = "<" + label + ">"; |
| + var fileName = "[" + editor._url.split("/").pop() + "]"; |
| + var selectionText = ""; |
| + if (selection.isEmpty()) |
| + selectionText = "line: " + selection.startLine + " column: " + selection.startColumn; |
| + else |
| + selectionText = "(NOT EMPTY): " + selection.toString(); |
| + InspectorTest.addResult(label + " " + selectionText + " " + fileName); |
| + } |
| + |
| + InspectorTest.runTestSuite([ |
| + function testSimpleMovements(next) |
| + { |
| + var uiSourceCode = findSourceCode("blink-fs"); |
|
vsevik
2014/01/15 16:19:05
use InspectorTest.showScriptSource from debugger-t
lushnikov
2014/01/16 17:10:29
Done.
|
| + panel._showFile(uiSourceCode); |
| + uiSourceCode.requestContent(onContentLoaded); |
| + function onContentLoaded() |
| + { |
| + var editor = panel.visibleView.textEditor; |
| + dumpSelection(editor, "Initial position"); |
| + clickAtEditor(editor, 4, 7); |
| + |
| + InspectorTest.typeIn("\nSome more text here"); |
| + dumpSelection(editor, "Typed in some text"); |
| + |
| + rollback(); |
| + dumpSelection(editor, "Rolled back"); |
| + InspectorTest.typeIn("\nSome more text here as well\n"); |
| + dumpSelection(editor, "Typed in some text"); |
| + |
| + rollover(); |
| + dumpSelection(editor, "Rolled over"); |
| + next(); |
| + } |
| + }, |
| + |
| + function testSequentialJumps(next) |
| + { |
| + var editor = panel.visibleView.textEditor; |
| + const jumpsToDo = 4; |
| + clickAndDump(editor, jumpBack, [10, 11, 12, 13], [3, 4, 5, 6]); |
| + |
| + function jumpBack() |
| + { |
| + for (var i = 0; i < jumpsToDo; ++i) { |
| + rollback(); |
| + dumpSelection(editor, "Rolled back"); |
| + } |
| + for (var i = 0; i < jumpsToDo; ++i) { |
| + rollover(); |
| + dumpSelection(editor, "Rolled over"); |
| + } |
| + next(); |
| + } |
| + }, |
| + |
| + function testDeletePreviousJumpLocations(next) |
| + { |
| + var editor = panel.visibleView.textEditor; |
| + editor.editRange(new WebInspector.TextRange(9, 0, 15, 0), ""); |
| + dumpSelection(editor, "Removed lines from 9 to 15"); |
| + rollback(); |
| + dumpSelection(editor, "Rolled back"); |
| + rollover(); |
| + dumpSelection(editor, "Rolled over"); |
| + next(); |
| + }, |
| + |
| + function testDeleteNextJumpLocations(next) |
| + { |
| + var editor = panel.visibleView.textEditor; |
| + const jumpsToDo = 4; |
| + clickAndDump(editor, step2, [10, 11, 12, 13], [3, 4, 5, 6]); |
| + |
| + function step2() |
| + { |
| + for (var i = 0; i < jumpsToDo; ++i) |
| + rollback(); |
| + dumpSelection(editor, "Rolled back 4 times"); |
| + editor.editRange(new WebInspector.TextRange(9, 0, 11, 0), ""); |
| + dumpSelection(editor, "Removed lines from 9 to 11"); |
| + rollover(); |
| + dumpSelection(editor, "Rolled over"); |
| + next(); |
| + } |
| + }, |
| + |
| + function testCrossFileJump(next) |
| + { |
| + var uiSourceCode = findSourceCode("workspace-test.js"); |
| + panel._showFile(uiSourceCode); |
| + uiSourceCode.requestContent(onContentLoaded); |
| + function onContentLoaded() |
| + { |
| + var editor = panel.visibleView.textEditor; |
| + dumpSelection(editor, "Opened workspace-test.js"); |
| + clickAndDump(editor, step2, [10, 11], [1, 1]); |
| + } |
| + function step2() |
| + { |
| + for (var i = 0; i < 4; ++i) { |
| + rollback(); |
| + dumpSelection(panel.visibleView.textEditor, "Rolled back"); |
| + } |
| + for (var i = 0; i < 4; ++i) { |
| + rollover(); |
| + dumpSelection(panel.visibleView.textEditor, "Rolled over"); |
| + } |
| + next(); |
| + } |
| + }, |
| + |
| + function testCloseCrossFile(next) |
| + { |
| + var selectedTab = panel._editorContainer._tabbedPane.selectedTabId; |
| + panel._editorContainer._tabbedPane.closeTab(selectedTab); |
| + dumpSelection(panel.visibleView.textEditor, "Close active tab"); |
| + for (var i = 0; i < 1; ++i) { |
| + rollback(); |
| + dumpSelection(panel.visibleView.textEditor, "Rolled back"); |
| + } |
| + for (var i = 0; i < 3; ++i) { |
| + rollover(); |
| + dumpSelection(panel.visibleView.textEditor, "Rolled over"); |
| + } |
| + next(); |
| + }, |
| + |
| + function testHistoryDepth(next) |
| + { |
| + var lines = []; |
| + var columns = []; |
| + const jumpsAmount = WebInspector.EditingLocationHistoryManager.HistoryDepth; |
| + for(var i = 0; i < jumpsAmount; ++i) { |
| + lines.push(i + 10); |
| + columns.push(7); |
| + } |
| + var editor = panel.visibleView.textEditor; |
| + clickAndDump(editor, step2, lines, columns); |
| + function step2() |
| + { |
| + for (var i = 0; i < jumpsAmount; ++i) { |
| + rollback(); |
| + dumpSelection(editor, "Rolled back"); |
| + } |
| + next(); |
| + } |
| + }, |
| + |
| + function testInFileSearch(next) |
| + { |
| + var searchableView = panel.searchableView(); |
| + searchableView.showSearchField(); |
| + dumpSelection(panel.visibleView.textEditor, "Before searching"); |
| + InspectorTest.typeIn("generate_"); |
| + for (var i = 0; i < 3; ++i) |
| + searchableView.handleFindPreviousShortcut(); |
| + searchableView.closeSearch(); |
| + dumpSelection(panel.visibleView.textEditor, "After searching"); |
| + rollback(); |
| + dumpSelection(panel.visibleView.textEditor, "Rolled back"); |
| + rollover(); |
| + dumpSelection(panel.visibleView.textEditor, "Rolled over"); |
| + next(); |
| + }, |
| + |
| + function testShowAnchorLocation(next) |
| + { |
| + dumpSelection(panel.visibleView.textEditor, "Before switching to other panel"); |
| + var uiSourceCode = findSourceCode("workspace-test.js"); |
| + var linkifier = new WebInspector.Linkifier(); |
| + var anchorUri = uiSourceCode.uri(); |
|
vsevik
2014/01/15 16:19:05
anchorURI
lushnikov
2014/01/16 17:10:29
Done.
|
| + var jumpAnchor = linkifier.linkifyLocation(anchorUri, 10, 1); |
| + WebInspector.showPanel("timeline"); |
| + WebInspector.showAnchorLocation(jumpAnchor); |
| + InspectorTest.addResult("Selection: " + panel.visibleView.textEditor.selection().toString()); |
| + dumpSelection(panel.visibleView.textEditor, "Showed anchor in " + anchorUri.split("/").pop() + " with line 333 column 3"); |
| + rollback(); |
| + dumpSelection(panel.visibleView.textEditor, "Rolled back"); |
| + rollover(); |
| + dumpSelection(panel.visibleView.textEditor, "Rolled over"); |
| + next(); |
| + }, |
| + |
| + function testShowUISourceCode(next) |
| + { |
| + dumpSelection(panel.visibleView.textEditor, "Initial state"); |
| + var uiSourceCode = findSourceCode("blink-fs.js"); |
| + var jumps = [20, 10, 30]; |
| + for (var i = 0; i < jumps.length; ++i) { |
| + panel.showUISourceCode(uiSourceCode, jumps[i]); |
| + dumpSelection(panel.visibleView.textEditor, "jump to line " + jumps[i]); |
| + } |
| + panel.highlightPosition(40, 10); |
| + dumpSelection(panel.visibleView.textEditor, "highlight line 40"); |
| + for (var i = 0; i < jumps.length + 1; ++i) { |
| + rollback(); |
| + dumpSelection(panel.visibleView.textEditor, "rollback"); |
| + } |
| + next(); |
| + } |
| + ]); |
| +}; |
| +</script> |
| +</head> |
| +<body onload="runTest()"> |
| +<p>Tests that jumping to previous location works as intended.</p> |
| +</body> |
| +</html> |