Move undo/redo functionality into history.js. Started unit test file.

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1864 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Jeff Schiller
2010-11-12 19:08:29 +00:00
parent 86c750848b
commit 4a133d490d
10 changed files with 651 additions and 493 deletions

View File

@@ -7,8 +7,9 @@
<h1>All SVG-edit Tests</h1>
<p>This file frames all SVG-edit test pages. This should only include tests known to work. These tests are known to pass 100% in the following: Firefox 3.6, Chrome 7, IE9 Preview 6 (1.9.8006.6000), Opera 10.63. If a test is broken in this page, it is possible that <em>YOU</em> broke it. Please do not submit code that breaks any of these tests.</p>
<iframe src='svgtransformlist_test.html' width='100%' height='300'></iframe>
<iframe src='svgutils_test.html' width='100%' height='300'></iframe>
<iframe src='math_test.html' width='100%' height='300'></iframe>
<iframe src='svgutils_test.html' width='100%' height='300'></iframe>
<iframe src='history_test.html' width='100%' height='300'></iframe>
</body>
<script>
window.setTimeout(function() {

51
test/history_test.html Normal file
View File

@@ -0,0 +1,51 @@
<!DOCTYPE html>
<html>
<head>
<link rel='stylesheet' href='qunit/qunit.css' type='text/css'/>
<script src='../editor/jquery.js'></script>
<script type='text/javascript' src='../editor/svgtransformlist.js'></script>
<script type='text/javascript' src='../editor/history.js'></script>
<script type='text/javascript' src='../editor/svgutils.js'></script>
<script type='text/javascript' src='qunit/qunit.js'></script>
<script type='text/javascript'>
$(function() {
// log function
QUnit.log = function(result, message) {
if (window.console && window.console.log) {
window.console.log(result +' :: '+ message);
}
};
var svgns = 'http://www.w3.org/2000/svg';
var svg = document.createElementNS(svgns, 'svg');
module('svgedit.history Module');
test('Test svgedit.history package', function() {
expect(13);
ok(svgedit.history);
ok(svgedit.history.MoveElementCommand);
ok(svgedit.history.InsertElementCommand);
ok(svgedit.history.ChangeElementCommand);
ok(svgedit.history.RemoveElementCommand);
ok(svgedit.history.BatchCommand);
ok(svgedit.history.UndoManager);
equals(typeof svgedit.history.MoveElementCommand, typeof function(){});
equals(typeof svgedit.history.InsertElementCommand, typeof function(){});
equals(typeof svgedit.history.ChangeElementCommand, typeof function(){});
equals(typeof svgedit.history.RemoveElementCommand, typeof function(){});
equals(typeof svgedit.history.BatchCommand, typeof function(){});
equals(typeof svgedit.history.UndoManager, typeof function(){});
});
});
</script>
</head>
<body>
<h1 id='qunit-header'>Unit Tests for history.js</h1>
<h2 id='qunit-banner'></h2>
<h2 id='qunit-userAgent'></h2>
<ol id='qunit-tests'>
</ol>
</body>
</html>

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<link rel='stylesheet' href='qunit/qunit.css' type='text/css'/>
<html>
<head>
<link rel='stylesheet' href='qunit/qunit.css' type='text/css'/>
<script src='../editor/jquery.js'></script>
<!-- svgutils.js depends on these two... mock out? -->
<script type='text/javascript' src='../editor/browsersupport.js'></script>
@@ -80,7 +80,6 @@
var convert = svgedit.utilities.convertToXMLReferences;
equals(convert('ABC'), 'ABC');
// equals(convert('ÀBC'), '&#192;BC');
// alert(convert('ÿBC', true));
});
test('Test svgedit.utilities.bboxToObj() function', function() {
@@ -101,6 +100,16 @@
equals(obj.height, 4);
});
test("Test getUrlFromAttr", function() {
expect(4);
equal(svgedit.utilities.getUrlFromAttr("url(#foo)"), "#foo");
equal(svgedit.utilities.getUrlFromAttr("url(somefile.svg#foo)"), "somefile.svg#foo");
equal(svgedit.utilities.getUrlFromAttr("url('#foo')"), "#foo");
equal(svgedit.utilities.getUrlFromAttr('url("#foo")'), "#foo");
});
});
</script>
</head>

View File

@@ -11,6 +11,7 @@
<script type="text/javascript" src="../editor/units.js"></script>
<script type="text/javascript" src="../editor/svgutils.js"></script>
<script type="text/javascript" src="../editor/sanitize.js"></script>
<script type="text/javascript" src="../editor/history.js"></script>
<script type="text/javascript" src="../editor/svgcanvas.js"></script>
<script type="text/javascript" src="qunit/qunit.js"></script>
<script type="text/javascript">
@@ -128,15 +129,6 @@
equal(nfu, null, "Removed <use> element that had no href");
});
test("Test getUrlFromAttr", function() {
expect(4);
equal(svgCanvas.getUrlFromAttr("url(#foo)"), "#foo");
equal(svgCanvas.getUrlFromAttr("url(somefile.svg#foo)"), "somefile.svg#foo");
equal(svgCanvas.getUrlFromAttr("url('#foo')"), "#foo");
equal(svgCanvas.getUrlFromAttr('url("#foo")'), "#foo");
});
// This test shows that an element with an invalid attribute is still parsed in properly
// and only the attribute is not imported
test("Test invalid attribute", function() {