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: BasicComboBoxUI tests


I added these new tests:

2005-10-18 David Gilbert <david.gilbert@object-refinery.com>

* gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createArrowButton.java: New test,
* gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createEditor.java: New test,
* gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createRenderer.java: New test,
* gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/general.java: New test,
* gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getDefaultSize.java: New test,
* gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getMaximumSize.java: New test,
* gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getMinimumSize.java: New test,
* gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getPreferredSize.java: New test,
* gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/MyBasicComboBoxUI.java: New support class,
* gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/MyBasicComboBoxUILAF.java: Likewise.


Regards,

Dave
Index: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/MyBasicComboBoxUI.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/MyBasicComboBoxUI.java
diff -N gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/MyBasicComboBoxUI.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/MyBasicComboBoxUI.java	18 Oct 2005 21:25:48 -0000
@@ -0,0 +1,72 @@
+// Tags: not-a-test
+
+// Copyright (C) 2005 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.
+
+package gnu.testlet.javax.swing.plaf.basic.BasicComboBoxUI;
+
+import java.awt.Dimension;
+
+import javax.swing.ComboBoxEditor;
+import javax.swing.JButton;
+import javax.swing.JList;
+import javax.swing.ListCellRenderer;
+import javax.swing.plaf.basic.BasicComboBoxUI;
+import javax.swing.plaf.basic.ComboPopup;
+
+/**
+ * A support class that provides access to protected methods.
+ */
+public class MyBasicComboBoxUI extends BasicComboBoxUI 
+{
+  public JButton createArrowButton() 
+  {
+    return super.createArrowButton();
+  }
+  
+  public ComboBoxEditor createEditor()
+  {
+    return super.createEditor();
+  }
+  
+  public ListCellRenderer createRenderer()
+  {
+    return super.createRenderer();
+  }
+  
+  public Dimension getDefaultSize()
+  {
+    return super.getDefaultSize();
+  }
+  
+  public Dimension getDisplaySize() 
+  {
+    return super.getDisplaySize();
+  }
+  
+  public JList getListBoxField() 
+  {
+    return this.listBox;
+  }
+  
+  public ComboPopup getComboPopupField()
+  {
+    return this.popup;
+  }
+}
Index: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/MyBasicComboBoxUILAF.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/MyBasicComboBoxUILAF.java
diff -N gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/MyBasicComboBoxUILAF.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/MyBasicComboBoxUILAF.java	18 Oct 2005 21:25:48 -0000
@@ -0,0 +1,61 @@
+// Tags: not-a-test
+
+// Copyright (C) 2005 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.
+
+package gnu.testlet.javax.swing.plaf.basic.BasicComboBoxUI;
+
+import javax.swing.UIDefaults;
+import javax.swing.plaf.basic.BasicLookAndFeel;
+
+public class MyBasicComboBoxUILAF extends BasicLookAndFeel {
+
+  public String getID() 
+  {
+    return "MyBasicLookAndFeel";
+  }
+  public String getName() 
+  {
+    return "MyBasicLookAndFeel";
+  }
+  public String getDescription() 
+  {
+    return "MyBasicLookAndFeel";
+  }
+  public boolean isSupportedLookAndFeel() 
+  {
+    return true;    
+  }
+  public boolean isNativeLookAndFeel() 
+  {
+    return false;    
+  }
+  public void initSystemColorDefaults(UIDefaults defaults)
+  {
+    super.initSystemColorDefaults(defaults);
+  }
+  public void initComponentDefaults(UIDefaults defaults)
+  {
+    super.initComponentDefaults(defaults);
+  }
+  public void initClassDefaults(UIDefaults defaults)
+  {
+    super.initClassDefaults(defaults);
+  }
+}
Index: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createArrowButton.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createArrowButton.java
diff -N gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createArrowButton.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createArrowButton.java	18 Oct 2005 21:25:48 -0000
@@ -0,0 +1,50 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 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.
+
+package gnu.testlet.javax.swing.plaf.basic.BasicComboBoxUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JButton;
+import javax.swing.plaf.basic.BasicArrowButton;
+import javax.swing.plaf.basic.BasicComboBoxUI;
+
+/**
+ * Some checks for the createArrowButton() method in the 
+ * {@link BasicComboBoxUI} class.  
+ */
+public class createArrowButton implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)  
+  {
+    MyBasicComboBoxUI ui = new MyBasicComboBoxUI();
+    JButton b = ui.createArrowButton();
+    harness.check(b instanceof BasicArrowButton);  
+  }
+
+}
Index: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createEditor.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createEditor.java
diff -N gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createEditor.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createEditor.java	18 Oct 2005 21:25:48 -0000
@@ -0,0 +1,50 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 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.
+
+package gnu.testlet.javax.swing.plaf.basic.BasicComboBoxUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.ComboBoxEditor;
+import javax.swing.plaf.basic.BasicComboBoxUI;
+import javax.swing.plaf.basic.BasicComboBoxEditor.UIResource;
+
+/**
+ * Some checks for the createEditor() method in the 
+ * {@link BasicComboBoxUI} class.  
+ */
+public class createEditor implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)  
+  {
+    MyBasicComboBoxUI ui = new MyBasicComboBoxUI();
+    ComboBoxEditor editor = ui.createEditor();
+    harness.check(editor instanceof UIResource);  
+  }
+
+}
Index: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createRenderer.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createRenderer.java
diff -N gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createRenderer.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/createRenderer.java	18 Oct 2005 21:25:48 -0000
@@ -0,0 +1,91 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 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.
+
+package gnu.testlet.javax.swing.plaf.basic.BasicComboBoxUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Font;
+
+import javax.swing.JComboBox;
+import javax.swing.ListCellRenderer;
+import javax.swing.UIManager;
+import javax.swing.plaf.basic.BasicComboBoxUI;
+
+/**
+ * Some checks for the createRenderer() method in the 
+ * {@link BasicComboBoxUI} class.  
+ */
+public class createRenderer implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)  
+  {
+    try
+    {
+      UIManager.setLookAndFeel(new MyBasicComboBoxUILAF());
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+    }
+    
+    // use this to check that the defaults are just those for a JLabel
+    UIManager.put("Label.font", new Font("Dialog", Font.PLAIN, 21));
+    UIManager.put("Label.foreground", Color.green);
+    UIManager.put("Label.background", Color.yellow);
+    
+    MyBasicComboBoxUI ui = new MyBasicComboBoxUI();
+    ListCellRenderer renderer = ui.createRenderer();
+    Component c = (Component) renderer;
+    
+    harness.check(c.getFont(), new Font("Dialog", Font.PLAIN, 21));
+    harness.check(c.getForeground(), Color.green);
+    harness.check(c.getBackground(), Color.yellow);
+    
+    // confirm that the method creates a new instance every time
+    ListCellRenderer renderer2 = ui.createRenderer();
+    harness.check(renderer != renderer2);
+    
+    JComboBox cb = new JComboBox();
+    ListCellRenderer renderer3 = cb.getRenderer();
+    Component c3 = (Component) renderer3;
+    harness.check(c3.getFont(), new Font("Dialog", Font.PLAIN, 21));
+    harness.check(c3.getForeground(), Color.green);
+    harness.check(c3.getBackground(), Color.yellow);
+    
+    // changing the font on the combo box doesn't update the renderer font
+    cb.setFont(new Font("Dialog", Font.BOLD, 10));
+    harness.check(c3.getFont(), new Font("Dialog", Font.PLAIN, 21));
+    ListCellRenderer renderer4 = cb.getRenderer();
+    harness.check(renderer3 == renderer4);
+    
+  }
+
+}
Index: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/general.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/general.java
diff -N gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/general.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/general.java	18 Oct 2005 21:25:48 -0000
@@ -0,0 +1,53 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 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.
+
+package gnu.testlet.javax.swing.plaf.basic.BasicComboBoxUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JComboBox;
+import javax.swing.JList;
+import javax.swing.plaf.basic.BasicComboBoxUI;
+
+/**
+ * Some checks for the createUI() method in the 
+ * {@link BasicComboBoxUI} class.  
+ */
+public class general implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)  
+  {
+    JComboBox cb = new JComboBox();
+    MyBasicComboBoxUI ui = new MyBasicComboBoxUI();
+    cb.setUI(ui);
+    JList list1 = ui.getListBoxField();
+    JList list2 = ui.getComboPopupField().getList();
+    harness.check(list1 == list2);
+  }
+
+}
\ No newline at end of file
Index: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getDefaultSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getDefaultSize.java
diff -N gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getDefaultSize.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getDefaultSize.java	18 Oct 2005 21:25:48 -0000
@@ -0,0 +1,68 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 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.
+
+package gnu.testlet.javax.swing.plaf.basic.BasicComboBoxUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+
+import javax.swing.JComboBox;
+import javax.swing.plaf.basic.BasicComboBoxUI;
+
+/**
+ * Some checks for the getDefaultSize() method in the 
+ * {@link BasicComboBoxUI} class.  
+ */
+public class getDefaultSize implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)  
+  {
+    JComboBox cb = new JComboBox();
+    MyBasicComboBoxUI ui = new MyBasicComboBoxUI();
+    cb.setUI(ui);
+    int additionalHeight = 2;  // margin?  border?
+    int additionalWidth = 2;  
+    FontMetrics fm = cb.getFontMetrics(cb.getFont());
+    
+    // the following width calculation is a guess.  We know the value
+    // depends on the font size, and that it is relatively small, so after
+    // trying out a few candidates this one seems to give the right result
+    int width = fm.charWidth(' ') + additionalWidth;
+    int height = fm.getHeight() + additionalHeight;
+    harness.check(ui.getDefaultSize(), new Dimension(width, height));
+    cb.setFont(new Font("Dialog", Font.PLAIN, 32));
+    fm = cb.getFontMetrics(cb.getFont());
+    width = fm.charWidth(' ') + additionalWidth;
+    height = fm.getHeight() + additionalHeight;
+    harness.check(ui.getDefaultSize(), new Dimension(width, height));
+  }
+
+}
Index: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getMaximumSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getMaximumSize.java
diff -N gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getMaximumSize.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getMaximumSize.java	18 Oct 2005 21:25:48 -0000
@@ -0,0 +1,52 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 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.
+
+package gnu.testlet.javax.swing.plaf.basic.BasicComboBoxUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Dimension;
+
+import javax.swing.JComboBox;
+import javax.swing.plaf.basic.BasicComboBoxUI;
+
+/**
+ * Some checks for the getMaximumSize() method in the 
+ * {@link BasicComboBoxUI} class.  
+ */
+public class getMaximumSize implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)  
+  {
+    JComboBox cb = new JComboBox();
+    BasicComboBoxUI ui = new BasicComboBoxUI();
+    cb.setUI(ui);
+    harness.check(ui.getMaximumSize(cb), new Dimension(32767, 32767));  
+  }
+
+}
Index: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getMinimumSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getMinimumSize.java
diff -N gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getMinimumSize.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getMinimumSize.java	18 Oct 2005 21:25:48 -0000
@@ -0,0 +1,74 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 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.
+
+package gnu.testlet.javax.swing.plaf.basic.BasicComboBoxUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Dimension;
+import java.awt.FontMetrics;
+
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JComboBox;
+import javax.swing.plaf.basic.BasicComboBoxUI;
+
+/**
+ * Some checks for the getMinimumSize() method in the 
+ * {@link BasicComboBoxUI} class.  
+ */
+public class getMinimumSize implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)  
+  {
+    JComboBox cb = new JComboBox();
+    BasicComboBoxUI ui = new BasicComboBoxUI();
+    cb.setUI(ui);
+    int additionalHeight = 2;  // margin?  border?
+    int additionalWidth = 2;  
+    FontMetrics fm = cb.getFontMetrics(cb.getFont());
+    
+    // the following width calculation is a guess.  We know the value
+    // depends on the font size, and that it is relatively small, so after
+    // trying out a few candidates this one seems to give the right result
+    int width = fm.charWidth(' ') + additionalWidth;
+    int height = fm.getHeight() + additionalHeight;
+    harness.check(ui.getMinimumSize(cb), new Dimension(width + height, height));
+                   // the width is the display width plus the button width and
+                   // the button width is equal to 'height'
+    
+    cb.setModel(new DefaultComboBoxModel(new Object[] {"X"}));
+    width = fm.charWidth('X') + additionalWidth;
+    harness.check(ui.getMinimumSize(cb), new Dimension(width + height, height));
+    
+    cb.setPrototypeDisplayValue("XX");    
+    width = fm.stringWidth("XX") + additionalWidth;
+    harness.check(ui.getMinimumSize(cb), new Dimension(width + height, height));
+    
+  }
+
+}
Index: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getPreferredSize.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getPreferredSize.java
diff -N gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getPreferredSize.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/basic/BasicComboBoxUI/getPreferredSize.java	18 Oct 2005 21:25:48 -0000
@@ -0,0 +1,76 @@
+// Tags: JDK1.2
+
+// Copyright (C) 2005 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.
+
+package gnu.testlet.javax.swing.plaf.basic.BasicComboBoxUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Dimension;
+import java.awt.FontMetrics;
+
+import javax.swing.DefaultComboBoxModel;
+import javax.swing.JComboBox;
+import javax.swing.plaf.basic.BasicComboBoxUI;
+
+/**
+ * Some checks for the getPreferredSize() method in the 
+ * {@link BasicComboBoxUI} class.  
+ */
+public class getPreferredSize implements Testlet 
+{
+
+  /**
+   * Runs the test using the specified harness.
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)  
+  {
+    JComboBox cb = new JComboBox();
+    BasicComboBoxUI ui = new BasicComboBoxUI();
+    cb.setUI(ui);
+    int additionalHeight = 2;  // margin?  border?
+    int additionalWidth = 2;  
+    FontMetrics fm = cb.getFontMetrics(cb.getFont());
+    
+    // the following width calculation is a guess.  We know the value
+    // depends on the font size, and that it is relatively small, so after
+    // trying out a few candidates this one seems to give the right result
+    int width = fm.charWidth(' ') + additionalWidth;
+    int height = fm.getHeight() + additionalHeight;
+    harness.check(ui.getPreferredSize(cb), 
+            new Dimension(width + height, height));
+                   // the width is the display width plus the button width and
+                   // the button width is equal to 'height'
+    
+    cb.setModel(new DefaultComboBoxModel(new Object[] {"X"}));
+    width = fm.charWidth('X') + additionalWidth;
+    harness.check(ui.getPreferredSize(cb), 
+            new Dimension(width + height, height));
+    
+    cb.setPrototypeDisplayValue("XX");    
+    width = fm.stringWidth("XX") + additionalWidth;
+    harness.check(ui.getPreferredSize(cb), 
+            new Dimension(width + height, height));
+  }
+
+}
\ No newline at end of file

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