< prev index next >

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

Print this page




  77 
  78     @Test
  79     public void testPropertyPropagation_viewport() throws Exception {
  80         NodeTest.testObjectPropertyPropagation(
  81                 imageView, "viewport",
  82                 new Rectangle2D(10, 20, 200, 100),
  83                 new Rectangle2D(20, 10, 100, 200));
  84     }
  85 
  86     @Test
  87     public void testPropertyPropagation_image() throws Exception {
  88         NodeTest.testObjectPropertyPropagation(
  89                 imageView, "image", "image",
  90                 null,
  91                 TestImages.TEST_IMAGE_200x100,
  92                 (sgValue, pgValue) -> {
  93                     if (sgValue == null) {
  94                         assertNull(pgValue);
  95                     } else {
  96                         assertSame(
  97                                 ((Image) sgValue).impl_getPlatformImage(),
  98                                 pgValue);
  99                     }
 100 
 101                     return 0;
 102                 }
 103         );
 104     }
 105 
 106     @Test
 107     public void testUrlConstructor() {
 108         final StubImageLoaderFactory imageLoaderFactory =
 109                 ((StubToolkit) Toolkit.getToolkit()).getImageLoaderFactory();
 110 
 111         final String url = "file:img_view_image.png";
 112         imageLoaderFactory.registerImage(
 113                 url, new StubPlatformImageInfo(50, 40));
 114 
 115         final ImageView newImageView = new ImageView(url);
 116 
 117         assertEquals(url, newImageView.getImage().getUrl());


 157                 ((StubToolkit) Toolkit.getToolkit()).getImageLoaderFactory();
 158 
 159         final String url = "file:async.png";
 160         imageLoaderFactory.registerImage(
 161                 url, new StubPlatformImageInfo(100, 200));
 162 
 163         final Image placeholderImage =
 164                 TestImages.TEST_IMAGE_200x100;
 165         final Image asyncImage =
 166                 new Image(url, 200, 100, true, true, true);
 167 
 168         final StubAsyncImageLoader lastAsyncImageLoader =
 169                 imageLoaderFactory.getLastAsyncImageLoader();
 170 
 171         final StubImageView pgImageView =
 172                 (StubImageView) imageView.impl_getPGNode();
 173 
 174         imageView.setImage(asyncImage);
 175 
 176         NodeTest.callSyncPGNode(imageView);
 177         assertSame(placeholderImage.impl_getPlatformImage(),
 178                    pgImageView.getImage());
 179         assertBoundsEqual(box(0, 0, 200, 100), imageView.getBoundsInLocal());
 180 
 181         lastAsyncImageLoader.finish();
 182 
 183         NodeTest.callSyncPGNode(imageView);
 184         assertSame(asyncImage.impl_getPlatformImage(),
 185                    pgImageView.getImage());
 186         assertBoundsEqual(box(0, 0, 100, 200), imageView.getBoundsInLocal());
 187     }
 188     */
 189 
 190     public class StubImageView extends ImageView {
 191         public StubImageView() {
 192             super();
 193         }
 194 
 195         @Override
 196         protected NGNode impl_createPeer() {
 197             return new StubNGImageView();
 198         }
 199     }
 200 
 201     public class StubNGImageView extends NGImageView {
 202         // for tests
 203         private Object image;
 204         private float x;




  77 
  78     @Test
  79     public void testPropertyPropagation_viewport() throws Exception {
  80         NodeTest.testObjectPropertyPropagation(
  81                 imageView, "viewport",
  82                 new Rectangle2D(10, 20, 200, 100),
  83                 new Rectangle2D(20, 10, 100, 200));
  84     }
  85 
  86     @Test
  87     public void testPropertyPropagation_image() throws Exception {
  88         NodeTest.testObjectPropertyPropagation(
  89                 imageView, "image", "image",
  90                 null,
  91                 TestImages.TEST_IMAGE_200x100,
  92                 (sgValue, pgValue) -> {
  93                     if (sgValue == null) {
  94                         assertNull(pgValue);
  95                     } else {
  96                         assertSame(
  97                                 Toolkit.getImageAccessor().getPlatformImage((Image) sgValue),
  98                                 pgValue);
  99                     }
 100 
 101                     return 0;
 102                 }
 103         );
 104     }
 105 
 106     @Test
 107     public void testUrlConstructor() {
 108         final StubImageLoaderFactory imageLoaderFactory =
 109                 ((StubToolkit) Toolkit.getToolkit()).getImageLoaderFactory();
 110 
 111         final String url = "file:img_view_image.png";
 112         imageLoaderFactory.registerImage(
 113                 url, new StubPlatformImageInfo(50, 40));
 114 
 115         final ImageView newImageView = new ImageView(url);
 116 
 117         assertEquals(url, newImageView.getImage().getUrl());


 157                 ((StubToolkit) Toolkit.getToolkit()).getImageLoaderFactory();
 158 
 159         final String url = "file:async.png";
 160         imageLoaderFactory.registerImage(
 161                 url, new StubPlatformImageInfo(100, 200));
 162 
 163         final Image placeholderImage =
 164                 TestImages.TEST_IMAGE_200x100;
 165         final Image asyncImage =
 166                 new Image(url, 200, 100, true, true, true);
 167 
 168         final StubAsyncImageLoader lastAsyncImageLoader =
 169                 imageLoaderFactory.getLastAsyncImageLoader();
 170 
 171         final StubImageView pgImageView =
 172                 (StubImageView) imageView.impl_getPGNode();
 173 
 174         imageView.setImage(asyncImage);
 175 
 176         NodeTest.callSyncPGNode(imageView);
 177         assertSame(Toolkit.getImageAccessor().getPlatformImage(placeholderImage),
 178                    pgImageView.getImage());
 179         assertBoundsEqual(box(0, 0, 200, 100), imageView.getBoundsInLocal());
 180 
 181         lastAsyncImageLoader.finish();
 182 
 183         NodeTest.callSyncPGNode(imageView);
 184         assertSame(Toolkit.getImageAccessor().getPlatformImage(asyncImage),
 185                    pgImageView.getImage());
 186         assertBoundsEqual(box(0, 0, 100, 200), imageView.getBoundsInLocal());
 187     }
 188     */
 189 
 190     public class StubImageView extends ImageView {
 191         public StubImageView() {
 192             super();
 193         }
 194 
 195         @Override
 196         protected NGNode impl_createPeer() {
 197             return new StubNGImageView();
 198         }
 199     }
 200 
 201     public class StubNGImageView extends NGImageView {
 202         // for tests
 203         private Object image;
 204         private float x;


< prev index next >