| <html> |
| <head> |
| <script src="../../http/tests/inspector/inspector-test.js"></script> |
| <script src="editor-test.js"></script> |
| <script> |
| |
| function test() |
| { |
| var textEditor = InspectorTest.createTestEditor(); |
| textEditor.setText("1\n2\n3\n4"); |
| |
| InspectorTest.runTestSuite([ |
| function testMarkiningInitialStateAsClean(next) |
| { |
| InspectorTest.addResult("Initial state: clean=" + textEditor.isClean()); |
| textEditor.markClean(); |
| InspectorTest.addResult("After marking clean: clean=" + textEditor.isClean()); |
| textEditor.editRange(WebInspector.TextRange.createFromLocation(0, 0), "newText"); |
| InspectorTest.addResult("EDIT; clean=" + textEditor.isClean()); |
| textEditor.undo(); |
| InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
| textEditor.redo(); |
| InspectorTest.addResult("REDO; clean=" + textEditor.isClean()); |
| textEditor.undo(); |
| InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
| textEditor.editRange(WebInspector.TextRange.createFromLocation(1, 0), "newText2"); |
| InspectorTest.addResult("EDIT; clean=" + textEditor.isClean()); |
| textEditor.undo(); |
| InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
| next(); |
| }, |
| |
| function testMiddleStateAsClean(next) |
| { |
| InspectorTest.addResult("Initial state: clean=" + textEditor.isClean()); |
| for(var i = 0; i < 3; ++i) { |
| textEditor.editRange(WebInspector.TextRange.createFromLocation(i, 0), "newText" + i); |
| InspectorTest.addResult("EDIT; clean=" + textEditor.isClean()); |
| } |
| textEditor.markClean(); |
| InspectorTest.addResult("After marking clean: clean=" + textEditor.isClean()); |
| textEditor.editRange(WebInspector.TextRange.createFromLocation(3, 0), "newText" + 3); |
| InspectorTest.addResult("EDIT; clean=" + textEditor.isClean()); |
| for(var i = 0; i < 4; ++i) { |
| textEditor.undo(); |
| InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
| } |
| for(var i = 0; i < 4; ++i) { |
| textEditor.redo(); |
| InspectorTest.addResult("REDO; clean=" + textEditor.isClean()); |
| } |
| for(var i = 0; i < 2; ++i) { |
| textEditor.undo(); |
| InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
| } |
| textEditor.editRange(WebInspector.TextRange.createFromLocation(1, 0), "foo"); |
| InspectorTest.addResult("EDIT; clean=" + textEditor.isClean()); |
| textEditor.undo(); |
| InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
| textEditor.undo(); |
| InspectorTest.addResult("UNDO; clean=" + textEditor.isClean()); |
| next(); |
| }, |
| ]); |
| } |
| |
| </script> |
| </head> |
| |
| <body onload="runTest()"> |
| <p> |
| This test checks TextEditorModel.markClean/isClean methods |
| </p> |
| |
| </body> |
| </html> |