jdk/test/java/awt/xembed/server/TestXEmbedServer.java
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 7806 ad4062c4253d
child 31660 1a4e2e5c15e1
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 7806
diff changeset
     2
 * Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     4
 *
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     7
 * published by the Free Software Foundation.
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     8
 *
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    13
 * accompanied this code).
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    14
 *
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 443
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 443
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 443
diff changeset
    21
 * questions.
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    22
 */
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    23
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    24
import java.awt.*;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    25
import java.awt.event.*;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    26
import javax.swing.*;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    27
import java.io.*;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    28
import java.util.logging.*;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    29
import sun.awt.WindowIDProvider;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    30
import java.awt.dnd.*;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    31
import java.awt.datatransfer.*;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    32
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    33
public abstract class TestXEmbedServer {
7806
ad4062c4253d 6560348: PIT : java/awt/xembed/server/RunTestXEmbed.java fails
ptisnovs
parents: 5506
diff changeset
    34
    // vertical position of server AND client windows
ad4062c4253d 6560348: PIT : java/awt/xembed/server/RunTestXEmbed.java fails
ptisnovs
parents: 5506
diff changeset
    35
    private static final int VERTICAL_POSITION = 200;
ad4062c4253d 6560348: PIT : java/awt/xembed/server/RunTestXEmbed.java fails
ptisnovs
parents: 5506
diff changeset
    36
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    37
    private static final Logger log = Logger.getLogger("test.xembed");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    38
    Frame f;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    39
    Canvas client;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    40
    Button toFocus;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    41
    Button b_modal;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    42
    JButton b_close;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    43
    JDialog modal_d;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    44
    JFrame dummy;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    45
    Container clientCont;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    46
    boolean passed;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    47
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    48
    public boolean isPassed() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    49
        return passed;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    50
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    51
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    52
    public TestXEmbedServer(boolean manual) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    53
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    54
        // Enable testing extensions in XEmbed server
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    55
        System.setProperty("sun.awt.xembed.testing", "true");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    56
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    57
        f = new Frame("Main frame");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    58
        f.addWindowListener(new WindowAdapter() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    59
                public void windowClosing(WindowEvent e) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    60
                    synchronized(TestXEmbedServer.this) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    61
                        TestXEmbedServer.this.notifyAll();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    62
                    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    63
                    dummy.dispose();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    64
                    f.dispose();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    65
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    66
            });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    67
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    68
        f.setLayout(new BorderLayout());
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    69
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    70
        Container bcont = new Container();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    71
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    72
        toFocus = new Button("Click to focus server");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    73
        final TextField tf = new TextField(20);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    74
        tf.setName("0");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    75
        DragSource ds = new DragSource();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    76
        final DragSourceListener dsl = new DragSourceAdapter() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    77
                public void dragDropEnd(DragSourceDropEvent dsde) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    78
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    79
            };
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    80
        final DragGestureListener dgl = new DragGestureListener() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    81
                public void dragGestureRecognized(DragGestureEvent dge) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    82
                    dge.startDrag(null, new StringSelection(tf.getText()), dsl);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    83
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    84
            };
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    85
        ds.createDefaultDragGestureRecognizer(tf, DnDConstants.ACTION_COPY, dgl);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    86
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    87
        final DropTargetListener dtl = new DropTargetAdapter() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    88
                public void drop(DropTargetDropEvent dtde) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    89
                    dtde.acceptDrop(DnDConstants.ACTION_COPY);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    90
                    try {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    91
                        tf.setText(tf.getText() + (String)dtde.getTransferable().getTransferData(DataFlavor.stringFlavor));
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    92
                    } catch (Exception e) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    93
                    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    94
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    95
            };
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    96
        final DropTarget dt = new DropTarget(tf, dtl);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    97
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    98
        Button b_add = new Button("Add client");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    99
        b_add.addActionListener(new ActionListener() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   100
                public void actionPerformed(ActionEvent e) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   101
                    addClient();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   102
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   103
            });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   104
        Button b_remove = new Button("Remove client");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   105
        b_remove.addActionListener(new ActionListener() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   106
                public void actionPerformed(ActionEvent e) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   107
                    if (clientCont.getComponentCount() != 0) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   108
                        clientCont.remove(clientCont.getComponentCount()-1);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   109
                    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   110
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   111
            });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   112
        b_close = new JButton("Close modal dialog");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   113
        b_close.addActionListener(new ActionListener() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   114
                public void actionPerformed(ActionEvent e) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   115
                    modal_d.dispose();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   116
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   117
            });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   118
        b_modal = new Button("Show modal dialog");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   119
        b_modal.addActionListener(new ActionListener() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   120
                public void actionPerformed(ActionEvent e) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   121
                    modal_d = new JDialog(f, "Modal dialog", true);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   122
                    modal_d.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   123
                    modal_d.setBounds(0, 100, 200, 50);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   124
                    modal_d.getContentPane().add(b_close);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   125
                    modal_d.validate();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   126
                    modal_d.show();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   127
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   128
            });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   129
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   130
        bcont.add(tf);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   131
        bcont.add(toFocus);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   132
        bcont.add(b_add);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   133
        bcont.add(b_remove);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   134
        bcont.add(b_modal);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   135
        if (manual) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   136
            Button pass = new Button("Pass");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   137
            pass.addActionListener(new ActionListener() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   138
                    public void actionPerformed(ActionEvent e) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   139
                        passed = true;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   140
                        synchronized(TestXEmbedServer.this) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   141
                            TestXEmbedServer.this.notifyAll();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   142
                        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   143
                    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   144
                });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   145
            bcont.add(pass);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   146
            Button fail = new Button("Fail");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   147
            fail.addActionListener(new ActionListener() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   148
                    public void actionPerformed(ActionEvent e) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   149
                        passed = false;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   150
                        synchronized(TestXEmbedServer.this) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   151
                            TestXEmbedServer.this.notifyAll();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   152
                        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   153
                    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   154
                });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   155
            bcont.add(fail);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   156
        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   157
        b_modal.setName("2");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   158
        bcont.setLayout(new FlowLayout());
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   159
        f.add(bcont, BorderLayout.NORTH);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   160
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   161
        clientCont = Box.createVerticalBox();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   162
        f.add(clientCont, BorderLayout.CENTER);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   163
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   164
        dummy = new JFrame("Dummy");
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   165
        dummy.getContentPane().add(new JButton("Button"));
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   166
        dummy.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
7806
ad4062c4253d 6560348: PIT : java/awt/xembed/server/RunTestXEmbed.java fails
ptisnovs
parents: 5506
diff changeset
   167
        dummy.setBounds(0, VERTICAL_POSITION, 100, 100);
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   168
        dummy.setVisible(true);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   169
7806
ad4062c4253d 6560348: PIT : java/awt/xembed/server/RunTestXEmbed.java fails
ptisnovs
parents: 5506
diff changeset
   170
        f.setBounds(300, VERTICAL_POSITION, 800, 300);
443
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   171
        f.setVisible(true);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   172
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   173
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   174
    public abstract Process startClient(Rectangle bounds[], long window);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   175
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   176
    public void addClient() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   177
        client = new Canvas() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   178
                public void paint(Graphics g) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   179
                    super.paint(g);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   180
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   181
            };
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   182
        client.setBackground(new Color(30, 220, 40));
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   183
        clientCont.add(client);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   184
        clientCont.validate();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   185
        WindowIDProvider pid = (WindowIDProvider)client.getPeer();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   186
        log.fine("Added XEmbed server(Canvas) with X window ID " + pid.getWindow());
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   187
        Rectangle toFocusBounds = toFocus.getBounds();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   188
        toFocusBounds.setLocation(toFocus.getLocationOnScreen());
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   189
        f.validate();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   190
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   191
        // KDE doesn't accept clicks on title as activation - click below title
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   192
        Rectangle fbounds = f.getBounds();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   193
        fbounds.y += f.getInsets().top;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   194
        fbounds.height -= f.getInsets().top;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   195
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   196
        Process proc = startClient(new Rectangle[] {fbounds, dummy.getBounds(), toFocusBounds,
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   197
                                                    new Rectangle(b_modal.getLocationOnScreen(), b_modal.getSize()),
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   198
                                                    new Rectangle(10, 130, 20, 20)}, pid.getWindow());
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   199
        new ClientWatcher(client, proc, clientCont).start();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   200
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   201
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   202
    public void dispose() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   203
        f.dispose();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   204
        f = null;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   205
        dummy.dispose();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   206
        dummy = null;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   207
        if (modal_d != null) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   208
            modal_d.dispose();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   209
            modal_d = null;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   210
        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   211
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   212
}
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   213
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   214
class ClientWatcher extends Thread {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   215
    private Process clientProcess;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   216
    private Canvas client;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   217
    private Container parent;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   218
    public ClientWatcher(Canvas client, Process proc, Container parent) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   219
        this.client = client;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   220
        this.clientProcess = proc;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   221
        this.parent = parent;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   222
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   223
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   224
    public void run() {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   225
        try {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   226
            clientProcess.waitFor();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   227
        } catch (InterruptedException ie) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   228
        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   229
        parent.remove(client);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   230
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   231
}