Search in sources :

Example 1 with ImageLoaderEvent

use of org.eclipse.swt.graphics.ImageLoaderEvent in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_graphics_ImageLoader method test_addImageLoaderListenerLorg_eclipse_swt_graphics_ImageLoaderListener.

@Test
public void test_addImageLoaderListenerLorg_eclipse_swt_graphics_ImageLoaderListener() {
    ImageLoader loader = new ImageLoader();
    ImageLoaderListener loaderListener = e -> loaderListenerCalled = true;
    try {
        loader.addImageLoaderListener(null);
        fail("No exception thrown for addImageLoaderListener with null argument");
    } catch (IllegalArgumentException e) {
    }
    assertFalse(":a:", loader.hasListeners());
    loader.addImageLoaderListener(loaderListener);
    assertTrue(":b:", loader.hasListeners());
    loaderListenerCalled = false;
    try (InputStream stream = SwtTestUtil.class.getResourceAsStream("interlaced_target.png")) {
        loader.load(stream);
    } catch (IOException e) {
    }
    assertTrue(":c:", loaderListenerCalled);
    loaderListenerCalled = false;
    try (InputStream stream = SwtTestUtil.class.getResourceAsStream("target.png")) {
        loader.load(stream);
    } catch (IOException e) {
    }
    assertFalse(":d:", loaderListenerCalled);
    loaderListenerCalled = false;
    loader.notifyListeners(new ImageLoaderEvent(loader, loader.data[0], 0, true));
    assertTrue(":e:", loaderListenerCalled);
    loader.removeImageLoaderListener(loaderListener);
    assertFalse(":f:", loader.hasListeners());
}
Also used : ImageLoader(org.eclipse.swt.graphics.ImageLoader) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Assert.assertFalse(org.junit.Assert.assertFalse) Assert.assertTrue(org.junit.Assert.assertTrue) Assert.fail(org.junit.Assert.fail) IOException(java.io.IOException) SWTException(org.eclipse.swt.SWTException) ImageLoaderEvent(org.eclipse.swt.graphics.ImageLoaderEvent) ImageLoaderListener(org.eclipse.swt.graphics.ImageLoaderListener) Test(org.junit.Test) InputStream(java.io.InputStream) ImageLoaderEvent(org.eclipse.swt.graphics.ImageLoaderEvent) InputStream(java.io.InputStream) ImageLoaderListener(org.eclipse.swt.graphics.ImageLoaderListener) IOException(java.io.IOException) ImageLoader(org.eclipse.swt.graphics.ImageLoader) Test(org.junit.Test)

Example 2 with ImageLoaderEvent

use of org.eclipse.swt.graphics.ImageLoaderEvent in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_graphics_ImageLoaderEvent method test_ConstructorLorg_eclipse_swt_graphics_ImageLoaderLorg_eclipse_swt_graphics_ImageDataIZ.

@Test
public void test_ConstructorLorg_eclipse_swt_graphics_ImageLoaderLorg_eclipse_swt_graphics_ImageDataIZ() {
    try {
        new ImageLoaderEvent(null, null, 0, true);
        fail("No exception thrown for ImageLoader source == null");
    } catch (IllegalArgumentException e) {
    }
    new ImageLoaderEvent(new ImageLoader(), null, 0, true);
}
Also used : ImageLoaderEvent(org.eclipse.swt.graphics.ImageLoaderEvent) ImageLoader(org.eclipse.swt.graphics.ImageLoader) Test(org.junit.Test)

Example 3 with ImageLoaderEvent

use of org.eclipse.swt.graphics.ImageLoaderEvent in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_graphics_ImageLoaderEvent method test_toString.

@Test
public void test_toString() {
    ImageLoaderEvent event = new ImageLoaderEvent(new ImageLoader(), null, 0, true);
    assertNotNull(event.toString());
    assertTrue(event.toString().length() > 0);
}
Also used : ImageLoaderEvent(org.eclipse.swt.graphics.ImageLoaderEvent) ImageLoader(org.eclipse.swt.graphics.ImageLoader) Test(org.junit.Test)

Aggregations

ImageLoader (org.eclipse.swt.graphics.ImageLoader)3 ImageLoaderEvent (org.eclipse.swt.graphics.ImageLoaderEvent)3 Test (org.junit.Test)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 SWTException (org.eclipse.swt.SWTException)1 ImageLoaderListener (org.eclipse.swt.graphics.ImageLoaderListener)1 Assert.assertFalse (org.junit.Assert.assertFalse)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Assert.fail (org.junit.Assert.fail)1