diff --git a/Jenkinsfile b/Jenkinsfile index cb02f3551..713a6ad80 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -81,17 +81,6 @@ pipeline { } } - stage('Run RCPTT Tests') { - steps { - wrap([$class: 'Xvnc', takeScreenshot: false, useXauthority: true]) { - script { - sh 'mvn -Dmaven.test.failure.ignore=true verify -P rcptt -e' - - } - } - } - } - stage('Publish tests results') { steps { junit allowEmptyResults: true, testResults: '*.xml,**/target/surefire-reports/*.xml' @@ -124,7 +113,7 @@ pipeline { } post { always { - archiveArtifacts artifacts: '**/*.log' + archiveArtifacts artifacts: '**/*.log, **/*.png' } } } \ No newline at end of file diff --git a/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/META-INF/MANIFEST.MF b/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/META-INF/MANIFEST.MF index 2b94cde86..6f4591b51 100644 --- a/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/META-INF/MANIFEST.MF +++ b/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/META-INF/MANIFEST.MF @@ -24,7 +24,8 @@ Require-Bundle: org.junit, org.eclipse.gmf.runtime.draw2d.ui, org.eclipse.gmf.runtime.diagram.ui, org.eclipse.sirius.common, - org.apache.batik.transcoder;bundle-version="1.14.0" + org.apache.batik.transcoder;bundle-version="1.14.0", + org.eclipse.emf.common.ui;bundle-version="2.21.0" Bundle-Vendor: %providerName Import-Package: org.eclipse.core.runtime, org.eclipse.gmf.runtime.diagram.ui.editparts diff --git a/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/models/Test1.aird b/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/models/Test1.aird index 5fbccf828..b313424eb 100644 --- a/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/models/Test1.aird +++ b/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/models/Test1.aird @@ -44,7 +44,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -66,7 +66,7 @@ - + @@ -77,14 +77,14 @@ - + - + @@ -103,7 +103,7 @@ - + @@ -114,7 +114,7 @@ - + @@ -125,7 +125,7 @@ - + @@ -136,10 +136,10 @@ - + - + @@ -280,7 +280,7 @@ - + @@ -291,7 +291,7 @@ - + @@ -302,7 +302,7 @@ - + @@ -313,14 +313,14 @@ - + - + @@ -339,7 +339,7 @@ - + @@ -350,7 +350,7 @@ - + @@ -361,7 +361,7 @@ - + @@ -372,10 +372,10 @@ - + - + @@ -514,7 +514,7 @@ - + @@ -525,7 +525,7 @@ - + @@ -536,7 +536,7 @@ - + @@ -547,14 +547,14 @@ - + - + @@ -573,7 +573,7 @@ - + @@ -584,7 +584,7 @@ - + @@ -595,7 +595,7 @@ - + @@ -606,10 +606,10 @@ - + - + @@ -748,7 +748,7 @@ - + @@ -759,7 +759,7 @@ - + @@ -770,7 +770,7 @@ - + @@ -781,14 +781,14 @@ - + - + @@ -807,7 +807,7 @@ - + @@ -818,7 +818,7 @@ - + @@ -829,7 +829,7 @@ - + @@ -840,10 +840,10 @@ - + - + @@ -854,7 +854,7 @@ - + @@ -1001,7 +1001,7 @@ - + @@ -1012,7 +1012,7 @@ - + @@ -1023,7 +1023,7 @@ - + @@ -1034,14 +1034,14 @@ - + - + @@ -1056,7 +1056,7 @@ - + @@ -1067,7 +1067,7 @@ - + @@ -1078,7 +1078,7 @@ - + @@ -1089,14 +1089,14 @@ - + - + diff --git a/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/src/org/polarsys/kitalpha/sirius/rotativeimage/junit/tests/testcases/RotativeImageDisplayTest.java b/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/src/org/polarsys/kitalpha/sirius/rotativeimage/junit/tests/testcases/RotativeImageDisplayTest.java index 894139a3d..684e1b127 100644 --- a/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/src/org/polarsys/kitalpha/sirius/rotativeimage/junit/tests/testcases/RotativeImageDisplayTest.java +++ b/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/src/org/polarsys/kitalpha/sirius/rotativeimage/junit/tests/testcases/RotativeImageDisplayTest.java @@ -17,14 +17,24 @@ import java.util.Map; import java.util.Map.Entry; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.PositionConstants; +import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.sirius.common.tools.api.resource.ImageFileFormat; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.ui.internal.refresh.listeners.WorkspaceFileResourceChangeListener; import org.eclipse.sirius.diagram.ui.provider.DiagramUIPlugin; import org.eclipse.sirius.diagram.ui.tools.api.image.DiagramImagesPath; +import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager; +import org.eclipse.sirius.ui.business.api.dialect.ExportFormat; +import org.eclipse.sirius.ui.business.api.dialect.ExportFormat.ExportDocumentFormat; +import org.eclipse.sirius.ui.business.api.dialect.ExportFormat.ScalingPolicy; +import org.eclipse.sirius.ui.tools.api.actions.export.SizeTooLargeException; import org.eclipse.sirius.viewpoint.DRepresentationDescriptor; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; @@ -94,6 +104,8 @@ public class RotativeImageDisplayTest extends RotativeSiriusTest { protected void setUp() throws Exception { super.setUp(); Resource.setNonDisposeHandler(null); + setPreferenceAutoRefresh(true); + setPrefereneRefreshOnOpening(true); genericSetUp(TEST_XMI_PATH, TEST_ODESIGN_PATH, TEST_AIRD_PATH); // Set test data @@ -141,6 +153,8 @@ public void testSVGDiagramImages() { DDiagram ddiagram = getDDiagramFromId(repId); DiagramEditor editor = openEditor(ddiagram); + export(ddiagram, session, getProject().getFile("TotoDis.png")); + for (Entry entry : dDiagramElementToPositionConstantRotationSVG.entrySet()) { String elementId = entry.getKey(); int position = entry.getValue(); diff --git a/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/src/org/polarsys/kitalpha/sirius/rotativeimage/junit/tests/testcases/RotativeImageMovementTest.java b/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/src/org/polarsys/kitalpha/sirius/rotativeimage/junit/tests/testcases/RotativeImageMovementTest.java index 9759ec12e..fa8c55048 100644 --- a/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/src/org/polarsys/kitalpha/sirius/rotativeimage/junit/tests/testcases/RotativeImageMovementTest.java +++ b/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/src/org/polarsys/kitalpha/sirius/rotativeimage/junit/tests/testcases/RotativeImageMovementTest.java @@ -14,16 +14,26 @@ import java.util.List; import java.util.stream.Collectors; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.draw2d.IFigure; import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.emf.transaction.RecordingCommand; import org.eclipse.emf.transaction.TransactionalEditingDomain; import org.eclipse.emf.transaction.util.TransactionUtil; +import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; +import org.eclipse.sirius.common.tools.api.resource.ImageFileFormat; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.DDiagramElement; import org.eclipse.sirius.diagram.ui.internal.edit.parts.WorkspaceImageEditPart; +import org.eclipse.sirius.ui.business.api.dialect.DialectUIManager; +import org.eclipse.sirius.ui.business.api.dialect.ExportFormat; +import org.eclipse.sirius.ui.business.api.dialect.ExportFormat.ExportDocumentFormat; +import org.eclipse.sirius.ui.tools.api.actions.export.SizeTooLargeException; import org.eclipse.sirius.viewpoint.DRepresentationDescriptor; import org.eclipse.swt.graphics.Resource; import org.polarsys.kitalpha.sirius.rotativeimage.figures.Rotative4ImagesSVGWorkspaceImageFigure; @@ -60,6 +70,8 @@ public class RotativeImageMovementTest extends RotativeSiriusTest { @Override protected void setUp() throws Exception { super.setUp(); + setPreferenceAutoRefresh(true); + setPrefereneRefreshOnOpening(true); Resource.setNonDisposeHandler(null); genericSetUp(TEST_XMI_PATH, TEST_ODESIGN_PATH, TEST_AIRD_PATH); } @@ -82,7 +94,8 @@ public void testMoveImages() { String figureDocumentKey = ((Rotative4ImagesSVGWorkspaceImageFigure) bottomFigure).getDocumentKey(); assertTrue("Figure should reference uri " + FOURIMAGESICON_PREFIX + "_" + BOTTOM + SVG + " instead uri is " + figureDocumentKey, figureDocumentKey.endsWith(FOURIMAGESICON_PREFIX + "_" + BOTTOM + SVG)); - + + export(ddiagram, session, getProject().getFile("TotoRot.png")); // We change the name of a port. After an Arrange all, it will move to west according to conditional style. closeEditor(editor); DDiagramElement port = getDiagramElementFromUid(ddiagram, BOTTOM_E1_BORDERNODE_ID, DDiagramElement.class); @@ -90,6 +103,7 @@ public void testMoveImages() { editor = openEditor(ddiagram); + export(ddiagram, session, getProject().getFile("TotoRot2.png")); // Check new position bottomFigure = getFigure(ddiagram, BOTTOM_E1_BORDERNODE_ID, editor); assertTrue(bottomFigure instanceof Rotative4ImagesSVGWorkspaceImageFigure); diff --git a/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/src/org/polarsys/kitalpha/sirius/rotativeimage/junit/tests/testcases/RotativeSiriusTest.java b/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/src/org/polarsys/kitalpha/sirius/rotativeimage/junit/tests/testcases/RotativeSiriusTest.java index 967380c4e..99bfe3db1 100644 --- a/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/src/org/polarsys/kitalpha/sirius/rotativeimage/junit/tests/testcases/RotativeSiriusTest.java +++ b/sirius/tests/plugins/org.polarsys.kitalpha.sirius.rotativeimage.junit.tests/src/org/polarsys/kitalpha/sirius/rotativeimage/junit/tests/testcases/RotativeSiriusTest.java @@ -19,6 +19,10 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.draw2d.IFigure; import org.eclipse.emf.ecore.EClass; @@ -26,9 +30,12 @@ import org.eclipse.emf.ecore.EStructuralFeature; import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramEditor; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.sirius.business.api.dialect.DialectManager; +import org.eclipse.sirius.business.api.preferences.SiriusPreferencesKeys; import org.eclipse.sirius.business.api.session.Session; import org.eclipse.sirius.business.api.session.SessionManager; +import org.eclipse.sirius.common.tools.api.resource.ImageFileFormat; import org.eclipse.sirius.diagram.DDiagram; import org.eclipse.sirius.diagram.DDiagramElement; import org.eclipse.sirius.diagram.ui.internal.edit.parts.DNode2EditPart; @@ -36,9 +43,13 @@ 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.dialect.ExportFormat; +import org.eclipse.sirius.ui.business.api.dialect.ExportFormat.ExportDocumentFormat; +import org.eclipse.sirius.ui.business.api.preferences.SiriusUIPreferencesKeys; import org.eclipse.sirius.ui.business.api.session.IEditingSession; import org.eclipse.sirius.ui.business.api.session.SessionUIManager; import org.eclipse.sirius.viewpoint.DRepresentationDescriptor; +import org.eclipse.sirius.viewpoint.provider.SiriusEditPlugin; import org.eclipse.ui.PlatformUI; import org.junit.Assert; @@ -52,6 +63,57 @@ private EStructuralFeature uidFeature(final EClass class1) { return class1.getEStructuralFeature("uid"); } + /** + * Set the auto refresh preference for diagram + * + * @apiNote that this method will affect the running instance (not specific to a given project) + * @see org.eclipse.sirius.business.api.session.Session.getSiriusPreferences + * @param value + */ + public static void setPreferenceAutoRefresh(final boolean value) { + IPreferenceStore preferenceStore = SiriusEditPlugin.getPlugin().getCorePreferenceStore(); + preferenceStore.setValue(SiriusPreferencesKeys.PREF_AUTO_REFRESH.name(), value); + } + + protected static IProject getProject() { + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("toto"); + if (!project.exists()) { + try { + project.create(new NullProgressMonitor()); + } catch (CoreException e) { + e.printStackTrace(); + } + } + if (!project.isOpen()) { + try { + project.open(new NullProgressMonitor()); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + return project; + } + + protected void export(DDiagram ddiagram, Session session, IFile file) { + try { + System.out.println(DialectUIManager.INSTANCE.exportWithResult(ddiagram, session, file.getLocation(), new ExportFormat(ExportDocumentFormat.NONE, ImageFileFormat.PNG), new NullProgressMonitor()).getExportedFiles()); + } catch (Exception e) { + e.printStackTrace(); + } + } + /** + * Set the refresh on opening preference for diagram + * + * @apiNote that this method will affect the running instance (not specific to a given project) + * @see org.eclipse.sirius.business.api.session.Session.getSiriusPreferences + * @param value + */ + public static void setPrefereneRefreshOnOpening(final boolean value) { + IPreferenceStore preferenceStore = SiriusEditPlugin.getPlugin().getPreferenceStore(); + preferenceStore.setValue(SiriusUIPreferencesKeys.PREF_REFRESH_ON_REPRESENTATION_OPENING.name(), value); + } + public DRepresentationDescriptor getRepresentationDescriptor(Session session, String id) { Collection representationDescriptors = DialectManager.INSTANCE .getAllRepresentationDescriptors(session);