-
Notifications
You must be signed in to change notification settings - Fork 11
/
SimpleELKLayoutTest.java
2397 lines (2114 loc) · 128 KB
/
SimpleELKLayoutTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* Copyright (c) 2020, 2024 Obeo.
* All rights reserved.
*
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
package org.eclipse.sirius.tests.unit.diagram.layout;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.draw2d.Connection;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.Label;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.PointList;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.emf.transaction.impl.TransactionalEditingDomainImpl;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.RequestConstants;
import org.eclipse.gef.requests.ChangeBoundsRequest;
import org.eclipse.gef.rulers.RulerProvider;
import org.eclipse.gef.tools.ToolUtilities;
import org.eclipse.gmf.runtime.diagram.ui.actions.ActionIds;
import org.eclipse.gmf.runtime.diagram.ui.editparts.DiagramEditPart;
import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
import org.eclipse.gmf.runtime.diagram.ui.figures.ResizableCompartmentFigure;
import org.eclipse.gmf.runtime.diagram.ui.internal.properties.WorkspaceViewerProperties;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor;
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer;
import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramWorkbenchPart;
import org.eclipse.gmf.runtime.diagram.ui.render.util.DiagramImageUtils;
import org.eclipse.gmf.runtime.diagram.ui.requests.ArrangeRequest;
import org.eclipse.gmf.runtime.draw2d.ui.figures.PolylineConnectionEx;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.gmf.runtime.draw2d.ui.geometry.LineSeg;
import org.eclipse.gmf.runtime.draw2d.ui.geometry.PointListUtilities;
import org.eclipse.gmf.runtime.draw2d.ui.internal.figures.AnimatableScrollPane;
import org.eclipse.gmf.runtime.notation.Bounds;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.gmf.runtime.notation.FontStyle;
import org.eclipse.gmf.runtime.notation.LayoutConstraint;
import org.eclipse.gmf.runtime.notation.Location;
import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.gmf.runtime.notation.NotationPackage;
import org.eclipse.gmf.runtime.notation.Routing;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.DDiagramElement;
import org.eclipse.sirius.diagram.DEdge;
import org.eclipse.sirius.diagram.DNode;
import org.eclipse.sirius.diagram.DNodeContainer;
import org.eclipse.sirius.diagram.DNodeList;
import org.eclipse.sirius.diagram.DNodeListElement;
import org.eclipse.sirius.diagram.DiagramPackage;
import org.eclipse.sirius.diagram.EdgeRouting;
import org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery;
import org.eclipse.sirius.diagram.business.api.query.IEdgeMappingQuery;
import org.eclipse.sirius.diagram.description.CustomLayoutConfiguration;
import org.eclipse.sirius.diagram.description.DescriptionFactory;
import org.eclipse.sirius.diagram.description.DescriptionPackage;
import org.eclipse.sirius.diagram.description.DiagramDescription;
import org.eclipse.sirius.diagram.description.EdgeMapping;
import org.eclipse.sirius.diagram.description.EnumLayoutOption;
import org.eclipse.sirius.diagram.description.EnumLayoutValue;
import org.eclipse.sirius.diagram.description.LayoutOptionTarget;
import org.eclipse.sirius.diagram.tools.api.preferences.SiriusDiagramPreferencesKeys;
import org.eclipse.sirius.diagram.tools.internal.commands.PinElementsCommand;
import org.eclipse.sirius.diagram.ui.business.api.query.ViewQuery;
import org.eclipse.sirius.diagram.ui.business.internal.query.DEdgeQuery;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramBorderNodeEditPart;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramContainerEditPart;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramEdgeEditPart;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramListEditPart;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramNodeEditPart;
import org.eclipse.sirius.diagram.ui.edit.api.part.IDiagramContainerEditPart;
import org.eclipse.sirius.diagram.ui.edit.api.part.IDiagramNodeEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.AbstractDNodeContainerCompartmentEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.DEdgeEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeListEditPart;
import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNodeListElementEditPart;
import org.eclipse.sirius.diagram.ui.internal.operation.ResetOriginChangeModelOperation;
import org.eclipse.sirius.diagram.ui.tools.api.editor.DDiagramEditor;
import org.eclipse.sirius.diagram.ui.tools.api.graphical.edit.styles.IBorderItemOffsets;
import org.eclipse.sirius.diagram.ui.tools.api.layout.LayoutUtils;
import org.eclipse.sirius.ext.base.Option;
import org.eclipse.sirius.ext.gmf.runtime.gef.ui.figures.IContainerLabelOffsets;
import org.eclipse.sirius.ext.gmf.runtime.gef.ui.figures.SiriusWrapLabel;
import org.eclipse.sirius.tests.SiriusTestsPlugin;
import org.eclipse.sirius.tests.support.api.EclipseTestsSupportHelper;
import org.eclipse.sirius.tests.support.api.SiriusDiagramTestCase;
import org.eclipse.sirius.tests.support.api.TestsUtil;
import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager;
import org.eclipse.sirius.ui.business.api.session.SessionUIManager;
import org.eclipse.sirius.viewpoint.DRepresentation;
import org.eclipse.sirius.viewpoint.description.Group;
import org.eclipse.sirius.viewpoint.description.RepresentationDescription;
import org.eclipse.ui.IEditorPart;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
/**
* Tests to realize some verification of arrange result with basic ELK layouts.
*
* @author lredor
*/
@SuppressWarnings("restriction")
public class SimpleELKLayoutTest extends SiriusDiagramTestCase {
/**
* A customized ViewQuery to ignore FontStyle, because the default Font Style depends on the OS where the test is
* launched. In reality, it is not ignored but the current font style is returned as default.
*
* @author Laurent Redor
*/
public class ViewQueryWithoutFontNameCheck extends ViewQuery {
public ViewQueryWithoutFontNameCheck(View view) {
super(view);
}
@Override
public Object getDefaultValue(EAttribute eAttribute) {
Object result = super.getDefaultValue(eAttribute);
if (NotationPackage.Literals.FONT_STYLE__FONT_NAME.equals(eAttribute)) {
FontStyle fontStyle = (FontStyle) view.getStyle(NotationPackage.Literals.FONT_STYLE);
if (fontStyle != null) {
result = fontStyle.eGet(NotationPackage.Literals.FONT_STYLE__FONT_NAME);
}
}
return result;
}
}
private static final String WRONG_INITIAL_ROUTING_MESSAGE = "The edge \"{0}\" has a wrong initial routing style.";
private static final String WRONG_ROUTING_AFTER_LAYOUT_MESSAGE = "The edge \"{0}\" has a wrong routing style after the arrange.";
private static final String PATH = "/data/unit/layout/withELK/";
private static final String PATH_REPLACE = "/data/unit/layout/withELK/replace/";
private static final String VSM_RESOURCE_NAME = "My.odesign";
private static final String SEMANTIC_RESOURCE_NAME = "My.ecore";
private static final String REPRESENTATIONS_RESOURCE_NAME = "representations.aird";
private DDiagram diagram;
private IDiagramWorkbenchPart editorPart;
private boolean initialSnapToGridValue;
private double initialGridSpacingValue;
private int initialRulerUnitValue;
@Override
protected void setUp() throws Exception {
super.setUp();
EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID + PATH + VSM_RESOURCE_NAME, "/" + TEMPORARY_PROJECT_NAME + "/" + VSM_RESOURCE_NAME);
EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID + PATH + SEMANTIC_RESOURCE_NAME, "/" + TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_RESOURCE_NAME);
EclipseTestsSupportHelper.INSTANCE.copyFile(SiriusTestsPlugin.PLUGIN_ID + PATH + REPRESENTATIONS_RESOURCE_NAME, "/" + TEMPORARY_PROJECT_NAME + "/" + REPRESENTATIONS_RESOURCE_NAME);
genericSetUp("/" + TEMPORARY_PROJECT_NAME + "/" + SEMANTIC_RESOURCE_NAME, "/" + TEMPORARY_PROJECT_NAME + "/" + VSM_RESOURCE_NAME,
"/" + TEMPORARY_PROJECT_NAME + "/" + REPRESENTATIONS_RESOURCE_NAME);
SessionUIManager.INSTANCE.createUISession(session);
}
@Override
protected void tearDown() throws Exception {
if (editorPart != null) {
SessionUIManager.INSTANCE.getUISession(session).closeEditors(false, Collections.singleton((DDiagramEditor) editorPart));
}
TestsUtil.emptyEventsFromUIThread();
super.tearDown();
}
/**
* Makes sure that activating the Snap to grid has no effect on the ELK layout.
*/
public void testArrangeWithSnapToWithELK() {
// We create a new diagram
EObject root = session.getSemanticResources().stream().findFirst().get().getContents().get(0);
DRepresentation representation = createRepresentation("SimpleDiagram", root);
// We open the editor and set the preferences for the test.
IEditorPart newEditorPart = DialectUIManager.INSTANCE.openEditor(session, representation, new NullProgressMonitor());
IPreferenceStore workspaceViewerPreferenceStore = ((DiagramGraphicalViewer) ((DiagramEditor) newEditorPart).getDiagramGraphicalViewer()).getWorkspaceViewerPreferenceStore();
changeSnapToPreferences(workspaceViewerPreferenceStore);
try {
arrangeAll((DiagramEditor) newEditorPart);
TestsUtil.synchronizationWithUIThread();
// We keep the figures bounds after the arrange all without the Snap to grid.
Map<DNode, Rectangle> DNodes2Bounds = computeNodesBounds(representation);
// We activate the Snap to Grid.
workspaceViewerPreferenceStore.setValue(WorkspaceViewerProperties.SNAPTOGRID, true);
// We perform the arrange all again.
arrangeAll((DiagramEditor) newEditorPart);
TestsUtil.synchronizationWithUIThread();
// We check that the layout did not change
Map<DNode, Rectangle> afterDNodes2Bounds = computeNodesBounds(representation);
afterDNodes2Bounds.forEach((dNode, rect) -> {
assertEquals("The layout should not change after having activated the snap to grid with ELK algorithm.", DNodes2Bounds.get(dNode), rect);
});
} finally {
restoreInitilaPreferences(workspaceViewerPreferenceStore);
}
}
/**
* Makes sure that activating the Snap to grid has effect on diagram without ELK algorithm
*/
public void testArrangeWithSnapToWithoutELK() {
// We create a new diagram
EObject root = session.getSemanticResources().stream().findFirst().get().getContents().get(0);
DRepresentation representation = createRepresentation("SimpleDiagramNoELK", root);
// We open the editor and set the preferences for the test.
IEditorPart newEditorPart = DialectUIManager.INSTANCE.openEditor(session, representation, new NullProgressMonitor());
IPreferenceStore workspaceViewerPreferenceStore = ((DiagramGraphicalViewer) ((DiagramEditor) newEditorPart).getDiagramGraphicalViewer()).getWorkspaceViewerPreferenceStore();
changeSnapToPreferences(workspaceViewerPreferenceStore);
try {
arrangeAll((DiagramEditor) newEditorPart);
TestsUtil.synchronizationWithUIThread();
// We keep the figures bounds after the arrange all without the Snap to grid.
Map<DNode, Rectangle> dNodes2Bounds = computeNodesBounds(representation);
// We activate the Snap to Grid.
workspaceViewerPreferenceStore.setValue(WorkspaceViewerProperties.SNAPTOGRID, true);
// We perform the arrange all again.
arrangeAll((DiagramEditor) newEditorPart);
TestsUtil.synchronizationWithUIThread();
// We check that the layout has changed
Map<DNode, Rectangle> afterDNodes2Bounds = computeNodesBounds(representation);
boolean atLeastOneElementHasChanged = false;
for (Iterator<Entry<DNode, Rectangle>> iterator = afterDNodes2Bounds.entrySet().iterator(); iterator.hasNext();) {
Entry<DNode, Rectangle> dNodeToRect = iterator.next();
if (!dNodeToRect.getValue().equals(dNodes2Bounds.get(dNodeToRect.getKey()))) {
atLeastOneElementHasChanged = true;
break;
}
}
assertTrue("The activation of the Snap to grid should have changed the layout", atLeastOneElementHasChanged);
} finally {
restoreInitilaPreferences(workspaceViewerPreferenceStore);
}
}
/**
* Check that the size of a Node under the root (under the diagram), is sufficiently large to read the label.
*/
public void testSizeOfRootNode() {
openDiagram("simpleDiagram");
AbstractDiagramNodeEditPart c1EditPart = getEditPart("MyClass1", AbstractDiagramNodeEditPart.class);
Dimension minimumTextSize = c1EditPart.getNodeLabel().getPreferredSize();
// Launch an arrange all
arrangeAll((DiagramEditor) editorPart);
// Check that the new Size is bigger than the minimum size to display the text
Dimension c1Dimension = c1EditPart.getFigure().getSize();
assertTrue("The size of \"MyClass1\" should be sufficiently large to read the label (minimul label size is " + minimumTextSize + " and node size is " + c1Dimension + ".",
c1Dimension.contains(minimumTextSize));
}
/**
* Check that the Note is moved with an arrange using ELK, when the preference "Move unlinked notes during layout"
* is enabled.
*
* @throws Exception
* in case of problem
*/
public void testNoteLayoutWithPrefTrue() throws Exception {
testNoteLayoutAccordingToPref(true);
}
/**
* Check that the Note is not moved with an arrange using ELK, when the preference "Move unlinked notes during
* layout" is disabled.
*
* @throws Exception
* in case of problem
*/
public void testNoteLayoutWithPrefFalse() throws Exception {
testNoteLayoutAccordingToPref(false);
}
/**
* Check that the size of a Note is the same before and after an arrange.
*/
@SuppressWarnings("rawtypes")
public void testNoteHaveFixedSizeAfterLayout() {
openDiagram("simpleDiagramWithNote");
// Get the GMF node corresponding to the Note
Node noteNode = getNote(editorPart.getDiagram());
assertTrue("One note should exist on the diagram", noteNode != null);
// Get the corresponding edit part
Map editPartRegistry = editorPart.getDiagramEditPart().getRoot().getViewer().getEditPartRegistry();
final IGraphicalEditPart noteEditPart = (IGraphicalEditPart) editPartRegistry.get(noteNode);
// Get the initial note bounds (to be compare to the new bounds after the layout)
final Rectangle initialNoteBounds = noteEditPart.getFigure().getBounds().getCopy();
changeDiagramPreference(SiriusDiagramPreferencesKeys.PREF_MOVE_NOTES_DURING_LATOUT.name(), true);
// Launch an arrange all
arrangeAll((DiagramEditor) editorPart);
// Check that the Note has been moved during the arrange
Rectangle currentNoteBounds = noteEditPart.getFigure().getBounds().getCopy();
assertFalse("The Note should be moved during the arrange.", initialNoteBounds.getLocation().equals(currentNoteBounds.getLocation()));
// Check that the size of the Note is the same after the arrange
assertEquals("The Note should have the same size before and after the arrange.", initialNoteBounds.getSize(), (currentNoteBounds.getSize()));
}
/**
* Check that the size of a Text is the same before and after an arrange.
*/
@SuppressWarnings("rawtypes")
public void testTextHaveFixedSizeAfterLayout() {
openDiagram("simpleDiagramWithText");
// Get the GMF node corresponding to the Note
Node textNode = getText(editorPart.getDiagram());
assertTrue("One test should exist on the diagram", textNode != null);
// Get the corresponding edit part
Map editPartRegistry = editorPart.getDiagramEditPart().getRoot().getViewer().getEditPartRegistry();
final IGraphicalEditPart textEditPart = (IGraphicalEditPart) editPartRegistry.get(textNode);
// Get the initial text bounds (to be compare to the new bounds after the layout)
final Rectangle initialTextBounds = textEditPart.getFigure().getBounds().getCopy();
// Launch an arrange all
arrangeAll((DiagramEditor) editorPart);
// Check that the Text has been moved during the arrange
Rectangle currentTextBounds = textEditPart.getFigure().getBounds().getCopy();
assertFalse("The Text should be moved during the arrange.", initialTextBounds.getLocation().equals(currentTextBounds.getLocation()));
// Check that the size of the Note is the same after the arrange
assertEquals("The Text should have the same size before and after the arrange.", initialTextBounds.getSize(), currentTextBounds.getSize());
}
/**
* Check that the location of the label is centered under the bottom side of its border node.
*/
public void testLocationOfLabelOnBorderOnBorderNode() {
openDiagram("diagramWithBorderNodesWithLabelOnBorder");
AbstractDiagramBorderNodeEditPart portEditPart = getEditPart("att1", AbstractDiagramBorderNodeEditPart.class);
// Launch an arrange all
arrangeAll((DiagramEditor) editorPart);
Rectangle borderNodeBounds = portEditPart.getFigure().getBounds().getCopy();
// Check the label location
boolean labelFound = false;
for (Object portChildObj : portEditPart.getChildren()) {
if (portChildObj instanceof IGraphicalEditPart) {
IFigure labelFigure = ((IGraphicalEditPart) portChildObj).getFigure();
String text = null;
if (labelFigure instanceof WrappingLabel) {
text = ((WrappingLabel) labelFigure).getText();
} else if (labelFigure instanceof Label) {
text = ((Label) labelFigure).getText();
} else if (labelFigure instanceof SiriusWrapLabel) {
SiriusWrapLabel label = (SiriusWrapLabel) labelFigure;
text = label.getText();
}
if (text != null) {
labelFound = true;
Rectangle labelBounds = labelFigure.getBounds();
assertEquals("The label of the border node is visually not horizontally centered on its border node (draw2d x coordinate).", labelBounds.getCenter().x(),
borderNodeBounds.getCenter().x());
assertEquals("The label of the border node is visually not under the bottom side of its border node (draw2d y coordinate).", labelBounds.getTop().y(),
borderNodeBounds.getBottom().y() + 1);
assertTrue(((IGraphicalEditPart) portChildObj).getModel() instanceof Node);
Node labelNode = (Node) ((IGraphicalEditPart) portChildObj).getModel();
Location gmfLabelLocation = (Location) labelNode.getLayoutConstraint();
assertEquals("The x GMF coordinate of the label of the border node does not correspond to a centered location.", -(labelBounds.width() - borderNodeBounds.width()) / 2,
gmfLabelLocation.getX(), 1);
assertEquals("The y GMF coordinate of the label of the border node does not correspond to a location under its border node.", borderNodeBounds.height() + 1,
gmfLabelLocation.getY());
}
}
if (!labelFound) {
fail("The label of the border node has not been found.");
}
}
}
/**
* Check that the height of a ListContainer is sufficient to display the list items (when list items are only icons
* without text).
*/
public void testListContainerWithIconListItemsLayout() {
openDiagram("diagramWithListWithIconListItems");
// Check for a list in the diagram
checkForListContainerWithIconListItems("L_MyClass1");
// Check for a list in a container
checkForListContainerWithIconListItems("MyClass1");
}
private void checkForListContainerWithIconListItems(String listName) {
DDiagramElement dde = getDDiagramElement(listName);
AbstractDiagramListEditPart editPart = getEditPart(dde, AbstractDiagramListEditPart.class);
assertEquals("Wrong number of list items, the list should contain 3 list items.", 3, ((DNodeList) dde).getOwnedElements().stream().count());
Dimension listItemSize = getEditPart(((DNodeList) dde).getOwnedElements().get(0), IGraphicalEditPart.class).getFigure().getSize();
// Launch an arrange all
arrangeAll((DiagramEditor) editorPart);
Dimension listSize = editPart.getFigure().getSize();
assertTrue("The height of the list should be at least bigger that thrice the size of a list item + 20 pixels for the title. Expected more than " + (20 + (3 * listItemSize.height()))
+ " but was " + listSize.height(), listSize.height() > (20 + (3 * listItemSize.height())));
}
/**
* Check that the size of a ListContainer is OK:
* <UL>
* <LI>Size is long enough to avoid wrap label of list items</LI>
* <LI>Incoming edges have no bendpoint</LI>
* <LI>Size if not too big</LI>
* </UL>
*/
public void testListContainerLayout() {
openDiagram("diagramWithList");
DDiagramElement c2Dde = getDDiagramElement("MyClass2");
DNodeListEditPart c2EditPart = getEditPart(c2Dde, DNodeListEditPart.class);
Optional<DNodeListElement> listItem = ((DNodeList) c2Dde).getOwnedElements().stream().filter(dde -> dde.getName().equals("listItemWithALongName")).findFirst();
assertTrue("The container \"MyClass2\" should have a list item named \"listItemWithALongName\".", listItem.isPresent());
IGraphicalEditPart listItemEditPart = getEditPart(listItem.get());
assertTrue("The node for \"listItemWithALongName\" should be a DNodeListElementEditPart.", listItemEditPart instanceof DNodeListElementEditPart);
int expectedOneLineHeight = ((DNodeListElementEditPart) listItemEditPart).getFigure().getSize().height();
// Launch an arrange all
arrangeAll((DiagramEditor) editorPart);
// Check that the new size of list item is sufficiently large to display the label without wrapping.
assertEquals("The list item should be on one line (with one line height)", expectedOneLineHeight, ((DNodeListElementEditPart) listItemEditPart).getFigure().getSize().height());
// Check that the new size of the list if not too big (around 2x the size of one line height : a delta of 20
// pixels for all margins).
assertEquals("The list should not be too high (arround 2x the size of one line height)", 2 * expectedOneLineHeight, c2EditPart.getFigure().getSize().height(), 20);
// Check that incoming edge has only 2 points (ie without intermediate bendpoints)
assertEquals("The container \"MyClass2\" should have one incoming edge", 1, c2EditPart.getTargetConnections().size());
assertTrue("The container \"MyClass2\" should have one incoming edge of kind DEdgeEditPart", c2EditPart.getTargetConnections().get(0) instanceof DEdgeEditPart);
DEdgeEditPart edgeEditPart = (DEdgeEditPart) c2EditPart.getTargetConnections().get(0);
assertTrue("The edge figure should be a PolylineConnectionEx", edgeEditPart.getFigure() instanceof PolylineConnectionEx);
assertEquals("The edge should have only 2 points (ie without intermediate bendpoints)", 2, ((PolylineConnectionEx) edgeEditPart.getFigure()).getPoints().size());
}
/**
* Check that the size of an empty ListContainer without title is OK (ie same size as default Sirius Size : 40x40).
*/
public void testEmptyListContainerMinimalSizeLayout() {
openDiagram("diagramWithEmptyListWithoutTitle");
Optional<DDiagramElement> dde = diagram.getDiagramElements().stream().findFirst();
assertTrue("The diagram should have at least one node.", dde.isPresent());
IGraphicalEditPart editPart = getEditPart(dde.get());
assertTrue("The first node should be a DNodeListEditPart.", editPart instanceof DNodeListEditPart);
assertEquals("Wrong number of list items, the list should be empty.", 0, ((DNodeList) dde.get()).getOwnedElements().stream().count());
// Launch an arrange all
arrangeAll((DiagramEditor) editorPart);
// Check that the new size is the default one
// (org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramElementContainerEditPart.getDefaultDimension(DDiagramElement)
// ie LayoutUtils.NEW_DEFAULT_CONTAINER_DIMENSION.
assertEquals("The width of the list should be the default Sirius one (to have a minimal size for empty list)", LayoutUtils.NEW_DEFAULT_CONTAINER_DIMENSION.width,
((DNodeListEditPart) editPart).getFigure().getSize().width());
assertEquals("The height of the list should be the default Sirius one (to have a minimal size for empty list)", LayoutUtils.NEW_DEFAULT_CONTAINER_DIMENSION.height,
((DNodeListEditPart) editPart).getFigure().getSize().height());
}
/**
* Check the layout of a container with VStack layout.
*/
public void testVStackContainerLayout() {
openDiagram("diagramWithRegions");
DDiagramElement vStackContainer = getDDiagramElement("root_V");
IGraphicalEditPart vStackContainerEditPart = getEditPart(vStackContainer, AbstractDiagramContainerEditPart.class);
Optional<DDiagramElement> c2Dde = ((DNodeContainer) vStackContainer).getOwnedDiagramElements().stream().filter(dde -> dde.getName().equals("MyClass2")).findFirst();
assertTrue("The container \"root_V\" should have a region named \"MyClass2\".", c2Dde.isPresent());
IGraphicalEditPart c2EditPart = getEditPart(c2Dde.get());
assertTrue("The node for \"MyClass2\" should be a AbstractDiagramContainerEditPart.", c2EditPart instanceof AbstractDiagramContainerEditPart);
int expectedOneLineHeight = ((AbstractDiagramContainerEditPart) c2EditPart).getNodeLabel().getSize().height();
int expectedOneLineWidth = ((AbstractDiagramContainerEditPart) c2EditPart).getNodeLabel().getSize().width();
// Launch an arrange all
arrangeAll((DiagramEditor) editorPart);
// Check that the new size of list item is sufficiently large to display the label without wrapping : one line
// label height + label offset + 1 pixel for the separator between 2 regions.
int expectedRegionHeight = Math.max(expectedOneLineHeight + IContainerLabelOffsets.LABEL_OFFSET + 1, LayoutUtils.NEW_DEFAULT_CONTAINER_DIMENSION.height);
int currentLineHeight = ((AbstractDiagramContainerEditPart) c2EditPart).getFigure().getSize().height();
assertTrue("The empty region should be on one line (with at least one line height; more than " + expectedRegionHeight + " but was " + currentLineHeight + ")",
currentLineHeight >= expectedRegionHeight);
// The GMF size of VStack container should be "auto-size" ie {-1,-1}
assertTrue(vStackContainerEditPart.getNotationView() instanceof Node);
Node vStackNode = (Node) vStackContainerEditPart.getNotationView();
LayoutConstraint layoutConstraint = vStackNode.getLayoutConstraint();
assertTrue(layoutConstraint instanceof Bounds);
Bounds bounds = (Bounds) layoutConstraint;
assertEquals("The width of the VStack container should be \"auto-sized\" after an arrange all.", -1, bounds.getWidth());
assertEquals("The height of the VStack container should be \"auto-sized\" after an arrange all.", -1, bounds.getHeight());
// Check that the new size of the VStack compartment if not too big (around 5x the size of one region height : a
// delta of 20 pixels for all margins).
assertEquals("The VStack container should not be too high (arround 5x the size of one line height)", 5 * expectedRegionHeight, vStackContainerEditPart.getFigure().getSize().height(), 20);
// Check width
assertEquals("The region size should fit the label size", expectedOneLineWidth, c2EditPart.getFigure().getSize().width(), 10);
// Check width, height, x and y location of each region (GMF bounds): Same width for each region, same height
// for each region, x==0 for each region, y==0 for first region and other regions below
assertEquals(2, ((AbstractDiagramContainerEditPart) vStackContainerEditPart).getChildren().size());
Object compartmentEditPart = ((AbstractDiagramContainerEditPart) vStackContainerEditPart).getChildren().get(1);
assertTrue(compartmentEditPart instanceof AbstractDNodeContainerCompartmentEditPart);
int previousRegionWidth = 0;
int previousRegionHeight = 0;
int previousY = 0;
for (Object child : ((AbstractDNodeContainerCompartmentEditPart) compartmentEditPart).getChildren()) {
if (child instanceof AbstractDiagramContainerEditPart) {
AbstractDiagramContainerEditPart regionEditPart = (AbstractDiagramContainerEditPart) child;
assertTrue(regionEditPart.getNotationView() instanceof Node);
Node regionNode = (Node) regionEditPart.getNotationView();
LayoutConstraint regionLayoutConstraint = regionNode.getLayoutConstraint();
assertTrue(regionLayoutConstraint instanceof Bounds);
Bounds regionBounds = (Bounds) regionLayoutConstraint;
assertEquals("x coordinate of each region should be 0", 0, regionBounds.getX());
assertEquals("Each region should be below the previous, wrong location for " + ((DNodeContainer) regionEditPart.resolveSemanticElement()).getName(), previousY + previousRegionHeight,
regionBounds.getY());
previousY = regionBounds.getY();
if (previousRegionWidth == 0) {
previousRegionWidth = regionBounds.getWidth();
} else {
assertEquals("Each region should have the same width, width of \"" + ((DNodeContainer) regionEditPart.resolveSemanticElement()).getName()
+ "\" is not the same than the previous region", previousRegionWidth, regionBounds.getWidth());
}
if (previousRegionHeight == 0) {
previousRegionHeight = regionBounds.getHeight();
} else {
assertEquals("Each region should have the same height, height of \"" + ((DNodeContainer) regionEditPart.resolveSemanticElement()).getName()
+ "\" is not the same than the previous region", previousRegionHeight, regionBounds.getHeight());
previousRegionHeight = regionBounds.getHeight();
}
}
}
}
/**
* Check that the "authorized side" constraint of a border node is considered in ELK layout.
*/
public void testBorderNodeLayoutWithOneAuthorizedSide() {
openDiagram("diagramWithBorderNodesWithOneAuthorizedSide");
// Initialization checks
Optional<DDiagramElement> p1Dde = diagram.getOwnedDiagramElements().stream().filter(dde -> dde.getName().equals("p1")).findFirst();
assertTrue("The diagram should have an element named \"p1\".", p1Dde.isPresent());
assertTrue("The diagram should have a node named \"p1\".", p1Dde.get() instanceof DNode);
Optional<DDiagramElement> p2Dde = diagram.getOwnedDiagramElements().stream().filter(dde -> dde.getName().equals("p2")).findFirst();
assertTrue("The diagram should have an element named \"p2\".", p2Dde.isPresent());
assertTrue("The diagram should have a node named \"p2\".", p2Dde.get() instanceof DNode);
List<DNode> borderNodesOfP1 = ((DNode) p1Dde.get()).getOwnedBorderedNodes();
assertEquals("\"p1\" should have one border node.", 1, borderNodesOfP1.size());
List<DNode> borderNodesOfP2 = ((DNode) p2Dde.get()).getOwnedBorderedNodes();
assertEquals("\"p2\" should have one border node.", 1, borderNodesOfP2.size());
// Launch an arrange all
arrangeAll((DiagramEditor) editorPart);
// Check that the figure of border node of p1 is above them from 2 pixels.
IGraphicalEditPart p1EditPart = getEditPart(p1Dde.get());
IGraphicalEditPart borderNodeOfp1EditPart = getEditPart(borderNodesOfP1.get(0));
Rectangle borderNodeOfp1Bounds = borderNodeOfp1EditPart.getFigure().getBounds();
int p1Delta = borderNodeOfp1Bounds.height() - IBorderItemOffsets.DEFAULT_OFFSET.height();
assertEquals("The y location of p1 should be 2 pixels lower that its border node as border node is constaint on North side.", p1EditPart.getFigure().getBounds().y() - p1Delta,
borderNodeOfp1Bounds.y());
// Check that GMF coordinates also reflect that
assertTrue(borderNodeOfp1EditPart.getModel() instanceof Node);
Node borderNodeOfp1Node = (Node) borderNodeOfp1EditPart.getModel();
Location gmfLocation1 = (Location) borderNodeOfp1Node.getLayoutConstraint();
assertEquals("The y GMF coordinate of the the border node of p1 is wrong.", -p1Delta, gmfLocation1.getY());
// Check that the figure of border node of p2 is below them from 2 pixels.
IGraphicalEditPart p2EditPart = getEditPart(p2Dde.get());
IGraphicalEditPart borderNodeOfp2EditPart = getEditPart(borderNodesOfP2.get(0));
Rectangle p2Bounds = p2EditPart.getFigure().getBounds();
Rectangle borderNodeOfp2Bounds = borderNodeOfp2EditPart.getFigure().getBounds();
int p2Delta = borderNodeOfp2Bounds.height() - IBorderItemOffsets.DEFAULT_OFFSET.height();
assertEquals("The bottom location of p2 should be 2 pixels upper that its border node as border node is constaint on South side.", p2Bounds.getBottom().y() + p2Delta,
borderNodeOfp2Bounds.getBottom().y());
// Check that GMF coordinates also reflect that
assertTrue(borderNodeOfp2EditPart.getModel() instanceof Node);
Node borderNodeOfp2Node = (Node) borderNodeOfp2EditPart.getModel();
Location gmfLocation2 = (Location) borderNodeOfp2Node.getLayoutConstraint();
assertEquals("The y GMF coordinate of the the border node of p2 is wrong.", p2Bounds.height() - IBorderItemOffsets.DEFAULT_OFFSET.height(), gmfLocation2.getY());
}
/**
* Check that when all sides are "authorized", a classical ELK layout (from left to right) is done.
*/
public void testBorderNodeLayoutWithAllAuthorizedSides() {
openDiagram("diagramWithBorderNodesWithAllAuthorizedSides");
// Initialization checks
Optional<DDiagramElement> p1Dde = diagram.getOwnedDiagramElements().stream().filter(dde -> dde.getName().equals("p1")).findFirst();
assertTrue("The diagram should have an element named \"p1\".", p1Dde.isPresent());
assertTrue("The diagram should have a node named \"p1\".", p1Dde.get() instanceof DNode);
Optional<DDiagramElement> p2Dde = diagram.getOwnedDiagramElements().stream().filter(dde -> dde.getName().equals("p2")).findFirst();
assertTrue("The diagram should have an element named \"p2\".", p2Dde.isPresent());
assertTrue("The diagram should have a node named \"p2\".", p2Dde.get() instanceof DNode);
List<DNode> borderNodesOfP1 = ((DNode) p1Dde.get()).getOwnedBorderedNodes();
assertEquals("\"p1\" should have one border node.", 1, borderNodesOfP1.size());
List<DNode> borderNodesOfP2 = ((DNode) p2Dde.get()).getOwnedBorderedNodes();
assertEquals("\"p2\" should have one border node.", 1, borderNodesOfP2.size());
// Launch an arrange all
arrangeAll((DiagramEditor) editorPart);
// Check that the figure of border node of p1 is above them from 2 pixels.
IGraphicalEditPart p1EditPart = getEditPart(p1Dde.get());
IGraphicalEditPart borderNodeOfp1EditPart = getEditPart(borderNodesOfP1.get(0));
Rectangle p1Bounds = p1EditPart.getFigure().getBounds();
Rectangle borderNodeOfp1Bounds = borderNodeOfp1EditPart.getFigure().getBounds();
int p1Delta = borderNodeOfp1Bounds.width() - IBorderItemOffsets.DEFAULT_OFFSET.height();
assertEquals("The right location of p1 should be 2 pixels lefter that its border node as border node has no constraint (East side is used).", p1Bounds.getRight().x() + p1Delta,
borderNodeOfp1Bounds.getRight().x());
// Check that GMF coordinates also reflect that
assertTrue(borderNodeOfp1EditPart.getModel() instanceof Node);
Node borderNodeOfp1Node = (Node) borderNodeOfp1EditPart.getModel();
Location gmfLocation1 = (Location) borderNodeOfp1Node.getLayoutConstraint();
assertEquals("The x GMF coordinate of the the border node of p1 is wrong.", p1Bounds.width() - IBorderItemOffsets.DEFAULT_OFFSET.height(), gmfLocation1.getX());
// Check that the figure of border node of p2 is below them from 2 pixels.
IGraphicalEditPart p2EditPart = getEditPart(p2Dde.get());
IGraphicalEditPart borderNodeOfp2EditPart = getEditPart(borderNodesOfP2.get(0));
Rectangle p2Bounds = p2EditPart.getFigure().getBounds();
Rectangle borderNodeOfp2Bounds = borderNodeOfp2EditPart.getFigure().getBounds();
int p2Delta = borderNodeOfp2Bounds.height() - IBorderItemOffsets.DEFAULT_OFFSET.height();
assertEquals("The x location of p2 should be 2 pixels righter that its border node as border node has no constraint (West side is used).", p2Bounds.x() - p2Delta, borderNodeOfp2Bounds.x());
// Check that GMF coordinates also reflect that
assertTrue(borderNodeOfp2EditPart.getModel() instanceof Node);
Node borderNodeOfp2Node = (Node) borderNodeOfp2EditPart.getModel();
Location gmfLocation2 = (Location) borderNodeOfp2Node.getLayoutConstraint();
assertEquals("The x GMF coordinate of the the border node of p2 is wrong.", -p2Delta, gmfLocation2.getX());
}
/**
* Makes sure that the result of an arrange all respect the following rules:
* <UL>
* <LI>The top left corner of the bounding box is {20, 20}</LI>
* <LI>There is no scrollbar on all containers</LI>
* <LI>All the containers's contents correctly layouted</LI>
* <UL>
*/
public void testArrangeAllResult() {
testArrangeAllResult_ForPackageArrangeSelection("diagramWithContainer");
}
/**
* Makes sure that the label on border of a node is moved when only its location is changed (nothing else is
* changed).
*/
public void testArrangeAllResultWhenOnlyABorderLabelShouldBeMoved() {
openDiagram("diagramWithJustALabelOnBorderMove");
// Get locations of MyClass1 and of attribute1 (they should not be moved in this test, already correctly
// located))
AbstractDiagramContainerEditPart nodeEditPart = getEditPart("MyClass1", AbstractDiagramContainerEditPart.class);
Rectangle nodeBounds = nodeEditPart.getFigure().getBounds().getCopy();
AbstractDiagramBorderNodeEditPart portEditPart = getEditPart("attribute1", AbstractDiagramBorderNodeEditPart.class);
Rectangle borderNodeBounds = portEditPart.getFigure().getBounds().getCopy();
// Launch an arrange all
arrangeAll((DiagramEditor) editorPart);
assertEquals("The node for \"MyClass1\" should not move during this test (data corrupted or behavior unexpected).", nodeBounds, nodeEditPart.getFigure().getBounds().getCopy());
assertEquals("The border node for \"attribute1\" should not move during this test (data corrupted or behavior unexpected).", borderNodeBounds, portEditPart.getFigure().getBounds().getCopy());
// Check the label location
boolean labelFound = false;
for (Object portChildObj : portEditPart.getChildren()) {
if (portChildObj instanceof IGraphicalEditPart) {
IFigure labelFigure = ((IGraphicalEditPart) portChildObj).getFigure();
String text = null;
if (labelFigure instanceof WrappingLabel) {
text = ((WrappingLabel) labelFigure).getText();
} else if (labelFigure instanceof Label) {
text = ((Label) labelFigure).getText();
} else if (labelFigure instanceof SiriusWrapLabel) {
SiriusWrapLabel label = (SiriusWrapLabel) labelFigure;
text = label.getText();
}
if (text != null) {
labelFound = true;
Rectangle labelBounds = labelFigure.getBounds();
assertTrue(((IGraphicalEditPart) portChildObj).getModel() instanceof Node);
Node labelNode = (Node) ((IGraphicalEditPart) portChildObj).getModel();
Location gmfLabelLocation = (Location) labelNode.getLayoutConstraint();
assertEquals("The x GMF coordinate of the label of the border node does not correspond to a centered location.", -(labelBounds.width() - borderNodeBounds.width()) / 2,
gmfLabelLocation.getX(), 1);
assertEquals("The y GMF coordinate of the label of the border node does not correspond to a location under its border node.", borderNodeBounds.height() + 1,
gmfLabelLocation.getY());
assertEquals("Even if GMF coordinates are OK, the label of the border node is visually not horizontally centered on its border node (draw2d x coordinate).",
labelBounds.getCenter().x(), borderNodeBounds.getCenter().x());
assertEquals("Even if GMF coordinates are OK, the label of the border node is visually not under the bottom side of its border node (draw2d y coordinate).",
labelBounds.getTop().y(), borderNodeBounds.getBottom().y() + 1);
}
}
if (!labelFound) {
fail("The label of the border node has not been found.");
}
}
}
/**
* Makes sure that the result of an arrange all respect the following rules:
* <UL>
* <LI>The top left corner of the bounding box is {20, 20}</LI>
* <LI>There is no scrollbar on all containers</LI>
* <LI>All the containers's contents correctly layouted</LI>
* <UL>
*/
public void testArrangeAllResultOfDiagramWithOneChild() {
openDiagram("diagramWithContainerWithOnlyOneChild");
// Launch an arrange all
arrangeAll((DiagramEditor) editorPart);
// Assert that the bounding box coordinates of all elements are {20, 20}
// Compute primary edit parts (first level edit parts of the container)
List<?> primaryEditParts = getPrimaryEditParts(editorPart.getDiagramEditPart());
List<IGraphicalEditPart> primaryGraphicalEditParts = Lists.newArrayList(Iterables.filter(primaryEditParts, IGraphicalEditPart.class));
Rectangle boundingbox = DiagramImageUtils.calculateImageRectangle(primaryGraphicalEditParts, 0, new Dimension(0, 0));
assertEquals("Wrong x coordinate for the bounding box of all diagram elements.", ResetOriginChangeModelOperation.MARGIN, boundingbox.x());
assertEquals("Wrong y coordinate for the bounding box of all diagram elements.", ResetOriginChangeModelOperation.MARGIN, boundingbox.y());
// Assert that there is no scroll bar on all containers
assertNoVisibleScrollBar(getEditPart("p1", IDiagramContainerEditPart.class));
// Assert that content of all containers is "correctly layouted"
assertAlignCentered(50, "Class1_1", "Class1_2");
}
/**
* Makes sure that the result of an arrange selection on one container respect the following rules:
* <UL>
* <LI>No scroll bar in the container (container resized)</LI>
* <LI>Container is not moved</LI>
* <LI>Container's content is correctly layouted</LI>
* <UL>
*/
public void testArrangeSelectionResultOnOneContainerInDiagram() {
testArrangeSelectionResultOnOneContainerInDiagram("diagramWithContainer");
}
/**
* Makes sure that the result of an arrange selection on one container respect the following rules:
* <UL>
* <LI>No scroll bar in the container (container resized)</LI>
* <LI>Container is not moved</LI>
* <LI>Container's content is correctly layouted</LI>
* <UL>
*/
public void testArrangeSelectionResultOnOneContainerInAnotherContainer() {
testArrangeSelectionResultOnOneContainerInAnotherContainer("diagramWithContainer");
}
/**
* Makes sure that the result of an arrange selection on one container respect the following rules:
* <UL>
* <LI>No scroll bar in the container (container resized)</LI>
* <LI>Container is not moved</LI>
* <LI>Container's content is correctly layouted</LI>
* <UL>
*/
public void testArrangeSelectionResultOnOneContainerWithBorderNode() {
testArrangeSelectionResultOnOneContainerWithBorderNode("diagramWithContainer");
}
/**
* Makes sure that the result of an arrange selection on two containers respect the following rules:
* <UL>
* <LI>The top-left corner of bounding box of selected elements remains the same</LI>
* <LI>Selected elements are layouted according to each others (but by ignoring other not selected elements,
* potential overlap with these elements)</LI>
* <LI>The content of the selected container is correctly layouted</LI>
* <UL>
*/
public void testArrangeSelectionResultOnTwoContainers() {
testArrangeSelectionResultOnTwoContainers("diagramWithContainer");
}
/**
* Makes sure that the result of an arrange selection of a container and some of its children respect the following
* rules:
* <UL>
* <LI>Same rules of arrange selection on only the container</LI>
* <UL>
*/
public void testArrangeSelectionResultOnOneContainerAndSomeOfItsChildren() {
testArrangeSelectionResultOnOneContainerAndSomeOfItsChildren("diagramWithContainer");
}
/**
* Makes sure that the result of an arrange selection of some children of a container respect the following rules:
* <UL>
* <LI>The top-left corner of bounding box of selected elements remains the same</LI>
* <LI>Selected elements are layouted according to each others (but by ignoring other not selected elements,
* potential overlap with these elements)</LI>
* <LI>The container size and location are not changed.</LI>
* <UL>
*/
public void testArrangeSelectionResultOnSomeContainerChildren() {
testArrangeSelectionResultOnSomeContainerChildren("diagramWithContainer");
}
/**
* Makes sure that the result of an arrange selection of some children of a container (contained in another
* container) respect the following rules:
* <UL>
* <LI>The top-left corner of bounding box of selected elements remains the same</LI>
* <LI>Selected elements are layouted according to each others (but by ignoring other not selected elements,
* potential overlap with these elements)</LI>
* <LI>The container size and location are not changed.</LI>
* <UL>
*/
public void testArrangeSelectionResultOnSomeContainerChildren_ContainedInAContainer() {
testArrangeSelectionResultOnSomeContainerChildren_ContainedInAContainer("diagramWithContainer");
}
/**
* Makes sure that the result of an arrange selection of a container and some children of other container respect
* the following rules:
* <UL>
* <LI>No rules: No layout is perform as this kind of arrange selection is forbidden (see comment in method
* org.eclipse.gmf.runtime.diagram.ui.actions.internal.ArrangeAction.getTargetEditPartForArrangeSelection(List)).</LI>
* <UL>
*/
public void testArrangeSelectionResultOnAContainerAndSomeChildrenOfOtherConainer() {
testArrangeSelectionResultOnAContainerAndSomeChildrenOfOtherConainer("diagramWithContainer");
}
/**
* Makes sure that the result of an arrange all respect the following rules:
* <UL>
* <LI>The top left corner of the bounding box is {20, 20}</LI>
* <LI>There is no scrollbar on all containers</LI>
* <LI>All the containers's contents correctly layouted</LI>
* <UL>
*/
public void testArrangeAllResultWithScroll() {
testArrangeAllResult_ForPackageArrangeSelection("diagramWithContainerAndScroll");
}
/**
* Makes sure that the result of an arrange selection on one container respect the following rules:
* <UL>
* <LI>No scroll bar in the container (container resized)</LI>
* <LI>Container is not moved</LI>
* <LI>Container's content is correctly layouted</LI>
* <UL>
*/
public void testArrangeSelectionResultWithScrollOnOneContainerInDiagram() {
testArrangeSelectionResultOnOneContainerInDiagram("diagramWithContainerAndScroll");
}
/**
* Makes sure that the result of an arrange selection on one container respect the following rules:
* <UL>
* <LI>No scroll bar in the container (container resized)</LI>
* <LI>Container is not moved</LI>
* <LI>Container's content is correctly layouted</LI>
* <UL>
*/
public void testArrangeSelectionResultWithScrollOnOneContainerInAnotherContainer() {
testArrangeSelectionResultOnOneContainerInAnotherContainer("diagramWithContainerAndScroll");
}
/**
* Makes sure that the result of an arrange selection on one container respect the following rules:
* <UL>
* <LI>No scroll bar in the container (container resized)</LI>
* <LI>Container is not moved</LI>
* <LI>Container's content is correctly layouted</LI>
* <UL>
*/
public void testArrangeSelectionResultWithScrollOnOneContainerWithBorderNode() {
testArrangeSelectionResultOnOneContainerWithBorderNode("diagramWithContainerAndScroll");
}
/**
* Makes sure that the result of an arrange selection on two containers respect the following rules:
* <UL>
* <LI>The top-left corner of bounding box of selected elements remains the same</LI>
* <LI>Selected elements are layouted according to each others (but by ignoring other not selected elements,
* potential overlap with these elements)</LI>
* <LI>The content of the selected container is correctly layouted</LI>
* <UL>
*/
public void testArrangeSelectionResultWithScrollOnTwoContainers() {
testArrangeSelectionResultOnTwoContainers("diagramWithContainerAndScroll");
}
/**
* Makes sure that the result of an arrange selection of a container and some of its children respect the following
* rules:
* <UL>
* <LI>Same rules of arrange selection on only the container</LI>
* <UL>
*/
public void testArrangeSelectionResultWithScrollOnOneContainerAndSomeOfItsChildren() {
testArrangeSelectionResultOnOneContainerAndSomeOfItsChildren("diagramWithContainerAndScroll");
}
/**
* Makes sure that the result of an arrange selection of some children of a container respect the following rules:
* <UL>
* <LI>The top-left corner of bounding box of selected elements remains the same</LI>
* <LI>Selected elements are layouted according to each others (but by ignoring other not selected elements,
* potential overlap with these elements)</LI>
* <LI>The container size and location are not changed.</LI>
* <UL>
*/
public void testArrangeSelectionResultWithScrollOnSomeContainerChildren() {
testArrangeSelectionResultOnSomeContainerChildren("diagramWithContainerAndScroll");
}
/**
* Makes sure that the result of an arrange selection of some children of a container respect the following rules:
* <UL>
* <LI>The top-left corner of bounding box of selected elements remains the same</LI>
* <LI>Selected elements are layouted according to each others (but by ignoring other not selected elements,
* potential overlap with these elements)</LI>
* <LI>The container size and location are not changed.</LI>
* <UL>
*/
public void testArrangeSelectionResultWithScrollOnSomeContainerChildrenn_ContainedInAContainer() {
testArrangeSelectionResultOnSomeContainerChildren_ContainedInAContainer("diagramWithContainerAndScroll");
}
/**
* Makes sure that the result of an arrange selection of a container and some children of other container respect
* the following rules:
* <UL>
* <LI>No rules: No layout is perform as this kind of arrange selection is forbidden (see comment in method