JUnit-tests for property views [message #1802760] |
Fri, 15 February 2019 04:50  |
Eclipse User |
|
|
|
For testing functionality of our Sirius-based editor, we let our test classes derive from org.eclipse.sirius.tests.support.api.SiriusDiagramTestCase. This is very useful for, e.g., applying tools from the palette and checking properties on sessions.
Besides the diagram, our .odesign specifies property pages as well. Is there functionality available for (a) selecting a model element on the diagram and then (b) testing the corresponding property pages' text fields, buttons, etc (similar to applying palette tools using SiriusDiagramTestCase)?
We'd like to avoid testing our property pages using RCPTT or by, e.g, manually obtaining EditParts on the property pages and manipulating these.
|
|
|
Re: JUnit-tests for property views [message #1802774 is a reply to message #1802760] |
Fri, 15 February 2019 08:46   |
Eclipse User |
|
|
|
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,
|
|
|
|
Powered by
FUDForum. Page generated in 0.03244 seconds