/* * Copyright (c) 2022, 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 8255439 * @key headful * @library /java/awt/regtesthelpers * @build PassFailJFrame * @summary To test tray icon scaling with on-the-fly DPI/Scale changes on Windows * @run main/manual TrayIconScalingTest * @requires (os.family == "windows")
*/
privatestaticfinal String INSTRUCTIONS = "This test checks if the tray icon gets updated when DPI / Scale" + " is changed on the fly.\n\n" + "STEPS: \n\n" + "1. Check the system tray / notification area on Windows" + " taskbar, you should see a white icon which displays a" + " number.\n\n" + "2. Navigate to Settings > System > Display and change the" + " display scale by selecting any value from" + " Scale & Layout dropdown.\n\n"+ "3. When the scale changes, check the white tray icon," + " there should be no distortion, it should be displayed sharp,\n" + " and the displayed number should correspond to the current"+ " scale:\n" + " 100% - 16, 125% - 20, 150% - 24, 175% - 28, 200% - 32.\n\n"+ " If the icon is displayed sharp and without any distortion," + " press PASS, otherwise press FAIL.\n";
privatestaticfinal Font font = new Font("Dialog", Font.BOLD, 12);
publicstaticvoid main(String[] args) throws InterruptedException, InvocationTargetException { // check if SystemTray supported on the machine if (!SystemTray.isSupported()) {
System.out.println("SystemTray is not supported"); return;
}
PassFailJFrame passFailJFrame = new PassFailJFrame("TrayIcon " + "Test Instructions", INSTRUCTIONS, 8, 18, 85);
createAndShowGUI(); // does not have a test window, // hence only the instruction frame is positioned
PassFailJFrame.positionTestWindow(null,
PassFailJFrame.Position.HORIZONTAL); try {
passFailJFrame.awaitAndCheck();
} finally {
tray.remove(icon);
}
}
privatestaticvoid createAndShowGUI() {
ArrayList<Image> imageList = new ArrayList<>(); for (int size = 16; size <= 48; size += 4) {
imageList.add(createIcon(size));
}
Image mRImage = new BaseMultiResolutionImage(imageList.toArray(new Image[0]));
tray = SystemTray.getSystemTray();
icon = new TrayIcon(mRImage);
try {
tray.add(icon);
} catch (AWTException e) { thrownew RuntimeException("Error while adding icon to system tray");
}
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.15Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.