blob: 50096bfb634a751c8f7e80a6da17697f7420b920 [file] [log] [blame]
g.czajkowski@samsung.com43b58582014-05-07 14:54:56 +00001<html>
2<head>
3<script src="../editing.js"></script>
4<title>Editing multiple words with markers test</title>
5</head>
6<body>
7<textarea id="testElement"></textarea>
8<script src="../../resources/js-test-pre.js"></script>
9<script>
10description('The test verifies if the spelling markers disappear when '
11 + 'the multiple misspelled words are concatenated by delete command. '
12 + 'To test manually, type "it\'s a meagesga meagesga", then '
13 + 'select and delete "esga meag". The test succeeds '
14 + 'if the remaining text does not have any underline.');
15
16jsTestIsAsync = true;
17
18if (window.internals) {
19 internals.settings.setUnifiedTextCheckerEnabled(true);
20 internals.settings.setAsynchronousSpellCheckingEnabled(true);
21}
22
23function resetText() {
24 var textArea = document.getElementById('testElement');
25 textArea.value = "";
26 textArea.focus();
27 typeCharacterCommand('i');
28 typeCharacterCommand('t');
29 typeCharacterCommand('\'');
30 typeCharacterCommand('s');
31 typeCharacterCommand(' ');
32 typeCharacterCommand('a');
33 typeCharacterCommand(' ');
34 typeCharacterCommand('m');
35 typeCharacterCommand('e');
36 typeCharacterCommand('a');
37 typeCharacterCommand('g');
38 typeCharacterCommand('e');
39 typeCharacterCommand('s');
40 typeCharacterCommand('g');
41 typeCharacterCommand('a');
42 typeCharacterCommand(' ');
43 typeCharacterCommand('m');
44 typeCharacterCommand('e');
45 typeCharacterCommand('a');
46 typeCharacterCommand('g');
47 typeCharacterCommand('e');
48 typeCharacterCommand('s');
49 typeCharacterCommand('g');
50 typeCharacterCommand('a');
51 typeCharacterCommand(' ');
52}
53
54var testCases = [
55 { selectionRange: null, spellingMarkerPositions: [ 0, 7 ], spellingMarkerLengths: [ 4, 8 ], shouldBeMarked: [ false, true ] },
56 { selectionRange: [ 11, 20 ], spellingMarkerPositions: [ 7, 11 ], spellingMarkerLengths: [ 4, 4 ], shouldBeMarked: [ false, false] },
57 { selectionRange: [ 11, 16 ], spellingMarkerPositions: [ 7, 11 ], spellingMarkerLengths: [ 4, 8 ], shouldBeMarked: [ false, false] },
58 { selectionRange: [ 15, 20 ], spellingMarkerPositions: [ 7, 15 ], spellingMarkerLengths: [ 8, 4 ], shouldBeMarked: [ false, false] }
59];
60
61var spellingPositions;
62var spellingLengths;
63var markersExpectation;
64
65function checkSpellingMarkerAfterDeleteingSelection(selectionRange, spellingMarkerPositions, spellingMarkerLengths, shouldBeMarked)
66{
67 resetText();
68 if (selectionRange) {
69 document.getElementById('testElement').setSelectionRange(selectionRange[0], selectionRange[1]);
70 execDeleteCommand();
71 }
72
73 spellingPositions = spellingMarkerPositions;
74 spellingLengths = spellingMarkerLengths;
75 markersExpectation = shouldBeMarked;
76
77 if (window.internals) {
78 shouldBecomeEqual('internals.hasSpellingMarker(spellingPositions[0], spellingLengths[0])',
79 markersExpectation[0] ? 'true' : 'false', function() {
80 shouldBecomeEqual('internals.hasSpellingMarker(spellingPositions[1], spellingLengths[1])',
81 markersExpectation[1] ? 'true' : 'false', function() {
82 debug("");
83 done();
84 });
85 });
86 }
87}
88
89function done()
90{
91 var nextTestCase = testCases.shift();
92 if (nextTestCase)
93 return setTimeout(checkSpellingMarkerAfterDeleteingSelection(
94 nextTestCase.selectionRange,
95 nextTestCase.spellingMarkerPositions,
96 nextTestCase.spellingMarkerLengths,
97 nextTestCase.shouldBeMarked,
98 0));
99
100 finishJSTest();
101}
102done();
103</script>
104<script src="../../resources/js-test-post.js"></script>
105</body>
106</html>