harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r517677 - in /harmony/enhanced/classlib/trunk/modules/swing/src: main/java/common/javax/swing/plaf/basic/ main/java/common/org/apache/harmony/x/swing/internal/nls/ test/api/java/common/javax/swing/plaf/basic/
Date Tue, 13 Mar 2007 12:59:48 GMT
Author: apetrenko
Date: Tue Mar 13 05:59:47 2007
New Revision: 517677

URL: http://svn.apache.org/viewvc?view=rev&rev=517677
Log:
Patch for HARMONY-1779 "[classlib][swing]javax.swing.plaf.basic.BasicEditorPaneUI.installUI
does not throw Error"

Modified:
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
    harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/internal/nls/messages.properties
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUITest.java

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java?view=diff&rev=517677&r1=517676&r2=517677
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/plaf/basic/BasicTextUI.java
Tue Mar 13 05:59:47 2007
@@ -87,6 +87,7 @@
 import org.apache.harmony.awt.text.TextUtils;
 import org.apache.harmony.x.swing.StringConstants;
 import org.apache.harmony.x.swing.Utilities;
+import org.apache.harmony.x.swing.internal.nls.Messages;
 
 
 public abstract class BasicTextUI extends TextUI implements ViewFactory {
@@ -689,11 +690,11 @@
     }
 
     public void installUI(final JComponent c) {
-        super.installUI(c);
-
-        if (c == null || (!(c instanceof JTextComponent))) {
-            return;
+        if (!(c instanceof JTextComponent)) {
+            throw new Error(Messages.getString("swing.B1")); //$NON-NLS-1$
         }
+        
+        super.installUI(c);
 
         setComponent((JTextComponent)c);
 

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/internal/nls/messages.properties
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/internal/nls/messages.properties?view=diff&rev=517677&r1=517676&r2=517677
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/internal/nls/messages.properties
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/org/apache/harmony/x/swing/internal/nls/messages.properties
Tue Mar 13 05:59:47 2007
@@ -191,6 +191,7 @@
 swing.AD=Specified child is not a child of this node
 swing.AF=node doesn't have a parent
 swing.B0=modification mode is incorrect
+swing.B1=TextUI needs JTextComponent
 
 swing.err.01=Illegal request
 swing.err.02=BoxLayout should be used for one container only

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUITest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUITest.java?view=diff&rev=517677&r1=517676&r2=517677
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUITest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/plaf/basic/BasicTextUITest.java
Tue Mar 13 05:59:47 2007
@@ -33,6 +33,7 @@
 import javax.swing.InputMap;
 import javax.swing.JComponent;
 import javax.swing.JFrame;
+import javax.swing.JMenuItem;
 import javax.swing.JTextArea;
 import javax.swing.JTextField;
 import javax.swing.KeyStroke;
@@ -66,6 +67,8 @@
 import javax.swing.text.StyledEditorKit;
 import javax.swing.text.View;
 
+import junit.framework.AssertionFailedError;
+
 public class BasicTextUITest extends SwingTestCase {
     MyBasicTextUI basicTextUI;
 
@@ -176,8 +179,8 @@
         super.tearDown();
     }
 
-    public void testBasicTextUI() {
-    }
+//    public void testBasicTextUI() {
+//    }
 
     private void getPos(final BasicTextUI ui, final int start, final Position.Bias bias,
             final int direction, final int samplePos, final Position.Bias sample,
@@ -470,6 +473,34 @@
         assertEquals(caretBlinkRate, caret.getBlinkRate());
         assertEquals(jta.getDocument().getDefaultRootElement(), jta.getUI().getRootView(jta)
                 .getElement());
+    }
+
+    // Regression test for HARMONY-1779
+    public void testInstallUINull() {
+        basicTextUI = new MyBasicTextUI();
+        try {
+            basicTextUI.installUI(null);
+            fail("Error is expected (\"TextUI needs JTextComponent\")");
+        } catch (AssertionFailedError e) {
+            // Let JUnit handle its exceptions
+            throw e;
+        } catch (Error e) {
+            // expected
+        }
+    }
+
+    // Regression test for HARMONY-1779
+    public void testInstallUINonTextComponent() {
+        basicTextUI = new MyBasicTextUI();
+        try {
+            basicTextUI.installUI(new JMenuItem());
+            fail("Error is expected (\"TextUI needs JTextComponent\")");
+        } catch (AssertionFailedError e) {
+            // Let JUnit handle its exceptions
+            throw e;
+        } catch (Error e) {
+            // expected
+        }
     }
 
     public void testGetKeymapName() {



Mime
View raw message