I have a junit test which creates a project, then creates a file: "Makefile.am" inside the project. The junit test performs an openEditor and verifies the editor is a special editor (AutomakeEditor) that I have set up for Makefile.am files.
public void testAutomakeEditorAssociation() throws Exception {
project = ProjectTools.createProject("testProjectAET");
if(project == null) {
fail("Unable to create test project");
}
project.open(new NullProgressMonitor());
IFile makefileAmFile = tools.createFile(project, "Makefile.am", "");
assertTrue(makefileAmFile.exists());
IWorkbench workbench = AutotoolsTestsPlugin.getDefault().getWorkbench();
IEditorPart openEditor = org.eclipse.ui.ide.IDE.openEditor(workbench
.getActiveWorkbenchWindow().getActivePage(), makefileAmFile,
true);
assertTrue(openEditor instanceof AutomakeEditor);
project.delete(true, false, ProjectTools.getMonitor());
}
The assert regarding the openEditor being an instance of AutomakeEditor is failing for me every time when running the test as a Junit plugin test directly from Eclipse. A Text editor is being returned. This same test succeeds under automatic test runs that have been set up under Hudson for both Helios and Galileo (I am running Helios 3.6 Classic freshly downloaded from Eclipse.org on my system).
I debugged and found that the filename to editor association is correct (it finds my AutomakeEditor), but the editor is being filtered out because the isEnabled() check below found in WorkbenchActivityHelper returns false due to the identifier not being enabled.
public static final boolean filterItem(Object object) {
if (object instanceof IPluginContribution) {
IPluginContribution contribution = (IPluginContribution) object;
IWorkbenchActivitySupport workbenchActivitySupport = PlatformUI
.getWorkbench().getActivitySupport();
IIdentifier identifier = workbenchActivitySupport
.getActivityManager().getIdentifier(
createUnifiedId(contribution));
if (!identifier.isEnabled()) {
return true;
}
}
return false;
}
If I run a child Eclipse application with all plug-ins, editing a Makefile.am file works as expected (my AutomakeEditor is clearly being used as is evident with the icon being used). However, checking out the test case into the child Eclipse workspace and running it results in the same failure with a Text editor coming back from openEditor every time..
Any ideas why the filtering could be occurring? Is the test flawed?