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 var textEditor
= InspectorTest
.createTestEditor();
13 textEditor
.setMimeType("text/javascript");
14 textEditor
.setReadOnly(false);
15 textEditor
.element
.focus();
16 InspectorTest
.evaluateInPage("codeSnippet();", onCodeSnippet
);
18 function onCodeSnippet(result
)
20 var codeLines
= result
.value
;
21 textEditor
.setText(codeLines
);
22 InspectorTest
.runTestSuite(testSuite
);
25 function nextOccurrence(times
)
27 for (var i
= 0; i
< times
; ++i
)
28 textEditor
._selectNextOccurrenceController
.selectNextOccurrence();
31 function undoLastSelection()
33 textEditor
._selectNextOccurrenceController
.undoLastSelection();
36 function lineSelection(line
, from, to
)
38 if (typeof to
!== "number")
40 InspectorTest
.setLineSelections(textEditor
, [
41 { line
: line
, from: from, to
: to
}
46 function testCursorInTheWordStart(next
)
50 InspectorTest
.dumpSelectionStats(textEditor
);
54 function testCursorInTheWordEnd(next
)
58 InspectorTest
.dumpSelectionStats(textEditor
);
62 function testNonWordSelection(next
)
64 lineSelection(18, 12, 14);
66 InspectorTest
.dumpSelectionStats(textEditor
);
70 function testNonWordSelection2(next
)
72 lineSelection(17, 30, 33);
74 InspectorTest
.dumpSelectionStats(textEditor
);
78 function testNonWordSelection3(next
)
80 InspectorTest
.setLineSelections(textEditor
, [
81 { line
: 14, from: 15, to
: 25 },
82 { line
: 16, column
: 21 },
83 { line
: 17, from: 42, to
: 47 },
85 var selections
= textEditor
.selections();
87 InspectorTest
.dumpSelectionStats(textEditor
);
91 function testNonWordSelection4(next
)
93 InspectorTest
.setLineSelections(textEditor
, [
94 { line
: 14, from: 15, to
: 25 },
95 { line
: 16, from: 21, to
: 23 },
96 { line
: 17, from: 42, to
: 47 },
98 var selections
= textEditor
.selections();
100 InspectorTest
.dumpSelectionStats(textEditor
);
104 function testTriggerWordSearchInMixedCase(next
)
106 InspectorTest
.setLineSelections(textEditor
, [
107 { line
: 9, from: 10, to
: 25 },
108 { line
: 14, column
: 33 }
111 InspectorTest
.dumpSelectionStats(textEditor
);
120 <body onload=
"runTest();">
122 This test verifies Ctrl-D functionality, which selects next occurrence of word.
125 <pre id=
"codeSnippet">
126 function wordData() {
128 original: $(
".entry.original > .input").text(),
129 translation: $(
".entry.translation > .input").text(),
130 tags: $(
".active-tags > .tagcloud > .tag").toArray().map(function(value) { return value.textContent; })
134 function submitWord(url) {
135 var stub = new App.Stub($(
".content"));
136 $.post(url, wordData())
138 var callback = $(
"meta[data-callback]").attr(
"data-callback");
140 window.location = callback;
143 $(
".entry.original > .input").text(
"").focus();
144 $(
".entry.translation > .input").text(
"");
147 .fail(function(obj, err, errDescr) {
148 stub.failure(
"Error: " + errDescr);