Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6393333

SWAT FocusEventTest fails in b74

XMLWordPrintable

      Java Version: 1.6.0-beta2-b74
      /net/mizu/usr/re/jdk1.6.0/binaries/linux-i586/latest
      Platforms:
      applebee.sfbay SuSE linux9.3 (x86-64) 2.6.11.4-21.9 default GNU/linux

      Problems:
      The test fails in b74 and it passes in b73, b72 in linux platform,
      it passes in winxppor and solaris10 in b74.

      The execptions as followings:
      java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
      at javasoft.awtsqe.RobotAppletTest.init(Unknown Source)
      at com.sun.javatest.regtest.AppletWrapper$AppletThread.run(AppletWrapper.java:57)
      at java.lang.Thread.run(Thread.java:626)
      Caused by: java.lang.reflect.InvocationTargetException
      at java.awt.EventQueue.invokeAndWait(EventQueue.java:994)
      ... 3 more
      Caused by: java.lang.NullPointerException
      at javax.swing.JPasswordField.customSetUIProperty(JPasswordField.java:337)
      at javax.swing.LookAndFeel.installProperty(LookAndFeel.java:150)
      at javax.swing.plaf.basic.BasicPasswordFieldUI.installDefaults(BasicPasswordFieldUI.java:58)
      at javax.swing.plaf.basic.BasicTextUI.installUI(BasicTextUI.java:686)
      at javax.swing.plaf.basic.BasicTextFieldUI.installUI(BasicTextFieldUI.java:57)
      at sun.awt.X11.XTextFieldPeer$AWTTextFieldUI.installUI(XTextFieldPeer.java:493)
      at javax.swing.JComponent.setUI(JComponent.java:613)
      at sun.awt.X11.XTextFieldPeer$XAWTTextField.updateUI(XTextFieldPeer.java:660)
      at javax.swing.text.JTextComponent.<init>(JTextComponent.java:305)
      at javax.swing.JTextField.<init>(JTextField.java:207)
      at javax.swing.JPasswordField.<init>(JPasswordField.java:116)
      at javax.swing.JPasswordField.<init>(JPasswordField.java:74)
      at sun.awt.X11.XTextFieldPeer$XAWTTextField.<init>(XTextFieldPeer.java:604)
      at sun.awt.X11.XTextFieldPeer.<init>(XTextFieldPeer.java:59)
      at sun.awt.X11.XToolkit.createTextField(XToolkit.java:757)
      at java.awt.TextField.addNotify(TextField.java:205)
      at java.awt.Container.addNotify(Container.java:2500)
      at java.awt.Panel.addNotify(Panel.java:71)
      at java.awt.Container.addNotify(Container.java:2500)
      at java.awt.Window.addNotify(Window.java:528)
      at java.awt.Frame.addNotify(Frame.java:479)
      at java.awt.Window.show(Window.java:711)
      at java.awt.Component.show(Component.java:1406)
      at java.awt.Component.setVisible(Component.java:1359)
      at java.awt.Window.setVisible(Window.java:694)
      at FocusEventGUI.start(FocusEventGUI.java:146)
      at javasoft.awtsqe.RobotAppletTest.useGui(Unknown Source)
      at FocusEventTest.initTestGUI(FocusEventTest.java:56)
      at javasoft.awtsqe.RobotAppletTest$1.run(Unknown Source)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
      STATUS:Failed.Applet thread threw exception: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException


      The test case as following:
      /**
       * test 1.0 2000/09/22
       *
       * @summary Try to traverse focus through focusable
       * & non focusable components in a
       * window and check whether the
       * FocusEvents are triggered properly.
       *
       * 1) Checking whether FocusEvent.FOCUS_GAINED is dispatched
       * to a focus traversable component when the component becomes
       * the Focus Owner
       *
       * 2) Checking whether a non traversable componet can receive
       * FocusEvent.FOCUS_GAINED event. When client code or user try
       * to focus a non focus traversable component,
       *
       * 3) Checking whether FocusEvent.FOCUS_LOST is dispatched to
       * a component when this component is loses a Focus Ownership.
       *
       * 4) Checking whether FocusEvent.FOCUS_LOST is dispatched to
       * When client code or user try to traverse focus from a
       * Focus Owner which is a non focus traversable,
       *
       * @author Pramod(###@###.###) area=AWTFocusManagement
       * @run applet FocusEventTest.html
       */

      import java.awt.*;
      import java.awt.event.*;
      import java.io.*;
      import sun.awt.*;
      import javasoft.awtsqe.*;
      // If you're using the LWComponent classes
      //import javasoft.awtsqe.lw.*;

      // CONFIG: Set the right class name
      // NOTE: All through the template is class names like FocusEventTest,
      // FocusEventGUI and FocusEventStage. It is meant that these
      // names be changed to reflect the nature of the test.
      // For example
      //
      // ButtonPressTest
      // ButtonPressGUI
      // ButtonPressStage
      //
      public class FocusEventTest extends RobotAppletTest {

          public void initMode() {
           setAuto(true); // CONFIG: Run automatically?
           setSingleStep(true); // CONFIG: With single step control?
          }

          public void initTestGUI() {

           // CONFIG: Set here the class name for the GUI
              useGui(new FocusEventGUI());
          }

          public void initWindowInfo() {

              // CONFIG: Set location & size for main window
              Container container = this.getParent();
              setSize(450,600);

              while( !( ( container = container.getParent() ) instanceof Frame ) );

              container.setLocation(340,0);
          }

          public void initInstructions() {
           if (isAuto()) {
                  instructions(new String[] {
                      "This is an AUTOMATIC test simply wait until it is done."
                  });
              }
              else {
                  instructions(new String[] {
      "This is a MANUAL test. You may interact with the GUI freely.",
      "Click on the 'Print' button to turn tracing on and off.",
      "The automatic test may be run by clicking on the 'Run Test' button.",
      "If the 'Single Step' button becomes enabled, the test has paused",
      "giving you a moment to think. Press the 'Single Step' button",
      "when you are ready to proceed.",
      "-------------------------------------------------------------",
      // CONFIG: Specify any instructions to the tester here.
      "Further test instructions are to be put here."
                  });
           }
          }

          FocusEventStage ts;

          public void runTest() {

              // CONFIG: Specify the class name of the test stage.
              // If you wish you can include multiple test stages,
              // and if so just ensure to use waitUntilDone to
              // synchronize with each one.
              ts = new FocusEventStage(this);
              ts.start();
          }

          public void stop() {

              // We wait here in 'stop' to allow the screen to refresh
              // and otherwise act properly. 'runTest' is called
              // from 'start' and, at least under jtreg, the applet
              // does not act properly until start returns.
              ts.waitUntilDone();
              // Technically one could have multiple test stages
              // by implementing something like the following.
              // If done, just make sure that you don't have overlapping
              // stages (more than one running at the same time) which
              // can easily be done by using 'waitUntilDone' to synchronize.
              //
              // FocusEventStage2 ts2 = new FocusEventStage2(this);
              // ts2.start();
              // ts2.waitUntilDone();
          }
      }

      ///////////////////////////////////////////////////////////
      ////////////////// TEST STAGE(S) //////////////////////////
      ///////////////////////////////////////////////////////////

      // This class encapsulates the logic of the test. It is a thread.
      //
      // NOTE: In displaying messages to users, and indicating test status
      // the code should call
      //
      // test.msg - to chatter at the user
      // test.warn - to give a warning to the user
      // test.error - to show an error message to the user
      // test.fail - to indicate the test has failed
      //
      // It is not appropriate to access test.messages directly.
      //
      class FocusEventStage extends TestStage {

          // CONFIG: Reference the GUI class
          FocusEventGUI gui;
          int delay = 500;
          short speed = (short) 50;

          // CONFIG: Insert any other data needed for test coordination
          public FocusEventStage(FocusEventTest test) {
              // CONFIG: Specify the class names properly
              super(test);
              gui = (FocusEventGUI)test.gui;
              // CONFIG: Initialize any other class data
          }

          /**
           * Called from TestStage.run - does the steps of running the test.
           *
           */
          public void doTest() {

              // CONFIG: Put here the code to exercise and verify the GUI.

              // Make fame visible
              // Sets a variable for start testing
              gui.setStartTest(true);

              // Only focus traversable component can receive
              // FocusEvent.FOCUS_GAINED event. When client code or user
              // try to focus a non focus traversable component,
              // this component can not receive FocusEvent.FOCUS_GAINED event

              // Bring mouse pointer on to button
              test.probot.mouseMove( test.probot.targetCenter(gui.button) );

              test.probot.pause(delay);

              // Click mouse on the button
              test.probot.click();

              test.probot.pause(delay * 5);

              if(gui.textfieldFocusLost ) {
                  gui.failMessage("Focus lost event has fired for "
                                  + "text field when click on disabled component ");
              }

              if(gui.buttonFocusGained) {
                  gui.failMessage("Disabled component gained focus "
                                  + gui.button);
              }

              checkFailStream();

              // FocusEvent.FOCUS_GAINED must be dispatched to a
              // focus traversable component when this component
              // becomes the Focus Owner

              // FocusEvent.FOCUS_LOST must be dispatched to a component
              // when this component is no longer a Focus Owner

              gui.setBooleans();

              test.probot.mouseMove( test.probot.targetCenter(gui.textfield) );

              test.probot.pause(delay);

              // Click mouse on the button
              test.probot.click();

              test.probot.pause(delay);

              test.probot.keyPress(KeyEvent.VK_TAB);
              test.probot.pause(keyDelay);
              test.probot.keyRelease(KeyEvent.VK_TAB);

              if(! gui.textareaFocusGained) {
                  synchronized (gui.lock) {
                      try {
                          gui.lock.wait(delay * 10);
                      } catch (Exception e) {
                      }
                  }
              }
              
              if( ! gui.textfieldFocusLost ) {
                  gui.failMessage("When tab is pressed, Focus lost event "
                                  + "didn't fire for " + gui.textfield);
              }

              checkFailStream();


              if(! gui.textareaFocusGained) {
                  gui.failMessage("When tab is pressed, Focus gained event "
                                  + "didn't fire for " + gui.textarea);
              }

              checkFailStream();

              // Sets varibale that testing is over
              gui.setStartTest(false);

              test.probot.pause(delay);

              gui.chatMessage("Test Completed");
          }

          public void checkFailStream(){
              while(!gui.failStream.empty()) {
                  test.fail((String)gui.failStream.pop());
                  // The pop command below is given to remove the message from the
                  // failstream once it's printed, so as to prevent infinite
                  // printing of messages.
                  gui.failStream.pop();
           }
          }//checkFailStream

          // CONFIG: If any inner classes are needed to support running the test,
          // place them here.
      }

            shickeysunw Shannon Hickey (Inactive)
            ttzhang Tao Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: