harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r901112 - /harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/
Date Wed, 20 Jan 2010 09:13:22 GMT
Author: regisxu
Date: Wed Jan 20 09:12:53 2010
New Revision: 901112

URL: http://svn.apache.org/viewvc?rev=901112&view=rev
Log:
Apply patch for HARMONY-6432: [test] Improve the method coverage rate of unit test for javax.acessibility

Added:
    harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleAttributeSequenceTest.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleHyperlinkTest.java
  (with props)
    harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleTextSequenceTest.java
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleBundleTest.java
    harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleRelationSetTest.java
    harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleRelationTest.java

Added: harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleAttributeSequenceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleAttributeSequenceTest.java?rev=901112&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleAttributeSequenceTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleAttributeSequenceTest.java
Wed Jan 20 09:12:53 2010
@@ -0,0 +1,34 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.accessibility;
+
+import junit.framework.TestCase;
+import javax.accessibility.AccessibleAttributeSequence;
+
+public class AccessibleAttributeSequenceTest extends TestCase {
+
+    /**
+     * @add test {@link javax.accessibility.AccessibleAttributeSequence#endIndex}
+     */
+    public void test_fields() {
+        AccessibleAttributeSequence aas = new AccessibleAttributeSequence();
+        assertEquals(0, aas.startIndex);
+        assertEquals(0, aas.endIndex);
+        assertNull(aas.attributes);
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleAttributeSequenceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleBundleTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleBundleTest.java?rev=901112&r1=901111&r2=901112&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleBundleTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleBundleTest.java
Wed Jan 20 09:12:53 2010
@@ -21,26 +21,70 @@
 
 package javax.accessibility;
 
+import java.util.Locale;
+
 import junit.framework.TestCase;
 
 public class AccessibleBundleTest extends TestCase {
+    private MockAccessibleBundle bundle;
+
+    private Object[][] resources;
+
+    private static final String ACCESSIBLE_RESOURSE_BUNDLE = "javax.accessibility.AccessibleResourceBundle";
//$NON-NLS-1$
+
+    class MockAccessibleBundle extends AccessibleBundle {
+        public String getKey() {
+            return key;
+        }
+
+        public void setKey(String key) {
+            this.key = key;
+        }
+
+        public String toDisplayString(String resourceBundleName, Locale locale) {
+            return super.toDisplayString(resourceBundleName, locale);
+        }
+    }
 
     @SuppressWarnings("deprecation")
-    public void testToDisplayString() throws Exception {
-        AccessibleBundle bundle = new AccessibleBundle() {
-        };
+    public void setUp() {
+        bundle = new MockAccessibleBundle();
+        resources = new AccessibleResourceBundle().getContents();
+    }
 
-        Object[][] resources = new AccessibleResourceBundle().getContents();
+    public void tearDown() {
+        bundle = null;
+        resources = null;
+    }
 
+    /**
+     * @test {@link javax.accessibility.AccessibleBundle#toDisplayString()}
+     * @add test
+     *      {@link javax.accessibility.AccessibleBundle#toDisplayString(java.util.Locale)}
+     *@add test
+     *      {@link javax.accessibility.AccessibleBundle#toDisplayString(String, java.util.Locale)}
+     */
+    public void testToDisplayString_withoutArgAndWithArg() throws Exception {
         for (int i = 0; i < resources.length; i++) {
-            bundle.key = (String) resources[i][0];
-            assertEquals("DisplayString don't match resource: " + bundle.key, bundle
-                    .toDisplayString(), resources[i][1]);
-            assertEquals("toDisplayString don't match toString: " + bundle.key, bundle
-                    .toString(), bundle.toDisplayString());
+            bundle.setKey((String) resources[i][0]);
+            Locale defaultLocale = Locale.getDefault();
+            String expected = bundle.toDisplayString();
+            String actualWithLocale = bundle.toDisplayString(defaultLocale);
+            String actualWithResourceBundleName = bundle.toDisplayString(
+                    ACCESSIBLE_RESOURSE_BUNDLE, defaultLocale);
+            assertEquals("DisplayString don't match resource: "
+                    + bundle.getKey(), bundle.toDisplayString(),
+                    resources[i][1]);
+            assertEquals("toDisplayString(locale) error ", expected,
+                    actualWithLocale);
+            assertEquals(expected, actualWithResourceBundleName);
+            assertEquals("toDisplayString don't match toString: "
+                    + bundle.getKey(), bundle.toString(), bundle
+                    .toDisplayString());
         }
-        bundle.key = "ShouldNotFindSuchAString";
+        bundle.setKey("ShouldNotFindSuchAString");
         assertEquals("Not bundled DisplayString should match itself",
                 "ShouldNotFindSuchAString", bundle.toDisplayString());
     }
+
 }

Added: harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleHyperlinkTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleHyperlinkTest.java?rev=901112&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleHyperlinkTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleHyperlinkTest.java
Wed Jan 20 09:12:53 2010
@@ -0,0 +1,76 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.accessibility;
+
+import junit.framework.TestCase;
+
+public class AccessibleHyperlinkTest extends TestCase{
+
+    class MockAccessibleHyperlink extends AccessibleHyperlink{
+
+        @Override
+        public boolean doAccessibleAction(int i) {
+            return false;
+        }
+
+        @Override
+        public Object getAccessibleActionAnchor(int i) {
+            return null;
+        }
+
+        @Override
+        public int getAccessibleActionCount() {
+            return 0;
+        }
+
+        @Override
+        public String getAccessibleActionDescription(int i) {
+            return null;
+        }
+
+        @Override
+        public Object getAccessibleActionObject(int i) {
+            return null;
+        }
+
+        @Override
+        public int getEndIndex() {
+            return 0;
+        }
+
+        @Override
+        public int getStartIndex() {
+            return 0;
+        }
+
+        @Override
+        public boolean isValid() {
+            return false;
+        }
+
+    }
+
+    /**
+     * @add tests {@link javax.accessibility.AccessibleHyperlink}
+     */
+    public void test_constructor(){
+        MockAccessibleHyperlink mock=new MockAccessibleHyperlink();
+        assertNotNull(mock);
+        assertFalse(mock.isValid());
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleHyperlinkTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleRelationSetTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleRelationSetTest.java?rev=901112&r1=901111&r2=901112&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleRelationSetTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleRelationSetTest.java
Wed Jan 20 09:12:53 2010
@@ -42,13 +42,18 @@
     }
 
     public void testAccessibleRelationSet() {
-        assertNotNull(set.relations);
+        assertNotNull(set.toArray());
 
         try {
             new AccessibleRelationSet(null);
             fail("expected null pointer exception");
         } catch (NullPointerException e) {
         }
+        AccessibleRelationSet set2 = new AccessibleRelationSet(relations);
+        for (AccessibleRelation re : relations) {
+            assertTrue("new set did not contain the relation", set2.contains(re
+                    .getKey()));
+        }
     }
 
     public void testAddContains() {
@@ -69,7 +74,7 @@
     }
 
     public void testNullOperations() {
-        set.relations = null;
+        set.clear();
         assertFalse("Empty set should not contain any item", set
                 .contains(AccessibleRelation.LABEL_FOR));
         assertNull("Empty set should not contain any item", set
@@ -77,7 +82,7 @@
         assertFalse("Empty set should not contain any item", set.remove(set
                 .get(AccessibleRelation.LABEL_FOR)));
         set.add(new AccessibleRelation(AccessibleRelation.CONTROLLER_FOR));
-        set.relations = null;
+        set.clear();
         set.addAll(relations);
     }
 
@@ -90,11 +95,11 @@
         assertSame(relations[0], set.get(AccessibleRelation.CONTROLLED_BY));
         set.remove(set.get(AccessibleRelation.CONTROLLED_BY));
 
-        set.relations = null;
+        set.clear();
         set.addAll(relations);
         set.addAll(relations);
         assertEquals("Should not add duplicate items in addAll",
-                relations.length, set.relations.size());
+                relations.length, set.size());
     }
 
     public void testGet() {
@@ -106,7 +111,7 @@
 
     public void testClear() {
         set.clear();
-        assertEquals("Cleared array should be empty", 0, set.relations.size());
+        assertEquals("Cleared array should be empty", 0, set.size());
     }
 
     public void testRemove() {
@@ -124,7 +129,7 @@
                 "String representation should contain elements representation",
                 stateSetString.indexOf(relations[1].toString()) >= 0);
 
-        set.relations = null;
+        set.clear();
         set.toString();
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleRelationTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleRelationTest.java?rev=901112&r1=901111&r2=901112&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleRelationTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleRelationTest.java
Wed Jan 20 09:12:53 2010
@@ -23,7 +23,7 @@
 
     public void testGetKey() {
         AccessibleRelation relation = new AccessibleRelation(AccessibleRelation.LABEL_FOR);
-        assertEquals(relation.key, relation.getKey());
+        assertEquals(AccessibleRelation.LABEL_FOR, relation.getKey());
     }
 
     public void testAccessibleRelation() {
@@ -52,4 +52,27 @@
         assertEquals(1, relation.getTarget().length);
         assertNull(relation.getTarget()[0]);
     }
+
+    /**
+     * @add tests
+     *      {@link javax.accessibility.AccessibleRelation#AccessibleRelation(String, Object)}
+     */
+    public void test_constructor_Ljava_lang_StringLjava_lang_Object() {
+        AccessibleRelation relation = new AccessibleRelation(
+                AccessibleRelation.LABEL_FOR, new String("test"));
+        assertEquals("target[0] did not equals to parameter passed in", "test",
+                (relation.getTarget()[0]).toString());
+    }
+
+    /**
+     * @add tests
+     *      {@link javax.accessibility.AccessibleRelation#AccessibleRelation(String, Object[])}
+     */
+    public void test_constructor_Ljava_lang_String$Ljava_lang_Object() {
+        AccessibleRelation relation = new AccessibleRelation("test",
+                new Object[2]);
+        assertEquals(2, relation.getTarget().length);
+        relation = new AccessibleRelation("test", null);
+        assertEquals(0, relation.getTarget().length);
+    }
 }

Added: harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleTextSequenceTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleTextSequenceTest.java?rev=901112&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleTextSequenceTest.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleTextSequenceTest.java
Wed Jan 20 09:12:53 2010
@@ -0,0 +1,37 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package javax.accessibility;
+
+import junit.framework.TestCase;
+
+public class AccessibleTextSequenceTest extends TestCase {
+    /**
+     * add tests {@link javax.accessibility.AccessibleTextSequence}
+     */
+    public void test_constructor() {
+        class MockAccessibleTextSequence extends AccessibleTextSequence {
+            public MockAccessibleTextSequence() {
+                super();
+            }
+        }
+        MockAccessibleTextSequence mock = new MockAccessibleTextSequence();
+        assertEquals("init error", 0, mock.endIndex);
+        assertEquals("init error", 0, mock.startIndex);
+        assertNull("init error", mock.text);
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/accessibility/src/test/api/java/common/javax/accessibility/AccessibleTextSequenceTest.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message