harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r517170 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/plaf/basic/ test/api/java/common/javax/swing/plaf/basic/
Date Mon, 12 Mar 2007 11:05:09 GMT
Author: apetrenko
Date: Mon Mar 12 04:05:07 2007
New Revision: 517170

URL: http://svn.apache.org/viewvc?view=rev&rev=517170
Log:
Patch for HARMONY-2613 "[classlib][swing][plaf] javax.swing.plaf.basic.BasicTableUI methods
throw unspecified NPE if UI is not attached to a table"

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableHeaderUI.java
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableUI.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTableHeaderUITest.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTableUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableHeaderUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableHeaderUI.java?view=diff&rev=517170&r1=517169&r2=517170
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableHeaderUI.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableHeaderUI.java
Mon Mar 12 04:05:07 2007
@@ -101,11 +101,15 @@
         }
 
         public void mouseEntered(final MouseEvent e) {
-            updateCursor(e);
+            if (header != null) {
+                updateCursor(e);
+            }
         }
 
         public void mouseExited(final MouseEvent e) {
-            header.setCursor(originalHeaderCursor);
+            if (header != null) {
+                header.setCursor(originalHeaderCursor);
+            }
         }
 
 
@@ -316,7 +320,9 @@
     }
 
     protected void uninstallDefaults() {
-        Utilities.uninstallColorsAndFont(header);
+        if (header != null) {
+            Utilities.uninstallColorsAndFont(header);
+        }
     }
 
     protected void installListeners() {

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableUI.java?view=diff&rev=517170&r1=517169&r2=517170
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableUI.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTableUI.java
Mon Mar 12 04:05:07 2007
@@ -121,7 +121,7 @@
         }
 
         public void mousePressed(final MouseEvent e) {
-            if (!table.isEnabled()) {
+            if (table == null || !table.isEnabled()) {
                 return;
             }
 
@@ -162,7 +162,7 @@
         }
 
         public void mouseReleased(final MouseEvent e) {
-            if (!table.isEnabled()) {
+            if (table == null || !table.isEnabled()) {
                 return;
             }
 
@@ -178,7 +178,7 @@
         }
 
         public void mouseDragged(final MouseEvent e) {
-            if (!table.isEnabled()) {
+            if (table == null || !table.isEnabled()) {
                 return;
             }
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTableHeaderUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTableHeaderUITest.java?view=diff&rev=517170&r1=517169&r2=517170
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTableHeaderUITest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTableHeaderUITest.java
Mon Mar 12 04:05:07 2007
@@ -25,7 +25,10 @@
 import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.Graphics;
+import java.awt.Label;
+import java.awt.event.MouseWheelEvent;
 import javax.swing.BasicSwingTestCase;
+import javax.swing.JTable;
 import javax.swing.UIManager;
 import javax.swing.plaf.ColorUIResource;
 import javax.swing.plaf.FontUIResource;
@@ -34,8 +37,14 @@
 import org.apache.harmony.x.swing.Utilities;
 
 public class BasicTableHeaderUITest extends BasicSwingTestCase {
+
     private BasicTableHeaderUI ui;
 
+    private MouseWheelEvent mouseWheelEvent =
+            new MouseWheelEvent(new Label(),
+                    0, 0, 0, 0, 0, 0, false, 0,
+                    MouseWheelEvent.WHEEL_UNIT_SCROLL, 0);
+
     public BasicTableHeaderUITest(final String name) {
         super(name);
     }
@@ -63,6 +72,13 @@
     }
 
     public void testInstallUninstallUI() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.uninstallUI(new JTable());
+            }
+        });
         assertNull(ui.header);
         assertNull(ui.rendererPane);
         JTableHeader header = new JTableHeader();
@@ -76,6 +92,18 @@
     }
 
     public void testInstallUninstallDefaults() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.installDefaults();
+            }
+        });
+
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.uninstallDefaults();
+
         ui.header = new JTableHeader();
         ui.header.setForeground(new ColorUIResource(Color.RED));
         ui.header.setBackground(new ColorUIResource(Color.BLUE));
@@ -93,8 +121,23 @@
     }
 
     public void testInstallUninstallListeners() throws Exception {
-        ui.header = new JTableHeader();
         assertNull(ui.mouseInputListener);
+
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.installListeners();
+            }
+        });
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.uninstallListeners();
+            }
+        });
+        ui.header = new JTableHeader();
         int mouseListenersCount = ui.header.getMouseListeners().length;
         int mouseMotionListenersCount = ui.header.getMouseMotionListeners().length;
         ui.installListeners();
@@ -113,15 +156,56 @@
         assertTrue(Utilities.isEmptyArray(ui.header.getActionMap().allKeys()));
     }
 
+    public void testInstallKeyboardActions() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.installKeyboardActions();
+    }
+
+    public void testUninstallKeyboardActions() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.uninstallKeyboardActions();
+    }
+
     public void testPaint() throws Exception {
+        final Graphics g = createTestGraphics();
+
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.paint(g, new JTable());
+            }
+        });
         ui.installUI(new JTableHeader());
         ui.header.getColumnModel().addColumn(new TableColumn());
-        Graphics g = createTestGraphics();
         g.setClip(0, 0, 100, 100);
         ui.paint(g, null);
     }
 
     public void testGetMinimumMaximumPreferredSize() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.getMinimumSize(new JTable());
+            }
+        });
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.getMaximumSize(new JTable());
+            }
+        });
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.getPreferredSize(new JTable());
+            }
+        });
         ui.header = new JTableHeader();
         assertEquals(new Dimension(), ui.getMinimumSize(null));
         assertEquals(new Dimension(), ui.getMaximumSize(null));
@@ -151,8 +235,66 @@
                 .getPreferredSize(null));
     }
 
-    public void testMouseInputListener() throws Exception {
+    public void testMouseInputHandlerMouseEnteredNull() throws Exception {
         // Regression test for HARMONY-1777
         new BasicTableHeaderUI().new MouseInputHandler().mouseEntered(null);
+    }
+
+    public void testMouseInputHandlerMouseClicked() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.new MouseInputHandler().mouseClicked(mouseWheelEvent);
+    }
+
+    public void testMouseInputHandlerMouseEntered() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.new MouseInputHandler().mouseEntered(mouseWheelEvent);
+    }
+
+    public void testMouseInputHandlerMouseExited() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.new MouseInputHandler().mouseExited(mouseWheelEvent);
+    }
+
+    public void testMouseInputHandlerMousePressed() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.new MouseInputHandler().mousePressed(mouseWheelEvent);
+            }
+        });
+    }
+
+    public void testMouseInputHandlerMouseReleased() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.new MouseInputHandler().mouseReleased(mouseWheelEvent);
+            }
+        });
+    }
+
+    public void testMouseInputHandlerMouseDragged() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.new MouseInputHandler().mouseDragged(mouseWheelEvent);
+            }
+        });
+    }
+
+    public void testMouseInputHandlerMouseMoved() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.new MouseInputHandler().mouseMoved(mouseWheelEvent);
+            }
+        });
     }
 }

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTableUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTableUITest.java?view=diff&rev=517170&r1=517169&r2=517170
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTableUITest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTableUITest.java
Mon Mar 12 04:05:07 2007
@@ -22,6 +22,10 @@
 
 import java.awt.Dimension;
 import java.awt.Graphics;
+import java.awt.Label;
+import java.awt.event.FocusEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseWheelEvent;
 import javax.swing.BasicSwingTestCase;
 import javax.swing.CellRendererPane;
 import javax.swing.JTable;
@@ -32,6 +36,15 @@
 public class BasicTableUITest extends BasicSwingTestCase {
     private BasicTableUI ui;
 
+    private FocusEvent focusEvent = new FocusEvent(new JTable(), 0);
+
+    private KeyEvent keyEvent = new KeyEvent(new JTable(), 0, 0, 0, 0);
+
+    private MouseWheelEvent mouseWheelEvent =
+            new MouseWheelEvent(new Label(),
+                    0, 0, 0, 0, 0, 0, false, 0,
+                    MouseWheelEvent.WHEEL_UNIT_SCROLL, 0);
+
     public BasicTableUITest(final String name) {
         super(name);
     }
@@ -83,6 +96,13 @@
     }
 
     public void testUninstallUI() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.uninstallUI(new JTable());
+            }
+        });
         JTable table = new JTable();
         ui.installUI(table);
         ui.uninstallUI(null);
@@ -92,6 +112,27 @@
 
     public void testGetMinimumMaximumPreferredSize() throws Exception {
         JTable table = new JTable();
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.getMinimumSize(new JTable());
+            }
+        });
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.getMaximumSize(new JTable());
+            }
+        });
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.getPreferredSize(new JTable());
+            }
+        });
         ui.table = table;
         assertEquals(new Dimension(), ui.getMinimumSize(null));
         TableColumn column1 = new TableColumn();
@@ -133,17 +174,32 @@
         ui.paint(g, null);
     }
 
-    // Regression test for HARMONY-1776
     public void testPaint_Null() throws Exception {
         try {
+            // Regression test for HARMONY-1776
             ui.paint(null, null);
             fail("NullPointerException should have been thrown");
         } catch (NullPointerException e) {
             // Expected
         }
+
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.paint(createTestGraphics(), new JTable());
+            }
+        });
     }
 
     public void testInstallDefaults() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.installDefaults();
+            }
+        });
         ui.table = new JTable();
         ui.installDefaults();
         assertSame(UIManager.getFont("Table.font"), ui.table.getFont());
@@ -154,5 +210,139 @@
                 .getSelectionForeground());
         assertSame(UIManager.getColor("Table.selectionBackground"), ui.table
                 .getSelectionBackground());
+    }
+
+    public void testInstallKeyboardActions() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.installKeyboardActions();
+            }
+        });
+    }
+
+    public void testUninstallDefaults() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.uninstallDefaults();
+            }
+        });
+    }
+
+    public void testUninstallKeyboardActions() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.uninstallKeyboardActions();
+            }
+        });
+    }
+
+    public void testInstallListeners() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.installListeners();
+            }
+        });
+    }
+
+    public void testUninstallListeners() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.uninstallListeners();
+            }
+        });
+    }
+
+    public void testFocusHandlerFocusGained() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.new FocusHandler().focusGained(focusEvent);
+            }
+        });
+    }
+
+    public void testFocusHandlerFocusLost() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.new FocusHandler().focusLost(focusEvent);
+            }
+        });
+    }
+
+    public void testKeyHandlerKeyPressed() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.new KeyHandler().keyPressed(keyEvent);
+    }
+
+    public void testKeyHandlerKeyReleased() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.new KeyHandler().keyReleased(keyEvent);
+    }
+
+    public void testFocusHandlerKeyTyped() throws Exception {
+        testExceptionalCase(new NullPointerCase() {
+            // Regression test for HARMONY-2613
+            @Override
+            public void exceptionalAction() throws Exception {
+                ui.new KeyHandler().keyTyped(keyEvent);
+            }
+        });
+    }
+
+    public void testMouseInputHandlerMouseClicked() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.new MouseInputHandler().mouseClicked(mouseWheelEvent);
+    }
+
+    public void testMouseInputHandlerMouseEntered() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.new MouseInputHandler().mouseEntered(mouseWheelEvent);
+    }
+
+    public void testMouseInputHandlerMouseExited() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.new MouseInputHandler().mouseExited(mouseWheelEvent);
+    }
+
+    public void testMouseInputHandlerMousePressed() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.new MouseInputHandler().mousePressed(mouseWheelEvent);
+    }
+
+    public void testMouseInputHandlerMouseReleased() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.new MouseInputHandler().mouseReleased(mouseWheelEvent);
+    }
+
+    public void testMouseInputHandlerMouseDragged() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.new MouseInputHandler().mouseDragged(mouseWheelEvent);
+    }
+
+    public void testMouseInputHandlerMouseMoved() throws Exception {
+        // Regression test for HARMONY-2613
+        // Make sure it throws no exceptions
+        ui.new MouseInputHandler().mouseMoved(mouseWheelEvent);
     }
 }



Mime
View raw message