@@ -3,13 +3,16 @@ import {
3
3
inject
4
4
} from 'test/TestHelper' ;
5
5
6
- import {
7
- getOrientation
8
- } from 'diagram-js/lib/layout/LayoutUtil' ;
6
+ import { getOrientation } from 'diagram-js/lib/layout/LayoutUtil' ;
9
7
10
8
import modelingModule from 'lib/features/modeling' ;
11
9
import coreModule from 'lib/core' ;
12
10
11
+ import {
12
+ DEFAULT_LABEL_SIZE ,
13
+ getExternalLabelMid
14
+ } from 'lib/util/LabelUtil' ;
15
+
13
16
var testModules = [
14
17
modelingModule ,
15
18
coreModule
@@ -281,6 +284,45 @@ describe('modeling/behavior - AdaptiveLabelPositioningBehavior', function() {
281
284
}
282
285
) ) ;
283
286
287
+
288
+ it ( 'should not adjust position' , inject ( function ( bpmnFactory , elementFactory , elementRegistry , modeling , textRenderer ) {
289
+
290
+ // given
291
+ var sequenceFlow = elementRegistry . get ( 'SequenceFlow_1' ) ;
292
+
293
+ var intermediateThrowEvent = elementFactory . createShape ( {
294
+ businessObject : bpmnFactory . create ( 'bpmn:IntermediateThrowEvent' , {
295
+ name : 'Foo'
296
+ } ) ,
297
+ type : 'bpmn:IntermediateThrowEvent' ,
298
+ x : 0 ,
299
+ y : 0
300
+ } ) ;
301
+
302
+ var externalLabelMid = getExternalLabelMid ( intermediateThrowEvent ) ;
303
+
304
+ var externalLabelBounds = textRenderer . getExternalLabelBounds ( DEFAULT_LABEL_SIZE , 'Foo' ) ;
305
+
306
+ var label = elementFactory . createLabel ( {
307
+ labelTarget : intermediateThrowEvent ,
308
+ x : externalLabelMid . x - externalLabelBounds . width / 2 ,
309
+ y : externalLabelMid . y - externalLabelBounds . height / 2 ,
310
+ width : externalLabelBounds . width ,
311
+ height : externalLabelBounds . height
312
+ } ) ;
313
+
314
+ var sequenceFlowMid = getConnectionMid ( sequenceFlow . waypoints [ 0 ] , sequenceFlow . waypoints [ 1 ] ) ;
315
+
316
+ // when
317
+ modeling . createElements ( [ intermediateThrowEvent , label ] , sequenceFlowMid , sequenceFlow ) ;
318
+
319
+ // then
320
+ expect ( label . x ) . to . be . closeTo ( 325 , 1 ) ;
321
+ expect ( label . y ) . to . be . closeTo ( 335 , 1 ) ;
322
+ expect ( label . width ) . to . be . closeTo ( 19 , 1 ) ;
323
+ expect ( label . height ) . to . be . closeTo ( 14 , 1 ) ;
324
+ } ) ) ;
325
+
284
326
} ) ;
285
327
286
328
} ) ;
@@ -407,3 +449,12 @@ describe('modeling/behavior - AdaptiveLabelPositioningBehavior', function() {
407
449
} ) ;
408
450
409
451
} ) ;
452
+
453
+ // helpers //////////
454
+
455
+ function getConnectionMid ( a , b ) {
456
+ return {
457
+ x : ( a . x + b . x ) / 2 ,
458
+ y : ( a . y + b . y ) / 2
459
+ } ;
460
+ }
0 commit comments