Monkeyrunner“拖拽”命令使用了错误的坐标?这是一个错误吗?
我正在探索 Monkeyrunner 脚本环境,测试各种事件以确保我可以充分模拟我的应用程序。具体来说,我对“拖动”功能中使用的坐标有疑问。
连接 Monkeyrunner 但没有运行应用程序(即,仅坐在主屏幕上)时,输入以下命令将模仿左右“滑动”事件,将一个主屏幕向左移动。
device.drag((100,400),(500,400),0.15,5)
这效果很好。
该命令应该会产生相反方向的滑动……
device.drag((500,400),(100,400),0.15,5)
但事实并非如此。
但确实如此:
device.drag((400,400),(100,400),0.15,5)
为了进一步测试这一点,我下载了 "MagicMarker" 应用程序。这样我就可以准确地看到这些不同的触摸事件发生的位置。显然,除非我使用自己的应用程序,否则它不会让我截图,所以我只需要描述我在这里看到的内容。希望您能验证这一点或告诉我我错过了哪一步。
这个命令...
device.drag((100,400),(500,400),0.15,5)
...从左到右画一条水平线,穿过屏幕的中间。它正好位于我的摩托罗拉 Droid 屏幕的中央。两个端点都清晰可见,两端都有边距。
此命令...
device.drag((500,400),(100,400),0.15,5)
...应该是在相反方向(从右到左)绘制的同一条线,将线向右偏移 100px。第一个端点要么位于屏幕边缘,要么完全在屏幕外。我不知道。
令我困惑的是坐标似乎不一致。点 (500,400) 位于屏幕的垂直中心,如果用作左右拖动移动的端点,则稍微偏向右侧,但如果用作左右拖动移动的起点,则似乎完全超出屏幕拖动移动。
感觉这可能是 Monkeyrunner 环境中的一个错误。想法?
I'm exploring the Monkeyrunner scripting environment, testing various events to make sure I can adequately simulate my app. Specifically I have questions about the coordinates used in the "drag" function.
With Monkeyrunner connected but no app running (i.e., just sitting at the home screen), entering the following command will mimic a left-right "swipe" event, moving one home screen to the left.
device.drag((100,400),(500,400),0.15,5)
This works beautifully.
This command, then should produce a swipe in the opposite direction...
device.drag((500,400),(100,400),0.15,5)
...but it doesn't.
But this does:
device.drag((400,400),(100,400),0.15,5)
To further test this I downloaded the "MagicMarker" app. This way I can see exactly where these different touch events are occurring. Apparently it won't let me take a screenshot unless I'm using my own app, so I'll just have to describe what I'm seeing here. Hopefully you can verify this or tell me what step I'm missing.
This command...
device.drag((100,400),(500,400),0.15,5)
...draws a horizontal line from left to right, across the middle of my screen. It is exactly centered in my Motorola Droid's screen. Both endpoints are clearly visible with a margin on either end.
This command...
device.drag((500,400),(100,400),0.15,5)
...which should be the same line drawn in the opposite direction (right to left), draws the line offset by 100px to the right. The first endpoint is either at the edge of the screen or offscreen entirely. I can't tell.
What's puzzling me is that the coordinates don't seem consistent. The point (500,400) is in the vertical center of the screen and a bit off to the right if used as an endpoint in a left-right drag move, but seems to be offscreen entirely if used as a starting point in a right-left drag move.
It feels like this might be a bug in the Monkeyrunner environment. Thoughts?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这里有 2 个错误。一个在 MonkeyRunner 中,另一个在您的代码中。我在 Nexus S 上进行测试,屏幕尺寸为 480x800。 Driod 非常接近这个尺寸,我这样检查:
所以当你向右拖动时,你的最后一段(x=500)超出了屏幕边缘。当框架在拖动结束时收到“向上”事件时,它似乎恢复正常。
当您向右拖动时,您的第一个片段会超出屏幕,这是框架不喜欢的。由于它在屏幕外发生了“向下”事件,因此它会删除完成拖动的所有移动事件。
像这样拖动应该可以工作:
MonkeyRunner 中的错误是它删除了拖动命令的最后一部分。所以看起来它正在完成屏幕上的拖动,但实际上并没有。解决此问题的方法如下:https://review.source.android.com/21635
There are 2 bugs here. One in MonkeyRunner, the other in your code. I'm testing on Nexus S, and the screen size is 480x800. Driod is pretty close to that size I checked it like this:
So when you're dragging to the right, your last segment (at x=500) is off the edge of the screen. When the framework gets that "up" event at the end of the drag, it seems to recover OK.
When you're dragging to the right, your first segment is off the screen, which the framework doesn't like. Since it got a "down" event off-screen, it drops all the move events that complete the drag.
Doing you drags like this should work:
The bug in MonkeyRunner is that it dropped the last section of your drag command. So it looked like it was finishing the drag on the screen, but actually wasn't. The fix to this is here: https://review.source.android.com/21635