jdk/test/java/awt/Graphics2D/DrawString/XRenderElt254TextTest.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 23010 6dadb192ad81
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:
21778
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
     1
/*
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 23010
diff changeset
     2
 * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
21778
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
     4
 *
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
     7
 * published by the Free Software Foundation.
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
     8
 *
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    13
 * accompanied this code).
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    14
 *
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    18
 *
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    21
 * questions.
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    22
 */
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    23
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    24
import java.awt.*;
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    25
import java.awt.MultipleGradientPaint.*;
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    26
import java.awt.image.*;
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    27
import java.io.*;
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    28
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    29
import javax.imageio.*;
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    30
import javax.swing.*;
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    31
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    32
/**
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    33
 * @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 23010
diff changeset
    34
 * @key headful
21778
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    35
 * @bug 8028722
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    36
 * @summary tests wether drawString with 254 characters causes the xrender
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    37
 *          pipeline to hang.
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    38
 * @author ceisserer
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    39
 */
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    40
public class XRenderElt254TextTest extends Frame implements Runnable {
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    41
    public volatile boolean success = false;
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    42
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    43
    public void run() {
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    44
        Image dstImg = getGraphicsConfiguration().createCompatibleVolatileImage(400, 400);
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    45
        Graphics2D g = (Graphics2D) dstImg.getGraphics();
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    46
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    47
        StringBuilder strBuilder = new StringBuilder(254);
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    48
        for (int c = 0; c < 254; c++) {
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    49
          strBuilder.append('a');
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    50
        }
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    51
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    52
        for (int i = 0; i < 100; i++) {
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    53
            g.drawString(strBuilder.toString(), 20, 20);
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    54
            Toolkit.getDefaultToolkit().sync();
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    55
        }
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    56
        success = true;
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    57
    }
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    58
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    59
    public static void main(String[] args) throws Exception {
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    60
        XRenderElt254TextTest test = new XRenderElt254TextTest();
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    61
        new Thread(test).start();
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    62
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    63
        for (int i = 0; i < 30; i++) {
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    64
            Thread.sleep(1000);
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    65
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    66
            if (test.success) {
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    67
            return; // Test finished successful
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    68
            }
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    69
        }
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    70
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    71
        throw new RuntimeException("Test Failed");
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    72
    }
2548f26027c1 8028722: Render: Drawing strings with exactly 254 glyphs causes hangs
ceisserer
parents:
diff changeset
    73
}