Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMalgorzata Janczarska2011-10-21 17:12:11 +0000
committerTomasz Zarna2011-10-21 17:12:11 +0000
commit72e049524fb42f6dcc2f3d8af5c27231b8089c37 (patch)
treececa59a44f9e2c4b4df0e8c1fd67c59d5c0ad9dc /tests/org.eclipse.team.tests.core
parent33f3884b44162a4fc6b1236e969d2804dcd07c28 (diff)
downloadeclipse.platform.team-72e049524fb42f6dcc2f3d8af5c27231b8089c37.tar.gz
eclipse.platform.team-72e049524fb42f6dcc2f3d8af5c27231b8089c37.tar.xz
eclipse.platform.team-72e049524fb42f6dcc2f3d8af5c27231b8089c37.zip
bug 347557: [Edit] NPE when saving a file in a compare editor (always)I20111024-1300
A fix for the case founded by Dani when one part of the comparison is empty e.g. after adding a new file.
Diffstat (limited to 'tests/org.eclipse.team.tests.core')
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java
index f8d1add85..bd53f5bc9 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/ui/SaveableCompareEditorInputTest.java
@@ -272,4 +272,56 @@ public class SaveableCompareEditorInputTest extends TeamTest {
* handled, see javadoc to SaveableCompareEditorInput.
*/
}
+
+ public void testDirtyFlagOnLocalResourceTypedElementAndEmptyRight()
+ throws CoreException, InvocationTargetException,
+ InterruptedException, IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException,
+ NoSuchMethodException, IOException {
+
+ // Create left element by SaveableCompareEditorInput to be properly
+ // saved, see javadoc to SaveableCompareEditorInput
+ LocalResourceTypedElement el1 = (LocalResourceTypedElement) SaveableCompareEditorInput
+ .createFileElement(file1);
+ ITypedElement el2 = null;
+
+ CompareConfiguration conf = new CompareConfiguration();
+ conf.setLeftEditable(true);
+ TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
+ el1, el2, conf);
+
+ compareEditorInput.prepareCompareInput(null);
+
+ verifyDirtyStateChanges(compareEditorInput);
+
+ // check whether file was saved
+
+ assertTrue(compareContent(new ByteArrayInputStream(
+ (fileContents1 + appendFileContents).getBytes()),
+ file1.getContents()));
+ }
+
+ public void testDirtyFlagOnCustomTypedElementAndEmptyRight()
+ throws CoreException, InvocationTargetException,
+ InterruptedException, IllegalArgumentException, SecurityException,
+ IllegalAccessException, NoSuchFieldException,
+ NoSuchMethodException, IOException {
+
+ ITypedElement el1 = new TestFileElement(file1);
+ ITypedElement el2 = null;
+
+ CompareConfiguration conf = new CompareConfiguration();
+ conf.setLeftEditable(true);
+ TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput(
+ el1, el2, conf);
+
+ compareEditorInput.prepareCompareInput(null);
+
+ verifyDirtyStateChanges(compareEditorInput);
+
+ /*
+ * not checking if changes were saved because in this case saving is not
+ * handled, see javadoc to SaveableCompareEditorInput.
+ */
+ }
}

Back to the top