| | |
| | | <link rel='stylesheet' href='qunit/qunit.css' type='text/css'/> |
| | | <script src='../editor/lib/jquery.js'></script> |
| | | <script type='text/javascript' src='../editor/src/history.js'></script> |
| | | <script type='text/javascript' src='qunit/qunit.js'></script> |
| | | <script type='text/javascript' src='qunit/qunit.js'></script> |
| | | <script type='text/javascript'> |
| | | $(function() { |
| | | // TODO(codedread): Write tests for handling history events. |
| | |
| | | |
| | | test('Test svgedit.history package', function() { |
| | | expect(13); |
| | | |
| | | |
| | | ok(svgedit.history); |
| | | ok(svgedit.history.MoveElementCommand); |
| | | ok(svgedit.history.InsertElementCommand); |
| | |
| | | equals(typeof svgedit.history.BatchCommand, typeof function(){}); |
| | | equals(typeof svgedit.history.UndoManager, typeof function(){}); |
| | | }); |
| | | |
| | | |
| | | test('Test UndoManager methods', function() { |
| | | expect(14); |
| | | setUp(); |
| | | |
| | | |
| | | ok(undoMgr); |
| | | ok(undoMgr.addCommandToHistory); |
| | | ok(undoMgr.getUndoStackSize); |
| | |
| | | equals(typeof undoMgr.resetUndoStack, typeof function(){}); |
| | | equals(typeof undoMgr.getNextUndoCommandText, typeof function(){}); |
| | | equals(typeof undoMgr.getNextRedoCommandText, typeof function(){}); |
| | | |
| | | |
| | | tearDown(); |
| | | }); |
| | | |
| | | |
| | | test('Test UndoManager.addCommandToHistory() function', function() { |
| | | expect(3); |
| | | |
| | | |
| | | setUp(); |
| | | |
| | | equals(undoMgr.getUndoStackSize(), 0); |
| | |
| | | |
| | | tearDown(); |
| | | }); |
| | | |
| | | |
| | | test('Test UndoManager.getUndoStackSize() and getRedoStackSize() functions', function() { |
| | | expect(18); |
| | | |
| | | |
| | | setUp(); |
| | | |
| | | undoMgr.addCommandToHistory(new MockCommand()); |
| | |
| | | |
| | | equals(undoMgr.getUndoStackSize(), 3); |
| | | equals(undoMgr.getRedoStackSize(), 0); |
| | | |
| | | |
| | | undoMgr.undo(); |
| | | equals(undoMgr.getUndoStackSize(), 2); |
| | | equals(undoMgr.getRedoStackSize(), 1); |
| | |
| | | undoMgr.redo(); |
| | | equals(undoMgr.getUndoStackSize(), 3); |
| | | equals(undoMgr.getRedoStackSize(), 0); |
| | | |
| | | |
| | | tearDown(); |
| | | }); |
| | | |
| | | |
| | | test('Test UndoManager.resetUndoStackSize() function', function() { |
| | | expect(4); |
| | | |
| | | |
| | | setUp(); |
| | | |
| | | undoMgr.addCommandToHistory(new MockCommand()); |
| | | undoMgr.addCommandToHistory(new MockCommand()); |
| | | undoMgr.addCommandToHistory(new MockCommand()); |
| | | undoMgr.undo(); |
| | | |
| | | |
| | | equals(undoMgr.getUndoStackSize(), 2); |
| | | equals(undoMgr.getRedoStackSize(), 1); |
| | | |
| | | |
| | | undoMgr.resetUndoStack(); |
| | | |
| | | equals(undoMgr.getUndoStackSize(), 0); |
| | | equals(undoMgr.getRedoStackSize(), 0); |
| | | |
| | | |
| | | tearDown(); |
| | | }); |
| | | |
| | |
| | | undoMgr.undo(); |
| | | undoMgr.undo(); |
| | | equals(lastCalled, 'cmd2.unapply'); |
| | | |
| | | |
| | | undoMgr.undo(); |
| | | equals(lastCalled, 'cmd1.unapply'); |
| | | lastCalled = null; |
| | |
| | | |
| | | undoMgr.redo(); |
| | | equals(lastCalled, 'cmd1.apply'); |
| | | |
| | | |
| | | undoMgr.redo(); |
| | | equals(lastCalled, 'cmd2.apply'); |
| | | |
| | |
| | | var line = document.createElementNS(svgns,'line'); |
| | | line.setAttributeNS(null, 'class', 'newClass'); |
| | | change = new svgedit.history.ChangeElementCommand(line,{class:'oldClass'}); |
| | | |
| | | |
| | | ok(change.unapply); |
| | | ok(change.apply); |
| | | equals(typeof change.unapply, typeof function(){}); |
| | |
| | | |
| | | change.apply(); |
| | | equals(line.getAttributeNS(null, 'class'), 'newClass'); |
| | | |
| | | |
| | | tearDown(); |
| | | }); |
| | | |
| | |
| | | |
| | | }); |
| | | </script> |
| | | </head> |
| | | <body> |
| | | </head> |
| | | <body> |
| | | <h1 id='qunit-header'>Unit Tests for history.js</h1> |
| | | <h2 id='qunit-banner'></h2> |
| | | <h2 id='qunit-userAgent'></h2> |
| | |
| | | <div id='div5'></div> |
| | | </div> |
| | | |
| | | </body> |
| | | </body> |
| | | </html> |