Commit cfb3aab4 authored by Thibaut Frain's avatar Thibaut Frain

Added svgedit tests

parent 2f9b088a
......@@ -56,9 +56,10 @@
<link rel="alternate" type="application/atom+xml" title="SVG-edit General Discussion" href="http://groups.google.com/group/svg-edit/feed/atom_v1_0_msgs.xml" />
<link rel="alternate" type="application/atom+xml" title="SVG-edit Updates (Issues/Fixes/Commits)" href="http://code.google.com/feeds/p/svg-edit/updates/basic" />
<script type="text/javascript" src="../lib/rsvp.js"></script>
<script type="text/javascript" src="../lib/jschannel.js"></script>
<script type="text/javascript" src="../lib/renderjs.js"></script>
<script type="text/javascript" src="../js/gadget_svg_edit.js"></script>
<script type="text/javascript" src="../js/gadget_svgedit.js"></script>
<!-- Add script with custom handlers here -->
<title>SVG-edit</title>
......
......@@ -17,9 +17,22 @@
<script src="bw-gadget-test.js"></script>
<script src="jqs-gadget-test.js"></script>
<script src="codemirror-gadget-test.js""></script>
<script src="svgedit-gadget-test.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div id="svgedit-fixtures">
<div id="fixture-1" style="display: none;">
<svg width="640" height="480" xmlns="http://www.w3.org/2000/svg">
<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
<g>
<title>Layer 1</title>
<rect fill="#FF0000" stroke="#000000" stroke-width="5" x="109" y="174" width="287" height="54" id="svg_1"/>
<rect fill="#FF0000" stroke="#000000" stroke-width="5" x="393" y="121" width="99" height="222" id="svg_2"/>
</g>
</svg>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, height=device-height"/>
<title>Test svgedit gadget</title>
<link rel="stylesheet" href="../src/lib/qunit/qunit.css">
<script src="../src/lib/jquery.js"></script>
<script src="../src/lib/qunit/qunit.js"></script>
<script src="../src/lib/sinon/sinon.js"></script>
<script src="../src/lib/rsvp.js"></script>
<script src="../src/lib/jschannel.js"></script>
<script src="../src/lib/renderjs.js"></script>
<script src="svgedit-gadget-test.js"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<div id="svgedit-fixtures">
<div id="fixture-1" style="display: none;">
<svg width="640" height="480" xmlns="http://www.w3.org/2000/svg">
<!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
<g>
<title>Layer 1</title>
<rect fill="#FF0000" stroke="#000000" stroke-width="5" x="109" y="174" width="287" height="54" id="svg_1"/>
<rect fill="#FF0000" stroke="#000000" stroke-width="5" x="393" y="121" width="99" height="222" id="svg_2"/>
</g>
</svg>
</div>
</div>
</body>
</html>
/*global window, document, QUnit, jQuery, rJS, sinon, XMLSerializer */
/*jslint indent: 2, maxerr: 3, maxlen: 79 */
"use strict";
QUnit.config.testTimeout = 1000;
(function (window, $, QUnit, rJS) {
//var test = QUnit.test,
var asyncTest = QUnit.asyncTest,
//stop = QUnit.stop,
start = QUnit.start,
ok = QUnit.ok,
//expect = QUnit.expect,
//throws = QUnit.throws,
//deepEqual = QUnit.deepEqual;
svgeditGadgetURL = '../src/gadget/svgedit.html';
function iframeSelector(selectorString) {
return $('iframe').contents().find(selectorString);
}
rJS(window).ready(function (g) {
var gadget_context = document.getElementById('qunit-fixture');
asyncTest("[svgedit gadget] loading (iframed)", 1, function () {
g.declareGadget(svgeditGadgetURL,
{sandbox: "iframe", element: gadget_context})
.then(function () {
ok(iframeSelector("svg")[0]);
})
.always(start);
});
asyncTest("[svgedit gadget] initial textarea (iframed)", 1, function () {
g.declareGadget(svgeditGadgetURL,
{sandbox: "iframe", element: gadget_context})
.then(function (gadget) {
return gadget.getContent();
})
.then(function (content) {
ok(content.indexOf('Layer 1') !== -1);
})
.always(start);
});
asyncTest("[svgedit gadget] clear content (iframed)", 2, function () {
var gadget;
g.declareGadget(svgeditGadgetURL,
{sandbox: "iframe", element: gadget_context})
.then(function (g) {
gadget = g;
gadget.setContent($("#svgedit-fixtures #fixture-1").html())
.then(gadget.getContent)
.then(function (content) {
ok(content.indexOf('rect') !== -1);
})
.then(gadget.clearContent)
.then(gadget.getContent)
.then(function (content) {
ok(content.indexOf('rect') === -1);
})
.always(start);
});
});
asyncTest("[svgedit gadget] set/get content (iframed)", 1, function () {
var gadget;
g.declareGadget(svgeditGadgetURL,
{sandbox: "iframe", element: gadget_context})
.then(function (g) {
gadget = g;
g.setContent($("#svgedit-fixtures #fixture-1").html())
.then(gadget.getContent)
.then(function (content) {
ok(content.indexOf('rect') !== -1);
})
.always(start);
});
});
});
} (window, jQuery, QUnit, rJS));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment