Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpguilet2016-10-18 08:28:11 +0000
committerPierre-Charles David2016-10-19 15:56:05 +0000
commit46535e02c56964b313bd27ebe097a0c0893eeb77 (patch)
tree2838baf70471b809911f0e7c052beeea88abb683
parentc34a7a47620a97d4a4e0ad00240943e2cfe200bd (diff)
downloadorg.eclipse.sirius-46535e02c56964b313bd27ebe097a0c0893eeb77.tar.gz
org.eclipse.sirius-46535e02c56964b313bd27ebe097a0c0893eeb77.tar.xz
org.eclipse.sirius-46535e02c56964b313bd27ebe097a0c0893eeb77.zip
[500253] Add tests corresponding to the fix
-Adds tests on service completion for "service:", Aql and Acceleo -Modified the manifest for testing completion. Removed the direct dependency to org.eclipse.emf.ecore that does not trigger the bug. Bug: 500253 Change-Id: Ifa9661a16c9d3c8c4c4d2a0e4a04ce7833b71e10 Signed-off-by: pguilet <pierre.guilet@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/MANIFEST.MF7
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/ServicesWithDependencies.java40
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/test.ecore6
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/test.odesign9
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/CompletionProposalInVSMTest.java144
5 files changed, 184 insertions, 22 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/MANIFEST.MF b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/MANIFEST.MF
index 48a62c1180..98524feca8 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/MANIFEST.MF
+++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/MANIFEST.MF
@@ -1,12 +1,13 @@
Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
Bundle-Name: org.eclipse.sirius.test.design
-Bundle-SymbolicName: org.eclipse.sirius.test.design;singleton=true
+Bundle-SymbolicName: org.eclipse.sirius.test.design;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: org.eclipse.sirius.test.design.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.sirius,
- org.eclipse.sirius.common.acceleo.mtl,
- org.eclipse.emf.ecore
+ org.eclipse.sirius.common.acceleo.mtl
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
+Import-Package: org.eclipse.sirius.sample.interactions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/ServicesWithDependencies.java b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/ServicesWithDependencies.java
new file mode 100644
index 0000000000..209c1245a1
--- /dev/null
+++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/ServicesWithDependencies.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.sirius.test.design;
+
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.sirius.sample.basicfamily.BasicfamilyFactory;
+import org.eclipse.sirius.sample.basicfamily.Family;
+import org.eclipse.sirius.sample.interactions.CallMessage;
+import org.eclipse.sirius.sample.interactions.Interaction;
+import org.eclipse.sirius.sample.interactions.InteractionsFactory;
+
+/**
+ * Class containing services referencing the {@link Interaction} metamodel.
+ */
+public class ServicesWithDependencies {
+
+ /**
+ * Service using a class from interactions model that is referenced by this
+ * plugin by a bundle dependency. The service is called from the "service:"
+ * keyword.
+ *
+ * @param any
+ * eObject source of the service call
+ * @return a string
+ */
+ public CallMessage testInteractionsService(EObject any) {
+ CallMessage createCallMessage = InteractionsFactory.eINSTANCE.createCallMessage();
+ createCallMessage.setName("testInteractionsWithServiceServiceCallOk");
+ return createCallMessage;
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/test.ecore b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/test.ecore
index 90966f5fda..1daeaa5b1f 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/test.ecore
+++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/test.ecore
@@ -1,7 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<ecore:EPackage xmi:version="2.0"
- xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test"
- nsURI="http://org.eclipse.sirius.test" nsPrefix="test">
+<ecore:EPackage xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="test" nsURI="http://org.eclipse.sirius.test" nsPrefix="test">
<eClassifiers xsi:type="ecore:EClass" name="Test"/>
</ecore:EPackage>
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/test.odesign b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/test.odesign
index 2b02d0972e..8aa2f0cff1 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/test.odesign
+++ b/plugins/org.eclipse.sirius.tests.swtbot/data/unit/editor/vsm/completion/test.odesign
@@ -1,8 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
-<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" name="test" version="10.0.0.201411061000">
+<description:Group xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:description="http://www.eclipse.org/sirius/description/1.1.0" xmlns:description_1="http://www.eclipse.org/sirius/diagram/description/1.1.0" name="test" version="11.0.0.201609021200">
<ownedViewpoints name="VP">
- <ownedRepresentations xsi:type="description_1:DiagramDescription" name="Diag"/>
+ <ownedRepresentations xsi:type="description_1:DiagramDescription" name="Diag" domainClass="EClass">
+ <defaultLayer name="Default">
+ <containerMappings name="C1" domainClass="EClass"/>
+ </defaultLayer>
+ </ownedRepresentations>
<ownedJavaExtensions qualifiedClassName="org.eclipse.sirius.test.design.BasicService"/>
<ownedJavaExtensions qualifiedClassName="org::eclipse::sirius::test::design::AcceleoMtlInterpreterTestModule"/>
+ <ownedJavaExtensions qualifiedClassName="org.eclipse.sirius.test.design.ServicesWithDependencies"/>
</ownedViewpoints>
</description:Group>
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/CompletionProposalInVSMTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/CompletionProposalInVSMTest.java
index 7461fd869c..137cd9cbfa 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/CompletionProposalInVSMTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/editor/vsm/CompletionProposalInVSMTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2014 THALES GLOBAL SERVICES.
+ * Copyright (c) 2010, 2016 THALES GLOBAL SERVICES.
* 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
@@ -12,6 +12,7 @@ package org.eclipse.sirius.tests.swtbot.editor.vsm;
import java.util.Collection;
import java.util.Collections;
+import java.util.List;
import org.eclipse.core.commands.Command;
import org.eclipse.core.commands.ParameterizedCommand;
@@ -22,13 +23,13 @@ import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.sirius.common.tools.internal.assist.ProposalProviderRegistry;
import org.eclipse.sirius.diagram.DiagramPackage;
import org.eclipse.sirius.diagram.description.DescriptionPackage;
+import org.eclipse.sirius.sample.interactions.InteractionsPackage;
import org.eclipse.sirius.tests.support.api.EclipseTestsSupportHelper;
import org.eclipse.sirius.tests.support.api.TestsUtil;
import org.eclipse.sirius.tests.swtbot.Activator;
@@ -41,6 +42,7 @@ import org.eclipse.swtbot.swt.finder.waits.DefaultCondition;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotButton;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTable;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
import org.eclipse.ui.handlers.IHandlerService;
@@ -62,6 +64,8 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
private static final String BASIC_SERVICE_JAVA = "BasicService.java";
+ private static final String SERVICE_WITH_DEPENDENCIES_JAVA = "ServicesWithDependencies.java";
+
private static final String PATH = "data/unit/editor/vsm/completion/";
private static final String VSM_PROJECT_NAME = "org.eclipse.sirius.test.design";
@@ -87,6 +91,7 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
*/
@Override
protected void onSetUpAfterOpeningDesignerPerspective() throws Exception {
+ setErrorCatchActive(false);
}
/**
@@ -102,7 +107,7 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
* disable auto build.
* @throws CommandException
*/
- private void initContext() throws InterruptedException, OperationCanceledException, CoreException, CommandException {
+ private void initContext(List<String> nodes) throws InterruptedException, OperationCanceledException, CoreException, CommandException {
designerPerspectives.openSiriusPerspective();
// Wait the end of the current build and/or refresh.
waitJobsBuildOrRefresh();
@@ -135,6 +140,7 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
package_name = package_name.replace('.', pathSeparator);
String dest = VSM_PROJECT_NAME + "/src/" + package_name + pathSeparator;
EclipseTestsSupportHelper.INSTANCE.copyFile(Activator.PLUGIN_ID, PATH + BASIC_SERVICE_JAVA, dest + BASIC_SERVICE_JAVA);
+ EclipseTestsSupportHelper.INSTANCE.copyFile(Activator.PLUGIN_ID, PATH + SERVICE_WITH_DEPENDENCIES_JAVA, dest + SERVICE_WITH_DEPENDENCIES_JAVA);
// Copy the mtl files
EclipseTestsSupportHelper.INSTANCE.copyFile(Activator.PLUGIN_ID, PATH + ACCELEO_MTL_INTERPRETER_TEST_MODULE_MTL, dest + ACCELEO_MTL_INTERPRETER_TEST_MODULE_MTL);
@@ -149,7 +155,11 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
waitJobsBuildOrRefresh();
bot.activeEditor().setFocus();
- bot.activeEditor().bot().tree().expandNode("platform:/resource/" + VSM_PROJECT_NAME + "/description/" + VSM, "test", "VP", "Diag").select();
+ SWTBotTreeItem lastExpandNode = bot.activeEditor().bot().tree().expandNode("platform:/resource/" + VSM_PROJECT_NAME + "/description/" + VSM);
+ for (String node : nodes) {
+ lastExpandNode = lastExpandNode.expandNode(node);
+ }
+ lastExpandNode.select();
propertiesBot = bot.viewByTitle("Properties");
propertiesBot.setFocus();
@@ -157,8 +167,8 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
}
private void addAcceleoNature(IProject projet) throws CommandException {
- ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);
- IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
+ ICommandService commandService = PlatformUI.getWorkbench().getService(ICommandService.class);
+ IHandlerService handlerService = PlatformUI.getWorkbench().getService(IHandlerService.class);
Command addAcceleoNatureCommand = commandService.getCommand("org.eclipse.sirius.common.acceleo.mtl.ide.internal.convert"); //$NON-NLS-1$
// If the acceleo interpreter is not present, do not configure.
@@ -200,12 +210,11 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
return;
}
- initContext();
+ initContext(Lists.newArrayList("test", "VP", "Diag"));
// Set the domain class
SWTBotText domainClass = propertiesBot.bot().text(2);
domainClass.setFocus();
- domainClass.setText("EClass");
// Init the Precondition Expression
SWTBotText precondition = propertiesBot.bot().text(3);
@@ -217,6 +226,114 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
assertTrue("Proposals on EClass should contain service for EClass.", contentAssistProposal.contains("sampleService() : String"));
assertTrue("Proposals on EClass should contain service for EClass.", contentAssistProposal.contains("sampleServiceOnEClass() : String"));
assertFalse("Proposals on EClass should not contain services for EPackage.", contentAssistProposal.contains("sampleServiceOnEPackage() : String"));
+
+ }
+
+ /**
+ * Check that the right Java service appears in the completion proposals
+ * with Acceleo interpreter.
+ *
+ * Warning: To ensure the non regression of the associtated bug 500253, the
+ * manifest must not have a direct reference to org.eclipse.emf.ecore.
+ *
+ * @exception Exception
+ * In case of problem during context initialization.
+ */
+ public void test_Java_Service_Completion_By_Acceleo() throws Exception {
+
+ if (TestsUtil.shouldSkipUnreliableTests()) {
+ return;
+ }
+
+ initContext(Lists.newArrayList("test", "VP", "Diag", "Default", "C1"));
+
+ // Set the domain class
+ SWTBotText domainClass = propertiesBot.bot().text(2);
+ domainClass.setFocus();
+
+ // Init the Precondition Expression
+ SWTBotText precondition = propertiesBot.bot().text(3);
+ precondition.setFocus();
+ precondition.setText("[self./]");
+
+ // Get proposals
+ Collection<String> contentAssistProposal = getContentAssistProposal(precondition, 6);
+ assertTrue("Proposals should be present.", contentAssistProposal.contains("testInteractionsService() : CallMessage"));
+ assertTrue("Proposals on EClass should contain service for EClass.", contentAssistProposal.contains("sampleService() : String"));
+ assertTrue("Proposals on EClass should contain service for EClass.", contentAssistProposal.contains("sampleServiceOnEClass() : String"));
+
+ }
+
+ /**
+ * Check that the right Java service appears in the completion proposals
+ * with service keyword used.
+ *
+ * Warning: To ensure the non regression of the associtated bug 500253, the
+ * manifest must not have a direct reference to org.eclipse.emf.ecore.
+ *
+ * @exception Exception
+ * In case of problem during context initialization.
+ */
+ public void test_Java_Service_Completion_By_Service_Keyword() throws Exception {
+
+ if (TestsUtil.shouldSkipUnreliableTests()) {
+ return;
+ }
+
+ initContext(Lists.newArrayList("test", "VP", "Diag", "Default", "C1"));
+
+ // Set the domain class
+ SWTBotText domainClass = propertiesBot.bot().text(2);
+ domainClass.setFocus();
+
+ // Init the Precondition Expression
+ SWTBotText precondition = propertiesBot.bot().text(3);
+ precondition.setFocus();
+ precondition.setText("service:");
+
+ // Get proposals
+ Collection<String> contentAssistProposal = getContentAssistProposal(precondition, 8);
+ assertTrue("Proposals should be present.", contentAssistProposal.contains("testInteractionsService()"));
+ assertTrue("Proposals on EClass should contain service for EClass.", contentAssistProposal.contains("sampleService()"));
+ assertTrue("Proposals on EClass should contain service for EClass.", contentAssistProposal.contains("sampleServiceOnEClass()"));
+
+ }
+
+ /**
+ * Check that the right Java service appears in the completion proposals
+ * with AQL interpreter.
+ *
+ * Warning: To ensure the non regression of the associtated bug 500253, the
+ * manifest must not have a direct reference to org.eclipse.emf.ecore.
+ *
+ * @exception Exception
+ * In case of problem during context initialization.
+ */
+ public void test_Java_Service_Completion_By_AQL() throws Exception {
+
+ if (TestsUtil.shouldSkipUnreliableTests()) {
+ return;
+ }
+
+ // initContext(Lists.newArrayList("test", "VP", "Diag", "Default",
+ // "C1"));
+ initContext(Lists.newArrayList("test", "VP", "Diag", "Default", "C1"));
+
+ // Set the domain class
+ SWTBotText domainClass = propertiesBot.bot().text(2);
+ domainClass.setFocus();
+
+ // Init the Precondition Expression
+ SWTBotText precondition = propertiesBot.bot().text(3);
+ precondition.setFocus();
+ precondition.setText("aql:self.");
+
+ // Get proposals
+ Collection<String> contentAssistProposal = getContentAssistProposal(precondition, 9);
+ assertTrue("Proposals should be present.", contentAssistProposal.contains("testInteractionsService()"));
+ assertTrue("Proposals on EClass should contain service for EClass.", contentAssistProposal.contains("sampleService()"));
+ assertTrue("Proposals on EClass should contain service for EClass.", contentAssistProposal.contains("sampleServiceOnEClass()"));
+
}
/**
@@ -231,12 +348,11 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
return;
}
- initContext();
+ initContext(Lists.newArrayList("test", "VP", "Diag"));
// Set the domain class
SWTBotText domainClass = propertiesBot.bot().text(2);
domainClass.setFocus();
- domainClass.setText("EClass");
// Init the Precondition Expression
SWTBotText precondition = propertiesBot.bot().text(3);
@@ -272,7 +388,7 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
return;
}
- initContext();
+ initContext(Lists.newArrayList("test", "VP", "Diag"));
// Get proposals for domain class.
SWTBotText domainClass = propertiesBot.bot().text(2);
@@ -297,10 +413,10 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
* In case of problem during context initialization.
*/
public void test_Domain_Class_Completion_With_Selected_MetaModels() throws Exception {
- initContext();
+ initContext(Lists.newArrayList("test", "VP", "Diag"));
// select Sirius metamodels
- Collection<String> expectedMetamodels = Lists.newArrayList(DescriptionPackage.eNS_URI, DiagramPackage.eNS_URI, ViewpointPackage.eNS_URI);
+ Collection<String> expectedMetamodels = Lists.newArrayList(DescriptionPackage.eNS_URI, DiagramPackage.eNS_URI, ViewpointPackage.eNS_URI, InteractionsPackage.eNS_URI);
selectSiriusMetaModels(expectedMetamodels);
propertiesBot = bot.viewByTitle("Properties");
@@ -395,6 +511,7 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
/**
* {@inheritDoc}
*/
+ @Override
public boolean test() throws Exception {
return expectedSelectionCound == swtBotTable.selectionCount();
}
@@ -402,6 +519,7 @@ public class CompletionProposalInVSMTest extends AbstractContentAssistTest {
/**
* {@inheritDoc}
*/
+ @Override
public String getFailureMessage() {
return "The selection count is not the expected one, expected (" + expectedSelectionCound + "), " + swtBotTable.selectionCount();
}

Back to the top