OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../http/tests/inspector/inspector-test.js"></script> | 3 <script src="../../http/tests/inspector/inspector-test.js"></script> |
4 <script src="highlighter-test.js"></script> | 4 <script src="editor-test.js"></script> |
5 <script> | 5 <script> |
6 | 6 |
7 function test() | 7 function test() |
8 { | 8 { |
9 var textModel = new WebInspector.TextEditorModel(); | 9 var textEditor = InspectorTest.createTestEditor(); |
10 textModel.setText("1\n2\n3\n4"); | 10 textEditor.setText("1\n2\n3\n4"); |
11 | 11 |
12 InspectorTest.runTestSuite([ | 12 InspectorTest.runTestSuite([ |
13 function testMarkiningInitialStateAsClean(next) | 13 function testMarkiningInitialStateAsClean(next) |
14 { | 14 { |
15 InspectorTest.addResult("Initial state: clean=" + textModel.isClean(
)); | 15 InspectorTest.addResult("Initial state: clean=" + textEditor.isClean
()); |
16 textModel.markClean(); | 16 textEditor.markClean(); |
17 InspectorTest.addResult("After marking clean: clean=" + textModel.is
Clean()); | 17 InspectorTest.addResult("After marking clean: clean=" + textEditor.i
sClean()); |
18 textModel.editRange(WebInspector.TextRange.createFromLocation(0, 0),
"newText"); | 18 textEditor.editRange(WebInspector.TextRange.createFromLocation(0, 0)
, "newText"); |
19 InspectorTest.addResult("EDIT; clean=" + textModel.isClean()); | 19 InspectorTest.addResult("EDIT; clean=" + textEditor.isClean()); |
20 textModel.undo(); | 20 textEditor.undo(); |
21 InspectorTest.addResult("UNDO; clean=" + textModel.isClean()); | 21 InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
22 textModel.redo(); | 22 textEditor.redo(); |
23 InspectorTest.addResult("REDO; clean=" + textModel.isClean()); | 23 InspectorTest.addResult("REDO; clean=" + textEditor.isClean()); |
24 textModel.undo(); | 24 textEditor.undo(); |
25 InspectorTest.addResult("UNDO; clean=" + textModel.isClean()); | 25 InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
26 textModel.editRange(WebInspector.TextRange.createFromLocation(1, 0),
"newText2"); | 26 textEditor.editRange(WebInspector.TextRange.createFromLocation(1, 0)
, "newText2"); |
27 InspectorTest.addResult("EDIT; clean=" + textModel.isClean()); | 27 InspectorTest.addResult("EDIT; clean=" + textEditor.isClean()); |
28 textModel.undo(); | 28 textEditor.undo(); |
29 InspectorTest.addResult("UNDO; clean=" + textModel.isClean()); | 29 InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
30 next(); | 30 next(); |
31 }, | 31 }, |
32 | 32 |
33 function testMiddleStateAsClean(next) | 33 function testMiddleStateAsClean(next) |
34 { | 34 { |
35 InspectorTest.addResult("Initial state: clean=" + textModel.isClean(
)); | 35 InspectorTest.addResult("Initial state: clean=" + textEditor.isClean
()); |
36 for(var i = 0; i < 3; ++i) { | 36 for(var i = 0; i < 3; ++i) { |
37 textModel.editRange(WebInspector.TextRange.createFromLocation(i,
0), "newText" + i); | 37 textEditor.editRange(WebInspector.TextRange.createFromLocation(i
, 0), "newText" + i); |
38 InspectorTest.addResult("EDIT; clean=" + textModel.isClean()); | 38 InspectorTest.addResult("EDIT; clean=" + textEditor.isClean()); |
39 } | 39 } |
40 textModel.markClean(); | 40 textEditor.markClean(); |
41 InspectorTest.addResult("After marking clean: clean=" + textModel.is
Clean()); | 41 InspectorTest.addResult("After marking clean: clean=" + textEditor.i
sClean()); |
42 textModel.editRange(WebInspector.TextRange.createFromLocation(3, 0),
"newText" + 3); | 42 textEditor.editRange(WebInspector.TextRange.createFromLocation(3, 0)
, "newText" + 3); |
43 InspectorTest.addResult("EDIT; clean=" + textModel.isClean()); | 43 InspectorTest.addResult("EDIT; clean=" + textEditor.isClean()); |
44 for(var i = 0; i < 4; ++i) { | 44 for(var i = 0; i < 4; ++i) { |
45 textModel.undo(); | 45 textEditor.undo(); |
46 InspectorTest.addResult("UNDO; clean=" + textModel.isClean()); | 46 InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
47 } | 47 } |
48 for(var i = 0; i < 4; ++i) { | 48 for(var i = 0; i < 4; ++i) { |
49 textModel.redo(); | 49 textEditor.redo(); |
50 InspectorTest.addResult("REDO; clean=" + textModel.isClean()); | 50 InspectorTest.addResult("REDO; clean=" + textEditor.isClean()); |
51 } | 51 } |
52 for(var i = 0; i < 2; ++i) { | 52 for(var i = 0; i < 2; ++i) { |
53 textModel.undo(); | 53 textEditor.undo(); |
54 InspectorTest.addResult("UNDO; clean=" + textModel.isClean()); | 54 InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
55 } | 55 } |
56 textModel.editRange(WebInspector.TextRange.createFromLocation(1, 0),
"foo"); | 56 textEditor.editRange(WebInspector.TextRange.createFromLocation(1, 0)
, "foo"); |
57 InspectorTest.addResult("EDIT; clean=" + textModel.isClean()); | 57 InspectorTest.addResult("EDIT; clean=" + textEditor.isClean()); |
58 textModel.undo(); | 58 textEditor.undo(); |
59 InspectorTest.addResult("UNDO; clean=" + textModel.isClean()); | 59 InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
60 textModel.undo(); | 60 textEditor.undo(); |
61 InspectorTest.addResult("UNDO; clean=" + textModel.isClean()); | 61 InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
62 next(); | 62 next(); |
63 }, | 63 }, |
64 ]); | 64 ]); |
65 } | 65 } |
66 | 66 |
67 </script> | 67 </script> |
68 </head> | 68 </head> |
69 | 69 |
70 <body onload="runTest()"> | 70 <body onload="runTest()"> |
71 <p> | 71 <p> |
72 This test checks TextEditorModel.markClean/isClean methods | 72 This test checks TextEditorModel.markClean/isClean methods |
73 </p> | 73 </p> |
74 | 74 |
75 </body> | 75 </body> |
76 </html> | 76 </html> |
OLD | NEW |