diff --git a/core/org.eclipse.cdt.ui.tests/plugin.xml b/core/org.eclipse.cdt.ui.tests/plugin.xml index 1072a81b42a..b281c1f38cf 100644 --- a/core/org.eclipse.cdt.ui.tests/plugin.xml +++ b/core/org.eclipse.cdt.ui.tests/plugin.xml @@ -220,4 +220,12 @@ + + + + + + + diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java index fdb79f94f5e..19722ee1b71 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java @@ -11,12 +11,16 @@ package org.eclipse.cdt.ui.tests.text; import java.io.File; +import java.net.URI; +import java.net.URISyntaxException; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.URIUtil; +import org.eclipse.core.filesystem.provider.FileSystem; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; @@ -33,6 +37,7 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Event; import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorRegistry; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; @@ -72,6 +77,32 @@ public class BasicCEditorTest extends BaseUITestCase { } } + public static class Bug278632FileSystem extends FileSystem { + public Bug278632FileSystem() { + getClass(); + } + + @Override + public IFileStore getStore(URI uri) { + try { + // For the test case, this just return the FS implementation + // used for the null filesystem. + // In a real application this would be a real implementation, + // however for the purposes + // of exposing the bug, any non-file:// scheme will do. + return EFS.getStore(new URI( + EFS.getNullFileSystem().getScheme(), uri + .getSchemeSpecificPart(), null)); + } catch (URISyntaxException e) { + e.printStackTrace(); + return null; + } catch (CoreException e) { + e.printStackTrace(); + return null; + } + } + } + private static CEditor fEditor; private static SourceViewer fSourceViewer; private ICProject fCProject; @@ -378,6 +409,33 @@ public class BasicCEditorTest extends BaseUITestCase { assertSame(style.foreground, ppDirectiveColor); } + public void testNonFileEFSResource_Bug278632() { + IWorkbenchPage page = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow().getActivePage(); + assertNotNull(page); + + IEditorRegistry reg = page.getWorkbenchWindow().getWorkbench() + .getEditorRegistry(); + String editorID = reg.getDefaultEditor(".c").getId(); + + URI uri = null; + try { + uri = new URI("bug278632", "/folder/file", null); + } catch (URISyntaxException e) { + e.printStackTrace(); + } + assertNotNull(uri); + + IEditorPart part = null; + try { + part = IDE.openEditor(page, uri, editorID, true); + } catch (PartInitException e) { + e.printStackTrace(); + } + assertNotNull(part); + assertTrue(part instanceof CEditor); + } + /** * Type characters into the styled text. *