use of org.eclipse.swt.graphics.ImageLoaderListener 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());
}
Aggregations