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: MetalComboBoxUI test fixes


This patch brings these tests in line with JDK 1.5, and cleans up any custom look and feel settings at the end of each test:

2006-02-01 David Gilbert <david.gilbert@object-refinery.com>

* gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getDisplaySize.java
(testNotEditable): Set theme,
(testEditable): Set MetalLookAndFeel at end,
* gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getMinimumSize.java
(test): Set known look and feel,
(testEditable): Updated expected values,
(testEditableWithCustomFont): Likewise,
* gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getPreferredSize.java
(testEditable): Updated expected values.


Regards,

Dave
Index: gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getDisplaySize.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getDisplaySize.java,v
retrieving revision 1.1
diff -u -r1.1 getDisplaySize.java
--- gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getDisplaySize.java	7 Nov 2005 22:04:27 -0000	1.1
+++ gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getDisplaySize.java	1 Feb 2006 14:58:21 -0000
@@ -1,6 +1,6 @@
 // Tags: JDK1.2
 
-// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+// Copyright (C) 2005, 2006 David Gilbert <david.gilbert@object-refinery.com>
 
 // This file is part of Mauve.
 
@@ -33,6 +33,7 @@
 import javax.swing.JTextField;
 import javax.swing.UIManager;
 import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.metal.DefaultMetalTheme;
 import javax.swing.plaf.metal.MetalComboBoxUI;
 import javax.swing.plaf.metal.MetalLookAndFeel;
 
@@ -63,6 +64,7 @@
   {
     try
     {
+      MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
       UIManager.setLookAndFeel(new MetalLookAndFeel());
     }
     catch (UnsupportedLookAndFeelException e)
@@ -140,6 +142,16 @@
     cb.setPrototypeDisplayValue("Long Prototype Display Value");
     width = fm.stringWidth("Long Prototype Display Value") + 2;
     harness.check(ui.getDisplaySize(), new Dimension(width, height));
+    
+    // restore a sane look and feel
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+    }
   }
 
 }
Index: gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getMinimumSize.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getMinimumSize.java,v
retrieving revision 1.1
diff -u -r1.1 getMinimumSize.java
--- gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getMinimumSize.java	7 Nov 2005 22:04:27 -0000	1.1
+++ gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getMinimumSize.java	1 Feb 2006 14:58:22 -0000
@@ -1,6 +1,6 @@
-// Tags: JDK1.2
+// Tags: JDK1.5
 
-// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+// Copyright (C) 2005, 2006 David Gilbert <david.gilbert@object-refinery.com>
 
 // This file is part of Mauve.
 
@@ -32,9 +32,13 @@
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.JComboBox;
 import javax.swing.JTextField;
+import javax.swing.UIManager;
+import javax.swing.UnsupportedLookAndFeelException;
+import javax.swing.plaf.metal.DefaultMetalTheme;
 import javax.swing.plaf.metal.MetalComboBoxButton;
 import javax.swing.plaf.metal.MetalComboBoxIcon;
 import javax.swing.plaf.metal.MetalComboBoxUI;
+import javax.swing.plaf.metal.MetalLookAndFeel;
 
 /**
  * Some checks for the getMinimumSize() method in the 
@@ -50,6 +54,16 @@
    */
   public void test(TestHarness harness)
   {
+    // test with a known LAF/theme
+    try
+    {
+      MetalLookAndFeel.setCurrentTheme(new DefaultMetalTheme());
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+    }
+    catch (UnsupportedLookAndFeelException e)
+    {
+      e.printStackTrace();
+    }
     test1(harness);
     test2(harness);
     testEditable(harness);
@@ -133,7 +147,7 @@
     cb.setEditable(true);
     Insets tfInsets = tf.getInsets();
     FontMetrics fm = cb.getFontMetrics(cb.getFont());
-    int height = fm.getHeight() + tfInsets.top + tfInsets.bottom + 1;
+    int height = fm.getHeight() + tfInsets.top + tfInsets.bottom + 5;
     int width = fm.stringWidth("m") * tf.getColumns() + tfInsets.left 
         + tfInsets.right + height + 3; 
     harness.check(ui.getPreferredSize(cb), new Dimension(width, height));    
@@ -151,7 +165,7 @@
     Insets tfInsets2 = tf2.getInsets();
     cb2.setFont(new Font("Dialog", Font.PLAIN, 24));
     FontMetrics fm2 = cb2.getFontMetrics(cb2.getFont());
-    int height2 = fm2.getHeight() + tfInsets2.top + tfInsets2.bottom + 1;
+    int height2 = fm2.getHeight() + tfInsets2.top + tfInsets2.bottom + 5;
     int width2 = fm2.stringWidth("m") * tf2.getColumns() + tfInsets2.left 
         + tfInsets2.right + height2 + 3; 
     harness.check(ui2.getPreferredSize(cb2), new Dimension(width2, height2));    
@@ -177,7 +191,7 @@
     cb.setEditable(true);
     Insets tfInsets = tf.getInsets();
     FontMetrics fm = cb.getFontMetrics(cb.getFont());
-    int height = fm.getHeight() + tfInsets.top + tfInsets.bottom + 1;
+    int height = fm.getHeight() + tfInsets.top + tfInsets.bottom + 5;
     int width = fm.stringWidth("m") * tf.getColumns() + tfInsets.left 
         + tfInsets.right + height + 3; 
     harness.check(ui.getPreferredSize(cb), new Dimension(width, height));    
@@ -195,7 +209,7 @@
     Insets tfInsets2 = tf2.getInsets();
     cb2.setFont(new Font("Dialog", Font.PLAIN, 24));
     FontMetrics fm2 = cb2.getFontMetrics(cb2.getFont());
-    int height2 = fm2.getHeight() + tfInsets2.top + tfInsets2.bottom + 1;
+    int height2 = fm2.getHeight() + tfInsets2.top + tfInsets2.bottom + 5;
     int width2 = fm2.stringWidth("m") * tf2.getColumns() + tfInsets2.left 
         + tfInsets2.right + height2 + 3; 
     harness.check(ui2.getPreferredSize(cb2), new Dimension(width2, height2));    
Index: gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getPreferredSize.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getPreferredSize.java,v
retrieving revision 1.1
diff -u -r1.1 getPreferredSize.java
--- gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getPreferredSize.java	7 Nov 2005 22:04:27 -0000	1.1
+++ gnu/testlet/javax/swing/plaf/metal/MetalComboBoxUI/getPreferredSize.java	1 Feb 2006 14:58:22 -0000
@@ -1,6 +1,6 @@
-// Tags: JDK1.2
+// Tags: JDK1.5
 
-// Copyright (C) 2005 David Gilbert <david.gilbert@object-refinery.com>
+// Copyright (C) 2005, 2006 David Gilbert <david.gilbert@object-refinery.com>
 
 // This file is part of Mauve.
 
@@ -93,7 +93,7 @@
     Insets tfInsets = tf.getInsets();
     System.out.println("tfInsets = " + tfInsets);
     FontMetrics fm = cb.getFontMetrics(cb.getFont());
-    int height = fm.getHeight() + tfInsets.top + tfInsets.bottom + 1;
+    int height = fm.getHeight() + tfInsets.top + tfInsets.bottom + 5;
     int width = fm.stringWidth("m") * tf.getColumns() + tfInsets.left 
         + tfInsets.right + height + 3; 
     harness.check(ui.getPreferredSize(cb), new Dimension(width, height));    
@@ -111,7 +111,7 @@
     Insets tfInsets2 = tf2.getInsets();
     cb2.setFont(new Font("Dialog", Font.PLAIN, 24));
     FontMetrics fm2 = cb2.getFontMetrics(cb2.getFont());
-    int height2 = fm2.getHeight() + tfInsets2.top + tfInsets2.bottom + 1;
+    int height2 = fm2.getHeight() + tfInsets2.top + tfInsets2.bottom + 5;
     int width2 = fm2.stringWidth("m") * tf2.getColumns() + tfInsets2.left 
         + tfInsets2.right + height2 + 3; 
     harness.check(ui2.getPreferredSize(cb2), new Dimension(width2, height2));    

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