modules/graphics/src/test/java/test/javafx/scene/image/TestImages.java

Print this page
rev 9250 : 8134762: Refactor Javafx graphics module tests for clear separation of tests
Reviewed-by:


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javafx.scene.image;
  27 
  28 import com.sun.javafx.pgstub.StubImageLoaderFactory;
  29 import com.sun.javafx.pgstub.StubPlatformImageInfo;
  30 import com.sun.javafx.pgstub.StubToolkit;
  31 import com.sun.javafx.tk.Toolkit;


  32 
  33 public final class TestImages {
  34     public static final Image TEST_IMAGE_0x100;
  35     public static final Image TEST_IMAGE_100x0;
  36     public static final Image TEST_IMAGE_100x200;
  37     public static final Image TEST_IMAGE_200x100;
  38 
  39     public static final Image TEST_IMAGE_32x32;
  40     public static final Image TEST_IMAGE_32x64;
  41     public static final Image TEST_IMAGE_64x32;
  42     public static final Image TEST_IMAGE_64x64;
  43 
  44     public static final Image TEST_ERROR_IMAGE;
  45 
  46     private static final StubImageLoaderFactory imageLoaderFactory;
  47 
  48     private TestImages() {
  49     }
  50 
  51     static {


  77 
  78     public static Image createAnimatedTestImage(
  79             final int width,
  80             final int height,
  81             final int loopCount, final int... frameDelays) {
  82         final String url = "file:testAnimImg_" + width + "x" + height + ".png";
  83         final StubPlatformImageInfo spii = 
  84                 new StubPlatformImageInfo(width, height, frameDelays, loopCount);
  85         imageLoaderFactory.registerImage(url, spii);
  86 
  87         return new Image(url);
  88     }
  89 
  90     /**
  91      * Stops animation timeline on the image. Used to prevent problems with
  92      * rewiding animation time.
  93      *
  94      * @param image the animated image to dispose
  95      */
  96     public static void disposeAnimatedImage(final Image image) {
  97         image.dispose();
  98     }
  99 }


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package test.javafx.scene.image;
  27 
  28 import test.com.sun.javafx.pgstub.StubImageLoaderFactory;
  29 import test.com.sun.javafx.pgstub.StubPlatformImageInfo;
  30 import test.com.sun.javafx.pgstub.StubToolkit;
  31 import com.sun.javafx.tk.Toolkit;
  32 import javafx.scene.image.Image;
  33 import javafx.scene.image.ImageShim;
  34 
  35 public final class TestImages {
  36     public static final Image TEST_IMAGE_0x100;
  37     public static final Image TEST_IMAGE_100x0;
  38     public static final Image TEST_IMAGE_100x200;
  39     public static final Image TEST_IMAGE_200x100;
  40 
  41     public static final Image TEST_IMAGE_32x32;
  42     public static final Image TEST_IMAGE_32x64;
  43     public static final Image TEST_IMAGE_64x32;
  44     public static final Image TEST_IMAGE_64x64;
  45 
  46     public static final Image TEST_ERROR_IMAGE;
  47 
  48     private static final StubImageLoaderFactory imageLoaderFactory;
  49 
  50     private TestImages() {
  51     }
  52 
  53     static {


  79 
  80     public static Image createAnimatedTestImage(
  81             final int width,
  82             final int height,
  83             final int loopCount, final int... frameDelays) {
  84         final String url = "file:testAnimImg_" + width + "x" + height + ".png";
  85         final StubPlatformImageInfo spii = 
  86                 new StubPlatformImageInfo(width, height, frameDelays, loopCount);
  87         imageLoaderFactory.registerImage(url, spii);
  88 
  89         return new Image(url);
  90     }
  91 
  92     /**
  93      * Stops animation timeline on the image. Used to prevent problems with
  94      * rewiding animation time.
  95      *
  96      * @param image the animated image to dispose
  97      */
  98     public static void disposeAnimatedImage(final Image image) {
  99         ImageShim.dispose(image);
 100     }
 101 }