Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » More shells than expected
More shells than expected [message #28442] Wed, 18 March 2009 17:05 Go to next message
Hans Schwaebli is currently offline Hans SchwaebliFriend
Messages: 70
Registered: July 2009
Member
Since a few weeks (or even longer) I get more shells than I expect.

I use bot.shells().lenght

Previously it returned 1 if there was no modal dialog. But now it returns
2 or even more, although there is no modal dialog visible.

I could not figure out what that "phantom" shell objects are on the GUI.

I always thought the main shell is the application itself which anyone can
see (is visible). And if there is a model dialog on top of that shell,
then there are 2 shells, but not more or less.

Did something change regarding that in SWTBot? Or have I to look at the
application under test if there something changed? Or any ideas why this
is?
Re: More shells than expected [message #28958 is a reply to message #28442] Wed, 18 March 2009 23:56 Go to previous messageGo to next message
Ketan Patel is currently offline Ketan PatelFriend
Messages: 68
Registered: July 2009
Member
Looking at the code, it does not appear to have been touch for awhile.
Besides the underlying code that returns all shells is:

public Shell[] getShells() {
return UIThreadRunnable.syncExec(display, new ArrayResult<Shell>() {
public Shell[] run() {
return display.getShells();
}
});
}
Re: More shells than expected [message #28995 is a reply to message #28958] Thu, 19 March 2009 08:06 Go to previous messageGo to next message
Hans Schwaebli is currently offline Hans SchwaebliFriend
Messages: 70
Registered: July 2009
Member
Then it might be something with the application under test.

But what could these invisible Shells be? There is a application window
(main Shell) and no dialog on top of it. How can it then count more than 1
Shell?
Re: More shells than expected [message #29032 is a reply to message #28995] Thu, 19 March 2009 08:17 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
These could be shells that were created but not opened.

Try looking at the titles on these shells to get an idea of what they
do, or set up a breakpoint in the shell constructor to see where they're
being created.

-- Ketan

On 19/3/09 13:36, Hans Schwaebli wrote:
> Then it might be something with the application under test.
>
> But what could these invisible Shells be? There is a application window
> (main Shell) and no dialog on top of it. How can it then count more than
> 1 Shell?
>
Re: More shells than expected [message #29068 is a reply to message #29032] Thu, 19 March 2009 09:40 Go to previous messageGo to next message
Hans Schwaebli is currently offline Hans SchwaebliFriend
Messages: 70
Registered: July 2009
Member
What I try to achieve is to generically test whether there is a modal
dialog in front of the application (for example warning or error dialog).

Since after some actions I expect either a modal dialog to appear or no
modal dialog to appear.

I thought I can do this with display.shells().length, but it is not
suitable for that purpose.

Any idea how I can test this generically (independent of shell title etc.)?
Re: More shells than expected [message #29146 is a reply to message #29068] Thu, 19 March 2009 12:31 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
See the #resetWorkbench() method in
http://github.com/ketan/swtbot/blob/master/org.eclipse.swtbo t.eclipse.dsl/src/org/eclipse/swtbot/eclipse/dsl/DefaultWork bench.java

The dsl plugin is not distributed because of lack of tests around it,
but you'll find most of the things you need there.

-- Ketan

On 19/3/09 15:10, Hans Schwaebli wrote:
> What I try to achieve is to generically test whether there is a modal
> dialog in front of the application (for example warning or error dialog).
>
> Since after some actions I expect either a modal dialog to appear or no
> modal dialog to appear.
>
> I thought I can do this with display.shells().length, but it is not
> suitable for that purpose.
>
> Any idea how I can test this generically (independent of shell title etc.)?
>
Re: More shells than expected [message #29184 is a reply to message #29146] Thu, 19 March 2009 16:18 Go to previous messageGo to next message
Hans Schwaebli is currently offline Hans SchwaebliFriend
Messages: 70
Registered: July 2009
Member
It was not quite the solution to my problem, but it gave me an idea. Now I
solve it this way:

public void assertActiveShell(String text)
{
SWTBot bot = new SWTBot();
SWTBotShell activeShell = bot.activeShell();
String activeShellText = activeShell.getText();
assertEquals(text, activeShellText);
}

DefaultWorkbench.java has some nice helper methods, but in my mind they
are not DSL specific.


Ketan Padegaonkar wrote:

> See the #resetWorkbench() method in
>
http://github.com/ketan/swtbot/blob/master/org.eclipse.swtbo t.eclipse.dsl/src/org/eclipse/swtbot/eclipse/dsl/DefaultWork bench.java

> The dsl plugin is not distributed because of lack of tests around it,
> but you'll find most of the things you need there.

> -- Ketan
Re: More shells than expected [message #29337 is a reply to message #28995] Thu, 19 March 2009 23:10 Go to previous messageGo to next message
Ketan Patel is currently offline Ketan PatelFriend
Messages: 68
Registered: July 2009
Member
I know there can be "hidden" shells. We have one always open but not
shown...so there are always two shells but only one shown.

Hans Schwaebli wrote:

> Then it might be something with the application under test.

> But what could these invisible Shells be? There is a application window
> (main Shell) and no dialog on top of it. How can it then count more than 1
> Shell?
Re: More shells than expected [message #29374 is a reply to message #29068] Thu, 19 March 2009 23:20 Go to previous message
Ketan Patel is currently offline Ketan PatelFriend
Messages: 68
Registered: July 2009
Member
This might not work all the time but if your goal is to make sure your
application under test is accessible, I would try getting all the shells
descendant of your application, i.e. Shell.getShells() method. In SWTBot,
look at
org.eclipse.swtbot.swt.finder.waits.Conditions.waitForShell( Matcher <?>,
Shell); you should be able to pass in anything() matcher to get all the
shell.

Another idea is to try to force focus the application. If it fails, get
the active shell and close it if not what you looking for in a loop.


Hans Schwaebli wrote:

> What I try to achieve is to generically test whether there is a modal
> dialog in front of the application (for example warning or error dialog).

> Since after some actions I expect either a modal dialog to appear or no
> modal dialog to appear.

> I thought I can do this with display.shells().length, but it is not
> suitable for that purpose.

> Any idea how I can test this generically (independent of shell title etc.)?
Previous Topic:Changes in update site structure
Next Topic:problem with the main SWTBot update site?
Goto Forum:
  


Current Time: Fri Apr 19 20:54:16 GMT 2024

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

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

Back to the top