Lines 20-25
Link Here
|
20 |
import org.eclipse.ercp.swt.core.tests.junit.SwtTestCase; |
20 |
import org.eclipse.ercp.swt.core.tests.junit.SwtTestCase; |
21 |
import org.eclipse.swt.*; |
21 |
import org.eclipse.swt.*; |
22 |
import org.eclipse.swt.graphics.*; |
22 |
import org.eclipse.swt.graphics.*; |
|
|
23 |
import org.eclipse.swt.internal.Platform; |
23 |
|
24 |
|
24 |
/** |
25 |
/** |
25 |
* Automated Test Suite for class org.eclipse.swt.graphics.ImageLoader |
26 |
* Automated Test Suite for class org.eclipse.swt.graphics.ImageLoader |
Lines 70-80
Link Here
|
70 |
String fileName = SwtTestCase.imageFilenames[0]; |
71 |
String fileName = SwtTestCase.imageFilenames[0]; |
71 |
for (int i=0; i<numFormats; i++) { |
72 |
for (int i=0; i<numFormats; i++) { |
72 |
String format = SwtTestCase.imageFormats[i]; |
73 |
String format = SwtTestCase.imageFormats[i]; |
73 |
stream = SwtTestCase.class.getResourceAsStream(fileName + "." + format); |
74 |
//Win32 does not support ImageLoader load jpg/png as inputstream |
74 |
loader.load(stream); |
75 |
boolean isPlatformWin32 = Platform.isWin32(); |
75 |
try { |
76 |
if (!(isPlatformWin32&&(format=="jpg"|format=="png"))){ |
76 |
stream.close(); |
77 |
stream = SwtTestCase.class.getResourceAsStream(fileName + "." + format); |
77 |
} catch (IOException e) {} |
78 |
loader.load(stream); |
|
|
79 |
try { |
80 |
stream.close(); |
81 |
} catch (IOException e) {} |
82 |
} |
78 |
} |
83 |
} |
79 |
} finally { |
84 |
} finally { |
80 |
try { |
85 |
try { |
Lines 149-165
Link Here
|
149 |
String filename = SwtTestCase.imageFilenames[0]; |
154 |
String filename = SwtTestCase.imageFilenames[0]; |
150 |
// must use jpg since save is not implemented yet in png format |
155 |
// must use jpg since save is not implemented yet in png format |
151 |
String filetype = "jpg"; |
156 |
String filetype = "jpg"; |
152 |
inStream = SwtTestCase.class.getResourceAsStream(filename + "." + filetype); |
157 |
inStream = SwtTestCase.class.getResourceAsStream(filename + "." + filetype); |
153 |
loader.load(inStream); |
158 |
//eSWT does not support png and jpg as outputStream saving in Win32, WinCE and WindowMobile. |
154 |
try { |
159 |
boolean isPlatformWin32WinCEWM = Platform.isWin32()|Platform.isWinCE()|Platform.isWindowMobile()|Platform.isSmartPhone(); |
155 |
inStream.close(); |
160 |
if (!isPlatformWin32WinCEWM){ |
156 |
} catch (IOException e) {} |
161 |
loader.load(inStream); |
157 |
for (int i = 0; i < imageFormats.length; i++) { |
162 |
try { |
158 |
if (imageFormats[i].equals(filetype)) { |
163 |
inStream.close(); |
159 |
// save using the appropriate format |
164 |
} catch (IOException e) {} |
160 |
loader.save(outStream, SWT.IMAGE_JPEG); |
165 |
for (int i = 0; i < imageFormats.length; i++) { |
161 |
break; |
166 |
if (imageFormats[i].equals(filetype)) { |
162 |
} |
167 |
// save using the appropriate format |
|
|
168 |
loader.save(outStream, SWT.IMAGE_JPEG); |
169 |
break; |
170 |
} |
171 |
} |
163 |
} |
172 |
} |
164 |
} |
173 |
} |
165 |
} finally { |
174 |
} finally { |
Lines 179-208
Link Here
|
179 |
} catch (IllegalArgumentException e) { |
188 |
} catch (IllegalArgumentException e) { |
180 |
} |
189 |
} |
181 |
for (int i=0; i<imageFormats.length; i++) { |
190 |
for (int i=0; i<imageFormats.length; i++) { |
182 |
for (int j=0; j<SwtTestCase.imageFilenames.length; j++) { |
191 |
boolean isPlatformWin32 = Platform.isWin32(); |
183 |
filename = SwtTestCase.imageFilenames[j]; |
192 |
boolean isPlatformWinCE5 = Platform.isWinCE(); |
184 |
String filetype = imageFormats[i]; |
193 |
// Win32 does not support ImageLoader load jpg/png as inputstream |
185 |
InputStream inStream = SwtTestCase.class.getResourceAsStream(filename + "." + filetype); |
194 |
if (!(isPlatformWin32&&(imageFormats[i]=="jpg"|imageFormats[i]=="png"))){ |
186 |
loader.load(inStream); |
195 |
for (int j=0; j<SwtTestCase.imageFilenames.length; j++) { |
187 |
try { |
196 |
filename = SwtTestCase.imageFilenames[j]; |
|
|
197 |
String filetype = imageFormats[i]; |
198 |
InputStream inStream = SwtTestCase.class.getResourceAsStream(filename + "." + filetype); |
199 |
loader.load(inStream); |
200 |
try { |
188 |
inStream.close(); |
201 |
inStream.close(); |
189 |
} catch (IOException e) {} |
202 |
} catch (IOException e) {} |
190 |
File imageFile = new File(filename + "saved."+filetype); |
203 |
File imageFile = new File(filename + "saved."+filetype); |
191 |
imageFile.delete(); |
204 |
imageFile.delete(); |
192 |
loader.save(imageFile.getName(), imageTypes[i]); |
205 |
//WinCE5 does not support ImageLoader save gif/png |
193 |
assertTrue("image not saved " + filetype, imageFile.exists()); |
206 |
if (!(isPlatformWinCE5&&(imageFormats[i]=="gif"|imageFormats[i]=="png"))){ |
194 |
} |
207 |
loader.save(imageFile.getName(), imageTypes[i]); |
|
|
208 |
assertTrue("image not saved " + filetype, imageFile.exists()); |
209 |
} |
210 |
} |
211 |
} |
212 |
} |
213 |
//Win32 does not support ImageLoader load jpg/png as inputstream |
214 |
boolean isPlatformWin32 = Platform.isWin32(); |
215 |
boolean isPlatformWinCE5 = Platform.isWinCE(); |
216 |
if(!isPlatformWin32){ |
217 |
filename = "transparent.png"; |
218 |
InputStream inStream = SwtTestCase.class.getResourceAsStream(filename); |
219 |
loader.load(inStream); |
220 |
try { |
221 |
inStream.close(); |
222 |
} catch (IOException e) {} |
223 |
File imageFile = new File("transparentsaved.png"); |
224 |
imageFile.delete(); |
225 |
|
226 |
//WinCE5 does not support ImageLoader save gif/png |
227 |
if (!isPlatformWinCE5){ |
228 |
loader.save(imageFile.getName(), SWT.IMAGE_PNG); |
229 |
assertTrue("transparent png image not saved ", imageFile.exists()); |
230 |
} |
231 |
// j2se and j2me(cdc) can load from a filename but, j2me(cldc) throws an exception |
195 |
} |
232 |
} |
196 |
filename = "transparent.png"; |
|
|
197 |
InputStream inStream = SwtTestCase.class.getResourceAsStream(filename); |
198 |
loader.load(inStream); |
199 |
try { |
200 |
inStream.close(); |
201 |
} catch (IOException e) {} |
202 |
File imageFile = new File("transparentsaved.png"); |
203 |
imageFile.delete(); |
204 |
loader.save(imageFile.getName(), SWT.IMAGE_PNG); |
205 |
assertTrue("transparent png image not saved ", imageFile.exists()); |
206 |
// j2se and j2me(cdc) can load from a filename but, j2me(cldc) throws an exception |
207 |
} |
233 |
} |
208 |
} |
234 |
} |