/hg/gfx-test: 2012-01-18 Pavel Tisnovsky <ptisnovs at redhat.com>
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Wed Jan 18 01:57:07 PST 2012
changeset 0f154450543f in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=0f154450543f
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Wed Jan 18 10:59:30 2012 +0100
2012-01-18 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/framework/CommonBitmapOperations.java:
* src/org/gfxtest/framework/ImageFactory.java: Added support
for new pattern types.
* src/org/gfxtest/testsuites/BitBltBasicTests.java: Added
new tests which use new pattern types.
diffstat:
ChangeLog | 8 +
src/org/gfxtest/framework/CommonBitmapOperations.java | 89 +++++++++++++++
src/org/gfxtest/framework/ImageFactory.java | 103 +++++++++++++++++-
src/org/gfxtest/testsuites/BitBltBasicTests.java | 28 ++++
4 files changed, 224 insertions(+), 4 deletions(-)
diffs (317 lines):
diff -r f01a066ab3b3 -r 0f154450543f ChangeLog
--- a/ChangeLog Tue Jan 17 17:06:27 2012 +0100
+++ b/ChangeLog Wed Jan 18 10:59:30 2012 +0100
@@ -1,3 +1,11 @@
+2012-01-18 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/framework/CommonBitmapOperations.java:
+ * src/org/gfxtest/framework/ImageFactory.java:
+ Added support for new pattern types.
+ * src/org/gfxtest/testsuites/BitBltBasicTests.java:
+ Added new tests which use new pattern types.
+
2012-01-17 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/framework/annotations/Transformation.java:
diff -r f01a066ab3b3 -r 0f154450543f src/org/gfxtest/framework/CommonBitmapOperations.java
--- a/src/org/gfxtest/framework/CommonBitmapOperations.java Tue Jan 17 17:06:27 2012 +0100
+++ b/src/org/gfxtest/framework/CommonBitmapOperations.java Wed Jan 18 10:59:30 2012 +0100
@@ -127,6 +127,7 @@
public static TestResult doBitBltTestWithEmptyImage(TestImage image, Graphics2D graphics2d, int type)
{
BufferedImage bufferedImage = createBufferedBitmap(type);
+ // basic check if buffered image was created
if (bufferedImage == null)
{
return TestResult.FAILED;
@@ -147,6 +148,7 @@
public static TestResult doBitBltTestWithCheckerImage(TestImage image, Graphics2D graphics2d, int imageType)
{
BufferedImage bufferedImage = ImageFactory.createCheckerImage(GRID_SIZE, DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
+ // basic check if buffered image was created
if (bufferedImage == null)
{
return TestResult.FAILED;
@@ -167,6 +169,7 @@
public static TestResult doBitBltTestWithCheckerImage(TestImage image, Graphics2D graphics2d, int imageType, int width, int height)
{
BufferedImage bufferedImage = ImageFactory.createCheckerImage(GRID_SIZE, DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
+ // basic check if buffered image was created
if (bufferedImage == null)
{
return TestResult.FAILED;
@@ -187,6 +190,7 @@
public static TestResult doBitBltTestWithDiagonalCheckerImage(TestImage image, Graphics2D graphics2d, int imageType)
{
BufferedImage bufferedImage = ImageFactory.createDiagonalCheckerImage(GRID_SIZE, DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
+ // basic check if buffered image was created
if (bufferedImage == null)
{
return TestResult.FAILED;
@@ -207,6 +211,91 @@
public static TestResult doBitBltTestWithDiagonalCheckerImage(TestImage image, Graphics2D graphics2d, int imageType, int width, int height)
{
BufferedImage bufferedImage = ImageFactory.createDiagonalCheckerImage(GRID_SIZE, DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
+ // basic check if buffered image was created
+ if (bufferedImage == null)
+ {
+ return TestResult.FAILED;
+ }
+ return BitBlt(bufferedImage, image, graphics2d, width, height) ? TestResult.PASSED : TestResult.FAILED;
+ }
+
+ /**
+ * Create new buffered image containing grid pattern and then do basic BitBlt test.
+ *
+ * @param image
+ * image to which another image is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @param imageType
+ * type of the created image
+ */
+ public static TestResult doBitBltTestWithGridImage(TestImage image, Graphics2D graphics2d, int imageType)
+ {
+ BufferedImage bufferedImage = ImageFactory.createGridImage(GRID_SIZE, DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
+ // basic check if buffered image was created
+ if (bufferedImage == null)
+ {
+ return TestResult.FAILED;
+ }
+ return BitBlt(bufferedImage, image, graphics2d) ? TestResult.PASSED : TestResult.FAILED;
+ }
+
+ /**
+ * Create new buffered image containing grid pattern and then do basic BitBlt test.
+ *
+ * @param image
+ * image to which another image is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @param imageType
+ * type of the created image
+ */
+ public static TestResult doBitBltTestWithGridImage(TestImage image, Graphics2D graphics2d, int imageType, int width, int height)
+ {
+ BufferedImage bufferedImage = ImageFactory.createGridImage(GRID_SIZE, DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
+ // basic check if buffered image was created
+ if (bufferedImage == null)
+ {
+ return TestResult.FAILED;
+ }
+ return BitBlt(bufferedImage, image, graphics2d, width, height) ? TestResult.PASSED : TestResult.FAILED;
+ }
+
+ /**
+ * Create new buffered image containing diagonal grid pattern and then do basic BitBlt test.
+ *
+ * @param image
+ * image to which another image is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @param imageType
+ * type of the created image
+ */
+ public static TestResult doBitBltTestWithDiagonalGridImage(TestImage image, Graphics2D graphics2d, int imageType)
+ {
+ BufferedImage bufferedImage = ImageFactory.createDiagonalGridImage(GRID_SIZE, DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
+ // basic check if buffered image was created
+ if (bufferedImage == null)
+ {
+ return TestResult.FAILED;
+ }
+ return BitBlt(bufferedImage, image, graphics2d) ? TestResult.PASSED : TestResult.FAILED;
+ }
+
+ /**
+ * Create new buffered image containing diagonal grid pattern and then do basic BitBlt test.
+ *
+ * @param image
+ * image to which another image is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @param imageType
+ * type of the created image
+ */
+ public static TestResult doBitBltTestWithDiagonalGridImage(TestImage image, Graphics2D graphics2d, int imageType, int width, int height)
+ {
+ BufferedImage bufferedImage = ImageFactory.createDiagonalGridImage(GRID_SIZE, DEFAULT_TEST_IMAGE_WIDTH, DEFAULT_TEST_IMAGE_HEIGHT, imageType);
+ // basic check if buffered image was created
if (bufferedImage == null)
{
return TestResult.FAILED;
diff -r f01a066ab3b3 -r 0f154450543f src/org/gfxtest/framework/ImageFactory.java
--- a/src/org/gfxtest/framework/ImageFactory.java Tue Jan 17 17:06:27 2012 +0100
+++ b/src/org/gfxtest/framework/ImageFactory.java Wed Jan 18 10:59:30 2012 +0100
@@ -53,7 +53,19 @@
public class ImageFactory
{
/**
- * Create image containing checker pattern.
+ * Converts boolean value into an integer representing black or white color.
+ *
+ * @param whiteColorFlag
+ * true if white color is required, false otherwise
+ * @return integer representing black or white color
+ */
+ private static int booleanToBlackOrWhiteColor(boolean whiteColorFlag)
+ {
+ return whiteColorFlag ? 0xffffffff: 0xff000000;
+ }
+
+ /**
+ * Create image containing checker black and white pattern.
*
* @param gridSize
* size of a grid
@@ -84,7 +96,8 @@
boolean evenRow = (y % doubledGridSize) >= gridSize;
// compute color for each pixel
boolean whiteField = evenColumn ^ evenRow;
- int color = whiteField ? 0xffffffff: 0xff000000;
+ // convert boolean into color code
+ int color = booleanToBlackOrWhiteColor(whiteField);
image.setRGB(x, y, color);
}
}
@@ -92,7 +105,7 @@
}
/**
- * Create image containing diagonal checker pattern.
+ * Create image containing diagonal checker black and white pattern.
*
* @param gridSize
* size of a grid
@@ -126,10 +139,92 @@
boolean evenRow = ((width2 + x - y) % doubledGridSize) >= gridSize;
// compute color for each pixel
boolean whiteField = evenColumn ^ evenRow;
- int color = whiteField ? 0xffffffff: 0xff000000;
+ // convert boolean into color code
+ int color = booleanToBlackOrWhiteColor(whiteField);
image.setRGB(x, y, color);
}
}
return image;
}
+
+ /**
+ * Create image containing simple grid black and white pattern.
+ *
+ * @param gridSize
+ * size of a grid
+ * @param width
+ * width of a buffered image
+ * @param height
+ * height of a buffered image
+ * @param imageType
+ * buffered image type
+ * @return buffered image containing checker pattern
+ */
+ public static BufferedImage createGridImage(int gridSize, int width, int height, int imageType)
+ {
+ // used by test for a tile colors
+ int doubledGridSize = gridSize << 1;
+
+ // create new image
+ BufferedImage image = new BufferedImage(width, height, imageType);
+
+ // for all lines in a raster image
+ for (int y = 0; y < height; y++)
+ {
+ // for all columns on a line
+ for (int x = 0; x < width; x++)
+ {
+ // compute color for each tile
+ boolean evenColumn = (x % doubledGridSize) == 0;
+ boolean evenRow = (y % doubledGridSize) == 0;
+ // compute color for each pixel
+ boolean blackField = evenColumn || evenRow;
+ // convert boolean into color code
+ int color = booleanToBlackOrWhiteColor(!blackField);
+ image.setRGB(x, y, color);
+ }
+ }
+ return image;
+ }
+
+ /**
+ * Create image containing simple diagonal grid black and white pattern.
+ *
+ * @param gridSize
+ * size of a grid
+ * @param width
+ * width of a buffered image
+ * @param height
+ * height of a buffered image
+ * @param imageType
+ * buffered image type
+ * @return buffered image containing checker pattern
+ */
+ public static BufferedImage createDiagonalGridImage(int gridSize, int width, int height, int imageType)
+ {
+ // used by test for a tile colors
+ int doubledGridSize = gridSize << 1;
+
+ // create new image
+ BufferedImage image = new BufferedImage(width, height, imageType);
+
+ // for all lines in a raster image
+ for (int y = 0; y < height; y++)
+ {
+ // for all columns on a line
+ for (int x = 0; x < width; x++)
+ {
+ // compute color for each tile
+ boolean evenColumn = ((x+y) % doubledGridSize) == 0;
+ boolean evenRow = ((x-y) % doubledGridSize) == 0;
+ // compute color for each pixel
+ boolean blackField = evenColumn || evenRow;
+ // convert boolean into color code
+ int color = booleanToBlackOrWhiteColor(!blackField);
+ image.setRGB(x, y, color);
+ }
+ }
+ return image;
+ }
+
}
diff -r f01a066ab3b3 -r 0f154450543f src/org/gfxtest/testsuites/BitBltBasicTests.java
--- a/src/org/gfxtest/testsuites/BitBltBasicTests.java Tue Jan 17 17:06:27 2012 +0100
+++ b/src/org/gfxtest/testsuites/BitBltBasicTests.java Wed Jan 18 10:59:30 2012 +0100
@@ -411,6 +411,34 @@
}
/**
+ * Test basic BitBlt operation for grid buffered image with type TYPE_BYTE_BINARY.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return
+ */
+ public TestResult testBitBltGridBufferedImageTypeByteBinary(TestImage image, Graphics2D graphics2d)
+ {
+ return CommonBitmapOperations.doBitBltTestWithGridImage(image, graphics2d, BufferedImage.TYPE_BYTE_BINARY);
+ }
+
+ /**
+ * Test basic BitBlt operation for diagonal grid buffered image with type TYPE_BYTE_BINARY.
+ *
+ * @param image
+ * image to which line is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return
+ */
+ public TestResult testBitBltDiagonalGridBufferedImageTypeByteBinary(TestImage image, Graphics2D graphics2d)
+ {
+ return CommonBitmapOperations.doBitBltTestWithDiagonalGridImage(image, graphics2d, BufferedImage.TYPE_BYTE_BINARY);
+ }
+
+ /**
* Entry point to the test suite.
*
* @param args not used in this case
More information about the distro-pkg-dev
mailing list