This is the mail archive of the mauve-patches@sourceware.org mailing list for the Mauve project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

FYI: New InputMap tests


This patch (committed) adds tests for most of the methods in the javax.swing.InputMap class:

2006-07-05 David Gilbert <david.gilbert@object-refinery.com>

   * gnu/testlet/javax/swing/InputMap/allKeys.java: New test,
   * gnu/testlet/javax/swing/InputMap/clear.java: New test,
   * gnu/testlet/javax/swing/InputMap/constructor.java: New test,
   * gnu/testlet/javax/swing/InputMap/get.java: New test,
   * gnu/testlet/javax/swing/InputMap/getParent.java: New test,
   * gnu/testlet/javax/swing/InputMap/keys.java: New test,
   * gnu/testlet/javax/swing/InputMap/put.java: New test,
   * gnu/testlet/javax/swing/InputMap/remove.java: New test,
   * gnu/testlet/javax/swing/InputMap/setParent.java: New test,
   * gnu/testlet/javax/swing/InputMap/size.java: New test.

Regards,

Dave
Index: gnu/testlet/javax/swing/InputMap/allKeys.java
===================================================================
RCS file: gnu/testlet/javax/swing/InputMap/allKeys.java
diff -N gnu/testlet/javax/swing/InputMap/allKeys.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/InputMap/allKeys.java	5 Jul 2006 10:32:21 -0000
@@ -0,0 +1,67 @@
+/* allKeys.java -- some checks for the allKeys() method in the InputMap class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.3
+
+package gnu.testlet.javax.swing.InputMap;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.InputMap;
+import javax.swing.KeyStroke;
+
+public class allKeys implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    InputMap m = new InputMap();
+    harness.check(m.allKeys(), null);
+    KeyStroke ks1 = KeyStroke.getKeyStroke('a');
+    m.put(ks1, "AAA");
+    KeyStroke[] keys = m.allKeys();
+    harness.check(keys.length, 1);
+    harness.check(keys[0], ks1);
+    
+    InputMap p = new InputMap();
+    m.setParent(p);
+    keys = m.allKeys();
+    harness.check(keys.length, 1);
+    harness.check(keys[0], ks1);
+    
+    KeyStroke ks2 = KeyStroke.getKeyStroke('b');
+    p.put(ks2, "BBB");
+    keys = m.allKeys();
+    harness.check(keys.length, 2);
+    harness.check(keys[0], ks2);
+    harness.check(keys[1], ks1);
+    
+    // try a KeyStroke that is defined in both maps
+    KeyStroke ks3 = KeyStroke.getKeyStroke('z');
+    p.put(ks3, "ZZZ");
+    m.put(ks3, "XXX");
+    keys = m.allKeys();
+    harness.check(keys.length, 3);
+    harness.check(keys[0], ks2);
+    harness.check(keys[1], ks3);
+    harness.check(keys[2], ks1);
+  }
+}
Index: gnu/testlet/javax/swing/InputMap/clear.java
===================================================================
RCS file: gnu/testlet/javax/swing/InputMap/clear.java
diff -N gnu/testlet/javax/swing/InputMap/clear.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/InputMap/clear.java	5 Jul 2006 10:32:21 -0000
@@ -0,0 +1,52 @@
+/* clear.java -- some checks for the clear() method in the InputMap class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.3
+
+package gnu.testlet.javax.swing.InputMap;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.InputMap;
+import javax.swing.KeyStroke;
+
+public class clear implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    InputMap m = new InputMap();
+    m.clear();
+    harness.check(m.size(), 0);
+    m.put(KeyStroke.getKeyStroke('a'), "AAA");
+    harness.check(m.size(), 1);
+    m.clear();
+    harness.check(m.size(), 0);
+    
+    // confirm that this method doesn't change the parent
+    InputMap p = new InputMap();
+    p.put(KeyStroke.getKeyStroke('z'), "ZZZ");
+    harness.check(p.size(), 1);
+    m.setParent(p);
+    m.clear();
+    harness.check(p.size(), 1);
+  }
+}
Index: gnu/testlet/javax/swing/InputMap/constructor.java
===================================================================
RCS file: gnu/testlet/javax/swing/InputMap/constructor.java
diff -N gnu/testlet/javax/swing/InputMap/constructor.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/InputMap/constructor.java	5 Jul 2006 10:32:21 -0000
@@ -0,0 +1,41 @@
+/* constructor.java -- some checks for the constructor in the InputMap class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDk1.3
+
+package gnu.testlet.javax.swing.InputMap;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.InputMap;
+
+public class constructor implements Testlet 
+{
+  public void test(TestHarness harness)
+  {
+    InputMap m = new InputMap();
+    harness.check(m.size(), 0);
+    harness.check(m.getParent(), null);
+    harness.check(m.keys(), null);
+    harness.check(m.allKeys(), null);
+  }
+}
Index: gnu/testlet/javax/swing/InputMap/get.java
===================================================================
RCS file: gnu/testlet/javax/swing/InputMap/get.java
diff -N gnu/testlet/javax/swing/InputMap/get.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/InputMap/get.java	5 Jul 2006 10:32:21 -0000
@@ -0,0 +1,51 @@
+/* get.java -- some checks for the get() method in the InputMap class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.3
+
+package gnu.testlet.javax.swing.InputMap;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.InputMap;
+import javax.swing.KeyStroke;
+
+public class get implements Testlet 
+{
+  public void test(TestHarness harness)
+  {
+    InputMap m = new InputMap();
+    KeyStroke ks1 = KeyStroke.getKeyStroke('a');
+    harness.check(m.get(ks1), null);
+    m.put(ks1, "ABC");
+    harness.check(m.get(ks1), "ABC");
+    
+    harness.check(m.get(null), null);
+    
+    // check that a binding in the parent is found
+    InputMap p = new InputMap();
+    KeyStroke ks2 = KeyStroke.getKeyStroke('b');
+    p.put(ks2, "XYZ");
+    m.setParent(p);
+    harness.check(m.get(ks2), "XYZ");
+  }
+}
Index: gnu/testlet/javax/swing/InputMap/getParent.java
===================================================================
RCS file: gnu/testlet/javax/swing/InputMap/getParent.java
diff -N gnu/testlet/javax/swing/InputMap/getParent.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/InputMap/getParent.java	5 Jul 2006 10:32:21 -0000
@@ -0,0 +1,44 @@
+/* getParent.java -- some checks for the getParent() method in the InputMap 
+       class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.3
+
+package gnu.testlet.javax.swing.InputMap;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.InputMap;
+
+public class getParent implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    InputMap m = new InputMap();
+    harness.check(m.getParent(), null);
+    InputMap p = new InputMap();
+    m.setParent(p);
+    harness.check(m.getParent(), p);
+    m.setParent(null);
+    harness.check(m.getParent(), null);
+  }
+}
Index: gnu/testlet/javax/swing/InputMap/keys.java
===================================================================
RCS file: gnu/testlet/javax/swing/InputMap/keys.java
diff -N gnu/testlet/javax/swing/InputMap/keys.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/InputMap/keys.java	5 Jul 2006 10:32:21 -0000
@@ -0,0 +1,62 @@
+/* keys.java -- some checks for the keys() method in the InputMap class.
+   Copyright (C) 2006 David Gilbert  <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.3
+
+package gnu.testlet.javax.swing.InputMap;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.InputMap;
+import javax.swing.KeyStroke;
+
+public class keys implements Testlet 
+{
+  public void test(TestHarness harness)
+  {
+    InputMap map = new InputMap();
+    KeyStroke[] k = map.keys();
+    harness.check(k, null);
+    map.put(KeyStroke.getKeyStroke('a'), "AAA");
+    k = map.keys();
+    harness.check(k.length, 1);
+    harness.check(k[0], KeyStroke.getKeyStroke('a'));
+    map.put(KeyStroke.getKeyStroke('b'), "BBB");
+    k = map.keys();
+    harness.check(k.length, 2);
+    harness.check(k[1], KeyStroke.getKeyStroke('b'));
+    map.put(KeyStroke.getKeyStroke('b'), null);
+    k = map.keys();
+    harness.check(k.length, 1);
+    harness.check(k[0], KeyStroke.getKeyStroke('a'));    
+    map.clear();
+    k = map.keys();
+    harness.check(k.length, 0);
+    
+    // check that no keys from the parent are used
+    InputMap p = new InputMap();
+    p.put(KeyStroke.getKeyStroke('z'), "ZZZ");
+    map.setParent(p);
+    k = map.keys();
+    harness.check(k.length, 0);
+  }
+}
Index: gnu/testlet/javax/swing/InputMap/put.java
===================================================================
RCS file: gnu/testlet/javax/swing/InputMap/put.java
diff -N gnu/testlet/javax/swing/InputMap/put.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/InputMap/put.java	5 Jul 2006 10:32:21 -0000
@@ -0,0 +1,50 @@
+/* put.java -- some checks for the put() method in the InputMap class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.3
+
+package gnu.testlet.javax.swing.InputMap;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.InputMap;
+import javax.swing.KeyStroke;
+
+public class put implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    InputMap m = new InputMap();
+    KeyStroke ks1 = KeyStroke.getKeyStroke('a');
+    m.put(ks1, "ABC");
+    harness.check(m.get(ks1), "ABC");
+    m.put(ks1, "DEF");
+    harness.check(m.get(ks1), "DEF");
+    m.put(ks1, null);
+    harness.check(m.get(ks1), null);
+    harness.check(m.size(), 0);
+    
+    // try null key
+    m.put(null, "ZZZ");
+    harness.check(m.get(null), null);
+  }
+}
Index: gnu/testlet/javax/swing/InputMap/remove.java
===================================================================
RCS file: gnu/testlet/javax/swing/InputMap/remove.java
diff -N gnu/testlet/javax/swing/InputMap/remove.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/InputMap/remove.java	5 Jul 2006 10:32:21 -0000
@@ -0,0 +1,64 @@
+/* remove.java -- some checks for the remove() method in the InputMap class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.3
+
+package gnu.testlet.javax.swing.InputMap;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.InputMap;
+import javax.swing.KeyStroke;
+
+public class remove implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    InputMap m = new InputMap();
+    KeyStroke ks1 = KeyStroke.getKeyStroke('a');
+    
+    // try removing from an empty map
+    m.remove(ks1);
+    harness.check(m.get(ks1), null);
+    
+    // add and remove
+    m.put(ks1, "ABC");
+    harness.check(m.get(ks1), "ABC");
+    m.remove(ks1);
+    harness.check(m.get(ks1), null);
+    
+    // try removing null
+    m.remove(null);
+    harness.check(m.size(), 0);
+    m.put(ks1, "ABC");
+    m.remove(null);
+    harness.check(m.size(), 1);
+    
+    // confirm that remove doesn't affect the parent
+    KeyStroke ks2 = KeyStroke.getKeyStroke('b');
+    InputMap p = new InputMap();
+    p.put(ks2, "ZZZ");
+    m.setParent(p);
+    m.remove(ks2);
+    harness.check(m.get(ks2), "ZZZ");
+  }
+}
Index: gnu/testlet/javax/swing/InputMap/setParent.java
===================================================================
RCS file: gnu/testlet/javax/swing/InputMap/setParent.java
diff -N gnu/testlet/javax/swing/InputMap/setParent.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/InputMap/setParent.java	5 Jul 2006 10:32:21 -0000
@@ -0,0 +1,44 @@
+/* setParent.java -- some checks for the setParent() method in the InputMap 
+       class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.3
+
+package gnu.testlet.javax.swing.InputMap;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.InputMap;
+
+public class setParent implements Testlet
+{
+  public void test(TestHarness harness)
+  {
+    InputMap m = new InputMap();
+    harness.check(m.getParent(), null);
+    InputMap p = new InputMap();
+    m.setParent(p);
+    harness.check(m.getParent(), p);
+    m.setParent(null);
+    harness.check(m.getParent(), null);
+  }
+}
Index: gnu/testlet/javax/swing/InputMap/size.java
===================================================================
RCS file: gnu/testlet/javax/swing/InputMap/size.java
diff -N gnu/testlet/javax/swing/InputMap/size.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/InputMap/size.java	5 Jul 2006 10:32:21 -0000
@@ -0,0 +1,49 @@
+/* size.java -- some checks for the size() method in the InputMap class.
+   Copyright (C) 2006 David Gilbert <david.gilbert@object-refinery.com>
+This file is part of Mauve.
+
+Mauve is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+Mauve is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Mauve; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+*/
+
+// Tags: JDK1.3
+
+package gnu.testlet.javax.swing.InputMap;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.InputMap;
+import javax.swing.KeyStroke;
+
+public class size implements Testlet 
+{
+  public void test(TestHarness harness)
+  {
+    InputMap m = new InputMap();
+    harness.check(m.size(), 0);
+    m.put(KeyStroke.getKeyStroke('a'), "ABC");
+    harness.check(m.size(), 1);
+    m.put(KeyStroke.getKeyStroke('b'), "DEF");
+    harness.check(m.size(), 2);
+    InputMap p = new InputMap();
+    p.put(KeyStroke.getKeyStroke('c'), "GHI");
+    m.setParent(p);
+    harness.check(m.size(), 2);
+    m.clear();
+    harness.check(m.size(), 0);
+  }
+}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]