Community
Participate
Working Groups
I wrote JUnit tests on Indigo to tests the handler activation. On Juno, this code doesn't work for several reasons : - MakeHandlersGo.isEnabled() returns always true without testing the real handler - MakeHandlerGo is not a HandlerProxy, so I can't get the Handler declared in the plugin.xml to do an instanceof on it. org.eclipse.core.commands.Command testedCommand = ... IHandler handler = testedCommand.getHandler(); if(handler instanceof HandlerProxy) { handler = ((HandlerProxy)currentHandler).getHandler(); } Assert.isTrue(handler instanceof MyOwnHandler); Assert.isTrue(handler.isEnabled()); Now with this code I get a MakeHandlersGo which is always enabled... I think it is a bug on the compatibility layer? Do you have a solution to adapt my tests
You cannot depend on Command#getHandler(); We are free to set that to whatever we want. MakeHandlerGo in the M5 warmup isEnabled() will return enable for the active handlers now. In Eclipse 4 you can look up a handler (technically also using internals) using something like: MApplication app = workbench.getService(MAppliation.class); IEclipseContext context = app.getContext(); Object handler = HandlerServiceImpl.lookUpHandler(context, "command.id"); In 4.2 that tends to be an E4HandlerProxy, also an internal class. If you are looking on more information on this, I would suggest the Eclipse Platform or E4 forum at http://www.eclipse.org/forums/ PW
Thank you for your answer. I posted this question on the forum the 23th of January before to post this bug, but I didn't get an answer. /Vincent Lorenzo