Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
db6e972c
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
db6e972c
编写于
11月 21, 2011
作者:
R
rupashka
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
7109085: Test use hotkeys not intended for Mac
Reviewed-by: rupashka Contributed-by: alexandr.scherbatiy@oracle.com
上级
83d20ffd
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
438 addition
and
0 deletion
+438
-0
test/javax/swing/regtesthelpers/Util.java
test/javax/swing/regtesthelpers/Util.java
+13
-0
test/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java
...javax/swing/text/DefaultEditorKit/4278839/bug4278839.java
+154
-0
test/javax/swing/text/JTextComponent/5074573/bug5074573.java
test/javax/swing/text/JTextComponent/5074573/bug5074573.java
+159
-0
test/javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java
...vax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java
+112
-0
未找到文件。
test/javax/swing/regtesthelpers/Util.java
浏览文件 @
db6e972c
...
...
@@ -140,4 +140,17 @@ public class Util {
return
null
;
}
/**
* Hits keys by robot.
*/
public
static
void
hitKeys
(
Robot
robot
,
int
...
keys
)
{
for
(
int
i
=
0
;
i
<
keys
.
length
;
i
++)
{
robot
.
keyPress
(
keys
[
i
]);
}
for
(
int
i
=
keys
.
length
-
1
;
i
>=
0
;
i
--)
{
robot
.
keyRelease
(
keys
[
i
]);
}
}
}
test/javax/swing/text/DefaultEditorKit/4278839/bug4278839.java
0 → 100644
浏览文件 @
db6e972c
/*
* Copyright (c) 2011, 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 Jan 16, 2003
* @bug 4278839
* @summary Incorrect cursor movement between words at the end of line
* @author Anton Nashatyrev
* @library ../../../regtesthelpers
* @build Util
* @run main bug4278839
*/
import
java.awt.*
;
import
java.awt.event.*
;
import
javax.swing.*
;
import
sun.awt.SunToolkit
;
public
class
bug4278839
extends
JFrame
{
private
static
boolean
passed
=
true
;
private
static
JTextArea
area
;
private
static
Robot
robo
;
private
static
SunToolkit
toolkit
;
public
static
void
main
(
String
[]
args
)
{
try
{
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
robo
=
new
Robot
();
robo
.
setAutoDelay
(
100
);
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
createAndShowGUI
();
}
});
toolkit
.
realSync
();
clickMouse
();
toolkit
.
realSync
();
if
(
"Aqua"
.
equals
(
UIManager
.
getLookAndFeel
().
getID
()))
{
Util
.
hitKeys
(
robo
,
KeyEvent
.
VK_HOME
);
}
else
{
Util
.
hitKeys
(
robo
,
KeyEvent
.
VK_CONTROL
,
KeyEvent
.
VK_HOME
);
}
toolkit
.
realSync
();
passed
&=
moveCaret
(
true
)
==
1
;
passed
&=
moveCaret
(
true
)
==
5
;
passed
&=
moveCaret
(
true
)
==
8
;
passed
&=
moveCaret
(
true
)
==
9
;
passed
&=
moveCaret
(
true
)
==
13
;
passed
&=
moveCaret
(
true
)
==
16
;
passed
&=
moveCaret
(
true
)
==
17
;
passed
&=
moveCaret
(
false
)
==
16
;
passed
&=
moveCaret
(
false
)
==
13
;
passed
&=
moveCaret
(
false
)
==
9
;
passed
&=
moveCaret
(
false
)
==
8
;
passed
&=
moveCaret
(
false
)
==
5
;
passed
&=
moveCaret
(
false
)
==
1
;
passed
&=
moveCaret
(
false
)
==
0
;
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"Test failed because of an exception:"
,
e
);
}
if
(!
passed
)
{
throw
new
RuntimeException
(
"Test failed."
);
}
}
private
static
int
moveCaret
(
boolean
right
)
throws
Exception
{
Util
.
hitKeys
(
robo
,
getCtrlKey
(),
right
?
KeyEvent
.
VK_RIGHT
:
KeyEvent
.
VK_LEFT
);
toolkit
.
realSync
();
final
int
[]
result
=
new
int
[
1
];
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
result
[
0
]
=
area
.
getCaretPosition
();
}
});
int
pos
=
result
[
0
];
return
pos
;
}
private
static
void
clickMouse
()
throws
Exception
{
final
Rectangle
result
[]
=
new
Rectangle
[
1
];
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
result
[
0
]
=
new
Rectangle
(
area
.
getLocationOnScreen
(),
area
.
getSize
());
}
});
Rectangle
rect
=
result
[
0
];
robo
.
mouseMove
(
rect
.
x
+
rect
.
width
/
2
,
rect
.
y
+
rect
.
width
/
2
);
robo
.
mousePress
(
InputEvent
.
BUTTON1_MASK
);
}
/**
* Gets a control key related to the used Look & Feel
* Returns VK_ALT for Aqua and VK_CONTROL for others
*/
public
static
int
getCtrlKey
()
{
if
(
"Aqua"
.
equals
(
UIManager
.
getLookAndFeel
().
getID
()))
{
return
KeyEvent
.
VK_ALT
;
}
return
KeyEvent
.
VK_CONTROL
;
}
private
static
void
createAndShowGUI
()
{
JFrame
frame
=
new
JFrame
();
frame
.
setTitle
(
"Bug# 4278839"
);
frame
.
setSize
(
200
,
200
);
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
area
=
new
JTextArea
(
"\naaa bbb\nccc ddd\n"
);
frame
.
getContentPane
().
add
(
new
JScrollPane
(
area
));
frame
.
setVisible
(
true
);
}
}
test/javax/swing/text/JTextComponent/5074573/bug5074573.java
0 → 100644
浏览文件 @
db6e972c
/*
* Copyright (c) 2011, 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 5074573
* @summary tests delte-next-word and delete-prev-word actions for all text compnents and all look&feels
* @author Igor Kushnirskiy
* @run main bug5074573
*/
import
java.util.*
;
import
java.awt.Robot
;
import
java.awt.Toolkit
;
import
java.awt.event.*
;
import
javax.swing.*
;
import
javax.swing.text.*
;
import
sun.awt.SunToolkit
;
public
class
bug5074573
{
private
static
JTextComponent
textComponent
;
final
static
String
testString
=
"123 456 789"
;
final
static
String
resultString
=
"456 "
;
final
static
List
<
Class
<?
extends
JTextComponent
>>
textClasses
=
Arrays
.
asList
(
JTextArea
.
class
,
JEditorPane
.
class
,
JTextPane
.
class
,
JTextField
.
class
,
JFormattedTextField
.
class
,
JPasswordField
.
class
);
public
static
void
main
(
String
[]
args
)
throws
Exception
{
for
(
UIManager
.
LookAndFeelInfo
info
:
UIManager
.
getInstalledLookAndFeels
())
{
UIManager
.
setLookAndFeel
(
info
.
getClassName
());
System
.
out
.
println
(
info
);
for
(
Class
<?
extends
JTextComponent
>
clazz
:
textClasses
)
{
boolean
res
=
test
(
clazz
);
if
(!
res
&&
clazz
!=
JPasswordField
.
class
)
{
throw
new
RuntimeException
(
"failed"
);
}
}
}
}
static
boolean
test
(
final
Class
<?
extends
JTextComponent
>
textComponentClass
)
throws
Exception
{
SunToolkit
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
Robot
robot
=
new
Robot
();
robot
.
setAutoWaitForIdle
(
true
);
robot
.
setAutoDelay
(
50
);
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
initialize
(
textComponentClass
);
}
});
toolkit
.
realSync
();
// Remove selection from JTextField components for the Aqua Look & Feel
if
(
textComponent
instanceof
JTextField
&&
"Aqua"
.
equals
(
UIManager
.
getLookAndFeel
().
getID
()))
{
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
Caret
caret
=
textComponent
.
getCaret
();
int
dot
=
caret
.
getDot
();
textComponent
.
select
(
dot
,
dot
);
}
});
toolkit
.
realSync
();
}
robot
.
keyPress
(
getCtrlKey
());
robot
.
keyPress
(
KeyEvent
.
VK_BACK_SPACE
);
robot
.
keyRelease
(
KeyEvent
.
VK_BACK_SPACE
);
robot
.
keyRelease
(
getCtrlKey
());
toolkit
.
realSync
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
Caret
caret
=
textComponent
.
getCaret
();
caret
.
setDot
(
0
);
}
});
toolkit
.
realSync
();
robot
.
keyPress
(
getCtrlKey
());
robot
.
keyPress
(
KeyEvent
.
VK_DELETE
);
robot
.
keyRelease
(
KeyEvent
.
VK_DELETE
);
robot
.
keyRelease
(
getCtrlKey
());
toolkit
.
realSync
();
return
resultString
.
equals
(
getText
());
}
private
static
String
getText
()
throws
Exception
{
final
String
[]
result
=
new
String
[
1
];
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
@Override
public
void
run
()
{
result
[
0
]
=
textComponent
.
getText
();
}
});
return
result
[
0
];
}
/**
* Gets a control key related to the used Look & Feel
* Returns VK_ALT for Aqua and VK_CONTROL for others
*/
public
static
int
getCtrlKey
()
{
if
(
"Aqua"
.
equals
(
UIManager
.
getLookAndFeel
().
getID
()))
{
return
KeyEvent
.
VK_ALT
;
}
return
KeyEvent
.
VK_CONTROL
;
}
private
static
void
initialize
(
Class
<?
extends
JTextComponent
>
textComponentClass
)
{
try
{
JFrame
frame
=
new
JFrame
();
textComponent
=
textComponentClass
.
newInstance
();
textComponent
.
setText
(
testString
);
frame
.
add
(
textComponent
);
frame
.
pack
();
frame
.
setVisible
(
true
);
textComponent
.
requestFocus
();
Caret
caret
=
textComponent
.
getCaret
();
caret
.
setDot
(
textComponent
.
getDocument
().
getLength
());
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
test/javax/swing/text/html/HTMLEditorKit/5043626/bug5043626.java
0 → 100644
浏览文件 @
db6e972c
/*
* Copyright (c) 2007, 2011, 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 5043626
* @summary Tests pressing Home or Ctrl+Home set cursor to invisible element <head>
* @author Alexander Potochkin
* @library ../../../../regtesthelpers
* @build Util
* @run main bug5043626
*/
import
java.awt.Robot
;
import
java.awt.Toolkit
;
import
javax.swing.*
;
import
javax.swing.text.Document
;
import
javax.swing.text.BadLocationException
;
import
java.awt.event.KeyEvent
;
import
sun.awt.SunToolkit
;
public
class
bug5043626
{
private
static
Document
doc
;
private
static
Robot
robot
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
SunToolkit
toolkit
=
(
SunToolkit
)
Toolkit
.
getDefaultToolkit
();
robot
=
new
Robot
();
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
createAndShowGUI
();
}
});
toolkit
.
realSync
();
Util
.
hitKeys
(
robot
,
KeyEvent
.
VK_HOME
);
Util
.
hitKeys
(
robot
,
KeyEvent
.
VK_1
);
toolkit
.
realSync
();
String
test
=
getText
();
if
(!
"1test"
.
equals
(
test
))
{
throw
new
RuntimeException
(
"Begin line action set cursor inside <head> tag"
);
}
Util
.
hitKeys
(
robot
,
KeyEvent
.
VK_HOME
);
Util
.
hitKeys
(
robot
,
KeyEvent
.
VK_2
);
toolkit
.
realSync
();
test
=
getText
();
if
(!
"21test"
.
equals
(
test
))
{
throw
new
RuntimeException
(
"Begin action set cursor inside <head> tag"
);
}
}
private
static
String
getText
()
throws
Exception
{
final
String
[]
result
=
new
String
[
1
];
SwingUtilities
.
invokeAndWait
(
new
Runnable
()
{
public
void
run
()
{
try
{
result
[
0
]
=
doc
.
getText
(
0
,
doc
.
getLength
()).
trim
();
}
catch
(
BadLocationException
ex
)
{
ex
.
printStackTrace
();
}
}
});
return
result
[
0
];
}
private
static
void
createAndShowGUI
()
{
JFrame
frame
=
new
JFrame
();
frame
.
setDefaultCloseOperation
(
JFrame
.
EXIT_ON_CLOSE
);
JEditorPane
editorPane
=
new
JEditorPane
();
editorPane
.
setContentType
(
"text/html"
);
editorPane
.
setText
(
"test"
);
editorPane
.
setEditable
(
true
);
frame
.
add
(
editorPane
);
frame
.
pack
();
frame
.
setVisible
(
true
);
doc
=
editorPane
.
getDocument
();
editorPane
.
setCaretPosition
(
doc
.
getLength
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录