Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDani Megert2015-03-22 12:09:17 -0400
committerDani Megert2015-03-22 12:09:17 -0400
commit0cfdcf63faaf40dab307eb2b272008ecab536947 (patch)
treeda3c968ba439d924d504edd9bb81605a5a549d33 /org.eclipse.search.tests
parent2d75c3db3bdc09d38a1484a833dd6f39c473082c (diff)
downloadeclipse.platform.text-0cfdcf63faaf40dab307eb2b272008ecab536947.tar.gz
eclipse.platform.text-0cfdcf63faaf40dab307eb2b272008ecab536947.tar.xz
eclipse.platform.text-0cfdcf63faaf40dab307eb2b272008ecab536947.zip
Don't depend on Java editor being present
Diffstat (limited to 'org.eclipse.search.tests')
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/core/tests/LineConversionTest.java21
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java13
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java28
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java20
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java17
-rw-r--r--org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java25
6 files changed, 67 insertions, 57 deletions
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LineConversionTest.java b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LineConversionTest.java
index dd958cb91..7066d89bb 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LineConversionTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/core/tests/LineConversionTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,21 +13,24 @@ package org.eclipse.search.core.tests;
import java.io.ByteArrayInputStream;
-import junit.framework.TestCase;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
+
import org.eclipse.search.internal.ui.SearchPlugin;
+import org.eclipse.search.tests.SearchTestPlugin;
+
import org.eclipse.search2.internal.ui.text.PositionTracker;
-import org.eclipse.ui.ide.IDE;
+
+import junit.framework.TestCase;
/**
*/
@@ -58,7 +61,7 @@ public class LineConversionTest extends TestCase {
}
public void testConvertToCharacter() throws Exception {
- IDE.openEditor(SearchPlugin.getActivePage(), fFile);
+ SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), fFile);
ITextFileBuffer fb= FileBuffers.getTextFileBufferManager().getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE);
IDocument doc= fb.getDocument();
@@ -84,7 +87,7 @@ public class LineConversionTest extends TestCase {
}
public void testBogusLines() throws Exception {
- IDE.openEditor(SearchPlugin.getActivePage(), fFile);
+ SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), fFile);
ITextFileBuffer fb= FileBuffers.getTextFileBufferManager().getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE);
IDocument doc= fb.getDocument();
@@ -97,7 +100,7 @@ public class LineConversionTest extends TestCase {
}
public void atestLineOffsets() throws Exception {
- IDE.openEditor(SearchPlugin.getActivePage(), fFile);
+ SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), fFile);
ITextFileBuffer fb= FileBuffers.getTextFileBufferManager().getTextFileBuffer(fFile.getFullPath(), LocationKind.IFILE);
IDocument doc= fb.getDocument();
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java
index cb8efede1..fcdde820e 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/SearchTestPlugin.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
+ * Copyright (c) 2005, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,13 +10,20 @@
*******************************************************************************/
package org.eclipse.search.tests;
+import org.eclipse.core.resources.IFile;
+
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.editors.text.EditorsUI;
+
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search2.internal.ui.SearchView;
@@ -58,4 +65,8 @@ public class SearchTestPlugin extends AbstractUIPlugin {
page.hideView((IViewPart)part);
}
+ public static IEditorPart openTextEditor(IWorkbenchPage activePage, IFile openFile1) throws PartInitException {
+ return IDE.openEditor(activePage, openFile1, EditorsUI.DEFAULT_TEXT_EDITOR_ID, true);
+ }
+
}
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
index 10e85ffca..24eef965f 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/AnnotationManagerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,10 +13,6 @@ package org.eclipse.search.tests.filesearch;
import java.util.HashSet;
import java.util.Iterator;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -25,8 +21,6 @@ import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.ui.ide.IDE;
-
import org.eclipse.ui.texteditor.AnnotationTypeLookup;
import org.eclipse.ui.texteditor.ITextEditor;
@@ -45,6 +39,10 @@ import org.eclipse.search.ui.text.Match;
import org.eclipse.search2.internal.ui.InternalSearchUI;
import org.eclipse.search2.internal.ui.text.EditorAnnotationManager;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class AnnotationManagerTest extends TestCase {
private FileSearchQuery fQuery1;
private FileSearchQuery fQuery2;
@@ -94,7 +92,7 @@ public class AnnotationManagerTest extends TestCase {
try {
for (int i= 0; i < files.length; i++) {
IFile file= (IFile)files[i];
- ITextEditor editor= (ITextEditor)IDE.openEditor(SearchPlugin.getActivePage(), file, true);
+ ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
annotationModel.getAnnotationIterator();
HashSet positions= new HashSet();
@@ -122,7 +120,7 @@ public class AnnotationManagerTest extends TestCase {
NewSearchUI.runQueryInForeground(null, fQuery1);
FileSearchResult result= (FileSearchResult) fQuery1.getSearchResult();
IFile file= (IFile) result.getElements()[0];
- IDE.openEditor(SearchTestPlugin.getDefault().getWorkbench().getWorkbenchWindows()[0].getPages()[0], file, true);
+ SearchTestPlugin.openTextEditor(SearchTestPlugin.getDefault().getWorkbench().getWorkbenchWindows()[0].getPages()[0], file);
result.addMatch(new FileMatch(file));
}
@@ -134,8 +132,8 @@ public class AnnotationManagerTest extends TestCase {
try {
for (int i= 0; i < files.length; i++) {
- IFile file= (IFile) files[0];
- ITextEditor editor= (ITextEditor) IDE.openEditor(SearchPlugin.getActivePage(), file, true);
+ IFile file= (IFile)files[i];
+ ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
int annotationCount= 0;
for (Iterator annotations= annotationModel.getAnnotationIterator(); annotations.hasNext();) {
@@ -159,8 +157,8 @@ public class AnnotationManagerTest extends TestCase {
NewSearchUI.runQueryInForeground(null, fQuery2);
try {
for (int i= 0; i < files.length; i++) {
- IFile file= (IFile) files[0];
- ITextEditor editor= (ITextEditor) IDE.openEditor(SearchPlugin.getActivePage(), file, true);
+ IFile file= (IFile)files[i];
+ ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
int annotationCount= 0;
IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
@@ -187,8 +185,8 @@ public class AnnotationManagerTest extends TestCase {
SearchTestPlugin.getDefault().getSearchView().showSearchResult(result);
try {
for (int i= 0; i < files.length; i++) {
- IFile file= (IFile) files[0];
- ITextEditor editor= (ITextEditor) IDE.openEditor(SearchPlugin.getActivePage(), file, true);
+ IFile file= (IFile)files[i];
+ ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
int annotationCount= 0;
IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
index cdfcf209d..5f25845f5 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/FileSearchTests.java
@@ -16,10 +16,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.resources.IFile;
@@ -28,7 +24,6 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.ide.IDE;
import org.eclipse.search.core.text.TextSearchEngine;
import org.eclipse.search.core.text.TextSearchMatchAccess;
@@ -37,8 +32,13 @@ import org.eclipse.search.core.text.TextSearchScope;
import org.eclipse.search.internal.core.text.PatternConstructor;
import org.eclipse.search.internal.ui.SearchPlugin;
import org.eclipse.search.tests.ResourceHelper;
+import org.eclipse.search.tests.SearchTestPlugin;
import org.eclipse.search.ui.text.FileTextSearchScope;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class FileSearchTests extends TestCase {
private static class TestResult {
@@ -233,10 +233,10 @@ public class FileSearchTests extends TestCase {
IWorkbenchPage activePage= SearchPlugin.getActivePage();
try {
- IDE.openEditor(activePage, openFile1, true);
- IDE.openEditor(activePage, openFile2, true);
- IDE.openEditor(activePage, openFile3, true);
- IDE.openEditor(activePage, openFile4, true);
+ SearchTestPlugin.openTextEditor(activePage, openFile1);
+ SearchTestPlugin.openTextEditor(activePage, openFile2);
+ SearchTestPlugin.openTextEditor(activePage, openFile3);
+ SearchTestPlugin.openTextEditor(activePage, openFile4);
long start= System.currentTimeMillis();
@@ -330,7 +330,7 @@ public class FileSearchTests extends TestCase {
IFile file2= ResourceHelper.createFile(folder, "file2", buf.toString());
try {
- IDE.openEditor(SearchPlugin.getActivePage(), file2, true);
+ SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file2);
Pattern searchPattern= PatternConstructor.createPattern("hello", false, true);
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
index f93c47435..2cbc53ff6 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/LineAnnotationManagerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,10 +13,6 @@ package org.eclipse.search.tests.filesearch;
import java.util.ArrayList;
import java.util.Iterator;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
@@ -26,23 +22,26 @@ import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.AnnotationTypeLookup;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.search.internal.ui.SearchPlugin;
+import org.eclipse.search.tests.SearchTestPlugin;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.FileTextSearchScope;
import org.eclipse.search.ui.text.Match;
-import org.eclipse.search.internal.ui.SearchPlugin;
-
import org.eclipse.search2.internal.ui.InternalSearchUI;
import org.eclipse.search2.internal.ui.text.EditorAnnotationManager;
import org.eclipse.search2.internal.ui.text.PositionTracker;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class LineAnnotationManagerTest extends TestCase {
private LineBasedFileSearch fLineQuery;
@@ -89,7 +88,7 @@ public class LineAnnotationManagerTest extends TestCase {
try {
for (int i= 0; i < files.length; i++) {
IFile file= (IFile) files[0];
- ITextEditor editor= (ITextEditor) IDE.openEditor(SearchPlugin.getActivePage(), file, true);
+ ITextEditor editor= (ITextEditor)SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
IAnnotationModel annotationModel= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
IDocument document= editor.getDocumentProvider().getDocument(editor.getEditorInput());
annotationModel.getAnnotationIterator();
diff --git a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
index e897250e6..274f57f81 100644
--- a/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
+++ b/org.eclipse.search.tests/src/org/eclipse/search/tests/filesearch/PositionTrackerTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2015 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,34 +10,33 @@
*******************************************************************************/
package org.eclipse.search.tests.filesearch;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.filebuffers.LocationKind;
-import org.eclipse.core.resources.IFile;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.Position;
import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.ide.IDE;
+import org.eclipse.search.internal.ui.SearchPlugin;
+import org.eclipse.search.internal.ui.text.FileSearchQuery;
+import org.eclipse.search.internal.ui.text.FileSearchResult;
+import org.eclipse.search.tests.SearchTestPlugin;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.text.AbstractTextSearchResult;
import org.eclipse.search.ui.text.FileTextSearchScope;
import org.eclipse.search.ui.text.Match;
-import org.eclipse.search.internal.ui.SearchPlugin;
-import org.eclipse.search.internal.ui.text.FileSearchQuery;
-import org.eclipse.search.internal.ui.text.FileSearchResult;
-
import org.eclipse.search2.internal.ui.InternalSearchUI;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
public class PositionTrackerTest extends TestCase {
FileSearchQuery fQuery1;
@@ -96,7 +95,7 @@ public class PositionTrackerTest extends TestCase {
private void checkInsertInsideMatch(FileSearchResult result, IFile file) throws PartInitException, BadLocationException {
Match[] matches= result.getMatches(file);
try {
- IDE.openEditor(SearchPlugin.getActivePage(), file);
+ SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
ITextFileBuffer fb= FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
IDocument doc= fb.getDocument();
@@ -127,7 +126,7 @@ public class PositionTrackerTest extends TestCase {
originalStarts[i]= matches[i].getOffset();
}
try {
- IDE.openEditor(SearchPlugin.getActivePage(), file);
+ SearchTestPlugin.openTextEditor(SearchPlugin.getActivePage(), file);
ITextFileBuffer fb= FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
IDocument doc= fb.getDocument();
doc.replace(0, 0, "Test");

Back to the top