jdk/test/java/awt/xembed/server/TestXEmbedServer.java
author volk
Sun, 13 Apr 2008 23:41:40 +0400
changeset 443 b49bc385fa7e
child 5506 202f599c92aa
permissions -rw-r--r--
6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348) Summary: Some AWT reg. tests are moved to open repository (for CRs 6444769, 6480547, and 6560348) Reviewed-by: ant
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
/*
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
     2
 * Copyright 2004-2008 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    21
 * have any questions.
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 {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    34
    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
    35
    Frame f;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    36
    Canvas client;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    37
    Button toFocus;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    38
    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
    39
    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
    40
    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
    41
    JFrame dummy;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    42
    Container clientCont;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    43
    boolean passed;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    44
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    45
    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
    46
        return 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
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    49
    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
    50
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    51
        // 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
    52
        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
    53
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    54
        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
    55
        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
    56
                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
    57
                    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
    58
                        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
    59
                    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    60
                    dummy.dispose();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    61
                    f.dispose();
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
            });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    64
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    65
        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
    66
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    67
        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
    68
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    69
        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
    70
        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
    71
        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
    72
        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
    73
        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
    74
                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
    75
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    76
            };
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    77
        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
    78
                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
    79
                    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
    80
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    81
            };
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    82
        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
    83
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    84
        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
    85
                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
    86
                    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
    87
                    try {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    88
                        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
    89
                    } 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
    90
                    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    91
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    92
            };
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    93
        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
    94
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    95
        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
    96
        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
    97
                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
    98
                    addClient();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
    99
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   100
            });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   101
        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
   102
        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
   103
                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
   104
                    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
   105
                        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
   106
                    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   107
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   108
            });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   109
        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
   110
        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
   111
                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
   112
                    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
   113
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   114
            });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   115
        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
   116
        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
   117
                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
   118
                    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
   119
                    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
   120
                    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
   121
                    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
   122
                    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
   123
                    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
   124
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   125
            });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   126
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   127
        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
   128
        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
   129
        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
   130
        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
   131
        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
   132
        if (manual) {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   133
            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
   134
            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
   135
                    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
   136
                        passed = true;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   137
                        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
   138
                            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
   139
                        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   140
                    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   141
                });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   142
            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
   143
            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
   144
            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
   145
                    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
   146
                        passed = false;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   147
                        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
   148
                            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
   149
                        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   150
                    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   151
                });
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   152
            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
   153
        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   154
        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
   155
        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
   156
        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
   157
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   158
        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
   159
        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
   160
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   161
        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
   162
        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
   163
        dummy.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
   164
        dummy.setBounds(0, 0, 100, 100);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   165
        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
   166
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   167
        f.setBounds(300, 0, 800, 300);
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   168
        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
   169
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   170
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   171
    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
   172
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   173
    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
   174
        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
   175
                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
   176
                    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
   177
                }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   178
            };
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   179
        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
   180
        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
   181
        clientCont.validate();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   182
        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
   183
        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
   184
        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
   185
        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
   186
        f.validate();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   187
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   188
        // 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
   189
        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
   190
        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
   191
        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
   192
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   193
        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
   194
                                                    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
   195
                                                    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
   196
        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
   197
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   198
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   199
    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
   200
        f.dispose();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   201
        f = null;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   202
        dummy.dispose();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   203
        dummy = null;
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   204
        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
   205
            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
   206
            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
   207
        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   208
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   209
}
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
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
   212
    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
   213
    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
   214
    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
   215
    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
   216
        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
   217
        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
   218
        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
   219
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   220
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   221
    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
   222
        try {
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   223
            clientProcess.waitFor();
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   224
        } 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
   225
        }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   226
        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
   227
    }
b49bc385fa7e 6686273: Some AWT reg. tests should be moved to open repository (for CRs 6444769, 6480547, and 6560348)
volk
parents:
diff changeset
   228
}