How to test non-eclipse code [message #485871] |
Tue, 15 September 2009 06:54  |
Eclipse User |
|
|
|
Originally posted by: michael.danielsson.tieto.com
I have searched for a simple example where some non-eclipse GUI code is
tested, but I haven't found any.
Can someone please create a some tests where the following class is tested
package com.md.glosy.gui;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
public class QGroup {
private Group group;
private Text text;
public QGroup(Composite composite, int style) {
group = createQuestionGroup(composite, style);
}
private Group createQuestionGroup(Composite composite, int style) {
Group newGroup = new Group(composite, style);
newGroup.setText("QGroup");
newGroup.setLayout(new GridLayout());
Composite c = new Composite(newGroup, style);
c.setLayout(new GridLayout());
Label l = new Label(c, SWT.WRAP);
l.setText("Översätt följande:");
text = new Text(c, SWT.SINGLE | SWT.BORDER);
newGroup.pack();
return newGroup;
}
public void clearQuestion() {
text.setText("");
}
public void setQuestion(String question) {
text.setText(question);
}
public String getQuestion() {
return text.getText();
}
public void setTitle(String title) {
group.setText(title);
}
}
Regards, Michael
|
|
|
|
|
|
Re: How to test non-eclipse code [message #487677 is a reply to message #487638] |
Thu, 24 September 2009 02:54  |
Eclipse User |
|
|
|
I have tried to separete the gui from the logic and therefore I have classes which like in this case only creates a composite with some content. Since I have separated the gui from the logic I can test a lot of my code with JUnit, but I also would like to test the gui.
In the qui tests I would like to check that some controls exist in the composite and I also would like to check that the getters and setters work. In many cases I also want to check that an event is triggered from the gui.
So what I am looking for is some code which, I suppose, adds a composite to a shell, checks that all controlls are there, enters some text, presses some buttons and check that the correct events are fired.
As I have said before I have looked for a simple example with code that I can use but I have not found any.
Is it possible to do this with SwtBot?
Regards,
Michael Danielsson
|
|
|
Powered by
FUDForum. Page generated in 0.04251 seconds