harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r513449 - in /harmony/enhanced/classlib/trunk/modules: awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java swing/src/test/api/java/common/javax/swing/text/UtilitiesTest.java
Date Thu, 01 Mar 2007 19:20:23 GMT
Author: apetrenko
Date: Thu Mar  1 11:20:22 2007
New Revision: 513449

URL: http://svn.apache.org/viewvc?view=rev&rev=513449
Log:
Patch for HARMONY-2745 "[classlib][swing] j.s.text.Utilities.getPosition{Above, Below} throw
NPE"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java
    harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/UtilitiesTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java?view=diff&rev=513449&r1=513448&r2=513449
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/text/TextUtils.java
Thu Mar  1 11:20:22 2007
@@ -372,7 +372,7 @@
                                              final int p, final int x)
             throws BadLocationException {
         int p0 = getRowStart(textKit, p);
-        if (p0 == 0) {
+        if (p0 <= 0) {
             return -1;
         }
         int end = p0 - 1;
@@ -405,6 +405,9 @@
                                              final int p, final int x)
             throws BadLocationException {
         int p0 = getRowEnd(textKit, p);
+        if (p0 == -1) {
+            return -1;
+        }
         int length = textKit.getDocument().getLength();
         if (p0 == length) {
             return p;

Modified: harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/UtilitiesTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/UtilitiesTest.java?view=diff&rev=513449&r1=513448&r2=513449
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/UtilitiesTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/UtilitiesTest.java
Thu Mar  1 11:20:22 2007
@@ -631,6 +631,18 @@
         getPositionAboveBelowTest(jtf);
     }
 
+    // HARMONY-2745
+    public void testGetPositionAbove() throws BadLocationException {
+        jta = new JTextArea();
+        assertEquals(-1, Utilities.getPositionAbove(jta, 1, 0));
+    }
+
+    // HARMONY-2745
+    public void testGetPositionBelow() throws BadLocationException {
+        jta = new JTextArea();
+        assertEquals(-1, Utilities.getPositionBelow(jta, 1, 0));
+    }
+
     void getWordStartTest(final JTextComponent c) {
         AbstractDocument ad = (AbstractDocument) c.getDocument();
         BreakIterator bi = BreakIterator.getWordInstance();



Mime
View raw message