Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Constant2012-08-22 15:08:20 +0000
committerOlivier Constant2012-08-22 15:08:20 +0000
commit5d0ee9c6640ab3e8367a3ad279e534247679a117 (patch)
tree1c2f462932612b4adc2a7045755866bab2aaae5c /tests/org.eclipse.emf.diffmerge.tests.wt.elements
parent2697446190ca15017df9e898bc6a62807af1b5e3 (diff)
downloadorg.eclipse.emf.diffmerge.core-5d0ee9c6640ab3e8367a3ad279e534247679a117.tar.gz
org.eclipse.emf.diffmerge.core-5d0ee9c6640ab3e8367a3ad279e534247679a117.tar.xz
org.eclipse.emf.diffmerge.core-5d0ee9c6640ab3e8367a3ad279e534247679a117.zip
Series of tests based on WindowTester.
Diffstat (limited to 'tests/org.eclipse.emf.diffmerge.tests.wt.elements')
-rw-r--r--tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/DiffMergeTestCase.java100
-rw-r--r--tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/cases/GraphTest.java56
-rw-r--r--tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/cases/HierarchyAdditionTest.java94
3 files changed, 83 insertions, 167 deletions
diff --git a/tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/DiffMergeTestCase.java b/tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/DiffMergeTestCase.java
index d1f56647..62681455 100644
--- a/tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/DiffMergeTestCase.java
+++ b/tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/DiffMergeTestCase.java
@@ -9,7 +9,10 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.swt.custom.ViewForm;
+import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.IPerspectiveDescriptor;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import com.windowtester.runtime.IUIContext;
@@ -19,6 +22,7 @@ import com.windowtester.runtime.swt.condition.shell.ShellDisposedCondition;
import com.windowtester.runtime.swt.condition.shell.ShellShowingCondition;
import com.windowtester.runtime.swt.locator.ButtonLocator;
import com.windowtester.runtime.swt.locator.CTabItemLocator;
+import com.windowtester.runtime.swt.locator.SWTWidgetLocator;
import com.windowtester.runtime.swt.locator.TreeItemLocator;
import com.windowtester.runtime.swt.locator.eclipse.ViewLocator;
import com.windowtester.runtime.swt.locator.eclipse.WorkbenchLocator;
@@ -39,14 +43,71 @@ public abstract class DiffMergeTestCase extends UITestCaseSWT {
/**
+ * Check that the persistent form of the 2 models at the current path are identical
+ * @throws Exception
+ */
+ protected void checkIdentical() throws Exception {
+ IUIContext ui = getUI();
+ final String current1 = CURRENT_PROJECT_NAME + SEP + MODEL1;
+ final String current2 = CURRENT_PROJECT_NAME + SEP + MODEL2;
+ ui.click(new TreeItemLocator(current1,
+ new ViewLocator("org.eclipse.jdt.ui.PackageExplorer")));
+ ui.click(1, new TreeItemLocator(current2,
+ new ViewLocator("org.eclipse.jdt.ui.PackageExplorer")), WT.CTRL);
+ ui.contextClick(new TreeItemLocator(current1,
+ new ViewLocator("org.eclipse.jdt.ui.PackageExplorer")),
+ "Compare With/Each Other as models");
+ ui.wait(new ShellShowingCondition("EMF Diff/Merge"));
+ ui.click(new ButtonLocator("&Finish"));
+ ui.wait(new ShellShowingCondition("Compare"));
+ ui.click(new ButtonLocator("OK"));
+ ui.wait(new ShellDisposedCondition("Compare"));
+ }
+
+ /**
+ * Check that the given model is valid
+ * @param isModel1 whether model1 is considered, or model2
+ * @throws Exception
+ */
+ protected void checkModelIsValid(boolean isModel1) throws Exception {
+ IUIContext ui = getUI();
+ String fileName = isModel1? MODEL1: MODEL2;
+ ui.click(new TreeItemLocator(CURRENT_PROJECT_NAME + SEP + fileName,
+ new ViewLocator("org.eclipse.jdt.ui.PackageExplorer")));
+ ui.contextClick(new TreeItemLocator(CURRENT_PROJECT_NAME + SEP + fileName,
+ new ViewLocator("org.eclipse.jdt.ui.PackageExplorer")),
+ "Open With/Elements Model Editor");
+ final String TREE_ROOT_LABEL = "platform:\\\\/resource\\\\/" + CURRENT_PROJECT_NAME + "\\\\/" + fileName;
+ ui.contextClick(
+ new TreeItemLocator(
+ TREE_ROOT_LABEL,
+ new SWTWidgetLocator(Tree.class, new SWTWidgetLocator(
+ ViewForm.class))), "Validate");
+ ui.wait(new ShellShowingCondition("Validation Information"));
+ ui.click(new ButtonLocator("OK"));
+ ui.wait(new ShellDisposedCondition("Validation Information"));
+ ui.wait(new ShellDisposedCondition("Progress Information"));
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ activePage.closeEditor(activePage.getActiveEditor(), false);
+ }
+ });
+ }
+
+ /**
* Apply the checks that must hold before and after save
* @throws Exception
*/
- protected void checkPersistency() throws Exception {
+ protected void checkPersistence() throws Exception {
IUIContext ui = getUI();
- persistencyChecks(ui);
- saveAndRecompareInFolder();
- persistencyChecks(ui);
+ persistenceChecks(ui);
+ closeCompareEditor(true);
+ checkModelIsValid(true);
+ checkModelIsValid(false);
+ compareInFolder(false);
+ persistenceChecks(ui);
}
/**
@@ -67,6 +128,19 @@ public abstract class DiffMergeTestCase extends UITestCaseSWT {
}
/**
+ * Close all editors
+ */
+ protected void closeEditors() {
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ activePage.closeAllEditors(false);
+ }
+ });
+ }
+
+ /**
* Compare the 2 models at the current path
* @param restore whether the saved version of the files should be restored first
* @throws Exception
@@ -93,14 +167,17 @@ public abstract class DiffMergeTestCase extends UITestCaseSWT {
* Return the path to the models to be compared
* @return a non-null path in the examples folder, e.g., "FolderName"
*/
- protected abstract String getModelPath();
+ protected String getModelPath() {
+ // Default implementation
+ return getClass().getSimpleName();
+ }
/**
* Define the checks that must hold before and after save
* @param ui a non-null UI context
* @throws Exception
*/
- protected void persistencyChecks(IUIContext ui) throws Exception {
+ protected void persistenceChecks(IUIContext ui) throws Exception {
// Override if checkPersistency() is used
}
@@ -127,17 +204,6 @@ public abstract class DiffMergeTestCase extends UITestCaseSWT {
predefinedFile2.copy(file2.getFullPath(), true, null);
}
- /**
- * Save and close the current comparison and re-open it at the given path
- * @param ui a non-null WindowTester UI context
- * @param path a non-null workspace path, e.g., "ProjectName/FolderName"
- * @throws Exception
- */
- protected void saveAndRecompareInFolder() throws Exception {
- closeCompareEditor(true);
- compareInFolder(false);
- }
-
/* @see junit.framework.TestCase#setUp()
*/
protected void setUp() throws Exception {
diff --git a/tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/cases/GraphTest.java b/tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/cases/GraphTest.java
deleted file mode 100644
index d0b9529d..00000000
--- a/tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/cases/GraphTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.eclipse.emf.diffmerge.tests.wt.elements.cases;
-
-import org.eclipse.emf.diffmerge.tests.wt.elements.DiffMergeTestCase;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-
-import com.windowtester.runtime.IUIContext;
-import com.windowtester.runtime.swt.locator.SWTWidgetLocator;
-import com.windowtester.runtime.swt.locator.TreeItemLocator;
-
-public class GraphTest extends DiffMergeTestCase {
-
- /**
- * @see org.eclipse.emf.diffmerge.tests.wt.elements.DiffMergeTestCase#getModelPath()
- */
- @Override
- protected String getModelPath() {
- return "Graph";
- }
-
- /**
- * Main test method.
- */
- public void testGraph() throws Exception {
- IUIContext ui = getUI();
- compareInFolder(true);
- ui.click(new TreeItemLocator("Root (8)/Edge N3-to-NB-Container",
- new SWTWidgetLocator(Tree.class, new SWTWidgetLocator(Composite.class,
- 0, new SWTWidgetLocator(SashForm.class)))));
- ui.click(new TreeItemLocator("Root (8)/Node N2 (4)", new SWTWidgetLocator(
- Tree.class, new SWTWidgetLocator(Composite.class, 0,
- new SWTWidgetLocator(SashForm.class)))));
- ui.click(new TreeItemLocator("Root (8)", new SWTWidgetLocator(Tree.class,
- new SWTWidgetLocator(Composite.class, 0, new SWTWidgetLocator(
- SashForm.class)))));
- ui.click(new TreeItemLocator("Root (8)/Node N2 (4)/Node N22 (2)",
- new SWTWidgetLocator(Tree.class, new SWTWidgetLocator(Composite.class,
- 0, new SWTWidgetLocator(SashForm.class)))));
- ui.click(new TreeItemLocator("Root (8)/Node N2 (4)/Node N22 (2)/Node N221",
- new SWTWidgetLocator(Tree.class, new SWTWidgetLocator(Composite.class,
- 0, new SWTWidgetLocator(SashForm.class)))));
- ui.click(new TreeItemLocator(
- "Root (8)/Node N2 (4)/Node N22 (2)/Edge N221-to-N3",
- new SWTWidgetLocator(Tree.class, new SWTWidgetLocator(Composite.class,
- 0, new SWTWidgetLocator(SashForm.class)))));
- ui.click(new TreeItemLocator("Root (8)/Node N3 (2)", new SWTWidgetLocator(
- Tree.class, new SWTWidgetLocator(Composite.class, 0,
- new SWTWidgetLocator(SashForm.class)))));
- ui.click(new TreeItemLocator("Root (8)/Referencing Node ToN221", new SWTWidgetLocator(
- Tree.class, new SWTWidgetLocator(Composite.class, 0,
- new SWTWidgetLocator(SashForm.class)))));
- closeCompareEditor(false);
- }
-
-} \ No newline at end of file
diff --git a/tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/cases/HierarchyAdditionTest.java b/tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/cases/HierarchyAdditionTest.java
deleted file mode 100644
index 68882bfb..00000000
--- a/tests/org.eclipse.emf.diffmerge.tests.wt.elements/src/org/eclipse/emf/diffmerge/tests/wt/elements/cases/HierarchyAdditionTest.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package org.eclipse.emf.diffmerge.tests.wt.elements.cases;
-
-import org.eclipse.emf.diffmerge.tests.wt.elements.DiffMergeTestCase;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.swt.widgets.Tree;
-
-import com.windowtester.runtime.IUIContext;
-import com.windowtester.runtime.swt.condition.shell.ShellDisposedCondition;
-import com.windowtester.runtime.swt.condition.shell.ShellShowingCondition;
-import com.windowtester.runtime.swt.locator.ButtonLocator;
-import com.windowtester.runtime.swt.locator.SWTWidgetLocator;
-import com.windowtester.runtime.swt.locator.TreeItemLocator;
-
-public class HierarchyAdditionTest extends DiffMergeTestCase {
-
- /**
- * @see org.eclipse.emf.diffmerge.tests.wt.elements.DiffMergeTestCase#getModelPath()
- */
- @Override
- protected String getModelPath() {
- return "HierarchyAddition";
- }
-
- /**
- * Main test method.
- */
- public void testHierarchyAddition() throws Exception {
- IUIContext ui = getUI();
- compareInFolder(true);
- ui.click(new TreeItemLocator("Root (8)/Element B (7)/Element D (2)",
- new SWTWidgetLocator(Tree.class, new SWTWidgetLocator(Composite.class,
- 0, new SWTWidgetLocator(SashForm.class)))));
- ui.click(new SWTWidgetLocator(ToolItem.class, "", 2, new SWTWidgetLocator(
- ToolBar.class, new SWTWidgetLocator(Composite.class,
- new SWTWidgetLocator(Composite.class, 1, new SWTWidgetLocator(
- SashForm.class))))));
- ui.wait(new ShellShowingCondition("Merge Operation"));
- ui.click(new ButtonLocator("Include differences in children"));
- ui.click(new ButtonLocator("OK"));
- ui.wait(new ShellDisposedCondition("Merge Operation"));
- ui.wait(new ShellDisposedCondition("Progress Information"));
- ui.wait(new ShellDisposedCondition("Progress Information"));
- ui.wait(new ShellShowingCondition("Merge Operation"));
- ui.click(new TreeItemLocator("Element E/Deletion", new SWTWidgetLocator(
- Tree.class, new SWTWidgetLocator(Group.class, "Implied changes"))));
- ui.click(new TreeItemLocator("Element F/Deletion", new SWTWidgetLocator(
- Tree.class, new SWTWidgetLocator(Group.class, "Implied changes"))));
- ui.click(new ButtonLocator("OK"));
- ui.wait(new ShellDisposedCondition("Merge Operation"));
- ui.wait(new ShellDisposedCondition("Progress Information"));
- ui.click(new TreeItemLocator(
- "Root (5)/Element B (4)/Element G (2)/Element H", new SWTWidgetLocator(
- Tree.class, new SWTWidgetLocator(Composite.class, 0,
- new SWTWidgetLocator(SashForm.class)))));
- ui.click(new SWTWidgetLocator(ToolItem.class, "", 0, new SWTWidgetLocator(
- ToolBar.class, new SWTWidgetLocator(Composite.class,
- new SWTWidgetLocator(Composite.class, 1, new SWTWidgetLocator(
- SashForm.class))))));
- ui.wait(new ShellDisposedCondition("Progress Information"));
- ui.wait(new ShellDisposedCondition("Progress Information"));
- ui.wait(new ShellShowingCondition("Merge Operation"));
- ui.click(new TreeItemLocator(
- "Element B/Addition into Root (via 'content')", new SWTWidgetLocator(
- Tree.class, new SWTWidgetLocator(Group.class, "Implied changes"))));
- ui.click(new TreeItemLocator(
- "Element G/Addition into Element B (via 'manyContent')",
- new SWTWidgetLocator(Tree.class, new SWTWidgetLocator(Group.class,
- "Implied changes"))));
- ui.click(new ButtonLocator("OK"));
- ui.wait(new ShellDisposedCondition("Merge Operation"));
- ui.wait(new ShellDisposedCondition("Progress Information"));
- checkPersistency();
- closeCompareEditor(false);
- }
-
- /**
- * @see org.eclipse.emf.diffmerge.tests.wt.elements.DiffMergeTestCase#persistencyChecks(com.windowtester.runtime.IUIContext)
- */
- @Override
- protected void persistencyChecks(IUIContext ui) throws Exception {
- ui.click(new TreeItemLocator(
- "Root (2)/Element B (2)/Element G (1)/Element I", new SWTWidgetLocator(
- Tree.class, new SWTWidgetLocator(Composite.class, 0,
- new SWTWidgetLocator(SashForm.class)))));
- ui.click(new TreeItemLocator("Root (2)/Element B (2)/Element C",
- new SWTWidgetLocator(Tree.class, new SWTWidgetLocator(Composite.class,
- 0, new SWTWidgetLocator(SashForm.class)))));
- }
-
-} \ No newline at end of file

Back to the top