3333import org .eclipse .compare .ITypedElement ;
3434import org .eclipse .compare .contentmergeviewer .TextMergeViewer ;
3535import org .eclipse .compare .internal .CompareEditor ;
36+ import org .eclipse .compare .internal .ComparePreferencePage ;
3637import org .eclipse .compare .internal .CompareUIPlugin ;
3738import org .eclipse .compare .internal .MergeSourceViewer ;
3839import org .eclipse .compare .structuremergeviewer .Differencer ;
4748import org .eclipse .core .runtime .IStatus ;
4849import org .eclipse .core .runtime .Platform ;
4950import org .eclipse .core .tests .resources .util .WorkspaceResetExtension ;
51+ import org .eclipse .jface .preference .IPreferenceStore ;
5052import org .eclipse .jface .viewers .Viewer ;
5153import org .eclipse .swt .custom .StyledText ;
5254import org .eclipse .swt .graphics .Image ;
@@ -214,8 +216,8 @@ public TestSaveableEditorInput(ITypedElement left, ITypedElement right,
214216 protected ICompareInput prepareCompareInput (IProgressMonitor monitor )
215217 throws InvocationTargetException , InterruptedException {
216218 input = createCompareInput ();
217- getCompareConfiguration ().setLeftEditable (true );
218- getCompareConfiguration ().setRightEditable (false );
219+ getCompareConfiguration ().setLeftEditable (leftIsChanged () );
220+ getCompareConfiguration ().setRightEditable (rightIsChanged () );
219221 return null ;
220222 }
221223
@@ -229,6 +231,15 @@ protected void fireInputChange() {
229231 }
230232 }
231233
234+ static boolean rightIsChanged () {
235+ IPreferenceStore store = CompareUIPlugin .getDefault ().getPreferenceStore ();
236+ return store .getBoolean (ComparePreferencePage .SWAPPED );
237+ }
238+
239+ static boolean leftIsChanged () {
240+ return !rightIsChanged ();
241+ }
242+
232243 private void verifyDirtyStateChanges (
233244 TestSaveableEditorInput compareEditorInput )
234245 throws IllegalArgumentException , SecurityException ,
@@ -240,10 +251,14 @@ private void verifyDirtyStateChanges(
240251 .findContentViewer (null , compareEditorInput .input , shell );
241252 viewer .setInput (compareEditorInput .getCompareResult ());
242253
243- MergeSourceViewer left = (MergeSourceViewer ) ReflectionUtils .getField (
244- viewer , "fLeft" );
254+ MergeSourceViewer changed ;
255+ if (leftIsChanged ()) {
256+ changed = (MergeSourceViewer ) ReflectionUtils .getField (viewer , "fLeft" );
257+ } else {
258+ changed = (MergeSourceViewer ) ReflectionUtils .getField (viewer , "fRight" );
259+ }
245260
246- StyledText leftText = left .getSourceViewer ().getTextWidget ();
261+ StyledText leftText = changed .getSourceViewer ().getTextWidget ();
247262
248263 // modify the left side of editor
249264 leftText .append (appendFileContents );
@@ -270,7 +285,6 @@ public void testDirtyFlagOnLocalResourceTypedElement()
270285 ITypedElement el2 = new TestFileElement (file2 );
271286
272287 CompareConfiguration conf = new CompareConfiguration ();
273- conf .setLeftEditable (true );
274288 TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput (
275289 el1 , el2 , conf );
276290
@@ -293,7 +307,6 @@ public void testDirtyFlagOnCustomTypedElement() throws CoreException,
293307 ITypedElement el2 = new TestFileElement (file2 );
294308
295309 CompareConfiguration conf = new CompareConfiguration ();
296- conf .setLeftEditable (true );
297310 TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput (
298311 el1 , el2 , conf );
299312
@@ -321,7 +334,6 @@ public void testDirtyFlagOnLocalResourceTypedElementAndEmptyRight()
321334 ITypedElement el2 = null ;
322335
323336 CompareConfiguration conf = new CompareConfiguration ();
324- conf .setLeftEditable (true );
325337 TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput (
326338 el1 , el2 , conf );
327339
@@ -344,7 +356,6 @@ public void testDirtyFlagOnCustomTypedElementAndEmptyRight()
344356 ITypedElement el2 = null ;
345357
346358 CompareConfiguration conf = new CompareConfiguration ();
347- conf .setLeftEditable (true );
348359 TestSaveableEditorInput compareEditorInput = new TestSaveableEditorInput (
349360 el1 , el2 , conf );
350361
0 commit comments