From: Chen, M. <Min...@bm...> - 2006-08-29 16:46:34
|
How about ABBOT.SWT? It is also there? -min -----Original Message----- From: Timothy Wall [mailto:tw...@us...]=20 Sent: Tuesday, August 29, 2006 7:44 AM To: Scott Symmank Cc: Chen, Min; abb...@li... Subject: Re: [abbot-users] How to click an out-of-view TableItem or TreeItem using abbot.swt The core AWT tester implementation for JComponent (and derived =20 classes) overrides a low-level method (click or mouseMove) to ensure =20 that the scrollable component has the active area visible before =20 performing the action. On Aug 25, 2006, at 6:13 PM, Scott Symmank wrote: > TreeItemTester.showItem(TreeItem) might help. > > > Or, if you *have* to actually scroll by clicking the > scroll, you might try something like this ( > i don't think it back into abbot.swt yet): > > import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.ScrollBar; > import org.eclipse.swt.widgets.Scrollable; > import org.eclipse.swt.widgets.Widget; > > import abbot.Log; > import abbot.Platform; > import abbot.tester.swt.Robot; > import abbot.tester.swt.RunnableWithResult; > import abbot.tester.swt.ScrollBarTester; > import abbot.tester.swt.ScrollableTester; > > /** @todo: write tests for below methods for > ScrollBar, > * add to SWTWorkarounds and ScrollBarTester > */ > public class ScrollBarTesterPatch extends > ScrollBarTester { > > public static int DEFAULT_DELAY =3D 200; > > /** > * Scroll the given amount, where amount=3D=3Dthe > number of > * times the arrow is pressed. > * > * Positive amounts scroll down for vertical > scrollbars, > * horizontal ones. > * > * 1. Assuming the arrow is a square. > * 2. HORIZONTAL ScrollBars have a width of size.y > * 3. VERTICAL ScrollBars have a width of size.x > */ > @Override > public void actionScroll(final ScrollBar bar, > final int amount){ > Log.debug("actionScroll("+amount+")"); > actionFocus(bar); > Point barSize =3D getSize(bar); > Log.debug("ScrollBarSize=3D"+barSize); > Rectangle barBounds =3D getBounds(bar); > int arrowWidth =3D barSize.x; > if (isHorizontal(bar)) { > arrowWidth =3D barSize.y; > } > Log.debug("ScrollBarArrowSize=3D"+arrowWidth); > if(amount<0){ > Point p =3D new Point( > > barBounds.x+arrowWidth/2, > > barBounds.y+arrowWidth/2 > ); > mouseMove(p.x,p.y); > for(int i=3Damount; i<=3D0; i++){ > Log.debug("ScrollBarArrowClick=3D - "+p); > mousePress(SWT.BUTTON1); > mouseRelease(SWT.BUTTON1); > Robot.delay(DEFAULT_DELAY); > } > } > else if(amount>0){ > Point p =3D new Point( > > barBounds.x+barBounds.width - arrowWidth/2, > > barBounds.y+barBounds.height - arrowWidth/2 > ); > mouseMove(p.x,p.y); > for(int i=3D0; i<amount;i++){ > Log.debug("ScrollBarArrowClick=3D + "+p); > mousePress(SWT.BUTTON1); > mouseRelease(SWT.BUTTON1); > } > } > actionWaitForIdle(bar.getDisplay()); > } > > public Rectangle getBounds(final ScrollBar > scrollBar) { > Log.debug("ScrollBarTester.getBounds()"); > final Scrollable parent =3D > getParent(scrollBar); > final Rectangle relativeBounds =3D > getRelativeBounds(scrollBar); > final Display display =3D > scrollBar.getDisplay(); > Rectangle result =3D (Rectangle) > Robot.syncExec(display, new RunnableWithResult() { > @Override > public Object runWithResult() { > return display.map (parent, null, > relativeBounds); > } > }); > Log.debug("ScrollBarBounds=3D"+result); > return result; > } > > public Rectangle getRelativeBounds (ScrollBar > scrollBar) { > Log.debug("ScrollBarTester.getRelativeBounds()"); > Point size =3D getSize(scrollBar); > Log.debug("ScrollBarSize=3D"+size); > Scrollable parent =3D getParent(scrollBar); > ScrollableTester scrollableTester =3D new > ScrollableTester(); > Rectangle bounds =3D > scrollableTester.getBounds(parent); > Log.debug("ScrollableRelativeBounds=3D"+bounds); > if (isLeftToRight(parent)) { > Log.debug("LEFT_TO_RIGHT"); > //SWT.LEFT_TO_RIGHT > if (isHorizontal(scrollBar)) { > Log.debug("HORIZONTAL"); > //SWT.HORIZONTAL > bounds.x =3D 0; > bounds.y =3D bounds.height - size.y; > } else { > Log.debug("VERTICAL"); > //SWT.VERTICAL > bounds.x =3D bounds.width - size.x; > //bounds.y =3D bounds.y; > } > } else { > Log.debug("RIGHT_TO_LEFT"); > //SWT.RIGHT_TO_LEFT > if (isHorizontal(scrollBar)) { > Log.debug("HORIZONTAL"); > //SWT.HORIZONTAL > bounds.x =3D bounds.width - size.x; > bounds.y =3D 0; > } else { > Log.debug("VERTICAL"); > //SWT.VERTICAL > bounds.x =3D 0; > bounds.y =3D bounds.height - size.y; > } > } > bounds.width =3D size.x; > bounds.height =3D size.y; > Log.debug("ScrollBarRelativeBounds=3D"+bounds); > return bounds; > } > > @Override > /** CR271861 ScrollBar.getSize() seems to return the > * size of the thumb on linux, not the size > * of the whole bar. So, get the size from > * the parent Scrollable. > */ > public Point getSize(final ScrollBar s) { > Point size =3D null; > if (Platform.isLinux()) { > size =3D super.getSize(s); > Scrollable parent =3D getParent(s); > Point scrollableSize =3D > TesterFactory.newScrollableTester().getSize(parent); > size.y =3D scrollableSize.y; > } else { > size =3D super.getSize(s); > } > =09 > return size; > } > > /** > * This method will return true if ScrollBar has > the horizontal style bit set. > * > * SWT.HORIZONTAL > * > */ > public boolean isHorizontal(final ScrollBar s) { > return (getStyle(s) & SWT.HORIZONTAL) !=3D 0; > } > > /** > * This method will return true if ScrollBar has > the vertical style bit set. > * > * SWT.VERTICAL > * > */ > public boolean isVertical(final ScrollBar s) { > return (getStyle(s) & SWT.VERTICAL) !=3D 0; > } > > public boolean isLeftToRight(final Widget w) { > return (getStyle(w) & SWT.LEFT_TO_RIGHT) !=3D 0; > } > > public boolean isRightToLeft(final Widget w) { > return (getStyle(w) & SWT.RIGHT_TO_LEFT) !=3D 0; > } > > } > > --- "Chen, Min" <Min...@bm...> wrote: > >> Hi there, >> >> >> >> I have been using abbot.swt to automate >> our Eclipse (SWT) >> based application, but ran into a problem in >> clicking a TableItem (or >> TreeItem) which is currently out-of-view and needs >> to use ScrollBar to >> bring it into view. I noticed that >> TableItemTester.actionClick does not >> know where to click in this case. I also tried >> TableItemTester.actionFocus to see if it can bring >> that item into view, >> but no avail. Really appreciate that some experts >> out there can help me >> on this. Thanks a lot! >> >> >> >> -min >> >>> > ---------------------------------------------------------------------- > --- >> Using Tomcat but need to do more? Need to support >> web services, security? >> Get stuff done quickly with pre-integrated >> technology to make your job easier >> Download IBM WebSphere Application Server v.1.0.1 >> based on Apache Geronimo >> > http://sel.as-us.falkag.net/sel?=20 > cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D121642> > _______________________________________________ >> abbot-users mailing list >> abb...@li... >> > https://lists.sourceforge.net/lists/listinfo/abbot-users >> > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com > > ---------------------------------------------------------------------- > --- > Using Tomcat but need to do more? Need to support web services, =20 > security? > Get stuff done quickly with pre-integrated technology to make your =20 > job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache =20 > Geronimo > http://sel.as-us.falkag.net/sel?=20 > cmd=3Dlnk&kid=3D120709&bid=3D263057&dat=3D121642 > _______________________________________________ > abbot-users mailing list > abb...@li... > https://lists.sourceforge.net/lists/listinfo/abbot-users > Timothy Wall http://abbot.sf.net |