11/*******************************************************************************
2- * Copyright (c) 2000, 2024 IBM Corporation and others.
2+ * Copyright (c) 2000, 2025 IBM Corporation and others.
33 *
44 * This program and the accompanying materials
55 * are made available under the terms of the Eclipse Public License 2.0
@@ -57,27 +57,21 @@ public GoBackForwardsTest() {
5757 private static final String FILE_CONTENTS = "public class GoBackForwardsTestFile {\n "
5858 + " public static void main(String[] args) {\n " + " System.out.println(\" Hello world!\" );\n "
5959 + " }\n " + "}" ;
60- private static final String JAVA_EDITOR_ID = "org.eclipse.jdt. ui.CompilationUnitEditor " ;
61- private static final String TEXT_EDITOR_ID = "org.eclipse.ui.genericeditor.GenericEditor " ;
60+ private static final String GENERIC_EDITOR_ID = "org.eclipse.ui.genericeditor.GenericEditor " ;
61+ private static final String TEXT_EDITOR_ID = "org.eclipse.ui.DefaultTextEditor " ;
6262 private static final String SELECTION_STRING = "Selection<offset: 10, length: 5>" ;
6363
6464 private IProject project ;
6565 private IFile file ;
6666
6767 @ Override
68- public void doSetUp () {
69- try {
70- project = FileUtil .createProject (PROJECT_NAME );
71- file = FileUtil .createFile (FILE_NAME , project );
72- StringBuilder stringBuilder = new StringBuilder ();
73- stringBuilder .append (FILE_CONTENTS );
74- Files .writeString (Paths .get (file .getLocation ().toOSString ()), stringBuilder );
75- project .refreshLocal (IResource .DEPTH_INFINITE , null );
76- } catch (CoreException e ) {
77- fail ("Should not throw an exception" );
78- } catch (IOException e ) {
79- fail ("Should not throw an exception" );
80- }
68+ public void doSetUp () throws CoreException , IOException {
69+ project = FileUtil .createProject (PROJECT_NAME );
70+ file = FileUtil .createFile (FILE_NAME , project );
71+ StringBuilder stringBuilder = new StringBuilder ();
72+ stringBuilder .append (FILE_CONTENTS );
73+ Files .writeString (Paths .get (file .getLocation ().toOSString ()), stringBuilder );
74+ project .refreshLocal (IResource .DEPTH_INFINITE , null );
8175
8276 }
8377
@@ -88,22 +82,22 @@ public void testNavigationHistoryNavigation() {
8882
8983 processEvents ();
9084
91- Condition javaEditorNoSelection = currentNavigationHistoryLocationCondition (JAVA_EDITOR_ID , false );
92- Condition javaEditorSelection = currentNavigationHistoryLocationCondition (JAVA_EDITOR_ID , true );
85+ Condition genericEditorNoSelection = currentNavigationHistoryLocationCondition (GENERIC_EDITOR_ID , false );
86+ Condition genericEditorSelection = currentNavigationHistoryLocationCondition (GENERIC_EDITOR_ID , true );
9387 Condition textEditorNoSelection = currentNavigationHistoryLocationCondition (TEXT_EDITOR_ID , false );
9488 Condition textEditorSelection = currentNavigationHistoryLocationCondition (TEXT_EDITOR_ID , true );
9589
9690 FileEditorInput editorInput = new FileEditorInput (file );
9791
98- openJavaEditor (editorInput );
92+ openGenericEditor (editorInput );
9993
100- if (!processEventsUntil (javaEditorNoSelection , 1000 )) {
94+ if (!processEventsUntil (genericEditorNoSelection , 1000 )) {
10195 fail ("Timeout during navigation." + getStateDetails ());
10296 }
10397
104- selectInJavaEditor (editorInput );
98+ selectInGenericEditor (editorInput );
10599
106- if (!processEventsUntil (javaEditorSelection , 1000 )) {
100+ if (!processEventsUntil (genericEditorSelection , 1000 )) {
107101 fail ("Timeout during navigation." + getStateDetails ());
108102 }
109103
@@ -119,9 +113,9 @@ public void testNavigationHistoryNavigation() {
119113 fail ("Timeout during navigation." + getStateDetails ());
120114 }
121115
122- openJavaEditor (editorInput );
116+ openGenericEditor (editorInput );
123117
124- if (!processEventsUntil (javaEditorSelection , 1000 )) {
118+ if (!processEventsUntil (genericEditorSelection , 1000 )) {
125119 fail ("Timeout during navigation." + getStateDetails ());
126120 }
127121
@@ -131,11 +125,11 @@ public void testNavigationHistoryNavigation() {
131125 fail ("Timeout during navigation." + getStateDetails ());
132126 }
133127
134- // Navigate backward from text editor to java editor
135- goBackward (EditorTestHelper .getActiveWorkbenchWindow (), javaEditorSelection );
128+ // Navigate backward from text editor to editor
129+ goBackward (EditorTestHelper .getActiveWorkbenchWindow (), genericEditorSelection );
136130 Assert .assertEquals (
137131 "Failed to correctly navigate backward from text editor to java editor." + getStateDetails (),
138- JAVA_EDITOR_ID , getActiveEditorId ());
132+ GENERIC_EDITOR_ID , getActiveEditorId ());
139133
140134 // Navigate backward from java editor to text editor
141135 goBackward (EditorTestHelper .getActiveWorkbenchWindow (), textEditorSelection );
@@ -150,16 +144,16 @@ public void testNavigationHistoryNavigation() {
150144 TEXT_EDITOR_ID , getActiveEditorId ());
151145
152146 // Navigate backward from java editor to java editor
153- goBackward (EditorTestHelper .getActiveWorkbenchWindow (), javaEditorSelection );
154- goBackward (EditorTestHelper .getActiveWorkbenchWindow (), javaEditorNoSelection );
147+ goBackward (EditorTestHelper .getActiveWorkbenchWindow (), genericEditorSelection );
148+ goBackward (EditorTestHelper .getActiveWorkbenchWindow (), genericEditorNoSelection );
155149 Assert .assertEquals (
156150 "Failed to correctly navigate backward from java editor to java editor." + getStateDetails (),
157- JAVA_EDITOR_ID , getActiveEditorId ());
151+ GENERIC_EDITOR_ID , getActiveEditorId ());
158152
159153 // Navigate forward from java editor to java editor
160- goForward (EditorTestHelper .getActiveWorkbenchWindow (), javaEditorSelection );
154+ goForward (EditorTestHelper .getActiveWorkbenchWindow (), genericEditorSelection );
161155 Assert .assertEquals ("Failed to correctly navigate forward from java editor to java editor." + getStateDetails (),
162- JAVA_EDITOR_ID , getActiveEditorId ());
156+ GENERIC_EDITOR_ID , getActiveEditorId ());
163157
164158 // Navigate forward from text editor to text editor
165159 goForward (EditorTestHelper .getActiveWorkbenchWindow (), textEditorNoSelection );
@@ -168,9 +162,9 @@ public void testNavigationHistoryNavigation() {
168162 TEXT_EDITOR_ID , getActiveEditorId ());
169163
170164 // Navigate forward from text editor to java editor
171- goForward (EditorTestHelper .getActiveWorkbenchWindow (), javaEditorSelection );
165+ goForward (EditorTestHelper .getActiveWorkbenchWindow (), genericEditorSelection );
172166 Assert .assertEquals ("Failed to correctly navigate forward from text editor to java editor." + getStateDetails (),
173- JAVA_EDITOR_ID , getActiveEditorId ());
167+ GENERIC_EDITOR_ID , getActiveEditorId ());
174168
175169 // Navigate forward from java editor to text editor
176170 goForward (EditorTestHelper .getActiveWorkbenchWindow (), textEditorSelection );
@@ -190,19 +184,19 @@ private Condition currentNavigationHistoryLocationCondition(String editorId, boo
190184 };
191185 }
192186
193- private void openJavaEditor (IEditorInput editorInput ) {
187+ private void openGenericEditor (IEditorInput editorInput ) {
194188 try {
195- EditorTestHelper .getActivePage ().openEditor (editorInput , JAVA_EDITOR_ID , true ,
189+ EditorTestHelper .getActivePage ().openEditor (editorInput , GENERIC_EDITOR_ID , true ,
196190 IWorkbenchPage .MATCH_ID | IWorkbenchPage .MATCH_INPUT );
197191 } catch (PartInitException e ) {
198192 fail ("Should not throw an exception" );
199193 }
200194 }
201195
202- private void selectInJavaEditor (IEditorInput editorInput ) {
196+ private void selectInGenericEditor (IEditorInput editorInput ) {
203197 try {
204198 AbstractTextEditor editor = (AbstractTextEditor ) EditorTestHelper .getActivePage ().openEditor (editorInput ,
205- JAVA_EDITOR_ID , true , IWorkbenchPage .MATCH_ID | IWorkbenchPage .MATCH_INPUT );
199+ GENERIC_EDITOR_ID , true , IWorkbenchPage .MATCH_ID | IWorkbenchPage .MATCH_INPUT );
206200 editor .selectAndReveal (10 , 5 );
207201 } catch (PartInitException e ) {
208202 fail ("Should not throw an exception" );
0 commit comments