From 9e05c37db19061fa09e38bb82298037c62fe1202 Mon Sep 17 00:00:00 2001 From: Vincent Lorenzo Date: Mon, 21 Jul 2014 13:35:25 +0200 Subject: Fix build problems due to new tests plugins --- .../META-INF/MANIFEST.MF | 6 +- .../org/eclipse/papyrus/tests/extra/AllTests.java | 10 +- .../META-INF/MANIFEST.MF | 1 + .../NattableCommonTests.launch | 4 +- .../papyrus/infra/nattable/tests/AllTests.java | 25 -- .../nattable/tests/TableSelectionProviderTest.java | 276 ----------------- .../infra/nattable/tests/tests/AllTests.java | 25 ++ .../tests/tests/TableSelectionProviderTest.java | 277 +++++++++++++++++ .../META-INF/MANIFEST.MF | 2 + .../META-INF/MANIFEST.MF | 1 + .../org.eclipse.papyrus.tests/META-INF/MANIFEST.MF | 3 +- .../test/org/eclipse/papyrus/tests/AllTests.java | 1 + .../META-INF/MANIFEST.MF | 1 + ...eclipse.papyrus.uml.diagram.common.tests.launch | 4 +- .../papyrus/uml/diagram/common/tests/AllTests.java | 25 -- .../diagram/common/tests/CommonBendpointsTest.java | 332 -------------------- .../uml/diagram/common/tests/tests/AllTests.java | 25 ++ .../common/tests/tests/CommonBendpointsTest.java | 333 +++++++++++++++++++++ 18 files changed, 684 insertions(+), 667 deletions(-) delete mode 100644 tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/AllTests.java delete mode 100644 tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/TableSelectionProviderTest.java create mode 100644 tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/AllTests.java create mode 100644 tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/TableSelectionProviderTest.java delete mode 100644 tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/AllTests.java delete mode 100644 tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/CommonBendpointsTest.java create mode 100644 tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java create mode 100644 tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/CommonBendpointsTest.java diff --git a/tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/META-INF/MANIFEST.MF b/tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/META-INF/MANIFEST.MF index 1b92adee520..170f99d69e2 100644 --- a/tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/META-INF/MANIFEST.MF +++ b/tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/META-INF/MANIFEST.MF @@ -12,7 +12,11 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.uml.nattable.tests;bundle-version="0.10.2", org.eclipse.papyrus.sysml.nattable.requirement.tests;bundle-version="0.10.2", org.eclipse.papyrus.infra.nattable.views.editor.tests;bundle-version="0.10.2", - org.eclipse.papyrus.infra.nattable.model.editor.tests;bundle-version="0.10.2" + org.eclipse.papyrus.infra.nattable.model.editor.tests;bundle-version="0.10.2", + org.eclipse.papyrus.infra.nattable.tests;bundle-version="0.10.2", + org.eclipse.papyrus.infra.nattable.views.tests;bundle-version="0.10.2", + org.eclipse.papyrus.sysml.nattable.allocation.tests;bundle-version="0.10.2", + org.eclipse.papyrus.uml.nattable.generic.tests;bundle-version="0.10.2" Bundle-Vendor: Eclipse Modeling Project Bundle-ActivationPolicy: lazy Bundle-Version: 0.10.2.qualifier diff --git a/tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/src/org/eclipse/papyrus/tests/extra/AllTests.java b/tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/src/org/eclipse/papyrus/tests/extra/AllTests.java index f0641cc8436..753b9840b48 100644 --- a/tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/src/org/eclipse/papyrus/tests/extra/AllTests.java +++ b/tests/junit/extraplugins/org.eclipse.papyrus.tests.extra/src/org/eclipse/papyrus/tests/extra/AllTests.java @@ -49,14 +49,18 @@ public class AllTests { /* **************** plugins *********************** */ /* css */ suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.infra.gmfdiag.css.tests.tests.AllTests.class)); - + //nattable tests suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.uml.nattable.tests.tests.AllTests.class)); suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.sysml.nattable.requirement.tests.tests.AllTests.class)); + suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.sysml.nattable.allocation.tests.tests.AllTests.class)); suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.infra.nattable.views.tests.tests.AllTests.class)); suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.infra.nattable.model.editor.tests.tests.AllTests.class)); - - + suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.infra.nattable.views.tests.tests.AllTests.class)); + suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.infra.nattable.tests.tests.AllTests.class)); + suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.uml.nattable.generic.tests.tests.AllTests.class)); + + } /** diff --git a/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/META-INF/MANIFEST.MF b/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/META-INF/MANIFEST.MF index e2d1d795fab..ff15b488496 100644 --- a/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/META-INF/MANIFEST.MF +++ b/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/META-INF/MANIFEST.MF @@ -22,3 +22,4 @@ Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Bundle-Localization: plugin Bundle-Description: T%Bundle-Description +Export-Package: org.eclipse.papyrus.infra.nattable.tests.tests diff --git a/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/NattableCommonTests.launch b/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/NattableCommonTests.launch index d982b1d146d..9732ed6f825 100644 --- a/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/NattableCommonTests.launch +++ b/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/NattableCommonTests.launch @@ -19,7 +19,7 @@ - + @@ -29,7 +29,7 @@ - + diff --git a/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/AllTests.java b/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/AllTests.java deleted file mode 100644 index b50c8135441..00000000000 --- a/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/AllTests.java +++ /dev/null @@ -1,25 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.infra.nattable.tests; - - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Suite.class) -@SuiteClasses({ TableSelectionProviderTest.class }) -public class AllTests { - // JUnit 4 test suite -} diff --git a/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/TableSelectionProviderTest.java b/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/TableSelectionProviderTest.java deleted file mode 100644 index 5e34bfb995d..00000000000 --- a/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/TableSelectionProviderTest.java +++ /dev/null @@ -1,276 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.infra.nattable.tests; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.nebula.widgets.nattable.NatTable; -import org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOffCommand; -import org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOnCommand; -import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; -import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; -import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; -import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel; -import org.eclipse.papyrus.infra.core.services.ServiceException; -import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel; -import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; -import org.eclipse.papyrus.infra.nattable.model.nattable.Table; -import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest; -import org.eclipse.papyrus.uml.tools.model.UmlModel; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.PlatformUI; -import org.eclipse.uml2.uml.Model; -import org.eclipse.uml2.uml.NamedElement; -import org.eclipse.uml2.uml.Package; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.osgi.framework.Bundle; - -/** - * - * @author VL222926 - * - * This class tests the selection provider of the table - * - */ -public class TableSelectionProviderTest extends AbstractEditorTest { - - //TODO : this class could be refactored with other class tests used for table (reveal semantic element) - protected Resource di; - - protected Resource notation; - - protected Resource uml; - - protected Table table; - - protected Model root; - - - private INattableModelManager tableManager; - - private NatTable nattable; - - private NamedElement class1; - - // private NamedElement class2; - - private Package _package; - - private NamedElement nestedClass1; - - private NamedElement nestedClass2; - - /** - * - * Constructor. - * This plugin test the ModelExplorerView - */ - public TableSelectionProviderTest() { - super(); - } - - - private String modelRoot = "model"; - - @Before - public void initTests() throws CoreException, IOException { - try { - initModel("testSelectionProvider", "model", getBundle()); - } catch (Exception e) { - e.printStackTrace(); - } - - ResourceSet set = null; - try { - set = getModelSet(); - } catch (ServiceException e) { - Activator.log.error(e); - } - final List resources = set.getResources(); - - final StringBuffer model_uml = new StringBuffer(this.modelRoot); - model_uml.append("."); - model_uml.append(UmlModel.UML_FILE_EXTENSION); - final StringBuffer model_notation = new StringBuffer(this.modelRoot); - model_notation.append("."); - model_notation.append(NotationModel.NOTATION_FILE_EXTENSION); - final StringBuffer model_di = new StringBuffer(this.modelRoot); - model_di.append("."); - model_di.append(DiModel.DI_FILE_EXTENSION); - for(Resource current : resources) { - if(current.getURI().lastSegment().equals(model_uml.toString())) { - this.uml = current; - } else if(current.getURI().lastSegment().equals(model_notation.toString())) { - this.notation = current; - } else if(current.getURI().lastSegment().equals(model_di.toString())) { - this.di = current; - } - - - } - this.table = (Table)this.notation.getAllContents().next(); - this.root = (Model)this.uml.getContents().get(0); - - this.tableManager = (INattableModelManager)this.editor.getAdapter(INattableModelManager.class); - this.nattable = (NatTable)((IAdaptable)this.tableManager).getAdapter(NatTable.class); - - this.class1 = this.root.getMember("Class1"); - // this.class2 = this.root.getMember("Class2"); - this._package = (Package)this.root.getMember("Package"); - this.nestedClass1 = this._package.getMember("NestedClass1"); - this.nestedClass2 = this._package.getMember("NestedClass2"); - } - - - /** - * test the selection of a single row - */ - @Test - public void testRowSelection() { - SelectionLayer selectionLayer = this.tableManager.getBodyLayerStack().getSelectionLayer(); - selectionLayer.clear(); - Assert.assertTrue(getCurrentSelection().isEmpty()); - this.nattable.doCommand(new TurnViewportOffCommand()); - this.nattable.doCommand(new SelectRowsCommand(this.nattable, 2, 3, false, false));//select the row representing class1 - this.nattable.doCommand(new TurnViewportOnCommand()); - final List wantedSelection = new ArrayList(); - wantedSelection.add(this.class1); - verifyCurrentSelection(wantedSelection); - } - - /** - * Test the selection of several rows - */ - @Test - public void test_RowSelectionWithCTRL() { - SelectionLayer selectionLayer = this.tableManager.getBodyLayerStack().getSelectionLayer(); - selectionLayer.clear(); - Assert.assertTrue(getCurrentSelection().isEmpty()); - Assert.assertTrue(getCurrentSelection().isEmpty()); - this.nattable.doCommand(new TurnViewportOffCommand()); - this.nattable.doCommand(new SelectRowsCommand(this.nattable, 2, 3, false, false));//select the row representing class1 - this.nattable.doCommand(new SelectRowsCommand(this.nattable, 2, 5, false, true));//select the row representing package - this.nattable.doCommand(new TurnViewportOnCommand()); - final List wantedSelection = new ArrayList(); - wantedSelection.add(this._package); - wantedSelection.add(this.class1); - verifyCurrentSelection(wantedSelection); - } - - /** - * test the selection of one row, followed by the selection of a cell, with CTRL - */ - @Test - public void test_RowThenCellSelection() { - SelectionLayer selectionLayer = this.tableManager.getBodyLayerStack().getSelectionLayer(); - selectionLayer.clear(); - Assert.assertTrue(getCurrentSelection().isEmpty()); - this.nattable.doCommand(new TurnViewportOffCommand()); - this.nattable.doCommand(new SelectRowsCommand(this.nattable, 2, 3, false, false));//select the row representing class1 - this.nattable.doCommand(new SelectCellCommand(this.nattable, 5, 5, false, true));//select the cell package/members - this.nattable.doCommand(new TurnViewportOnCommand()); - final List wantedSelection = new ArrayList(); - wantedSelection.add(this.class1); - wantedSelection.add(this.nestedClass1); - wantedSelection.add(this.nestedClass2); - verifyCurrentSelection(wantedSelection); - } - - /** - * test the selection of one cell, followed by the selection of one row, with CTRL - */ - @Test - public void test_CellThenRowSelection() { - SelectionLayer selectionLayer = this.tableManager.getBodyLayerStack().getSelectionLayer(); - selectionLayer.clear(); - Assert.assertTrue(getCurrentSelection().isEmpty()); - this.nattable.doCommand(new TurnViewportOffCommand()); - this.nattable.doCommand(new SelectCellCommand(this.nattable, 5, 5, false, false));//select the cell package/members - this.nattable.doCommand(new SelectRowsCommand(this.nattable, 2, 3, false, true));//select the row representing class1 - this.nattable.doCommand(new TurnViewportOnCommand()); - final List wantedSelection = new ArrayList(); - wantedSelection.add(this.class1); - wantedSelection.add(this.nestedClass1); - wantedSelection.add(this.nestedClass2); - verifyCurrentSelection(wantedSelection); - } - - /** - * - * @param wantedSelection - * compare the wanted selection and the current selection - */ - protected void verifyCurrentSelection(final List wantedSelection) { - ISelection selection = getCurrentSelection(); - if(selection instanceof IStructuredSelection) { - List currentSelection = ((IStructuredSelection)selection).toList(); - Assert.assertEquals(wantedSelection.size(), currentSelection.size()); - for(Object current : currentSelection) { - Assert.assertTrue(wantedSelection.contains(current)); - } - } - } - - /** - * - * @return - * the current eclipse selection - */ - protected ISelection getCurrentSelection() { - return getSelectionService().getSelection(); - } - - /** - * - * @return - * the selection service - */ - protected ISelectionService getSelectionService() { - return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); - } - - - - /** - * - * @see org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest#getBundle() - * - * @return - */ - @Override - protected Bundle getBundle() { - return Activator.getDefault().getBundle(); - } - - /** - * - * @see org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest#getSourcePath() - * - * @return - */ - @Override - protected String getSourcePath() { - return "resources/"; - } -} diff --git a/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/AllTests.java b/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/AllTests.java new file mode 100644 index 00000000000..c118a8ed3cf --- /dev/null +++ b/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/AllTests.java @@ -0,0 +1,25 @@ +/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.nattable.tests.tests; + + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ TableSelectionProviderTest.class }) +public class AllTests { + // JUnit 4 test suite +} diff --git a/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/TableSelectionProviderTest.java b/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/TableSelectionProviderTest.java new file mode 100644 index 00000000000..85e313ab087 --- /dev/null +++ b/tests/junit/extraplugins/table/org.eclipse.papyrus.infra.nattable.tests/src/org/eclipse/papyrus/infra/nattable/tests/tests/TableSelectionProviderTest.java @@ -0,0 +1,277 @@ +/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.infra.nattable.tests.tests; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.nebula.widgets.nattable.NatTable; +import org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOffCommand; +import org.eclipse.nebula.widgets.nattable.print.command.TurnViewportOnCommand; +import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectCellCommand; +import org.eclipse.nebula.widgets.nattable.selection.command.SelectRowsCommand; +import org.eclipse.papyrus.infra.core.resource.sasheditor.DiModel; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.gmfdiag.common.model.NotationModel; +import org.eclipse.papyrus.infra.nattable.manager.table.INattableModelManager; +import org.eclipse.papyrus.infra.nattable.model.nattable.Table; +import org.eclipse.papyrus.infra.nattable.tests.Activator; +import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest; +import org.eclipse.papyrus.uml.tools.model.UmlModel; +import org.eclipse.ui.ISelectionService; +import org.eclipse.ui.PlatformUI; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.NamedElement; +import org.eclipse.uml2.uml.Package; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.osgi.framework.Bundle; + +/** + * + * @author VL222926 + * + * This class tests the selection provider of the table + * + */ +public class TableSelectionProviderTest extends AbstractEditorTest { + + //TODO : this class could be refactored with other class tests used for table (reveal semantic element) + protected Resource di; + + protected Resource notation; + + protected Resource uml; + + protected Table table; + + protected Model root; + + + private INattableModelManager tableManager; + + private NatTable nattable; + + private NamedElement class1; + + // private NamedElement class2; + + private Package _package; + + private NamedElement nestedClass1; + + private NamedElement nestedClass2; + + /** + * + * Constructor. + * This plugin test the ModelExplorerView + */ + public TableSelectionProviderTest() { + super(); + } + + + private String modelRoot = "model"; + + @Before + public void initTests() throws CoreException, IOException { + try { + initModel("testSelectionProvider", "model", getBundle()); + } catch (Exception e) { + e.printStackTrace(); + } + + ResourceSet set = null; + try { + set = getModelSet(); + } catch (ServiceException e) { + Activator.log.error(e); + } + final List resources = set.getResources(); + + final StringBuffer model_uml = new StringBuffer(this.modelRoot); + model_uml.append("."); + model_uml.append(UmlModel.UML_FILE_EXTENSION); + final StringBuffer model_notation = new StringBuffer(this.modelRoot); + model_notation.append("."); + model_notation.append(NotationModel.NOTATION_FILE_EXTENSION); + final StringBuffer model_di = new StringBuffer(this.modelRoot); + model_di.append("."); + model_di.append(DiModel.DI_FILE_EXTENSION); + for(Resource current : resources) { + if(current.getURI().lastSegment().equals(model_uml.toString())) { + this.uml = current; + } else if(current.getURI().lastSegment().equals(model_notation.toString())) { + this.notation = current; + } else if(current.getURI().lastSegment().equals(model_di.toString())) { + this.di = current; + } + + + } + this.table = (Table)this.notation.getAllContents().next(); + this.root = (Model)this.uml.getContents().get(0); + + this.tableManager = (INattableModelManager)this.editor.getAdapter(INattableModelManager.class); + this.nattable = (NatTable)((IAdaptable)this.tableManager).getAdapter(NatTable.class); + + this.class1 = this.root.getMember("Class1"); + // this.class2 = this.root.getMember("Class2"); + this._package = (Package)this.root.getMember("Package"); + this.nestedClass1 = this._package.getMember("NestedClass1"); + this.nestedClass2 = this._package.getMember("NestedClass2"); + } + + + /** + * test the selection of a single row + */ + @Test + public void testRowSelection() { + SelectionLayer selectionLayer = this.tableManager.getBodyLayerStack().getSelectionLayer(); + selectionLayer.clear(); + Assert.assertTrue(getCurrentSelection().isEmpty()); + this.nattable.doCommand(new TurnViewportOffCommand()); + this.nattable.doCommand(new SelectRowsCommand(this.nattable, 2, 3, false, false));//select the row representing class1 + this.nattable.doCommand(new TurnViewportOnCommand()); + final List wantedSelection = new ArrayList(); + wantedSelection.add(this.class1); + verifyCurrentSelection(wantedSelection); + } + + /** + * Test the selection of several rows + */ + @Test + public void test_RowSelectionWithCTRL() { + SelectionLayer selectionLayer = this.tableManager.getBodyLayerStack().getSelectionLayer(); + selectionLayer.clear(); + Assert.assertTrue(getCurrentSelection().isEmpty()); + Assert.assertTrue(getCurrentSelection().isEmpty()); + this.nattable.doCommand(new TurnViewportOffCommand()); + this.nattable.doCommand(new SelectRowsCommand(this.nattable, 2, 3, false, false));//select the row representing class1 + this.nattable.doCommand(new SelectRowsCommand(this.nattable, 2, 5, false, true));//select the row representing package + this.nattable.doCommand(new TurnViewportOnCommand()); + final List wantedSelection = new ArrayList(); + wantedSelection.add(this._package); + wantedSelection.add(this.class1); + verifyCurrentSelection(wantedSelection); + } + + /** + * test the selection of one row, followed by the selection of a cell, with CTRL + */ + @Test + public void test_RowThenCellSelection() { + SelectionLayer selectionLayer = this.tableManager.getBodyLayerStack().getSelectionLayer(); + selectionLayer.clear(); + Assert.assertTrue(getCurrentSelection().isEmpty()); + this.nattable.doCommand(new TurnViewportOffCommand()); + this.nattable.doCommand(new SelectRowsCommand(this.nattable, 2, 3, false, false));//select the row representing class1 + this.nattable.doCommand(new SelectCellCommand(this.nattable, 5, 5, false, true));//select the cell package/members + this.nattable.doCommand(new TurnViewportOnCommand()); + final List wantedSelection = new ArrayList(); + wantedSelection.add(this.class1); + wantedSelection.add(this.nestedClass1); + wantedSelection.add(this.nestedClass2); + verifyCurrentSelection(wantedSelection); + } + + /** + * test the selection of one cell, followed by the selection of one row, with CTRL + */ + @Test + public void test_CellThenRowSelection() { + SelectionLayer selectionLayer = this.tableManager.getBodyLayerStack().getSelectionLayer(); + selectionLayer.clear(); + Assert.assertTrue(getCurrentSelection().isEmpty()); + this.nattable.doCommand(new TurnViewportOffCommand()); + this.nattable.doCommand(new SelectCellCommand(this.nattable, 5, 5, false, false));//select the cell package/members + this.nattable.doCommand(new SelectRowsCommand(this.nattable, 2, 3, false, true));//select the row representing class1 + this.nattable.doCommand(new TurnViewportOnCommand()); + final List wantedSelection = new ArrayList(); + wantedSelection.add(this.class1); + wantedSelection.add(this.nestedClass1); + wantedSelection.add(this.nestedClass2); + verifyCurrentSelection(wantedSelection); + } + + /** + * + * @param wantedSelection + * compare the wanted selection and the current selection + */ + protected void verifyCurrentSelection(final List wantedSelection) { + ISelection selection = getCurrentSelection(); + if(selection instanceof IStructuredSelection) { + List currentSelection = ((IStructuredSelection)selection).toList(); + Assert.assertEquals(wantedSelection.size(), currentSelection.size()); + for(Object current : currentSelection) { + Assert.assertTrue(wantedSelection.contains(current)); + } + } + } + + /** + * + * @return + * the current eclipse selection + */ + protected ISelection getCurrentSelection() { + return getSelectionService().getSelection(); + } + + /** + * + * @return + * the selection service + */ + protected ISelectionService getSelectionService() { + return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); + } + + + + /** + * + * @see org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest#getBundle() + * + * @return + */ + @Override + protected Bundle getBundle() { + return Activator.getDefault().getBundle(); + } + + /** + * + * @see org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest#getSourcePath() + * + * @return + */ + @Override + protected String getSourcePath() { + return "resources/"; + } +} diff --git a/tests/junit/extraplugins/table/org.eclipse.papyrus.sysml.nattable.allocation.tests/META-INF/MANIFEST.MF b/tests/junit/extraplugins/table/org.eclipse.papyrus.sysml.nattable.allocation.tests/META-INF/MANIFEST.MF index c27c1742805..5f449983d41 100755 --- a/tests/junit/extraplugins/table/org.eclipse.papyrus.sysml.nattable.allocation.tests/META-INF/MANIFEST.MF +++ b/tests/junit/extraplugins/table/org.eclipse.papyrus.sysml.nattable.allocation.tests/META-INF/MANIFEST.MF @@ -19,3 +19,5 @@ Require-Bundle: org.eclipse.ui, Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Bundle-Vendor: %Bundle-Vendor +Export-Package: org.eclipse.papyrus.sysml.nattable.allocation.tests, + org.eclipse.papyrus.sysml.nattable.allocation.tests.tests diff --git a/tests/junit/extraplugins/table/org.eclipse.papyrus.uml.nattable.generic.tests/META-INF/MANIFEST.MF b/tests/junit/extraplugins/table/org.eclipse.papyrus.uml.nattable.generic.tests/META-INF/MANIFEST.MF index ed733fdbf84..d09919a4489 100755 --- a/tests/junit/extraplugins/table/org.eclipse.papyrus.uml.nattable.generic.tests/META-INF/MANIFEST.MF +++ b/tests/junit/extraplugins/table/org.eclipse.papyrus.uml.nattable.generic.tests/META-INF/MANIFEST.MF @@ -22,3 +22,4 @@ Require-Bundle: org.junit;bundle-version="4.11.0", Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ActivationPolicy: lazy Bundle-Vendor: %Bundle-Vendor +Export-Package: org.eclipse.papyrus.uml.nattable.generic.tests.tests diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF index d19c63bc9d1..ce7bf1092f2 100644 --- a/tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/core/org.eclipse.papyrus.tests/META-INF/MANIFEST.MF @@ -39,7 +39,8 @@ Require-Bundle: org.eclipse.ui, org.eclipse.papyrus.uml.diagram.interactionoverview.tests;bundle-version="0.10.2", org.eclipse.papyrus.uml.diagram.sequence.tests;bundle-version="0.10.2", org.eclipse.papyrus.uml.diagram.composite.tests;bundle-version="0.10.2", - org.eclipse.papyrus.infra.extendedtypes.tests;bundle-version="0.10.2" + org.eclipse.papyrus.infra.extendedtypes.tests;bundle-version="0.10.2", + org.eclipse.papyrus.uml.diagram.common.tests;bundle-version="0.10.2" Bundle-Vendor: %providerName Bundle-ActivationPolicy: lazy Bundle-Version: 0.10.2.qualifier diff --git a/tests/junit/plugins/core/org.eclipse.papyrus.tests/test/org/eclipse/papyrus/tests/AllTests.java b/tests/junit/plugins/core/org.eclipse.papyrus.tests/test/org/eclipse/papyrus/tests/AllTests.java index 7b8933a19e5..577a22f552b 100644 --- a/tests/junit/plugins/core/org.eclipse.papyrus.tests/test/org/eclipse/papyrus/tests/AllTests.java +++ b/tests/junit/plugins/core/org.eclipse.papyrus.tests/test/org/eclipse/papyrus/tests/AllTests.java @@ -73,6 +73,7 @@ public class AllTests { suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.uml.diagram.timing.tests.AllTests.class)); suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.uml.diagram.usecase.tests.AllTests.class)); + suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.uml.diagram.common.tests.tests.AllTests.class)); //suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.uml.diagram.sequence.tests.AllTests.class)); //Disabled. They currently do not run on Hudson //suiteClasses.add(new PluginTestSuiteClass(org.eclipse.papyrus.uml.diagram.interactionoverview.tests.AllTests.class)); //Disabled. They currently do not run on Hudson // diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/META-INF/MANIFEST.MF b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/META-INF/MANIFEST.MF index e2134a1e154..524076b5585 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/META-INF/MANIFEST.MF +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/META-INF/MANIFEST.MF @@ -21,3 +21,4 @@ Bundle-Vendor: %Bundle-Vendor Bundle-Name: %Bundle-Name Bundle-Localization: plugin Bundle-Description: This plugin provides tests for the papyrus plugin UML Diagram Common +Export-Package: org.eclipse.papyrus.uml.diagram.common.tests.tests diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/org.eclipse.papyrus.uml.diagram.common.tests.launch b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/org.eclipse.papyrus.uml.diagram.common.tests.launch index 41a4ea4a273..3f0570aa483 100644 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/org.eclipse.papyrus.uml.diagram.common.tests.launch +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/org.eclipse.papyrus.uml.diagram.common.tests.launch @@ -14,7 +14,7 @@ - + @@ -24,7 +24,7 @@ - + diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/AllTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/AllTests.java deleted file mode 100644 index 4adfdfb6073..00000000000 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/AllTests.java +++ /dev/null @@ -1,25 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.tests; - - -import org.junit.runner.RunWith; -import org.junit.runners.Suite; -import org.junit.runners.Suite.SuiteClasses; - -@RunWith(Suite.class) -@SuiteClasses({ CommonBendpointsTest.class }) -public class AllTests { - // JUnit 4 test suite -} diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/CommonBendpointsTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/CommonBendpointsTest.java deleted file mode 100644 index 8713584af73..00000000000 --- a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/CommonBendpointsTest.java +++ /dev/null @@ -1,332 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2014 CEA LIST. - * - * - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation - * - *****************************************************************************/ -package org.eclipse.papyrus.uml.diagram.common.tests; - -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.draw2d.IFigure; -import org.eclipse.draw2d.geometry.Point; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.ecore.resource.ResourceSet; -import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.papyrus.infra.core.services.ServiceException; -import org.eclipse.papyrus.infra.gmfdiag.common.figure.edge.PapyrusEdgeFigure; -import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement; -import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest; -import org.eclipse.ui.ISelectionService; -import org.eclipse.ui.PlatformUI; -import org.eclipse.uml2.uml.Model; -import org.eclipse.uml2.uml.NamedElement; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; -import org.osgi.framework.Bundle; - -/** - * - * @author VL222926 - * - */ -public class CommonBendpointsTest extends AbstractEditorTest { - - protected Resource di; - - protected Resource notation; - - protected Resource uml; - - protected Diagram diag; - - protected Model root; - - /** - * - * Constructor. - * This plugin test the ModelExplorerView - */ - public CommonBendpointsTest() { - super(); - } - - - @Before - public void initTests() throws CoreException, IOException { - try { - initModel("testBendpoints", "model", getBundle()); //$NON-NLS-1$ //$NON-NLS-2$ - } catch (Exception e) { - e.printStackTrace(); - } - - ResourceSet set = null; - try { - set = getModelSet(); - } catch (ServiceException e) { - e.printStackTrace(); - } - // IEditorInput input = this.editor.getEditorInput(); - List resources = set.getResources(); - for(Resource current : resources) { - // current.load(null); - if(current.getURI().lastSegment().equals("model.uml")) { //$NON-NLS-1$ - this.uml = current; - } else if(current.getURI().lastSegment().equals("model.notation")) { //$NON-NLS-1$ - this.notation = current; - } else if(current.getURI().lastSegment().equals("model.di")) { //$NON-NLS-1$ - this.di = current; - } - - - } - this.diag = (Diagram)this.notation.getAllContents().next(); - this.root = (Model)this.uml.getContents().get(0); - } - - protected void verifyCommonBendpoints(final List wantedPoints, final Collection pointsFound1) { - List pointsFound = new ArrayList(pointsFound1); - Assert.assertEquals(wantedPoints.size(), pointsFound.size()); - for(Point current : pointsFound) { - Assert.assertTrue(wantedPoints.contains(current)); - } - - } - - /** - * - * @param name - * the name of a uml element - * @return - * the link figure for the element - */ - protected PapyrusEdgeFigure getLinkFigureFor(final String name) { - final NamedElement element = this.root.getMember(name); - Assert.assertTrue(this.editor.getActiveEditor() instanceof IRevealSemanticElement); - ((IRevealSemanticElement)this.editor.getActiveEditor()).revealSemanticElement(Collections.singletonList(element)); - final ISelection selection = getSelectionService().getSelection(); - Assert.assertTrue(selection instanceof IStructuredSelection); - Object current = ((IStructuredSelection)selection).getFirstElement(); - Assert.assertTrue(current instanceof IGraphicalEditPart); - final IFigure fig = ((IGraphicalEditPart)current).getFigure(); - Assert.assertTrue(fig instanceof PapyrusEdgeFigure); - return (PapyrusEdgeFigure)fig; - } - - @Test - public void commonBendpoints_Test1() { - List wantedResult = new ArrayList(); - wantedResult.add(new Point(300, 140)); - - PapyrusEdgeFigure fig = getLinkFigureFor("Association1"); //$NON-NLS-1$ - Collection res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - - - fig = getLinkFigureFor("Association2"); //$NON-NLS-1$ - res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - - - } - - //no common bendpoints when the link do not share their source or their target - @Test - public void commonBendpoints_Test2() { - List wantedResult = new ArrayList(); - - PapyrusEdgeFigure fig = getLinkFigureFor("Association3"); //$NON-NLS-1$ - Collection res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - - - fig = getLinkFigureFor("Association4"); //$NON-NLS-1$ - res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - } - - @Test - public void commonBendpoints_Test3() { - List wantedResult = new ArrayList(); - wantedResult.add(new Point(280, 840)); - wantedResult.add(new Point(280, 920)); - - PapyrusEdgeFigure fig = getLinkFigureFor("Association6"); //$NON-NLS-1$ - Collection res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - - - fig = getLinkFigureFor("Association7"); //$NON-NLS-1$ - res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - } - - //no common bendpoints between 2 kind of uml link - @Test - public void testCommonbendpoints_Test4() { - List wantedResult = new ArrayList(); - - PapyrusEdgeFigure fig = getLinkFigureFor("Association5"); //$NON-NLS-1$ - Collection res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - - - fig = getLinkFigureFor("Dependency1"); //$NON-NLS-1$ - res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - } - - @Test - public void commonBendpoints_Test5() { - List wantedResult = new ArrayList(); - wantedResult.add(new Point(1000, 940)); - PapyrusEdgeFigure fig = getLinkFigureFor("Association8"); //$NON-NLS-1$ - Collection res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - - - fig = getLinkFigureFor("Association9"); //$NON-NLS-1$ - res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - } - - @Test - public void commonBendpoints_Test6() { - List wantedResult = new ArrayList(); - wantedResult.add(new Point(260, 1200)); - wantedResult.add(new Point(360, 1280)); - wantedResult.add(new Point(380, 1220)); - PapyrusEdgeFigure fig = getLinkFigureFor("Association10"); //$NON-NLS-1$ - Collection res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - - - fig = getLinkFigureFor("Association1&"); //$NON-NLS-1$ - res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - } - - @Test - public void testCommonbendpoints_Test7() { - List wantedResult = new ArrayList(); - - PapyrusEdgeFigure fig = getLinkFigureFor("Association12"); //$NON-NLS-1$ - Collection res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - - - fig = getLinkFigureFor("Association13"); //$NON-NLS-1$ - res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - } - - @Test - public void testCommonbendpoints_Test8() { - List wantedResult = new ArrayList(); - - PapyrusEdgeFigure fig = getLinkFigureFor("Association14"); //$NON-NLS-1$ - Collection res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - - - fig = getLinkFigureFor("Association15"); //$NON-NLS-1$ - res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - } - - @Test - public void testCommonbendpoints_Test9() { - List wantedResult = new ArrayList(); - - PapyrusEdgeFigure fig = getLinkFigureFor("Association22"); //$NON-NLS-1$ - Collection res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - - - fig = getLinkFigureFor("Association23"); //$NON-NLS-1$ - res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - } - - @Test - public void testCommonbendpoints_Test10() { - List wantedResult = new ArrayList(); - wantedResult.add(new Point(280, 1900)); - wantedResult.add(new Point(280, 1940)); - wantedResult.add(new Point(280, 2000)); - wantedResult.add(new Point(280, 2040)); - - PapyrusEdgeFigure fig = getLinkFigureFor("Association16"); //$NON-NLS-1$ - Collection res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - - - fig = getLinkFigureFor("Association17"); //$NON-NLS-1$ - res = fig.getCommonBendpointsToDraw(); - verifyCommonBendpoints(wantedResult, res); - } - - @Test - public void testCommonbendpoints_Test11() { - - PapyrusEdgeFigure fig = getLinkFigureFor("Association19"); //$NON-NLS-1$ - Collection res = fig.getCommonBendpointsToDraw(); - List wantedResult = new ArrayList(); - wantedResult.add(new Point(740, 1980)); - verifyCommonBendpoints(wantedResult, res); - - - fig = getLinkFigureFor("Association20"); //$NON-NLS-1$ - res = fig.getCommonBendpointsToDraw(); - wantedResult = new ArrayList(); - wantedResult.add(new Point(740, 1980)); - wantedResult.add(new Point(780, 2020)); - wantedResult.add(new Point(780, 2060)); - verifyCommonBendpoints(wantedResult, res); - - - fig = getLinkFigureFor("Association21"); //$NON-NLS-1$ - res = fig.getCommonBendpointsToDraw(); - wantedResult = new ArrayList(); - wantedResult.add(new Point(780, 2020)); - wantedResult.add(new Point(780, 2060)); - verifyCommonBendpoints(wantedResult, res); - } - - protected ISelectionService getSelectionService() { - return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); - } - - protected IStructuredSelection getCurrentSelection() { - ISelectionService serv = getSelectionService(); - ISelection selection = serv.getSelection(); - return (IStructuredSelection)selection; - } - - - @Override - protected Bundle getBundle() { - return Activator.getDefault().getBundle(); - } - - @Override - protected String getSourcePath() { - return "resources/"; //$NON-NLS-1$ - } -} diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java new file mode 100644 index 00000000000..f2100327a07 --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/AllTests.java @@ -0,0 +1,25 @@ +/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.tests.tests; + + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.runners.Suite.SuiteClasses; + +@RunWith(Suite.class) +@SuiteClasses({ CommonBendpointsTest.class }) +public class AllTests { + // JUnit 4 test suite +} diff --git a/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/CommonBendpointsTest.java b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/CommonBendpointsTest.java new file mode 100644 index 00000000000..37c8f1c05e8 --- /dev/null +++ b/tests/junit/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.common.tests/src/org/eclipse/papyrus/uml/diagram/common/tests/tests/CommonBendpointsTest.java @@ -0,0 +1,333 @@ +/***************************************************************************** + * Copyright (c) 2014 CEA LIST. + * + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation + * + *****************************************************************************/ +package org.eclipse.papyrus.uml.diagram.common.tests.tests; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.draw2d.IFigure; +import org.eclipse.draw2d.geometry.Point; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart; +import org.eclipse.gmf.runtime.notation.Diagram; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.papyrus.infra.core.services.ServiceException; +import org.eclipse.papyrus.infra.gmfdiag.common.figure.edge.PapyrusEdgeFigure; +import org.eclipse.papyrus.infra.widgets.util.IRevealSemanticElement; +import org.eclipse.papyrus.junit.utils.tests.AbstractEditorTest; +import org.eclipse.papyrus.uml.diagram.common.tests.Activator; +import org.eclipse.ui.ISelectionService; +import org.eclipse.ui.PlatformUI; +import org.eclipse.uml2.uml.Model; +import org.eclipse.uml2.uml.NamedElement; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.osgi.framework.Bundle; + +/** + * + * @author VL222926 + * + */ +public class CommonBendpointsTest extends AbstractEditorTest { + + protected Resource di; + + protected Resource notation; + + protected Resource uml; + + protected Diagram diag; + + protected Model root; + + /** + * + * Constructor. + * This plugin test the ModelExplorerView + */ + public CommonBendpointsTest() { + super(); + } + + + @Before + public void initTests() throws CoreException, IOException { + try { + initModel("testBendpoints", "model", getBundle()); //$NON-NLS-1$ //$NON-NLS-2$ + } catch (Exception e) { + e.printStackTrace(); + } + + ResourceSet set = null; + try { + set = getModelSet(); + } catch (ServiceException e) { + e.printStackTrace(); + } + // IEditorInput input = this.editor.getEditorInput(); + List resources = set.getResources(); + for(Resource current : resources) { + // current.load(null); + if(current.getURI().lastSegment().equals("model.uml")) { //$NON-NLS-1$ + this.uml = current; + } else if(current.getURI().lastSegment().equals("model.notation")) { //$NON-NLS-1$ + this.notation = current; + } else if(current.getURI().lastSegment().equals("model.di")) { //$NON-NLS-1$ + this.di = current; + } + + + } + this.diag = (Diagram)this.notation.getAllContents().next(); + this.root = (Model)this.uml.getContents().get(0); + } + + protected void verifyCommonBendpoints(final List wantedPoints, final Collection pointsFound1) { + List pointsFound = new ArrayList(pointsFound1); + Assert.assertEquals(wantedPoints.size(), pointsFound.size()); + for(Point current : pointsFound) { + Assert.assertTrue(wantedPoints.contains(current)); + } + + } + + /** + * + * @param name + * the name of a uml element + * @return + * the link figure for the element + */ + protected PapyrusEdgeFigure getLinkFigureFor(final String name) { + final NamedElement element = this.root.getMember(name); + Assert.assertTrue(this.editor.getActiveEditor() instanceof IRevealSemanticElement); + ((IRevealSemanticElement)this.editor.getActiveEditor()).revealSemanticElement(Collections.singletonList(element)); + final ISelection selection = getSelectionService().getSelection(); + Assert.assertTrue(selection instanceof IStructuredSelection); + Object current = ((IStructuredSelection)selection).getFirstElement(); + Assert.assertTrue(current instanceof IGraphicalEditPart); + final IFigure fig = ((IGraphicalEditPart)current).getFigure(); + Assert.assertTrue(fig instanceof PapyrusEdgeFigure); + return (PapyrusEdgeFigure)fig; + } + + @Test + public void commonBendpoints_Test1() { + List wantedResult = new ArrayList(); + wantedResult.add(new Point(300, 140)); + + PapyrusEdgeFigure fig = getLinkFigureFor("Association1"); //$NON-NLS-1$ + Collection res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + + + fig = getLinkFigureFor("Association2"); //$NON-NLS-1$ + res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + + + } + + //no common bendpoints when the link do not share their source or their target + @Test + public void commonBendpoints_Test2() { + List wantedResult = new ArrayList(); + + PapyrusEdgeFigure fig = getLinkFigureFor("Association3"); //$NON-NLS-1$ + Collection res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + + + fig = getLinkFigureFor("Association4"); //$NON-NLS-1$ + res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + } + + @Test + public void commonBendpoints_Test3() { + List wantedResult = new ArrayList(); + wantedResult.add(new Point(280, 840)); + wantedResult.add(new Point(280, 920)); + + PapyrusEdgeFigure fig = getLinkFigureFor("Association6"); //$NON-NLS-1$ + Collection res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + + + fig = getLinkFigureFor("Association7"); //$NON-NLS-1$ + res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + } + + //no common bendpoints between 2 kind of uml link + @Test + public void testCommonbendpoints_Test4() { + List wantedResult = new ArrayList(); + + PapyrusEdgeFigure fig = getLinkFigureFor("Association5"); //$NON-NLS-1$ + Collection res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + + + fig = getLinkFigureFor("Dependency1"); //$NON-NLS-1$ + res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + } + + @Test + public void commonBendpoints_Test5() { + List wantedResult = new ArrayList(); + wantedResult.add(new Point(1000, 940)); + PapyrusEdgeFigure fig = getLinkFigureFor("Association8"); //$NON-NLS-1$ + Collection res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + + + fig = getLinkFigureFor("Association9"); //$NON-NLS-1$ + res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + } + + @Test + public void commonBendpoints_Test6() { + List wantedResult = new ArrayList(); + wantedResult.add(new Point(260, 1200)); + wantedResult.add(new Point(360, 1280)); + wantedResult.add(new Point(380, 1220)); + PapyrusEdgeFigure fig = getLinkFigureFor("Association10"); //$NON-NLS-1$ + Collection res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + + + fig = getLinkFigureFor("Association1&"); //$NON-NLS-1$ + res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + } + + @Test + public void testCommonbendpoints_Test7() { + List wantedResult = new ArrayList(); + + PapyrusEdgeFigure fig = getLinkFigureFor("Association12"); //$NON-NLS-1$ + Collection res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + + + fig = getLinkFigureFor("Association13"); //$NON-NLS-1$ + res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + } + + @Test + public void testCommonbendpoints_Test8() { + List wantedResult = new ArrayList(); + + PapyrusEdgeFigure fig = getLinkFigureFor("Association14"); //$NON-NLS-1$ + Collection res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + + + fig = getLinkFigureFor("Association15"); //$NON-NLS-1$ + res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + } + + @Test + public void testCommonbendpoints_Test9() { + List wantedResult = new ArrayList(); + + PapyrusEdgeFigure fig = getLinkFigureFor("Association22"); //$NON-NLS-1$ + Collection res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + + + fig = getLinkFigureFor("Association23"); //$NON-NLS-1$ + res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + } + + @Test + public void testCommonbendpoints_Test10() { + List wantedResult = new ArrayList(); + wantedResult.add(new Point(280, 1900)); + wantedResult.add(new Point(280, 1940)); + wantedResult.add(new Point(280, 2000)); + wantedResult.add(new Point(280, 2040)); + + PapyrusEdgeFigure fig = getLinkFigureFor("Association16"); //$NON-NLS-1$ + Collection res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + + + fig = getLinkFigureFor("Association17"); //$NON-NLS-1$ + res = fig.getCommonBendpointsToDraw(); + verifyCommonBendpoints(wantedResult, res); + } + + @Test + public void testCommonbendpoints_Test11() { + + PapyrusEdgeFigure fig = getLinkFigureFor("Association19"); //$NON-NLS-1$ + Collection res = fig.getCommonBendpointsToDraw(); + List wantedResult = new ArrayList(); + wantedResult.add(new Point(740, 1980)); + verifyCommonBendpoints(wantedResult, res); + + + fig = getLinkFigureFor("Association20"); //$NON-NLS-1$ + res = fig.getCommonBendpointsToDraw(); + wantedResult = new ArrayList(); + wantedResult.add(new Point(740, 1980)); + wantedResult.add(new Point(780, 2020)); + wantedResult.add(new Point(780, 2060)); + verifyCommonBendpoints(wantedResult, res); + + + fig = getLinkFigureFor("Association21"); //$NON-NLS-1$ + res = fig.getCommonBendpointsToDraw(); + wantedResult = new ArrayList(); + wantedResult.add(new Point(780, 2020)); + wantedResult.add(new Point(780, 2060)); + verifyCommonBendpoints(wantedResult, res); + } + + protected ISelectionService getSelectionService() { + return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService(); + } + + protected IStructuredSelection getCurrentSelection() { + ISelectionService serv = getSelectionService(); + ISelection selection = serv.getSelection(); + return (IStructuredSelection)selection; + } + + + @Override + protected Bundle getBundle() { + return Activator.getDefault().getBundle(); + } + + @Override + protected String getSourcePath() { + return "resources/"; //$NON-NLS-1$ + } +} -- cgit v1.2.3