Commit b664151b authored by Thibaut Frain's avatar Thibaut Frain

Added svg_edit tests

parent dbfcc252
<!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="../<%= copy.qunitcss.relative_dest %>">
<script src="../<%= curl.jquery.relative_dest %>"></script>
<script src="../<%= copy.qunitjs.relative_dest %>"></script>
<script src="../<%= copy.rsvp.relative_dest %>"></script>
<script src="../<%= copy.renderjs.relative_dest %>"></script>
<script src="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 */
(function (window, $, QUnit, rJS) {
"use strict";
QUnit.config.testTimeout = 1000;
var asyncTest = QUnit.asyncTest,
start = QUnit.start,
ok = QUnit.ok,
svgeditGadgetURL = 'index.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