PolyVertTest.java revision 430
/*
* Copyright 2002-2008 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code 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
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
/*
* @test
* @bug 4678208 4771101 6328481 6588884
* @summary verify the pixelization of degenerate polylines and polygons
* @run main PolyVertTest
*/
public class PolyVertTest {
static int TESTWIDTH;
static int TESTHEIGHT;
static final int REG_TEST_WIDTH = 10;
static final int REG_TEST_HEIGHT = 10;
static final int FULL_TEST_WIDTH = 50;
static final int FULL_TEST_HEIGHT = 200;
static final int FRINGE = 2;
static BufferedImage refImg;
static BufferedImage errorImg;
static Component testCanvas;
static int totalbadpixels;
static int totalfuzzypixels;
static int numbadtests;
static int numfuzzytests;
static int numframes;
static int fuzzystarty;
static boolean counting;
static boolean showerrors;
static boolean showresults;
static boolean fringe;
static boolean forceerror;
static boolean fulltest = true;
static boolean hwonly;
public void windowClosing(WindowEvent e) {
if (--numframes <= 0) {
}
}
};
public PolyVertTest() {
/*
setBackground(Color.white);
setForeground(Color.black);
*/
}
static int polypts[][][] = {
{
// void polygon (no points)
{}, {},
},
{
// one point
{ 0 }, { 0 },
},
{
// two points
{ 0, 5 }, { 0, 0 },
{ 0, 0, 6, 1,
10, 0, 6, 1,
20, 0, 6, 1 },
{ 0, 0, 6, 1,
10, 0, 1, 1, 15, 0, 1, 1,
20, 0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0, 1, 1,
20, 0, 1, 1 },
},
{
// empty triangle
{ 0, 0, 0 }, { 0, 0, 0 },
{ 0, 0, 1, 1,
10, 0, 1, 1,
20, 0, 1, 1 },
},
};
if (forceerror) {
}
if (!fulltest) {
return;
}
g2d.setPaintMode();
int y = 50;
y += 10;
}
y += 10;
}
g2d.setPaintMode();
}
public Dimension getPreferredSize() {
}
"print this usage summary");
"run all tests and accumulate error counts");
"force at least one error in each test");
"draw a yellow fringe around problems");
"display results window for tests with problems");
"display results window for all tests");
"only run test cases reported in bug reports");
"run full suite of test cases for a 'unit test'");
"only run tests for screen and VolatileImage");
}
counting = true;
forceerror = true;
fringe = true;
showerrors = true;
showresults = true;
fulltest = false;
fulltest = true;
hwonly = true;
usage(0);
} else {
usage(1);
}
}
if (fulltest) {
} else {
}
// Prevents premature exit by the WindowAdapter if the user
// closes the last visible results window before we've
// finished our tests.
numframes++;
testScreen();
if (!hwonly) {
}
if (totalfuzzypixels > 0) {
numfuzzytests+" tests");
}
if (totalbadpixels > 0) {
numbadtests+" tests");
}
--numframes;
}
}
public static void makeReferenceImage() {
if (!fulltest) {
g.dispose();
return;
}
for (int y = 10; y < 50; y += 10) {
}
int y = 50;
g.translate(10, y);
}
}
g.translate(-10, -y);
y += 10;
}
fuzzystarty = y;
g.translate(10, y);
}
}
g.translate(-10, -y);
y += 10;
}
g.dispose();
}
public static void initerrorbuf() {
droperrorbuf();
}
}
}
public static void droperrorbuf() {
}
}
}
}
if (img instanceof BufferedImage) {
} else {
g.dispose();
}
}
public static boolean isFuzzyPixel(int X, int Y) {
int ytrans = fuzzystarty;
return false;
}
{
return true;
}
}
}
ytrans += 10;
}
return false;
}
int numbadpixels = 0;
int numfuzzypixels = 0;
for (int y = 0; y < TESTHEIGHT; y++) {
for (int x = 0; x < TESTWIDTH; x++) {
boolean isfuzzy = isFuzzyPixel(x, y);
if (showerrors || showresults) {
initerrorbuf();
}
" while testing: "+name);
}
if (isfuzzy) {
} else {
numbadpixels++;
}
}
}
}
if (numbadpixels > 0) {
numbadtests++;
}
if (numfuzzypixels > 0) {
}
numfuzzypixels+" questionable pixels "+
"found while testing "+name);
if (showerrors || showresults) {
}
} else if (showresults) {
initerrorbuf();
}
}
}
if (fringe) {
for (int y = 0; y < TESTHEIGHT; y++) {
for (int x = 0; x < TESTWIDTH; x++) {
{
}
}
}
}
}
}
}
f.setLayout(new BorderLayout());
++numframes;
f.add(p, "Center");
droperrorbuf();
f.pack();
f.show();
}
public static void testBufferedImage() {
}
}
public static void testScreen() {
testCanvas = child;
f.pack();
f.show();
f.hide();
}
public static void testOffscreen() {
}
public static void testCompatibleImages() {
}
}
}
}
gconfig+".createCompat()");
gconfig+".createCompat(OPAQUE)");
gconfig+".createCompat(BITMASK)");
gconfig+".createCompat(TRANSLUCENT)");
gconfig+".createCompatVolatile()");
}
public static void testVolatileImage() {
}
public static class ImageCanvas extends Canvas {
}
public Dimension getPreferredSize() {
}
}
}
public static class TestCanvas extends Canvas {
public Dimension getPreferredSize() {
}
getHeight() < TESTHEIGHT)
{
return;
}
render((Graphics2D) g);
Point p = getLocationOnScreen();
try {
} catch (AWTException e) {
e.printStackTrace();
}
synchronized (this) {
notifyAll();
}
}
public synchronized BufferedImage getImage() {
try {
wait();
} catch (InterruptedException e) {
return null;
}
}
return bimg;
}
}
}