|
Lines 19-26
import java.util.List;
Link Here
|
| 19 |
import junit.framework.Test; |
19 |
import junit.framework.Test; |
| 20 |
|
20 |
|
| 21 |
import org.eclipse.compare.CompareConfiguration; |
21 |
import org.eclipse.compare.CompareConfiguration; |
|
|
22 |
import org.eclipse.compare.CompareViewerSwitchingPane; |
| 22 |
import org.eclipse.compare.ITypedElement; |
23 |
import org.eclipse.compare.ITypedElement; |
| 23 |
import org.eclipse.compare.contentmergeviewer.TextMergeViewer; |
24 |
import org.eclipse.compare.contentmergeviewer.TextMergeViewer; |
|
|
25 |
import org.eclipse.compare.internal.CompareEditor; |
| 26 |
import org.eclipse.compare.internal.CompareUIPlugin; |
| 24 |
import org.eclipse.compare.internal.MergeSourceViewer; |
27 |
import org.eclipse.compare.internal.MergeSourceViewer; |
| 25 |
import org.eclipse.compare.structuremergeviewer.Differencer; |
28 |
import org.eclipse.compare.structuremergeviewer.Differencer; |
| 26 |
import org.eclipse.compare.structuremergeviewer.ICompareInput; |
29 |
import org.eclipse.compare.structuremergeviewer.ICompareInput; |
|
Lines 33-44
import org.eclipse.core.runtime.CoreException;
Link Here
|
| 33 |
import org.eclipse.core.runtime.ILogListener; |
36 |
import org.eclipse.core.runtime.ILogListener; |
| 34 |
import org.eclipse.core.runtime.IProgressMonitor; |
37 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 35 |
import org.eclipse.core.runtime.IStatus; |
38 |
import org.eclipse.core.runtime.IStatus; |
|
|
39 |
import org.eclipse.jface.viewers.Viewer; |
| 36 |
import org.eclipse.swt.custom.StyledText; |
40 |
import org.eclipse.swt.custom.StyledText; |
| 37 |
import org.eclipse.swt.graphics.Image; |
41 |
import org.eclipse.swt.graphics.Image; |
| 38 |
import org.eclipse.swt.widgets.Shell; |
42 |
import org.eclipse.swt.widgets.Shell; |
| 39 |
import org.eclipse.team.internal.ui.mapping.AbstractCompareInput; |
43 |
import org.eclipse.team.internal.ui.mapping.AbstractCompareInput; |
| 40 |
import org.eclipse.team.internal.ui.mapping.CompareInputChangeNotifier; |
44 |
import org.eclipse.team.internal.ui.mapping.CompareInputChangeNotifier; |
| 41 |
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement; |
45 |
import org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement; |
|
|
46 |
import org.eclipse.team.internal.ui.synchronize.SaveablesCompareEditorInput; |
| 42 |
import org.eclipse.team.tests.core.TeamTest; |
47 |
import org.eclipse.team.tests.core.TeamTest; |
| 43 |
import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput; |
48 |
import org.eclipse.team.ui.synchronize.SaveableCompareEditorInput; |
| 44 |
import org.eclipse.ui.PlatformUI; |
49 |
import org.eclipse.ui.PlatformUI; |
|
Lines 49-65
public class SaveableCompareEditorInputTest extends TeamTest {
Link Here
|
| 49 |
return suite(SaveableCompareEditorInputTest.class); |
54 |
return suite(SaveableCompareEditorInputTest.class); |
| 50 |
} |
55 |
} |
| 51 |
|
56 |
|
|
|
57 |
private static final String COMPARE_EDITOR = CompareUIPlugin.PLUGIN_ID |
| 58 |
+ ".CompareEditor"; //$NON-NLS-1$ |
| 59 |
|
| 52 |
private IFile file1; |
60 |
private IFile file1; |
| 53 |
private IFile file2; |
61 |
private IFile file2; |
| 54 |
private String appendFileContents = "_append"; |
62 |
private String appendFileContents = "_append"; |
| 55 |
private String fileContents1 = "FileContents"; |
63 |
private String fileContents1 = "FileContents"; |
| 56 |
private String fileContents2 = "FileContents2"; |
64 |
private String fileContents2 = "FileContents2"; |
| 57 |
private TestLogListener logListener = new TestLogListener(); |
65 |
private TestLogListener logListener = new TestLogListener(); |
|
|
66 |
private IProject project; |
| 58 |
|
67 |
|
| 59 |
protected void setUp() throws Exception { |
68 |
protected void setUp() throws Exception { |
| 60 |
super.setUp(); |
69 |
super.setUp(); |
| 61 |
|
70 |
|
| 62 |
IProject project = createProject("Project_", new String[] { |
71 |
project = createProject("Project_", new String[] { |
| 63 |
"File1.txt", "File2.txt" }); |
72 |
"File1.txt", "File2.txt" }); |
| 64 |
|
73 |
|
| 65 |
file1 = project.getFile("File1.txt"); |
74 |
file1 = project.getFile("File1.txt"); |
|
Lines 106-112
public class SaveableCompareEditorInputTest extends TeamTest {
Link Here
|
| 106 |
|
115 |
|
| 107 |
private class TestLogListener implements ILogListener { |
116 |
private class TestLogListener implements ILogListener { |
| 108 |
public void logging(IStatus status, String plugin) { |
117 |
public void logging(IStatus status, String plugin) { |
| 109 |
fail(status.getMessage()); |
118 |
if (status.getSeverity() == IStatus.ERROR) |
|
|
119 |
fail(status.getMessage()); |
| 110 |
} |
120 |
} |
| 111 |
} |
121 |
} |
| 112 |
|
122 |
|
|
Lines 324-327
public class SaveableCompareEditorInputTest extends TeamTest {
Link Here
|
| 324 |
* handled, see javadoc to SaveableCompareEditorInput. |
334 |
* handled, see javadoc to SaveableCompareEditorInput. |
| 325 |
*/ |
335 |
*/ |
| 326 |
} |
336 |
} |
|
|
337 |
|
| 338 |
private void verifyModifyAndSaveBothSidesOfCompareEditor(String extention) |
| 339 |
throws InterruptedException, InvocationTargetException, |
| 340 |
IllegalArgumentException, SecurityException, |
| 341 |
IllegalAccessException, NoSuchFieldException, CoreException { |
| 342 |
|
| 343 |
// create files to compare |
| 344 |
IFile file1 = project.getFile("CompareFile1." + extention); |
| 345 |
IFile file2 = project.getFile("CompareFile2." + extention); |
| 346 |
file1.create(new ByteArrayInputStream(fileContents1.getBytes()), true, |
| 347 |
null); |
| 348 |
file2.create(new ByteArrayInputStream(fileContents2.getBytes()), true, |
| 349 |
null); |
| 350 |
|
| 351 |
// prepare comparison |
| 352 |
SaveablesCompareEditorInput input = new SaveablesCompareEditorInput( |
| 353 |
null, SaveablesCompareEditorInput.createFileElement(file1), |
| 354 |
SaveablesCompareEditorInput.createFileElement(file2), |
| 355 |
PlatformUI.getWorkbench().getActiveWorkbenchWindow() |
| 356 |
.getActivePage()); |
| 357 |
input.run(null); |
| 358 |
|
| 359 |
// open CompareEditor |
| 360 |
CompareEditor editor = (CompareEditor) PlatformUI.getWorkbench() |
| 361 |
.getActiveWorkbenchWindow().getActivePage() |
| 362 |
.openEditor(input, COMPARE_EDITOR, true); |
| 363 |
|
| 364 |
CompareViewerSwitchingPane pane = (CompareViewerSwitchingPane) ReflectionUtils |
| 365 |
.getField(input, "fContentInputPane", true); |
| 366 |
|
| 367 |
Viewer viewer = pane.getViewer(); |
| 368 |
|
| 369 |
MergeSourceViewer left = (MergeSourceViewer) ReflectionUtils.getField( |
| 370 |
viewer, "fLeft", true); |
| 371 |
MergeSourceViewer right = (MergeSourceViewer) ReflectionUtils.getField( |
| 372 |
viewer, "fRight", true); |
| 373 |
|
| 374 |
// modify both sides of CompareEditor |
| 375 |
StyledText leftText = left.getSourceViewer().getTextWidget(); |
| 376 |
StyledText rightText = right.getSourceViewer().getTextWidget(); |
| 377 |
leftText.append(appendFileContents); |
| 378 |
rightText.append(appendFileContents); |
| 379 |
|
| 380 |
// save both sides |
| 381 |
editor.doSave(null); |
| 382 |
|
| 383 |
assertFalse(editor.isDirty()); |
| 384 |
|
| 385 |
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() |
| 386 |
.closeEditor(editor, false); |
| 387 |
|
| 388 |
// validate if both sides where saved |
| 389 |
assertTrue(compareContent(new ByteArrayInputStream( |
| 390 |
(fileContents1 + appendFileContents).getBytes()), |
| 391 |
file1.getContents())); |
| 392 |
assertTrue(compareContent(new ByteArrayInputStream( |
| 393 |
(fileContents2 + appendFileContents).getBytes()), |
| 394 |
file2.getContents())); |
| 395 |
} |
| 396 |
|
| 397 |
public void testModifyAndSaveBothSidesOfCompareEditorHtml() |
| 398 |
throws IllegalArgumentException, SecurityException, |
| 399 |
InterruptedException, InvocationTargetException, |
| 400 |
IllegalAccessException, NoSuchFieldException, CoreException { |
| 401 |
verifyModifyAndSaveBothSidesOfCompareEditor("html"); |
| 402 |
} |
| 403 |
|
| 404 |
public void testModifyAndSaveBothSidesOfCompareEditorTxt() |
| 405 |
throws IllegalArgumentException, SecurityException, |
| 406 |
InterruptedException, InvocationTargetException, |
| 407 |
IllegalAccessException, NoSuchFieldException, CoreException { |
| 408 |
verifyModifyAndSaveBothSidesOfCompareEditor("txt"); |
| 409 |
} |
| 410 |
|
| 411 |
public void testModifyAndSaveBothSidesOfCompareEditorJava() |
| 412 |
throws IllegalArgumentException, SecurityException, |
| 413 |
InterruptedException, InvocationTargetException, |
| 414 |
IllegalAccessException, NoSuchFieldException, CoreException { |
| 415 |
verifyModifyAndSaveBothSidesOfCompareEditor("java"); |
| 416 |
} |
| 417 |
|
| 418 |
public void testModifyAndSaveBothSidesOfCompareEditorXml() |
| 419 |
throws IllegalArgumentException, SecurityException, |
| 420 |
InterruptedException, InvocationTargetException, |
| 421 |
IllegalAccessException, NoSuchFieldException, CoreException { |
| 422 |
verifyModifyAndSaveBothSidesOfCompareEditor("xml"); |
| 423 |
} |
| 424 |
|
| 425 |
public void testModifyAndSaveBothSidesOfCompareEditorProperties() |
| 426 |
throws IllegalArgumentException, SecurityException, |
| 427 |
InterruptedException, InvocationTargetException, |
| 428 |
IllegalAccessException, NoSuchFieldException, CoreException { |
| 429 |
verifyModifyAndSaveBothSidesOfCompareEditor("properties"); |
| 430 |
} |
| 327 |
} |
431 |
} |