Hmm... My guess is that you're
getting it in setUp(). You need to be on the UI thread to do most
SWT/jface API calls (like creating & opening dialogs).
| From:
|
Bleyh, Nicolás <Nicolas.Bleyh <at> misys.com>
|
| To:
|
Gary Johnston/Raleigh/IBM <at> IBMUS, <abbot-users <at> lists.sourceforge.net>
|
| Date:
|
05/14/2008 10:45 AM
|
| Subject:
|
RE: [abbot-users] Testing SWT Buttons |
Hi Gary,
Thanks for you answer. I have
modified the code, but I still get the "invalid thread" exception.
My test class now looks like:
public class ImportDictionaryWizardTest2
extends WorkbenchTestCase {
private ImportDictionaryWizard
wizard;
private WizardDialog dialog;
<at> Before
public void setUp() {
wizard = new ImportDictionaryWizard();
wizard.init(getWorkbench(), new SampleSelection());
dialog = new WizardDialog(getShell(), wizard);
dialog.setBlockOnOpen(false);
dialog.create();
dialog.open();
}
<at> Test
public void testWizard() {
WizardTester.Default.actionClickCancel(dialog.getShell());
}
}
What is wrong?
Regards,
Nick
From: abbot-users-bounces <at> lists.sourceforge.net
[
mailto:abbot-users-bounces <at> lists.sourceforge.net]
On Behalf Of Gary Johnston
Sent: Mittwoch, 14. Mai 2008 14:20
To: abbot-users <at> lists.sourceforge.net
Subject: Re: [abbot-users] Testing SWT Buttons
Hi, Nick,
All of the Abbot SWT Testers are intended to used *off* the UI thread (and
they check for this). This will happen automatically if your TestCase
class extends SWTTestCase or WorkbenchTestCase. Then, your own test
code will not (and should not) use Display.syncExec(Runnable) for invoking
*Tester methods (which call it themselves where necessary).
Your code could then look something like this (i.e., same as before but
not in a Display.syncExec(Runnable).
...
Button next = (Button) WidgetFinderImpl.getDefault().find(dialog.buttonBar,
new WidgetTextMatcher(IDialogConstants.NEXT_LABEL, Button.class));
ButtonTester.getButtonTester().actionClick(next);
assertTrue(dialog.getCurrentPage() instanceof AbstractImportWizardLoadPage);
...
BTW, there is some slightly higher-level support for dealing with Dialogs
and Wizards. For example, check out WizardTester which has methods
like actionClickNext(Shell) that would simply this a bit more:
...
WizardTester.Default.actionClickNext(dialog.getShell());
assertTrue(dialog.getCurrentPage() instanceof
AbstractImportWizardLoadPage);
...
If you know the page title of the expected AbstractImportWizardLoadPage
(let's say it's "Import Wizard Load") then it gets even simpler:
...
WizardTester.Default.actionClickNext(dialog.getShell(),
"Import Wizard Load");
...
I hope this helps.
Regards,
| From:
|
Bleyh, Nicolás <Nicolas.Bleyh <at> misys.com>
|
| To:
|
<abbot-users <at> lists.sourceforge.net>
|
| Date:
|
05/14/2008 05:15 AM
|
| Subject:
|
[abbot-users] Testing SWT Buttons |
Hi,
I'm trying to test an Eclipse Wizard. For this reason I use Abbot to click
on the next button and go to the next wizard page. I have the following
code:
...
display.syncExec(new Runnable()
{
public void run()
{
...
Button next = (Button) WidgetFinderImpl.getDefault().find(dialog.buttonBar,
new WidgetTextMatcher(IDialogConstants.NEXT_LABEL, Button.class));
ButtonTester.getButtonTester().actionClick(next);
assertTrue(dialog.getCurrentPage() instanceof AbstractImportWizardLoadPage);
...
}
}
...
With this code I get an "invalid thread" exception at the point
ButtonTester.getButtonTester().actionClick(next)
Can anyone provide an example how the ButtonTester should be used? Thanks.
Nick
"Misys" is the trade name for Misys plc (registered in England
and Wales). Registration Number: 01360027. Registered office: Burleigh
House, Chapel Oak, Salford Priors, Evesham WR11 8SP. For a list of Misys
group operating companies please go to
http://www.misys.com/html/about_us/group_operating_companies/.
This email and any attachments have been scanned for known viruses using
multiple scanners.
We believe that this email and any attachments are virus free, however
the recipient must take full responsibility for virus checking. This email
message is intended for the named recipient only. It may be privileged
and/or confidential. If you are not the named recipient of this email please
notify us immediately and do not copy it or use it for any purpose, nor
disclose its contents to any other person. This email does not constitute
the commencement of legal relations between you and Misys plc. Please refer
to the executed contract between you and the relevant member of the Misys
group for the identity of the contracting party with which you are dealing.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________
abbot-users mailing list
abbot-users <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/abbot-users
"Misys" is the trade
name for Misys plc (registered in England and Wales). Registration Number:
01360027. Registered office: Burleigh House, Chapel Oak, Salford Priors,
Evesham WR11 8SP. For a list of Misys group operating companies please
go to http://www.misys.com/html/about_us/group_operating_companies/.
This email and any attachments have been scanned for known viruses using
multiple scanners.
We believe that this email
and any attachments are virus free, however the recipient must take full
responsibility for virus checking. This email message is intended for the
named recipient only. It may be privileged and/or confidential. If you
are not the named recipient of this email please notify us immediately
and do not copy it or use it for any purpose, nor disclose its contents
to any other person. This email does not constitute the commencement of
legal relations between you and Misys plc. Please refer to the executed
contract between you and the relevant member of the Misys group for the
identity of the contracting party with which you are dealing.