Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRalf Sternberg2011-01-22 15:54:02 +0000
committerRalf Sternberg2011-01-22 15:54:02 +0000
commit9e5d4b544867d7e498f5b3edf8a234bf991a4fab (patch)
tree75de269dd31395052a8ec37c2aff7b843c103b71 /tests
parent143bd20970305031549541b6840313275916b091 (diff)
downloadorg.eclipse.rap-9e5d4b544867d7e498f5b3edf8a234bf991a4fab.tar.gz
org.eclipse.rap-9e5d4b544867d7e498f5b3edf8a234bf991a4fab.tar.xz
org.eclipse.rap-9e5d4b544867d7e498f5b3edf8a234bf991a4fab.zip
Applied patch for bug 334511: [Image] Image(Device,int,int) constructor is missing
https://bugs.eclipse.org/bugs/show_bug.cgi?id=334511
Diffstat (limited to 'tests')
-rw-r--r--tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/graphics/Image_Test.java60
1 files changed, 48 insertions, 12 deletions
diff --git a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/graphics/Image_Test.java b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/graphics/Image_Test.java
index e2b981bca9..d9340a3dca 100644
--- a/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/graphics/Image_Test.java
+++ b/tests/org.eclipse.rap.rwt.test/src/org/eclipse/swt/graphics/Image_Test.java
@@ -40,7 +40,7 @@ public class Image_Test extends TestCase {
public void testStreamConstructorWithNullInputStream() {
try {
- new Image( new Display(), (InputStream)null );
+ new Image( new Display(), ( InputStream )null );
fail( "Must provide input stream for constructor" );
} catch( IllegalArgumentException e ) {
assertEquals( "Argument cannot be null", e.getMessage() );
@@ -163,8 +163,18 @@ public class Image_Test extends TestCase {
////////////////////////
// ImageData constructor
+
+ public void testImageDataConstructor() {
+ Display display = new Display();
+ ClassLoader loader = Fixture.class.getClassLoader();
+ InputStream stream = loader.getResourceAsStream( Fixture.IMAGE_100x50 );
+ ImageData imageData = new ImageData( stream );
+ Image image = new Image( display, imageData );
+ assertEquals( 100, image.getBounds().width );
+ assertEquals( 50, image.getBounds().height );
+ }
- public void testDataConstructorWithNullDevice() {
+ public void testImageDataConstructorWithNullDevice() {
ClassLoader loader = Fixture.class.getClassLoader();
InputStream stream = loader.getResourceAsStream( Fixture.IMAGE1 );
ImageData imageData = new ImageData( stream );
@@ -176,23 +186,49 @@ public class Image_Test extends TestCase {
}
}
- public void testDataConstructorWithNullImageData() {
+ public void testImageDataConstructorWithNullImageData() {
try {
- new Image( new Display(), (ImageData)null );
+ new Image( new Display(), ( ImageData )null );
fail( "Must provide image data for constructor" );
} catch( IllegalArgumentException e ) {
assertEquals( "Argument cannot be null", e.getMessage() );
}
}
+
+ ///////////////////////////
+ // Width/Height constructor
+
+ public void testWidthHeightConstructor() {
+ Display device = new Display();
+ Image image = new Image( device, 1, 1 );
+ ImageData imageData = image.getImageData();
+ RGB[] rgbs = imageData.getRGBs();
+ assertEquals( new RGB( 255, 255, 255 ), rgbs[ 0 ] );
+ assertEquals( new Rectangle( 0, 0, 1, 1 ), image.getBounds() );
+ }
- public void testImageDataConstructor() {
- Display display = new Display();
- ClassLoader loader = Fixture.class.getClassLoader();
- InputStream stream = loader.getResourceAsStream( Fixture.IMAGE_100x50 );
- ImageData imageData = new ImageData( stream );
- Image image = new Image( display, imageData );
- assertEquals( 100, image.getBounds().width );
- assertEquals( 50, image.getBounds().height );
+ public void testWidthHeightConstructorWithNullDevice() {
+ try {
+ new Image( null, 1, 1 );
+ fail( "Must provide device for constructor" );
+ } catch( IllegalArgumentException expected ) {
+ }
+ }
+
+ public void testWidthHeightConstructorWithZeroWidth() {
+ try {
+ new Image( null, 0, 1 );
+ fail( "Width must be a positive value" );
+ } catch( IllegalArgumentException expected ) {
+ }
+ }
+
+ public void testWidthHeightConstructorWithZeroHeight() {
+ try {
+ new Image( null, 1, 0 );
+ fail( "Height must be a positive value" );
+ } catch( IllegalArgumentException expected ) {
+ }
}
////////////////

Back to the top