Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » JUnit-tests for property views
JUnit-tests for property views [message #1802760] Fri, 15 February 2019 09:50 Go to next message
Tjalling Ran is currently offline Tjalling RanFriend
Messages: 4
Registered: February 2019
Junior Member
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 13:46 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles DavidFriend
Messages: 491
Registered: July 2009
Senior Member
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
Re: JUnit-tests for property views [message #1802897 is a reply to message #1802774] Mon, 18 February 2019 17:05 Go to previous message
Tjalling Ran is currently offline Tjalling RanFriend
Messages: 4
Registered: February 2019
Junior Member
Thank you for the elaborate answer. I wasn't aware of the DialectUIServices, very useful to know. For the EEFPageDescription, I've put an item on our backlog, as that seems definitely worth trying.
Previous Topic:[ANN] Sirius 6.1.2
Next Topic:Sirius to visio
Goto Forum:
  


Current Time: Wed Oct 23 21:55:47 GMT 2019

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

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

Back to the top