Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » My editor is filtered out during junit test, any ideas why?
My editor is filtered out during junit test, any ideas why? [message #545440] Wed, 07 July 2010 19:09
Jeff Johnston is currently offline Jeff JohnstonFriend
Messages: 215
Registered: July 2009
Senior Member
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?
Previous Topic:Losing events from post selection listener
Next Topic:Any way to know when bundles are started?
Goto Forum:
  


Current Time: Fri Apr 19 06:34:29 GMT 2024

Powered by FUDForum. Page generated in 0.01435 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top