Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian W. Damus2015-12-09 16:12:00 -0500
committerChristian W. Damus2015-12-09 16:12:00 -0500
commit46ff949a0e22eb38ef76cb6aa52c662db9f77f8d (patch)
treef023f764c3906bee559167636de504e52e747afd /tests
parent1658f126ea54ba2029ab1d464d83dae023332520 (diff)
downloadorg.eclipse.papyrus-46ff949a0e22eb38ef76cb6aa52c662db9f77f8d.tar.gz
org.eclipse.papyrus-46ff949a0e22eb38ef76cb6aa52c662db9f77f8d.tar.xz
org.eclipse.papyrus-46ff949a0e22eb38ef76cb6aa52c662db9f77f8d.zip
Bug 469188: [Editor] Page management improvements in the Papyrus multi-editor
https://bugs.eclipse.org/bugs/show_bug.cgi?id=469188 Present all notation views (diagrams, tables, etc.) in a single list instead of separate lists in the welcome page.
Diffstat (limited to 'tests')
-rw-r--r--tests/junit/plugins/infra/editor/org.eclipse.papyrus.infra.editor.welcome.tests/resources/many_diagrams.notation5
-rw-r--r--tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.welcome.tests/src/org/eclipse/papyrus/infra/gmfdiag/welcome/tests/WelcomeModelElementTest.java78
2 files changed, 47 insertions, 36 deletions
diff --git a/tests/junit/plugins/infra/editor/org.eclipse.papyrus.infra.editor.welcome.tests/resources/many_diagrams.notation b/tests/junit/plugins/infra/editor/org.eclipse.papyrus.infra.editor.welcome.tests/resources/many_diagrams.notation
index 1efe539ad0c..053aac8e6af 100644
--- a/tests/junit/plugins/infra/editor/org.eclipse.papyrus.infra.editor.welcome.tests/resources/many_diagrams.notation
+++ b/tests/junit/plugins/infra/editor/org.eclipse.papyrus.infra.editor.welcome.tests/resources/many_diagrams.notation
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:configuration="http://www.eclipse.org/papyrus/infra/viewpoints/configuration" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:nattable="http://www.eclipse.org/papyrus/nattable/model" xmlns:nattableaxis="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis" xmlns:nattableaxisconfiguration="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration" xmlns:nattableaxisprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider" xmlns:nattableconfiguration="http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/viewpoints/policy/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis http://www.eclipse.org/papyrus/nattable/model#//nattableaxis http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model#//nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableconfiguration">
+<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:configuration="http://www.eclipse.org/papyrus/infra/viewpoints/configuration" xmlns:css="http://www.eclipse.org/papyrus/infra/gmfdiag/css" xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" xmlns:nattable="http://www.eclipse.org/papyrus/nattable/model" xmlns:nattableaxis="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis" xmlns:nattableaxisconfiguration="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration" xmlns:nattableaxisprovider="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider" xmlns:nattableconfiguration="http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration" xmlns:notation="http://www.eclipse.org/gmf/runtime/1.0.2/notation" xmlns:style="http://www.eclipse.org/papyrus/infra/viewpoints/policy/style" xmlns:uml="http://www.eclipse.org/uml2/5.0.0/UML" xsi:schemaLocation="http://www.eclipse.org/papyrus/nattable/model/table/nattableaxis http://www.eclipse.org/papyrus/nattable/model#//nattableaxis http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableaxisconfiguration http://www.eclipse.org/papyrus/nattable/model/table/nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model#//nattableaxisprovider http://www.eclipse.org/papyrus/nattable/model/nattableconfiguration http://www.eclipse.org/papyrus/nattable/model#//nattableconfiguration">
<notation:Diagram xmi:id="_gyar8J0SEeWdwKZ41HcqWg" type="PapyrusUMLClassDiagram" name="classes" measurementUnit="Pixel">
<styles xmi:type="notation:StringValueStyle" xmi:id="_gyar8Z0SEeWdwKZ41HcqWg" name="diagram_compatibility_version" stringValue="1.1.0"/>
<styles xmi:type="notation:DiagramStyle" xmi:id="_gyar8p0SEeWdwKZ41HcqWg"/>
@@ -17,6 +17,9 @@
</styles>
<element xmi:type="uml:Model" href="many_diagrams.uml#_GN_tsJz0EeWdwKZ41HcqWg"/>
</notation:Diagram>
+ <css:ModelStyleSheets xmi:id="_ahnksJ6xEeWcy-hbAbG1yg">
+ <stylesheets xmi:type="css:EmbeddedStyleSheet" xmi:id="_ah-KAJ6xEeWcy-hbAbG1yg" label="my styles" content="Class {&#xA; gradient: white;&#xA; fillColor: yellow;&#xA;}"/>
+ </css:ModelStyleSheets>
<notation:Diagram xmi:id="_D_gEwJ0TEeWdwKZ41HcqWg" type="UseCase" name="use cases" measurementUnit="Pixel">
<styles xmi:type="notation:StringValueStyle" xmi:id="_D_gEwZ0TEeWdwKZ41HcqWg" name="diagram_compatibility_version" stringValue="1.1.0"/>
<styles xmi:type="notation:DiagramStyle" xmi:id="_D_gEwp0TEeWdwKZ41HcqWg"/>
diff --git a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.welcome.tests/src/org/eclipse/papyrus/infra/gmfdiag/welcome/tests/WelcomeModelElementTest.java b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.welcome.tests/src/org/eclipse/papyrus/infra/gmfdiag/welcome/tests/WelcomeModelElementTest.java
index 7735220c8b4..a5ae4145251 100644
--- a/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.welcome.tests/src/org/eclipse/papyrus/infra/gmfdiag/welcome/tests/WelcomeModelElementTest.java
+++ b/tests/junit/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.welcome.tests/src/org/eclipse/papyrus/infra/gmfdiag/welcome/tests/WelcomeModelElementTest.java
@@ -29,11 +29,12 @@ import java.util.stream.Collectors;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.list.ListDiffEntry;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.papyrus.infra.editor.welcome.tests.AbstractWelcomePageTest;
-import org.eclipse.papyrus.infra.gmfdiag.welcome.internal.modelelements.DiagramObservable;
+import org.eclipse.papyrus.infra.gmfdiag.welcome.internal.modelelements.NotationObservable;
import org.eclipse.papyrus.infra.gmfdiag.welcome.internal.modelelements.WelcomeModelElement;
import org.eclipse.papyrus.infra.gmfdiag.welcome.internal.modelelements.WelcomeModelElementFactory;
import org.eclipse.papyrus.infra.viewpoints.configuration.PapyrusDiagram;
@@ -57,38 +58,39 @@ public class WelcomeModelElementTest extends AbstractWelcomePageTest {
}
@Test
- public void diagramsProperty() {
- IObservableList<DiagramObservable> diagrams = getDiagrams();
+ public void viewsProperty() {
+ IObservableList<NotationObservable> views = getNotationViews();
- assertThat(diagrams.size(), is(4));
- assertThat(diagrams, hasItem(anything()));
+ assertThat(views.size(), is(6));
+ assertThat(views, hasItem(anything()));
- List<String> diagramNames = diagrams.stream()
- .map(DiagramObservable::getDiagram)
+ List<String> diagramNames = views.stream()
+ .map(NotationObservable::getView)
.map(IObservableValue::getValue)
- .map(Diagram::getName)
+ .map(this::getName)
.collect(Collectors.toList());
assertThat(diagramNames, both(hasItem("classes")).and(hasItem("packages"))
- .and(hasItem("use cases")).and(hasItem("components")));
+ .and(hasItem("use cases")).and(hasItem("components"))
+ .and(hasItem("table")).and(hasItem("tree table")));
- List<String> contextNames = diagrams.stream()
- .map(DiagramObservable::getContext)
+ List<String> contextNames = views.stream()
+ .map(NotationObservable::getContext)
.map(IObservableValue::getValue)
.map(NamedElement.class::cast)
.map(NamedElement::getName)
.collect(Collectors.toList());
- assertThat(contextNames, is(Collections.nCopies(4, "model")));
+ assertThat(contextNames, is(Collections.nCopies(6, "model")));
}
@Test
- public void deleteDiagram() {
- IObservableList<DiagramObservable> diagrams = getDiagrams();
+ public void deleteView() {
+ IObservableList<NotationObservable> views = getNotationViews();
- DiagramObservable toBeDeleted = getDiagram(diagrams, "use cases");
+ NotationObservable toBeDeleted = getView(views, "use cases");
boolean[] deleted = { false };
- diagrams.addListChangeListener(event -> {
- for (ListDiffEntry<? extends DiagramObservable> next : event.diff.getDifferences()) {
+ views.addListChangeListener(event -> {
+ for (ListDiffEntry<? extends NotationObservable> next : event.diff.getDifferences()) {
if (!next.isAddition() && (next.getElement() == toBeDeleted)) {
deleted[0] = true;
}
@@ -99,24 +101,24 @@ public class WelcomeModelElementTest extends AbstractWelcomePageTest {
@Override
protected void doExecute() {
- EcoreUtil.delete(toBeDeleted.getDiagram().getValue(), true);
+ EcoreUtil.delete(toBeDeleted.getView().getValue(), true);
}
});
assertThat("List did not notify", deleted[0], is(true));
- assertThat(diagrams.size(), is(3));
- assertThat(diagrams, not(hasItem(toBeDeleted)));
+ assertThat(views.size(), is(5));
+ assertThat(views, not(hasItem(toBeDeleted)));
}
@Test
- public void createDiagram() {
- IObservableList<DiagramObservable> diagrams = getDiagrams();
+ public void createView() {
+ IObservableList<NotationObservable> views = getNotationViews();
- DiagramObservable[] created = { null };
+ NotationObservable[] created = { null };
- diagrams.addListChangeListener(event -> {
- for (ListDiffEntry<? extends DiagramObservable> next : event.diff.getDifferences()) {
- if (next.isAddition() && "CreatedInTest".equals(next.getElement().getDiagram().getValue().getName())) {
+ views.addListChangeListener(event -> {
+ for (ListDiffEntry<? extends NotationObservable> next : event.diff.getDifferences()) {
+ if (next.isAddition() && "CreatedInTest".equals(getName(next.getElement().getView().getValue()))) {
created[0] = next.getElement();
}
}
@@ -134,13 +136,13 @@ public class WelcomeModelElementTest extends AbstractWelcomePageTest {
});
assertThat("List did not notify", created[0], notNullValue());
- assertThat(diagrams.size(), is(5));
- assertThat(diagrams, hasItem(created[0]));
+ assertThat(views.size(), is(7));
+ assertThat(views, hasItem(created[0]));
}
@Test
public void isEditable() {
- assertThat(fixture.isEditable("diagrams"), is(true));
+ assertThat(fixture.isEditable("views"), is(true));
assertThat(fixture.isEditable("garbage"), is(false));
}
@@ -154,15 +156,21 @@ public class WelcomeModelElementTest extends AbstractWelcomePageTest {
requireWelcome(), null); // The data-context isn't used by the factory
}
- IObservableList<DiagramObservable> getDiagrams() {
+ IObservableList<NotationObservable> getNotationViews() {
@SuppressWarnings("unchecked")
- IObservableList<DiagramObservable> result = (IObservableList<DiagramObservable>) fixture.getObservable("diagrams");
+ IObservableList<NotationObservable> result = (IObservableList<NotationObservable>) fixture.getObservable("views");
return result;
}
- DiagramObservable getDiagram(Collection<? extends DiagramObservable> diagrams, String name) {
- return diagrams.stream()
- .filter(d -> name.equals(d.getDiagram().getValue().getName()))
+ NotationObservable getView(Collection<? extends NotationObservable> views, String name) {
+ return views.stream()
+ .filter(d -> name.equals(getName(d.getView().getValue())))
.findFirst().get();
}
+
+ // Diagrams and tables have a 'name' attribute
+ String getName(EObject object) {
+ EStructuralFeature nameAttribute = object.eClass().getEStructuralFeature("name");
+ return (String) object.eGet(nameAttribute);
+ }
}

Back to the top