Expand Tree Items

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

Expand Tree Items

Postby Steffen8708 » Tue Nov 04, 2008 7:22 am

Hi,

I'm trying to play a bit with window tester for testing an eclipse application. It is possible to locate tree items, but as far as I tried out, this is impossible if items are lazyly creating in JFace viewers. I think when I look for an item with path "foo/bar" then window tester automatically should expand item "foo" to get "bar" visible (if "foo" and "bar" exist). Is there any possibility to let window tester expand items?

Greetings,
Steffen
Steffen8708
 
Posts: 29
Joined: Tue Nov 04, 2008 7:11 am

Re: Expand Tree Items

Postby Phil Quitslund » Mon Nov 10, 2008 8:25 am

Hi Steffen,

The find(..) method does not do expanding. However the click(..) does. In other words, if you want to access a hidden tree item you should prefer a click(..). If you simply want to expand a node, you might also select the parent and emit the appropriate keystroke (not terribly elegant but should work). For instance:

Code: Select all
ui.click(new TreeItemLocator("my/parent"));
ui.keyClick(WT.ARROW_RIGHT);


If expand is a feature you would like to see implemented, please let us know and we will add it to our feature requests.

Thanks for the inquiry!


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

Re: Expand Tree Items

Postby Steffen8708 » Tue Nov 11, 2008 4:48 am

Hi Phil,

at the moment i emulate expanding by a click on the cross of a tree item. It works but this is likely not independent from OS or the widget tool kit and not elegant, too. Surely, the key pressing method will work, but i would like to avoid selecting a tree item because i just want to test if a specific tree item exists (or not exists). A selection of that item maybe causes side effects by selection listeners. How does your ui.click(...) method do the expanding? By using the arrow key?

> If expand is a feature you would like to see implemented, please let us know and we will add it to our feature requests.

Yes, that would be great.

Thanks for answering,
Steffen
Steffen8708
 
Posts: 29
Joined: Tue Nov 04, 2008 7:11 am

Re: Expand Tree Items

Postby Phil Quitslund » Tue Nov 11, 2008 12:48 pm

Great. Thanks for the feedback. Could you send a ticket in to support so that it gets queued in our issue management system?:

wintest-support@instantiations.com

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

Re: Expand Tree Items

Postby Steffen8708 » Thu Nov 13, 2008 6:00 am

Ok, I can do it. What information should the eMail contain? Feature request and description of problem?

Steffen
Steffen8708
 
Posts: 29
Joined: Tue Nov 04, 2008 7:11 am

Re: Expand Tree Items

Postby mwa » Thu Nov 13, 2008 7:24 am

Hi,

perhaps my helper pieces of code are interesting in this context, too. Would be nice if you have some improvements for me. You can use regular expressions to find TreeItems:
Code: Select all
public static void expandProblemTree(final IUIContext ui)
       throws WidgetSearchException {
   IWidgetReference errorNode = (IWidgetReference) ui.find(treeItem(
      "Errors\\s?\\((\\w|\\d|\\s)*\\)").in(view("Problems")));
   TreeItem errorItem = (TreeItem) errorNode.getWidget();
   if (!isExpanded(errorItem)) {
       expand(errorNode, ui);
   }
}


Code: Select all
public static void expand(final IWidgetReference errorNode,
       final IUIContext ui) throws WidgetSearchException {

   ui.click(errorNode);
   ui.keyClick(SWT.ARROW_RIGHT);
   ui.wait(new ICondition() {
       public boolean test() {
         return isExpanded((TreeItem) errorNode.getWidget());
       }
   });
}


Code: Select all
public static boolean isExpanded(final TreeItem item) {
   final boolean[] expanded = new boolean[1];
   Display.getDefault().syncExec(new Runnable() {
       public void run() {
         expanded[0] = item.getExpanded();
       }
   });
   return expanded[0];
}


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

Re: Expand Tree Items

Postby Phil Quitslund » Thu Nov 13, 2008 9:53 pm

Steffen8708 wrote:Ok, I can do it. What information should the eMail contain? Feature request and description of problem?

Steffen



Both would be great; a pointer to this forum thread would work too.

Thanks!
--
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