Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Fleck2016-12-07 16:18:51 +0000
committerlgoubet2019-07-16 12:52:37 +0000
commit42f0b44af4e8d8b4a953234913d514a03c4225bb (patch)
tree71dc9dea79e3d997bdff0b7694d40227366c7c9f
parent621b4e5d9b7b73cd31d6d4c32b0ce86f4e4b7dd8 (diff)
downloadorg.eclipse.emf.compare-3.3.8M2.tar.gz
org.eclipse.emf.compare-3.3.8M2.tar.xz
org.eclipse.emf.compare-3.3.8M2.zip
[506928] ComparisonScopeEditorInput does not respect configuration3.3.8M2
Initialize comparison input with comparison configuration. Includes tests. Bug: 506928 Change-Id: I39c07e0093211170a81aba07fe082d0aafc74afa Also-by: Tobias Ortmayr <tobias.ortmayr@gmail.com> Signed-off-by: Martin Fleck <mfleck@eclipsesource.com>
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/TestBug506928.java144
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/data/_506928/left.nodes6
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/data/_506928/origin.nodes5
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/data/_506928/right.nodes4
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/suite/BugsTestSuite.java7
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/editor/ComparisonScopeEditorInput.java11
6 files changed, 172 insertions, 5 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/TestBug506928.java b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/TestBug506928.java
new file mode 100644
index 000000000..9d8dd5fb5
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/TestBug506928.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2016 EclipseSource Services GmbH 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:
+ * Tobias Ortmayr - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.compare.ide.ui.tests.internal.editor;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.compare.EMFCompare;
+import org.eclipse.emf.compare.domain.ICompareEditingDomain;
+import org.eclipse.emf.compare.domain.impl.EMFCompareEditingDomain;
+import org.eclipse.emf.compare.ide.ui.internal.configuration.EMFCompareConfiguration;
+import org.eclipse.emf.compare.ide.ui.internal.editor.ComparisonScopeEditorInput;
+import org.eclipse.emf.compare.ide.ui.internal.editor.ComparisonScopeInput;
+import org.eclipse.emf.compare.scope.DefaultComparisonScope;
+import org.eclipse.emf.compare.scope.IComparisonScope;
+import org.eclipse.emf.compare.tests.framework.AbstractInputData;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests that the {@link ComparisonScopeEditorInput} is correctly initialized with the
+ * {@link EMFCompareConfiguration}. This test is related to the bug
+ * <a href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=506928">506928</a>
+ *
+ * @author <a href="mailto:tobias.ortmayr@gmail.com">Tobias Ortmayr</a>
+ */
+@SuppressWarnings("restriction")
+public class TestBug506928 {
+ private Resource left, right, origin;
+
+ private ICompareEditingDomain editingDomain;
+
+ private ComposedAdapterFactory adapterFactory;
+
+ private EMFCompare comparator;
+
+ @Before
+ public void setUp() throws IOException {
+ Bug506928InputData inputData = new Bug506928InputData();
+ left = inputData.getResource("left.nodes"); //$NON-NLS-1$
+ right = inputData.getResource("right.nodes"); //$NON-NLS-1$
+ origin = inputData.getResource("origin.nodes"); //$NON-NLS-1$
+ editingDomain = EMFCompareEditingDomain.create(left, right, origin);
+ adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ comparator = EMFCompare.builder().build();
+ }
+
+ @SuppressWarnings({"boxing" })
+ protected void testComparisonScopeEditorInput(boolean leftEditable, boolean rightEditable) {
+ // create configuration
+ EMFCompareConfiguration configuration = new EMFCompareConfiguration(new CompareConfiguration());
+ configuration.setLeftEditable(leftEditable);
+ configuration.setRightEditable(rightEditable);
+
+ // create comparison scope editor input based on configuration
+ IComparisonScope scope = new DefaultComparisonScope(left, right, origin);
+ ComparisonScopeEditorInput input = new ComparisonScopeEditorInput(configuration, editingDomain,
+ adapterFactory, comparator, scope);
+
+ // no comparison result before opening the editor
+ assertEquals(input.getCompareResult(), null);
+
+ // open editor to get comparison result
+ try {
+ input.run(new NullProgressMonitor());
+ } catch (InvocationTargetException e) {
+ fail(e.getMessage());
+ } catch (InterruptedException e) {
+ fail(e.getMessage());
+ }
+
+ // ensure correct result
+ assertTrue(input.getCompareResult() instanceof ComparisonScopeInput);
+ ComparisonScopeInput result = (ComparisonScopeInput)input.getCompareResult();
+
+ // assert compare configuration has not been changed
+ assertEquals(leftEditable, input.getCompareConfiguration().isLeftEditable());
+ assertEquals(rightEditable, input.getCompareConfiguration().isRightEditable());
+
+ // assert result reflects the correct configuration
+ assertEquals(input.getCompareConfiguration().isLeftEditable(), result.isLeftEditable());
+ assertEquals(input.getCompareConfiguration().isRightEditable(), result.isRightEditable());
+ }
+
+ /**
+ * Tests that the compare configuration is propagated correctly when both sides are not editable.
+ */
+ @Test
+ public void testComparisionScopeEditorInput_BothNotEditable() {
+ testComparisonScopeEditorInput(false, false);
+ }
+
+ /**
+ * Tests that the compare configuration is propagated correctly when only the left side is editable.
+ */
+ @Test
+ public void testComparisionScopeEditorInput_LeftEditable() {
+ testComparisonScopeEditorInput(true, false);
+ }
+
+ /**
+ * Tests that the compare configuration is propagated correctly when only the right side is editable.
+ */
+ @Test
+ public void testComparisionScopeEditorInput_RightEditable() {
+ testComparisonScopeEditorInput(false, true);
+ }
+
+ /**
+ * Tests that the compare configuration is propagated correctly when both sides are editable.
+ */
+ @Test
+ public void testComparisionScopeEditorInput_BothEditable() {
+ testComparisonScopeEditorInput(true, true);
+ }
+
+ public class Bug506928InputData extends AbstractInputData {
+
+ private static final String PATH_PREFIX = "data/_506928/"; //$NON-NLS-1$
+
+ public Resource getResource(String resourceName) throws IOException {
+ StringBuilder resourceURL = new StringBuilder(PATH_PREFIX);
+ resourceURL.append(resourceName);
+ return loadFromClassLoader(resourceURL.toString());
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/data/_506928/left.nodes b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/data/_506928/left.nodes
new file mode 100644
index 000000000..24d08b565
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/data/_506928/left.nodes
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes" xmi:id="_yWc_0JUeEeGiestbncRZoQ" name="Root">
+ <containmentRef1 xmi:id="_MPLmoN82EeO5ttKSQEjHCQ" name="DeletedNode">
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" xmi:id="_4K6KkN82EeO5ttKSQEjHCQ" name="MovingNode"/>
+ </containmentRef1>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/data/_506928/origin.nodes b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/data/_506928/origin.nodes
new file mode 100644
index 000000000..bcf6f07b3
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/data/_506928/origin.nodes
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes" xmi:id="_yWc_0JUeEeGiestbncRZoQ" name="Root">
+ <containmentRef1 xmi:id="_MPLmoN82EeO5ttKSQEjHCQ" name="DeletedNode"/>
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" xmi:id="_4K6KkN82EeO5ttKSQEjHCQ" name="MovingNode"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/data/_506928/right.nodes b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/data/_506928/right.nodes
new file mode 100644
index 000000000..5cdea6520
--- /dev/null
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/internal/editor/data/_506928/right.nodes
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<nodes:Node xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:nodes="http://www.eclipse.org/emf/compare/tests/nodes" xmi:id="_yWc_0JUeEeGiestbncRZoQ" name="Root">
+ <containmentRef1 xsi:type="nodes:NodeOppositeRefOneToOne" xmi:id="_4K6KkN82EeO5ttKSQEjHCQ" name="MovingNode"/>
+</nodes:Node>
diff --git a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/suite/BugsTestSuite.java b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/suite/BugsTestSuite.java
index b758f335b..570146c95 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/suite/BugsTestSuite.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui.tests/src/org/eclipse/emf/compare/ide/ui/tests/suite/BugsTestSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2014, 2016 Obeo.
+ * Copyright (c) 2014, 2016 Obeo 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
@@ -7,9 +7,11 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Tobias Ortmayr - bug 506928
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.tests.suite;
+import org.eclipse.emf.compare.ide.ui.tests.internal.editor.TestBug506928;
import org.eclipse.emf.compare.ide.ui.tests.structuremergeviewer.actions.TestBug434822;
import org.eclipse.emf.compare.ide.ui.tests.structuremergeviewer.actions.TestBug434827;
import org.eclipse.emf.compare.ide.ui.tests.structuremergeviewer.actions.TestBug434828;
@@ -29,6 +31,7 @@ import org.junit.runners.Suite.SuiteClasses;
*/
@RunWith(Suite.class)
@SuiteClasses({TestBug434827.class, TestBug434822.class, TestBug434828.class, TestBug434828_2.class,
- TestBug459131.class, TestBug470503.class, TestBug475586.class, TestBug497566.class })
+ TestBug459131.class, TestBug470503.class, TestBug475586.class, TestBug497566.class,
+ TestBug506928.class })
public class BugsTestSuite {
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/editor/ComparisonScopeEditorInput.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/editor/ComparisonScopeEditorInput.java
index 72840c1ff..adddf04d3 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/editor/ComparisonScopeEditorInput.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/editor/ComparisonScopeEditorInput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012, 2013 Obeo.
+ * Copyright (c) 2012, 2016 Obeo 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
@@ -7,6 +7,7 @@
*
* Contributors:
* Obeo - initial API and implementation
+ * Tobias Ortmayr - bug 506928
*******************************************************************************/
package org.eclipse.emf.compare.ide.ui.internal.editor;
@@ -50,8 +51,12 @@ public class ComparisonScopeEditorInput extends AbstractEMFCompareEditorInput {
@Override
protected Object doPrepareInput(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
- getCompareConfiguration().setEMFComparator(comparator);
- return new ComparisonScopeInput(scope, getAdapterFactory());
+ EMFCompareConfiguration configuration = getCompareConfiguration();
+ configuration.setEMFComparator(comparator);
+ ComparisonScopeInput input = new ComparisonScopeInput(scope, getAdapterFactory());
+ input.setLeftEditable(configuration.isLeftEditable());
+ input.setRightEditable(configuration.isRightEditable());
+ return input;
}
/**

Back to the top