OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../sources/debugger/resources/edit-me.js"></script> | 3 <script src="../sources/debugger/resources/edit-me.js"></script> |
4 <script src="../editor/editor-test.js"></script> | 4 <script src="../editor/editor-test.js"></script> |
5 <script src="../../http/tests/inspector/inspector-test.js"></script> | 5 <script src="../../http/tests/inspector/inspector-test.js"></script> |
6 <script src="../../http/tests/inspector/debugger-test.js"></script> | 6 <script src="../../http/tests/inspector/debugger-test.js"></script> |
7 <script> | 7 <script> |
8 function test() | 8 function test() |
9 { | 9 { |
10 InspectorTest.showScriptSource("edit-me.js", onSourceFrame); | 10 InspectorTest.showScriptSource("edit-me.js", onSourceFrame); |
11 | 11 |
12 var textEditor; | 12 var textEditor; |
13 function onSourceFrame(sourceFrame) | 13 function onSourceFrame(sourceFrame) |
14 { | 14 { |
15 textEditor = sourceFrame.textEditor; | 15 textEditor = sourceFrame.textEditor; |
16 textEditor.element.focus(); | 16 textEditor.element.focus(); |
17 InspectorTest.runTestSuite(testSuite); | 17 InspectorTest.runTestSuite(testSuite); |
18 } | 18 } |
19 | 19 |
20 var testSuite = [ | 20 var testSuite = [ |
21 // This test has to be the first. It validates that autocompletion contr
oller | 21 // This test has to be the first. It validates that autocompletion contr
oller |
22 // will initialize as a key will be pressed. | 22 // will initialize as a key will be pressed. |
23 function testCompletionsShowUpOnKeyPress(next) | 23 function testCompletionsShowUpOnKeyPress(next) |
24 { | 24 { |
25 textEditor.setText("name1 name2 name3 name4\nna"); | 25 textEditor.setText("name1 name2 name3 name4\nna"); |
26 textEditor.setSelection(Common.TextRange.createFromLocation(1, 2)); | 26 textEditor.setSelection(TextUtils.TextRange.createFromLocation(1, 2)
); |
27 InspectorTest.addSniffer(TextEditor.TextEditorAutocompleteController
.prototype, "_onSuggestionsShownForTest", onAutocompletionSuggestBox); | 27 InspectorTest.addSniffer(TextEditor.TextEditorAutocompleteController
.prototype, "_onSuggestionsShownForTest", onAutocompletionSuggestBox); |
28 InspectorTest.typeIn(textEditor, "m"); | 28 InspectorTest.typeIn(textEditor, "m"); |
29 function onAutocompletionSuggestBox() | 29 function onAutocompletionSuggestBox() |
30 { | 30 { |
31 document.activeElement.dispatchEvent(InspectorTest.createKeyEven
t("Enter")); | 31 document.activeElement.dispatchEvent(InspectorTest.createKeyEven
t("Enter")); |
32 dumpDictionary(next); | 32 dumpDictionary(next); |
33 } | 33 } |
34 }, | 34 }, |
35 | 35 |
36 function testSetInitialText(next) | 36 function testSetInitialText(next) |
37 { | 37 { |
38 textEditor.setText("one two three3_\nfour five\na_b\nsix\n123foo\n13
2\nseven"); | 38 textEditor.setText("one two three3_\nfour five\na_b\nsix\n123foo\n13
2\nseven"); |
39 dumpDictionary(next); | 39 dumpDictionary(next); |
40 }, | 40 }, |
41 | 41 |
42 function testAlphaNumericWords(next) | 42 function testAlphaNumericWords(next) |
43 { | 43 { |
44 textEditor.setText("2 2foo foo2 2foo4 foo3bar"); | 44 textEditor.setText("2 2foo foo2 2foo4 foo3bar"); |
45 dumpDictionary(next); | 45 dumpDictionary(next); |
46 }, | 46 }, |
47 | 47 |
48 function testRemoveDuplicate(next) | 48 function testRemoveDuplicate(next) |
49 { | 49 { |
50 textEditor.setText("one\none"); | 50 textEditor.setText("one\none"); |
51 textEditor.setSelection(new Common.TextRange(0, 0, 0, 3)); | 51 textEditor.setSelection(new TextUtils.TextRange(0, 0, 0, 3)); |
52 InspectorTest.typeIn(textEditor, "\b", dumpDictionary.bind(null, nex
t)); | 52 InspectorTest.typeIn(textEditor, "\b", dumpDictionary.bind(null, nex
t)); |
53 }, | 53 }, |
54 | 54 |
55 function testSetText(next) | 55 function testSetText(next) |
56 { | 56 { |
57 textEditor.setText("dog cat 'mouse';dog bird"); | 57 textEditor.setText("dog cat 'mouse';dog bird"); |
58 dumpDictionary(next); | 58 dumpDictionary(next); |
59 }, | 59 }, |
60 | 60 |
61 function testSimpleEdit(next) | 61 function testSimpleEdit(next) |
62 { | 62 { |
63 textEditor.setSelection(Common.TextRange.createFromLocation(0, 3)); | 63 textEditor.setSelection(TextUtils.TextRange.createFromLocation(0, 3)
); |
64 InspectorTest.typeIn(textEditor, "\b", dumpDictionary.bind(null, nex
t)); | 64 InspectorTest.typeIn(textEditor, "\b", dumpDictionary.bind(null, nex
t)); |
65 }, | 65 }, |
66 | 66 |
67 function testDeleteOneDogAndOneCat(next) | 67 function testDeleteOneDogAndOneCat(next) |
68 { | 68 { |
69 textEditor.setSelection(Common.TextRange.createFromLocation(0, 6)); | 69 textEditor.setSelection(TextUtils.TextRange.createFromLocation(0, 6)
); |
70 InspectorTest.typeIn(textEditor, "\b\b\b\b\b\b", dumpDictionary.bind
(null, next)); | 70 InspectorTest.typeIn(textEditor, "\b\b\b\b\b\b", dumpDictionary.bind
(null, next)); |
71 } | 71 } |
72 ]; | 72 ]; |
73 | 73 |
74 function dumpDictionary(next) { | 74 function dumpDictionary(next) { |
75 var wordsInDictionary = textEditor._autocompleteController._dictionary.w
ordsWithPrefix(""); | 75 var wordsInDictionary = textEditor._autocompleteController._dictionary.w
ordsWithPrefix(""); |
76 InspectorTest.addResult("========= Text in editor ========="); | 76 InspectorTest.addResult("========= Text in editor ========="); |
77 InspectorTest.dumpTextWithSelection(textEditor); | 77 InspectorTest.dumpTextWithSelection(textEditor); |
78 InspectorTest.addResult("======= Words in dictionary ======="); | 78 InspectorTest.addResult("======= Words in dictionary ======="); |
79 InspectorTest.addResult("[" + wordsInDictionary.sort().join(", ") + "]")
; | 79 InspectorTest.addResult("[" + wordsInDictionary.sort().join(", ") + "]")
; |
80 InspectorTest.addResult("============="); | 80 InspectorTest.addResult("============="); |
81 next(); | 81 next(); |
82 } | 82 } |
83 } | 83 } |
84 | 84 |
85 </script> | 85 </script> |
86 </head> | 86 </head> |
87 | 87 |
88 <body onload="runTest();"> | 88 <body onload="runTest();"> |
89 <p> | 89 <p> |
90 This test checks how text editor updates autocompletion dictionary in a response | 90 This test checks how text editor updates autocompletion dictionary in a response |
91 to user input. | 91 to user input. |
92 </p> | 92 </p> |
93 </body> | 93 </body> |
94 </html> | 94 </html> |
OLD | NEW |