1
1
/*******************************************************************************
2
- * Copyright (c) 2000, 2024 IBM Corporation and others.
2
+ * Copyright (c) 2000, 2025 IBM Corporation and others.
3
3
*
4
4
* This program and the accompanying materials
5
5
* are made available under the terms of the Eclipse Public License 2.0
@@ -57,27 +57,21 @@ public GoBackForwardsTest() {
57
57
private static final String FILE_CONTENTS = "public class GoBackForwardsTestFile {\n "
58
58
+ " public static void main(String[] args) {\n " + " System.out.println(\" Hello world!\" );\n "
59
59
+ " }\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 " ;
62
62
private static final String SELECTION_STRING = "Selection<offset: 10, length: 5>" ;
63
63
64
64
private IProject project ;
65
65
private IFile file ;
66
66
67
67
@ 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 );
81
75
82
76
}
83
77
@@ -88,22 +82,22 @@ public void testNavigationHistoryNavigation() {
88
82
89
83
processEvents ();
90
84
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 );
93
87
Condition textEditorNoSelection = currentNavigationHistoryLocationCondition (TEXT_EDITOR_ID , false );
94
88
Condition textEditorSelection = currentNavigationHistoryLocationCondition (TEXT_EDITOR_ID , true );
95
89
96
90
FileEditorInput editorInput = new FileEditorInput (file );
97
91
98
- openJavaEditor (editorInput );
92
+ openGenericEditor (editorInput );
99
93
100
- if (!processEventsUntil (javaEditorNoSelection , 1000 )) {
94
+ if (!processEventsUntil (genericEditorNoSelection , 1000 )) {
101
95
fail ("Timeout during navigation." + getStateDetails ());
102
96
}
103
97
104
- selectInJavaEditor (editorInput );
98
+ selectInGenericEditor (editorInput );
105
99
106
- if (!processEventsUntil (javaEditorSelection , 1000 )) {
100
+ if (!processEventsUntil (genericEditorSelection , 1000 )) {
107
101
fail ("Timeout during navigation." + getStateDetails ());
108
102
}
109
103
@@ -119,9 +113,9 @@ public void testNavigationHistoryNavigation() {
119
113
fail ("Timeout during navigation." + getStateDetails ());
120
114
}
121
115
122
- openJavaEditor (editorInput );
116
+ openGenericEditor (editorInput );
123
117
124
- if (!processEventsUntil (javaEditorSelection , 1000 )) {
118
+ if (!processEventsUntil (genericEditorSelection , 1000 )) {
125
119
fail ("Timeout during navigation." + getStateDetails ());
126
120
}
127
121
@@ -131,11 +125,11 @@ public void testNavigationHistoryNavigation() {
131
125
fail ("Timeout during navigation." + getStateDetails ());
132
126
}
133
127
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 );
136
130
Assert .assertEquals (
137
131
"Failed to correctly navigate backward from text editor to java editor." + getStateDetails (),
138
- JAVA_EDITOR_ID , getActiveEditorId ());
132
+ GENERIC_EDITOR_ID , getActiveEditorId ());
139
133
140
134
// Navigate backward from java editor to text editor
141
135
goBackward (EditorTestHelper .getActiveWorkbenchWindow (), textEditorSelection );
@@ -150,16 +144,16 @@ public void testNavigationHistoryNavigation() {
150
144
TEXT_EDITOR_ID , getActiveEditorId ());
151
145
152
146
// 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 );
155
149
Assert .assertEquals (
156
150
"Failed to correctly navigate backward from java editor to java editor." + getStateDetails (),
157
- JAVA_EDITOR_ID , getActiveEditorId ());
151
+ GENERIC_EDITOR_ID , getActiveEditorId ());
158
152
159
153
// Navigate forward from java editor to java editor
160
- goForward (EditorTestHelper .getActiveWorkbenchWindow (), javaEditorSelection );
154
+ goForward (EditorTestHelper .getActiveWorkbenchWindow (), genericEditorSelection );
161
155
Assert .assertEquals ("Failed to correctly navigate forward from java editor to java editor." + getStateDetails (),
162
- JAVA_EDITOR_ID , getActiveEditorId ());
156
+ GENERIC_EDITOR_ID , getActiveEditorId ());
163
157
164
158
// Navigate forward from text editor to text editor
165
159
goForward (EditorTestHelper .getActiveWorkbenchWindow (), textEditorNoSelection );
@@ -168,9 +162,9 @@ public void testNavigationHistoryNavigation() {
168
162
TEXT_EDITOR_ID , getActiveEditorId ());
169
163
170
164
// Navigate forward from text editor to java editor
171
- goForward (EditorTestHelper .getActiveWorkbenchWindow (), javaEditorSelection );
165
+ goForward (EditorTestHelper .getActiveWorkbenchWindow (), genericEditorSelection );
172
166
Assert .assertEquals ("Failed to correctly navigate forward from text editor to java editor." + getStateDetails (),
173
- JAVA_EDITOR_ID , getActiveEditorId ());
167
+ GENERIC_EDITOR_ID , getActiveEditorId ());
174
168
175
169
// Navigate forward from java editor to text editor
176
170
goForward (EditorTestHelper .getActiveWorkbenchWindow (), textEditorSelection );
@@ -190,19 +184,19 @@ private Condition currentNavigationHistoryLocationCondition(String editorId, boo
190
184
};
191
185
}
192
186
193
- private void openJavaEditor (IEditorInput editorInput ) {
187
+ private void openGenericEditor (IEditorInput editorInput ) {
194
188
try {
195
- EditorTestHelper .getActivePage ().openEditor (editorInput , JAVA_EDITOR_ID , true ,
189
+ EditorTestHelper .getActivePage ().openEditor (editorInput , GENERIC_EDITOR_ID , true ,
196
190
IWorkbenchPage .MATCH_ID | IWorkbenchPage .MATCH_INPUT );
197
191
} catch (PartInitException e ) {
198
192
fail ("Should not throw an exception" );
199
193
}
200
194
}
201
195
202
- private void selectInJavaEditor (IEditorInput editorInput ) {
196
+ private void selectInGenericEditor (IEditorInput editorInput ) {
203
197
try {
204
198
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 );
206
200
editor .selectAndReveal (10 , 5 );
207
201
} catch (PartInitException e ) {
208
202
fail ("Should not throw an exception" );
0 commit comments