< prev index next >

test/javax/swing/plaf/basic/BasicComboPopup/8154069/Bug8154069.java

Print this page


   1 /*
   2  * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test

  26  * @bug 8154069
  27  * @summary Jaws reads wrong values from comboboxes when no element is selected
  28  * @run main Bug8154069
  29  */
  30 
  31 import javax.accessibility.Accessible;
  32 import javax.accessibility.AccessibleContext;
  33 import javax.accessibility.AccessibleSelection;
  34 import javax.swing.JComboBox;
  35 import javax.swing.JFrame;
  36 import javax.swing.SwingUtilities;
  37 import javax.swing.UIManager;
  38 import javax.swing.plaf.nimbus.NimbusLookAndFeel;
  39 
  40 public class Bug8154069 {
  41 
  42     private static JFrame frame;
  43     private static volatile Exception exception = null;
  44 
  45     public static void main(String args[]) throws Exception {


  72                     int count = as.getAccessibleSelectionCount();
  73                     if (count != 0) {
  74                         throw new RuntimeException("getAccessibleSelection count is not 0");
  75                     }
  76                     Accessible a = as.getAccessibleSelection(0);
  77                     if (a != null) {
  78                         throw new RuntimeException("getAccessibleSelection(0) is not null");
  79                     }
  80                 } catch (Exception e) {
  81                     exception = e;
  82                 }
  83             });
  84             if (exception != null) {
  85                 System.out.println("Test failed: " + exception.getMessage());
  86                 throw exception;
  87             } else {
  88                 System.out.println("Test passed.");
  89             }
  90         } finally {
  91             SwingUtilities.invokeAndWait(() -> {
  92                 frame.dispose();
  93             });
  94         }
  95     }
  96 
  97 }
   1 /*
   2  * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @key headful
  27  * @bug 8154069
  28  * @summary Jaws reads wrong values from comboboxes when no element is selected
  29  * @run main Bug8154069
  30  */
  31 
  32 import javax.accessibility.Accessible;
  33 import javax.accessibility.AccessibleContext;
  34 import javax.accessibility.AccessibleSelection;
  35 import javax.swing.JComboBox;
  36 import javax.swing.JFrame;
  37 import javax.swing.SwingUtilities;
  38 import javax.swing.UIManager;
  39 import javax.swing.plaf.nimbus.NimbusLookAndFeel;
  40 
  41 public class Bug8154069 {
  42 
  43     private static JFrame frame;
  44     private static volatile Exception exception = null;
  45 
  46     public static void main(String args[]) throws Exception {


  73                     int count = as.getAccessibleSelectionCount();
  74                     if (count != 0) {
  75                         throw new RuntimeException("getAccessibleSelection count is not 0");
  76                     }
  77                     Accessible a = as.getAccessibleSelection(0);
  78                     if (a != null) {
  79                         throw new RuntimeException("getAccessibleSelection(0) is not null");
  80                     }
  81                 } catch (Exception e) {
  82                     exception = e;
  83                 }
  84             });
  85             if (exception != null) {
  86                 System.out.println("Test failed: " + exception.getMessage());
  87                 throw exception;
  88             } else {
  89                 System.out.println("Test passed.");
  90             }
  91         } finally {
  92             SwingUtilities.invokeAndWait(() -> {
  93                 if (frame != null) { frame.dispose(); }
  94             });
  95         }
  96     }
  97 
  98 }
< prev index next >