Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fluegge2010-08-27 04:01:15 -0400
committerMartin Fluegge2010-08-27 04:01:15 -0400
commitdf56ab7de6df1a105b99c35cf2f65691044e4317 (patch)
treee892e75420f1d81165878b12c6ef2d992f8b75fb
parent98dbde127282df1127ee7d6cfe35fdd99d802cf3 (diff)
downloadcdo-df56ab7de6df1a105b99c35cf2f65691044e4317.tar.gz
cdo-df56ab7de6df1a105b99c35cf2f65691044e4317.tar.xz
cdo-df56ab7de6df1a105b99c35cf2f65691044e4317.zip
[320193] [Dawn] Provide a flexible testing environment for UI tests
https://bugs.eclipse.org/bugs/show_bug.cgi?id=320193
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/.settings/org.eclipse.jdt.core.prefs12
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/.settings/org.eclipse.jdt.ui.prefs4
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/DE_DE.keyboard (renamed from plugins/org.eclipse.emf.cdo.dawn.tests/EN_US.keyboard)0
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnUITest.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java18
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/ConflictTest.java208
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnProjectExplorerTest.java74
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/MultipleResourcesDeletionTest.java311
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/MultipleResourcesTest.java505
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/SimpleDiagramTest.java17
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java143
-rw-r--r--plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotUtil.java187
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java42
13 files changed, 1455 insertions, 96 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/.settings/org.eclipse.jdt.core.prefs b/plugins/org.eclipse.emf.cdo.dawn.tests/.settings/org.eclipse.jdt.core.prefs
index e6d94e03c0..dd54bc6c8c 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/.settings/org.eclipse.jdt.core.prefs
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/.settings/org.eclipse.jdt.core.prefs
@@ -1,4 +1,4 @@
-#Mon Apr 12 14:00:12 CEST 2010
+#Fri Aug 20 17:57:05 CEST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.codeComplete.argumentPrefixes=
org.eclipse.jdt.core.codeComplete.argumentSuffixes=
@@ -102,6 +102,7 @@ org.eclipse.jdt.core.compiler.taskPriorities=NORMAL,HIGH,HIGH,LOW,LOW,LOW,LOW,LO
org.eclipse.jdt.core.compiler.taskTags=TODO,FIXME,XXX,PERF,MEM,POLISH,@generated NOT,@ADDED
org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
@@ -112,6 +113,7 @@ org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
@@ -156,10 +158,15 @@ org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
org.eclipse.jdt.core.formatter.comment.line_length=120
+org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
+org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
org.eclipse.jdt.core.formatter.compact_else_if=true
org.eclipse.jdt.core.formatter.continuation_indentation=2
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
+org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
@@ -174,6 +181,7 @@ org.eclipse.jdt.core.formatter.indentation.size=2
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=insert
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert
@@ -356,5 +364,7 @@ org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
org.eclipse.jdt.core.formatter.tabulation.char=space
org.eclipse.jdt.core.formatter.tabulation.size=2
+org.eclipse.jdt.core.formatter.use_on_off_tags=true
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
+org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/.settings/org.eclipse.jdt.ui.prefs b/plugins/org.eclipse.emf.cdo.dawn.tests/.settings/org.eclipse.jdt.ui.prefs
index 724b873437..61083b7673 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/.settings/org.eclipse.jdt.ui.prefs
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/.settings/org.eclipse.jdt.ui.prefs
@@ -1,4 +1,4 @@
-#Thu Feb 04 09:44:24 CET 2010
+#Fri Aug 20 17:54:44 CEST 2010
cleanup.add_default_serial_version_id=true
cleanup.add_generated_serial_version_id=false
cleanup.add_missing_annotations=true
@@ -54,7 +54,7 @@ cleanup_profile=_EMFT
cleanup_settings_version=2
eclipse.preferences.version=1
editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
-formatter_profile=_EMFT
+formatter_profile=_Unmanaged profile 'EMFT' (Dawn)
formatter_settings_version=11
org.eclipse.jdt.ui.exception.name=ex
org.eclipse.jdt.ui.gettersetter.use.is=true
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/EN_US.keyboard b/plugins/org.eclipse.emf.cdo.dawn.tests/DE_DE.keyboard
index 5ac15af68d..5ac15af68d 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/EN_US.keyboard
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/DE_DE.keyboard
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnUITest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnUITest.java
index 7a9bcd4ba7..9d1cd718f5 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnUITest.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AbstractDawnUITest.java
@@ -17,6 +17,8 @@ import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.ui.AbstractCDOUITest;
import org.eclipse.emf.cdo.view.CDOView;
+import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.Node;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
import org.eclipse.swtbot.swt.finder.finders.UIThreadRunnable;
@@ -37,6 +39,7 @@ public abstract class AbstractDawnUITest extends AbstractCDOUITest// AbstractDaw
{
SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
SWTBotPreferences.SCREENSHOTS_DIR = DawnTestPlatform.instance.getTestFolder();
+ resetWorkbench();
super.setUp();
}
@@ -61,18 +64,15 @@ public abstract class AbstractDawnUITest extends AbstractCDOUITest// AbstractDaw
IWorkbenchPage page = window.getActivePage();
String editorID = EditorDescriptionHelper.getEditorIdForDawnEditor(resource.getName());
- // if (editorID != null && !editorID.equals(""))
+ try
{
- try
- {
- DawnEditorInput editorInput = new DawnEditorInput(resource.getURI());
-
- page.openEditor(editorInput, editorID);
- }
- catch (PartInitException e)
- {
- e.printStackTrace();
- }
+ DawnEditorInput editorInput = new DawnEditorInput(resource.getURI());
+
+ page.openEditor(editorInput, editorID);
+ }
+ catch (PartInitException e)
+ {
+ e.printStackTrace();
}
}
}
@@ -108,4 +108,12 @@ public abstract class AbstractDawnUITest extends AbstractCDOUITest// AbstractDaw
editor.activateTool(type);
editor.drag(fromXPosition, fromYPosition, toXPosition, toYPosition);
}
+
+ protected void createEdge(String type, Node nodeFrom, Node nodeTo, SWTBotGefEditor editor)
+ {
+
+ Bounds boundsA = (Bounds)nodeFrom.getLayoutConstraint();
+ Bounds boundsB = (Bounds)nodeTo.getLayoutConstraint();
+ createEdge(type, boundsA.getX(), boundsA.getY(), boundsB.getX(), boundsB.getY(), editor);
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java
index 3de89051bb..e5d96e01f9 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/AllTestsDawnUISWTBot.java
@@ -11,7 +11,9 @@
package org.eclipse.emf.cdo.dawn.tests;
import org.eclipse.emf.cdo.dawn.tests.bugzillas.Bugzilla_321024_Test;
+import org.eclipse.emf.cdo.dawn.tests.ui.ConflictTest;
import org.eclipse.emf.cdo.dawn.tests.ui.DawnCreationWizardSWTBotTest;
+import org.eclipse.emf.cdo.dawn.tests.ui.DawnProjectExplorerTest;
import org.eclipse.emf.cdo.dawn.tests.ui.MultipleResourcesTest;
import org.eclipse.emf.cdo.dawn.tests.ui.SimpleDiagramTest;
@@ -23,11 +25,21 @@ import org.junit.runners.Suite.SuiteClasses;
* This test suite should be executed as SWTBot test.
*
* @author Martin Fluegge
+ * @formatter:off
*/
+
@RunWith(Suite.class)
-@SuiteClasses({ DawnCreationWizardSWTBotTest.class, SimpleDiagramTest.class, MultipleResourcesTest.class,
- Bugzilla_321024_Test.class })
+@SuiteClasses({
+ DawnCreationWizardSWTBotTest.class,
+ SimpleDiagramTest.class,
+ MultipleResourcesTest.class,
+ // MultipleResourcesDeletionTest.class, //excluded because of ui freeze
+ DawnProjectExplorerTest.class,
+ ConflictTest.class,
+ Bugzilla_321024_Test.class
+ })
+
+
public class AllTestsDawnUISWTBot
{
-
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/ConflictTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/ConflictTest.java
new file mode 100644
index 0000000000..dcc14e38d0
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/ConflictTest.java
@@ -0,0 +1,208 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnUITest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class ConflictTest extends AbstractDawnUITest
+{
+ private static SWTGefBot bot;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception
+ {
+ bot = new SWTGefBot();
+ DawnSWTBotUtil.initTest(bot);
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ closeAllEditors();
+ sleep(1000);
+ super.tearDown();
+ }
+
+ @Test
+ public void testAClassConflictMove() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ editor.save();
+
+ editor.drag(100, 100, 200, 200);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+
+ DawnSWTBotUtil.moveNodeRemotely(nodeA, 200, 300);
+
+ transaction.commit();
+ }
+ sleep(500);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+
+ assertEquals(true, DawnAcoreTestUtil.showsConflict(classBEditpart.part()));
+ }
+
+ @Test
+ public void testAClassConflictbyRemoteNameChange() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ editor.save();
+
+ SWTBotGefEditPart swtBotGefEditPart = DawnAcoreTestUtil.getAClassEditParts(editor).get(0);
+ Node node = (Node)swtBotGefEditPart.part().getModel();
+ ((AClass)node.getElement()).setName("myName");
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ AClass aClass = (AClass)nodeA.getElement();
+ aClass.setName("newName");
+
+ transaction.commit();
+ }
+ sleep(500);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+
+ assertEquals(true, DawnAcoreTestUtil.showsConflict(classBEditpart.part()));
+ }
+
+ @Test
+ public void testAInterfaceConflictMove() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 100, 100, "A", bot, editor);
+ editor.save();
+
+ editor.drag(100, 100, 200, 200);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+
+ DawnSWTBotUtil.moveNodeRemotely(nodeA, 200, 300);
+
+ transaction.commit();
+ }
+ sleep(500);
+ List<SWTBotGefEditPart> interfaceEditParts = DawnAcoreTestUtil.getAInterfaceEditParts(editor);
+ SWTBotGefEditPart interfaceEditpart = interfaceEditParts.get(0);
+
+ assertEquals(true, DawnAcoreTestUtil.showsConflict(interfaceEditpart.part()));
+ }
+
+ @Test
+ public void testAAssociationConflict() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aClassEditParts.get(1).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_ASSOCIATION, nodeA, nodeB, editor);
+ editor.save();
+
+ List<SWTBotGefEditPart> aClassAssociationsEditParts = DawnAcoreTestUtil.getAClassAssociationsEditParts(editor);
+
+ DawnSWTBotUtil.addBendPoint((Edge)aClassAssociationsEditParts.get(0).part().getModel(), 0, 100, -100, 0);
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ try
+ {
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Edge edge = (Edge)diagram.getEdges().get(0);
+ DawnSWTBotUtil.addBendPoint(edge, 0, 100, -100, 0);
+
+ transaction.commit();
+ }
+ finally
+ {
+ transaction.close();
+ }
+ }
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnProjectExplorerTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnProjectExplorerTest.java
new file mode 100644
index 0000000000..fff8400eff
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/DawnProjectExplorerTest.java
@@ -0,0 +1,74 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui;
+
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnUITest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil;
+import org.eclipse.emf.cdo.dawn.ui.views.DawnExplorer;
+
+import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
+import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.eclipse.ui.IViewPart;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * @author Martin Fluegge
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class DawnProjectExplorerTest extends AbstractDawnUITest
+{
+ private static SWTGefBot bot;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception
+ {
+ bot = new SWTGefBot();
+ DawnSWTBotUtil.initTest(bot);
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ closeAllEditors();
+ super.tearDown();
+ }
+
+ @Test
+ public void testOpenDawnExplorer() throws Exception
+ {
+ bot.menu("Window").menu("Show View").menu("Other...").click();
+
+ SWTBotShell shell = bot.shell("Show View");
+ shell.activate();
+ bot.tree().expandNode("Dawn").select("Dawn Explorer");
+ bot.button("OK").click();
+
+ SWTBotView activeView = bot.activeView();
+ assertEquals("Dawn Explorer", activeView.getViewReference().getTitle());
+ IViewPart view = activeView.getViewReference().getView(false);
+ assertInstanceOf(DawnExplorer.class, view);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/MultipleResourcesDeletionTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/MultipleResourcesDeletionTest.java
new file mode 100644
index 0000000000..8bd12b9887
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/MultipleResourcesDeletionTest.java
@@ -0,0 +1,311 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, Germany) and others.
+ * 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:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.tests.ui;
+
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
+import org.eclipse.emf.cdo.dawn.tests.AbstractDawnUITest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CommitException;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+@RunWith(SWTBotJunit4ClassRunner.class)
+public class MultipleResourcesDeletionTest extends AbstractDawnUITest
+{
+ private static SWTGefBot bot;
+
+ @BeforeClass
+ public static void beforeClass() throws Exception
+ {
+ bot = new SWTGefBot();
+ DawnSWTBotUtil.initTest(bot);
+ }
+
+ @Override
+ @Before
+ public void setUp() throws Exception
+ {
+ super.setUp();
+ }
+
+ @Override
+ @After
+ public void tearDown() throws Exception
+ {
+ closeAllEditors();
+ super.tearDown();
+ }
+
+ @Test
+ public void testDeleteAClassRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ EObject aClass = nodeA.getElement();
+
+ diagram.removeChild(nodeA);
+ ((ACoreRoot)diagram.getElement()).getClasses().remove(aClass);
+
+ transaction.commit();
+ DawnAcoreTestUtil.sleep(1000);
+ }
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ assertEquals(0, aClassEditParts.size());
+ Diagram diagram = (Diagram)editor.mainEditPart().part().getModel();
+ ACoreRoot aCoreRoot = (ACoreRoot)diagram.getElement();
+
+ assertEquals(0, aCoreRoot.getClasses().size());
+ editor.close();
+ }
+
+ @Test
+ public void testDeleteAInterfaceRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 100, 100, "A", bot, editor);
+ editor.save();
+
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ EObject element = nodeA.getElement();
+
+ diagram.removeChild(nodeA);
+ ((ACoreRoot)diagram.getElement()).getInterfaces().remove(element);
+
+ transaction.commit();
+ sleep(1000);
+ }
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ assertEquals(0, aClassEditParts.size());
+ Diagram diagram = (Diagram)editor.mainEditPart().part().getModel();
+ ACoreRoot aCoreRoot = (ACoreRoot)diagram.getElement();
+
+ assertEquals(0, aCoreRoot.getInterfaces().size());
+ editor.close();
+ }
+
+ @Test
+ public void testDeleteAssociationConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aClassEditParts.get(1).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_ASSOCIATION, nodeA, nodeB, editor);
+ editor.save();
+
+ deleteEdge();
+
+ List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part());
+ assertEquals(0, connectionEditParts.size());
+ editor.close();
+ sleep(1000);
+ }
+
+ @SuppressWarnings("unchecked")
+ private List<Edge> getAllConnections(EditPart part)
+ {
+ Diagram diagram = (Diagram)part.getModel();
+ return diagram.getEdges();
+ }
+
+ @Test
+ public void testDeleteCompositionConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aClassEditParts.get(1).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_COMPOSITION, nodeA, nodeB, editor);
+ editor.save();
+
+ deleteEdge();
+
+ List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part());
+ assertEquals(0, connectionEditParts.size());
+ }
+
+ @Test
+ public void testDeleteInheritanceConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aClassEditParts.get(1).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_IHERITS, nodeA, nodeB, editor);
+ editor.save();
+
+ deleteEdge();
+
+ List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part());
+ assertEquals(0, connectionEditParts.size());
+ }
+
+ @Test
+ public void testDeleteImplementsConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 200, 200, "B", bot, editor);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ List<SWTBotGefEditPart> aInterfaceEditParts = DawnAcoreTestUtil.getAInterfaceEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aInterfaceEditParts.get(0).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_IMPLEMENTS, nodeA, nodeB, editor);
+ editor.save();
+
+ deleteEdge();
+
+ List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part());
+ assertEquals(0, connectionEditParts.size());
+ }
+
+ @Test
+ public void testDeleteAggregationConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aClassEditParts.get(1).part().getModel();
+
+ createEdge(DawnAcoreTestUtil.CONNECTION_AGGREGATION, nodeA, nodeB, editor);
+ editor.save();
+
+ deleteEdge();
+
+ List<Edge> connectionEditParts = getAllConnections(editor.mainEditPart().part());
+ assertEquals(0, connectionEditParts.size());
+ }
+
+ private void deleteEdge() throws CommitException
+ {
+ {
+ CDOSession session = openSession("repo1");
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Edge edge = (Edge)diagram.getEdges().get(0);
+ edge.setSource(null);
+ edge.setTarget(null);
+ diagram.removeEdge(edge);
+ transaction.commit();
+
+ sleep(1000);
+ }
+ }
+ /**
+ * left for future reference
+ */
+ // private class EdgeDeletionThread extends Thread
+ // {
+ // private final CountDownLatch cdl;
+ //
+ // public EdgeDeletionThread(CountDownLatch cdl)
+ // {
+ // this.cdl = cdl;
+ // setDaemon(true);
+ // }
+ //
+ // @Override
+ // public void run()
+ // {
+ // CDOSession session = openSession();
+ // CDOTransaction transaction = session.openTransaction();
+ // CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+ //
+ // Diagram diagram = (Diagram)resource2.getContents().get(0);
+ //
+ // Edge edge = (Edge)diagram.getEdges().get(0);
+ // diagram.removeEdge(edge);
+ // try
+ // {
+ // transaction.commit();
+ // }
+ // catch (CommitException ex)
+ // {
+ // throw new RuntimeException(ex);
+ // }
+ // finally
+ // {
+ // transaction.close();
+ // cdl.countDown();
+ // }
+ // }
+ // }
+}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/MultipleResourcesTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/MultipleResourcesTest.java
index e28730466f..d5ef60acc9 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/MultipleResourcesTest.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/MultipleResourcesTest.java
@@ -11,25 +11,43 @@
package org.eclipse.emf.cdo.dawn.tests.ui;
import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
-import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.ACoreRoot;
+import org.eclipse.emf.cdo.dawn.examples.acore.AcoreFactory;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassAggregationsEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassAssociationsEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassCompositionsEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassImplementedInterfacesEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassSubClassesEditPart;
import org.eclipse.emf.cdo.dawn.tests.AbstractDawnUITest;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnAcoreTestUtil;
+import org.eclipse.emf.cdo.dawn.tests.ui.util.DawnSWTBotUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
import org.eclipse.swtbot.swt.finder.junit.SWTBotJunit4ClassRunner;
-import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
-import org.eclipse.swtbot.swt.finder.widgets.SWTBotText;
-import org.hamcrest.Description;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
+import java.util.ArrayList;
import java.util.List;
/**
@@ -38,15 +56,13 @@ import java.util.List;
@RunWith(SWTBotJunit4ClassRunner.class)
public class MultipleResourcesTest extends AbstractDawnUITest
{
- private static final String A_CLASS = "AClass";
-
private static SWTGefBot bot;
@BeforeClass
public static void beforeClass() throws Exception
{
bot = new SWTGefBot();
- // DawnSWTBotUtil.initTest(bot);
+ DawnSWTBotUtil.initTest(bot);
}
@Override
@@ -60,93 +76,450 @@ public class MultipleResourcesTest extends AbstractDawnUITest
@After
public void tearDown() throws Exception
{
+ sleep(500);
closeAllEditors();
super.tearDown();
}
@Test
- public void createNewDawnDiagramAndAddElements() throws Exception
+ public void testRemotelyRenameAClass() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+
+ editor.save();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 250, 100, "B", bot, editor);
+
+ editor.save();
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(2, diagram.getChildren().size());
+
+ View nodeB = (View)diagram.getChildren().get(1);
+
+ AClass classB = (AClass)nodeB.getElement();
+
+ assertEquals("B", classB.getName());
+
+ classB.setName("C");
+ transaction.commit();
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(1);
+ AClass editorClassB = (AClass)((View)classBEditpart.part().getModel()).getElement();
+ assertEquals("C", editorClassB.getName());
+ }
+
+ @Test
+ public void testRemotelyMoveNode() throws Exception
{
- bot.menu("File").menu("New").menu("Other...").click();
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+
+ editor.save();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ assertEquals(1, diagram.getChildren().size());
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+
+ Bounds bounds = (Bounds)nodeA.getLayoutConstraint();
+ bounds.setHeight(40);
+ bounds.setWidth(30);
+ bounds.setX(200);
+ bounds.setY(250);
+
+ transaction.commit();
+
+ sleep(500);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+ Node editorNodeA = (Node)classBEditpart.part().getModel();
+ Bounds editorBounds = (Bounds)editorNodeA.getLayoutConstraint();
+
+ assertEquals(bounds.getX(), editorBounds.getX());
+ assertEquals(bounds.getY(), editorBounds.getY());
+ assertEquals(bounds.getWidth(), editorBounds.getWidth());
+ assertEquals(bounds.getHeight(), editorBounds.getHeight());
+ }
+
+ @Test
+ public void testCreateNodeRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+ assertNotNull(editor);
+ editor.save();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ ACoreRoot aCoreRoot = (ACoreRoot)diagram.getElement();
+
+ AClass newAClass = AcoreFactory.eINSTANCE.createAClass();
+ newAClass.setName("A-Team");
+
+ aCoreRoot.getClasses().add(newAClass);
+
+ Node newNode = DawnAcoreTestUtil.createNewAClassRemote(diagram, newAClass);
+
+ newNode.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ Bounds bounds = (Bounds)newNode.getLayoutConstraint();
+ bounds.setHeight(40);
+ bounds.setWidth(30);
+ bounds.setX(200);
+ bounds.setY(250);
+
+ newNode.setElement(newAClass);
+
+ assertEquals(1, diagram.getChildren().size());
+ assertEquals(1, aCoreRoot.getClasses().size());
+
+ transaction.commit();
+
+ sleep(1000);
+
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ assertEquals(1, aClassEditParts.size());
+
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(0);
+ Node editorNewNode = (Node)classBEditpart.part().getModel();
+ AClass editorNewAclass = (AClass)editorNewNode.getElement();
+
+ assertEquals("A-Team", editorNewAclass.getName());
+ Bounds editorBounds = (Bounds)editorNewNode.getLayoutConstraint();
+
+ assertEquals(bounds.getX(), editorBounds.getX());
+ assertEquals(bounds.getY(), editorBounds.getY());
+ assertEquals(bounds.getWidth(), editorBounds.getWidth());
+ assertEquals(bounds.getHeight(), editorBounds.getHeight());
+
+ }
+
+ @Test
+ public void testAddNodeRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+ assertNotNull(editor);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+
+ editor.save();
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node newNode = EcoreUtil.copy((Node)diagram.getChildren().get(0));// diagram.createChild(NotationPackage.eINSTANCE.getNode());
+
+ newNode.setLayoutConstraint(NotationFactory.eINSTANCE.createBounds());
+ Bounds bounds = (Bounds)newNode.getLayoutConstraint();
+ bounds.setHeight(40);
+ bounds.setWidth(30);
+ bounds.setX(200);
+ bounds.setY(250);
+
+ AClass newAClass = AcoreFactory.eINSTANCE.createAClass();
+ newAClass.setName("A-Team");
+ newNode.setElement(newAClass);
+
+ ACoreRoot aCoreRoot = (ACoreRoot)diagram.getElement();
+ aCoreRoot.getClasses().add(newAClass);
+
+ diagram.insertChild(newNode);
+ assertEquals(2, diagram.getChildren().size());
+ assertEquals(2, aCoreRoot.getClasses().size());
- SWTBotShell shell = bot.shell("New");
- shell.activate();
- bot.tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+ transaction.commit();
- bot.button("Next >").click();
- bot.button("Next >").click();
- bot.button("Finish").click();
+ sleep(1000);
- SWTBotGefEditor editor = bot.gefEditor("default.acore_diagram");
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
+
+ assertEquals(2, aClassEditParts.size());
+
+ SWTBotGefEditPart classBEditpart = aClassEditParts.get(1);
+ Node editorNewNode = (Node)classBEditpart.part().getModel();
+ AClass editorNewAclass = (AClass)editorNewNode.getElement();
+
+ assertEquals("A-Team", editorNewAclass.getName());
+ Bounds editorBounds = (Bounds)editorNewNode.getLayoutConstraint();
+
+ assertEquals(bounds.getX(), editorBounds.getX());
+ assertEquals(bounds.getY(), editorBounds.getY());
+ assertEquals(bounds.getWidth(), editorBounds.getWidth());
+ assertEquals(bounds.getHeight(), editorBounds.getHeight());
+ }
+
+ @Test
+ public void testModifyConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
assertNotNull(editor);
- editor.activateTool(A_CLASS);
- editor.click(100, 100);
- typeTextToFocusedWidget("A", bot, true);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
- editor.saveAndClose();
- // editor.save();
+ List<SWTBotGefEditPart> aClassEditParts = DawnAcoreTestUtil.getAClassEditParts(editor);
- // create second diagram
- bot.menu("File").menu("New").menu("Other...").click();
+ Node nodeA = (Node)aClassEditParts.get(0).part().getModel();
+ Node nodeB = (Node)aClassEditParts.get(1).part().getModel();
- shell = bot.shell("New");
- shell.activate();
- shell.setFocus();
- bot.tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
+ createEdge(DawnAcoreTestUtil.CONNECTION_ASSOCIATION, nodeA, nodeB, editor);
+ editor.save();
- bot.button("Next >").click();
- SWTBotText fileNameLabel = bot.textWithLabel("File name:");
- fileNameLabel.setText("default2.acore_diagram");
- bot.button("Next >").click();
+ {
+ List<SWTBotGefEditPart> aaClassAssociationsEditParts = DawnAcoreTestUtil.getAClassAssociationsEditParts(editor);
+ assertEquals(1, aaClassAssociationsEditParts.size());
+ EditPart part = aaClassAssociationsEditParts.get(0).part();
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(2, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
+ }
- fileNameLabel = bot.textWithLabel("File name:");
- fileNameLabel.setText("default.acore");
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+ List<?> edges = diagram.getEdges();
+ assertEquals(1, edges.size());
+
+ Edge edge = (Edge)edges.get(0);
+
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0);
- bot.button("Finish").click();
+ RelativeBendpoints relativeBendpoints = (RelativeBendpoints)edge.getBendpoints();
+
+ @SuppressWarnings("unchecked")
+ List<RelativeBendpoint> points = relativeBendpoints.getPoints();
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(points);
+ newBendPoints.add(1, relativeBendpoint);
+ relativeBendpoints.setPoints(newBendPoints);
+
+ transaction.commit();
+ sleep(1000);
+ }
+
+ List<SWTBotGefEditPart> aaClassAssociationsEditParts = DawnAcoreTestUtil.getAClassAssociationsEditParts(editor);
+ assertEquals(1, aaClassAssociationsEditParts.size());
+ EditPart part = aaClassAssociationsEditParts.get(0).part();
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
+ }
- editor = bot.gefEditor("default2.acore_diagram");
+ @Test
+ public void testCreateAssociationConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
- List<SWTBotGefEditPart> editParts = getAClassEditParts(editor);
- assertEquals(0, editParts.size());
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
- editor.activateTool(A_CLASS);
- editor.click(100, 100);
- typeTextToFocusedWidget("B", bot, true);
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
- editor.activateTool(A_CLASS);
- editor.click(300, 300);
- typeTextToFocusedWidget("C", bot, true);
- editor.click(200, 200);
- editor.saveAndClose();
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
- openEditor("/default.acore_diagram");
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ Node nodeB = (Node)diagram.getChildren().get(1);
- editor = bot.gefEditor("default.acore_diagram");
- editParts = getAClassEditParts(editor);
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>();
- assertEquals(1, editParts.size());
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0);
+ newBendPoints.add(relativeBendpoint);
- SWTBotGefEditPart swtBotGefEditPart = editParts.get(0);
- View view = (View)swtBotGefEditPart.part().getModel();
+ Edge edge = DawnAcoreTestUtil.createNewAssociationRemote(nodeA, nodeB, newBendPoints);
- assertEquals("A", ((AClass)view.getElement()).getName());
+ assertNotNull(edge);
+ transaction.commit();
+ sleep(1000);
+ }
+ List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor);
+ assertEquals(1, connectionEditParts.size());
+ EditPart part = connectionEditParts.get(0).part();
+ assertInstanceOf(AClassAssociationsEditPart.class, part);
+ assertInstanceOf(Edge.class, part.getModel());
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
}
- private List<SWTBotGefEditPart> getAClassEditParts(SWTBotGefEditor editor)
+ @Test
+ public void testCreateAggregationConnectionRemotely() throws Exception
{
- List<SWTBotGefEditPart> editParts = editor.editParts(new AbstractMatcher<AClassEditPart>()
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+ editor.save();
{
- @Override
- protected boolean doMatch(Object item)
- {
- return item instanceof AClassEditPart;
- }
-
- public void describeTo(Description description)
- {
- }
- });
- return editParts;
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ Node nodeB = (Node)diagram.getChildren().get(1);
+
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>();
+
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0);
+ newBendPoints.add(relativeBendpoint);
+
+ Edge edge = DawnAcoreTestUtil.createNewAggregationRemote(nodeA, nodeB, newBendPoints);
+
+ assertNotNull(edge);
+ transaction.commit();
+ sleep(1000);
+ }
+ List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor);
+ assertEquals(1, connectionEditParts.size());
+ EditPart part = connectionEditParts.get(0).part();
+ assertInstanceOf(AClassAggregationsEditPart.class, part);
+ assertInstanceOf(Edge.class, part.getModel());
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
+ }
+
+ @Test
+ public void testCreateCompositionConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ Node nodeB = (Node)diagram.getChildren().get(1);
+
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>();
+
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0);
+ newBendPoints.add(relativeBendpoint);
+
+ Edge edge = DawnAcoreTestUtil.createNewCompositionRemote(nodeA, nodeB, newBendPoints);
+
+ assertNotNull(edge);
+ transaction.commit();
+ sleep(1000);
+ }
+ List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor);
+ assertEquals(1, connectionEditParts.size());
+ EditPart part = connectionEditParts.get(0).part();
+ assertInstanceOf(AClassCompositionsEditPart.class, part);
+ assertInstanceOf(Edge.class, part.getModel());
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
+ }
+
+ @Test
+ public void testCreateInheritanceConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ Node nodeB = (Node)diagram.getChildren().get(1);
+
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>();
+
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0);
+ newBendPoints.add(relativeBendpoint);
+
+ Edge edge = DawnAcoreTestUtil.createNewInheritanceRelationRemote(nodeA, nodeB, newBendPoints);
+
+ assertNotNull(edge);
+ transaction.commit();
+ sleep(1000);
+ }
+ List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor);
+ assertEquals(1, connectionEditParts.size());
+ EditPart part = connectionEditParts.get(0).part();
+ assertInstanceOf(AClassSubClassesEditPart.class, part);
+ assertInstanceOf(Edge.class, part.getModel());
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
+ }
+
+ @Test
+ public void testCreateImplementsConnectionRemotely() throws Exception
+ {
+ SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
+
+ createNodeWithLabel(DawnAcoreTestUtil.A_INTERFACE, 100, 100, "A", bot, editor);
+ createNodeWithLabel(DawnAcoreTestUtil.A_CLASS, 200, 200, "B", bot, editor);
+
+ editor.save();
+ {
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource2 = transaction.getResource("/default.acore_diagram");
+
+ Diagram diagram = (Diagram)resource2.getContents().get(0);
+
+ Node nodeA = (Node)diagram.getChildren().get(0);
+ Node nodeB = (Node)diagram.getChildren().get(1);
+
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>();
+
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(0, 100, -100, 0);
+ newBendPoints.add(relativeBendpoint);
+
+ Edge edge = DawnAcoreTestUtil.createNewImplementsRelationRemote(nodeA, nodeB, newBendPoints);
+
+ assertNotNull(edge);
+ transaction.commit();
+ sleep(1000);
+ }
+ List<SWTBotGefEditPart> connectionEditParts = DawnSWTBotUtil.getAllConnections(editor);
+ assertEquals(1, connectionEditParts.size());
+ EditPart part = connectionEditParts.get(0).part();
+ assertInstanceOf(AClassImplementedInterfacesEditPart.class, part);
+ assertInstanceOf(Edge.class, part.getModel());
+ Edge editorEdge = (Edge)part.getModel();
+ assertEquals(3, ((RelativeBendpoints)editorEdge.getBendpoints()).getPoints().size());
}
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/SimpleDiagramTest.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/SimpleDiagramTest.java
index 6a72802983..239b0d4e0c 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/SimpleDiagramTest.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/SimpleDiagramTest.java
@@ -41,6 +41,7 @@ import org.junit.runner.RunWith;
import java.util.ArrayList;
import java.util.List;
+import java.util.Locale;
/**
* @author Martin Fluegge
@@ -50,6 +51,10 @@ public class SimpleDiagramTest extends AbstractDawnUITest
{
private static SWTGefBot bot;
+ {
+ Locale.setDefault(Locale.US);
+ }
+
@BeforeClass
public static void beforeClass() throws Exception
{
@@ -73,7 +78,7 @@ public class SimpleDiagramTest extends AbstractDawnUITest
}
@Test
- public void createNewDawnDiagramAndAddElements() throws Exception
+ public void testCreateNewDawnDiagramAndAddElements() throws Exception
{
SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
assertNotNull(editor);
@@ -89,7 +94,6 @@ public class SimpleDiagramTest extends AbstractDawnUITest
CDOView view = session.openView();
CDOResource diagramResource = view.getResource("/default.acore_diagram");
- // TODO: Fix this naming after BUG 321024 is solved.
CDOResource semanticResource = view.getResource("/default.acore");
assertNotNull(diagramResource);
@@ -111,7 +115,7 @@ public class SimpleDiagramTest extends AbstractDawnUITest
}
@Test
- public void createNewDawnDiagramAndAddElementsWithEdges() throws Exception
+ public void testCreateNewDawnDiagramAndAddElementsWithEdges() throws Exception
{
SWTBotGefEditor editor = DawnAcoreTestUtil.openNewAcoreEditor("default.acore_diagram", bot);
assertNotNull(editor);
@@ -135,7 +139,6 @@ public class SimpleDiagramTest extends AbstractDawnUITest
CDOResource diagramResource = view.getResource("/default.acore_diagram");
- // TODO: Fix this naming after BUG 321024 is solved.
CDOResource semanticResource = view.getResource("/default.acore");
assertNotNull(diagramResource);
@@ -154,7 +157,6 @@ public class SimpleDiagramTest extends AbstractDawnUITest
name++;
}
view.close();
- // session.close();
}
// for (SWTBotGefEditPart ep : connectionEditParts)
@@ -189,7 +191,6 @@ public class SimpleDiagramTest extends AbstractDawnUITest
CDOResource diagramResource = view.getResource("/default.acore_diagram");
- // TODO: Fix this naming after BUG 321024 is solved.
CDOResource semanticResource = view.getResource("/default.acore");
assertNotNull(diagramResource);
@@ -228,7 +229,6 @@ public class SimpleDiagramTest extends AbstractDawnUITest
CDOResource diagramResource = view.getResource("/default.acore_diagram");
- // TODO: Fix this naming after BUG 321024 is solved.
CDOResource semanticResource = view.getResource("/default.acore");
assertNotNull(diagramResource);
@@ -267,7 +267,6 @@ public class SimpleDiagramTest extends AbstractDawnUITest
CDOResource diagramResource = view.getResource("/default.acore_diagram");
- // TODO: Fix this naming after BUG 321024 is solved.
CDOResource semanticResource = view.getResource("/default.acore");
assertNotNull(diagramResource);
@@ -316,7 +315,6 @@ public class SimpleDiagramTest extends AbstractDawnUITest
CDOResource diagramResource = view.getResource("/default.acore_diagram");
- // TODO: Fix this naming after BUG 321024 is solved.
CDOResource semanticResource = view.getResource("/default.acore");
assertNotNull(diagramResource);
@@ -352,7 +350,6 @@ public class SimpleDiagramTest extends AbstractDawnUITest
assertEquals(1, D.getCompositions().size());
assertEquals(C, D.getCompositions().get(0));
view.close();
- // session.close();
}
editor.close();
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java
index 16b4edd9ca..e8d8c37661 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnAcoreTestUtil.java
@@ -10,10 +10,38 @@
*/
package org.eclipse.emf.cdo.dawn.tests.ui.util;
+import org.eclipse.emf.cdo.dawn.appearance.DawnAppearancer;
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassAggregationsEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassAssociationsEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassCompositionsEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassImplementedInterfacesEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassSubClassesEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AInterfaceEditPart;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.part.AcoreVisualIDRegistry;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreElementTypes;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.providers.AcoreViewProvider;
+
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.LineBorder;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
+import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotShell;
+import org.hamcrest.Description;
+
+import java.util.List;
+
/**
* @author Martin Fluegge
*/
@@ -37,6 +65,8 @@ public class DawnAcoreTestUtil
public static final String CONNECTION_COMPOSITION = "composition";
+ private static IViewProvider viewProvider = new AcoreViewProvider();
+
public static SWTBotGefEditor openNewAcoreEditor(String diagramResourceName, SWTGefBot bot)
{
bot.menu("File").menu("New").menu("Other...").click();
@@ -46,8 +76,119 @@ public class DawnAcoreTestUtil
bot.tree().expandNode("Dawn Examples").select("Dawn Acore Diagram");
bot.button("Next >").click();
bot.button("Finish").click();
-
SWTBotGefEditor editor = bot.gefEditor(diagramResourceName);
return editor;
}
+
+ public static List<SWTBotGefEditPart> getAClassEditParts(SWTBotGefEditor editor)
+ {
+ List<SWTBotGefEditPart> editParts = editor.editParts(new AbstractMatcher<AClassEditPart>()
+ {
+ @Override
+ protected boolean doMatch(Object item)
+ {
+ return item instanceof AClassEditPart;
+ }
+
+ public void describeTo(Description description)
+ {
+ }
+ });
+ return editParts;
+ }
+
+ public static List<SWTBotGefEditPart> getAInterfaceEditParts(SWTBotGefEditor editor)
+ {
+ List<SWTBotGefEditPart> editParts = editor.editParts(new AbstractMatcher<AInterfaceEditPart>()
+ {
+ @Override
+ protected boolean doMatch(Object item)
+ {
+ return item instanceof AInterfaceEditPart;
+ }
+
+ public void describeTo(Description description)
+ {
+ }
+ });
+ return editParts;
+ }
+
+ public static List<SWTBotGefEditPart> getAClassAssociationsEditParts(SWTBotGefEditor editor)
+ {
+ List<SWTBotGefEditPart> editParts = getAClassEditParts(editor);
+ return DawnSWTBotUtil.getConnectionEditParts(editor, AClassAssociationsEditPart.class, editParts);
+ }
+
+ public static Node createNewAClassRemote(Diagram diagram, AClass newAClass)
+ {
+ String type = AcoreVisualIDRegistry.getType(AClassEditPart.VISUAL_ID);
+ return DawnSWTBotUtil.createNewNodeRemote(diagram, newAClass, type);
+ }
+
+ // public static Edge createNewAssociationRemote(Node source, Node target)
+ // {
+ // String type = AcoreVisualIDRegistry.getType(AClassAssociationsEditPart.VISUAL_ID);
+ // Edge newEdge = DawnSWTBotUtil.createEdgeRemote(source, target, type);
+ // return newEdge;
+ // }
+
+ public static Edge createNewAssociationRemote(Node source, Node target, List<RelativeBendpoint> bendpoints)
+ {
+ String type = AcoreVisualIDRegistry.getType(AClassAssociationsEditPart.VISUAL_ID);
+ return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassAssociations_4003, bendpoints,
+ viewProvider);
+ }
+
+ public static Edge createNewImplementsRelationRemote(Node source, Node target, List<RelativeBendpoint> bendpoints)
+ {
+ String type = AcoreVisualIDRegistry.getType(AClassImplementedInterfacesEditPart.VISUAL_ID);
+ return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassImplementedInterfaces_4002,
+ bendpoints, viewProvider);
+ }
+
+ public static Edge createNewInheritanceRelationRemote(Node source, Node target, List<RelativeBendpoint> bendpoints)
+ {
+ String type = AcoreVisualIDRegistry.getType(AClassSubClassesEditPart.VISUAL_ID);
+ return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassSubClasses_4001, bendpoints,
+ viewProvider);
+ }
+
+ public static Edge createNewCompositionRemote(Node source, Node target, List<RelativeBendpoint> bendpoints)
+ {
+ String type = AcoreVisualIDRegistry.getType(AClassCompositionsEditPart.VISUAL_ID);
+ return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassCompositions_4005, bendpoints,
+ viewProvider);
+ }
+
+ public static Edge createNewAggregationRemote(Node source, Node target, List<RelativeBendpoint> bendpoints)
+ {
+ String type = AcoreVisualIDRegistry.getType(AClassAggregationsEditPart.VISUAL_ID);
+ return DawnSWTBotUtil.createEdgeRemote(source, target, type, AcoreElementTypes.AClassAggregations_4004, bendpoints,
+ viewProvider);
+ }
+
+ public static void sleep(int seconds)
+ {
+ try
+ {
+ Thread.sleep(seconds);
+ }
+ catch (InterruptedException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ public static boolean showsConflict(EditPart editPart)
+ {
+ if (editPart instanceof AClassEditPart || editPart instanceof AInterfaceEditPart)
+ {
+ GraphicalEditPart e = (GraphicalEditPart)editPart;
+
+ IFigure figure = e.getFigure();
+ return ((LineBorder)figure.getBorder()).getColor().equals(DawnAppearancer.COLOR_DELETE_CONFLICT);
+ }
+ return false;
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotUtil.java b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotUtil.java
index cab47a02dc..2148ef7f6e 100644
--- a/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotUtil.java
+++ b/plugins/org.eclipse.emf.cdo.dawn.tests/src/org/eclipse/emf/cdo/dawn/tests/ui/util/DawnSWTBotUtil.java
@@ -10,8 +10,35 @@
*/
package org.eclipse.emf.cdo.dawn.tests.ui.util;
+import org.eclipse.emf.cdo.dawn.examples.acore.AClass;
+import org.eclipse.emf.cdo.dawn.examples.acore.diagram.edit.parts.AClassEditPart;
+import org.eclipse.emf.cdo.dawn.synchronize.DawnConflictHelper;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.gef.EditPart;
+import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
+import org.eclipse.gmf.runtime.diagram.core.providers.IViewProvider;
+import org.eclipse.gmf.runtime.diagram.core.services.ViewService;
+import org.eclipse.gmf.runtime.diagram.core.util.ViewUtil;
+import org.eclipse.gmf.runtime.emf.type.core.IElementType;
+import org.eclipse.gmf.runtime.notation.Bounds;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.Edge;
+import org.eclipse.gmf.runtime.notation.Node;
+import org.eclipse.gmf.runtime.notation.RelativeBendpoints;
+import org.eclipse.gmf.runtime.notation.datatype.RelativeBendpoint;
import org.eclipse.swtbot.eclipse.finder.SWTWorkbenchBot;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefConnectionEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
+import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditor;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
+import org.eclipse.swtbot.swt.finder.matchers.AbstractMatcher;
+
+import org.hamcrest.Description;
+
+import java.util.ArrayList;
+import java.util.List;
/**
* @author Martin Fluegge
@@ -37,4 +64,164 @@ public class DawnSWTBotUtil
}
}
+ public static List<SWTBotGefEditPart> getAllEditParts(SWTBotGefEditor editor)
+ {
+ List<SWTBotGefEditPart> editParts = editor.editParts(new AbstractMatcher<EditPart>()
+ {
+ @Override
+ protected boolean doMatch(Object item)
+ {
+ return item instanceof AClassEditPart;
+ }
+
+ public void describeTo(Description description)
+ {
+ }
+ });
+ return editParts;
+ }
+
+ public static List<SWTBotGefEditPart> getConnectionEditParts(SWTBotGefEditor editor, Class<? extends EditPart> clazz)
+ {
+ List<SWTBotGefEditPart> editParts = getAllEditParts(editor);
+ return getConnectionEditParts(editor, clazz, editParts);
+ }
+
+ public static List<SWTBotGefEditPart> getConnectionEditParts(SWTBotGefEditor editor, Class<? extends EditPart> clazz,
+ List<SWTBotGefEditPart> editParts)
+ {
+
+ List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>();
+ for (SWTBotGefEditPart editPart : editParts)
+ {
+
+ for (SWTBotGefConnectionEditPart sourceConnection : editPart.sourceConnections())
+ {
+ if (clazz.isInstance(sourceConnection.part()))
+ {
+ ret.add(sourceConnection);
+ }
+ }
+ }
+ return ret;
+ }
+
+ static Object monitor = new Object();
+
+ /**
+ * returns all ConnectionEditparts from teh given editor
+ */
+ public static List<SWTBotGefEditPart> getAllConnections(final SWTBotGefEditor editor)
+ {
+ AbstractMatcher<EditPart> matcher = new AbstractMatcher<EditPart>()
+ {
+ @Override
+ protected boolean doMatch(Object item)
+ {
+ return true;
+ }
+
+ public void describeTo(Description description)
+ {
+ }
+ };
+ List<SWTBotGefEditPart> aClassEditParts = editor.editParts(matcher);
+
+ List<SWTBotGefEditPart> ret = new ArrayList<SWTBotGefEditPart>();
+
+ for (SWTBotGefEditPart editPart : aClassEditParts)
+ {
+ ret.addAll(editPart.sourceConnections());
+ }
+ return ret;
+ }
+
+ public static Node createNewNodeRemote(Diagram diagram, AClass newAClass, String type)
+ {
+ Node newNode = ViewService.createNode(diagram, newAClass, type, PreferencesHint.USE_DEFAULTS);
+ return newNode;
+ }
+
+ public static Edge createEdgeRemote(Node source, Node target, String type, IElementType elementType,
+ List<RelativeBendpoint> bendpoints, IViewProvider viewProvider)
+ {
+ Edge edge = viewProvider.createEdge(elementType, source.getDiagram(), type, ViewUtil.APPEND, true,
+ PreferencesHint.USE_DEFAULTS);
+
+ edge.setTarget(target);
+ edge.setSource(source);
+
+ RelativeBendpoints exitingBendpoints = (RelativeBendpoints)edge.getBendpoints();
+ @SuppressWarnings("unchecked")
+ List<RelativeBendpoint> points = exitingBendpoints.getPoints();
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(points);
+ newBendPoints.addAll(1, bendpoints);
+ exitingBendpoints.setPoints(newBendPoints);
+
+ return edge;
+ }
+
+ public static void addBendPoint(Edge edge, int sourceX, int sourceY, int targetX, int targetY)
+ {
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>();
+ RelativeBendpoint relativeBendpoint = new RelativeBendpoint(sourceX, sourceY, targetX, targetY);
+ newBendPoints.add(relativeBendpoint);
+ DawnSWTBotUtil.addBendpoints(edge, newBendPoints);
+ }
+
+ public static void addBendpoints(Edge edge, List<RelativeBendpoint> bendpoints)
+ {
+ RelativeBendpoints exitingBendpoints = (RelativeBendpoints)edge.getBendpoints();
+ @SuppressWarnings("unchecked")
+ List<RelativeBendpoint> points = exitingBendpoints.getPoints();
+ List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(points);
+ newBendPoints.addAll(1, bendpoints);
+ exitingBendpoints.setPoints(newBendPoints);
+ }
+
+ public static Object showsConflict(EditPart editPart)
+ {
+ return DawnConflictHelper.isConflicted((EObject)editPart.getModel());
+ }
+
+ public static void moveNodeRemotely(Node nodeA, int x, int y)
+ {
+ Bounds bounds = (Bounds)nodeA.getLayoutConstraint();
+ bounds.setX(x);
+ bounds.setY(y);
+ }
+
+ public static void resizeNodeRemotely(Node nodeA, int height, int width)
+ {
+ Bounds bounds = (Bounds)nodeA.getLayoutConstraint();
+ bounds.setHeight(height);
+ bounds.setWidth(width);
+ }
+
+ // public static Edge createEdgeRemote(Node source, Node target, String type)
+ // {
+ // Edge newEdge = ViewService.createEdge(source, target, type, PreferencesHint.USE_DEFAULTS);
+ //
+ // return newEdge;
+ // }
+ //
+ // public static Edge createEdgeRemote(Node source, Node target, EObject model, String type)
+ // {
+ // Edge newEdge = ViewService.createEdge(source, target, model, type, PreferencesHint.USE_DEFAULTS);
+ // return newEdge;
+ // }
+ //
+ // public static Edge createEdgeRemote(Node source, Node target, String type, List<RelativeBendpoint> bendPoints)
+ // {
+ // Edge edge = createEdgeRemote(source, target, type);
+ // RelativeBendpoints exitingBendpoints = (RelativeBendpoints)edge.getBendpoints();
+ //
+ // @SuppressWarnings("unchecked")
+ // List<RelativeBendpoint> points = exitingBendpoints.getPoints();
+ // List<RelativeBendpoint> newBendPoints = new ArrayList<RelativeBendpoint>(points);
+ // newBendPoints.addAll(1, bendPoints);
+ // exitingBendpoints.setPoints(newBendPoints);
+ //
+ // return edge;
+ // }
}
diff --git a/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java b/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java
index ac6e666cc3..1d257ef1e9 100644
--- a/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java
+++ b/plugins/org.eclipse.emf.cdo.tests.ui/src/org/eclipse/emf/cdo/tests/ui/AbstractCDOUITest.java
@@ -28,6 +28,9 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.WorkbenchException;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
/**
* @author Martin Fluegge
*/
@@ -44,6 +47,28 @@ public abstract class AbstractCDOUITest extends AbstractCDOTest
protected void closeAllEditors()
{
+ final CountDownLatch countDownLatch = new CountDownLatch(1);
+ Display.getDefault().asyncExec(new Runnable()
+ {
+
+ public void run()
+ {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(false);
+ countDownLatch.countDown();
+ }
+ });
+ try
+ {
+ countDownLatch.await(5000, TimeUnit.MILLISECONDS);
+ }
+ catch (InterruptedException ex)
+ {
+ throw new RuntimeException(ex);
+ }
+ }
+
+ protected void closeAllEditorsSync()
+ {
UIThreadRunnable.syncExec(new VoidResult()
{
public void run()
@@ -55,7 +80,8 @@ public abstract class AbstractCDOUITest extends AbstractCDOTest
protected void resetWorkbench()
{
- UIThreadRunnable.syncExec(new VoidResult()
+ final CountDownLatch countDownLatch = new CountDownLatch(1);
+ UIThreadRunnable.asyncExec(new VoidResult()
{
public void run()
{
@@ -66,7 +92,7 @@ public abstract class AbstractCDOUITest extends AbstractCDOTest
IWorkbenchPage page = workbenchWindow.getActivePage();
Shell activeShell = Display.getCurrent().getActiveShell();
- if (activeShell != workbenchWindow.getShell())
+ if (activeShell != workbenchWindow.getShell() && activeShell != null)
{
activeShell.close();
}
@@ -83,8 +109,20 @@ public abstract class AbstractCDOUITest extends AbstractCDOTest
{
throw new RuntimeException(e);
}
+ finally
+ {
+ countDownLatch.countDown();
+ }
}
});
+ try
+ {
+ countDownLatch.await(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS);
+ }
+ catch (InterruptedException ex)
+ {
+ throw new RuntimeException(ex);
+ }
}
/**

Back to the top