jdk/test/java/awt/Window/BackgroundIsNotUpdated/BackgroundIsNotUpdated.java
author yan
Fri, 05 Dec 2014 14:55:08 +0300
changeset 28087 622b2f420bc3
parent 23248 3418855fb2c5
child 39056 d99e63b6d962
permissions -rw-r--r--
8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2 Reviewed-by: serb, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
23248
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
     1
/*
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
     4
 *
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
     7
 * published by the Free Software Foundation.
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
     8
 *
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    13
 * accompanied this code).
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    14
 *
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    18
 *
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    21
 * questions.
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    22
 */
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    23
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    24
import java.awt.AWTException;
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    25
import java.awt.Color;
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    26
import java.awt.Frame;
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    27
import java.awt.Graphics;
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    28
import java.awt.Point;
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    29
import java.awt.Robot;
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    30
import java.awt.Window;
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    31
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    32
/**
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    33
 * @test
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    34
 * @bug 8001472
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    35
 * @summary Background of the window should not depend from the paint()/update()
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    36
 * @author Sergey Bylokhov
28087
622b2f420bc3 8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 23248
diff changeset
    37
 * @library ../../../../lib/testlibrary
622b2f420bc3 8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 23248
diff changeset
    38
 * @build ExtendedRobot
622b2f420bc3 8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 23248
diff changeset
    39
 * @run main BackgroundIsNotUpdated
23248
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    40
 */
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    41
public final class BackgroundIsNotUpdated extends Window {
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    42
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    43
    public BackgroundIsNotUpdated(final Frame owner) {
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    44
        super(owner);
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    45
    }
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    46
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    47
    @Override
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    48
    public void paint(final Graphics ignored) {
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    49
        // Intentionally left blank
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    50
    }
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    51
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    52
    @Override
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    53
    public void update(final Graphics ignored) {
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    54
        // Intentionally left blank
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    55
    }
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    56
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    57
    public static void main(final String[] args) throws AWTException {
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    58
        final Window window = new BackgroundIsNotUpdated(null);
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    59
        window.setSize(300, 300);
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    60
        window.setLocationRelativeTo(null);
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    61
        window.setVisible(true);
28087
622b2f420bc3 8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 23248
diff changeset
    62
        window.requestFocus();
622b2f420bc3 8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 23248
diff changeset
    63
        final ExtendedRobot robot = new ExtendedRobot();
622b2f420bc3 8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 23248
diff changeset
    64
        robot.setAutoDelay(200);
622b2f420bc3 8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 23248
diff changeset
    65
        robot.waitForIdle(1000);
23248
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    66
        window.setBackground(Color.GREEN);
28087
622b2f420bc3 8063104: Change open awt regression tests to avoid sun.awt.SunToolkit.realSync, part 2
yan
parents: 23248
diff changeset
    67
        robot.waitForIdle(1000);
23248
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    68
        Point point = window.getLocationOnScreen();
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    69
        Color color = robot.getPixelColor(point.x + window.getWidth() / 2,
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    70
                                          point.y + window.getHeight() / 2);
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    71
        window.dispose();
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    72
        if (!color.equals(Color.GREEN)) {
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    73
            throw new RuntimeException(
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    74
                    "Expected: " + Color.GREEN + " , Actual: " + color);
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    75
        }
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    76
    }
3418855fb2c5 8001472: api/java_awt/Window/indexTGF_* tests fail because expected colors aren't equal
serb
parents:
diff changeset
    77
}