2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
bootstrapModeler,
|
|
|
|
bootstrapViewer,
|
|
|
|
inject
|
|
|
|
} from 'test/TestHelper';
|
2014-04-25 11:31:18 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
create as svgCreate
|
|
|
|
} from 'tiny-svg';
|
2017-12-16 23:06:01 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import coreModule from 'lib/core';
|
|
|
|
import rendererModule from 'lib/draw';
|
|
|
|
import modelingModule from 'lib/features/modeling';
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
import {
|
|
|
|
query as domQuery
|
|
|
|
} from 'min-dom';
|
2014-04-25 11:31:18 +00:00
|
|
|
|
2018-05-23 12:27:32 +00:00
|
|
|
import { isAny } from 'lib/features/modeling/util/ModelingUtil';
|
|
|
|
|
|
|
|
import {
|
|
|
|
getDi
|
|
|
|
} from 'lib/draw/BpmnRenderUtil';
|
|
|
|
|
2016-11-08 13:24:26 +00:00
|
|
|
function checkErrors(done) {
|
|
|
|
return function(err, warnings) {
|
|
|
|
expect(warnings).to.be.empty;
|
|
|
|
expect(err).not.to.exist;
|
|
|
|
done();
|
|
|
|
};
|
|
|
|
}
|
2014-04-25 11:31:18 +00:00
|
|
|
|
2018-04-02 19:01:53 +00:00
|
|
|
|
2014-06-18 09:45:30 +00:00
|
|
|
describe('draw - bpmn renderer', function() {
|
2014-04-25 11:31:18 +00:00
|
|
|
|
2018-09-20 20:18:10 +00:00
|
|
|
it('should render labels', function(done) {
|
|
|
|
var xml = require('./BpmnRenderer.labels.bpmn');
|
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render activity markers', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/activity-markers.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-21 11:51:59 +00:00
|
|
|
});
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2014-05-18 10:20:11 +00:00
|
|
|
|
2016-01-21 13:19:06 +00:00
|
|
|
it('should render association markers', function(done) {
|
|
|
|
var xml = require('../../fixtures/bpmn/draw/associations.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2016-01-21 13:19:06 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render activity markers (combination)', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/activity-markers-combination.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-19 14:22:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render conditional flows', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/conditional-flow.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-18 10:20:11 +00:00
|
|
|
});
|
|
|
|
|
2014-05-16 12:45:48 +00:00
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render conditional default flows', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/conditional-flow-default.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-16 12:45:48 +00:00
|
|
|
});
|
|
|
|
|
2014-05-02 09:17:25 +00:00
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render NO conditional flow (gateway)', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/conditional-flow-gateways.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-02 09:17:25 +00:00
|
|
|
});
|
|
|
|
|
2014-05-12 09:48:24 +00:00
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render conditional flow (typed task)', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/conditional-flow-typed-task.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-12 09:48:24 +00:00
|
|
|
});
|
|
|
|
|
2014-05-05 15:22:43 +00:00
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render data objects', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/data-objects.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-05 15:22:43 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render events', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/events.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-05 15:22:43 +00:00
|
|
|
});
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2014-05-02 06:25:08 +00:00
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render events (interrupting)', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/events-interrupting.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-02 06:25:08 +00:00
|
|
|
});
|
2014-04-25 11:31:18 +00:00
|
|
|
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render event subprocesses (collapsed)', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/event-subprocesses-collapsed.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-04-25 11:31:18 +00:00
|
|
|
});
|
|
|
|
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render event subprocesses (expanded)', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/event-subprocesses-expanded.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-02 06:25:08 +00:00
|
|
|
});
|
|
|
|
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2014-05-02 06:25:08 +00:00
|
|
|
it('should render gateways', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/gateways.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-04-30 14:36:02 +00:00
|
|
|
});
|
|
|
|
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render group', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/group.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-04-25 11:31:18 +00:00
|
|
|
});
|
|
|
|
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2018-10-24 11:43:34 +00:00
|
|
|
it('should render group name', function(done) {
|
|
|
|
var xml = require('../../fixtures/bpmn/draw/group-name.bpmn');
|
|
|
|
|
|
|
|
bootstrapViewer(xml).call(this, function(err) {
|
|
|
|
|
|
|
|
inject(function(elementRegistry) {
|
|
|
|
|
|
|
|
var groupGfx = elementRegistry.getGraphics('Group_1');
|
|
|
|
|
|
|
|
expect(domQuery('.djs-label', groupGfx)).to.exist;
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
})();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
it('should render message marker', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/message-marker.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-27 15:48:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2014-05-02 06:25:08 +00:00
|
|
|
it('should render pools', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/pools.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-02 06:25:08 +00:00
|
|
|
});
|
2014-05-09 13:20:29 +00:00
|
|
|
|
2014-05-27 15:48:04 +00:00
|
|
|
|
|
|
|
it('should render pool collection marker', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/pools-with-collection-marker.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-27 15:48:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should render task types', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/task-types.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-27 15:48:04 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should render text annotations', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/text-annotation.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-27 15:48:04 +00:00
|
|
|
});
|
|
|
|
|
2014-05-28 20:48:11 +00:00
|
|
|
|
|
|
|
it('should render flow markers', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/flow-markers.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-05-28 20:48:11 +00:00
|
|
|
});
|
|
|
|
|
2015-12-23 11:59:14 +00:00
|
|
|
|
2014-07-09 08:02:34 +00:00
|
|
|
it('should render xor gateways blank and with X', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/xor.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-07-09 08:02:34 +00:00
|
|
|
});
|
|
|
|
|
2015-12-23 11:59:14 +00:00
|
|
|
|
2014-07-15 10:43:30 +00:00
|
|
|
it('should render boundary events with correct z-index', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/boundary-event-z-index.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-07-15 10:43:30 +00:00
|
|
|
});
|
|
|
|
|
2015-12-23 11:59:14 +00:00
|
|
|
|
2014-07-15 10:43:30 +00:00
|
|
|
it('should render boundary events without flowNodeRef', function(done) {
|
2016-06-07 06:46:45 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/boundary-event-without-refnode.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-07-15 10:43:30 +00:00
|
|
|
});
|
|
|
|
|
2015-12-23 11:59:14 +00:00
|
|
|
|
2014-07-15 10:43:30 +00:00
|
|
|
it('should render boundary event only once if referenced incorrectly via flowNodeRef (robustness)', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/boundary-event-with-refnode.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-07-15 10:43:30 +00:00
|
|
|
});
|
|
|
|
|
2015-12-23 11:59:14 +00:00
|
|
|
|
2014-08-18 10:38:41 +00:00
|
|
|
it('should render gateway event if attribute is missing in XML', function(done) {
|
2015-03-31 12:17:15 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/draw/gateway-type-default.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2014-08-18 10:38:41 +00:00
|
|
|
});
|
|
|
|
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-12-23 11:59:14 +00:00
|
|
|
it('should render call activity', function(done) {
|
|
|
|
var xml = require('../../fixtures/bpmn/draw/call-activity.bpmn');
|
|
|
|
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, function(err) {
|
2015-12-23 11:59:14 +00:00
|
|
|
|
|
|
|
inject(function(elementRegistry) {
|
|
|
|
|
|
|
|
var callActivityGfx = elementRegistry.getGraphics('CallActivity');
|
|
|
|
|
|
|
|
// make sure the + marker is shown
|
2016-09-14 06:18:56 +00:00
|
|
|
expect(domQuery('[data-marker=sub-process]', callActivityGfx)).to.exist;
|
2015-12-23 11:59:14 +00:00
|
|
|
|
2017-12-04 21:27:32 +00:00
|
|
|
done(err);
|
2015-12-23 11:59:14 +00:00
|
|
|
})();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
it('should render adhoc sub process', function(done) {
|
|
|
|
var xml = require('../../fixtures/bpmn/draw/activity-markers-simple.bpmn');
|
|
|
|
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, function(err) {
|
2015-12-23 11:59:14 +00:00
|
|
|
|
|
|
|
inject(function(elementRegistry) {
|
|
|
|
|
|
|
|
var callActivityGfx = elementRegistry.getGraphics('AdHocSubProcess');
|
|
|
|
|
|
|
|
// make sure the + marker is shown
|
2016-09-14 06:18:56 +00:00
|
|
|
expect(domQuery('[data-marker=adhoc]', callActivityGfx)).to.exist;
|
2015-12-23 11:59:14 +00:00
|
|
|
|
2017-12-04 21:27:32 +00:00
|
|
|
done(err);
|
2015-12-23 11:59:14 +00:00
|
|
|
})();
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-09-29 09:08:20 +00:00
|
|
|
it('should add random ID suffix to marker ID', function(done) {
|
2017-11-10 20:07:26 +00:00
|
|
|
|
2017-09-29 09:08:20 +00:00
|
|
|
var xml = require('../../fixtures/bpmn/simple.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, function(err) {
|
2017-09-29 09:08:20 +00:00
|
|
|
|
|
|
|
inject(function(canvas) {
|
|
|
|
var svg = canvas._svg;
|
|
|
|
var markers = svg.querySelectorAll('marker');
|
|
|
|
|
|
|
|
expect(markers[0].id).to.match(/^sequenceflow-end-white-black-[A-Za-z0-9]+$/);
|
|
|
|
})();
|
|
|
|
|
2017-12-04 21:27:32 +00:00
|
|
|
done(err);
|
2017-09-29 09:08:20 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-12-20 15:54:45 +00:00
|
|
|
it('should properly render colored markers', function(done) {
|
|
|
|
|
|
|
|
var xml = require('../../fixtures/bpmn/draw/colors.bpmn');
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, function(err) {
|
2016-12-20 15:54:45 +00:00
|
|
|
|
|
|
|
inject(function(canvas) {
|
|
|
|
var svg = canvas._svg;
|
|
|
|
var markers = svg.querySelectorAll('marker');
|
|
|
|
|
|
|
|
expect(markers).to.have.length(5);
|
2017-09-29 09:08:20 +00:00
|
|
|
expect(markers[0].id).to.match(/^sequenceflow-end-white-black-[A-Za-z0-9]{25}$/);
|
2018-05-24 12:19:48 +00:00
|
|
|
expect(markers[1].id).to.match(/^sequenceflow-end-yellow-blue-[A-Za-z0-9]{25}$/);
|
2018-05-23 12:27:32 +00:00
|
|
|
expect(markers[2].id).to.match(/^association-end-white-black-[A-Za-z0-9]{25}$/);
|
|
|
|
expect(markers[3].id).to.match(/^messageflow-end-white-black-[A-Za-z0-9]{25}$/);
|
|
|
|
expect(markers[4].id).to.match(/^messageflow-start-white-black-[A-Za-z0-9]{25}$/);
|
2016-12-20 15:54:45 +00:00
|
|
|
})();
|
|
|
|
|
2017-12-04 21:27:32 +00:00
|
|
|
done(err);
|
2016-12-20 15:54:45 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2017-12-16 23:06:01 +00:00
|
|
|
it('should render sequenceFlows without source', function(done) {
|
|
|
|
|
|
|
|
var xml = require('../../fixtures/bpmn/draw/colors.bpmn');
|
|
|
|
bootstrapModeler(xml, {
|
|
|
|
modules: [
|
|
|
|
coreModule,
|
|
|
|
rendererModule,
|
|
|
|
modelingModule
|
|
|
|
]
|
2018-05-24 12:19:48 +00:00
|
|
|
}).call(this, function(err) {
|
2017-12-16 23:06:01 +00:00
|
|
|
|
|
|
|
inject(function(elementFactory, graphicsFactory) {
|
|
|
|
|
|
|
|
// given
|
|
|
|
var g = svgCreate('g');
|
|
|
|
|
|
|
|
var connection = elementFactory.create('connection', {
|
|
|
|
type: 'bpmn:SequenceFlow',
|
|
|
|
waypoints: [
|
|
|
|
{ x: 0, y: 0 },
|
|
|
|
{ x: 10, y: 100 }
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
var gfx = graphicsFactory.drawConnection(g, connection);
|
|
|
|
|
|
|
|
expect(gfx).to.exist;
|
|
|
|
})();
|
|
|
|
|
|
|
|
done(err);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2018-05-23 12:27:32 +00:00
|
|
|
describe('colors', function() {
|
|
|
|
|
|
|
|
var xml = require('../../fixtures/bpmn/draw/colors.bpmn');
|
|
|
|
|
|
|
|
|
|
|
|
it('should render colors without warnings and errors', function(done) {
|
2018-05-24 12:19:48 +00:00
|
|
|
bootstrapViewer(xml).call(this, checkErrors(done));
|
2018-05-23 12:27:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
describe('default colors', function() {
|
|
|
|
|
|
|
|
var defaultFillColor = 'red',
|
|
|
|
defaultStrokeColor = 'lime';
|
|
|
|
|
|
|
|
// TODO(philippfromme): remove once PhantomJS is not used anymore
|
|
|
|
var hexValues = {
|
|
|
|
blue: '#0000ff',
|
|
|
|
lime: '#00ff00',
|
|
|
|
red: '#ff0000',
|
|
|
|
yellow: '#ffff00'
|
|
|
|
};
|
|
|
|
|
|
|
|
beforeEach(bootstrapViewer(xml,{
|
2018-05-24 13:02:02 +00:00
|
|
|
bpmnRenderer: {
|
2018-05-23 12:27:32 +00:00
|
|
|
defaultFillColor: defaultFillColor,
|
|
|
|
defaultStrokeColor: defaultStrokeColor
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
|
|
|
|
function expectFillColor(element, color) {
|
|
|
|
expect([ color, hexValues[ color ]]).to.include(element.style.fill);
|
|
|
|
}
|
|
|
|
|
|
|
|
function expectStrokeColor(element, color) {
|
|
|
|
expect([ color, hexValues[ color ]]).to.include(element.style.stroke);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Expect colors depending on element type.
|
|
|
|
*
|
|
|
|
* @param {djs.model.base} element - Element.
|
|
|
|
* @param {SVG} gfx - Graphics of element.
|
|
|
|
* @param {String} fillColor - Fill color to expect.
|
|
|
|
* @param {String} strokeColor - Stroke color to expect.
|
|
|
|
*/
|
|
|
|
function expectColors(element, gfx, fillColor, strokeColor) {
|
|
|
|
var djsVisual = domQuery('.djs-visual', gfx);
|
|
|
|
|
|
|
|
var circle, path, polygon, polyline, rect, text;
|
|
|
|
|
|
|
|
if (element.labelTarget) {
|
|
|
|
text = domQuery('text', djsVisual);
|
|
|
|
|
|
|
|
expectFillColor(text, strokeColor);
|
|
|
|
} else if (element.waypoints) {
|
|
|
|
path = domQuery('path', djsVisual);
|
|
|
|
polyline = domQuery('polyline', djsVisual);
|
|
|
|
|
|
|
|
expectStrokeColor(path || polyline, strokeColor);
|
|
|
|
} else if (isAny(element, [ 'bpmn:StartEvent', 'bpmn:EndEvent' ])) {
|
|
|
|
circle = domQuery('circle', djsVisual);
|
|
|
|
|
|
|
|
expectFillColor(circle, fillColor);
|
|
|
|
expectStrokeColor(circle, strokeColor);
|
|
|
|
} else if (isAny(element, [ 'bpmn:Task', 'bpmn:SubProcess', 'bpmn:Particpant' ])) {
|
|
|
|
rect = domQuery('rect', djsVisual);
|
|
|
|
text = domQuery('text', djsVisual);
|
|
|
|
|
|
|
|
expectFillColor(rect, fillColor);
|
|
|
|
expectStrokeColor(rect, strokeColor);
|
|
|
|
expectFillColor(text, strokeColor);
|
|
|
|
} else if (isAny(element, [ 'bpmn:Gateway' ])) {
|
|
|
|
polygon = domQuery('polygon', djsVisual);
|
|
|
|
|
|
|
|
expectFillColor(polygon, fillColor);
|
|
|
|
expectStrokeColor(polygon, strokeColor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
it('should render default colors without overriding', inject(function(canvas, elementRegistry) {
|
|
|
|
var rootElement = canvas.getRootElement();
|
|
|
|
|
|
|
|
elementRegistry.forEach(function(e) {
|
|
|
|
if (e === rootElement) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var gfx = elementRegistry.getGraphics(e),
|
|
|
|
di = getDi(e),
|
|
|
|
fillColor = di.get('bioc:fill'),
|
|
|
|
strokeColor = di.get('bioc:stroke');
|
|
|
|
|
|
|
|
if (fillColor || strokeColor) {
|
|
|
|
expectColors(e, gfx, fillColor, strokeColor);
|
|
|
|
} else {
|
|
|
|
expectColors(e, gfx, defaultFillColor, defaultStrokeColor);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('path', function() {
|
2015-10-09 23:36:35 +00:00
|
|
|
|
2017-12-12 22:39:09 +00:00
|
|
|
var diagramXML = require('./BpmnRenderer.simple-cropping.bpmn');
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
var testModules = [ coreModule, rendererModule ];
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
beforeEach(bootstrapModeler(diagramXML, { modules: testModules }));
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2016-06-07 06:46:45 +00:00
|
|
|
describe('circle', function() {
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
it('should return a circle path', inject(function(canvas, elementRegistry, graphicsFactory) {
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// given
|
|
|
|
var eventElement = elementRegistry.get('StartEvent_1');
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// when
|
|
|
|
var startPath = graphicsFactory.getShapePath(eventElement);
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// then
|
|
|
|
expect(startPath).to.equal('M247,343m0,-18a18,18,0,1,1,0,36a18,18,0,1,1,0,-36z');
|
|
|
|
}));
|
2015-04-17 14:40:45 +00:00
|
|
|
|
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
it('should return a diamond path', inject(function(canvas, elementRegistry, graphicsFactory) {
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// given
|
|
|
|
var gatewayElement = elementRegistry.get('ExclusiveGateway_1');
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// when
|
|
|
|
var gatewayPath = graphicsFactory.getShapePath(gatewayElement);
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// then
|
|
|
|
expect(gatewayPath).to.equal('M418,318l25,25l-25,25l-25,-25z');
|
|
|
|
}));
|
2015-07-15 15:22:19 +00:00
|
|
|
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
it('should return a rounded rectangular path', inject(function(canvas, elementRegistry, graphicsFactory) {
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// given
|
|
|
|
var subProcessElement = elementRegistry.get('SubProcess_1');
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// when
|
|
|
|
var subProcessPath = graphicsFactory.getShapePath(subProcessElement);
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// then
|
|
|
|
expect(subProcessPath).to.equal('M584,243l330,0a10,10,0,0,1,10,10l0,180a10,10,0,0,1,-10,10' +
|
|
|
|
'l-330,0a10,10,0,0,1,-10,-10l0,-180a10,10,0,0,1,10,-10z');
|
|
|
|
}));
|
2015-04-17 14:40:45 +00:00
|
|
|
|
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
it('should return a rectangular path', inject(function(canvas, elementRegistry, graphicsFactory) {
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// given
|
|
|
|
var TextAnnotationElement = elementRegistry.get('TextAnnotation_1');
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// when
|
|
|
|
var TextAnnotationPath = graphicsFactory.getShapePath(TextAnnotationElement);
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
// then
|
2016-12-01 12:17:44 +00:00
|
|
|
expect(TextAnnotationPath).to.equal('M368,156l100,0l0,80l-100,0z');
|
2015-10-09 23:36:35 +00:00
|
|
|
}));
|
2015-04-17 14:40:45 +00:00
|
|
|
|
2015-10-09 23:36:35 +00:00
|
|
|
});
|
2015-04-17 14:40:45 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2017-11-10 20:07:26 +00:00
|
|
|
|
|
|
|
describe('extension API', function() {
|
|
|
|
|
|
|
|
var diagramXML = require('../../fixtures/bpmn/simple.bpmn');
|
|
|
|
|
|
|
|
beforeEach(bootstrapModeler(diagramXML, {
|
|
|
|
modules: [
|
|
|
|
coreModule,
|
|
|
|
rendererModule
|
|
|
|
]
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
it('should expose helpers', inject(function(bpmnRenderer) {
|
|
|
|
|
|
|
|
// then
|
|
|
|
expect(bpmnRenderer._drawPath).to.be.a('function');
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2015-04-17 14:40:45 +00:00
|
|
|
});
|