Help please: testing modal dialog

Help
whoknew99
2006-10-18
2013-05-20
  • whoknew99
    whoknew99
    2006-10-18

    I am sure this has been answered before so I apologize in advance.  BTW I did look at the FAQ and searched this forum FWIW.

    I am trying to write code using Abbot to test my GUI's modal logon screen (fixture/Foo).  Although I am creating and showing my modal dialog in a separate thread, I always get this in my test after calling JButtonTester.actionClick (I never get to 'Made it here'):
    abbot.tester.ActionFailedException: Could not make visible by scrolling the point (52,12) on javax.swing.JButton[signOnButton,240,15,105x25,invalid,layout=javax.swing.OverlayLayout,alignmentX=0.0,alignmentY=0.5,border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@45378f,flags=296,maximumSize=,minimumSize=,preferredSize=,defaultIcon=,disabledIcon=,disabledSelectedIcon=,margin=javax.swing.plaf.InsetsUIResource[top=2,left=14,bottom=2,right=14],paintBorder=true,paintFocus=true,pressedIcon=,rolloverEnabled=false,rolloverIcon=,rolloverSelectedIcon=,selectedIcon=,text=Sign On,defaultCapable=true]

    I am pretty sure that this means the dialog is not visible.  However I am confused as I am calling setVisible(true) on it.

    So what is going on?

    Thanks in advance,

    Larry

    **********************************

    public class FooTest extends ComponentTestFixture {

            ...
           
        protected void setUp() throws Exception {
            super.setUp();
                    fixture = new Foo("Test");
        }
       
        protected void tearDown() throws Exception {
            fixture.dispose();
            fixture = null;
                    super.tearDown();
        }
       
        public void testUserAndPasswordEmpty() {

            Runnable r = new Runnable() {
                public void run() {
                    //fixture.setVisible(true);
                    showWindow(fixture);
                }
            };
            Thread t = new Thread(r);
           
                JButton signOnButton = null;
                try {
                    signOnButton = (JButton) getFinder().find(new NameMatcher(Foo.SIGNON_BTN_NAME));
                } catch (MultipleComponentsFoundException mcfe) {
                    Assert.fail("caught exception: " + mcfe.getClass().getName() + ". message:" + mcfe.getMessage());
                } catch (ComponentNotFoundException cnfe) {
                    Assert.fail("caught exception: " + cnfe.getClass().getName() + ". message:" + cnfe.getMessage());
                }

                JButtonTester signOnTester = new JButtonTester();
                signOnTester.actionClick(signOnButton);
                System.out.println("Made it");
               
        }
    }

     
    • whoknew99
      whoknew99
      2006-10-19

      I have everything working now so please don't spend any time on this.  Thanks!

       
      • A. E. Walker
        A. E. Walker
        2007-11-01

        How did you resolve this issue?

         
    • Mary-Anne Wolf
      Mary-Anne Wolf
      2009-01-30

      I can only guess, but when I am testing a dialog,
      I find that it may not be visible immediately after I call setVisible,
      so I need to loop until JDialog.isVisible is true,
      and only treat the JDialog as visible after that loop finishes.

      Mary-Anne