jdk/test/java/awt/datatransfer/SystemSelection/SystemSelectionSwingTest.java
author goetz
Tue, 14 Jun 2016 10:44:59 +0200
changeset 39056 d99e63b6d962
parent 25569 2bea87828632
permissions -rw-r--r--
8159690: [TESTBUG] Mark headful tests with @key headful. Reviewed-by: simonis, alexsch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25569
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     1
/*
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 25569
diff changeset
     2
 * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
25569
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     4
 *
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    10
 *
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    15
 * accompanied this code).
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    16
 *
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    20
 *
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    23
 * questions.
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    24
 */
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    25
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    26
import javax.swing.*;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    27
import java.awt.*;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    28
import java.awt.datatransfer.Clipboard;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    29
import java.awt.datatransfer.DataFlavor;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    30
import java.awt.datatransfer.Transferable;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    31
import java.awt.event.FocusAdapter;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    32
import java.awt.event.FocusEvent;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    33
import java.awt.event.InputEvent;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    34
import java.util.Properties;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    35
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    36
/*
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    37
 * @test
39056
d99e63b6d962 8159690: [TESTBUG] Mark headful tests with @key headful.
goetz
parents: 25569
diff changeset
    38
 * @key headful
25569
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    39
 * @summary To check the functionality of newly added API getSystemSelection & make sure
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    40
 *          that it's mapped to primary clipboard
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    41
 * @author Jitender(jitender.singh@eng.sun.com) area=AWT
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    42
 * @library ../../../../lib/testlibrary
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    43
 * @build ExtendedRobot
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    44
 * @run main SystemSelectionSwingTest
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    45
 */
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    46
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    47
public class SystemSelectionSwingTest {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    48
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    49
    JFrame jframe;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    50
    JTextField jtf1, jtf2;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    51
    Clipboard clip;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    52
    Transferable t;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    53
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    54
    public static void main(String[] args) throws Exception {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    55
        new SystemSelectionSwingTest().doTest();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    56
    }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    57
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    58
    SystemSelectionSwingTest() {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    59
        jframe = new JFrame();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    60
        jframe.setSize(200, 200);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    61
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    62
        jtf1 = new JTextField();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    63
        jtf1.addFocusListener( new FocusAdapter() {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    64
            public void focusGained(FocusEvent fe) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    65
                fe.getSource();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    66
            }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    67
        });
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    68
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    69
        jtf2 = new JTextField();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    70
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    71
        jframe.add(jtf2, BorderLayout.NORTH);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    72
        jframe.add(jtf1, BorderLayout.CENTER);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    73
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    74
        jframe.setVisible(true);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    75
        jframe.toFront();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    76
        jtf1.requestFocus();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    77
        jtf1.setText("Selection Testing");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    78
    }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    79
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    80
    // Check whether Security manager is there
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    81
    public void checkSecurity() {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    82
        SecurityManager sm = System.getSecurityManager();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    83
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    84
        if (sm == null) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    85
            System.out.println("security manager is not there");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    86
            getPrimaryClipboard();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    87
        } else {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    88
            try {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    89
                sm.checkPermission(new AWTPermission("accessClipboard"));
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    90
                getPrimaryClipboard();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    91
            } catch(SecurityException e) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    92
                clip = null;
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    93
                System.out.println("Access to System selection is not allowed");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    94
            }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    95
        }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    96
    }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    97
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    98
    // Get the contents from the clipboard
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
    99
    void getClipboardContent() throws Exception {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   100
        t = clip.getContents(this);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   101
        if ( (t != null) && (t.isDataFlavorSupported(DataFlavor.stringFlavor) )) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   102
            jtf2.setBackground(Color.red);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   103
            jtf2.setForeground(Color.black);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   104
            jtf2.setText((String) t.getTransferData(DataFlavor.stringFlavor));
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   105
        }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   106
    }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   107
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   108
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   109
    // Get System Selection i.e. Primary Clipboard
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   110
    private void getPrimaryClipboard() {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   111
        Properties ps = System.getProperties();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   112
        String operSys = ps.getProperty("os.name");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   113
        clip = Toolkit.getDefaultToolkit().getSystemSelection();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   114
        if (clip == null) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   115
            if ((operSys.substring(0,3)).equalsIgnoreCase("Win") ||
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   116
                    (operSys.substring(0,3)).equalsIgnoreCase("Mac"))
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   117
                System.out.println(operSys + " operating system does not support system selection ");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   118
            else
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   119
                throw new RuntimeException("Method getSystemSelection() is returning null on X11 platform");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   120
        }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   121
    }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   122
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   123
    // Compare the selected text with one pasted from the clipboard
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   124
    public void compareText() {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   125
        if ((jtf2.getText()).equals(jtf1.getSelectedText()) &&
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   126
                System.getProperties().getProperty("os.name").substring(0,3) != "Win") {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   127
            System.out.println("Selected text & clipboard contents are same\n");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   128
        } else  {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   129
            throw new RuntimeException("Selected text & clipboard contents differs\n");
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   130
        }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   131
    }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   132
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   133
    public void doTest() throws Exception {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   134
        ExtendedRobot robot = new ExtendedRobot();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   135
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   136
        jframe.setLocation(100, 100);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   137
        robot.waitForIdle(2000);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   138
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   139
        Point tf1Location = jtf1.getLocationOnScreen();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   140
        Dimension tf1Size = jtf1.getSize();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   141
        checkSecurity();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   142
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   143
        if (clip != null) {
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   144
            robot.mouseMove(tf1Location.x + 5, tf1Location.y + tf1Size.height / 2);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   145
            robot.waitForIdle(2000);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   146
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   147
            robot.waitForIdle(20);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   148
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   149
            robot.waitForIdle(20);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   150
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   151
            robot.waitForIdle(20);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   152
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   153
            robot.waitForIdle(2000);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   154
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   155
            getClipboardContent();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   156
            compareText();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   157
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   158
            robot.mouseMove(tf1Location.x + tf1Size.width / 2, tf1Location.y + tf1Size.height / 2);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   159
            robot.waitForIdle(2000);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   160
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   161
            robot.waitForIdle(20);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   162
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   163
            robot.waitForIdle(20);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   164
            robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   165
            robot.waitForIdle(20);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   166
            robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   167
            robot.waitForIdle(2000);
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   168
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   169
            getClipboardContent();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   170
            compareText();
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   171
        }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   172
    }
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   173
}
2bea87828632 8048246: Move AWT_DnD/Clipboard/Automated functional tests to OpenJDK
yan
parents:
diff changeset
   174