jdk/test/java/awt/GraphicsDevice/CloneConfigsTest.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 27274 62de2c957523
permissions -rw-r--r--
8159690: [TESTBUG] Mark headful tests with @key headful. Reviewed-by: simonis, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4204
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
     1
/*
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 27274
diff changeset
     2
 * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
4204
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
     4
 *
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
     7
 * published by the Free Software Foundation.
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
     8
 *
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    13
 * accompanied this code).
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    14
 *
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4204
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4204
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4204
diff changeset
    21
 * questions.
4204
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    22
 */
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    23
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    24
/*
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    25
 * @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 27274
diff changeset
    26
 * @key headful
27274
62de2c957523 8059848: Test java/awt/GraphicsDevice/CloneConfigsTest.java causes JVM crash in OEL 7.0
prr
parents: 23010
diff changeset
    27
 * @bug     6822057 7124400 8059848
4204
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    28
 *
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    29
 * @summary Test verifies that list of supported graphics configurations
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    30
 *          can not be changed via modification of elements of an array
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    31
 *          returned by getConfiguration() method.
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    32
 *
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    33
 * @run     main CloneConfigsTest
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    34
 * @run     main/othervm -Dsun.java2d.opengl=True CloneConfigsTest
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    35
 * @run     main/othervm -Dsun.java2d.d3d=true CloneConfigsTest
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    36
 * @run     main/othervm -Dsun.java2d.noddraw=true CloneConfigsTest
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    37
 */
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    38
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    39
import java.awt.GraphicsConfiguration;
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    40
import java.awt.GraphicsDevice;
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    41
import java.awt.GraphicsEnvironment;
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    42
import java.awt.Rectangle;
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    43
import java.awt.geom.AffineTransform;
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    44
import java.awt.image.BufferedImage;
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    45
import java.awt.image.ColorModel;
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    46
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    47
public class CloneConfigsTest {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    48
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    49
    public static void main(String[] args) {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    50
        GraphicsEnvironment env =
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    51
                GraphicsEnvironment.getLocalGraphicsEnvironment();
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    52
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    53
        GraphicsDevice[] devices = env.getScreenDevices();
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    54
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    55
        GraphicsConfiguration c = new TestConfig();
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    56
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    57
        for (GraphicsDevice gd : devices) {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    58
            System.out.println("Device: " + gd);
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    59
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    60
            GraphicsConfiguration[] configs = gd.getConfigurations();
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    61
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    62
            for (int i = 0; i < configs.length; i++) {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    63
                GraphicsConfiguration gc  = configs[i];
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    64
                System.out.println("\tConfig: " + gc);
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    65
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    66
                configs[i] = c;
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    67
            }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    68
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    69
            // verify whether array of configs was modified
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    70
            configs = gd.getConfigurations();
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    71
            for (GraphicsConfiguration gc : configs) {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    72
                if (gc == c) {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    73
                    throw new RuntimeException("Test failed.");
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    74
                }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    75
            }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    76
            System.out.println("Test passed.");
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    77
        }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    78
    }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    79
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    80
    private static class TestConfig extends GraphicsConfiguration {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    81
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    82
        @Override
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    83
        public GraphicsDevice getDevice() {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    84
            throw new UnsupportedOperationException("Not supported yet.");
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    85
        }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    86
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    87
        @Override
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    88
        public BufferedImage createCompatibleImage(int width, int height) {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    89
            throw new UnsupportedOperationException("Not supported yet.");
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    90
        }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    91
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    92
        @Override
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    93
        public ColorModel getColorModel() {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    94
            throw new UnsupportedOperationException("Not supported yet.");
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    95
        }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    96
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    97
        @Override
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    98
        public ColorModel getColorModel(int transparency) {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
    99
            throw new UnsupportedOperationException("Not supported yet.");
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   100
        }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   101
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   102
        @Override
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   103
        public AffineTransform getDefaultTransform() {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   104
            throw new UnsupportedOperationException("Not supported yet.");
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   105
        }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   106
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   107
        @Override
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   108
        public AffineTransform getNormalizingTransform() {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   109
            throw new UnsupportedOperationException("Not supported yet.");
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   110
        }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   111
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   112
        @Override
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   113
        public Rectangle getBounds() {
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   114
            throw new UnsupportedOperationException("Not supported yet.");
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   115
        }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   116
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   117
    }
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   118
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents:
diff changeset
   119
}