-
Notifications
You must be signed in to change notification settings - Fork 147
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f77c69b
commit 07f860c
Showing
6 changed files
with
960 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
.../JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_graphics_SVGRasterizer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.eclipse.swt.tests.junit; | ||
|
||
import static org.eclipse.swt.tests.junit.SwtTestUtil.assertSWTProblem; | ||
import static org.junit.Assert.fail; | ||
|
||
import java.io.File; | ||
import java.net.URL; | ||
|
||
import org.eclipse.swt.SWT; | ||
import org.eclipse.swt.SWTException; | ||
import org.eclipse.swt.graphics.Image; | ||
import org.eclipse.swt.graphics.ImageData; | ||
import org.eclipse.swt.graphics.ImageDataProvider; | ||
import org.eclipse.swt.graphics.ImageFileNameProvider; | ||
import org.eclipse.swt.widgets.Display; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
public class Test_org_eclipse_swt_graphics_SVGRasterizer { | ||
Display display; | ||
|
||
ImageFileNameProvider imageFileNameProvider = zoom -> { | ||
String fileName = "collapseall.svg"; | ||
return getPath(fileName); | ||
}; | ||
|
||
ImageDataProvider imageDataProvider = zoom -> { | ||
String fileName = "collapseall.svg"; | ||
return new ImageData(getPath(fileName), zoom); | ||
}; | ||
|
||
@Before | ||
public void setUp() { | ||
display = Display.getDefault(); | ||
} | ||
|
||
String getPath(String fileName) { | ||
String urlPath; | ||
String pluginPath = System.getProperty("PLUGIN_PATH"); | ||
if (pluginPath == null) { | ||
URL url = getClass().getClassLoader().getResource(fileName); | ||
if (url == null) { | ||
fail("URL == null for file " + fileName); | ||
} | ||
urlPath = url.getFile(); | ||
} else { | ||
urlPath = pluginPath + "/data/" + fileName; | ||
} | ||
|
||
if (File.separatorChar != '/') urlPath = urlPath.replace('/', File.separatorChar); | ||
if (SwtTestUtil.isWindows && urlPath.indexOf(File.separatorChar) == 0) urlPath = urlPath.substring(1); | ||
urlPath = urlPath.replaceAll("%20", " "); | ||
return urlPath; | ||
} | ||
|
||
@Test | ||
public void test_ConstructorLorg_eclipse_swt_graphics_Device_ImageFileNameProvider() { | ||
// Valid provider | ||
Image image = new Image(display, imageFileNameProvider); | ||
image.dispose(); | ||
// Corrupt Image provider | ||
ImageFileNameProvider provider = zoom -> { | ||
String fileName = "corrupt.svg"; | ||
return getPath(fileName); | ||
}; | ||
try { | ||
image = new Image(display, provider); | ||
image.dispose(); | ||
fail("No exception thrown for corrupt image file."); | ||
} catch (SWTException e) { | ||
assertSWTProblem("Incorrect exception thrown for provider with corrupt images", SWT.ERROR_INVALID_IMAGE, e); | ||
} | ||
} | ||
|
||
@Test | ||
public void test_ConstructorLorg_eclipse_swt_graphics_Device_ImageDataProvider() { | ||
// Valid provider | ||
Image image = new Image(display, imageDataProvider); | ||
image.dispose(); | ||
// Corrupt Image provider | ||
ImageDataProvider provider = zoom -> { | ||
String fileName = "corrupt.svg"; | ||
return new ImageData(getPath(fileName), zoom); | ||
}; | ||
try { | ||
image = new Image(display, provider); | ||
image.dispose(); | ||
fail("No exception thrown for corrupt image file."); | ||
} catch (SWTException e) { | ||
assertSWTProblem("Incorrect exception thrown for provider with corrupt images", SWT.ERROR_INVALID_IMAGE, e); | ||
} | ||
} | ||
} |
223 changes: 223 additions & 0 deletions
223
...s/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/collapseall.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.