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: MetalScrollBarUI - additional checks


This patch adds some new checks for the MetalScrollBarUI class. The setting of the scrollBarWidth field at the right time is important to make the JGoodies PlasticLookAndFeel work on GNU Classpath:

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

	* gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/constructor.java
	(test): Add a check for the default value of the scrollBarWidth field,
	* gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/installDefaults.java:
	New file,
	* gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/MyMetalScrollBarUI.java
	(MyMetalScrollBarUI): Call super(),
	(installDefaults): New method,
	(setScrollbar): Likewise,
	(getScrollBarWidthField): Likewise.

I have a patch for GNU Classpath to make these new checks all pass.

Regards,

Dave
Index: gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/MyMetalScrollBarUI.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/MyMetalScrollBarUI.java,v
retrieving revision 1.1
diff -u -r1.1 MyMetalScrollBarUI.java
--- gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/MyMetalScrollBarUI.java	24 Oct 2005 21:26:22 -0000	1.1
+++ gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/MyMetalScrollBarUI.java	7 Sep 2006 09:18:53 -0000
@@ -1,6 +1,6 @@
 // Tags: not-a-test
 
-// 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.
 
@@ -24,15 +24,40 @@
 import java.awt.Dimension;
 import java.awt.Rectangle;
 
+import javax.swing.JScrollBar;
 import javax.swing.plaf.metal.MetalScrollBarUI;
 
 /**
- * Provides access to protected methods.
+ * Provides access to protected methods for testing purposes.
  */
 public class MyMetalScrollBarUI extends MetalScrollBarUI {
 
   public MyMetalScrollBarUI() 
   {
+    super();
+  }
+  
+  /**
+   * Overrides installDefaults() to enable public access in tests.
+   */
+  public void installDefaults()
+  {
+    super.installDefaults();
+  }
+  
+  /**
+   * Sets the value of the (otherwise protected) field scrollbar.
+   *
+   * @param sb the scrollbar to set
+   */
+  public void setScrollbar(JScrollBar sb)
+  {
+    scrollbar = sb;
+  }
+
+  public int getScrollBarWidthField()
+  {
+    return this.scrollBarWidth;
   }
   
   public Dimension getMinimumThumbSize()
Index: gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/constructor.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/constructor.java,v
retrieving revision 1.1
diff -u -r1.1 constructor.java
--- gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/constructor.java	24 Oct 2005 21:26:22 -0000	1.1
+++ gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/constructor.java	7 Sep 2006 09:18:53 -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.
 
@@ -58,6 +58,7 @@
     MyMetalScrollBarUI ui = new MyMetalScrollBarUI();
     harness.check(ui.getTrackBounds(), null);
     harness.check(ui.getThumbBounds(), null);
+    harness.check(ui.getScrollBarWidthField(), 0);
     
     JScrollBar scrollBar = new JScrollBar(JScrollBar.HORIZONTAL);
     scrollBar.setUI(ui);
Index: gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/installDefaults.java
===================================================================
RCS file: gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/installDefaults.java
diff -N gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/installDefaults.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/javax/swing/plaf/metal/MetalScrollBarUI/installDefaults.java	7 Sep 2006 09:18:54 -0000
@@ -0,0 +1,60 @@
+/* installDefaults.java -- some checks for the installDefaults() method in the
+       MetalScrollBarUI 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.5
+
+package gnu.testlet.javax.swing.plaf.metal.MetalScrollBarUI;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import javax.swing.JScrollBar;
+import javax.swing.UIManager;
+import javax.swing.plaf.metal.MetalLookAndFeel;
+
+/**
+ * Some tests for the initialisation performed in the installDefaults() method.
+ */
+public class installDefaults implements Testlet
+{
+  
+  public void test(TestHarness harness)
+  {
+    // use a known look and feel
+    try
+    {
+      UIManager.setLookAndFeel(new MetalLookAndFeel());
+    }
+    catch (Exception e)
+    {
+      e.printStackTrace();
+    }    
+    MyMetalScrollBarUI ui = new MyMetalScrollBarUI();
+    harness.check(ui.getScrollBarWidthField(), 0);
+    ui.setScrollbar(new JScrollBar());
+    ui.installDefaults();
+    
+    // the scrollBarWidth field must be initialised, the JGoodies Plastic
+    // look and feel relies on this...
+    harness.check(ui.getScrollBarWidthField(), 17);    
+  }
+}

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