diff options
author | Christian W. Damus | 2015-08-07 16:13:52 +0000 |
---|---|---|
committer | Christian W. Damus | 2015-08-07 16:15:27 +0000 |
commit | 9c5bdceb6b4fd22de8d3d1b060a892abe1881f24 (patch) | |
tree | 1585591a5e896b2b5b73834c1c2545e1c81449d8 /tests/junit/plugins/infra | |
parent | e8700f1a17b4de70cb39cd406721b51f337422ea (diff) | |
download | org.eclipse.papyrus-9c5bdceb6b4fd22de8d3d1b060a892abe1881f24.tar.gz org.eclipse.papyrus-9c5bdceb6b4fd22de8d3d1b060a892abe1881f24.tar.xz org.eclipse.papyrus-9c5bdceb6b4fd22de8d3d1b060a892abe1881f24.zip |
Bug 474489: [Composite Structure] Infinite loop while using canonical mode
https://bugs.eclipse.org/bugs/show_bug.cgi?id=474489
Add a canonical strategy for structured classifiers in composite
diagrams that presents only ports and parts as canonical children
(connectors handled separately, not requiring any change).
Diffstat (limited to 'tests/junit/plugins/infra')
-rw-r--r-- | tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.canonical.tests/src/org/eclipse/papyrus/infra/gmfdiag/canonical/tests/RegressionTest.java | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.canonical.tests/src/org/eclipse/papyrus/infra/gmfdiag/canonical/tests/RegressionTest.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.canonical.tests/src/org/eclipse/papyrus/infra/gmfdiag/canonical/tests/RegressionTest.java index a4e3a54aee5..34d7cfba9bf 100644 --- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.canonical.tests/src/org/eclipse/papyrus/infra/gmfdiag/canonical/tests/RegressionTest.java +++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.canonical.tests/src/org/eclipse/papyrus/infra/gmfdiag/canonical/tests/RegressionTest.java @@ -14,12 +14,24 @@ package org.eclipse.papyrus.infra.gmfdiag.canonical.tests; import static org.eclipse.papyrus.junit.framework.runner.ScenarioRunner.verificationPoint; +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.not; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.fail; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.impl.AdapterImpl; import org.eclipse.papyrus.junit.framework.runner.Scenario; import org.eclipse.papyrus.junit.framework.runner.ScenarioRunner; import org.eclipse.papyrus.junit.utils.rules.ActiveDiagram; import org.eclipse.papyrus.junit.utils.rules.PluginResource; import org.eclipse.uml2.uml.Constraint; +import org.eclipse.uml2.uml.Property; +import org.eclipse.uml2.uml.StateMachine; +import org.eclipse.uml2.uml.Type; +import org.eclipse.uml2.uml.UMLFactory; +import org.eclipse.uml2.uml.UMLPackage; +import org.junit.Test; import org.junit.runner.RunWith; /** @@ -66,4 +78,48 @@ public class RegressionTest extends AbstractCanonicalTest { } } + @PluginResource("models/composite.di") + @ActiveDiagram("main") + @NeedsUIEvents + @Test + public void nestedClassifiersDontCauseLoopInCompositeDiagram_bug474489() { + class Trap extends AdapterImpl { + boolean caught; + + @Override + public void notifyChanged(Notification msg) { + switch (msg.getEventType()) { + case Notification.ADD: + if (msg.getFeature() == UMLPackage.Literals.STRUCTURED_CLASSIFIER__OWNED_ATTRIBUTE) { + caught = true; + fail(); + } + break; + default: + break; + } + } + } + + final org.eclipse.uml2.uml.Class blackBox = (org.eclipse.uml2.uml.Class) editor.getModel().getOwnedType("BlackBox"); + setCanonical(true, requireEditPart(blackBox)); + + // Add an owned behavior + StateMachine behavior = UMLFactory.eINSTANCE.createStateMachine(); + behavior.setName("StateMachine1"); + + // Listen for attempts to drop the nested behavior as new property typed by it + final Trap trap = new Trap(); + blackBox.eAdapters().add(0, trap); + + add(blackBox, behavior, UMLPackage.Literals.BEHAVIORED_CLASSIFIER__OWNED_BEHAVIOR); + assertThat("Canonical edit-policy dropped the nested behavior as a part", trap.caught, is(false)); + + assertNoView(behavior); + + // No part was created for this behavior (as its type), either + for (Property next : blackBox.getAllAttributes()) { + assertThat(next.getType(), not(is((Type) behavior))); + } + } } |