--- /dev/null 2015-11-05 17:33:53.132999596 +0400
+++ new/test/java/awt/image/multiresolution/MultiDisplayTest/MultiDisplayTest.html 2015-11-13 15:15:07.714332461 +0400
@@ -0,0 +1,56 @@
+
+
+
+
+ MultiDisplayTest
+
+
+
+
+This test requires two-display configuration, where
+
+- 1st display is operating in HiDPI mode
+- 2nd display is non-HiDPI.
+
+In other cases please simply push "Pass".
+
+
+To run test please push "Start".
+
+Then drag parent / child to different displays and check
+that the proper image is shown for every window
+(must be "1x" for non-HiDPI and "2x" for HiDPI).
+
+Please try to drag both parent and child,
+do it fast several times and check if no artefacts occur.
+
+For Mac OS X please check also the behavior for
+translucent windows appearing on the 2nd (non-active) display.
+
+Close the windows.
+
+In case if no issues occur please push "Pass", otherwise "Fail".
+
+
+
--- /dev/null 2015-11-05 17:33:53.132999596 +0400
+++ new/test/java/awt/image/multiresolution/MultiDisplayTest/MultiDisplayTest.java 2015-11-13 15:15:08.326332434 +0400
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+
+/*
+ @test
+ @bug 8142861
+ @summary Check if multiresolution image behaves properly on HiDPI + non-HiDPI display pair.
+ @author a.stepanov
+ @run applet/manual=yesno MultiDisplayTest.html
+*/
+
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import javax.imageio.ImageIO;
+
+
+public class MultiDisplayTest extends Applet {
+
+ private static final int W = 200;
+ private static final int H = 200;
+
+
+
+ public void init() { this.setLayout(new BorderLayout()); }
+
+ public void start() {
+
+ Button b = new Button("Start");
+
+ b.addActionListener(new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
+ ParentFrame p = new ParentFrame();
+ new ChildDialog(p);
+ }
+ });
+
+ add(b, BorderLayout.CENTER);
+
+ validate();
+ setVisible(true);
+ }
+
+
+
+ private static void generateImagePair(String name, Color c) {
+
+ String name1x = name + ".png", name2x = name + "@2x.png";
+
+ try {
+ if (!new File(name1x).exists()) { generateImage(name1x, 1, c); }
+ if (!new File(name2x).exists()) { generateImage(name2x, 2, c); }
+ } catch (Exception dummy) {
+ System.err.println("cannot create images for " + name);
+ System.exit(1);
+ }
+ }
+
+ private static void generateImage(String name, int scale, Color c) throws IOException {
+
+ BufferedImage image = new BufferedImage(scale * W, scale * H, BufferedImage.TYPE_INT_RGB);
+ Graphics g = image.getGraphics();
+ g.setColor(c);
+ g.fillRect(0, 0, scale * W, scale * H);
+
+ g.setColor(Color.WHITE);
+ Font f = g.getFont();
+ g.setFont(new Font(f.getName(), Font.BOLD, scale * 48));
+ g.drawChars((scale + "X").toCharArray(), 0, 2, scale * W / 2, scale * H / 2);
+
+ ImageIO.write(image, "png", new File(name));
+ }
+
+ private static class ParentFrame extends Frame {
+
+ private final String parentName = "parent";
+
+ public ParentFrame() {
+ EventQueue.invokeLater(this::CreateUI);
+ }
+
+ private void CreateUI() {
+
+ generateImagePair(parentName, Color.BLACK);
+
+ addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) { dispose(); }
+ });
+ setSize(W, H);
+ setLocation(50, 50);
+ setTitle(parentName);
+ setResizable(false);
+ setVisible(true);
+ }
+
+ @Override
+ public void paint(Graphics gr) {
+
+ Graphics2D g = (Graphics2D) gr;
+ if (g != null) {
+ Image img = Toolkit.getDefaultToolkit().getImage(
+ new File(parentName + ".png").getAbsolutePath());
+ g.drawImage(img, 0, 0, this);
+ }
+ }
+ }
+
+ private static class ChildDialog extends Dialog {
+
+ private final String childName = "child";
+
+ public ChildDialog(Frame f) {
+ super(f);
+ EventQueue.invokeLater(this::CreateUI);
+ }
+
+ private void CreateUI() {
+
+ generateImagePair(childName, Color.BLUE);
+
+ addWindowListener(new WindowAdapter() {
+ @Override
+ public void windowClosing(WindowEvent e) { dispose(); }
+ });
+ setSize(W, H);
+ setTitle(childName);
+ setResizable(false);
+ setModal(true);
+ setVisible(true);
+ }
+
+ @Override
+ public void paint(Graphics gr) {
+
+ Graphics2D g = (Graphics2D) gr;
+ if (g != null) {
+ Image img = Toolkit.getDefaultToolkit().getImage(
+ new File(childName + ".png").getAbsolutePath());
+ g.drawImage(img, 0, 0, this);
+ }
+ }
+ }
+}
+