No Locator for GEF PolylineConnection?

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

No Locator for GEF PolylineConnection?

Postby 3061 » Wed Mar 04, 2009 3:06 am

I'm lookiong for a way to locate a custom PolylineConnection that has a text label on it. The Application I'm doing the test for draws UML Class diagrams using GEF and locating the Classes and Diagrams works as expected using:
Code: Select all
ui.click(new ByTextFigureLocator("TestClass1"));


However I can't find a way to locate a PolylineConnection (example: <<implements>> arrow) connecting two Figures (example: Class and Interface).
Image
Image

When using the recorder and click on the Interface, then Class and then on the arrow connecting them, I get something like this:

Code: Select all
   IUIContext ui = getUI();
   ui.click(new NamedEditPartFigureLocator("TestInterface"));
   ui.click(new NamedEditPartFigureLocator("TestClass1"));
   ui.click(new LRLocator(5, new LabelLocator()));
   ui.click(new LRLocator(1, new ClassDependencyConnectionFigureLocator()));
   ui.click(new LRLocator(1, new PolygonDecorationLocator()));


It's a bit different every time when recording, and when playing it black, it actually does not click on the Polyline at all.

ClassDependencyConnectionFigure extends PolylineConnection and basically just adds the arrowhead and label to the connection:

Code: Select all
public class ClassDependencyConnectionFigure extends PolylineConnection implements PresentationFigure
{
        //[...]

   protected void createStereotypes()
   {
      if (stereotypes == null)
      {
         stereotypes = new Label();
         stereotypes.setText("«implements»");
         stereotypes.setOpaque(true);
      }
      if (!stereotypeAdded)
      {
         add(stereotypes, new ConnectionLocator(this, ConnectionLocator.MIDDLE));
         stereotypeAdded = true;
      }
   }


   protected void removeStereotypes()
   {
      if (stereotypes != null)
      {
         remove(stereotypes);
         stereotypeAdded = false;
      }
   }


   protected void updateStereotypes()
   {
      createStereotypes();
      if (!showLinkStereotype(link))
      {
         removeStereotypes();
      }
   }

       //[...]

}



I'd love to be able to locate the <<implements>>arrow between the Interface and Class with something like

Code: Select all
ui.click(new LabeledLocator(ClassDependencyConnectionFigure.class, "«implements»", myTestInterface, myTestClass));


Is there a way to teach WindowTester new Locators? It's frustrating having a labeled thing in GEF and no way to locate it with WindowTester.
I appreciate any help, even if it's "you can't locate Polylines right now, sorry."
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: No Locator for GEF PolylineConnection?

Postby Phil Quitslund » Wed Mar 04, 2009 11:40 am

Have you looked at naming as a way to solve this problem? The recorder is savvy to named figures or edit parts. The locators that get generated if you use naming are these, for named figures and edit parts respectively:

http://downloads.instantiations.com/WindowTesterDoc/integration/latest/docs/html/reference/javadoc/com/windowtester/runtime/gef/locator/NamedFigureLocator.html

http://downloads.instantiations.com/WindowTesterDoc/integration/latest/docs/html/reference/javadoc/com/windowtester/runtime/gef/locator/NamedEditPartFigureLocator.html

Let us know if this will work for you.

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

Re: No Locator for GEF PolylineConnection?

Postby 3061 » Thu Mar 05, 2009 12:12 am

Problem is, the Polyline are not Figures it seems. Also in a Diagram, you can identify classes by name because, at least in my case, duplicate names are not allowed. However there are lots of arrows named "<<implements>>". I'll play around with naming some more, I'm not sure how exactly I can name those Polyline thingies.
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: No Locator for GEF PolylineConnection?

Postby Phil Quitslund » Fri Mar 06, 2009 10:18 am

Let us know where you get and we can do some poking around on our end.

Is there anything in the Eclipse GEF samples we can use to cook up a testcase that we can share between us?

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

Re: No Locator for GEF PolylineConnection?

Postby 3061 » Mon Mar 09, 2009 12:08 am

I'm still looking into naming those things, I have access to the source code and may get permission to mess around in it. I'll let you know how it goes.
I'll look into the GEF samples also. Basically, when the recorder is running and I click on a Polyline, it records coordinates of it only.
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: No Locator for GEF PolylineConnection?

Postby Phil Quitslund » Mon Mar 09, 2009 8:02 am

Good deal. Let us know how it goes and we'll be happy to help.

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

Re: No Locator for GEF PolylineConnection?

Postby 3061 » Tue Mar 10, 2009 5:17 am

Naming the bastard did the trick! 8)

My custom class ClassDependencyConnectionFigure extends PolylineConnection which extends <insert some draw2D objects in here> Figure.
I added the getFigureId()-Method as advised which returns a unique Name for than Connection like: UmlClassDependencyArrow_from_MyClass_to_MyInterface

When I click on that arrow, the recorder still outputs
Code: Select all
ui.click(new LRLocator(8, new LabelLocator()));
ui.click(new FigureCanvasXYLocator(239, 303));

but when I manually enter
Code: Select all
ui.click(new NamedFigureLocator("UmlClassDependencyArrow_from_MyClass_to_MyInterface"));

it successfully clicks on the center of the correct arrow and rightfully fails when the name is not right.


I can imagine the recorder would ouptut the NamedFigureLocator if I click the exact center of the arrow...

Anyway, Problem solved.
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: No Locator for GEF PolylineConnection?

Postby 3061 » Wed Mar 11, 2009 7:39 am

Next Problem...

So making the GUI Test select the Implementation arrows works well.

But Inheritance arrows are troublesome, the NamedFigureLocator does not put the mouse cursor on the dead center of the Polyline, it's usually off by a few pixels.
Interestingly, it's always dead on the PolyLine and the arrow gets selected (highlighted) upon ui.click(new NamedFigureLocator(uniqueNameOfArrow)); when it's vertical, horizontal, or at a 45° angle to the coordinate system. When the angle is slightly different, it still select the arrow althought the mouse cursor is off by a pixel. But at other angles, the cursor is off by a few pixels, enough to "miss" the arrow. See attached picture.

The mouse cursor is farthest away from the arrow, when the angle (relative to the horizontal) is 22.5°, 67.5°, 112.5°, 157.5° 202.5°, 247.5° 292.5° and 337.5°. That's always between the 45° diagonal and the horizontal/vertical.


It didn't matter on the "Implementation" arrows, because those had a rather large label in the middle, so the off-center locater was still on the label. How exactly does the NamedFigureLocator locate the center of a Figure and move the mouse cursor there? I have a feeling the decorator of the Polyline (the triangle-shaped arrowhead) is the problem.

Note that the ui.click(new NamedFigureLocator(connectionId)); does not fail when the cursor is too far from the arrow to select it.
Attachments
FigureLocator hit and miss.PNG
FigureLocator hit and miss.PNG (37.09 KiB) Viewed 1332 times
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: No Locator for GEF PolylineConnection?

Postby 3061 » Wed Mar 11, 2009 8:56 am

Here's where the moise pointer is when doing
Code: Select all
ui.click(new ByTextFigureLocator(figureName));


Coudn't take screenshots that included the mouse pointer, so I took a picture with an actual camera. First, I though Gef has some kind of bounding box (marked red) and the center of the figure is computed using that box as a reference... the blue line is just extending the line from the bottom figure to the moise pointer.

Thought this might help figuring out the problem. The mouse pointer position isn't random by the way, there seems to be a method behind it.
Attachments
IMG_1377 edit copy.jpg
IMG_1377 edit copy.jpg (59.45 KiB) Viewed 1329 times
IMG_1374 edit copy.jpg
IMG_1374 edit copy.jpg (86.59 KiB) Viewed 1328 times
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: No Locator for GEF PolylineConnection?

Postby Phil Quitslund » Fri Mar 13, 2009 9:36 am

Wow, great report! Have you sent a pointer to support?

wintest-support@instantiations.com

Having a ticket open in our bug tracking system will help us better track the fix.

Thanks for the thoughtful follow-up!


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

Re: No Locator for GEF PolylineConnection?

Postby 3061 » Mon Mar 16, 2009 2:16 am

Phil Quitslund wrote:Wow, great report! Have you sent a pointer to support?

wintest-support@instantiations.com

Having a ticket open in our bug tracking system will help us better track the fix.

Thanks for the thoughtful follow-up!


-phil


Just sent the mail to support. I just like posting issues in the forum too; This way, other users who found a similar issue can see they're not alone with their problems.
Right now I'm working around the problem by overriding the decoration size with a 1 by 1 pixel decoration. Now you can't tell apart a line from an arrow, but the test works and knows what is what by the Figure names. :wink:

Thanks for the fast responses by the way.
3061
 
Posts: 42
Joined: Mon Feb 23, 2009 12:43 am

Re: No Locator for GEF PolylineConnection?

Postby Phil Quitslund » Mon Mar 16, 2009 10:54 am

Thanks again for this thoughtful thread. We've got your ticket in our support queue and as soon as we ship 3.8 for EclipseCon we'll dig in. Stay tuned... and 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