Cédric Brun bio photo

Cédric Brun

Build open-source technologies to enable mission critical tools for complex domains.

Email Twitter LinkedIn Github Youtube

In my never-ending quest of ideas or tools to avoid doing boring stuff (that sacred goal explains my interest in pragmatic modeling), I made quite a victory today thanks to one of those gems you find in Eclipse.

Here I’m speaking about the help/tutorials you get in the Eclipse help menu.

We often add many screenshots in the tutorial but this tiny little idea of “showing stuff to the user” may have a huge cost! The drawback of using such images in the help is that as the tool evolves the UI does so, and the tutorial screenshots are quickly really different from the real tool user interface.

Then you even have to recapture screenshots for every release, or just decide that “a real doc has no screenshots”.

Both are inadmissible. One idea would be to integrate this “screen capture” step in the build process and automatically capture the wizards, views or properties. Then, you would even be able to localize your documentation screenshots starting this process for every localization you have. You’ve got pretty much anything you need right now thanks to Eclipse to do that.

The gem I mentioned is SWTBot. Thanks to this little tool I quickly managed to get a basic test scenario working to test UI. Even if testing is important, and testing UI is tricky, here my goal was to produce the screenshots from the tests. Here is the code:

bot.view("Welcome").close();

bot.menu("Window").menu("Open Perspective").menu("Other...").click();
SWTBotShell openPerspectiveShell = bot.shell("Open Perspective");
openPerspectiveShell.activate();

bot.table().select("Acceleo");
captureScreenshot("1-switch-perspective.png");
bot.button("OK").click();

Switch perspective

bot.menu("File").menu("New").menu("Project...").click();
SWTBotShell newProjectShell = bot.shell("New Project");
newProjectShell.activate();
bot.tree().expandNode("Acceleo").getNode("Generator Project").select();
captureScreenshot("2-new-generator-project.png");

New generator project

bot.button("Next >").click();
bot.text().setText("org.acceleo.uml2.gen.java");
captureScreenshot("3-new-generator-step1.png");

New generator step 1

bot.button("Finish").click();
bot.waitUntil(Conditions.shellCloses(newProjectShell));
captureScreenshot("4-generator-project-done.png");

Generator project done

bot.menu("File").menu("New").menu("Empty Generator").click();
SWTBotShell newTemplateShell = bot.shell("New");
newTemplateShell.activate();
captureScreenshot("5-new-template-wizard.png");

New template wizard

bot.comboBox().setSelection("https://www.eclipse.dev/uml2/2.1.0/UML");
bot.comboBox(1).setSelection("uml.Class");
captureScreenshot("6-new-template-wizard-full.png");

New template wizard full

That’s the 喜喜 (ShuangXi) effect: you roughly test your UI and you get your screenshots!

ps: special “Hi” to the unique Guangzhou visitor I had on this blog so far :)