Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » SWTBot » Problem by tests with Editor
Problem by tests with Editor [message #41443] Thu, 02 July 2009 12:40 Go to next message
Pavel Cybulskij is currently offline Pavel CybulskijFriend
Messages: 21
Registered: July 2009
Junior Member
Hallo Ketan,
I’m trying to get access to a confirmation dialog, that comes after
closing of a dirty(!) editor. (I mean this one: "do you want to save
changes? – Yes/No/Cancel").
If I close the editor manually, then this dialog appears ...
But if I try to close the editor via SWTBot ( myEditor.close() ), then the
editor is closed without to show me the dialog (and it doesn’t save any
changes in editor).
Is it smth. wrong with SWTBot (version .340), or I use this method
incorrect?
How can I get the access to this confirmation dialog?

Thanx in advance!

Pavel. C.
Re: Problem by tests with Editor [message #41487 is a reply to message #41443] Thu, 02 July 2009 14:58 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
There's three methods:
editor.close() -- close without saving
editor.save() -- save
editor.saveAndClose() -- save and close :)

You may ask editor.isDirty() to determine if the editor needs saving.

--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr


On 2/7/09 18:10, Pavel Cybulskij wrote:
> Hallo Ketan,
> I�m trying to get access to a confirmation dialog, that comes after
> closing of a dirty(!) editor. (I mean this one: "do you want to save
> changes? � Yes/No/Cancel").
> If I close the editor manually, then this dialog appears ...
> But if I try to close the editor via SWTBot ( myEditor.close() ), then
> the editor is closed without to show me the dialog (and it doesn�t save
> any changes in editor).
> Is it smth. wrong with SWTBot (version .340), or I use this method
> incorrect? How can I get the access to this confirmation dialog?
>
> Thanx in advance!
>
> Pavel. C.
>
>
Re: Problem by tests with Editor [message #41511 is a reply to message #41443] Thu, 02 July 2009 18:05 Go to previous messageGo to next message
Ketan Patel is currently offline Ketan PatelFriend
Messages: 68
Registered: July 2009
Member
If you want the "do you want to save" dialog, you have to close the editor
using file close menu.

Pavel Cybulskij wrote:

> Hallo Ketan,
> I’m trying to get access to a confirmation dialog, that comes after
> closing of a dirty(!) editor. (I mean this one: "do you want to save
> changes? – Yes/No/Cancel").
> If I close the editor manually, then this dialog appears ...
> But if I try to close the editor via SWTBot ( myEditor.close() ), then the
> editor is closed without to show me the dialog (and it doesn’t save any
> changes in editor).
> Is it smth. wrong with SWTBot (version .340), or I use this method
> incorrect?
> How can I get the access to this confirmation dialog?

> Thanx in advance!

> Pavel. C.
Re: Problem by tests with Editor [message #41538 is a reply to message #41511] Fri, 03 July 2009 09:54 Go to previous messageGo to next message
Pavel Cybulskij is currently offline Pavel CybulskijFriend
Messages: 21
Registered: July 2009
Junior Member
ooooh, it's not so good!
it's not suitable for my case, because i need to close ONLY the dirty
editor (not the whole GUI) and check if the saving/not-saving/canceling
via confirm. menu brings some changes in GUI (whithout to close it) ...
:-(
Re: Problem by tests with Editor [message #41631 is a reply to message #41487] Fri, 03 July 2009 09:56 Go to previous messageGo to next message
Pavel Cybulskij is currently offline Pavel CybulskijFriend
Messages: 21
Registered: July 2009
Junior Member
oh, i know, i know, thank you.
the question was about the access of confirm. manu :-)
Re: Problem by tests with Editor [message #41653 is a reply to message #41631] Fri, 03 July 2009 11:28 Go to previous messageGo to next message
Kay-Uwe Graw is currently offline Kay-Uwe GrawFriend
Messages: 24
Registered: July 2009
Junior Member
If you mean, that you want to close the dialog in your test, you can do
the following

//makes sure that the confirmation dialog is there
bot.shell("Confirmation Dialog Title");


//click ok in the dialog
bot.button("OK").click();
Re: Problem by tests with Editor [message #41683 is a reply to message #41653] Fri, 03 July 2009 14:16 Go to previous messageGo to next message
Pavel Cybulskij is currently offline Pavel CybulskijFriend
Messages: 21
Registered: July 2009
Junior Member
i need to OPEN this dialog first. And it's the main problem! :-(
Re: Problem by tests with Editor [message #41713 is a reply to message #41683] Fri, 03 July 2009 14:48 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 3/7/09 19:46, Pavel Cybulskij wrote:
> i need to OPEN this dialog first. And it's the main problem! :-(

What exactly are you trying to test, that dialog is provided by eclipse
and the save operation is invoked by it based on what you click.

--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr
Re: Problem by tests with Editor [message #41744 is a reply to message #41538] Fri, 03 July 2009 17:27 Go to previous messageGo to next message
Ketan Patel is currently offline Ketan PatelFriend
Messages: 68
Registered: July 2009
Member
In Eclipse, File -> Close (Ctrl+W) will close the active editor. If it is
dirty then it will bring up the dialog to save it. File -> Exit close the
IDE.

Pavel Cybulskij wrote:

> ooooh, it's not so good!
> it's not suitable for my case, because i need to close ONLY the dirty
> editor (not the whole GUI) and check if the saving/not-saving/canceling
> via confirm. menu brings some changes in GUI (whithout to close it) ...
> :-(
Re: Problem by tests with Editor [message #41805 is a reply to message #41713] Mon, 06 July 2009 09:06 Go to previous messageGo to next message
Pavel Cybulskij is currently offline Pavel CybulskijFriend
Messages: 21
Registered: July 2009
Junior Member
Ok. The whole story from A till Z:

- I have in my perspective a view that contains a list of file names;
- a double click on a file name opens the embedded editor with file
content;
- I make some changes in file content and the editor becomes dirty;
- Now I want to close the editor so, that the confirmation menu comes;
- Then I want to click buttons “Yes” or “No” in confirmation menu
(question: "Do you want so save changes?");
- And finally I want to check, if the content of a file was really changed
(or wasn’t changed);

You see, I can’t do the last step if I call the dialog via File/Exit,
because the whole GUI will be closed after clicking on "Yes/No" …
And as I already said, if I try to close only the editor via
editor.close(), I get no confirmation menu ...
That’s it :-)


Ketan Padegaonkar wrote:

> On 3/7/09 19:46, Pavel Cybulskij wrote:
>> i need to OPEN this dialog first. And it's the main problem! :-(

> What exactly are you trying to test, that dialog is provided by eclipse
> and the save operation is invoked by it based on what you click.
Re: Problem by tests with Editor [message #41836 is a reply to message #41805] Mon, 06 July 2009 09:42 Go to previous messageGo to next message
Ketan Padegaonkar is currently offline Ketan PadegaonkarFriend
Messages: 873
Registered: July 2009
Senior Member
On 6/7/09 14:36, Pavel Cybulskij wrote:
> You see, I can�t do the last step if I call the dialog via File/Exit,
> because the whole GUI will be closed after clicking on "Yes/No" �

File>Exit exits eclipse. File>Close, closes the current open file. You
want to File>Close instead of File>Exit.

--
Ketan
http://studios.thoughtworks.com/twist | http://twitter.com/ketanpkr
Re: Problem by tests with Editor [message #41868 is a reply to message #41836] Mon, 06 July 2009 10:55 Go to previous messageGo to next message
Pavel Cybulskij is currently offline Pavel CybulskijFriend
Messages: 21
Registered: July 2009
Junior Member
looking good,
but unfortunatly it is no File/Close in GUI that i test... :-/
OK, i see i have to abdicate this test ...

thanx for the answers anyway ... :-)


Ketan Padegaonkar wrote:

> On 6/7/09 14:36, Pavel Cybulskij wrote:
>> You see, I canï¿œt do the last step if I call the dialog via File/Exit,
>> because the whole GUI will be closed after clicking on "Yes/No" ᅵ

> File>Exit exits eclipse. File>Close, closes the current open file. You
> want to File>Close instead of File>Exit.
Re: Problem by tests with Editor [message #41896 is a reply to message #41805] Mon, 06 July 2009 18:52 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Pavel Cybulskij wrote:
> Ok. The whole story from A till Z:
>
> - I have in my perspective a view that contains a list of file names;
> - a double click on a file name opens the embedded editor with file
> content; - I make some changes in file content and the editor becomes
> dirty;
> - Now I want to close the editor so, that the confirmation menu comes;
> - Then I want to click buttons "Yes" or "No" in confirmation menu
> (question: "Do you want so save changes?");
> - And finally I want to check, if the content of a file was really
> changed (or wasn't changed);
>
> You see, I can't do the last step if I call the dialog via File/Exit,
> because the whole GUI will be closed after clicking on "Yes/No"
> And as I already said, if I try to close only the editor via
> editor.close(), I get no confirmation menu ...
> That's it :-)

I still don't see why you need that dialog.

In the case you want it to close and save (same as clicking yes in the
dialog), call the method editor.saveAndClose().

In the case you don't want it to save your modification (same as
clicking no in the dialog), call the method editor.close().

In the case you don't want it to close (same as clicking cancel in the
dialog), don't call any of the methods.

Then, after each calls, you do whatever check you need to do.

I seem to have the same test case as you: I open an editor, edit the
content, close without saving then check if my modifications were
applied. I never needed that dialog for my test and I don't see why you
would need it...
--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: Problem by tests with Editor [message #41958 is a reply to message #41896] Tue, 07 July 2009 08:37 Go to previous messageGo to next message
Pavel Cybulskij is currently offline Pavel CybulskijFriend
Messages: 21
Registered: July 2009
Junior Member
Pascal Gelinas wrote:

> I never needed that dialog for my test and I don't see why you
> would need it...

... because i don't want to test the methods of SWTBot (e.g.
SaveAndCose() etc.) itself. I want to test my(!) GUI. And this
confirmation dialog is one of it's elements!
That's it! ;-)
Re: Problem by tests with Editor [message #42022 is a reply to message #41958] Tue, 07 July 2009 12:25 Go to previous messageGo to next message
Pascal G is currently offline Pascal GFriend
Messages: 157
Registered: July 2009
Senior Member
Isn't that confirmation dialog supplied by SWT/JFace automatically when
you close an editor? If so, its not your responsibility to test it. I
mean, if you didn't build it, I don't see why you should test it...

The way I see it, that dialog is part of the application's GUI, but it
is not part of the codebase of the application. Your tests should only
target the codebase of your application. My guess is that you don't test
SWT component such as how an image is painted (for example), so why
would you test a dialog that is part of SWT/JFace codebase?

Pavel Cybulskij wrote:
> .. because i don't want to test the methods of SWTBot (e.g.
> SaveAndCose() etc.) itself. I want to test my(!) GUI.

I don't see why calling those method makes you test them... those method
emulates (more or less) the confirmation dialog, just as every other
method in SWTBot, such as click() or select(), emulates UI interaction.

--
Pascal Gélinas | Software Developer
*Nu Echo Inc.*
http://www.nuecho.com/ | http://blog.nuecho.com/

*Because performance matters.*
Re: Problem by tests with Editor [message #496648 is a reply to message #41868] Tue, 10 November 2009 19:12 Go to previous message
Wade Walker is currently offline Wade WalkerFriend
Messages: 4
Registered: July 2009
Junior Member
Hi Pavel,

I wrote some code to do exactly what you asked for. You can see it here http://www.eclipse.org/forums/index.php?t=msg&th=157288& amp;start=0&S=569ed9ea1c67f379bbb20f9c81de9fe3 in a forum post, or here https://bugs.eclipse.org/bugs/show_bug.cgi?id=294781 in a request for SWTBot enhancement that I submitted.

This code is tested and works for me -- I successfully test the "Save Resource" confirmation dialog that pops up when you try to close a dirty editor.
Previous Topic:Closing CTabs
Next Topic:How to test chart with SWTBot
Goto Forum:
  


Current Time: Thu Mar 28 12:35:04 GMT 2024

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

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

Back to the top