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]

Patch: New AWT widget painting tests


Tests to make sure that these AWT widgets are painted on top of a
background image, not behind.

2006-03-10  Lillian Angel  <langel@redhat.com>

        * gnu/testlet/java/awt/Button/PaintTest.java: New Test.
        * gnu/testlet/java/awt/Canvas/PaintTest.java: New Test.
        * gnu/testlet/java/awt/Checkbox/PaintTest.java: New Test.
        * gnu/testlet/java/awt/Label/PaintTest.java: New Test.
        * gnu/testlet/java/awt/List/ScrollbarPaintTest.java: New Test.
        * gnu/testlet/java/awt/ScrollPane/ScrollbarPaintTest.java: New
Test.
        * gnu/testlet/java/awt/Scrollbar/ScrollbarPaintTest.java: New
Test.
        * gnu/testlet/java/awt/TextArea/ScrollbarPaintTest.java: New
Test.
        * gnu/testlet/java/awt/TextField/PaintTest.java: New Test.
        * gnu/testlet/java/awt/Choice/PaintTest.java: New Test.

Index: gnu/testlet/java/awt/Choice/PaintTest.java
===================================================================
RCS file: gnu/testlet/java/awt/Choice/PaintTest.java
diff -N gnu/testlet/java/awt/Choice/PaintTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/Choice/PaintTest.java	10 Mar 2006 18:43:06 -0000
@@ -0,0 +1,90 @@
+/* PaintTest.java -- 
+   Copyright (C) 2006 Red Hat
+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: GUI, JDK 1.0
+
+package gnu.testlet.java.awt.Choice;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+import gnu.testlet.java.awt.LocationTests;
+
+import java.awt.Choice;
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+
+public class PaintTest
+    extends Panel
+    implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness. 
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)
+  {
+    setBackground(Color.red);
+    Frame f = new Frame();
+    Choice c = new Choice();
+    c.setBackground(Color.blue);
+    add(c);
+    f.add(this);
+    f.pack();
+    f.show();
+    Rectangle bounds = c.getBounds();
+    Insets i = f.getInsets();
+    Point loc = f.getLocationOnScreen();
+    bounds.x += i.left + loc.x;
+    bounds.y += i.top + loc.y;
+    
+    Robot r = harness.createRobot();
+    Color choice = r.getPixelColor(bounds.x, bounds.y + bounds.height/2);
+    harness.check(choice.equals(Color.BLUE));
+    
+    // There is a delay to avoid any race conditions    
+    // and so user can see frame
+    r.waitForIdle();
+    r.delay(1000);
+  }
+
+  public void paint(Graphics g)
+  {
+    Image offScr = createImage(getSize().width, getSize().height);
+    Graphics offG = offScr.getGraphics();
+    offG.setClip(0, 0, getSize().width, getSize().height);
+
+    super.paint(offG);
+    g.drawImage(offScr, 0, 0, null);
+
+    offG.dispose();
+  }
+}
+
+
Index: gnu/testlet/java/awt/Button/PaintTest.java
===================================================================
RCS file: gnu/testlet/java/awt/Button/PaintTest.java
diff -N gnu/testlet/java/awt/Button/PaintTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/Button/PaintTest.java	10 Mar 2006 18:43:19 -0000
@@ -0,0 +1,89 @@
+/* PaintTest.java -- 
+   Copyright (C) 2006 Red Hat
+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: GUI, JDK 1.0
+
+package gnu.testlet.java.awt.Button;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+import gnu.testlet.java.awt.LocationTests;
+
+import java.awt.Button;
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+
+public class PaintTest
+    extends Panel
+    implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness. 
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)
+  {
+    setBackground(Color.red);
+    Frame f = new Frame();
+    Button b = new Button("        ");
+    b.setBackground(Color.blue);
+    add(b);
+    f.add(this);
+    f.pack();
+    f.show();
+    Rectangle bounds = b.getBounds();
+    Point loc = f.getLocationOnScreen();
+    Insets i = f.getInsets();
+    bounds.x += i.left + loc.x;
+    bounds.y += i.top + loc.y;
+    
+    Robot r = harness.createRobot();
+    Color but = r.getPixelColor(bounds.x + bounds.width/2, bounds.y + bounds.height/2);
+    harness.check(!but.equals(Color.red));
+    
+    // There is a delay to avoid any race conditions    
+    // and so user can see frame
+    r.waitForIdle();
+    r.delay(1000);
+  }
+
+  public void paint(Graphics g)
+  {
+    Image offScr = createImage(getSize().width, getSize().height);
+    Graphics offG = offScr.getGraphics();
+    offG.setClip(0, 0, getSize().width, getSize().height);
+
+    super.paint(offG);
+    g.drawImage(offScr, 0, 0, null);
+
+    offG.dispose();
+  }
+}
+
Index: gnu/testlet/java/awt/Canvas/PaintTest.java
===================================================================
RCS file: gnu/testlet/java/awt/Canvas/PaintTest.java
diff -N gnu/testlet/java/awt/Canvas/PaintTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/Canvas/PaintTest.java	10 Mar 2006 18:43:19 -0000
@@ -0,0 +1,89 @@
+/* PaintTest.java -- 
+   Copyright (C) 2006 Red Hat
+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: GUI, JDK 1.0
+
+package gnu.testlet.java.awt.Canvas;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+import gnu.testlet.java.awt.LocationTests;
+
+import java.awt.Canvas;
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+
+public class PaintTest
+    extends Panel
+    implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness. 
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)
+  {
+    setBackground(Color.red);
+    Frame f = new Frame();
+    Canvas c = new Canvas();
+    c.setBackground(Color.blue);
+    c.setSize(100,100);
+    add(c);
+    f.add(this);
+    f.pack();
+    f.show();
+    Point loc = f.getLocationOnScreen();
+    Rectangle bounds = c.getBounds();
+    Insets i = f.getInsets();
+    bounds.x += i.left + loc.x;
+    bounds.y += i.top + loc.y;
+    
+    Robot r = harness.createRobot();
+    LocationTests.checkRectangleCornerColors(harness, r, bounds, Color.blue, true);
+    
+    // There is a delay to avoid any race conditions    
+    // and so user can see frame
+    r.waitForIdle();
+    r.delay(1000);
+  }
+
+  public void paint(Graphics g)
+  {
+    Image offScr = createImage(getSize().width, getSize().height);
+    Graphics offG = offScr.getGraphics();
+    offG.setClip(0, 0, getSize().width, getSize().height);
+
+    super.paint(offG);
+    g.drawImage(offScr, 0, 0, null);
+
+    offG.dispose();
+  }
+}
+
Index: gnu/testlet/java/awt/Checkbox/PaintTest.java
===================================================================
RCS file: gnu/testlet/java/awt/Checkbox/PaintTest.java
diff -N gnu/testlet/java/awt/Checkbox/PaintTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/Checkbox/PaintTest.java	10 Mar 2006 18:43:19 -0000
@@ -0,0 +1,90 @@
+/* PaintTest.java -- 
+   Copyright (C) 2006 Red Hat
+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: GUI, JDK 1.0
+
+package gnu.testlet.java.awt.Checkbox;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+import gnu.testlet.java.awt.LocationTests;
+
+import java.awt.Checkbox;
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+
+public class PaintTest
+    extends Panel
+    implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness. 
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)
+  {
+    setBackground(Color.red);
+    Frame f = new Frame();
+    Checkbox c = new Checkbox("check!");
+    c.setBackground(Color.blue);
+    add(c);
+    f.add(this);
+    f.pack();
+    f.show();
+    Point loc = f.getLocationOnScreen();
+    Rectangle bounds = c.getBounds();
+    Insets i = f.getInsets();
+    bounds.x += i.left + loc.x;
+    bounds.y += i.top + loc.y;
+    
+    Robot r = harness.createRobot();
+    Color check = r.getPixelColor(bounds.x + bounds.width/2, bounds.y + bounds.height/2);
+    harness.check(check.equals(Color.blue));
+    
+    // There is a delay to avoid any race conditions    
+    // and so user can see frame
+    r.waitForIdle();
+    r.delay(1000);
+  }
+
+  public void paint(Graphics g)
+  {
+    Image offScr = createImage(getSize().width, getSize().height);
+    Graphics offG = offScr.getGraphics();
+    offG.setClip(0, 0, getSize().width, getSize().height);
+
+    super.paint(offG);
+    g.drawImage(offScr, 0, 0, null);
+
+    offG.dispose();
+  }
+}
+
+
Index: gnu/testlet/java/awt/Label/PaintTest.java
===================================================================
RCS file: gnu/testlet/java/awt/Label/PaintTest.java
diff -N gnu/testlet/java/awt/Label/PaintTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/Label/PaintTest.java	10 Mar 2006 18:43:19 -0000
@@ -0,0 +1,90 @@
+/* PaintTest.java -- 
+   Copyright (C) 2006 Red Hat
+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: GUI, JDK 1.0
+
+package gnu.testlet.java.awt.Label;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+import gnu.testlet.java.awt.LocationTests;
+
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Label;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+
+public class PaintTest
+    extends Panel
+    implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness. 
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)
+  {
+    setBackground(Color.red);
+    Frame f = new Frame();
+    Label c = new Label("label");
+    c.setBackground(Color.blue);
+    add(c);
+    f.add(this);
+    f.pack();
+    f.show();
+    Point loc = f.getLocationOnScreen();
+    Rectangle bounds = c.getBounds();
+    Insets i = f.getInsets();
+    bounds.x += loc.x + i.left;
+    bounds.y += loc.y + i.top;
+    
+    Robot r = harness.createRobot();
+    Color label = r.getPixelColor(bounds.x + bounds.width/2 ,bounds.y + bounds.height/2 + 5);
+    harness.check(label.equals(Color.blue));
+    
+    // There is a delay to avoid any race conditions    
+    // and so user can see frame
+    r.waitForIdle();
+    r.delay(1000);
+  }
+
+  public void paint(Graphics g)
+  {
+    Image offScr = createImage(getSize().width, getSize().height);
+    Graphics offG = offScr.getGraphics();
+    offG.setClip(0, 0, getSize().width, getSize().height);
+
+    super.paint(offG);
+    g.drawImage(offScr, 0, 0, null);
+
+    offG.dispose();
+  }
+}
+
+
Index: gnu/testlet/java/awt/List/ScrollbarPaintTest.java
===================================================================
RCS file: gnu/testlet/java/awt/List/ScrollbarPaintTest.java
diff -N gnu/testlet/java/awt/List/ScrollbarPaintTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/List/ScrollbarPaintTest.java	10 Mar 2006 18:43:19 -0000
@@ -0,0 +1,96 @@
+/* ScrollbarPaintTest.java -- 
+   Copyright (C) 2006 Red Hat
+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: GUI, JDK 1.0
+
+package gnu.testlet.java.awt.List;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.List;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+
+public class ScrollbarPaintTest
+    extends Panel
+    implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness. 
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)
+  {
+    setBackground(Color.red);
+    Frame f = new Frame();
+    List c = new List(2);
+    c.add("1");
+    c.add("2");
+    c.add("3");
+    add(c);
+    f.add(this);
+    f.pack();
+    f.show();
+    Rectangle bounds = c.getBounds();
+    Insets i = f.getInsets();
+    Point loc = f.getLocationOnScreen();
+    loc.x += i.left + bounds.x;
+    loc.y += i.top + bounds.y;
+    bounds.x += i.left;
+    bounds.y += i.top;
+    
+    Robot r = harness.createRobot();
+    Color scroll = r.getPixelColor(loc.x + bounds.width - i.left, loc.y + bounds.height/2);
+    
+    // Check if scrollbar was painted.
+    harness.check(!(scroll.equals(Color.white)));
+    harness.check(!(scroll.equals(Color.red)));
+    
+    // There is a delay to avoid any race conditions    
+    // and so user can see frame
+    r.waitForIdle();
+    r.delay(1000);
+  }
+
+  public void paint(Graphics g)
+  {
+    Image offScr = createImage(getSize().width, getSize().height);
+    Graphics offG = offScr.getGraphics();
+    offG.setClip(0, 0, getSize().width, getSize().height);
+
+    super.paint(offG);
+    g.drawImage(offScr, 0, 0, null);
+
+    offG.dispose();
+  }
+}
+
+
Index: gnu/testlet/java/awt/ScrollPane/ScrollbarPaintTest.java
===================================================================
RCS file: gnu/testlet/java/awt/ScrollPane/ScrollbarPaintTest.java
diff -N gnu/testlet/java/awt/ScrollPane/ScrollbarPaintTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/ScrollPane/ScrollbarPaintTest.java	10 Mar 2006 18:43:19 -0000
@@ -0,0 +1,90 @@
+/* ScrollbarPaintTest.java -- 
+   Copyright (C) 2006 Red Hat
+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: GUI, JDK 1.0
+
+package gnu.testlet.java.awt.ScrollPane;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.ScrollPane;
+
+public class ScrollbarPaintTest
+    extends Panel
+    implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness. 
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)
+  {
+    setBackground(Color.red);
+    Frame f = new Frame();
+    ScrollPane c = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
+    add(c);
+    f.add(this);
+    f.pack();
+    f.show();
+    Rectangle bounds = c.getBounds();
+    Insets i = f.getInsets();
+    Point loc = f.getLocationOnScreen();
+    loc.x += i.left + bounds.x;
+    loc.y += i.top + bounds.y;
+    bounds.width -= (i.left + i.right);
+    bounds.height -= (i.top + i.bottom);
+    
+    Robot r = harness.createRobot();
+    Color scroll = r.getPixelColor(loc.x + bounds.width, loc.y + bounds.height/2);
+    harness.check(!(scroll.equals(Color.red)));
+    
+    // There is a delay to avoid any race conditions    
+    // and so user can see frame
+    r.waitForIdle();
+    r.delay(2000);
+  }
+
+  public void paint(Graphics g)
+  {
+    Image offScr = createImage(getSize().width, getSize().height);
+    Graphics offG = offScr.getGraphics();
+    offG.setClip(0, 0, getSize().width, getSize().height);
+
+    super.paint(offG);
+    g.drawImage(offScr, 0, 0, null);
+
+    offG.dispose();
+  }
+}
+
+
Index: gnu/testlet/java/awt/Scrollbar/ScrollbarPaintTest.java
===================================================================
RCS file: gnu/testlet/java/awt/Scrollbar/ScrollbarPaintTest.java
diff -N gnu/testlet/java/awt/Scrollbar/ScrollbarPaintTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/Scrollbar/ScrollbarPaintTest.java	10 Mar 2006 18:43:19 -0000
@@ -0,0 +1,94 @@
+/* ScrollbarPaintTest.java -- 
+   Copyright (C) 2006 Red Hat
+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: GUI, JDK 1.0
+
+package gnu.testlet.java.awt.Scrollbar;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.Scrollbar;
+
+public class ScrollbarPaintTest
+    extends Panel
+    implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness. 
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)
+  {
+    setBackground(Color.red);
+    Frame f = new Frame();
+    Scrollbar c = new Scrollbar();
+    add(c);
+    f.add(this);
+    f.pack();
+    f.show();
+    Rectangle bounds = c.getBounds();
+    Insets i = f.getInsets();
+    Point loc = f.getLocationOnScreen();
+    loc.x += i.left + bounds.x;
+    loc.y += i.top + bounds.y;
+    bounds.x += i.left;
+    bounds.y += i.top;
+    bounds.width -= (i.left + i.right);
+    bounds.height -= (i.top + i.bottom);
+    
+    Robot r = harness.createRobot();
+    Color scroll = r.getPixelColor(loc.x + bounds.width, loc.y + bounds.height/2);
+
+    // Check if scrollbar was painted.
+    harness.check(!(scroll.equals(Color.red)));
+    
+    // There is a delay to avoid any race conditions    
+    // and so user can see frame
+    r.waitForIdle();
+    r.delay(1000);
+  }
+
+  public void paint(Graphics g)
+  {
+    Image offScr = createImage(getSize().width, getSize().height);
+    Graphics offG = offScr.getGraphics();
+    offG.setClip(0, 0, getSize().width, getSize().height);
+
+    super.paint(offG);
+    g.drawImage(offScr, 0, 0, null);
+
+    offG.dispose();
+  }
+}
+
+
Index: gnu/testlet/java/awt/TextArea/ScrollbarPaintTest.java
===================================================================
RCS file: gnu/testlet/java/awt/TextArea/ScrollbarPaintTest.java
diff -N gnu/testlet/java/awt/TextArea/ScrollbarPaintTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/TextArea/ScrollbarPaintTest.java	10 Mar 2006 18:43:19 -0000
@@ -0,0 +1,88 @@
+/* ScrollbarPaintTest.java -- 
+   Copyright (C) 2006 Red Hat
+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: GUI, JDK 1.0
+
+package gnu.testlet.java.awt.TextArea;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.TextArea;
+
+public class ScrollbarPaintTest
+    extends Panel
+    implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness. 
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)
+  {
+    setBackground(Color.red);
+    Frame f = new Frame();
+    TextArea c = new TextArea("", 2, 20, TextArea.SCROLLBARS_VERTICAL_ONLY);
+    add(c);
+    f.add(this);
+    f.pack();
+    f.show();
+    Rectangle bounds = c.getBounds();
+    Insets i = f.getInsets();
+    Point loc = f.getLocationOnScreen();
+    loc.x += i.left + bounds.x;
+    loc.y += i.top + bounds.y;
+    
+    Robot r = harness.createRobot();
+    Color scroll = r.getPixelColor(loc.x + bounds.width - i.left, loc.y + bounds.height/2);
+    harness.check(!(scroll.equals(Color.red)));
+    
+    // There is a delay to avoid any race conditions    
+    // and so user can see frame
+    r.waitForIdle();
+    r.delay(2000);
+  }
+
+  public void paint(Graphics g)
+  {
+    Image offScr = createImage(getSize().width, getSize().height);
+    Graphics offG = offScr.getGraphics();
+    offG.setClip(0, 0, getSize().width, getSize().height);
+
+    super.paint(offG);
+    g.drawImage(offScr, 0, 0, null);
+
+    offG.dispose();
+  }
+}
+
+
Index: gnu/testlet/java/awt/TextField/PaintTest.java
===================================================================
RCS file: gnu/testlet/java/awt/TextField/PaintTest.java
diff -N gnu/testlet/java/awt/TextField/PaintTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/testlet/java/awt/TextField/PaintTest.java	10 Mar 2006 18:43:19 -0000
@@ -0,0 +1,88 @@
+/* PaintTest.java -- 
+   Copyright (C) 2006 Red Hat
+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: GUI, JDK 1.0
+
+package gnu.testlet.java.awt.TextField;
+
+import gnu.testlet.TestHarness;
+import gnu.testlet.Testlet;
+
+import java.awt.Color;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Image;
+import java.awt.Insets;
+import java.awt.Panel;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Robot;
+import java.awt.TextField;
+
+public class PaintTest
+    extends Panel
+    implements Testlet
+{
+
+  /**
+   * Runs the test using the specified harness. 
+   * 
+   * @param harness  the test harness (<code>null</code> not permitted).
+   */
+  public void test(TestHarness harness)
+  {
+    setBackground(Color.red);
+    Frame f = new Frame();
+    TextField b = new TextField(10);
+    b.setBackground(Color.WHITE);
+    add(b);
+    f.add(this);
+    f.pack();
+    f.show();
+    Rectangle bounds = b.getBounds();
+    Point loc = f.getLocationOnScreen();
+    Insets i = f.getInsets();
+    bounds.x += loc.x + i.left;
+    bounds.y += loc.y + i.top;
+    
+    Robot r = harness.createRobot();
+    Color text = r.getPixelColor(bounds.x + bounds.width/2, bounds.y + bounds.height/2);
+    harness.check(text.equals(Color.white));
+
+    // There is a delay to avoid any race conditions    
+    // and so user can see frame
+    r.waitForIdle();
+    r.delay(1000);
+  }
+
+  public void paint(Graphics g)
+  {
+    Image offScr = createImage(getSize().width, getSize().height);
+    Graphics offG = offScr.getGraphics();
+    offG.setClip(0, 0, getSize().width, getSize().height);
+
+    super.paint(offG);
+    g.drawImage(offScr, 0, 0, null);
+
+    offG.dispose();
+  }
+}
+

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