1838N/A/*
2362N/A * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
1838N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1838N/A *
1838N/A * This code is free software; you can redistribute it and/or modify it
1838N/A * under the terms of the GNU General Public License version 2 only, as
1838N/A * published by the Free Software Foundation.
1838N/A *
1838N/A * This code is distributed in the hope that it will be useful, but WITHOUT
1838N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1838N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
1838N/A * version 2 for more details (a copy is included in the LICENSE file that
1838N/A * accompanied this code).
1838N/A *
1838N/A * You should have received a copy of the GNU General Public License version
1838N/A * 2 along with this work; if not, write to the Free Software Foundation,
1838N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1838N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
1838N/A */
1838N/A
1838N/A/*
1838N/A * @test
5038N/A * @bug 6822057 7124400
1838N/A *
1838N/A * @summary Test verifies that list of supported graphics configurations
1838N/A * can not be changed via modification of elements of an array
1838N/A * returned by getConfiguration() method.
1838N/A *
1838N/A * @run main CloneConfigsTest
1838N/A * @run main/othervm -Dsun.java2d.opengl=True CloneConfigsTest
1838N/A * @run main/othervm -Dsun.java2d.d3d=true CloneConfigsTest
1838N/A * @run main/othervm -Dsun.java2d.noddraw=true CloneConfigsTest
1838N/A */
1838N/A
1838N/Aimport java.awt.GraphicsConfiguration;
1838N/Aimport java.awt.GraphicsDevice;
1838N/Aimport java.awt.GraphicsEnvironment;
1838N/Aimport java.awt.Rectangle;
1838N/Aimport java.awt.geom.AffineTransform;
1838N/Aimport java.awt.image.BufferedImage;
1838N/Aimport java.awt.image.ColorModel;
1838N/A
1838N/Apublic class CloneConfigsTest {
1838N/A
1838N/A public static void main(String[] args) {
1838N/A GraphicsEnvironment env =
1838N/A GraphicsEnvironment.getLocalGraphicsEnvironment();
1838N/A
1838N/A GraphicsDevice[] devices = env.getScreenDevices();
1838N/A
1838N/A GraphicsConfiguration c = new TestConfig();
1838N/A
1838N/A for (GraphicsDevice gd : devices) {
1838N/A System.out.println("Device: " + gd);
1838N/A
1838N/A GraphicsConfiguration[] configs = gd.getConfigurations();
1838N/A
1838N/A for (int i = 0; i < configs.length; i++) {
1838N/A GraphicsConfiguration gc = configs[i];
1838N/A System.out.println("\tConfig: " + gc);
1838N/A
1838N/A configs[i] = c;
1838N/A }
1838N/A
1838N/A // verify whether array of configs was modified
1838N/A configs = gd.getConfigurations();
1838N/A for (GraphicsConfiguration gc : configs) {
1838N/A if (gc == c) {
1838N/A throw new RuntimeException("Test failed.");
1838N/A }
1838N/A }
1838N/A System.out.println("Test passed.");
1838N/A }
1838N/A }
1838N/A
1838N/A private static class TestConfig extends GraphicsConfiguration {
1838N/A
1838N/A @Override
1838N/A public GraphicsDevice getDevice() {
1838N/A throw new UnsupportedOperationException("Not supported yet.");
1838N/A }
1838N/A
1838N/A @Override
1838N/A public BufferedImage createCompatibleImage(int width, int height) {
1838N/A throw new UnsupportedOperationException("Not supported yet.");
1838N/A }
1838N/A
1838N/A @Override
1838N/A public ColorModel getColorModel() {
1838N/A throw new UnsupportedOperationException("Not supported yet.");
1838N/A }
1838N/A
1838N/A @Override
1838N/A public ColorModel getColorModel(int transparency) {
1838N/A throw new UnsupportedOperationException("Not supported yet.");
1838N/A }
1838N/A
1838N/A @Override
1838N/A public AffineTransform getDefaultTransform() {
1838N/A throw new UnsupportedOperationException("Not supported yet.");
1838N/A }
1838N/A
1838N/A @Override
1838N/A public AffineTransform getNormalizingTransform() {
1838N/A throw new UnsupportedOperationException("Not supported yet.");
1838N/A }
1838N/A
1838N/A @Override
1838N/A public Rectangle getBounds() {
1838N/A throw new UnsupportedOperationException("Not supported yet.");
1838N/A }
1838N/A
1838N/A }
1838N/A
1838N/A}