Skip to content

Commit

Permalink
Test
Browse files Browse the repository at this point in the history
  • Loading branch information
pdulth committed May 1, 2024
1 parent 24e631f commit 15c6697
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 14 deletions.
13 changes: 1 addition & 12 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -124,7 +113,7 @@ pipeline {
}
post {
always {
archiveArtifacts artifacts: '**/*.log'
archiveArtifacts artifacts: '**/*.log, **/Toto*'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,22 @@
import java.util.Map;
import java.util.Map.Entry;

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.tools.api.actions.export.SizeTooLargeException;
import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
Expand Down Expand Up @@ -94,6 +102,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
Expand Down Expand Up @@ -141,6 +151,14 @@ public void testSVGDiagramImages() {
DDiagram ddiagram = getDDiagramFromId(repId);
DiagramEditor editor = openEditor(ddiagram);

IPath path = WorkspaceSynchronizer.getFile(session.getSessionResource()).getProject().getFile("TotoDisplay.png").getFullPath();
try {
DialectUIManager.INSTANCE.export(ddiagram, session, path, new ExportFormat(ExportDocumentFormat.NONE, ImageFileFormat.PNG), new NullProgressMonitor());
} catch (SizeTooLargeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

for (Entry<String, Integer> entry : dDiagramElementToPositionConstantRotationSVG.entrySet()) {
String elementId = entry.getKey();
int position = entry.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,25 @@
import java.util.List;
import java.util.stream.Collectors;

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;
Expand Down Expand Up @@ -60,6 +69,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);
}
Expand All @@ -82,14 +93,29 @@ 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));


IPath path = WorkspaceSynchronizer.getFile(session.getSessionResource()).getProject().getFile("TotoRot.png").getFullPath();
try {
DialectUIManager.INSTANCE.export(ddiagram, session, path, new ExportFormat(ExportDocumentFormat.NONE, ImageFileFormat.PNG), new NullProgressMonitor());
} catch (SizeTooLargeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

// 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);
setName(port, "westSideOnly");

editor = openEditor(ddiagram);

path = WorkspaceSynchronizer.getFile(session.getSessionResource()).getProject().getFile("TotoRot2.png").getFullPath();
try {
DialectUIManager.INSTANCE.export(ddiagram, session, path, new ExportFormat(ExportDocumentFormat.NONE, ImageFileFormat.PNG), new NullProgressMonitor());
} catch (SizeTooLargeException e) {
e.printStackTrace();
}

// Check new position
bottomFigure = getFigure(ddiagram, BOTTOM_E1_BORDERNODE_ID, editor);
assertTrue(bottomFigure instanceof Rotative4ImagesSVGWorkspaceImageFigure);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@
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.diagram.DDiagram;
Expand All @@ -36,9 +38,11 @@
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.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;

Expand All @@ -52,6 +56,30 @@ 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);
}

/**
* 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<DRepresentationDescriptor> representationDescriptors = DialectManager.INSTANCE
.getAllRepresentationDescriptors(session);
Expand Down

0 comments on commit 15c6697

Please sign in to comment.