Bug 260623 - Add a DSL for common functions to manipulate the Eclipse IDE
Summary: Add a DSL for common functions to manipulate the Eclipse IDE
Status: NEW
Alias: None
Product: SWTBot
Classification: Technology
Component: EclipseBot (show other bugs)
Version: 2.0.0-dev   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Ketan Padegaonkar CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-01-10 14:16 EST by David Green CLA
Modified: 2009-02-01 11:38 EST (History)
3 users (show)

See Also:


Attachments
a candidate implementation of a DSL (8.89 KB, patch)
2009-01-10 14:17 EST, David Green CLA
KetanPadegaonkar: iplog+
Details | Diff
mylyn/context/zip (1.98 KB, application/octet-stream)
2009-01-12 14:14 EST, David Green CLA
no flags Details
modified patch from David (18.27 KB, patch)
2009-01-12 22:39 EST, Ketan Padegaonkar CLA
no flags Details | Diff
minor changes (2.69 KB, patch)
2009-01-13 00:36 EST, David Green CLA
no flags Details | Diff
mylyn/context/zip (3.56 KB, application/octet-stream)
2009-01-13 00:36 EST, David Green CLA
no flags Details
added @noimplement to Workbench (1.04 KB, patch)
2009-01-13 00:38 EST, David Green CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description David Green CLA 2009-01-10 14:16:09 EST
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).
Comment 1 David Green CLA 2009-01-10 14:17:17 EST
Created attachment 122188 [details]
a candidate implementation of a DSL
Comment 2 Ketan Padegaonkar CLA 2009-01-10 22:53:37 EST
Lol! Already quite some interest in this. Let me see how this can fit into SWTBot.
Comment 3 Ketan Padegaonkar CLA 2009-01-10 23:59:45 EST
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();
    }
Comment 4 Ketan Patel CLA 2009-01-11 12:17:45 EST
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();
>     }
> 

Comment 5 David Green CLA 2009-01-12 14:12:47 EST
(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@. 

Comment 6 David Green CLA 2009-01-12 14:14:17 EST
Created attachment 122314 [details]
mylyn/context/zip
Comment 7 Ketan Padegaonkar CLA 2009-01-12 21:30:41 EST
(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.
Comment 8 Ketan Padegaonkar CLA 2009-01-12 22:39:25 EST
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.
Comment 9 Ketan Padegaonkar CLA 2009-01-12 22:41:40 EST
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 10 Ketan Padegaonkar CLA 2009-01-12 22:45:14 EST
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
Comment 11 David Green CLA 2009-01-13 00:27:50 EST
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.
Comment 12 David Green CLA 2009-01-13 00:36:03 EST
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
Comment 13 David Green CLA 2009-01-13 00:36:05 EST
Created attachment 122366 [details]
mylyn/context/zip
Comment 14 David Green CLA 2009-01-13 00:38:49 EST
Created attachment 122367 [details]
added @noimplement to Workbench

added @noimplement to Workbench
Comment 15 Ketan Padegaonkar CLA 2009-01-13 00:45:25 EST
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.
Comment 16 Ketan Padegaonkar CLA 2009-01-13 00:57:21 EST
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 17 Ketan Padegaonkar CLA 2009-01-13 01:16:47 EST
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.
Comment 18 Ketan Padegaonkar CLA 2009-01-13 01:17:03 EST
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.
Comment 19 David Green CLA 2009-01-13 01:31:00 EST
(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.
Comment 20 Ketan Padegaonkar CLA 2009-01-13 14:57:22 EST
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
Comment 21 David Green CLA 2009-01-13 16:15:21 EST
(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!


Comment 22 Ketan Padegaonkar CLA 2009-01-13 22:27:03 EST
(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.
Comment 23 David Green CLA 2009-01-14 00:38:14 EST
(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.