TabbedPropertyList$ListElement is Broken

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

TabbedPropertyList$ListElement is Broken

Postby win » Tue May 12, 2009 7:35 am

Hi ,
When I am recording a test that uses a TabbedPropertyList I get an syntax error messgae in the generated code
for the following :

import org.eclipse.ui.internal.views.properties.tabbed.view.TabbedPropertyList$ListElement;

ui.click(new XYLocator(new SWTWidgetLocator(
TabbedPropertyList$ListElement.class, new ViewLocator(
"org.eclipse.ui.views.PropertySheet")), 61, 6));
ui.click(new XYLocator(new LabeledLocator(CLabel.class, "Return type:",
new ViewLocator("org.eclipse.ui.views.PropertySheet")), 21, 6));
ui.wait(new ShellShowingCondition("Select Type"));
ui.click(new TableItemLocator("string"));
ui.click(new ButtonLocator("OK"));

Is the TabbedPropertyList Fixed , I need it to work on both linux and Windows ????


If not please suggest a workaround .

Thanks
win
 
Posts: 7
Joined: Mon May 11, 2009 4:14 am

Re: TabbedPropertyList$ListElement is Broken

Postby Phil Quitslund » Tue May 12, 2009 2:22 pm

We're working on support for TabbedPropertyList items.

In the meantime, perhaps these notes will help?:

viewtopic.php?f=5&t=2451

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

Re: TabbedPropertyList$ListElement is Broken

Postby win » Wed May 13, 2009 7:40 am

Hi Phil,
I want to be able to run the generated tests on Linux/Windows this will not be possible if using the XYLocator().

Also With regard to the TPB_UNDER_PROPERTIES workaround
Are you suggesting instead of the XYLocator use the TPB_UNDER_PROPERTIES within the CTabItemLocator
ui.click(new CTabItemLocator(TPB_UNDER_PROPERTIES[1]));

Can you give an example .
win
 
Posts: 7
Joined: Mon May 11, 2009 4:14 am

Re: TabbedPropertyList$ListElement is Broken

Postby 3061 » Thu May 14, 2009 12:57 am

win wrote:Hi Phil,
I want to be able to run the generated tests on Linux/Windows this will not be possible if using the XYLocator().

Also With regard to the TPB_UNDER_PROPERTIES workaround
Are you suggesting instead of the XYLocator use the TPB_UNDER_PROPERTIES within the CTabItemLocator
ui.click(new CTabItemLocator(TPB_UNDER_PROPERTIES[1]));

Can you give an example .


Hey there, I'm the one who came up with the workaround. Here's how it works:

I got a public Class with the lables put into a String array in the same order as they are in the property sheet.

Code: Select all
public class PropertySheetLabels
{
   public static final String T_TAB_PROPERTIES = "Properties";

   // tabbed properties button labels. Those are on the left on the Properties Sheet

   public static final String B_TPB_GENERAL = "General"; // topmost button
   public static final String B_TPB_DESCRIPTION = "Description";
   public static final String B_TPB_DETAILS = "Details"; // bottommost button

   /**
    * String array containing the Labels of all the tabbed properties buttons
    * under the Properties View
    */
   public static final String[] TPB_UNDER_PROPERTIES = new String[] { B_TPB_GENERAL, B_TPB_DESCRIPTION, B_TPB_DETAILS};
}


Then, I made a method for clicking on a given button. You can copy that and the snippet below it (setFocusOnView) and try it out. It's crude, but works well. The offsets and button height are wor Windows (XP with the oldschool gray theme), you might need to adapt those if you're running on a different OS or theme.

Code: Select all
   /**
    * Attempts to click the given button in the Properties View. A click on the
    * "Properties" Tab is executed here, then the coordinates of the desired
    * button a calculated and the button is clicked.
    *
    * This is a workaround because there's no WindowTester Locator for the
    * vertical sub-tabs like General, Description, Details, etc...
    * Those sub-tabs are not declared in source code, but in the properties of
    * an Eclipse application...
    *
    * TODO Find a better way to do this so it doesn't break if buttons are
    * resized
    *
    * @see http://www.eclipse.org/articles/Article-Tabbed-Properties/tabbed_properties_view.html
    *
    * @param buttonName
    *            examples: "General", "Description", "Details"
    */
   protected void clickOnButtonInPropertiesView(String buttonName) throws Exception
   {
      IWidgetLocator propertiesTab = new CTabItemLocator(PropertySheetLabels.T_TAB_PROPERTIES);

      // click on Properties Tab
      setFocusOnView(propertiesTab);

      /*
       * offset coordinates of the topmost tabbed property button (relative to
       * the top left corner of the Properties View)
       */
      int xOffset = 45;
      int yOffset = 45;
      int buttonHeight = 20; // one button is 20 pixels high
      boolean givenButtonNameIsValid = false;

      // check if the given buttonName is valid
      int lastButtonIndex = PropertySheetLabels.TPB_UNDER_PROPERTIES.length;
      for (int i = 0; i < lastButtonIndex; i++)
      {
         if (PropertySheetLabels.TPB_UNDER_PROPERTIES[i].equals(buttonName))
         {
            yOffset += buttonHeight * i; // the new relative y coordinate
            givenButtonNameIsValid = true;
            break;
         }
      }



Code: Select all
   /**
    * Activates (i.e. clicks on the tab of) the given View
    *
    * @param tabNameAsIWidgetLocator
    * @throws Exception
    */
   protected void setFocusOnView(IWidgetLocator tabNameAsIWidgetLocator) throws Exception
   {
      // TODO Add try catch around ui.click?
      ui.click(tabNameAsIWidgetLocator);
      System.out.println("Clicked on the tab named " + tabNameAsIWidgetLocator);
      waitForJobsComplete();
   }
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: TabbedPropertyList$ListElement is Broken

Postby Phil Quitslund » Thu May 14, 2009 11:03 am

I've created an incubator project and have committed some first cuts exploring locators for property tab items. There's still work to be done, but it's a start... Any additions greatly appreciated!

The test that drives this provisional functionality can be browsed here:

http://code.google.com/p/wt-commons/sou ... gTest.java

If you really want to play with this, you'll want to grab the whole project from subversion. SVN access is described here:

http://code.google.com/p/wt-commons/source/checkout

Thanks!

-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