Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a8304d97
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
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看板
提交
a8304d97
编写于
1月 30, 2014
作者:
B
bagiras
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8013116: Robot moves mouse to point which differs from set in mouseMove on Unity shell
Reviewed-by: serb, azvegint
上级
3ccbcf21
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
171 addition
and
17 deletion
+171
-17
src/macosx/native/sun/awt/CRobot.m
src/macosx/native/sun/awt/CRobot.m
+2
-3
src/share/classes/java/awt/Robot.java
src/share/classes/java/awt/Robot.java
+6
-13
test/java/awt/Multiscreen/MultiScreenLocationTest/MultiScreenLocationTest.java
...reen/MultiScreenLocationTest/MultiScreenLocationTest.java
+110
-0
test/java/awt/regtesthelpers/Util.java
test/java/awt/regtesthelpers/Util.java
+53
-1
未找到文件。
src/macosx/native/sun/awt/CRobot.m
浏览文件 @
a8304d97
...
...
@@ -187,9 +187,8 @@ Java_sun_lwawt_macosx_CRobot_mouseEvent
// volatile, otherwise it warns that it might be clobbered by 'longjmp'
volatile
CGPoint
point
;
// Translate the device relative point into a valid global CGPoint.
point
.
x
=
mouseLastX
+
globalDeviceBounds
.
origin
.
x
;
point
.
y
=
mouseLastY
+
globalDeviceBounds
.
origin
.
y
;
point
.
x
=
mouseLastX
;
point
.
y
=
mouseLastY
;
__block
CGMouseButton
button
=
kCGMouseButtonLeft
;
__block
CGEventType
type
=
kCGEventMouseMoved
;
...
...
src/share/classes/java/awt/Robot.java
浏览文件 @
a8304d97
/*
* Copyright (c) 1999, 20
09
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 20
14
, 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
...
...
@@ -72,9 +72,6 @@ public class Robot {
private
int
autoDelay
=
0
;
private
static
int
LEGAL_BUTTON_MASK
=
0
;
// location of robot's GC, used in mouseMove(), getPixelColor() and captureScreenImage()
private
Point
gdLoc
;
private
DirectColorModel
screenCapCM
=
null
;
/**
...
...
@@ -132,7 +129,6 @@ public class Robot {
private
void
init
(
GraphicsDevice
screen
)
throws
AWTException
{
checkRobotAllowed
();
gdLoc
=
screen
.
getDefaultConfiguration
().
getBounds
().
getLocation
();
Toolkit
toolkit
=
Toolkit
.
getDefaultToolkit
();
if
(
toolkit
instanceof
ComponentFactory
)
{
peer
=
((
ComponentFactory
)
toolkit
).
createRobot
(
this
,
screen
);
...
...
@@ -200,7 +196,7 @@ public class Robot {
* @param y Y position
*/
public
synchronized
void
mouseMove
(
int
x
,
int
y
)
{
peer
.
mouseMove
(
gdLoc
.
x
+
x
,
gdLoc
.
y
+
y
);
peer
.
mouseMove
(
x
,
y
);
afterEvent
();
}
...
...
@@ -395,7 +391,7 @@ public class Robot {
* @return Color of the pixel
*/
public
synchronized
Color
getPixelColor
(
int
x
,
int
y
)
{
Color
color
=
new
Color
(
peer
.
getRGBPixel
(
gdLoc
.
x
+
x
,
gdLoc
.
y
+
y
));
Color
color
=
new
Color
(
peer
.
getRGBPixel
(
x
,
y
));
return
color
;
}
...
...
@@ -412,10 +408,7 @@ public class Robot {
public
synchronized
BufferedImage
createScreenCapture
(
Rectangle
screenRect
)
{
checkScreenCaptureAllowed
();
// according to the spec, screenRect is relative to robot's GD
Rectangle
translatedRect
=
new
Rectangle
(
screenRect
);
translatedRect
.
translate
(
gdLoc
.
x
,
gdLoc
.
y
);
checkValidRect
(
translatedRect
);
checkValidRect
(
screenRect
);
BufferedImage
image
;
DataBufferInt
buffer
;
...
...
@@ -441,14 +434,14 @@ public class Robot {
int
pixels
[];
int
[]
bandmasks
=
new
int
[
3
];
pixels
=
peer
.
getRGBPixels
(
translated
Rect
);
pixels
=
peer
.
getRGBPixels
(
screen
Rect
);
buffer
=
new
DataBufferInt
(
pixels
,
pixels
.
length
);
bandmasks
[
0
]
=
screenCapCM
.
getRedMask
();
bandmasks
[
1
]
=
screenCapCM
.
getGreenMask
();
bandmasks
[
2
]
=
screenCapCM
.
getBlueMask
();
raster
=
Raster
.
createPackedRaster
(
buffer
,
translatedRect
.
width
,
translatedRect
.
height
,
translated
Rect
.
width
,
bandmasks
,
null
);
raster
=
Raster
.
createPackedRaster
(
buffer
,
screenRect
.
width
,
screenRect
.
height
,
screen
Rect
.
width
,
bandmasks
,
null
);
SunWritableRaster
.
makeTrackable
(
buffer
);
image
=
new
BufferedImage
(
screenCapCM
,
raster
,
false
,
null
);
...
...
test/java/awt/Multiscreen/MultiScreenLocationTest/MultiScreenLocationTest.java
0 → 100644
浏览文件 @
a8304d97
/*
* Copyright (c) 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 8013116
@summary Robot moves mouse to point which differs from set in mouseMove on
Unity shell
@author Oleg Pekhovskiy
@library ../../regtesthelpers
@build Util
@run main MultiScreenLocationTest
*/
import
java.awt.AWTException
;
import
java.awt.Color
;
import
java.awt.Frame
;
import
java.awt.GraphicsConfiguration
;
import
java.awt.GraphicsDevice
;
import
java.awt.GraphicsEnvironment
;
import
java.awt.MouseInfo
;
import
java.awt.Point
;
import
java.awt.Rectangle
;
import
java.awt.Robot
;
import
java.awt.image.BufferedImage
;
import
test.java.awt.regtesthelpers.Util
;
public
class
MultiScreenLocationTest
{
private
static
final
Point
mouseOffset
=
new
Point
(
150
,
150
);
private
static
final
Point
frameOffset
=
new
Point
(
100
,
100
);
private
static
final
Color
color
=
Color
.
YELLOW
;
private
static
String
getErrorText
(
final
String
name
,
int
screen
)
{
return
name
+
" test failed on Screen #"
+
screen
+
"!"
;
}
public
static
void
main
(
String
[]
args
)
throws
AWTException
{
GraphicsEnvironment
ge
=
GraphicsEnvironment
.
getLocalGraphicsEnvironment
();
GraphicsDevice
[]
gds
=
ge
.
getScreenDevices
();
if
(
gds
.
length
<
2
)
{
System
.
out
.
println
(
"It's a multiscreen test... skipping!"
);
return
;
}
for
(
int
i
=
0
;
i
<
gds
.
length
;
++
i
)
{
GraphicsDevice
gd
=
gds
[
i
];
GraphicsConfiguration
gc
=
gd
.
getDefaultConfiguration
();
Rectangle
screen
=
gc
.
getBounds
();
Robot
robot
=
new
Robot
(
gd
);
// check Robot.mouseMove()
robot
.
mouseMove
(
screen
.
x
+
mouseOffset
.
x
,
screen
.
y
+
mouseOffset
.
y
);
Point
mouse
=
MouseInfo
.
getPointerInfo
().
getLocation
();
Point
point
=
screen
.
getLocation
();
point
.
translate
(
mouseOffset
.
x
,
mouseOffset
.
y
);
if
(!
point
.
equals
(
mouse
))
{
throw
new
RuntimeException
(
getErrorText
(
"Robot.mouseMove"
,
i
));
}
// check Robot.getPixelColor()
Frame
frame
=
new
Frame
(
gc
);
frame
.
setUndecorated
(
true
);
frame
.
setSize
(
100
,
100
);
frame
.
setLocation
(
screen
.
x
+
frameOffset
.
x
,
screen
.
y
+
frameOffset
.
y
);
frame
.
setBackground
(
color
);
frame
.
setVisible
(
true
);
robot
.
waitForIdle
();
Rectangle
bounds
=
frame
.
getBounds
();
if
(!
Util
.
testBoundsColor
(
bounds
,
color
,
5
,
1000
,
robot
))
{
throw
new
RuntimeException
(
getErrorText
(
"Robot.getPixelColor"
,
i
));
}
// check Robot.createScreenCapture()
BufferedImage
image
=
robot
.
createScreenCapture
(
bounds
);
int
rgb
=
color
.
getRGB
();
if
(
image
.
getRGB
(
0
,
0
)
!=
rgb
||
image
.
getRGB
(
image
.
getWidth
()
-
1
,
0
)
!=
rgb
||
image
.
getRGB
(
image
.
getWidth
()
-
1
,
image
.
getHeight
()
-
1
)
!=
rgb
||
image
.
getRGB
(
0
,
image
.
getHeight
()
-
1
)
!=
rgb
)
{
throw
new
RuntimeException
(
getErrorText
(
"Robot.createScreenCapture"
,
i
));
}
frame
.
dispose
();
}
System
.
out
.
println
(
"Test PASSED!"
);
}
}
test/java/awt/regtesthelpers/Util.java
浏览文件 @
a8304d97
/*
* Copyright (c) 2006, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 201
4
, 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
...
...
@@ -51,6 +51,7 @@ import java.awt.Toolkit;
import
java.awt.IllegalComponentStateException
;
import
java.awt.AWTException
;
import
java.awt.AWTEvent
;
import
java.awt.Color
;
import
java.awt.event.InputEvent
;
import
java.awt.event.WindowAdapter
;
...
...
@@ -184,6 +185,57 @@ public final class Util {
}
}
/**
* Tests whether screen pixel has the expected color performing several
* attempts. This method is useful for asynchronous window manager where
* it's impossible to determine when drawing actually takes place.
*
* @param x X position of pixel
* @param y Y position of pixel
* @param color expected color
* @param attempts number of attempts to undertake
* @param delay delay before each attempt
* @param robot a robot to use for retrieving pixel color
* @return true if pixel color matches the color expected, otherwise false
*/
public
static
boolean
testPixelColor
(
int
x
,
int
y
,
final
Color
color
,
int
attempts
,
int
delay
,
final
Robot
robot
)
{
while
(
attempts
--
>
0
)
{
robot
.
delay
(
delay
);
Color
screen
=
robot
.
getPixelColor
(
x
,
y
);
if
(
screen
.
equals
(
color
))
{
return
true
;
}
}
return
false
;
}
/**
* Tests whether the area within boundaries has the expected color
* performing several attempts. This method is useful for asynchronous
* window manager where it's impossible to determine when drawing actually
* takes place.
*
* @param bounds position of area
* @param color expected color
* @param attempts number of attempts to undertake
* @param delay delay before each attempt
* @param robot a robot to use for retrieving pixel color
* @return true if area color matches the color expected, otherwise false
*/
public
static
boolean
testBoundsColor
(
final
Rectangle
bounds
,
final
Color
color
,
int
attempts
,
int
delay
,
final
Robot
robot
)
{
int
right
=
bounds
.
x
+
bounds
.
width
-
1
;
int
bottom
=
bounds
.
y
+
bounds
.
height
-
1
;
while
(
attempts
--
>
0
)
{
if
(
testPixelColor
(
bounds
.
x
,
bounds
.
y
,
color
,
1
,
delay
,
robot
)
&&
testPixelColor
(
right
,
bounds
.
y
,
color
,
1
,
0
,
robot
)
&&
testPixelColor
(
right
,
bottom
,
color
,
1
,
0
,
robot
)
&&
testPixelColor
(
bounds
.
x
,
bottom
,
color
,
1
,
0
,
robot
))
{
return
true
;
}
}
return
false
;
}
public
static
void
waitForIdle
(
final
Robot
robot
)
{
// we do not use robot for now, use SunToolkit.realSync() instead
((
sun
.
awt
.
SunToolkit
)
Toolkit
.
getDefaultToolkit
()).
realSync
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录