problem with org.eclipse.ui.internal.MakeHandlersGo [message #782375] |
Mon, 23 January 2012 16:10 |
|
Hi all,
On Eclipse indigo, I wrote JUnit tests to tests the handler activation :
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, testedCommand.getHandler() returns an MakeHandlersGo and not the handler declared in the plugin.xml...
Do you have a solution to adapt my code to E4, but it continues to work on Eclipse 3.8 ?
Is a Layer Compatibility bug?
Regards,
|
|
|
Re: problem with org.eclipse.ui.internal.MakeHandlersGo [message #783507 is a reply to message #782375] |
Wed, 25 January 2012 21:11 |
Eclipse User |
|
|
|
vincent lorenzo wrote on Mon, 23 January 2012 11:10
Is a Layer Compatibility bug?
No. Your test is relying on an implementation detail.
There's no guarantee in Command.getHandler() that the handler returned is the actual handler object to be executed. But calling execute() on that returned handler object will cause the handler to be executed.
(In E4, handlers can be POJOs; the compat layer wraps these handlers in an IHandler wrapper.)
vincent lorenzo wrote on Mon, 23 January 2012 11:10
Do you have a solution to adapt my code to E4, but it continues to work on Eclipse 3.8 ?
Not really.
What are you actually trying to test? That your handler will be executed? (What if there are other handlers for the command?) That its activeWhen expression is correct? Perhaps associate a dummy handler with the same expression that sets a value on execution, and then actually execute it.
|
|
|
Powered by
FUDForum. Page generated in 0.02964 seconds