Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Support of MessageDialog
Support of MessageDialog [message #488578] Tue, 29 September 2009 10:39 Go to next message
Werner Hihn is currently offline Werner HihnFriend
Messages: 32
Registered: July 2009
Member
Hi Ketan, hi community,

first of all, thanks a lot for your great work. I started using SWTBot some months ago, and managed to test nearly everything I wanted in our eclipse based application, not least with the help of this community.

One thing I stumbled upon now, is the JFace MessageDialog...
I read a statement of yours [1] where you are saying the MessageDialog is not supported yet, another statement of Ketan Patel was that this should work using bot.shell("Title") [2].

Could you please tell me what' s the current state here? For me it' s not working, there' s no timeout, the test simply freezes as soon as the MessageDialog is displayed.
If there is no support for MessageDialog yet, would it speed up things, to file a bug for this? Wink

Thanks in advance,
Werner

[1] - http://ketan.padegaonkar.name/2007/11/14/another-sneak-previ ew-into-swtbot.html
[2] - http://dev.eclipse.org/mhonarc/newsLists/news.eclipse.swtbot /msg00492.html
Re: Support of MessageDialog [message #496716 is a reply to message #488578] Wed, 11 November 2009 06:55 Go to previous messageGo to next message
Daniel Weber is currently offline Daniel WeberFriend
Messages: 51
Registered: July 2009
Member
Hi Werner,

this snippet runs just fine:

@Test
public void msgDialog() throws Exception {
bot.activeShell().display.asyncExec(new Runnable() {
public void run() {
MessageDialog.openConfirm(bot.activeShell().widget, "A MessageDialog", "Buhu");
}
});
bot.shell("A MessageDialog").activate();
bot.sleep(5000);
bot.button("OK").click();
}

SWTBot currently cannot support native dialogs (see [1], [2] and [3]), e.g. SWT's FileDialog and ColorDialog. org.eclipse.jface.dialogs.MessageDialog however is not one of them and can therefore be properly supported by SWTBot (in jface 3.5.0, shipped with Eclipse Galileo). Maybe this was different back in 2007. Or Ketan actually meant org.eclipse.swt.widgets.MessageBox, which still creates a native dialog.

Regards,
Daniel

[1] - https://bugs.eclipse.org/bugs/show_bug.cgi?id=283609
[2] - https://bugs.eclipse.org/bugs/show_bug.cgi?id=292953
[3] - https://bugs.eclipse.org/bugs/show_bug.cgi?id=164192
Re: Support of MessageDialog [message #496734 is a reply to message #496716] Wed, 11 November 2009 08:48 Go to previous messageGo to next message
Werner Hihn is currently offline Werner HihnFriend
Messages: 32
Registered: July 2009
Member
Daniel,

thanks for your answer. Your snippet works fine for me, too. But when
I'm trying to access a MessageDialog opened from within my Application,
it still fails. I'll try to find out what' s the difference here..

btw, I'm using SWTBot 2.0.0.433-dev-e35 with an application based on
Eclipse Galileo.

Regards,
Werner

Daniel Weber schrieb:
> Hi Werner,
>
> this snippet runs just fine:
>
> @Test
> public void msgDialog() throws Exception {
> bot.activeShell().display.asyncExec(new Runnable() {
> public void run() {
> MessageDialog.openConfirm(bot.activeShell().widget, "A
> MessageDialog", "Buhu");
> }
> });
> bot.shell("A MessageDialog").activate();
> bot.sleep(5000);
> bot.button("OK").click();
> }
>
> SWTBot currently cannot support native dialogs (see [1], [2] and [3]),
> e.g. SWT's FileDialog and ColorDialog.
> org.eclipse.jface.dialogs.MessageDialog however is not one of them and
> can therefore be properly supported by SWTBot (in jface 3.5.0, shipped
> with Eclipse Galileo). Maybe this was different back in 2007. Or Ketan
> actually meant org.eclipse.swt.widgets.MessageBox, which still creates a
> native dialog.
>
> Regards,
> Daniel
>
> [1] - https://bugs.eclipse.org/bugs/show_bug.cgi?id=283609
> [2] - https://bugs.eclipse.org/bugs/show_bug.cgi?id=292953
> [3] - https://bugs.eclipse.org/bugs/show_bug.cgi?id=164192
Re: Support of MessageDialog [message #496737 is a reply to message #496734] Wed, 11 November 2009 09:08 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Werner Hihn wrote:
> Daniel,
>
> thanks for your answer. Your snippet works fine for me, too. But when
> I'm trying to access a MessageDialog opened from within my Application,
> it still fails. I'll try to find out what' s the difference here..
>
> btw, I'm using SWTBot 2.0.0.433-dev-e35 with an application based on
> Eclipse Galileo.

This generally happens when swtbot tests run on the ui thread. Are you
performing a swtbot launch(Run As>SWTBot Test) or a pde launch(Run
As>Plugin JUnit test) ?

-- Ketan
Re: Support of MessageDialog [message #496766 is a reply to message #496737] Wed, 11 November 2009 10:54 Go to previous messageGo to next message
Werner Hihn is currently offline Werner HihnFriend
Messages: 32
Registered: July 2009
Member
> This generally happens when swtbot tests run on the ui thread. Are you
> performing a swtbot launch(Run As>SWTBot Test) or a pde launch(Run
> As>Plugin JUnit test) ?
>
> -- Ketan

I'm using the swtbot launch, so tests are not running on the UI thread.

Werner
Re: Support of MessageDialog [message #496970 is a reply to message #488578] Wed, 11 November 2009 22:45 Go to previous messageGo to next message
Jay Norwood is currently offline Jay NorwoodFriend
Messages: 112
Registered: July 2009
Senior Member
ok, I tried to post once, but maybe it was lost since I don't see it in the replies. Maybe I hit the wrong button.

I just wanted to note a couple of things:

The sleep() isn't really necessary in this case because activate() has a waitUntil in it the shell is active.

I've found it necessary in some circumstances with testing of preference settings to do an activate on the initial shell again before attempting to click on its OK button.

So, for example:

bot.menu("Window").menu("Preferences").click();
SWTBotShell prefsShell = bot.shell("Preferences");
prefsShell.activate();

.... make some preference settings

prefsShell.activate();
bot.button("OK").click();
bot.waitUntil(shellCloses(prefsShell));

---------

I'd also like to also propose that we change SWTBotShell.activate() so that it returns SWTBotShell, so we can do:

SWTBotShell prefsShell = bot.shell("Preferences").activate();

in the above example.


Re: Support of MessageDialog [message #496978 is a reply to message #496970] Thu, 12 November 2009 03:03 Go to previous message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
Jay Norwood wrote:
> I'd also like to also propose that we change SWTBotShell.activate() so
> that it returns SWTBotShell, so we can do:
>
> SWTBotShell prefsShell = bot.shell("Preferences").activate();
>
> in the above example.


Done!

-- Ketan
Previous Topic:How to test chart with SWTBot
Next Topic:button.click() => IndexOutOfBoundsException
Goto Forum:
  


Current Time: Fri Dec 19 23:44:19 GMT 2014

Powered by FUDForum. Page generated in 0.13074 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software