harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r438034 - in /incubator/harmony/enhanced/classlib/trunk/modules/swing: ./ src/main/java/common/javax/swing/text/ src/main/java/common/javax/swing/undo/ src/test/api/java/common/javax/swing/text/ src/test/api/java/common/javax/swing/undo/
Date Tue, 29 Aug 2006 09:50:28 GMT
Author: hindessm
Date: Tue Aug 29 02:50:28 2006
New Revision: 438034

URL: http://svn.apache.org/viewvc?rev=438034&view=rev
Log:
Applied updates from "[#HARMONY-1137] [classlib][swing/text] unit test
AbstractDocument_DefaultDocumentEventTest fails".

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/swing/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/AbstractUndoableEdit.java
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/UndoManager.java
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_DefaultDocumentEventTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/undo/AbstractUndoableEditTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/build.xml?rev=438034&r1=438033&r2=438034&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/build.xml Tue Aug 29 02:50:28
2006
@@ -167,9 +167,6 @@
                     <exclude name="javax/swing/plaf/basic/BasicOptionPaneUITest.java"/>
                     <exclude name="javax/swing/plaf/basic/BasicTreeUITest.java"/>
                     <exclude name="javax/swing/table/BasicSwingTableTestCase.java"/>
-                    <exclude name="javax/swing/text/AbstractDocument_DefaultDocumentEventTest.java"/>
-                    <exclude name="javax/swing/text/AbstractDocument_ElementEditTest.java"/>
-                    <exclude name="javax/swing/text/AbstractDocument_UpdateTest.java"/>
                     <exclude name="javax/swing/text/DefaultCaret_MultithreadedTest.java"/>
                     <exclude name="javax/swing/text/DefaultEditorKitTest.java"/>
                     <exclude name="javax/swing/text/DefaultEditorKit_Actions_MultithreadedTest.java"/>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java?rev=438034&r1=438033&r2=438034&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/text/AbstractDocument.java
Tue Aug 29 02:50:28 2006
@@ -559,7 +559,7 @@
         }
 
         public String getRedoPresentationName() {
-            return RedoName + " " + getPresentationName();
+            return getRedoName() + " " + getPresentationName();
         }
 
         public EventType getType() {
@@ -567,7 +567,7 @@
         }
 
         public String getUndoPresentationName() {
-            return UndoName + " " + getPresentationName();
+            return getUndoName() + " " + getPresentationName();
         }
 
         public boolean isSignificant() {
@@ -625,6 +625,13 @@
             }
         }
 
+        private String getUndoName() {
+            return UIManager.getString("AbstractDocument.undoText");
+        }
+
+        private String getRedoName() {
+            return UIManager.getString("AbstractDocument.redoText");
+        }
     }
 
     public static class ElementEdit extends AbstractUndoableEdit

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/AbstractUndoableEdit.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/AbstractUndoableEdit.java?rev=438034&r1=438033&r2=438034&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/AbstractUndoableEdit.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/AbstractUndoableEdit.java
Tue Aug 29 02:50:28 2006
@@ -22,6 +22,8 @@
 import java.io.Serializable;
 import javax.swing.UIManager;
 
+import org.apache.harmony.x.swing.Utilities;
+
 public class AbstractUndoableEdit implements UndoableEdit, Serializable {
 
     private static final long serialVersionUID = 580150227676302096L;
@@ -60,21 +62,11 @@
     }
 
     public String getUndoPresentationName() {
-        String presentationName = getPresentationName();
-        String name = getUndoName();
-        if (presentationName.length() == 0) {
-            return name;
-        }
-        return name + " " + presentationName;
+        return getOperationPresentationName(getUndoName());
     }
 
     public String getRedoPresentationName() {
-        String presentationName = getPresentationName();
-        String name = getRedoName();
-        if (presentationName.length() == 0) {
-            return name;
-        }
-        return name + " " + presentationName;
+        return getOperationPresentationName(getRedoName());
     }
 
     public String getPresentationName() {
@@ -113,21 +105,19 @@
         alive = false;
     }
 
-    private String undoName;
-    private String redoName;
-    private String getUndoName() {
-        if (undoName == null) {
-            undoName = UIManager.getString("AbstractUndoableEdit.undoText");
-        }
-        return undoName;
+    final String getUndoName() {
+        return UIManager.getString("AbstractUndoableEdit.undoText");
     }
 
-    private String getRedoName() {
-        if (redoName == null) {
-            redoName = UIManager.getString("AbstractUndoableEdit.redoText");
-        }
-        return redoName;
+    final String getRedoName() {
+        return UIManager.getString("AbstractUndoableEdit.redoText");
     }
 
+    private String getOperationPresentationName(final String operationName) {
+        final String presentationName = getPresentationName();
+        return Utilities.isEmptyString(presentationName)
+               ? operationName
+               : operationName + " " + presentationName;
+    }
 }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/UndoManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/UndoManager.java?rev=438034&r1=438033&r2=438034&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/UndoManager.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/main/java/common/javax/swing/undo/UndoManager.java
Tue Aug 29 02:50:28 2006
@@ -124,7 +124,7 @@
         if (inProgress) {
             UndoableEdit undoEdit = editToBeUndone();
             if (undoEdit == null) {
-                return UndoName;
+                return getUndoName();
             }
             return undoEdit.getUndoPresentationName();
         } else {
@@ -144,7 +144,7 @@
         if (inProgress) {
             UndoableEdit redoEdit = editToBeRedone();
             if (redoEdit == null) {
-                return RedoName;
+                return getRedoName();
             }
             return redoEdit.getRedoPresentationName();
         } else {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_DefaultDocumentEventTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_DefaultDocumentEventTest.java?rev=438034&r1=438033&r2=438034&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_DefaultDocumentEventTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/text/AbstractDocument_DefaultDocumentEventTest.java
Tue Aug 29 02:50:28 2006
@@ -25,6 +25,7 @@
 import java.util.Vector;
 
 import javax.swing.BasicSwingTestCase;
+import javax.swing.UIManager;
 import javax.swing.event.DocumentEvent;
 import javax.swing.event.DocumentListener;
 import javax.swing.event.UndoableEditEvent;
@@ -69,6 +70,12 @@
      */
     UndoableEditEvent undoEvent;
 
+    private static final String UNDO_TEXT_KEY = "AbstractDocument.undoText";
+    private static final String REDO_TEXT_KEY = "AbstractDocument.redoText";
+
+    private String undoName;
+    private String redoName;
+
     /*
      * @see TestCase#setUp()
      */
@@ -97,6 +104,9 @@
 
         change = doc.new DefaultDocumentEvent(0, 10,
                 DocumentEvent.EventType.CHANGE);
+
+        undoName = UIManager.getString(UNDO_TEXT_KEY);
+        redoName = UIManager.getString(REDO_TEXT_KEY);
     }
 
     /**
@@ -232,27 +242,56 @@
             ref += edit.toString();
         }
         ref += "]";
-        //System.out.println(ref);
         assertEquals(ref, insert.toString());
-        //System.out.println(insert + "\n" + remove);
     }
 
     public void testGetUndoPresentationName() {
-        assertEquals("Undo addition",     insert.getUndoPresentationName());
-        assertEquals("Undo deletion",     remove.getUndoPresentationName());
-        assertEquals("Undo style change", change.getUndoPresentationName());
+        assertEquals(undoName + " " + insert.getPresentationName(),
+                     insert.getUndoPresentationName());
+        assertEquals(undoName + " " + remove.getPresentationName(),
+                     remove.getUndoPresentationName());
+        assertEquals(undoName + " " + change.getPresentationName(),
+                     change.getUndoPresentationName());
+    }
+
+    public void testGetUndoPresentationNameModified() {
+        UIManager.put(UNDO_TEXT_KEY, "ODNU");
+        try {
+            assertEquals("ODNU "
+                         + UIManager.getString("AbstractDocument.additionText"),
+                         insert.getUndoPresentationName());
+        } finally {
+            UIManager.put(UNDO_TEXT_KEY, undoName);
+        }
     }
 
     public void testGetRedoPresentationName() {
-        assertEquals("Redo addition",     insert.getRedoPresentationName());
-        assertEquals("Redo deletion",     remove.getRedoPresentationName());
-        assertEquals("Redo style change", change.getRedoPresentationName());
+        assertEquals(redoName + " " + insert.getPresentationName(),
+                     insert.getRedoPresentationName());
+        assertEquals(redoName + " " + remove.getPresentationName(),
+                     remove.getRedoPresentationName());
+        assertEquals(redoName + " " + change.getPresentationName(),
+                     change.getRedoPresentationName());
+    }
+
+    public void testGetRedoPresentationNameModified() {
+        UIManager.put(REDO_TEXT_KEY, "ODER");
+        try {
+            assertEquals("ODER "
+                         + UIManager.getString("AbstractDocument.additionText"),
+                         insert.getRedoPresentationName());
+        } finally {
+            UIManager.put(REDO_TEXT_KEY, redoName);
+        }
     }
 
     public void testGetPresentationName() {
-        assertEquals("addition",     insert.getPresentationName());
-        assertEquals("deletion",     remove.getPresentationName());
-        assertEquals("style change", change.getPresentationName());
+        assertSame(UIManager.getString("AbstractDocument.additionText"),
+                   insert.getPresentationName());
+        assertSame(UIManager.getString("AbstractDocument.deletionText"),
+                   remove.getPresentationName());
+        assertSame(UIManager.getString("AbstractDocument.styleChangeText"),
+                   change.getPresentationName());
     }
 
     public void testIsSignificant() {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/undo/AbstractUndoableEditTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/undo/AbstractUndoableEditTest.java?rev=438034&r1=438033&r2=438034&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/undo/AbstractUndoableEditTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java/common/javax/swing/undo/AbstractUndoableEditTest.java
Tue Aug 29 02:50:28 2006
@@ -25,14 +25,27 @@
 import junit.framework.TestCase;
 
 public class AbstractUndoableEditTest extends TestCase {
+    private static final String UNDO_NAME_KEY = "AbstractUndoableEdit.undoText";
+    private static final String REDO_NAME_KEY = "AbstractUndoableEdit.redoText";
+
     protected AbstractUndoableEdit obj;
 
+    private String defaultUndoName;
+    private String defaultRedoName;
+
     public static void main(final String[] args) {
         junit.textui.TestRunner.run(AbstractUndoableEditTest.class);
     }
 
     protected void setUp() throws Exception {
         obj = new AbstractUndoableEdit();
+        defaultUndoName = UIManager.getString(UNDO_NAME_KEY);
+        defaultRedoName = UIManager.getString(REDO_NAME_KEY);
+    }
+
+    protected void tearDown() throws Exception {
+        UIManager.put(UNDO_NAME_KEY, defaultUndoName);
+        UIManager.put(REDO_NAME_KEY, defaultRedoName);
     }
 
     public void testToString() {
@@ -141,12 +154,42 @@
     }
 
     public void testGetRedoPresentationName() {
-        assertEquals(UIManager.getString("AbstractUndoableEdit.redoText"),
+        assertEquals(UIManager.getString(REDO_NAME_KEY),
                      obj.getRedoPresentationName());
     }
 
+    public void testGetRedoPresentationNameModified() {
+        String redoName = "name of Redo";
+        UIManager.put(REDO_NAME_KEY, redoName);
+        assertEquals(redoName, obj.getRedoPresentationName());
+
+        redoName = "alternative redo";
+        UIManager.put(REDO_NAME_KEY, redoName);
+        assertEquals(redoName, obj.getRedoPresentationName());
+    }
+
     public void testGetUndoPresentationName() {
-        assertEquals(UIManager.getString("AbstractUndoableEdit.undoText"),
+        assertEquals(UIManager.getString(UNDO_NAME_KEY),
+                     obj.getUndoPresentationName());
+    }
+
+    public void testGetUndoPresentationNameModified() {
+        String undoName = "name of Undo";
+        UIManager.put(UNDO_NAME_KEY, undoName);
+        assertEquals(undoName, obj.getUndoPresentationName());
+
+        undoName = "alternative undo";
+        UIManager.put(UNDO_NAME_KEY, undoName);
+        assertEquals(undoName, obj.getUndoPresentationName());
+    }
+
+    public void testGetUndoPresentationNameNull() {
+        obj = new AbstractUndoableEdit() {
+            public String getPresentationName() {
+                return null;
+            }
+        };
+        assertEquals(UIManager.getString(UNDO_NAME_KEY),
                      obj.getUndoPresentationName());
     }
 



Mime
View raw message