sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/03: Add one more test.
Date Thu, 26 Dec 2019 17:36:04 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 8f5a5a8c3eec897a8c34f5892529a04352b6d376
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Thu Dec 26 16:29:06 2019 +0100

    Add one more test.
---
 .../coverage/j2d/AbstractRenderedImage.java        |  2 +-
 .../coverage/j2d/AbstractRenderedImageTest.java    | 41 +++++++++++++++-------
 2 files changed, 29 insertions(+), 14 deletions(-)

diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/AbstractRenderedImage.java
b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/AbstractRenderedImage.java
index 2a067aa..55ae9bc 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/AbstractRenderedImage.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/AbstractRenderedImage.java
@@ -262,7 +262,7 @@ public abstract class AbstractRenderedImage implements RenderedImage {
                 final Rectangle tb = aoi.intersection(tile.getBounds());        // Bounds
of transfer buffer.
                 if (tb.isEmpty()) {
                     /*
-                     * Should never happen since we iterate only on the tiles
+                     * Should never happen since we iterate only over the tiles
                      * that intersect the given area of interest.
                      */
                     throw new RasterFormatException("Inconsistent tile matrix.");
diff --git a/core/sis-feature/src/test/java/org/apache/sis/internal/coverage/j2d/AbstractRenderedImageTest.java
b/core/sis-feature/src/test/java/org/apache/sis/internal/coverage/j2d/AbstractRenderedImageTest.java
index 5520a56..30b71f1 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/internal/coverage/j2d/AbstractRenderedImageTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/internal/coverage/j2d/AbstractRenderedImageTest.java
@@ -18,6 +18,7 @@ package org.apache.sis.internal.coverage.j2d;
 
 import java.util.Random;
 import java.awt.Point;
+import java.awt.Rectangle;
 import java.awt.image.ColorModel;
 import java.awt.image.DataBuffer;
 import java.awt.image.Raster;
@@ -127,23 +128,19 @@ public final strictfp class AbstractRenderedImageTest extends TestCase
{
         }
 
         /*
-         * No source, no property, no color model since this test images is not for rendering
on screen.
+         * Size and tiling information.
          */
+        @Override public int         getMinX()        {return minX;}
+        @Override public int         getMinY()        {return minY;}
+        @Override public int         getWidth()       {return WIDTH;}
+        @Override public int         getHeight()      {return HEIGHT;}
+        @Override public int         getTileWidth()   {return TILE_WIDTH;}
+        @Override public int         getTileHeight()  {return TILE_HEIGHT;}
+        @Override public int         getMinTileX()    {return minTileX;}
+        @Override public int         getMinTileY()    {return minTileY;}
         @Override public ColorModel  getColorModel()  {return null;}
         @Override public SampleModel getSampleModel() {return tiles[0].getSampleModel();}
 
-        /*
-         * Size and tiling information.
-         */
-        @Override public int getMinX()            {return minX;}
-        @Override public int getMinY()            {return minY;}
-        @Override public int getWidth()           {return WIDTH;}
-        @Override public int getHeight()          {return HEIGHT;}
-        @Override public int getTileWidth()       {return TILE_WIDTH;}
-        @Override public int getTileHeight()      {return TILE_HEIGHT;}
-        @Override public int getMinTileX()        {return minTileX;}
-        @Override public int getMinTileY()        {return minTileY;}
-
         /**
          * Returns the tile at the given location in tile coordinates.
          */
@@ -172,4 +169,22 @@ public final strictfp class AbstractRenderedImageTest extends TestCase
{
             { 910,  911,  912  ,  1010, 1011, 1012  ,  1110, 1111, 1112  ,  1210, 1211, 1212}
         });
     }
+
+    /**
+     * Tests {@link AbstractRenderedImage#getData(Rectangle)} on a tiled image.
+     */
+    @Test
+    public void testGetDataRegion() {
+        final AbstractRenderedImage image = new TiledImage(random);
+        final Rectangle region = ImageUtilities.getBounds(image);
+        region.x      += 4;     // Exclude 4 columns on left side.
+        region.width  -= 6;     // Exclude 2 columns on right side.
+        region.y      += 1;     // Exclude 1 row on top.
+        region.height -= 3;     // Exclude 2 rows on bottom.
+        assertValuesEqual(image.getData(region), 0, new int[][] {
+            { 211,  212  ,   310,  311,  312  ,   410},
+            { 601,  602  ,   700,  701,  702  ,   800},
+            { 611,  612  ,   710,  711,  712  ,   810}
+        });
+    }
 }


Mime
View raw message