diff options
author | Christian W. Damus | 2016-09-28 20:00:20 +0000 |
---|---|---|
committer | Christian W. Damus | 2016-09-28 20:00:20 +0000 |
commit | ba9bd2d029fe053a359af8856946b69259d84406 (patch) | |
tree | 5e17c147ca5239f3775759e864a4fec43413c5b8 /tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt | |
parent | c3056fb283805999bf0584fce1cf9b482e8d5eff (diff) | |
download | org.eclipse.papyrus-rt-ba9bd2d029fe053a359af8856946b69259d84406.tar.gz org.eclipse.papyrus-rt-ba9bd2d029fe053a359af8856946b69259d84406.tar.xz org.eclipse.papyrus-rt-ba9bd2d029fe053a359af8856946b69259d84406.zip |
Bug 497742: Drag and drop of protocol in model explorer leads to bogus result
https://bugs.eclipse.org/bugs/show_bug.cgi?id=497742
Handle also the case of dropping a protocol before or after an element
that is not another protocol, so that the package found into which to
drop it is an ordinary package, not a protocol-container.
Change-Id: Idf6027f954343b844e17bafd5942b5cdbbf35561
Diffstat (limited to 'tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt')
-rw-r--r-- | tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/edition/MoveElementTests.java | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/edition/MoveElementTests.java b/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/edition/MoveElementTests.java index 46211b83a..944ef0fbc 100644 --- a/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/edition/MoveElementTests.java +++ b/tests/junit/umlrt/core/org.eclipse.papyrusrt.umlrt.core.tests/src/org/eclipse/papyrusrt/umlrt/core/tests/edition/MoveElementTests.java @@ -265,6 +265,42 @@ public class MoveElementTests { assertThat(modelContents.indexOf(capsule2), lessThan(modelContents.indexOf(protocol2Container))); } + /** + * Verifies the reordering of a protocol relative to a non-protocol in a package + * as is directed by the Model Explorer's drop assistant, which uses set requests + * to set a new list of packaged elements. This is different to {@link #reorderProtocols()} + * in that the protocol is not being dropped next to another protocol (from which the + * Model Explorer infers the latter's protocol-container as the drop target) but rather + * it is being dropped next to some other kind of element, which does not have the protocol + * structure, and so presents a more normal scenario except that it is still a protocol + * being dragged but it is its container package that needs to be dropped. + * + * @see <a href="http://eclip.se/497742">bug 497742</a> + */ + @Test + public void reorderProtocolRelativeToNonProtocol() { + // The Model Explorer doesn't understand the logical structure, so this + // is the kind of SetRequest that it creates when trying to insert a + // protocol ahead of some element in some package + List<PackageableElement> reordering = new ArrayList<>(model.getModel().getPackagedElements()); + reordering.add(0, protocol2); // Insertion ahead of the 'sub1' package + SetRequest request = new SetRequest(model.getModel(), UMLPackage.Literals.PACKAGE__PACKAGED_ELEMENT, reordering); + + ICommand command = ElementEditServiceUtils.getCommandProvider(model.getModel()).getEditCommand(request); + assertThat("No executable set command", command, isExecutable()); + + model.execute(command); + + // The protocol still looks okay + assertThat(protocol2.eContainer(), not(model.getModel())); + assertThat(protocol2.eContainer(), instanceOf(Package.class)); + assertThat(((Package) protocol2.eContainer()).getName(), is(protocol2.getName())); + assertThat(ProtocolUtils.getRTMessages(protocol2, RTMessageKind.OUT, false).size(), is(1)); + + // And the protocol-container was dropped in the expected place + assertThat(model.getModel().getPackagedElements().indexOf(protocol2.getOwner()), is(0)); + } + // // Test framework // |