Community
Participate
Working Groups
There are many common UI manipulation tasks that are used in UI tests that are not core to the test itself: * switching perspectives * resetting the perspective to its default settings * closing dialogs and views that could be left over from previous tests, or the 'Welcome' perspective It would be very useful to have these common functions available in a Java DSL (Domain Specific Language).
Created attachment 122188 [details] a candidate implementation of a DSL
Lol! Already quite some interest in this. Let me see how this can fit into SWTBot.
David, the patch looks good. The implementation of the reset method could use some love, by extracting out some more api. We have a similar API(below), which I can swap in instead. This also exposes a bit more api that users may leverage. Any thoughts, comments ? public void stop() throws Exception { eclipse.killAllLaunches(); eclipse.closeAllDialogs(); eclipse.saveAllEditors(); eclipse.closeAllEditors(); eclipse.deleteAllButTwistDogFoodProjects(); }
This would be nice...I was thinking about writing something like it. It would be nice to have it as part of SWTEclipseBot since it seems very common need. (In reply to comment #3) > David, the patch looks good. The implementation of the reset method could use > some love, by extracting out some more api. We have a similar API(below), which > I can swap in instead. > > This also exposes a bit more api that users may leverage. Any thoughts, > comments ? > > public void stop() throws Exception { > eclipse.killAllLaunches(); > eclipse.closeAllDialogs(); > eclipse.saveAllEditors(); > eclipse.closeAllEditors(); > eclipse.deleteAllButTwistDogFoodProjects(); > } >
(In reply to comment #3) > The implementation of the reset method could use some love, by extracting out some more api. Agreed, what I had there was quick and dirty. > We have a similar API(below), which > I can swap in instead. Sounds good. Perhaps you could update the patch? I couldn't find the API that you're referencing. > This also exposes a bit more api that users may leverage. Any thoughts, comments don't forget that we need to close the 'Welcome' view as well, and all methods in the DSL must return @this@.
Created attachment 122314 [details] mylyn/context/zip
(In reply to comment #5) > don't forget that we need to close the 'Welcome' view as well, and all methods > in the DSL must return @this@. In case the welcome screen is already closed, then this method will block (for about 15 seconds, which is the default timeout) each time it is invoked. Closing the welcome screen will add another few seconds to the test. For most people closing the welcome screen would be a one time activity before any test begins, but the cleanup, as you mention would probably happen as a cleanup after every test has executed. I assume this is not a frequent operation. So I'll probably investigate on some syntactic sugar that can make this additional thing of closing the welcome screen a bit more explicit. I'll check some code in and we could then see how we can make it look better.
Created attachment 122357 [details] modified patch from David Modified existing patch to move to a new dsl plugin. Also extracted some API out of the same patch.
Your patch (with some modifications has been applied on trunk in a brand new dsl plugin project). I'll work on this to add some more api as mentioned in comment #3.
Comment on attachment 122188 [details] a candidate implementation of a DSL Welcome to the SWTBot hall of fame. Your 249 line patch, just missed the IP review :P
Wow, that was quick. So outstanding issues are: * Welcome view will take too long to close if it's not open * Closing the Welcome screen as part of reset() will prevent UI tests on the Welcome screen from using reset() * Labels are hard-coded into the DSL, so this won't work for UIs in non-English locales * DSL for common views such as the Package Explorer * One of the Eclipse.workbench() methods returns DefaultWorkbench when it should return Workbench Thanks for getting this one in there, and let's iterate on the remaining issues.
Created attachment 122365 [details] minor changes (In reply to comment #10) > Welcome to the SWTBot hall of fame. Thanks! I just realized that I put the year 2008 in the copyright header. Should be 2009. attached a patch that fixes the copyright header, minor javadoc changes and workbench() now returns Workbench instead of DefaultWorkbench
Created attachment 122366 [details] mylyn/context/zip
Created attachment 122367 [details] added @noimplement to Workbench added @noimplement to Workbench
To add to David's comment #11: * I can see the Workbench class start to know about perspectives, and perhaps other abstractions as it evolves. It probably makes sense to pull out some form of a 'PerspectiveFinder/Helper' and other helper classes as need arises.
David, reg your previous patch, and the javadoc, that clients should not implement Workbench interface but subclass DefaultWorkbench instead. Do you see any reason for doing this ? I can see that Workbench may have different implementations based on eclipse versions, the customizations that come with an RCP application, etc. As long as the implementations adhere to the interface, I do not see any reason for marking this interface internal. Am I missing something more obvious ?
Comment on attachment 122188 [details] a candidate implementation of a DSL For some reasons this does not apply in the iplog, will remove flag, and add it back.
(In reply to comment #16) > David, reg your previous patch, and the javadoc, that clients should not > implement Workbench interface but subclass DefaultWorkbench instead. Do you see > any reason for doing this ? A Java interface that can be implemented by others can never change. This is how we ended up with insanity like IDocumentExtension, IDocumentExtension2, IDocumentExtension3, IDocumentExtension4, etc. This is why I made it an abstract class in the first place. If it must be an interface, then it should not be implemented outside of the plug-in.
I've made the Workbench an abstract class. Added some convinience API with some syntactic sugar coating as discussed before, any comments on this version ? To add to comment #11: * Investigate another low level eclipse API that can reset a perspective, instead of the menu based approach. * Still need to write a few tests to ensure basic functionality on eclipse 3.3/3.4
(In reply to comment #20) > I've made the Workbench an abstract class. I don't see it in revision 79: it's still an interface. > Added some convinience API with some > syntactic sugar coating as discussed before, any comments on this version ? Looks great!
(In reply to comment #21) > I don't see it in revision 79: it's still an interface. Fixed. Any other convenience API that folks wish to push into SWTBot are welcome.
(In reply to comment #22) > Any other convenience API that folks wish to push into SWTBot are welcome. Great, sounds good! I've got some DSL for the Package Explorer but won't be able to push it out for a month or so.