Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » GEF » how to test view in GEF MVC
how to test view in GEF MVC [message #1770640] Tue, 15 August 2017 13:57 Go to next message
Shenwei Zheng is currently offline Shenwei ZhengFriend
Messages: 22
Registered: December 2016
Junior Member
The graphical views are controlled by part in GEF MVC. How could we test view such as its layout and interaction? How could we know the visual elements are placed at the correct position? Is there anything in GEF we can apply for testing? Thank you.
Re: how to test view in GEF MVC [message #1770646 is a reply to message #1770640] Tue, 15 August 2017 14:28 Go to previous messageGo to next message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
Hi Shenwei,

the default interactions provided by GEF are tested, too. For this purpose, we implemented two JUnit test rules that initialize the JavaFX toolkit:
- The FXApplicationThreadRule [1] ensures that the test code is executed on the JavaFX application thread. Therefore, the scene graph can be accessed directly, without having to spawn runnables on the application thread. However, interactions (firing events, waiting for processing, etc.) needs to be done manually using FXApplicationThreadRule.
- The FXNonApplicationThreadRule [2] ensures that the test code is executed on a thread other than the JavaFX application thread. It provides a number of utility methods that can be used to perform interactions within the JavaFX application thread similar to the AWT Robot. The JavaFX events for mouse/keyboard interaction are synthesized, instead of trying to make the system send the events. The FXNonApplicationThreadRule ensures that the events are completely processed before continuing test execution. Therefore, I would suggest using FXNonApplicationThreadRule for testing interactions. For a usage example, you can take a look at BendConnectionPolicyTests [3].

One thing you will probably want to do different than GEF is using a mocking framework to reduce boilerplate code. For GEF, the different options still need to be evaluated and the test code needs to be refactored once a decision is made (for using a specific mocking framework), i.e. the many inner classes should not be taken as a deterrent.

[1] https://github.com/eclipse/gef/blob/master/org.eclipse.gef.mvc.tests.fx/src/org/eclipse/gef/mvc/tests/fx/rules/FXApplicationThreadRule.java
[2] https://github.com/eclipse/gef/blob/master/org.eclipse.gef.mvc.tests.fx/src/org/eclipse/gef/mvc/tests/fx/rules/FXNonApplicationThreadRule.java
[3] https://github.com/eclipse/gef/blob/master/org.eclipse.gef.mvc.tests.fx/src/org/eclipse/gef/mvc/tests/fx/BendConnectionPolicyTests.java

Best regards,
Matthias
Re: how to test view in GEF MVC [message #1772495 is a reply to message #1770646] Mon, 11 September 2017 14:03 Go to previous messageGo to next message
Shenwei Zheng is currently offline Shenwei ZhengFriend
Messages: 22
Registered: December 2016
Junior Member
Hi Matthias,

thanks very much. I will try it out.

Bests
Shenwei
Re: how to test view in GEF MVC [message #1780958 is a reply to message #1772495] Tue, 30 January 2018 12:55 Go to previous messageGo to next message
Shenwei Zheng is currently offline Shenwei ZhengFriend
Messages: 22
Registered: December 2016
Junior Member
Hi Matthias,

I have wrote first test case and it works fine, thank you very much.
But I still have a question regarding the plugin org.eclipse.gef.mvc.tests.fx. I didn't find any repository including this plugin. Is it already included somewhere? Thank you.

Bests
Shenwei
Re: how to test view in GEF MVC [message #1785831 is a reply to message #1780958] Fri, 20 April 2018 11:46 Go to previous message
Matthias Wienand is currently offline Matthias WienandFriend
Messages: 230
Registered: March 2015
Senior Member
Hi Shenwei,

the o.e.gef.mvc.tests.fx bundle is not published on the update sites. However, I believe it should be made available. Hence, I created https://bugs.eclipse.org/bugs/show_bug.cgi?id=533869 to keep track of the issue.

regards,
Matthias
Previous Topic:GEF5 MVC Draw polygon
Next Topic:Zest5: getting the model node from the displayed node
Goto Forum:
  


Current Time: Tue Dec 03 15:38:38 GMT 2024

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

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

Back to the top