| SWTBot for custom SWT control [message #1000772] |
Tue, 15 January 2013 07:13  |
Dirk Fauth Messages: 516 Registered: July 2012 |
Senior Member |
|
|
Hi,
I created a custom SWT control that contains of two TreeViewers, supporting moving items from left to right and vice versa. I am planning to contribute this to Nebula, but before that, I need to fix some special issues related to TreeViewers.
Said that, I wanted to add several test cases, using SWTBot. But I can not figure out how to get the test cases running with SWTBot.
Maybe I'm just missing some basic parts, but everything I find searching the web is related to Eclipse applications using the workbench. Of course I could create a small example application that consists of just a part with that composite. But shouldn't it be possible to test plain SWT? At least I read that it is possible, but with no examples.
Running the test cases as pure JUnit test out of Eclipse will cause an exception telling me the Realm can not be null. This is because I use databinding in the back.
In some example code I wrote, I solved it this way in a main method
final Display display = Display.getDefault();
final Shell shell = new Shell(display, SWT.SHELL_TRIM);
shell.setLayout(new FillLayout());
shell.setSize(400, 300);
shell.setText("Tree chooser example");
Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() {
public void run() {
new TreeChooserExample(true).createControl(shell);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
display.sleep();
}
}
}
});
But how to solve this with SWTBot?
Any help is appreciated.
Greez,
Dirk
|
|
|