|
Re: JUnit-tests for property views [message #1802774 is a reply to message #1802760] |
Fri, 15 February 2019 13:46 |
|
Hi,
For (a), there should be no issue with programmatically selecting an element on a diagram. You can use for example org.eclipse.sirius.ui.business.api.dialect.DialectUIServices.setSelection(DialectEditor, List<DRepresentationElement>) or org.eclipse.sirius.ui.business.api.dialect.DialectUIServices.selectAndReveal(DialectEditor, List<DRepresentationElement>). Just make sure to wait for the selection to take effect (using for example org.eclipse.sirius.tests.support.api.TestsUtil.synchronizationWithUIThread()).
For (b) however, there is no API to introspect/manipulate the contents of the properties views. Our own tests in Sirius for these are made using RCPTT. Depending on your case, there is one possible workaround which would allow you to obtain the EMF model that Sirius produces and gives to the EEF runtime which describes the structure of the properties view, and that you can then check. This however does not test the UI part where the EEF runtime renders the actual SWT widgets from this description.
The general idea for this workaround is:
- Get the org.eclipse.ui.views.properties.IPropertySheetPage which is currently displayed by the "Properties" view, using the standard Eclipse APIs. If your properties view is produced by Sirius/EEF, it will be an org.eclipse.eef.properties.ui.api.EEFTabbedPropertySheetPage. Let's call it "page"
- page.getCurrentTab().getSections() will give you the org.eclipse.eef.properties.ui.api.IEEFSections the correspond to the widget groups in the page. In practice there will be only one for properties views produced by Sirius/EEF.
- Here you need to cast the IEEFSection into org.eclipse.eef.ide.ui.properties.api.EEFSection and use Java reflection to read its "private EEFTab tab" field. Unfortunately there is currently no API to access this. You can use Sirius's org.eclipse.sirius.common.tools.api.util.ReflectionHelper.getFieldValueWithoutException(Object, String) for this if you want.
- Once you have the org.eclipse.eef.ide.ui.api.EEFTab, tab.getEEFPage().getDescription() will give you the org.eclipse.eef.EEFPageDescription which is the root of the EMF model that describes the whole structure of the properties page.
Regards,
Pierre-Charles David - Obeo
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
|
|
|
|
Powered by
FUDForum. Page generated in 0.03666 seconds