OLD | NEW |
---|---|
(Empty) | |
1 <html> | |
2 <head> | |
3 <script src="../http/tests/inspector/inspector-test.js"></script> | |
4 <script src="../http/tests/inspector/workspace-test.js"></script> | |
5 <script src="resources/blink-fs.js"></script> | |
6 <script src="editor/editor-test.js"></script> | |
7 <script> | |
8 function test() | |
9 { | |
10 WebInspector.experimentsSettings.jumpToPreviousLocation.enableForTest(); | |
11 WebInspector.showPanel("sources"); | |
12 var panel = WebInspector.panels.sources; | |
13 var project = WebInspector.workspace.projectsForType(WebInspector.projectTyp es.Network)[0]; | |
14 var sourceCodes = project.uiSourceCodes(); | |
15 | |
16 function rollback() | |
17 { | |
18 panel._historyManager.rollback(); | |
19 } | |
20 | |
21 function rollover() | |
22 { | |
23 panel._historyManager.rollover(); | |
24 } | |
25 | |
26 function findSourceCode(substring) | |
27 { | |
28 for (var i = 0; i < sourceCodes.length; ++i) { | |
29 if (sourceCodes[i].path().indexOf(substring) >= 0) | |
30 return sourceCodes[i]; | |
31 } | |
32 return null; | |
33 } | |
34 | |
35 function clickAtEditor(editor, lineNumber, columnNumber) | |
36 { | |
37 editor.scrollToLine(lineNumber); | |
38 var coordinates = editor.cursorPositionToCoordinates(lineNumber, columnN umber); | |
39 eventSender.mouseMoveTo(coordinates.x, coordinates.y); | |
40 eventSender.mouseDown(); | |
41 eventSender.mouseUp(); | |
42 dumpSelection(editor, "Mouse click (" + lineNumber + ", " + columnNumber + ")"); | |
43 } | |
44 | |
45 function clickAndDump(editor, callback, lines, columns) | |
46 { | |
47 var iterationsAmount = lines.length; | |
48 function innerClickAndDump(iteration) | |
49 { | |
50 if (iteration === iterationsAmount) { | |
51 callback(); | |
52 return; | |
53 } | |
54 clickAtEditor(editor, lines[iteration], columns[iteration]); | |
55 setTimeout(innerClickAndDump.bind(this, iteration + 1), 0); | |
56 } | |
57 innerClickAndDump(0); | |
58 } | |
59 | |
60 function dumpLineColumn(line, column) | |
61 { | |
62 return "line: " + line + " column: " + column; | |
63 } | |
64 | |
65 function dumpSelection(editor, label) | |
66 { | |
67 var selection = editor.selection(); | |
68 var label = "<" + label + ">"; | |
69 var fileName = "[" + editor._url.split("/").pop() + "]"; | |
70 var selectionText = ""; | |
71 if (selection.isEmpty()) | |
72 selectionText = "line: " + selection.startLine + " column: " + selec tion.startColumn; | |
73 else | |
74 selectionText = "(NOT EMPTY): " + selection.toString(); | |
75 InspectorTest.addResult(label + " " + selectionText + " " + fileName); | |
76 } | |
77 | |
78 InspectorTest.runTestSuite([ | |
79 function testSimpleMovements(next) | |
80 { | |
81 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.
| |
82 panel._showFile(uiSourceCode); | |
83 uiSourceCode.requestContent(onContentLoaded); | |
84 function onContentLoaded() | |
85 { | |
86 var editor = panel.visibleView.textEditor; | |
87 dumpSelection(editor, "Initial position"); | |
88 clickAtEditor(editor, 4, 7); | |
89 | |
90 InspectorTest.typeIn("\nSome more text here"); | |
91 dumpSelection(editor, "Typed in some text"); | |
92 | |
93 rollback(); | |
94 dumpSelection(editor, "Rolled back"); | |
95 InspectorTest.typeIn("\nSome more text here as well\n"); | |
96 dumpSelection(editor, "Typed in some text"); | |
97 | |
98 rollover(); | |
99 dumpSelection(editor, "Rolled over"); | |
100 next(); | |
101 } | |
102 }, | |
103 | |
104 function testSequentialJumps(next) | |
105 { | |
106 var editor = panel.visibleView.textEditor; | |
107 const jumpsToDo = 4; | |
108 clickAndDump(editor, jumpBack, [10, 11, 12, 13], [3, 4, 5, 6]); | |
109 | |
110 function jumpBack() | |
111 { | |
112 for (var i = 0; i < jumpsToDo; ++i) { | |
113 rollback(); | |
114 dumpSelection(editor, "Rolled back"); | |
115 } | |
116 for (var i = 0; i < jumpsToDo; ++i) { | |
117 rollover(); | |
118 dumpSelection(editor, "Rolled over"); | |
119 } | |
120 next(); | |
121 } | |
122 }, | |
123 | |
124 function testDeletePreviousJumpLocations(next) | |
125 { | |
126 var editor = panel.visibleView.textEditor; | |
127 editor.editRange(new WebInspector.TextRange(9, 0, 15, 0), ""); | |
128 dumpSelection(editor, "Removed lines from 9 to 15"); | |
129 rollback(); | |
130 dumpSelection(editor, "Rolled back"); | |
131 rollover(); | |
132 dumpSelection(editor, "Rolled over"); | |
133 next(); | |
134 }, | |
135 | |
136 function testDeleteNextJumpLocations(next) | |
137 { | |
138 var editor = panel.visibleView.textEditor; | |
139 const jumpsToDo = 4; | |
140 clickAndDump(editor, step2, [10, 11, 12, 13], [3, 4, 5, 6]); | |
141 | |
142 function step2() | |
143 { | |
144 for (var i = 0; i < jumpsToDo; ++i) | |
145 rollback(); | |
146 dumpSelection(editor, "Rolled back 4 times"); | |
147 editor.editRange(new WebInspector.TextRange(9, 0, 11, 0), ""); | |
148 dumpSelection(editor, "Removed lines from 9 to 11"); | |
149 rollover(); | |
150 dumpSelection(editor, "Rolled over"); | |
151 next(); | |
152 } | |
153 }, | |
154 | |
155 function testCrossFileJump(next) | |
156 { | |
157 var uiSourceCode = findSourceCode("workspace-test.js"); | |
158 panel._showFile(uiSourceCode); | |
159 uiSourceCode.requestContent(onContentLoaded); | |
160 function onContentLoaded() | |
161 { | |
162 var editor = panel.visibleView.textEditor; | |
163 dumpSelection(editor, "Opened workspace-test.js"); | |
164 clickAndDump(editor, step2, [10, 11], [1, 1]); | |
165 } | |
166 function step2() | |
167 { | |
168 for (var i = 0; i < 4; ++i) { | |
169 rollback(); | |
170 dumpSelection(panel.visibleView.textEditor, "Rolled back"); | |
171 } | |
172 for (var i = 0; i < 4; ++i) { | |
173 rollover(); | |
174 dumpSelection(panel.visibleView.textEditor, "Rolled over"); | |
175 } | |
176 next(); | |
177 } | |
178 }, | |
179 | |
180 function testCloseCrossFile(next) | |
181 { | |
182 var selectedTab = panel._editorContainer._tabbedPane.selectedTabId; | |
183 panel._editorContainer._tabbedPane.closeTab(selectedTab); | |
184 dumpSelection(panel.visibleView.textEditor, "Close active tab"); | |
185 for (var i = 0; i < 1; ++i) { | |
186 rollback(); | |
187 dumpSelection(panel.visibleView.textEditor, "Rolled back"); | |
188 } | |
189 for (var i = 0; i < 3; ++i) { | |
190 rollover(); | |
191 dumpSelection(panel.visibleView.textEditor, "Rolled over"); | |
192 } | |
193 next(); | |
194 }, | |
195 | |
196 function testHistoryDepth(next) | |
197 { | |
198 var lines = []; | |
199 var columns = []; | |
200 const jumpsAmount = WebInspector.EditingLocationHistoryManager.Histo ryDepth; | |
201 for(var i = 0; i < jumpsAmount; ++i) { | |
202 lines.push(i + 10); | |
203 columns.push(7); | |
204 } | |
205 var editor = panel.visibleView.textEditor; | |
206 clickAndDump(editor, step2, lines, columns); | |
207 function step2() | |
208 { | |
209 for (var i = 0; i < jumpsAmount; ++i) { | |
210 rollback(); | |
211 dumpSelection(editor, "Rolled back"); | |
212 } | |
213 next(); | |
214 } | |
215 }, | |
216 | |
217 function testInFileSearch(next) | |
218 { | |
219 var searchableView = panel.searchableView(); | |
220 searchableView.showSearchField(); | |
221 dumpSelection(panel.visibleView.textEditor, "Before searching"); | |
222 InspectorTest.typeIn("generate_"); | |
223 for (var i = 0; i < 3; ++i) | |
224 searchableView.handleFindPreviousShortcut(); | |
225 searchableView.closeSearch(); | |
226 dumpSelection(panel.visibleView.textEditor, "After searching"); | |
227 rollback(); | |
228 dumpSelection(panel.visibleView.textEditor, "Rolled back"); | |
229 rollover(); | |
230 dumpSelection(panel.visibleView.textEditor, "Rolled over"); | |
231 next(); | |
232 }, | |
233 | |
234 function testShowAnchorLocation(next) | |
235 { | |
236 dumpSelection(panel.visibleView.textEditor, "Before switching to oth er panel"); | |
237 var uiSourceCode = findSourceCode("workspace-test.js"); | |
238 var linkifier = new WebInspector.Linkifier(); | |
239 var anchorUri = uiSourceCode.uri(); | |
vsevik
2014/01/15 16:19:05
anchorURI
lushnikov
2014/01/16 17:10:29
Done.
| |
240 var jumpAnchor = linkifier.linkifyLocation(anchorUri, 10, 1); | |
241 WebInspector.showPanel("timeline"); | |
242 WebInspector.showAnchorLocation(jumpAnchor); | |
243 InspectorTest.addResult("Selection: " + panel.visibleView.textEditor .selection().toString()); | |
244 dumpSelection(panel.visibleView.textEditor, "Showed anchor in " + an chorUri.split("/").pop() + " with line 333 column 3"); | |
245 rollback(); | |
246 dumpSelection(panel.visibleView.textEditor, "Rolled back"); | |
247 rollover(); | |
248 dumpSelection(panel.visibleView.textEditor, "Rolled over"); | |
249 next(); | |
250 }, | |
251 | |
252 function testShowUISourceCode(next) | |
253 { | |
254 dumpSelection(panel.visibleView.textEditor, "Initial state"); | |
255 var uiSourceCode = findSourceCode("blink-fs.js"); | |
256 var jumps = [20, 10, 30]; | |
257 for (var i = 0; i < jumps.length; ++i) { | |
258 panel.showUISourceCode(uiSourceCode, jumps[i]); | |
259 dumpSelection(panel.visibleView.textEditor, "jump to line " + ju mps[i]); | |
260 } | |
261 panel.highlightPosition(40, 10); | |
262 dumpSelection(panel.visibleView.textEditor, "highlight line 40"); | |
263 for (var i = 0; i < jumps.length + 1; ++i) { | |
264 rollback(); | |
265 dumpSelection(panel.visibleView.textEditor, "rollback"); | |
266 } | |
267 next(); | |
268 } | |
269 ]); | |
270 }; | |
271 </script> | |
272 </head> | |
273 <body onload="runTest()"> | |
274 <p>Tests that jumping to previous location works as intended.</p> | |
275 </body> | |
276 </html> | |
OLD | NEW |