Editor input and shell conditions

WindowTester allows you to easily create and run unit tests for every GUI they build. It can also be used to generate system level tests.

Moderators: gnebling, Eric Clayberg, Dan Rubel, keertip, Phil Quitslund

Editor input and shell conditions

Postby mwa » Fri Jul 04, 2008 2:52 am

Hello,

i have written the following test:
Code: Select all
      IEditorInput eiOne = getPage().getEditor().getEditorInput();
      ui.enterText("foobar");
      ui.keyClick(WT.ARROW_DOWN);
      //      ui.wait(new ICondition)
      IEditorInput eiTwo = getPage().getEditor().getEditorInput();
      assertFalse(eiOne.equals(eiTwo));

getPage() is synchronised and gets current workbench page:
Code: Select all
IWorkbenchWindow wbWindow = wb.getActiveWorkbenchWindow();
page[0] = wbWindow.getActivePage();

If i print out the editor content, i see, that it is the right editor. Why the assert fails?
Only if I do a save before:
Code: Select all
ui.click(new MenuItemLocator("File/Save All"));

The assert is true, meaning the two editor contents are not the same any more. Is that a bug of the editor? Or is there perhaps a shell condition with which I can wait for the input?

A general questioin about shell conditions I have is: How do I now what text is on the shell? For example I have:
Code: Select all
      ui.keyClick(SWT.CTRL, 'F');
      ui.wait(new ShellShowingCondition("Find and Replace"));

How can I now here that the Text is "Find and Replace"? I cannot see the shell wich is displaying that.

Michael
mwa
 
Posts: 24
Joined: Mon Jun 16, 2008 4:38 am

Re: Editor input and shell conditions

Postby mwa » Fri Jul 04, 2008 3:16 am

Ok. Now I understand: the eclipse api is like that.
An IEditorPart has a corresponding IEditorInput which corresponds to the actual saved input. The user input that is not saved already of course is not IN THE FILE. So the editor is dirty, waiting for saving. When doSave is called, the content of the "model" is put into the file. So there is no way to get the content, if the editor does not have implemented a method for this purpose. It is a commercial editor I use here. So I have no chance to implement such a thing.
Am I right? Or is there something I have overlooked?

The shell condition question remains. :|
mwa
 
Posts: 24
Joined: Mon Jun 16, 2008 4:38 am

Re: Editor input and shell conditions

Postby Phil Quitslund » Mon Jul 07, 2008 8:45 am

Hi Michael,

I'm not sure I understand the question(s) so I'll take a stab and please fire back.

(1) Shell Condtions

The text in shell conditions is the Title of the Shell. In the case of "Find and Replace" the condition matches a Shell whose title bar reads "Find and Replace".

(2) Asserting text editor contents.

Rather than getting the text from the editor input, perhaps it would be best to interact with the editor's SWT control (likely a StyledText) --- that way you don't need to worry about whether the editor is dirty. Before I go down this road though, perhaps you can confirm that this is what you want to achieve. Are you wanting to assert that the contents of an editor are an expected String?

Let me know what I've missed and I can elaborate...
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am

Re: Editor input and shell conditions

Postby mwa » Fri Jul 11, 2008 7:14 am

Hi Phil,

thanks for the answer. You are right in both cases. In the meantime I have contacted the plugin provider and they send me an api documentation so I can get the editor contents now.
I now understand the Shell Conditions, two. I misunderstood this because of the name shell:-)

Michael
mwa
 
Posts: 24
Joined: Mon Jun 16, 2008 4:38 am

Re: Editor input and shell conditions

Postby Phil Quitslund » Fri Jul 11, 2008 8:20 am

Good deal.

Thanks for sharing your progress. Good luck and keep it coming!

-phil
--
Phil Quitslund
Software Engineer
Google, Inc.
Phil Quitslund
Moderator
 
Posts: 491
Joined: Fri Apr 28, 2006 6:26 am


Return to Window Tester

Who is online

Users browsing this forum: No registered users and 1 guest