1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-06 15:55:47 +02:00

Test case for bug 278632 by Andrew Eidsness

This commit is contained in:
Anton Leherbauer 2009-06-04 09:36:52 +00:00
parent 1fa3b1dd39
commit cd018e7c10
2 changed files with 66 additions and 0 deletions

View file

@ -220,4 +220,12 @@
</enablement>
</renameParticipant>
</extension>
<extension point="org.eclipse.core.filesystem.filesystems">
<filesystem
scheme="bug278632">
<run class="org.eclipse.cdt.ui.tests.text.BasicCEditorTest$Bug278632FileSystem"/>
</filesystem>
</extension>
</plugin>

View file

@ -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.
*