< prev index next >
test/java/awt/image/MultiResolutionImageTest.java
Print this page
*** 36,45 ****
--- 36,46 ----
import java.awt.RenderingHints;
import java.awt.image.ImageObserver;
import javax.swing.JPanel;
import jdk.testlibrary.Platform;
import java.awt.image.MultiResolutionImage;
+ import sun.awt.SunToolkit;
/**
* @test @bug 8011059
* @author Alexander Scherbatiy
* @summary [macosx] Make JDK demos look perfect on retina displays
*** 409,446 ****
}
throw new RuntimeException("Test url: " + testURL
+ ", result url: " + resultURL);
}
-
}
static URL getTestScaledImageURL(URL url) throws Exception {
! Method method = getScalableImageMethod("getScaledImageURL", URL.class);
! return (URL) method.invoke(null, url);
}
static String getTestScaledImageName(String name) throws Exception {
! Method method = getScalableImageMethod(
! "getScaledImageName", String.class);
! return (String) method.invoke(null, name);
}
private static boolean isValidPath(String path) {
return !path.isEmpty() && !path.endsWith("/") && !path.endsWith(".")
&& !path.contains("@2x");
}
- private static Method getScalableImageMethod(String name,
- Class... parameterTypes) throws Exception {
- Toolkit toolkit = Toolkit.getDefaultToolkit();
- Method method = toolkit.getClass()
- .
- getDeclaredMethod(name, parameterTypes);
- method.setAccessible(true);
- return method;
- }
private static final String[][] TEST_FILE_NAMES;
private static final URL[][] TEST_URLS;
static {
TEST_FILE_NAMES = new String[][]{
--- 410,445 ----
}
throw new RuntimeException("Test url: " + testURL
+ ", result url: " + resultURL);
}
}
static URL getTestScaledImageURL(URL url) throws Exception {
! String scaledPath = getTestScaledImageName(url.getPath());
! if (scaledPath == null) {
! return null;
! }
! return new URL(url.getProtocol(), url.getHost(), url.getPort(), scaledPath);
}
static String getTestScaledImageName(String name) throws Exception {
! Toolkit.MediaResolutionNamingScheme[] mediaSchemes = {
! new Toolkit.MediaResolutionNamingScheme("@2x", 2f)
! };
! Method method = SunToolkit.class
! .getDeclaredMethod("getRVNames", String.class, mediaSchemes.getClass());
! method.setAccessible(true);
! Object result = method.invoke(null, name, mediaSchemes);
! return result == null ? null : ((String[])result)[0];
}
private static boolean isValidPath(String path) {
return !path.isEmpty() && !path.endsWith("/") && !path.endsWith(".")
&& !path.contains("@2x");
}
private static final String[][] TEST_FILE_NAMES;
private static final URL[][] TEST_URLS;
static {
TEST_FILE_NAMES = new String[][]{
*** 449,460 ****
{"..", null},
{"/", null},
{"/.", null},
{"dir/", null},
{"dir/.", null},
- {"aaa@2x.png", null},
- {"/dir/aaa@2x.png", null},
{"image", "image@2x"},
{"image.ext", "image@2x.ext"},
{"image.aaa.ext", "image.aaa@2x.ext"},
{"dir/image", "dir/image@2x"},
{"dir/image.ext", "dir/image@2x.ext"},
--- 448,457 ----
< prev index next >