3 <script src=
"../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"editor-test.js"></script>
6 function codeSnippet() {
7 return document
.getElementById("codeSnippet").textContent
;
12 function testFunction()
25 var textEditor
= InspectorTest
.createTestEditor();
26 textEditor
.setMimeType("text/javascript");
27 textEditor
.setReadOnly(false);
28 textEditor
.element
.focus();
30 InspectorTest
.runTestSuite([
31 function testEnterInTheLineEnd(next
)
33 textEditor
.setText(testFunction
.toString());
34 var line
= textEditor
.line(2);
35 textEditor
.setSelection(WebInspector
.TextRange
.createFromLocation(2, line
.length
));
36 hitEnterDumpTextAndNext(next
);
39 function testEnterAfterOpenCurlyBrace(next
)
41 textEditor
.setText(testFunction
.toString());
42 var line
= textEditor
.line(1);
43 textEditor
.setSelection(WebInspector
.TextRange
.createFromLocation(1, line
.length
));
44 hitEnterDumpTextAndNext(next
);
47 function testEnterInTheMiddleOfLine(next
)
49 textEditor
.setText(testFunction
.toString());
50 var line
= textEditor
.line(2);
51 textEditor
.setSelection(WebInspector
.TextRange
.createFromLocation(2, line
.length
/ 2));
52 hitEnterDumpTextAndNext(next
);
55 function testEnterInTheBeginningOfTheLine(next
)
57 textEditor
.setText(testFunction
.toString());
58 textEditor
.setSelection(WebInspector
.TextRange
.createFromLocation(2, 0));
59 hitEnterDumpTextAndNext(next
);
62 function testEnterWithTheSelection(next
)
64 textEditor
.setText(testFunction
.toString());
65 textEditor
.setSelection(new WebInspector
.TextRange(2, 2, 2, 4));
66 hitEnterDumpTextAndNext(next
);
69 function testEnterWithReversedSelection(next
)
71 textEditor
.setText(testFunction
.toString());
72 textEditor
.setSelection(new WebInspector
.TextRange(2, 4, 2, 2));
73 hitEnterDumpTextAndNext(next
);
76 function testEnterWithTheMultiLineSelection(next
)
78 textEditor
.setText(testFunction
.toString());
79 textEditor
.setSelection(new WebInspector
.TextRange(2, 0, 8, 4));
80 hitEnterDumpTextAndNext(next
);
83 function testEnterWithFullLineSelection(next
)
85 textEditor
.setText(testFunction
.toString());
86 textEditor
.setSelection(new WebInspector
.TextRange(2, 0, 3, 0));
87 hitEnterDumpTextAndNext(next
);
90 function testEnterBeforeOpenBrace(next
)
92 textEditor
.setText(testFunction
.toString());
93 textEditor
.setSelection(new WebInspector
.TextRange(8, 0, 8, 0));
94 hitEnterDumpTextAndNext(next
);
97 function testEnterMultiCursor(next
)
99 textEditor
.setText(testFunction
.toString());
100 InspectorTest
.setLineSelections(textEditor
, [
101 { line
: 3, column
: 0 },
102 { line
: 5, column
: 1 },
103 { line
: 6, column
: 2 },
105 hitEnterDumpTextAndNext(next
);
109 function hitEnterDumpTextAndNext(next
)
111 InspectorTest
.fakeKeyEvent(textEditor
, "enter", null, step2
);
114 InspectorTest
.dumpTextWithSelection(textEditor
, true);
123 <body onload=
"runTest();">
125 This test checks text editor enter behaviour.