java/awt/TextArea/ScrollbarIntersectionTest/ScrollbarIntersectionTest.java
Print this page
@@ -1,24 +1,48 @@
/*
+ * Copyright (c) 2006, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
@test
@bug 6429174
@summary Tests that mouse click at the are of intersection of two
scrollbars for text area doesn't trigger any scrolling
@author artem.ananiev@sun.com: area=awt.text
+ @library ../../../../lib/testlibrary
+ @build jdk.testlibrary.OSInfo
@run main ScrollbarIntersectionTest
*/
import java.awt.*;
import java.awt.event.*;
+import jdk.testlibrary.OSInfo;
-import sun.awt.*;
public class ScrollbarIntersectionTest
{
private static void init()
{
- SunToolkit tk = (SunToolkit)Toolkit.getDefaultToolkit();
Frame f = new Frame("F");
f.setBounds(100, 100, 480, 360);
f.setLayout(new BorderLayout());
@@ -35,11 +59,10 @@
}
ta.append("\n");
f.add(ta);
f.setVisible(true);
- tk.realSync();
Robot r = null;
try
{
r = new Robot();
@@ -49,13 +72,14 @@
{
z.printStackTrace(System.err);
fail(z.getMessage());
return;
}
+ r.waitForIdle();
ta.setCaretPosition(0);
- tk.realSync();
+ r.waitForIdle();
Point p = ta.getLocationOnScreen();
Dimension d = ta.getSize();
int fh = 8;
@@ -74,21 +98,21 @@
};
r.mouseMove(p.x + d.width - 2, p.y + d.height - 2);
r.mousePress(InputEvent.BUTTON1_MASK);
r.mouseRelease(InputEvent.BUTTON1_MASK);
- tk.realSync();
+ r.waitForIdle();
// select 1st line in the text area
r.mouseMove(p.x + 2, p.y + 2 + fh / 2);
r.mousePress(InputEvent.BUTTON1_MASK);
for (int i = 0; i < d.width - 4; i += 4)
{
r.mouseMove(p.x + 2 + i, p.y + 2 + fh / 2);
}
r.mouseRelease(InputEvent.BUTTON1_MASK);
- tk.realSync();
+ r.waitForIdle();
String sel = ta.getSelectedText();
System.err.println("Selected text: " + sel);
if ((sel == null) || !sel.startsWith("0"))
{
@@ -107,10 +131,16 @@
private static int sleepTime = 300000;
public static void main( String args[] ) throws InterruptedException
{
+ if (OSInfo.getOSType() == OSInfo.OSType.MACOSX) {
+ // On OS X, this area is commandeered by the system,
+ // and frame would be wildly resized
+ System.out.println("Not for OS X");
+ return;
+ }
mainThread = Thread.currentThread();
try
{
init();
}